Skip to content

Instantly share code, notes, and snippets.

View johnsinco's full-sized avatar

John Stewart johnsinco

View GitHub Profile
@johnsinco
johnsinco / generate-engine
Created June 19, 2012 02:59
generate a new rails 3 plugin project (engine gem)
rails plugin new daengine --full --dummy-path=spec/dummy -T --skip-bundle
@johnsinco
johnsinco / gist:5125316
Created March 9, 2013 19:06
load your local instance with QA1 data.
c:\dev>mongo 10.0.20.154:27017
MongoDB shell version: 2.0.2-rc1
connecting to: 10.0.20.154:27017/test
> show dbs
local (empty)
> db.copyDatabase('edist_staging','edist_development','qa1-cms-db1:33478');
{ "ok" : 1 }
> show dbs
admin (empty)
edist_development 0.125GB
@johnsinco
johnsinco / gist:5556734
Created May 10, 2013 19:19
simple angularjs demo of a wizard flow (doesn't work)
angular.module('register', ['ngResource', 'rails']).
config(function($routeProvider) {
$routeProvider.
when('/', {controller:RegisterCtrl, templateUrl:'/partials/register.html'}).
when('/#profile', {controller:RegisterCtrl, templateUrl:'/partials/profile.html'}).
when('/#preferences', {controller:RegisterCtrl, templateUrl:'/partials/preferences.html'}).
otherwise({redirectTo:'/'});
});
angular.module('register').factory('User', ['railsResourceFactory', function (railsResourceFactory) {
@johnsinco
johnsinco / double-regex
Created October 2, 2013 19:25
ruby double-regex-error
# do something cool with input using a case
input = "some fool string"
case input
when /foo/
# do something
when /bar/
# do something else
when /(fool)/
# now do something special using the capture
local_var = $1 # get the capture
@johnsinco
johnsinco / merge vs update
Created January 21, 2015 22:41
Ruby Hash merge vs update
hsh = {a: 1, b: 2}
mrg = hsh.merge(b: 42)
mrg == hsh # false
upd = hsh.update(b: 69)
mrg == upd # true
run a single minitest. rake test TEST=test/test_foobar.rb TESTOPTS="--name=test_foobar1 -v"
TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
0.032859 286 50 0.000515 0.000115 rubyKeywordAsMethod \(defined?\|exit!\)\@!\<[_[:lower:]][_[:alnum:]]*[?!]
0.022910 584 390 0.000254 0.000039 rubyKeywordAsMethod \%(\%(\.\@1<!\.\)\|::\)\_s*\%([_[:lower:]][_[:alnum:]]*\|\<\%(BEGIN\|END\)\>\)
0.021121 360 122 0.000473 0.000059 rubyConstant \%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!
0.020811 522 284 0.000232 0.000040 rubySymbol [[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@=
0.017956 372 134 0.000246 0.000048 rubySymbol []})\"':]\@1<!\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@=
0.014816 239 0 0.000591 0.000062 rubyCapitalizedMethod \%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)*\s*(\@=
0.013742 488 260 0.000189 0.000028 rubyInteger \%(\%(\w\|[]})\"']\s*\)\@<
@johnsinco
johnsinco / vimtmux.md
Last active December 11, 2018 18:58
Vim / tmux resources

List of VIM / TMUX / Remote Pairing resources

@johnsinco
johnsinco / elixir_validation.ex
Last active August 28, 2020 18:03
elixir event handler for tradeline validation
defmodule Sample.EventHandler do
alias KaufmannEx.Schemas.Event
def given_event(%Event{name: :"loan.tradeline", payload: payload} = event) do
{state: state} = payload
if Enum.member?(["CO", "CA", "KS", FL"], state) do
{:ok, "loan.tradeline.validation.state", payload.tracking_number}
else