Skip to content

Instantly share code, notes, and snippets.

/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
var CryptoJS=CryptoJS||function(u,l){var d={},n=d.lib={},p=function(){},s=n.Base={extend:function(a){p.prototype=this;var c=new p;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
q=n.WordArray=s.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=l?c:4*a.length},toString:function(a){return(a||v).stringify(this)},concat:function(a){var c=this.words,m=a.words,f=this.sigBytes;a=a.sigBytes;this.clamp();if(f%4)for(var t=0;t<a;t++)c[f+t>>>2]|=(m[t>>>2]>>>24-8*(t%4)&255)<<24-8*((f+t)%4);else if(65535<m.le
@blanchma
blanchma / application_controller.rb
Created September 7, 2012 16:26 — forked from scottwb/application_controller.rb
Get a list of all the filters on a given Rails 3 controller.
# Add these methods to your ApplicationController. Then, any controller
# that inherits from it will have these methods and can programmatically
# determine what filters it has set.
class ApplicationController < ActionController::Base
def self.filters(kind = nil)
all_filters = _process_action_callbacks
all_filters = all_filters.select{|f| f.kind == kind} if kind
all_filters.map(&:filter)
end
@blanchma
blanchma / gist:3455080
Created August 24, 2012 20:06 — forked from sasimpson/gist:1112739
Ruby Net:HTTP chunked transfer
require 'uri'
require 'net/http'
class Chunked
def initialize(data, chunk_size)
@size = chunk_size
if data.respond_to? :read
@file = data
end
end
@blanchma
blanchma / gist:3166569
Created July 23, 2012 22:12
mongoid.yml
development:
sessions:
default:
database: logservice_development
hosts:
- localhost:27017
options:
# Change whether the session persists in safe mode by default.
# (default: false)
@blanchma
blanchma / captain_logger.rb
Created July 6, 2012 14:20
Captain Logger
# Example
# class Foo
# include CaptainLogger
# log_to :file => "foo.log"
# end
module CaptainLogger
def self.included(base)
class << base
@blanchma
blanchma / logger_module
Created July 6, 2012 03:10
Simple logger module
# Example
# class Foo
# include CaptainLogger
# config_logger ::file => "foo.log"
# end
module CaptainLogger
def self.included(base)
class << base
@blanchma
blanchma / node-and-npm-in-30-seconds.sh
Created May 6, 2012 14:55 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@blanchma
blanchma / .bashrc
Created January 4, 2012 18:27
Add Git Branch data to shell
# GIT Prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\u@\h:\w \$(parse_git_branch)\$ "
@blanchma
blanchma / geocoding.js
Created November 15, 2011 12:33
Get latitude and longitude from browser
// if the browser supports the w3c geo api
if(navigator.geolocation){
// get the current position
navigator.geolocation.getCurrentPosition(
// if this was successful, get the latitude and longitude
function(position){
var lat = position.coords.latitude;
var lon = position.coords.longitude;
},