The Angular 1.2 way: # By default, angular returns undefined for invalid attributes which removes # the value from the form field's ngModel (which means it's not sent to the...

...empty string instead of undefined. for elementType in ['input', 'textarea', 'select'] @app.directive elementType, -> priority: 1 restrict: 'E' require: '?ngModel' link: (scope, element, attributes, ngModelController) -> return unless ngModelController if elementType == 'input...

...force this error by setting a short timeout and sleeping in the query: Timeout.timeout(1) { User.find_by_sql('SELECT sleep(2) FROM users;') } # All subsequent queries then will fail with...

...which you can read, write or mock local symbols: klass = (-> privateVariable = 0 privateMethod = -> privateVariable += 1 publicMethod = -> privateMethod() add: add knife: eval(Knife.point) )() klass.knife.get('privateVariable') => 0 klass.knife.set('privateCounter', 5) klass.knife.get('privateCounter...

...clean bundler environment and without spring. def run(cmd, timeout = nil) ENV['DISABLE_SPRING'] = '1' Bundler.with_clean_env { super } end end World(Customization) We're also disabling Spring because it...

1. Sometimes you have search entries in the autocomplete of the address bar, which are higher weighted than your bookmarks. Pressing SHIFT + DEL while searching removes them from the history...

...a key for your encrypted harddisk: dd if=/dev/random of=/home/bob/keyfile_sdb1 bs=4096 count=1 Then add your keyfile to encrypted harddisk: How to change your dm-crypt passphrase (step...

full_path = File.expand_path attachment # find id to update id = full_path.match(/(\d+)\/original\/.+$/)[1] puts "Re-saving ##{id}..." your_model = YOURMODEL.find(id) # Paperclip will re-save the attachment using...

Note: This applies to plain Ruby scripts, Rails does not have this issue. When you work with Ruby strings, those...

...characters incorrectly and only outputs correct UTF-8 when you switch to Latin 1 (!). Also you need to setup charset and collation manually for each new database. To prevent this...

makandra dev

globstar off In that case, ** behaves just like * and will match exactly 1 directory level. $ ls spec/**/*_spec.rb spec/models/user_spec.rb To enable it, run shopt -s globstar

makandra dev
tldp.org

...the linked article.) Basic 0/1/2 references stdin/stdout/stderr >/2> redirects stdout/stderr, where > is taken as 1> &1/&2 references stdout/stderr &> redirects stdout and stderr = everything (caution: see below) Caution: &> is functional...

...when redirecting output in Ruby scripts. Instead of cmd &> file, prefer cmd > file 2>&1, which equals: "Redirect stdout of cmd to file, and redirect stderr just where stdout is...

...versions no longer include the ActiveRecord adapter (which is part of ActiveRecord since Rails .1). So your Gemfile should say:

...will return a list of their IDs: User.last.collect_ids # => [9] [User.first, User.last].collect_ids # => [1, 9] User.active.collect_ids # => [4, 5, 6] [4, 5, 6].collect_ids # => [4, 5, 6]

redis.io

...reproduced (like cached values). If you store data that you want to keep for 1 year or so, you must keep in mind that this data may disappear sooner.

Enable ip traffic forwarding: Open /etc/sysctl.conf Uncomment the line net.ipv4.ip_forward=1 Reload using sudo sysctl -p /etc/sysctl.conf Reconfigure ip_tables to allow NAT: Download the attached...

$helper.prependTo('body').text('click me').css({ zIndex: 9999, position: 'absolute' }); setTimeout(function() { $helper.remove() }, 1000); JAVASCRIPT find("##{id}").click Note that the link tag is removed after 1 second. You...

...application details. Consider the following: ActiveRecord::RecordNotFound: Couldn't find Organisation::Membership with 'id'=12 [WHERE "organisation_memberships"."user_id" = 1] You should probably not simply render those error messages...

...issue but it turns crazy if you try to include associated models deeper than 1 level: options = params.merge(:include => { :user => :avatar }) Post.paginate options When inspecting the merged params you will...

...I've got this message because the RAM Quota was exceed: 2013-11-11 17:13:25 WARNING nova.compute.api [req-bdasdfas-f5d7-4fcd-bf1b-asdfasdf229e ba2c21dadasdfasdf1d6asdfasdfa0f bfe2db2aasdfasdfb8ea686asdfasdfb] Quota exceeded for...

...bfe2db2aasdfasdfb8ea686asdfasdfb, tried to run 1 instances. Cannot run any more instances of this type. 2013-11-11 17:13:25 INFO nova.api.openstack.wsgi [req-bd003113-f5d7-4fcd-bf1b-asdfasdf229e ba2c21dadasdfasdf1d6asdfasdfa0f bfe2db2aasdfasdfb8ea686asdfasdfb...

comment = Comment.build(title: 'Bikini Bottom', content: 'Burgers for free', user_id: 1) comment.valid? => true comment.save => ActiveRecord::InvalidForeignKey Exception

github.com

>> JSON.parse(json) JSON::ParserError: 757: unexpected token at '"foo"' from /.../gems/json-1.7.7/lib/json/common.rb:155:in `parse' from /.../gems/json-1.7.7/lib/json/common.rb:155:in `parse' from (irb):1 Why? The error above happens...

...Linux will only use swap if *no* other memory is available sudo sysctl vm.swappiness 1 # Linux will try to avoid swap whenever possible The default value of the swappiness parameter...

There are many fun Unicode characters like ▲ or ☯. You might be tempted to use them for graphical elements in lieu...

...load a User and change both its group and its group_id: user = User.find(1) user.group = Group.find(3) user.group # returns # user.group_id = 4 user.group_id # returns 4 user.save