Skip to content

Instantly share code, notes, and snippets.

View rossta's full-sized avatar
💭
Being curious

Ross Kaffenberger rossta

💭
Being curious
View GitHub Profile
@rossta
rossta / ruby_install.sh
Created November 29, 2013 16:21
Bootstrap ruby on remote server
#!/usr/bin/env bash
RUBY_VERSION=ruby-2.0.0-p247
apt-get -y update
apt-get -y install build-essential libyaml-dev zlib1g-dev openssl libssl-dev libreadline-gplv2-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/$RUBY_VERSION.tar.gz
tar -xvzf $RUBY_VERSION.tar.gz
cd $RUBY_VERSION/
sudo ./configure --prefix=/usr/local
sudo make
@rossta
rossta / index.js
Last active July 19, 2021 12:15
Barebones node js server on express
var express = require('express');
var app = express.createServer();
app.configure(function() {
var pub = __dirname + "./public";
pub = require("path").normalize(pub);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
});
@rossta
rossta / caybara_rails.rb
Created March 25, 2013 16:19
Configuring Capybara RackTest driver for Rails in Capybara 2.0.+
Capybara.register_driver :rack_test do |app|
Capybara::RackTest::Driver.new(app,
redirect_limit: 15,
follow_redirects: true,
respect_data_method: true
)
end
@rossta
rossta / index.html
Last active December 14, 2015 11:08
Tweet Calendar
<!doctype html>
<meta charset="utf-8">
<div id="block"></div>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style type="text/css">
.block {
font: 10px sans-serif;
shape-rendering: crispEdges;
padding: 25px 0;
}
@rossta
rossta / ruby_trello_demo.rb
Created January 8, 2013 03:37
Ruby-trello and Threads: Making requests on behalf of multiple clients is not currently thread-safe, as demonstrated in the gist below (with placeholders for sensitive data).
include Trello
include Trello::Authorization
Trello::Authorization.const_set :AuthPolicy, OAuthPolicy
OAuthPolicy.consumer_credential = OAuthCredential.new('user_key', 'user_secret')
threads = []
tokens = %w[ not_rosstas_token rosstas_token ]
tokens.each_with_index do |token, i|
@rossta
rossta / index.html
Created January 1, 2013 18:24
Balls with wall collision; Click to add balls
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@rossta
rossta / index.html
Last active December 10, 2015 10:58
Click to add balls
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@rossta
rossta / ordered_by_counter.rb
Created October 17, 2012 10:27
OrderedByCounter article
module MyModule
extend ActiveSupport::Concern
# removed code that modified User when
# including this module in Article
end
module OrderedByCounter
extend ActiveSupport::Concern
@rossta
rossta / caching_config.rb
Last active September 28, 2015 23:08
Set controller caching in RSpec around block
RSpec.configure do |config|
config.around(:each, :caching) do |example|
caching = ActionController::Base.perform_caching
ActionController::Base.perform_caching = example.metadata[:caching]
example.run
Rails.cache.clear
ActionController::Base.perform_caching = caching
end
end
@rossta
rossta / devise_monkey_patch.rb
Created October 19, 2011 04:02
Devise patch for test env to cut out expensive password calculations
# Don't need passwords in test DB to be secure, but we would like 'em to be
# fast -- and the stretches mechanism is intended to make passwords
# computationally expensive.
module Devise
module Models
module DatabaseAuthenticatable
protected
def password_digest(password)
password