Skip to content

Instantly share code, notes, and snippets.

# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# What I expect...
~ (0.000454) SELECT `id`, `message`, `date_posted`, `last_edited`, `last_edited_by`, `player_id`, `forum_board_id`, `forum_topic_id` FROM `forum_replies` WHERE `forum_topic_id` IN (3, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 57, 54, 51, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36) ORDER BY `id` DESC
~ (0.000309) SELECT `id`, `name`, `user_id`, `active`, `age`, `level`, `life`, `strength`, `dexterity`, `intelligence`, `luck`, `bank`, `exp`, `energy`, `gender`, `wins`, `losses`, `stales`, `clan`, `last_killed`, `last_killedby`, `date_created`, `last_macro`, `macro_points`, `energy_refills`, `points`, `char_class`, `last_active`, `guild_id`, `forum_topic_id`, `forum_reply_id` FROM `players` WHERE `id` IN (1,2) LIMIT 1
==> ./configure --disable-osx-universal-binary --without-perl --prefix=/usr/local/Cellar/imagemagick/6.7.1-1 --enable-shared --disable-stati
==> make install
/bin/sh ./config/mkinstalldirs . ltdl/
cp ./ltdl/argz_.h ltdl/argz.h-t
mv ltdl/argz.h-t ltdl/argz.h
make install-am
CC ltdl/argz.lo
/bin/sh ./libtool --silent --tag=CC --mode=compile /usr/bin/cc -std=gnu99 -std=gnu99 -DHAVE_CONFIG_H -I. -I./config -I. -I. -DLT_CONFIG_H='<config/config.h>' -DLTDL -I. -I. -Iltdl -I./ltdl -I./ltdl/libltdl -I./Magick++/lib -I/usr/X11/include/freetype2 -I/usr/X11/include -I/usr/X11/include -I/usr/include/libxml2 -D_THREAD_SAFE -D_THREAD_SAFE -pthread -fopenmp -march=core2 -msse4.1 -w -pipe -O3 -Wall -D_THREAD_SAFE -pthread -c -o ltdl/argz.lo ltdl/argz.c
CC coders/coders_art_la-art.lo
/bin/sh ./libtool --silent --tag=CC --mode=compile /usr/bin/cc -std=gnu99 -std=gnu99 -DHAVE_CONFIG_H -I. -I./config -I/usr/X11/include/freetype2 -I/usr/X11/include -I/usr/X11/include -I/usr/include/libxml2 -D_THREAD_SAFE -D_
@durango
durango / about.md
Created August 21, 2011 18:59 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@durango
durango / ev.rb
Created August 21, 2011 00:15 — forked from dkubb/ev.rb
Poor-man's Embedded Value
class User
include DataMapper::Resource
property :id, Serial
property :username, String, :required => true, :unique => true
property :address_street_address, String
property :address_location, String
property :address_subdivision, String
property :address_country, String
# Disable :layout for any ajax request
# (easily allows you to support browsers with/without JS)
# Same concept can be applied to render, erb, etc.
module Sinatra
class Base
def haml(template, options={}); options.merge!(:layout => false) if request.xhr?; super; end
end
end
require 'redis'
# Easily use Redis anywhere from controllers, views, and more importantly models.
class RedisCache
def initialize
@redis = Redis.new(:host => "127.0.0.1", :port => 15501, :password => "password", :db => 1)
end
def method_missing(id, *args, &block)
require 'bcrypt'
require 'securerandom'
class User
include DataMapper::Resource
include BCrypt
property :id, Serial
property :email, String, :required => true, :index => :login, :unique => true, :unique_index => true, :format => :email_address
property :password_hash, Text, :required => true, :index => :login
class Mailbox
include DataMapper::Resource
property :id, Serial
property :title, String, :required => true, :length => 1..30
property :message, Text, :required => true, :length => 1..3000
property :date_sent, DateTime, :default => proc { DateTime.now }
belongs_to :to, 'Player'
belongs_to :from, 'Player'
==> ./configure --disable-osx-universal-binary --without-perl --prefix=/usr/local/Cellar/imagemagick/6.7.1-1 --enable-shared --disable-stat
==> make install
/bin/sh ./config/mkinstalldirs . ltdl/
cp ./ltdl/argz_.h ltdl/argz.h-t
mv ltdl/argz.h-t ltdl/argz.h
make install-am
CC ltdl/loaders/dlopen.lo
CC ltdl/argz.lo
CC coders/coders_art_la-art.lo
CC coders/coders_avs_la-avs.lo