Skip to content

Instantly share code, notes, and snippets.

View epramono's full-sized avatar

Eric Pramono epramono

View GitHub Profile
@epramono
epramono / Create URL Action
Created March 8, 2013 17:19
This is a custom URL Action for Drafts 2.5.x that allows you to create a new custom URL action based on the [[title]] and [[body]] of your current [[draft]]. The [[title]] will be used as the name of the new custom URL action, and the [[body]] will be used as the URL that will be invoked when the action is triggered. It is advised that the [[bod…
drafts://x-callback-url/import_action?type=URL&name=Create%20URL%20Action&url=drafts%3A%2F%2Fx-callback-url%2Fimport_action%3Ftype%3DURL%26name%3D%5B%5Btitle%5D%5D%26url%3D%5B%5Bbody%5D%5D
@epramono
epramono / tryruby04-block
Created August 27, 2012 08:31
TryRuby Level 4
# Ruby style
books.values.each { |rate| ratings[rate] += 1 }
# Java style
for (Object rate : books.getValues()) {
Integer count = ratings.get (rate);
if (count != null) ratings.put (rate, new Integer(count.intValue() + 1))
else ratings.put (rate, new Integer(1));
}