Skip to content

Instantly share code, notes, and snippets.

View lgs's full-sized avatar

Luca G. Soave lgs

View GitHub Profile
@JonRowe
JonRowe / async_rack_cache.rb
Created December 16, 2010 16:40
Async rack cache monkey patch.... use with caution
require 'async-rack'
require 'rack/cache'
module Rack::Cache
class Context
include AsyncRack::AsyncCallback::Mixin
def async_callback(result)
response = Response.new(*result)
@request ||= Request.new(env.dup.freeze)
store response if response.cacheable?
@zippy
zippy / devise-1-2-x-password-on-confirmation.rb
Created January 9, 2011 13:58
Implementation of getting user password as part of confirmation for Devise 1.2.x
#This is for Devise 1.2.x
# To your routes file add:
as :user do
match '/user/confirmation' => 'confirmations#update', :via => :put, :as=> :update_user_confirmation
end
# Add this inherited confirmations controller as app/controllers/confirmations_controller.rb
@chrisjacob
chrisjacob / README.md
Created February 18, 2011 03:44
Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Intro

Description: Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Author: Chris Jacob @_chrisjacob

Tutorial (Gist): https://gist.github.com/833223

The Result

@karmi
karmi / issues.rb
Created February 27, 2011 13:02
Putting Github issues into ElasticSearch
require 'rubygems'
require 'uri'
require 'yajl'
require 'yajl/http_stream'
require 'rest_client'
require 'slingshot'
URLS = %w[
http://github.com/api/v2/json/issues/list/karmi/elasticsearch.github.com/open
@karmi
karmi / collection.rb
Created March 8, 2011 11:59
Module which allows to use a proxy class for wrapping collections of all sorts.
# = Collection
#
# Module which allows to use a proxy class for wrapping collections of all sorts.
#
# Let's take a collection of articles, for example (see also the test suite below).
#
# The collection item class could look like this:
#
# class Article
# attr_reader :title
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end
@sente
sente / reddit.html
Created April 28, 2011 22:32
An example of a retrieving data from reddit's JSON(p) api using jquery
<!DOCTYPE html>
<!--
Stuart Powers
http://sente.cc/
http://twitter.com/stuartpowers
-->
<html>
<head>
@karmi
karmi / elasticoverflow.rb
Created May 3, 2011 09:32
Importing and searching RSS with ElasticSearch and Tire
# =======================================================
# Importing and searching RSS with ElasticSearch and Tire
# =======================================================
#
# This script downloads, parses and indexes Stackoverflow RSS feed with ElasticSearch
# via the [Tire](https://github.com/karmi/tire) Rubygem.
#
# Requirements
# ------------
#
@mrflip
mrflip / auth_and_rate_limit.rb
Created May 11, 2011 06:59
API key authentication + rate limiting in Goliath using MongoDB (incomplete sketch)
#!/usr/bin/env ruby
$: << File.join(File.dirname(__FILE__), '../lib')
require 'goliath'
require 'em-mongo'
require 'em-http'
require 'em-synchrony/em-http'
require 'yajl/json_gem'
require 'goliath/synchrony/mongo_receiver' # has the aroundware logic for talking to mongodb
require File.join(File.dirname(__FILE__), 'auth_receiver')
@karmi
karmi / .gitignore
Created May 15, 2011 11:15
Import your Gmail messages into ElasticSearch and search them with a simple web application.
.DS_Store
*.log
Gemfile.lock