Skip to content

Instantly share code, notes, and snippets.

@sr3d
sr3d / gist:1754122
Created February 6, 2012 19:07 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p0
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1754122)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
#
# Update to work with the falcon patch.
echo "Installing ruby-debug with ruby-1.9.3-p0 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
@sr3d
sr3d / gist:1562560
Created January 4, 2012 22:33
exchange_authentication.rb
Viewpoint::EWS::EWS.endpoint = 'https://webmail.sherweb2010.com/EWS/Exchange.asmx'
class << self
# Authenticate against @Wordnik.com Email account
# Viewpoint::EWS::EWS.set_auth('DOMAIN\alex_wordnik.com','password')
def authenticate(user, password)
user = user.downcase.strip
exchange_user = "DOMAIN\\#{user}_wordnik.com"
Rails.logger.debug "Authenticate for Exchange User #{exchange_user}"
Viewpoint::EWS::EWS.set_auth exchange_user, password
@sr3d
sr3d / gist:1434897
Created December 5, 2011 19:27
UberLogger
(function() {
if(typeof(console) == 'undefined') {
(function() {
/* Shim for window.console */
var methods = ['log', 'info', 'warn', 'error'];
window.console = {};
for(var i = 0; i < methods.length; i++){
window.console[ methods[i] ] = function() {};
}
})();
@sr3d
sr3d / CloudFoundry Push
Created May 30, 2011 22:07
Mongoid Initializer for CloudFoundry
alexle:pushpuppy sr3d$ vmc push pushpuppy --runtime ruby19
Would you like to deploy from the current directory? [Yn]:
Application Deployed URL: 'pushpuppy.cloudfoundry.com'?
Detected a Rails Application, is this correct? [Yn]:
Memory Reservation [Default:256M] (64M, 128M, 256M, 512M or 1G)
Creating Application: OK
Would you like to bind any services to 'pushpuppy'? [yN]: y
Would you like to use an existing provisioned service [yN]? N
The following system services are available::
1. mongodb
desc "Removes trailing whitespace and replaces tabs with two spaces"
task :whitespace do
sh %[find . \\( -name '*.rb' -or -name '*.yml' \\) -type f -exec ruby -pi -e 'gsub(/ +$/, "");gsub(/\t/, " ")' {} \\;]
end
var cachedFiles = {};
/* load a file and cache it so next time we don't have to re-evaluate again */
function load(path) {
if(!cachedFiles[path] || DEBUG ){
log('caching ' + path );
cachedFiles[path] = require(path);
};
return cachedFiles[path];
};
@sr3d
sr3d / celltrust.rb
Created March 29, 2011 01:57
Celltrust API Wrapper
module Celltrust
class Sms < Struct.new( :number, :message, :sms_id, :status )
@@count = 0
URL = 'https://www.primemessage.net/TxTNotify/SecureSMS'
def self.count
@@count
end
var TinyORM = (function(options) {
/* a hash containing all the available models */
var Models = {};
var connection = null;
var config = _.extend({
/* The name of the database which Ti will open. The local db is located at:
~/Library/Application Support/iPhone Simulator/4.2/Applications/APP_ID/Library/Application Support/database/dbname
*/
dbname: 'add.db',
@sr3d
sr3d / utils.js
Created February 23, 2011 10:17
my secret toolbelt
function log(object) {
Ti.API.debug(object);
if(logger) {
logger.log(object);
};
};
var indWin = null;
var actInd = null;
var listenOnce = function(event, handler) {
var handlerWrapper = function() {
handler();
Ti.App.removeEventListener(event, handlerWrapper);
};
Ti.App.addEventListener(event, handlerWrapper);
};
var listenButUnregisterWhenClose = function( win, hash ) {
_.each(hash, function(handler, event) {