Skip to content

Instantly share code, notes, and snippets.

View 10io's full-sized avatar

David Fernandez 10io

View GitHub Profile
@10io
10io / .rubocop.yml
Created December 9, 2014 14:25
Rubocop
# Common configuration.
AllCops:
# Include gemspec and Rakefile
Include:
- '**/*.gemspec'
- '**/*.podspec'
- '**/*.jbuilder'
- '**/*.rake'
- '**/*.opal'
- '**/Gemfile'
@10io
10io / readline_2.0.0.patch
Last active August 29, 2015 13:59
readline patch for ruby-install ruby-2.1.0
--- ext/readline/readline.c 2014-04-17 11:27:45.000000000 +0200
+++ ext/readline/readline.c 2014-04-17 11:27:57.000000000 +0200
@@ -1886,7 +1886,7 @@
rl_attempted_completion_function = readline_attempted_completion_function;
#if defined(HAVE_RL_PRE_INPUT_HOOK)
- rl_pre_input_hook = (Function *)readline_pre_input_hook;
+ rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
#endif
#ifdef HAVE_RL_CATCH_SIGNALS
@10io
10io / shell.sh
Last active December 30, 2015 08:29
Diff config vars on Heroku between staging and production. I use remote branch names (-r), you can also use the application name directly (-a)
$ diff <(heroku config -s -r staging | cut -f1 -d "=") <(heroku config -s -r production | cut -f1 -d "=")
@10io
10io / Ember Tips.md
Last active December 18, 2015 16:39
Ember.js tips
  • Do not try to return properties from controllers, return the whole object.
    • Eg: If you want to read a property of the first object of hasMany: do not return elements.firstObject.property. The hasMany are lazily loaded, thus not visible for models/controllers! The correct way is this: return the firstObject as computed property(elements.@each) and in the view bind the property. This way when the collection is lazy loaded, the view is notified and will update.
  • Caution with collections in computed properties. You can observe the collection pointer or the collection elements(using @each)! They are different. Observing the collection pointer will notify when the collection is replaced or deleted, but not when an item is added! For this, you need to use @each.
  • Displaying multiple model type on the same page is done with render(you can do it also with outlets but less clean).
  • Observing a collection in order to apply a JQuery plugin is done using a CollectionView with a function observing content. In t
@10io
10io / View ST2 commands
Created May 10, 2013 09:15
View ST2 commands
* open the console
* sublime.log_commands(True)
* profit
Credits:
http://stackoverflow.com/a/11837792
@10io
10io / unicode.rb
Created May 3, 2013 09:03
Convert any non ASCII char to their Unicode code point: Héllo -> H\u00e9ello
string.gsub(/[^\x00-\x7F]/) { |non_ascii| "\\u#{"%4.4x" % non_ascii.ord}" }
@10io
10io / show backtrace
Created May 1, 2013 11:02
Show backtrace from ruby debugger on ruby 1.9, see https://github.com/cldwalker/debugger/issues/16
pp caller.drop_while {|e| e[/ruby-debug|\(eval\)|debugger|\<internal:prelude\>/] }