Skip to content

Instantly share code, notes, and snippets.

View statianzo's full-sized avatar
🎯
Focusing

Jason Staten statianzo

🎯
Focusing
View GitHub Profile
@statianzo
statianzo / decode.rb
Created July 9, 2012 09:03
URUG Decoding
# {"1"=>"a", "2"=>"b" ... }
CHARS = Hash[('a'..'z').each_with_index.map{|char, i| [i.succ.to_s, char]}]
def decode(encoded, cur=[])
return cur.join if encoded.nil? || encoded.empty?
h1 = CHARS[encoded[0]]
h2 = CHARS[encoded[0,2]]
result = []
result << decode(encoded[1..-1], cur+[h1]) if h1 && encoded[1] != '0'
@statianzo
statianzo / error_handler.rb
Created August 27, 2012 17:25 — forked from bdotdub/error_handler.rb
Hoptoad notifier for Sinatra
error do
exception = request.env['sinatra.error']
Hoptoad::Notifier.send_error exception, params, request.env if %w(staging production).include?(ENV['RACK_ENV'])
erb :five_hundred
end
@statianzo
statianzo / selectable_queue.rb
Created September 10, 2012 19:02 — forked from garybernhardt/selectable_queue.rb
A queue that you can pass to IO.select. This is for use in a GUI application. I'm not turning into a Node programmer.
# A queue that you can pass to IO.select.
#
# NOT THREAD SAFE: Only one thread should write; only one thread should read.
#
# Purpose:
# Allow easy integration of data-producing threads into event loops. The
# queue will be readable from select's perspective as long as there are
# objects in the queue.
#
# Implementation:
@statianzo
statianzo / update_bundles.rb
Created October 17, 2012 17:29
Rebuilds pathogen bundle folder
#!/usr/bin/env ruby
git_bundles = [
"git://github.com/msanders/snipmate.vim.git",
#"git://github.com/scrooloose/nerdtree.git",
#"git://github.com/tpope/vim-haml.git",
"git://github.com/tpope/vim-markdown.git",
#"git://github.com/tpope/vim-rails.git",
#"git://github.com/tpope/vim-repeat.git",
#"git://github.com/tpope/vim-surround.git",
set t_Co=16
call pathogen#runtime_append_all_bundles()
syntax on
"let g:solarized_termcolors=256
colorscheme solarized
set background=dark
filetype plugin indent on
set nocompatible " We don't want vi compatibility.
@statianzo
statianzo / MyLockingStream.cs
Created December 13, 2012 19:33
Canan Kasaci's wrapper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace Fleck
if File.exists? '.env'
File.readlines('.env').
map{|l| l.chomp }.
reject{|l| l.empty?}.
map{|l| l.split '='}.
each {|k,v| ENV[k] ||= v}
end
IRB.conf[:USE_READLINE] = true
IRB.conf[:AUTO_INDENT] = false
module CsrfHelpers
def token
session[:csrf] ||= SecureRandom.hex(32)
end
def csrf_input_tag
%Q(<input type="hidden" name="authenticity_token" value="#{token}" />)
end
def csrf_meta_tag
#!/usr/bin/env bash
# HubCrypt
# ========
#
# Decrypt a file encrypted using hubencrypt (ok, it's just openssl + rsautl +
# your SSH keys). It needs the private key that matches your last public key
# listed at github.com/<user>.keys
#
@statianzo
statianzo / PKGBUILD.diff
Last active August 29, 2015 14:01
openresty PKGBUILD update
--- PKGBUILD.old 2013-09-30 14:24:47.000000000 -0600
+++ PKGBUILD 2014-05-27 12:59:49.359684637 -0600
@@ -4,7 +4,7 @@
_tmpdir=/var/lib/openresty
pkgname=openresty
_pkgname=ngx_openresty
-pkgver=1.4.2.9
+pkgver=1.5.12.1
pkgrel=1
pkgdesc="a powerful web app server by extending nginx"