Skip to content

Instantly share code, notes, and snippets.

View stevenschobert's full-sized avatar

Steven Schobert stevenschobert

View GitHub Profile
@stevenschobert
stevenschobert / instafeed_wrap_fourth.js
Created December 18, 2014 18:32
Instafeed.js - Wrap every 4th item with a tag
var count = 0;
var feed = new Instafeed({
filter: function(image) {
count += 1;
if (count % 4 === 0) {
image.customTagOpen = '<div>';
image.customTagClose = '</div>';
} else {
image.customTagOpen = '';
@stevenschobert
stevenschobert / clone.js
Last active August 29, 2015 14:12
Object Cloning (with deep support) - modeled after Lodash's _.clone implementation. Supports strings, numbers, booleans, dates, regexps, objects, and arrays.
function clone(value, deep) {
var boo = '[object Boolean]';
var num = '[object Number]';
var str = '[object String]';
var obj = '[object Object]';
var arr = '[object Array]';
var date = '[object Date]';
var reg = '[object RegExp]';
var cloned;
var klass;
@stevenschobert
stevenschobert / omnifocus-open-inbox.scpt
Last active August 29, 2015 14:13
Quickly open my "Inbox" and "Today" perspectives in OmniFocus
tell application "OmniFocus" to activate
tell application "System Events"
tell process "OmniFocus"
set perspectivesMenu to the first menu bar item of item 1 of menu bars whose name contains "Perspectives"
set inboxMenuItem to the first menu item of the first menu of perspectivesMenu whose name is "Inbox"
set viewMenu to the first menu bar item of item 1 of menu bars whose name contains "View"
click inboxMenuItem
@stevenschobert
stevenschobert / get_dock_dimensions.scpt
Created January 18, 2015 04:43
Get the dimensions of the OS X dock using AppleScript
tell application "System Events" to tell process "Dock"
set dock_dimensions to size in list 1
set dock_width to item 1 of dock_dimensions
set dock_height to item 2 of dock_dimensions
end tell
@stevenschobert
stevenschobert / import.sh
Last active August 29, 2015 14:22
Importing data from Heroku PostgeSQL application
heroku pg:backups capture
# replace BACKUP_NUM with backup number from above
heroku pg:backups public-url BACKUP_NUM
# replace URL with step from above
curl -o latest.dump URL
# replace LOCAL_DB_NAME with local database table
# replace DB_USERNAME with db user
@stevenschobert
stevenschobert / templar.coffee
Created December 3, 2012 22:33
Quick 'n Easy template parser in CoffeeScript
# ------------------------------------------------------
# Really simple template parser in CoffeeScript.
# Matches {{keyword}} syntax.
# Input: string, object
# Output: string
#
# Ex: templar("Hello {{planet}}!", {planet: "World"});
# -> outputs "Hello World!"
# ------------------------------------------------------
templar = (input, data) ->
@stevenschobert
stevenschobert / rack_counter.ru
Last active November 10, 2015 22:46
Rack powered counter JSON API. For testing purposes.
require 'rack'
require 'json'
COUNTERS = {}
app = Proc.new do |env|
req = Rack::Request.new(env)
COUNTERS[req.path] ||= 0
@stevenschobert
stevenschobert / onAir.js
Last active December 13, 2015 19:28
Run a podcast? Here's a little JavaScript function to test if your show is currently "On the Air".
/**
* onAir.js
*
* @param {string} day [the day your show airs (eg. "Tuesday")]
* @param {string} start [start time of the show in 24hr format (eg. "13:00")]
* @param {string} end [stop time of the show in 24hr format (eg. "14:30")]
* @param {string} timezone [the UTC time zone of your show (eg. "-6" for Central Time)]
* @return {bool}
*/
var onAir = function (day, start, end, timezone) {
@stevenschobert
stevenschobert / plainModule.js
Last active December 25, 2015 19:09
Pattern for exporting a plain JS module (when not using AMD/CommonJS). Pulled from O'Reilly's "Programming JavaScript Applications".
// Optional object namespace
var app = {};
(function (exports) {
(function (exports) {
// module exports
exports.moduleName = {
@stevenschobert
stevenschobert / package.sampe.json
Created November 6, 2013 16:23
My starter package.json
{
"name": "http-server",
"version": "0.0.0",
"author": "Steven Schobert <spschobert@gmail.com>",
"description": "let there be javascripts",
"scripts": {
"start": "node ./bin/http-server",
"test": "vows --spec --isolate",
"predeploy": "echo This will be run before deploying the app",
"postdeploy": "echo This will be run after deploying the app"