Skip to content

Instantly share code, notes, and snippets.

View masonhensley's full-sized avatar
🤠
Workin at Caris

Mason Hensley masonhensley

🤠
Workin at Caris
View GitHub Profile
@anhang
anhang / localStorage.js
Created July 20, 2011 23:07
HTML5 Local Storage with Expiration
AZHU.storage = {
save : function(key, jsonData, expirationMin){
if (!Modernizr.localstorage){return false;}
var expirationMS = expirationMin * 60 * 1000;
var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS}
localStorage.setItem(key, JSON.stringify(record));
return jsonData;
},
load : function(key){
if (!Modernizr.localstorage){return false;}
@appcdr
appcdr / app.js
Created August 29, 2011 15:45
Appcelerator: HTTPClient and JSON sample app
Ti.UI.backgroundColor = '#dddddd';
var url = "https://raw.github.com/appcelerator/Documentation-Examples/master/HTTPClient/data/json.txt";
var win = Ti.UI.createWindow();
var table = Ti.UI.createTableView();
var tableData = [];
var json, fighters, fighter, i, row, nameLabel, nickLabel;
var xhr = Ti.Network.createHTTPClient({
onload: function() {
@friggeri
friggeri / haiku
Created October 6, 2011 07:30
random heroku-like name generator
haiku = ->
adjs = [
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",
@tmeasday
tmeasday / css_splitter.rb
Created January 7, 2012 02:20
A modified CSS splitter that allows you to extract a single part.
# copied from https://gist.github.com/1131536, thanks christian peters.
module CssSplitter
def self.split(infile, outdir = File.dirname(infile), max_selectors = 4095)
charset_statement, rules = self.read_rules(infile)
return if rules.nil?
self.partition_rules(rules, max_selectors).each_with_index do |ruleset, index|
next if index == 0 # no need to write out the first file
@ryandotsmith
ryandotsmith / event_buffering.md
Created February 14, 2012 04:10
event buffering

Event Buffering

Eventually platforms outgrow the single-source-tree model and become distributed systems. A common pattern in these distributed systems is distributed composition via event buffering. Here we motivate and describe this event buffering pattern.

The Problem

@jrochkind
jrochkind / gist:2161449
Created March 22, 2012 18:40
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@ChristianPeters
ChristianPeters / config-application.rb
Created April 16, 2012 12:29
Adapted for Rails Asset Pipeline: Split CSS files so that there are no more than a given number of selectors in one style sheet. This is a tool to cope with Internet Explorer's limitation of max. 4095 selectors per stylesheet.
#...
module MyProject
class Application < Rails::Application
config.assets.precompile += %w( ie6.css ie6_portion2.css ie7.css ie7_portion2.css ie8.css ie8_portion2.css ie9.css ie9_portion2.css)
#...
@borgand
borgand / application_helper.rb
Created May 8, 2012 11:32
Rails HAML helper method to display Twitter Bootstrap alert boxes
module ApplicationHelper
# Display alert box with message or optional block
def alert_box(alert_type = :info)
haml_tag :div, :class => 'row-fluid' do
haml_tag :div, :class => "span9 alert alert-#{alert_type}" do
haml_tag :a, '×', :class => 'close', :'data-dismiss' => 'alert'
block_given? ? yield : msg
end
end
@harperreed
harperreed / NestThermostat.py
Created September 30, 2012 21:54
Nest python class
#! /usr/bin/env python
# -*- coding: utf-8 -*-
####################
# from
# https://github.com/johnray/Indigo-Nest-Thermostat-Plugin
# Copyright (c) 2012, Perceptive Automation, LLC. All rights reserved.
# http://www.perceptiveautomation.com
import os
import sys
@briangonzalez
briangonzalez / README.md
Created October 21, 2012 04:25
img2boxshadow - a ruby script to convert images to CSS [http://codepen.io/briangonzalez/details/AvrGI#pen-details-tab]

img2boxshadow.rb

a ruby script to convert images to CSS (box-shadows)

Installation

gem install rmagick    # you'll need ImageMagick & Ruby first
gem install colormath
gem install micro-optparse