Skip to content

Instantly share code, notes, and snippets.

View nathany's full-sized avatar
🙃

Nathan Youngman nathany

🙃
View GitHub Profile
<cfscript>
function decodeToken(stoken, crypt_key) {
token_bytes = BinaryDecode(URLDecode(stoken), "base64");
Arrays = CreateObject("java", "java.util.Arrays");
iv = Arrays.copyOf(token_bytes, 16);
crypted = Arrays.copyOfRange(token_bytes, 16, ArrayLen(token_bytes));
decoded_token = DecryptBinary(crypted, crypt_key, "AES/CBC/PKCS5Padding", iv);
return ToString(decoded_token);
@nathany
nathany / syntax_benchmark.py
Created March 30, 2010 19:40
benchmark Pygments from Python
# benchmark Pygments from Python
# http://github.com/ryanb/railscasts-episodes/blob/master/episode-207/syntax_benchmarks.rb
from pygments import highlight
from pygments.lexers import RubyLexer
from pygments.formatters import HtmlFormatter
import timeit
# run it once to initialize
@nathany
nathany / show SQL in irb console
Created March 11, 2010 17:31
Rails SQL logging from console
ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(STDOUT)
@nathany
nathany / edit.html.haml
Created December 3, 2009 17:13
starting on some RJS-like helpers for jQuery and CKEditor
- javascript_tag do
= after_ready do
= add_ckeditor_plugins(:snippet)
@nathany
nathany / gist:211991
Created October 16, 2009 19:17 — forked from kylefox/gist:211989
Git prompt for Bash
# Shows the [branch], and an * if there are uncommitted changes. Example:
# ~/projects/my_project[master*]:
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
@nathany
nathany / landing.rb
Created October 12, 2009 00:04
Heroku is great to host single-page "sites" for all those domains I'm not using.
require 'rubygems'
require 'sinatra'
require 'haml'
Domains = %w{gemsmith vogsphere youngman seraph intercessory cyaonline significantwhitespace 14159265358979}
DefaultDomain = 'default'
# what domain does the host contain?
# put this here because helpers are a pain to test!
def view_for_domain(host)
@nathany
nathany / gist:190435
Created September 21, 2009 18:33
based on hello from Stuart Halloway's book
;; reference to a set (unique) visitors
(def visitors (ref #{}))
(defn hello
"Writes hello message to *out*. Calls you by username.
Knows if you have been here before."
([] (hello "world")) ; with no arguments
([username]
(dosync
;; deref visitors, call username to see if it's there
/* Pure CSS tool tips from CSS Mastery, originally by Eric Meyer? With fix for IE, see below */
a.tooltip {
position: relative;
}
a.tooltip span {
display: none;
}
@nathany
nathany / gist:175670
Created August 26, 2009 17:46
pivot table example in SQL Server 2005
select PT.FacID, f1.FacName, [1] as QtyAlloc, [-1] as QtyUsed, [1] + [-1] as QtyRemain
from
(
select f1.FacID, sign(f1.Quantity) as Sgn, f1.Quantity
from FacCredits f1
) as q1
pivot
(
sum(q1.Quantity)
for q1.Sgn in ([1], [-1])
@nathany
nathany / README.md
Created April 28, 2015 17:53
Go / Ruby bridge with Sidekiq
brew install redis
gem install sidekiq
go get -u github.com/jrallison/go-workers

redis-server /usr/local/etc/redis.conf