robsite

Modeselektor

The group draws heavily from IDM, glitch, electro and hip hop.
Modeselektor produces all its material with self-developed software in Max/MSP and MIDI controllers.

2000007 (Feat. TTC) ist mal sehr nice.

· musik ·

Object#andand

Praktisches gem von Reg Braithwaite mit dem Methoden-Aufrufe auf nil-Objekten abgefangen werden können.

# Ohne andand:
@user = User.find(1)
@address = @user ? @user.address : nil
# Mit andand:
@address = User.find(1).andand.address

Enthält außerdem noch tap zum leichten debugging:

# Original:
p [1, 2, 3].reverse.map {|x| x**2 }
# Debug durch Auseinanderrupfen und Zwischenvariable:
bla = [1, 2, 3].reverse
p bla
p bla.map {|x| x**2 }
# Debug mit tap:
p [1, 2, 3].reverse.tap {|d| p d }.map {|x| x**2 }

Einfach sudo gem install andand und

require 'rubygems'
require 'andand'

in den Code.

Ähnlich praktisch ist der tee-Befehl auf der Commandline:

ps aux | tee p.txt | more

ps aux gibt alle laufenden Prozesse aus, tee p.txt schreibt die Ausgabe von ps aux in die Datei p.txt und gibt sie weiter an more.

Update:

Rails 2.3 hat andand-ähnliche Funktionalität schon eingebaut: try

@address = User.find(1).try(:address) 

Mehr dazu: ozmm.org/posts/try.html

· command line, productivity, programming, rails, ruby ·

Rails: before_filter mit Parametern

Kleiner Rails Tipp: before_filter akzeptiert auch Blöcke. So kann man den Methoden leicht Parameter übergeben. Der Block bekommt als Parameter den aktuellen Controller:

before_filter {|c| c.do_stuff(param1, param2)}
· rails, webdev ·

You Need the [PHP] Community

Don’t develop in the dark; get out there and meet people. Programming is not just about how many lines you’ve written and what sort of fun tricks you’ve managed to employ. It’s about getting out there and sharing with fellow developers and making the connections and friendships that could save you down the line.

· php, webdev, weisheiten ·
Mastodon