Skip to content

Instantly share code, notes, and snippets.

View nathany's full-sized avatar
🙃

Nathan Youngman nathany

🙃
View GitHub Profile
@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
<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 / i18n-default-interpoliations.rb
Created April 23, 2010 16:38
allow default options for Rails i18n
# override I18n.translate to support default_options
module I18n
mattr_accessor :default_options
self.default_options = {}
class << self
def translate_with_default_options(key, options = {})
translate_without_default_options(key, default_options.merge(options))
end
filesMatching(folder) { (file, dir) => // looks alot like a Ruby block
println(file + ": " + dir) // multiple statements
file.endsWith(query) && dir == false
}
///////////////////////////////////////////////////////////////////////////////
//
// jquery.protect.js
// Copyright (c) 2010 Yardstick Software
//
// This plugin allows you protect a page from selection/copying the text.
//
// Doesn't do anything about Print Scrn, Save As...
//
///////////////////////////////////////////////////////////////////////////////
# sudo gem install octopi
require "octopi"
include Octopi
y = User.find("yegrb")
y.public_repo_count
y.followers_count
y.gravatar_id
y.name, y.company, y.location, y.login, y.email
@nathany
nathany / search_procs.sql
Created May 31, 2010 19:31
SQL Server search through stored procedure and trigger code
USE MyDatabase
GO
SELECT mprod.object_id, oprod.name
FROM sys.sql_modules mprod
LEFT JOIN sys.objects oprod ON mprod.object_id = oprod.object_id
WHERE mprod.definition LIKE '%SearchString%'
@nathany
nathany / zshenv
Last active September 11, 2015 17:07
Go environment
export GOPATH=$HOME
export PATH=$PATH:$HOME/src/go.googlesource.com/go/bin:$HOME/bin
export GOROOT_BOOTSTRAP=$HOME/src/go.googlesource.com/go1.4
export GO15VENDOREXPERIMENT=1
gem: --no-ri --no-rdoc
#!/bin/sh
# Copies all data from the production database and populates the staging
# database with the dumped data.
echo "Dumping production data..."
mysqldump --add-drop-table --add-locks -e -l ys_production > /tmp/db_prod2stage.sql
echo "Populating staging data..."
mysql -e "use ys_staging; source /tmp/db_prod2stage.sql;"