Skip to content

Instantly share code, notes, and snippets.

View lukeasrodgers's full-sized avatar

Luke Rodgers lukeasrodgers

View GitHub Profile
@lukeasrodgers
lukeasrodgers / movies.cypher
Created January 22, 2016 19:55
neo4j movies.cypher export using neo4j-shell-tools
begin
CREATE (:`Movie`:`UNIQUE IMPORT LABEL` {`released`:1999, `tagline`:"Welcome to the Real World", `title`:"The Matrix"});
CREATE (:`Person`:`UNIQUE IMPORT LABEL` {`born`:1964, `name`:"Keanu Reeves"});
CREATE (:`Person`:`UNIQUE IMPORT LABEL` {`born`:1967, `name`:"Carrie-Anne Moss"});
CREATE (:`Person`:`UNIQUE IMPORT LABEL` {`born`:1961, `name`:"Laurence Fishburne"});
CREATE (:`Person`:`UNIQUE IMPORT LABEL` {`born`:1960, `name`:"Hugo Weaving"});
CREATE (:`Person`:`UNIQUE IMPORT LABEL` {`born`:1967, `name`:"Andy Wachowski"});
CREATE (:`Person`:`UNIQUE IMPORT LABEL` {`born`:1965, `name`:"Lana Wachowski"});
CREATE (:`Person`:`UNIQUE IMPORT LABEL` {`born`:1952, `name`:"Joel Silver"});
CREATE (:`Person`:`UNIQUE IMPORT LABEL` {`born`:1978, `name`:"Emil Eifrem"});
@lukeasrodgers
lukeasrodgers / movies.grapml
Created January 22, 2016 19:52
neo4j movies.graphml export using neo4j-shell-tools
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<graph id="G" edgedefault="directed">
<node id="n0" labels=":Movie"><data key="labels">:Movie</data><data key="tagline">Welcome to the Real World</data><data key="title">The Matrix</data><data key="released">1999</data></node>
<node id="n1" labels=":Person"><data key="labels">:Person</data><data key="name">Keanu Reeves</data><data key="born">1964</data></node>
<node id="n2" labels=":Person"><data key="labels">:Person</data><data key="name">Carrie-Anne Moss</data><data key="born">1967</data></node>
<node id="n3" labels=":Person"><data key="labels">:Person</data><data key="name">Laurence Fishburne</data><data key="born">1961</data></node>
<node id="n4" labels=":Person"><data key="labels">:Person</data><data key="name">Hugo Weaving</data><data key="born">
@lukeasrodgers
lukeasrodgers / quickrubyprof.rb
Created October 15, 2015 17:15
quick ruby profiling
# Gemfile
gem 'ruby-prof'
# code to profile
require 'ruby-prof'
RubyProf.start
# run code
result = RubyProf.stop
printer = RubyProf::CallStackPrinter.new(result)
@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)
@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 / 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 / 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 / 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 / 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 / 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