Archive for Note to self
November 28, 2011 at 7:33 pm · Filed under Note to self, Ruby
You use two heroku apps as staging and production for your project. You added both as git remotes, e.g. “production” and “staging”.
Now you want to push your local branch “poster” to remote “staging”, use
git push staging poster:master
Note, that you can only push to “master” on herokus side. This is just git syntax, but I keep forgetting it, so here it is for future reference.
Oktober 7, 2010 at 8:49 am · Filed under Note to self, Ruby
Sometimes you may wish to map an Array to a Hash in Ruby, like say, you got the output of I18n.available_locales
locales = [:en, :de, :fr]
and want to transform that into a Hash to fill a select element, like so:
[:en => 'EN', :de => 'DE', :fr => 'FR']
How do you do that in the most concise way?
First, there is always inject:
locales.inject({}) {|hsh, sym| hsh[sym] = sym.to_s.upcase; hsh}
But I like the following approach way better, mainly because it emphasizes my intention more clearly (and, btw. is faster too):
Hash[locales.map{|sym| [sym, sym.to_s.upcase]}]
Remember: Hash[:a,:b,:c,:d] produces {:a => :b, :c => :d}.
Oktober 18, 2009 at 5:46 pm · Filed under Allgemein, MacOSX, Note to self, Ruby
Suche nach Wort unter dem Cursor in vim: #.
jssh ist eine JavaScript Shell, die den Firefox per Port 9997 fernsteuerbar macht.
Download z.B. hier.
y erzeugt einen YAML dump auf der Rails console, mehr dazu hier.
=3D ist ein escaptes “=” in quoted_printable.
sudo /usr/libexec/locate.updatedb aktualisiert unter MacOSX sofort die locate Datenbank.
rake db:migrate:redo führt unter rails die letzte Migration rückwärts und sofort wieder vorwärts aus, so dass sich die Vorwärts-Action korrigieren läßt
ack -Q bringt ack dazu, literal, also ohne RegExp zu suchen.
Oktober 1, 2009 at 11:24 am · Filed under MacOSX, Note to self
In den single user mode (root shell) starten, beim Neustart:
[CMS] s
In den verbose mode (boot log) starten:
[CMD] v
In den safe mode (nur core kexts) starten:
[SHIFT]
August 27, 2009 at 11:01 am · Filed under Note to self
find . -newerBt '10 minutes ago' -depth 1 -print 2>/dev/null