Skip to content

Instantly share code, notes, and snippets.

View xxswingxx's full-sized avatar
🏠
Working from home

John Wu xxswingxx

🏠
Working from home
View GitHub Profile
# Search term parser from https://gist.github.com/1477730
# Modified to allow periods (and other non-letter chars) in unquoted field values
# and field names.
#
# Helper class to help parse out more advanced saerch terms
# from a form query
#
# Note: all hash keys are downcased, so ID:10 == {'id' => 10}
# you can also access all keys with methods e.g.: terms.id = terms['id'] = 10
# this doesn't work with query as thats reserved for the left-over pieces
@xxswingxx
xxswingxx / post-checkout.sh
Last active February 26, 2016 14:56
Reset database after doing a checkout
#! /bin/sh
# Reset the database only if the previous branch and the current one have different schemas
# Start from the repository root.
cd ./$(git rev-parse --show-cdup)
if git diff `git rev-parse --abbrev-ref HEAD` @{-1} | grep "ActiveRecord::Schema.define(version: "; then
rake db:reset
else
@xxswingxx
xxswingxx / get_average_historical.rb
Last active August 29, 2015 14:12
get_average_historical.rb
require 'csv'
require 'httparty'
require 'byebug'
OANDA_URL = 'https://www.oanda.com/rates/api/v1/rates/'
OANDA_KEY = ENV['OANDA_API_KEY']
OUTPUT_FILE = './rates.json'
year = {
month_1: [],
month_2: [],
@xxswingxx
xxswingxx / Example form.html
Last active August 29, 2015 14:08
Demo form
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript" src="lib/quaderno-stripe.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
@xxswingxx
xxswingxx / Install ghostscript 9.14.md
Last active October 28, 2015 09:33
Build and install ghostscript 9.14 from src

#Install ghostscript 9.14.md

Uninstall prior versions of ghostscript to avoid conflicts

sudo apt-get remove ghostscript

Install dependencies

 sudo apt-get install liblcms2-2 liblcms2-dev liblcms2-utils
@xxswingxx
xxswingxx / gist:0151df0355dcf0203c05
Created June 12, 2014 13:46
Ruby wrapper configuration example
require 'quaderno-ruby'
Quaderno::Base.configure do |config|
config.auth_token = 'my_authenticate_token'
config.subdomain = 'my_account_subdomain'
config.environment = :sandbox # :production by default
end