Skip to content

Instantly share code, notes, and snippets.

View tbeseda's full-sized avatar
🐀
womp rat

Taylor Beseda tbeseda

🐀
womp rat
View GitHub Profile
@tbeseda
tbeseda / commit-msg
Created March 24, 2014 18:26
Append current Rdio track to commit message
#!/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')
@tbeseda
tbeseda / spreadsheet_coordinates.coffee
Created October 3, 2013 23:07
Given a number of rows and columns generate spreadsheet style coordinates. i.e. [A1, B1, C1...BJ9, BK9, BL9]
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)
@tbeseda
tbeseda / Logger.js
Last active December 19, 2015 01:59
The utility I use to insert data into a Google Spreadsheet with Google Apps Script
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);
@tbeseda
tbeseda / Github.js
Created June 27, 2013 20:15
Grab some data from Github with Google Apps Scripts
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'
@tbeseda
tbeseda / Ducksboard.js
Last active December 19, 2015 01:58
Update Ducksboard slots from a Google Apps Script.
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: {
@tbeseda
tbeseda / isMobile.js
Last active December 11, 2015 10:48
// 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');
# 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
@tbeseda
tbeseda / wednesdays.coffee
Created June 6, 2012 22:10
Get each Wednesday for the rest of this year and all of next
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
@tbeseda
tbeseda / _instagram_thumbnail_handlebars_template.haml
Created May 22, 2012 22:24
How I do one-off front-end templating with Handlebars, HAML, and CoffeeScript.
%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}}"}}
@tbeseda
tbeseda / flickr_scraper.coffee
Created March 8, 2012 16:22
Scrape Flickr User's Photos to a Concise JSON Object
flickr = require './flickr'
photos = flickr.results.photos.photo
# Example input object
###
id: 6711220011
owner: 43769855@N02
secret: fa596d04c5
server: 7162
farm: 8