Skip to content

Instantly share code, notes, and snippets.

View lgs's full-sized avatar

Luca G. Soave lgs

View GitHub Profile
require 'rubygems'
require 'sinatra'
require 'fileutils'
# upload with:
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename
# or just go to http://localhost:4567/user/filename with a browser
get '/:name/:filename' do
@lgs
lgs / gist:833756
Created February 18, 2011 14:55
Sinatra Ajax Layout
get '/' do
haml :index, :layout => !request.xhr?
end
@lgs
lgs / gist:902512
Created April 4, 2011 21:45
rails new rails3-mongoid-omniauth-simple -m http://railswizard.org/66c91989aae353098e2d.rb -J -O -T
# >---------------------------------------------------------------------------<
#
# _____ _ _ __ ___ _
# | __ \ (_) | \ \ / (_) | |
# | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
# | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
# | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| |
# |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_|
#
# This template was generated by RailsWizard, the amazing and awesome Rails
@lgs
lgs / pinger.rb
Created June 20, 2011 15:13 — forked from technoweenie/pinger.rb
ZeroMQ pub/sub demo
require 'zmq'
context = ZMQ::Context.new
pub = context.socket ZMQ::PUB
pub.setsockopt ZMQ::IDENTITY, 'ping-pinger'
pub.bind 'tcp://*:5555'
i=0
loop do
pub.send "ping pinger #{i+=1}" ; sleep 1
end
@lgs
lgs / mongo_pubsub.rb
Created June 28, 2011 23:38 — forked from octplane/mongo_pubsub.rb
Simple Pub/Sub system using MongoDB, capped collections and tailable cursors in ruby
require 'rubygems'
require 'mongo'
module MongoPubSub
QUEUES_COLLECTION = 'queues'
class EndSubscriptionException < Exception; end
class Publisher
def initialize(queue_name, mongo_connection)
# Initialize queue collection as a capped collection
if not mongo_connection[QUEUES_COLLECTION].collection_names.include?(queue_name)
@lgs
lgs / hamlhtml5boilerplate.html.haml
Created July 27, 2011 16:29 — forked from neiled/hamlhtml5boilerplate.html.haml
My haml version of the html 5 boiler plate code
!!! 5
/[if lt IE 7] <html lang="en" class="no-js ie6">
/[if IE 7 ] <html lang="en" class="no-js ie7">
/[if IE 8 ] <html lang="en" class="no-js ie8">
/[if IE 9 ] <html lang="en" class="no-js ie9">
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
%head
%meta{:charset => "utf-8"}/
/
Always force latest IE rendering engine (even in intranet) &amp; Chrome Frame
# Basic tagging system for mongoid documents.
# jpemberthy 2010
#
# class User
# include Mongoid::Document
# include Mongoid::Document::Taggable
# end
#
# @user = User.new(:name => "Bobby")
# @user.tag_list = "awesome, slick, hefty"
@lgs
lgs / ci_countries.html
Created December 3, 2011 17:11 — forked from carlok/ci_countries.html
Google Geo Chart API used to show the countries you can visit just having an Italian Identity Card
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
/*
Carlo Perassi - http://perassi.org/ - 2011
based on:
http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
http://code.google.com/apis/ajax/playground/?type=visualization#geo_chart
http://code.google.com/intl/it-IT/apis/chart/interactive/docs/gallery/geochart.html
2011-12-25T09:18:03+00:00 app[web.1]: Start scheduled watched repos sync per user2011-12-25 09:18:03 +0000
2011-12-25T09:18:03+00:00 app[web.1]:
2011-12-25T09:18:03+00:00 app[web.1]: End scheduled watched repos sync per user2011-12-25 09:18:03 +0000
2011-12-25T09:18:03+00:00 app[web.1]:
2011-12-25T09:18:03+00:00 app[web.1]:
2011-12-25T09:18:06+00:00 app[web.1]: >> Thin web server (v1.3.1 codename Triple Espresso)
2011-12-25T09:18:06+00:00 app[web.1]: >> Maximum connections set to 1024
2011-12-25T09:18:06+00:00 app[web.1]: >> Listening on 0.0.0.0:33856, CTRL+C to stop
2011-12-25T09:18:06+00:00 heroku[web.1]: State changed from starting to up
2011-12-25T09:18:08+00:00 app[web.1]: Dalli/SASL authenticating as app1707530%40heroku.com
lsoave@ubuntu:~/rails/github/rails_apps_composer$ rake print --silent RECIPES=jquery,haml,rspec,cucumber,guard,mongoid,seed_database,add_user,omniauth,home_page,home_page_users,css_setup,application_layout,html5,navigation,users_page,omniauth_email,cleanup,ban_spiders,extras,git > ./template.txt --trace
** Invoke print (first_time)
** Execute print
rake aborted!
undefined method `requires' for nil:NilClass
/home/lsoave/rails/github/rails_apps_composer/lib/rails_wizard/template.rb:34:in `block in recipes_with_dependencies'
/home/lsoave/rails/github/rails_apps_composer/lib/rails_wizard/template.rb:33:in `each'
/home/lsoave/rails/github/rails_apps_composer/lib/rails_wizard/template.rb:33:in `recipes_with_dependencies'
/home/lsoave/rails/github/rails_apps_composer/lib/rails_wizard/template.rb:22:in `resolve_recipes'
(erb):23:in `compile'