Skip to content

Instantly share code, notes, and snippets.

View lukeasrodgers's full-sized avatar

Luke Rodgers lukeasrodgers

View GitHub Profile
@lukeasrodgers
lukeasrodgers / .vimrc
Last active August 29, 2015 13:57
no-plugins, generic .vimrc
" reload .vimrc when editing it: :so %
set nocompatible " be iMproved
filetype off " required!
set nu " show line numbers
set hlsearch " highlight search terms
" Clear last search highlighting
nnoremap <c-m> :noh<cr>
" Easier navigation between split windows
@lukeasrodgers
lukeasrodgers / self_signed_cert.conf
Created April 9, 2014 13:51
generate self-signed ssl certificate
# from http://quanterium.blogspot.com/2012/01/creating-self-signed-ssl-certificate.html
# see also http://www.mail-archive.com/openssl-users@openssl.org/msg47647.html
# to use:
# first, change alt_names
# then, openssl req -new -x509 -days 365 -nodes -out example.crt -keyout example.key -config example.conf
# and follow instructions
[ ca ]
default_ca = CA_default
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
@lukeasrodgers
lukeasrodgers / take_select.rb
Created September 18, 2014 19:19
ruby take_select
class Array
def take_select n, &block
count = 0
res = []
select do |x|
r = yield x
if r == true
count += 1
res << x
end
@lukeasrodgers
lukeasrodgers / webrick_perf_get
Last active August 29, 2015 14:11
webrick perf testing JSON API GET
Benchmarking 127.0.0.1 (be patient)
Finished 448 requests
Server Software: WEBrick/1.3.1
Server Hostname: 127.0.0.1
Server Port: 3080
Document Path: /api/v1/users/1/cabinets/1/drinks
Document Length: 801 bytes
@lukeasrodgers
lukeasrodgers / thin_perf_get
Last active August 29, 2015 14:11
thin perf testing JSON API GET
Benchmarking 127.0.0.1 (be patient)
Finished 390 requests
Server Software: thin
Server Hostname: 127.0.0.1
Server Port: 3080
Document Path: /api/v1/users/1/cabinets/1/drinks
Document Length: 801 bytes
@lukeasrodgers
lukeasrodgers / unicorn_perf_get
Created December 17, 2014 01:13
unicorn perf testing JSON API GET
Benchmarking 127.0.0.1 (be patient)
Finished 199 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 3080
Document Path: /api/v1/users/1/cabinets/1/drinks
Document Length: 801 bytes
@lukeasrodgers
lukeasrodgers / puma_perf_get
Created December 17, 2014 01:34
puma perf testing JSON API GET
Benchmarking 127.0.0.1 (be patient)
Finished 450 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 3080
Document Path: /api/v1/users/1/cabinets/1/drinks
Document Length: 801 bytes
@lukeasrodgers
lukeasrodgers / jsfactories.js
Last active August 29, 2015 14:16
simple js factories using builder pattern
/**
* Builder pattern for factories, mimic use of FactoryGirl traits.
* usage: factories.boostedBoost({retweets: 1}).twitter().withdrawn().geo(11217).generate();
* must call `generate` as last step
* may pass options to initial method call, as well as subsequent method calls
*/
function addFactory(factoryName, config) {
// add trait function to generated Factory
function addTrait(k, Factory, config) {
Factory.prototype[k] = function() {
@lukeasrodgers
lukeasrodgers / monkeypatch_ar_mysql_collation_charset.rb
Created October 6, 2015 21:02
monkeypatch active record mysql adapter to understand collation, charset
# this is ugly and terrible, don't do this
module ActiveRecord
module ConnectionAdapters
class TableDefinition
def column(name, type, options = {})
name = name.to_s
type = type.to_sym
column = self[name] || new_column_definition(@base, name, type)