Skip to content

Instantly share code, notes, and snippets.

View reqshark's full-sized avatar
🎚️
back at it

Bent Cardan reqshark

🎚️
back at it
View GitHub Profile
https://github.com/ricardochimal/taps

A Backbone.js demo app (Sinatra Backend)

Oct 16 2010

Updates

  • 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments

In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].

@reqshark
reqshark / hello_world_consumer.rb
Created June 10, 2012 17:26
RabbitMQ-consumer
if defined?(Bundler); Bundler.setup; else; require "rubygems"; end
require "amqp"
EventMachine.run do
AMQP.connect(:host => "localhost", :username => "guest", :password => "guest") do |connection|
puts "Connected. Waiting for messages... Hit Control + C to stop me."
channel = AMQP::Channel.new(connection)
exchange = channel.direct("hello-exchange", :durable => true, :auto_delete => false)
@reqshark
reqshark / hello_world_producer.rb
Created June 10, 2012 17:26
RabbitMQ-producer
if defined?(Bundler); Bundler.setup; else; require "rubygems"; end
require "amqp"
EventMachine.run do
AMQP.connect(:host => "localhost", :username => "guest", :password => "guest") do |connection|
puts "Connected. Hit Control + C to stop me."
channel = AMQP::Channel.new(connection)
channel.direct("hello-exchange", :durable => true, :auto_delete => false).
@reqshark
reqshark / unicorn.rb
Created July 2, 2012 23:03
Production Unicorns
app_dir = "/home/node/apps/routekickr"
app_name = "routekickr"
worker_processes 3
working_directory app_dir
# Load app into the master before forking workers for super-fast
# worker spawn times
preload_app true
# nuke workers after 60 seconds (the default)
@reqshark
reqshark / simple-mongodb-connection.rb
Created July 3, 2012 12:36
connecting to mongo from ruby
#!/usr/bin/env ruby
# ruby_simple_example.rb
#
# A sample ruby script covering connection to a MongoDB database given a
# fully-qualified URI. There are a few additional means, but we prefer the URI
# connection model because developers can use the same code to handle various
# database configuration possibilities (single, master/slave, replica sets).
#
# Author:: Mongolab
@reqshark
reqshark / mongomapper.rb
Created July 3, 2012 13:04
connecting to mongo from ruby
#!/usr/bin/env ruby
# mongomapper_simple_example.rb
#
# A sample ruby script covering connection to a MongoDB database given a
# fully-qualified URI, using the MongoMapper ODM.
# There are a few additional means, but we prefer the URI
# connection model because developers can use the same code to handle various
# database configuration possibilities (single, master/slave, replica sets).
#
@reqshark
reqshark / dependencies.rb
Created July 3, 2012 13:12
Quick RVM Install and all my favorite ruby dependencies
----- ruby dependencies -----
apt-get install gcc checkinstall build-essential automake openssl libreadline6 libreadline6-dev libc6-dev curl wget git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libsqlite3-0 libxml2-dev libpcre3 libpcre3-dev libicu-dev python-dev python-pip libxslt-dev autoconf libc6-dev ncurses-dev libtool bison subversion g++ openjdk-6-jre-headless libcurl4-openssl-dev libc6-dev libmysql++-dev nodejs nodejs-dev npm libv8-dev javascript-common libev-dev wget make redis-server openssh-server git-core python-dev python-pip libyaml-dev imagemagick
----- ----- ----- ----- -----
useradd masteroftheart -g sudo -s /bin/bash -m
echo "masteroftheart:gobigorgohome" | chpasswd
@reqshark
reqshark / user.rb
Created July 6, 2012 22:14
mongodb user model
class User
include MongoMapper::Document
safe
authenticates_with_sorcery!
key :name, String, :required => true
key :email, String, :unique => true
key :crypted_password, String
key :salt, String
@reqshark
reqshark / sorcery.rb
Created July 6, 2012 23:05
sorcery config file
Rails.application.config.sorcery.submodules = [:reset_password, :activity_logging, :external, :remember_me]
Rails.application.config.sorcery.configure do |config|
config.not_authenticated_action = :not_authenticated
config.save_return_to_url = true
config.cookie_domain = sorcery.kickr.io
# -- session timeout --
# config.session_timeout = 3600
# config.session_timeout_from_last_action = false
# -- activity logging --