Skip to content

Instantly share code, notes, and snippets.

View BrianTheCoder's full-sized avatar

Brian Smith BrianTheCoder

View GitHub Profile
@funny-falcon
funny-falcon / changes.md
Last active March 23, 2024 05:53
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@jaredhanson
jaredhanson / gist:3989193
Created October 31, 2012 19:13
Node Knockout 2012 - Getting Started with Passport
var express = require('express'),
passport = require('passport'),
TwitterStrategy = require('passport-twitter').Strategy,
ensureLoggedIn = require('connect-ensure-login').ensureLoggedIn,
app = express();
app.use(express.static(__dirname + '/public'));
app.use(express.cookieParser());
app.use(express.session({ secret: 'keyboard cat' }));
app.use(passport.initialize());
@rweald
rweald / simple-linear-regression.rb
Created August 29, 2012 19:13
Simple Linear Regression in Ruby
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))
@adammw
adammw / README.md
Created August 3, 2012 06:30
Node.js for Raspberry Pi

Node.js for Raspberry Pi

Pre-built binaries

Recent releases have been pre-built using cross-compilers and this script and are downloadable below.

If you have found these packages useful, give me a shout out on twitter: @adammw

@sishen
sishen / notifier.coffee
Created August 2, 2012 03:36
Web Notifications integration in Pragmatic.ly
class Notifier
constructor: ->
@enableNotification = false
@checkOrRequirePermission()
hasSupport: ->
window.webkitNotifications?
requestPermission: (cb) ->
window.webkitNotifications.requestPermission (cb)
@brentd
brentd / parallel_asset_compiler.rb
Created July 31, 2012 23:11
Parallelize assets:precompile
require 'parallel' # gem install parallel (https://github.com/grosser/parallel)
# Monkey patch to Sprockets::StaticCompiler, a class provided by actionpack
# that's used by the assets:precompile task. This patch uses the Parallel gem
# to parallelize asset compilation in the simplest way possible.
#
# Parallel wraps Process.fork to handle things like inter-process communication
# via pipes and determining the maximum number of processes to run based on
# your system's total logical processors. So far only tested on MRI 1.9.3 on OS X.
module Sprockets
@aiwilliams
aiwilliams / README.md
Created May 16, 2012 13:52
Storyboard in RubyMotion 1.4

Start XCode and create a new Storyboard file. I closed all my other XCode projects. When you choose the location of the created file, it should be your RubyMotion project's resources directory. Add a UIViewController, and set it's identifier property to "Start". Add some UI elements so you can see it working.

When you run rake in your RubyMotion project, it will compile the .storyboard file. You could auto-load the Storyboard using a plist configuration, but you'll see code can do it too.

@pengwynn
pengwynn / Rakefile
Created September 1, 2011 01:08
Build titanium
require 'rubygems'
require 'nokogiri'
require 'colored'
PROJECT_NAME="GolfStatus"
PROJECT_ROOT = File.dirname(__FILE__)
IPHONE_SDK_VERSION="4.3"
TI_SDK_VERSION="1.6.2"
TI_DIR='/Library/Application\ Support/Titanium'
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
if Rails.env.production?
Braintree::Configuration.environment = Rails.env.staging? ? :sandbox : :production
Braintree::Configuration.merchant_id = ENV["braintree_merchant_id"]
Braintree::Configuration.public_key = ENV["braintree_public_key"]
Braintree::Configuration.private_key = ENV["braintree_private_key"]
else
Braintree::Configuration.environment = :sandbox
Braintree::Configuration.merchant_id = "<super secret>"
Braintree::Configuration.public_key = "<super secret>"
Braintree::Configuration.private_key = "<super secret>"