Skip to content

Instantly share code, notes, and snippets.

# Rails 3 application template
# Usage: rails new app -JOT -m http://gist.github.com/460217.txt
# where J=no Prototype, O=no ActiveRecord, T=no TestUnit
# see http://mongoid.org/docs/installation/
# see also http://asciicasts.com/episodes/201-bundler
# see also http://github.com/josevalim/inherited_resources
# see also http://github.com/plataformatec/devise
# see also http://github.com/indirect/rails3-generators
mongo = yes? "Run MongoDB?"
@jtomson
jtomson / gist:771828
Created January 9, 2011 17:21 — forked from shripadk/gist:652819
some coffeescript-node-redis boilerplate
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'

Thin vs Puma

Run these two servers using the commands given in their source. Benchmark using:

ab -n 1000 -c 1000 http://localhost:8000/

I found thin can handle these requests without a problem. puma drops connections and causes ab to exit early.

With 200 threads, puma can handle 200 requests but does not respond promptly:

@al6x
al6x / 1_collection_spec.rb
Created January 10, 2012 09:54
Ruby vs NodeJS vs NodeJS + Async vs NodeJS + Fibers
require 'driver/spec_helper'
describe "Collection" do
with_mongo
it "should by default update all matched by criteria (not first as default in mongo)" do
db.units.save name: 'Probe', race: 'Protoss', status: 'alive'
db.units.save name: 'Zealot', race: 'Protoss', status: 'alive'
# Update.
anonymous
anonymous / gist:2387816
Created April 14, 2012 20:48
Example of using Meteor.methods() and Meteor.call()
if (Meteor.is_client) {
Template.hello.greeting = function () {
return "Welcome to XYZ.";
};
Template.hello.events = {
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
@pzol
pzol / README.md
Created June 5, 2012 07:23
RVM + Puma + Ubuntu

Running Puma on Nginx

I use the latest Puma v1.4.0 from rubygems.

Make sure you have nginx installed with these options:

>/opt/nginx/sbin/nginx -V
nginx version: nginx/1.0.15

built by gcc 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)

@cheeaun
cheeaun / firefoxos-phone-observations.md
Last active December 16, 2015 23:59
My observations on using Firefox OS phone, Peak, since 2 May 2013

My observations on using Firefox OS phone, Peak, since 2 May 2013

  • Auto-brightness is constantly changing when switching apps or views of an app, eventhough the surrounding ambient light doesn't change much. I've disabled it.
  • Press both 'Home' button and 'Sleep/wake' button, takes screenshot, like iPhone.
  • Gallery, Camera, Music app, etc don't work without a microSD memory card in the phone.
  • If 'USB mass storage' option is enabled in Settings app -> 'Media storage', Gallery and Camera app doesn't work while plugged in (charging) to the computer, stating that the memory card is in use.
  • 3 ways to install web apps; via Marketplace, Firefox browser or the Search screen. Sometimes generate different icons on the Home screen from each method.
  • Firefox browser seems to have a viewport issue, where web pages seems to be 2x zoomed out. Once the web page is added to Home screen, relaunch from there, the web page is no longer 2x zoomed out. [1] Marketplace app somehow still have issue.
  • Scrolling on t
@egonSchiele
egonSchiele / dining01.rb
Created May 13, 2013 01:50
A celluloid implementation of dining philosophers where the forks are actors too. Could cause deadlock since we wait on forks.
require 'rubygems'
require 'celluloid'
class Philosopher
include Celluloid
def initialize(name, left_fork, right_fork)
@name = name
@left_fork = left_fork
@right_fork = right_fork
self.think
@egonSchiele
egonSchiele / dining02.rb
Created May 13, 2013 01:53
Another implementation of the dining philosophers in Ruby using Celluloid. This time the forks are mutexes and we don't block to acquire them.
require 'rubygems'
require 'celluloid'
class Philosopher
include Celluloid
def initialize(name, left_fork, right_fork)
@name = name
@left_fork = left_fork
@right_fork = right_fork
self.think
# Builder file for sentry
#
FROM ubuntu
MAINTAINER Michael Crosby
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade