Skip to content

Instantly share code, notes, and snippets.

View nybblr's full-sized avatar
I help developers craft their best work, achieve goals, and never stop growing.

Jonathan Lee Martin nybblr

I help developers craft their best work, achieve goals, and never stop growing.
View GitHub Profile
rf- / validator.rb
Created April 6, 2012 19:57
Demonstrate validation of arbitrary fields (e.g., hstore)
View validator.rb
#!/usr/bin/env ruby
require 'active_record'
:adapter => 'sqlite3',
:database => ':memory:'
ActiveRecord::Schema.define do
brandonb927 /
Last active November 28, 2023 03:13
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see
# Alot of these configs have been taken from the various places
# on the web, most from here
agnoster /
Last active November 28, 2023 12:46
My ZSH Theme


A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

brentjanderson / adapter.js
Last active October 23, 2019 19:12
NOTE: Not updated since early 2013 - likely will not work with modern EmberData. Ember.JS, ember-data, and adapter. Not as primitive as the initial version and it supports object creation/deletion/etc. Does not support bulk updates like the first one just to keep it simple. Does support ember-data revision 11 and does support queries/f…
View adapter.js
/*jshint browser:true */
/*global DS:true, io:true, App:true */
(function() {
'use strict';
// Initializer for Models
window.Models = {};
console.warn("Don't pollute the global namespace with Models!");
oivoodoo / nested_attributes_parameters.rb
Created July 25, 2013 14:12
Enabled not numeric ids for the nested attributes using strong parameters
View nested_attributes_parameters.rb
require 'delegate'
# Because of using guid ids for the nested attributes we should define
# custom permit method. By default strong_parameters accept only numeric
# keys for the nested attributes in the fields_for form.
# Usage:
# params[:app][:nested_attributes] =[:app][:nested_attributes](
# params.require(:app).permit(:nested_attributes => [:id, :attribute1, :attribute2] => { '51e52eb101790c31ba000001' => { 'id' => '51e52eb101790c31ba000001', 'attribute1' => 'value1', 'attribute2' => 'value2' } } }
stevenharman / generate_ssl_cert
Created August 16, 2013 14:41
Generate a self-signed cert, update your hosts file, and add it to your OS X Keychain for local SSL success!
View generate_ssl_cert
#!/usr/bin/env sh
echo "Creating a self-signed certificate..."
openssl req -new -newkey rsa:2048 -sha1 -days 3650 -nodes -x509 -subj "/C=US/ST=Georgia/L=Atlanta/O=BNR/CN=localhost.ssl" -keyout config/server.key -out config/server.crt
if ! grep -q "\blocalhost\.ssl\b" /private/etc/hosts; then
echo "Adding localhost.ssl to your hosts file..."
echo " localhost.ssl" | sudo tee -a /private/etc/hosts
stevenharman / bin-puma
Last active December 21, 2015 04:39
A wrapper script that will start a local SSH tunnel (only in development environment), and then start Puma as normal. I use this with foreman from a Procfile.
View bin-puma
#!/usr/bin/env sh
# For the payment gateway callback URL
if [ "$CURRENT_ENV" == "development" ]; then
PORT_SSL=$(expr $PORT + 1)
echo "starting an SSL tunnel from :$PORT_SSL --(--)--> :$PORT"
bundle exec tunnels $PORT_SSL$PORT &
View multimethod.rb
class Module
def dispatch(*klasses, last)
last_klass, mid = last.first
klasses << last_klass
__dispatch_list << [klasses, instance_method(mid)]
define_method(mid, __dispatch_proc(__dispatch_list))
def __dispatch_list
@__dispatch_list ||= []
tinabeans / template.html
Last active April 16, 2023 02:52
A super-barebones single-column responsive email template, assuming a max-width of 540px. Read about it on the Fog Creek blog.
View template.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
@media only screen and (min-device-width: 541px) {
.content {
jarrodhroberson / CalcMD5Worker.js
Created November 26, 2013 00:09
Reading a File in chunks with the HTML5 FileReader API and calculating MD5 hash codes of the contents with the spark-md5 library in a WebWorker.
View CalcMD5Worker.js
function calcMD5(f) {
var blobSlice = Blob.prototype.slice;
var chunkSize = 2097152;
var chunks = Math.ceil(f.size/chunkSize);
var spark = new SparkMD5.ArrayBuffer();
var currentChunk = 0;
var fr = new FileReader();