Skip to content

Instantly share code, notes, and snippets.

View crypto-js
/*
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 Sep 7, 2012 — forked from scottwb/application_controller.rb
Get a list of all the filters on a given Rails 3 controller.
View application_controller.rb
# 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 Aug 24, 2012 — forked from sasimpson/gist:1112739
Ruby Net:HTTP chunked transfer
View gist:3455080
require 'uri'
require 'net/http'
class Chunked
def initialize(data, chunk_size)
@size = chunk_size
if data.respond_to? :read
@file = data
end
end
View gist:3166569
development:
sessions:
default:
database: logservice_development
hosts:
- localhost:27017
options:
# Change whether the session persists in safe mode by default.
# (default: false)
View captain_logger.rb
# Example
# class Foo
# include CaptainLogger
# log_to :file => "foo.log"
# end
module CaptainLogger
def self.included(base)
class << base
@blanchma
blanchma / logger_module
Created Jul 6, 2012
Simple logger module
View 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 — 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.
View node-and-npm-in-30-seconds.sh
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 Jan 4, 2012
Add Git Branch data to shell
View .bashrc
# 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 Nov 15, 2011
Get latitude and longitude from browser
View geocoding.js
// 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;
},