This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
message_file = ARGV[0] | |
def app_is_running?(app_name) | |
`ps aux` =~ /#{app_name}/ ? true : false | |
end | |
while true | |
if app_is_running?('Rdio.app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generate_coordinates = (rows, columns) -> | |
generated_coordinates = [] | |
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('') | |
for i in [1..rows] | |
for n in [0..(columns-1)] | |
a = if n < 26 then alphabet[n] else alphabet[Math.floor(n/26)-1] + alphabet[n%26] | |
generated_coordinates.push(a + i) | |
coordinates = generate_coordinates(8, 63) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SheetLogger = function() {} | |
SheetLogger.prototype = { | |
set_cell: function(sheet_name, range, value) { | |
var sheet = SpreadsheetApp.getActive().getSheetByName(sheet_name); | |
sheet.getRange(range).setValue(value); | |
}, | |
append_row_to_sheet: function(sheet_name, value) { | |
var sheet = SpreadsheetApp.getActive().getSheetByName(sheet_name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Github = function(token) { | |
this.token = token; | |
this.api_url = 'https://api.github.com/' | |
} | |
Github.prototype = { | |
parseISO8601: function(str) { | |
// http://anentropic.wordpress.com/2009/06/25/javascript-iso8601-parser-and-pretty-dates/ | |
// we assume str is a UTC date ending in 'Z' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ducksboard = function(token) { | |
this.token = token; | |
this.api_url = 'https://push.ducksboard.com/v/' | |
} | |
Ducksboard.prototype = { | |
send: function(endpoint, payload) { | |
var options = { | |
method: 'post', | |
headers: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple method to detect a mobile device | |
function isMobile(){ | |
return (/iphone|ipod|android|blackberry/).test(navigator.userAgent.toLowerCase()); | |
} | |
// Example usage: | |
if(isMobile()){ | |
console.log('This is a mobile device.'); | |
} else { | |
console.log('This is not a mobile device'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# looks up a set(s) of hashes in redis given the set name as a string | |
# and redis stores the ids of the sets members and hashes are stored at their id | |
### | |
example redis data structure: | |
users => ['1','2','3'] // all ids of all user objects | |
users:2 => {'name':'Bob'} // a redis hash of the user with id == 2 | |
usage example at the bottom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dow = 3 # for Wednesday | |
this_year = today.getUTCFullYear() | |
next_year = this_year+1 | |
wednesdays = [] | |
days_in_month = (month, year) -> | |
32 - new Date(year, month, 32).getDate() | |
year_number = this_year | |
while year_number <= next_year |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%script#instagram-thumbnail-popover{type: "text/x-handlebars-template"} | |
%img{src: "{{images.low_resolution.url}}"}/ | |
%i.icon-heart/ | |
{{likes.count}} likes | |
%script#instagram-thumbnails{type: "text/x-handlebars-template"} | |
%ul.thumbnails | |
{{#data}} | |
%li.span1 | |
%a.thumbnail{href: "{{link}}", title: "{{caption.text}}", data: {content:"{{> popover}}"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flickr = require './flickr' | |
photos = flickr.results.photos.photo | |
# Example input object | |
### | |
id: 6711220011 | |
owner: 43769855@N02 | |
secret: fa596d04c5 | |
server: 7162 | |
farm: 8 |