Skip to content

Instantly share code, notes, and snippets.

View epramono's full-sized avatar

Eric Pramono epramono

View GitHub Profile
@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));
}
@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 / PrependLinkToByword.js
Last active December 20, 2015 13:39
Installing this bookmarklet in Safari's Bookmarks Bar on your iPad will allow you to append a document named "Unitlted.txt" which is stored in iCloud with a Markdown-style hyperlink containing the currently selected text and the page URL. Once the hyperlink has been added, you will be redirected back to Safari automatically. For more information…
javascript:window.location=
'byword%3A%2F%2Fx-callback-url%2Fappend%3Flocation%3Dicloud%26name%3DUntitled.txt%26text%3D'+
encodeURIComponent("\n["+window.getSelection()+"]")+
encodeURIComponent("("+location.href+")\n")+
'%26x-success%3D'+encodeURIComponent(location.href)
@epramono
epramono / TravelPackingListInSilo
Last active December 20, 2015 14:29
A custom URL action in Drafts that allows you to create a packing list in Silo based on a comma-separated list stored in TextExpander Touch under the snippet <<travel>>. The default list will be appended with a comma-separated list you write in the [[body]] of your Drafts post. The [[title]] is reserved for the list title.
silo://x-callback-url/list_entity/add?
title=[[title]]&
notes={{<<ttravel>>}}[[body]]&
x-success={{drafts://}}
@epramono
epramono / TravelPackingListInClear
Created August 3, 2013 14:30
A custom URL action in Drafts that allows you to create a packing list in Clear based on a comma-separated list stored in TextExpander Touch under the snippet <<travel>>. The default list will be appended with a comma-separated list you write in the [[body]] of your Drafts post. The [[title]] is reserved for the list title.
clearapp://list/create?
listName=[[title]]&
tasks={{<<ttravel>>}}%20[[body]]
@epramono
epramono / TrackExpensesInGoogleSpreadsheet
Created August 3, 2013 14:37
A custom URL action in Drafts that creates a new entry in the default list of the Reminder app. The entry will be converted as a new row in a Google Spreadsheet file entitled "Expenses" using a specific IFTTT recipe. The Google Spreadsheet recipe uses ||| as the column separator.
drafts://x-callback-url/create?
text=Expenses%0A[[date|%-m/%-d/%y]]%7C%7C%7C[[date|%-I:%M:%S %p]]%7C%7C%7C[[line|1]]%7C%7C%7C[[line|2]]%7C%7C%7C[[line|3]]&
action=Reminder&
afterSuccess=Delete
@epramono
epramono / TrackGasFillUp
Created August 3, 2013 14:41
A custom URL action in Drafts that creates a new entry in the default list of the Reminder app. The entry will be converted as a new row in a Google Spreadsheet file entitled "Gas Fill Up" using a specific IFTTT recipe. The Google Spreadsheet recipe uses ||| as the column separator.
drafts://x-callback-url/create?
text=Gas%20Fill%20Up%0A[[date|%-m/%-d/%y]]%7C%7C%7C[[date|%-I:%M:%S %p]]%7C%7C%7C[[line|1]]%7C%7C%7C[[line|2]]%7C%7C%7C[[line|3]]%7C%7C%7C[[line|4]]&
action=Reminder&
afterSuccess=Delete
@epramono
epramono / MailLaterWithBody
Last active December 20, 2015 14:39
This action will prepare an email draft containing the recipient, subject and body, based on your Drafts post; and store it as a reminder in Due. The first line of your post will be treated as the email recipient, the second line as the email subject, and the third line as the date/time when you want to be reminded. The fourth line up to the end…
due://x-callback-url/add?
title=Mail%20about%20[[line|2]]%20at%20[[line|3]]%0A
{{launchpro-email://x-callback-url/?
to=[[line|1]]&
subject=[[line|2]]&
body=[[line|4..]]&
x-success=due%3A%2F%2F}}&
x-source=Drafts&
x-success={{drafts://}}
@epramono
epramono / AppendURLTitleQuoteToDrafts.js
Created August 4, 2013 00:07
This JavaScript bookmarklet will create a new post in Drafts containing the page title, URL and the current content of your clipboard.
javascript:window.location='drafts://x-callback-url/create?text='+
encodeURIComponent(document.title+'%5Cn')+
encodeURIComponent(location.href)+
'&action=Append%20with%20Clipboard&afterSuccess=Delete'
@epramono
epramono / AppGoneFree
Last active December 20, 2015 14:39
This action allows you to set a reminder in Due to search for an app that has just gone free. This is very useful if you're trying to download an app larger than 50 MB while you're on a 3G connection. As a bonus, you can share the news with your friends via Tweetbot. Requires: Drafts 3.0.6, Due 1.8, and Tweetbot 1.3.
due://x-callback-url/add?
title=Search%20for%20[[line|1]]%20at%20[[line|2]]%0A
{{http://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?
media=software&
term=[[line|1]]}}&
x-source=Tweetbot&
x-success=
{{tweetbot://epramono/post?
text=[[line|3]]%20[[line|1]]%20is%20free%20today.%0A%0A
http%3A%2F%2Fphobos.apple.com%2FWebObjects%2FMZSearch.woa%2Fwa%2Fsearch%3Fmedia%3Dsoftware%26term%3D[[line|1]]&