Skip to content

Instantly share code, notes, and snippets.

View DavidRagone's full-sized avatar

David Ragone DavidRagone

View GitHub Profile
mkdir sqpaymentform-nodejs-starterkit
cd sqpaymentform-nodejs-starterkit
curl https://raw.githubusercontent.com/hukid/sqpaymentform-nodejs-starterkit/master/app.js -o app.js
curl https://raw.githubusercontent.com/hukid/sqpaymentform-nodejs-starterkit/master/index.html -o index.html
curl https://raw.githubusercontent.com/hukid/sqpaymentform-nodejs-starterkit/master/sqpaymentform.css -o sqpaymentform.css
curl https://raw.githubusercontent.com/hukid/sqpaymentform-nodejs-starterkit/master/sqpaymentform.js -o sqpaymentform.js
curl https://raw.githubusercontent.com/hukid/sqpaymentform-nodejs-starterkit/master/package.json -o package.json
npm install
@DavidRagone
DavidRagone / .pryrc
Created October 1, 2016 04:22 — forked from manno/.pryrc
pry command for graphing AASM models with graphviz
# see https://github.com/ivantsepp/aasm_graph/blob/master/bin/aasm_graph
Pry::Commands.helpers {
def dot_template(edges)
<<-DOT
digraph cronjob {
rankdir=LR; /* This should be configurable */
node [shape = circle];
#{edges}
}
DOT
@DavidRagone
DavidRagone / rebase-flow.md
Last active September 21, 2016 21:33
Git rebase workflow for resolving db/schema.rb conflicts

Rebase flow

On base branch:

rake db:drop db:setup db:schema:dump # Ensure the database is consistent with base branch git rebase $base_branch

For each conflict

git checkout --ours db/schema.rb

git add db/schema.rb

@DavidRagone
DavidRagone / kiss
Created April 11, 2015 20:30
General thoughts on libraries that I'd like to use in future web-apps
[cuba](http://cuba.is/) for basic routing logic on top of Rack
[mote](https://github.com/soveran/mote) for templating
@DavidRagone
DavidRagone / binary_search.rb
Created October 1, 2013 06:15
Binary search, TDD
require 'rspec'
class Array
def binary_search(value, index = 0)
middle = self[size/2]
if middle == value
index + size/2
elsif size == 1
-1
elsif middle < value
@DavidRagone
DavidRagone / dfs_bfs.rb
Last active December 24, 2015 08:59
Depth first search + Breadth first search, TDD
# run with rspec [name of file]
require 'rspec'
class Node
attr_reader :value, :children
def initialize value
@value = value
@children = []
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@DavidRagone
DavidRagone / system_settings
Created April 9, 2013 15:31
System settings for new laptop setup
#!/usr/bin/env zsh
echo ">>>Tweaking system settings for a more pleasurable experience..."
echo ">>>Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
echo ">>>Enable subpixel font rendering on non-Apple LCDs"
defaults write NSGlobalDomain AppleFontSmoothing -int 2
@DavidRagone
DavidRagone / gist:4242337
Created December 8, 2012 22:43 — forked from markbates/gist:4240848
Getting Started with Rack

If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.

Rack describes itself as follows:

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.

At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.