Skip to content

Instantly share code, notes, and snippets.

var Promise = require("bluebird");
var Request = require("superagent").Request;
/**
* @namespace utils
* @class Superagent
*/
/**
@asterite
asterite / cryload.cr
Last active September 2, 2015 15:56
require "./cryload/*"
require "http"
module Cryload
class LoadGenerator
def initialize(@host, @number)
@stats = Stats.new @number
ch = generate_request_channel
loop do
check_log
@bcardarella
bcardarella / active_model_credit_card.rb
Created December 20, 2010 18:35
ActiveMerchant's Credit Card model updated to use ActiveModel::Validations
# Heavily borrowed from ActiveMerchant::Biling::CreditCard
# Updated for ActiveModel::Validations
class CreditCard
include ActiveMerchant::Billing::CreditCardMethods
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
include ActiveModel::Naming
## Attributes
@alexyoung
alexyoung / deploy.sh
Created May 17, 2011 10:47
Deployment script
#!/usr/bin/env bash
# Configuration
SERVER='myserver'
DEPLOY_TO='/path/to/app'
EXCLUDE='*.swp .git/ db/sphinx/ tmp/ log/'
DRY_RUN=false
DEPLOY_GEM_PATH='/opt/ec/ruby/1.8.7/lib/ruby/gems/1.8'
@joshsusser
joshsusser / gist:998055
Created May 29, 2011 19:20
turn off 255 limit for string fields in postgresql
# in rails application.rb
initializer "postgresql.no_default_string_limit" do
ActiveSupport.on_load(:active_record) do
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:string].delete(:limit)
end
end
@jrochkind
jrochkind / asset_precompile_prefix_fix.rb
Created January 11, 2012 16:15
Rails 3.1.3 asset precompile with SubURI fix
# ./config/initializers/asset_precompile_prefix_fix.rb
#
# So we can deploy at a SubURI, and precompile assets to respect that with:
# RAILS_RELATIVE_URL_ROOT=/foo rake assets:precompile
#
# See: http://stackoverflow.com/questions/7293918/broken-precompiled-assets-in-rails-3-1-when-deploying-to-a-sub-uri
#
# Confirmed working in Rails 3.1.3
# Future versions of Rails may make this monkey patch unneccesary. (or break
# it without making it unneccesary)
@kristopolous
kristopolous / omnilog.rb
Created June 29, 2012 20:46
OmniLogger
class OmniLog
attr_reader :available
def initialize(path)
@real = Logger.new(path)
@fake = Logger.new("/dev/null")
@available = Set.new
end
def add!(which)
@adriand
adriand / gist:3198178
Created July 29, 2012 11:58
ActiveMerchant and PayPal
# controller
def notify
order = Order.capture_payment(request.raw_post)
render :nothing => true
end
# Order model
def self.capture_payment(raw_post)
@voodootikigod
voodootikigod / migrate.js
Created January 3, 2012 22:45
Schema (SQL) and Data (JS) Migrations for node.js (specifically PostgreSQL, but could be MySQL)
#!/usr/bin/env node
// this file is stored in a directory of APP_ROOT/script for me, all things are relative to that
var APP_ROOT = __dirname+"/../";
// this assumes there is a file stored in APP_ROOT called "config.js" with the following structure:
//
// module.exports = {
// "development: {
// "postgresql": "tcp://postgres@localhost/dev-db"
@barneycarroll
barneycarroll / store.js
Created July 9, 2015 16:49
Little getter/setter for localStorage: store( 'name', 'barney' ); store( 'name' ) === 'barney'; store.delete( 'name' ); store.has( 'name' ) === false
// Get / setter for local storage
function store( key, value ){
if( arguments.length > 1 ){
localStorage.setItem( key, JSON.stringify( value ) )
return value
}
// Simultaneous getting / setting is bad.
// It is wasteful to continuously encode & then decompile JSON and never useful.
else {