Skip to content

Instantly share code, notes, and snippets.

View sbusso's full-sized avatar
🤖
Crafting with AI friends

Stéphane Busso sbusso

🤖
Crafting with AI friends
View GitHub Profile
@sbusso
sbusso / .gitignore
Created March 22, 2012 03:17 — forked from karmi/.gitignore
Visualizing timelines with Protovis and date histogram facet in ElasticSearch
.DS_Store
tmp/
@sbusso
sbusso / opml_generator.rb
Created April 2, 2012 07:34 — forked from jpmckinney/opml_generator.rb
Given an array of URLs, outputs an OPML file to STDOUT
# blog post: http://blog.slashpoundbang.com/post/3385815540/how-to-generate-an-opml-file-with-ruby
require 'open-uri'
require 'builder'
require 'truffle-hog'
require 'nokogiri'
# CHANGE ME
urls = %w(http://example.com/ http://example.org/)
@sbusso
sbusso / Gemfile
Created April 27, 2012 01:58
Super simple CMS with Rails Admin
# Add the gem
gem 'rails_admin'
@sbusso
sbusso / gist:2897330
Created June 8, 2012 18:07 — forked from jittuu/gist:792715
Test Omniauth Facebook Callback Controllers in Devise with rspec
require 'spec_helper'
describe Users::OauthCallbacksController, "handle facebook authentication callback" do
describe "#annonymous user" do
context "when facebook email doesn't exist in the system" do
before(:each) do
stub_env_for_omniauth
get :facebook
@sbusso
sbusso / grape_goliath
Created July 14, 2012 14:34
REST API: rails_api + thin vs grape + goliath vs sinatra + thin vs grape + thin
Request rate: 178.3 req/s (5.6 ms/req)
Request size [B]: 78.0
Reply rate [replies/s]: min 178.0 avg 178.0 max 178.0 stddev 0.0 (1 samples)
Reply time [ms]: response 5.6 transfer 0.0
Reply size [B]: header 126.0 content 167.0 footer 0.0 (total 293.0)
Reply status: 1xx=0 2xx=1000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.92 system 4.66 (user 16.4% system 83.1% total 99.6%)
Net I/O: 64.6 KB/s (0.5*10^6 bps)
@sbusso
sbusso / webby.rb
Created August 19, 2012 13:11
Webby to Jekyll migrator
require 'yaml'
require 'fileutils'
module Jekyll
module Webby
def self.process(webby_data_dir)
raise ArgumentError, "webby dir #{webby_data_dir} not found" unless File.directory?(webby_data_dir)
posts = 0
Dir["#{webby_data_dir}/**/*.txt"].each do |f|
@sbusso
sbusso / getscript.js
Created September 5, 2012 06:47
getScript() - load scripts asynchronously w/375 bytes of code - e.g. `getScript(src, cb)`
// # getScript()
// more or less stolen from jquery core and adapted by paul irish
function getScript(url,success) {
var head = document.getElementsByTagName("head")[0], done = false;
var script = document.createElement("script");
script.src = url;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) {
@sbusso
sbusso / template.rb
Created October 5, 2012 05:45
Rails Template
# create pg user
# rm -Rf railsm; rails new turfobet -m ~/Dropbox/rails_templates/bootstrap.rb -d postgresql --skip-bundle --local
add_source :gemcutter
gsub_file('Gemfile', "source 'https://rubygems.org'", "")
gem 'pg'
gem "haml-rails"
gem "simple_form"
gem 'font-awesome-rails'
gem 'remotipart', '~> 1.0'
@sbusso
sbusso / backup.rb
Created October 31, 2012 02:04
Gitlab HQ backup script
require 'rubygems'
require 'active_record'
require 'yaml'
require 'logger'
require 'fileutils'
require 'aws/s3'
ROOT = File.expand_path(File.dirname(__FILE__))
CONFIG = YAML.load_file(File.join(ROOT, "config", "database.yml"))
TMP_BACKUP = File.join(ROOT, "tmp", "backup")
@sbusso
sbusso / stream.rb
Created October 31, 2012 09:52
Sinatra stream #2
require 'sinatra'
conns = []
get '/' do
erb :index
end
get '/subscribe' do
content_type 'text/event-stream'