Posts

ruby on rails - Validate object based on the owner its parent -

i have has_many through association setup between artist , album models. add album has_many tracks. tracks have has_many through association between artists (i.e. featured artist ) feature model serves join table. i want prevent album artist(s) being featured artist on track. instance: album = album.find_by(name: "justified") track = album.track.first artist = artist.find_by(name: "justin timberlake") track.featured_artists << artist # ^^ should raise error since justin timberlake album's artist model setup class album < activerecord::base has_many :album_artists has_many :artists, through: :album_artists end class track < activerecord::base belongs_to :album has_many :features has_many :featured_artists, through: :features, class_name: "artist", foreign_key: "artist_id" end class albumartist < activerecord::base belongs_to :album belongs_to :artist validates_uniqueness_of :artist_id, sco...

command line - How do I use the -I option of du to ignore all files of a given type? -

hello running os x. i trying use du , -i option ignore files of given type. resorting -i because os x du doesnt include "exclude" option. essentially trying find os x equivalent command: du -ah --exclude="*.txt" /directory/folder

filemaker - How can I show a specific record near the top in list view without screen flicker? -

i have script (in filemaker 14) sets variable, $_record_number , get ( recordnumber ) based on specific criterion. once it's been set, want bring record top in list view. (it's possible criterion never fulfilled , $_record_number empty.) the portion of script looks following: go record/request/page [ last ] refresh window [] go record/request/page [ no dialog ; max ( $_record_number ; 1 ) ] when refresh window step isn't present, script doesn't work correctly. instead of bringing record top of list view, brings bottom. unfortunately, refresh window step causes window flicker script redraws layout. is there way duplicate end results of above steps without using refresh window , avoid screen redraw? failed techniques i've tried: using refresh object instead of refresh window targeting objects in both header , body using go related record relationship target record if you're using filemaker 13 or higher, can try refresh object ...

ajax - i have used datepicker but it always store date like 1970-01-01 -

can 1 please me? used date picker date , select today stores 1970-01-01 . $("#datepicker-1").datepicker(); }); and in php file stored in database: $dt=$_post['date']; $dt1=date('y-m-d',strtotime($dt)); but stores 1970-01-01 no matter date choose. please me.

javascript - node.js - making result available globally (Request module) -

i'm trying process returned json result request need expand scope outside request call. declared data variable empty string , assign result data doesn't print result. how can accomplish this? module.exports = function(callback) { var request = require("request") var url = "http://sheetsu.com/apis/94dc0db4" var data = ""; request({ url: url, json: true }, function (error, response, body) { if (!error && response.statuscode === 200) { callback(body) data = body; } }) console.log(data); } your script executed in order: request() executed console.log(data) request() callback function, asign data value if want print data , must inside request callback function. async module, useful when performing async tasks, specially if need perform tasks in specific order , use data requests.

JSQMessagesViewController animated typing indicator -

i'm working on project uses jsqmessagesviewcontroller library. has animated typing indicator, , if share approach? thanks! you want jsqtypingindicatorfooterview here documentation. http://cocoadocs.org/docsets/jsqmessagesviewcontroller/7.2.0/classes/jsqmessagestypingindicatorfooterview.html you can set ellipsiscolor messagebubblecolor color of bubble self. shoulddisplayonleft decide if should on left or right. collectionview collection view should show on.

ReactJs - Uncaught TypeError: Cannot read property 'string' of undefined -

my 2 files: app: import react, { component } 'react'; import { nice, super_nice } './colors'; import counter './counter'; export class app extends component { render() { return ( <div> <counter increment={ 1 } color={ nice } /> <counter increment={ 5 } color={ super_nice } /> </div> ); } } counter: import react, { component } 'react'; class counter extends component { constructor(props) { super(props); this.state = { counter: 0 }; this.interval = setinterval(() => this.tick(), 1000); } tick() { this.setstate({ counter: this.state.counter + this.props.increment }); } componentwillunmount() { clearinterval(this.interval); } render() { return ( <h1 style={ { color: this.props.color } }> counter ( { this.props.increment } ): { this.state.counter } </h1> ); } } counter.defaultprops = { i...