Skip to content

Instantly share code, notes, and snippets.

View nolan's full-sized avatar

Nolan Meyers nolan

View GitHub Profile
@nolan
nolan / Set proper base font size
Created June 8, 2010 03:15 — forked from blaine/gist:428898
Set proper base font size
var setTextMeasure = function (contentElement, targetMeasure, maxSize, minSize) {
if (!contentElement) contentElement = document.createElement('p');
if (!targetMeasure) targetMeasure = 66;
if (!maxSize) maxSize = 16;
if (!minSize) minSize = 9;
var sizer = contentElement.cloneNode();
sizer.style.cssText = 'margin: 0; padding: 0; color: transparent; background-color: transparent; position: absolute;';
@nolan
nolan / .caprc
Created January 25, 2011 23:00
Working Growl Capistrano notifications for Snow Leopard
# ~/.caprc
# Loads all capistrano recipes in ~/.recipes/ folder
Dir["#{ENV['HOME']}/.recipes/*.rb"].each do |tasks|
load tasks
end
@nolan
nolan / notifo.rb
Created January 26, 2011 19:17
Capistrano Notifo notification recipe w/ growlnotify fallback
# ~/.recipes/growl.rb
#
# Notifo setup in deploy scripts:
# set :notifo_service "NOTIFO_SERVICE_NAME" # Only if different from :application
# set :notifo_service_secret "NOTIFO_API_SECRET" # Only if different from application name
# set :notifo_subscriber_list "username1, username2" # Define default below to your username
# set :notifo_hostname 'example.com' # Defaults to :server_hostname. Set to empty string to use Notifo default
require 'notifo' rescue nil
@nolan
nolan / longest.rb
Created December 18, 2012 15:32
Determine the length of the longest string in an array
def longest(a)
a.map(&:length).max
end
@nolan
nolan / flatten_vs_manual.rb
Last active December 12, 2015 06:48
Benchmark flatten vs manual array creation
require "benchmark"
n = 50000
a = ('A'..'Z').to_a
a = a.zip(a) # [["A", "A"], ["B", "B"], ["C", "C"]...]
Benchmark.bm(7) do |x|
x.report("manual:") { n.times do; a.map {|b| ['X', b[0], b[1]] }; end }
x.report("flatten:") { n.times do; a.map {|b| ['X', b].flatten }; end }
doctype html
/[if lt IE 7]
html.no-js.lt-ie9.lt-ie8.lt-ie7 lang="en"
/[if IE 7]
html.no-js.lt-ie9.lt-ie8 lang="en"
/[if IE 8]
html.no-js.lt-ie9 lang="en"
| <!--[if (gte IE 8)]<!-->
<html class="no-js"> <!--<![endif]-->
head
@nolan
nolan / currency regex
Created January 30, 2015 21:11
currency regex
/^\$?\-?([1-9]{1}[0-9]{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\-?\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\(\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))\)$/
@nolan
nolan / application.controller.js
Last active November 10, 2015 19:57
Child Component Render
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
widgets: function(){
return this.get('store').peekAll('widget');
}.property(),
actions: {
addWidget: function(){
{"bids": [
{
"line_item_id": "193781",
"amount": "0.1777"
},
{
"line_item_id": "193782",
"amount": "0.1931"
},
{