Skip to content

Instantly share code, notes, and snippets.

View rkh's full-sized avatar
👀
heeeyyyy

Konstantin Haase rkh

👀
heeeyyyy
View GitHub Profile
# coding: binary
# IRC <-> Campfire bridge, set IRC password to SUBDOMAIN:TOKEN and connect to localhost:6667
# Remove special chars/spaces from channel names (ie "Foo Bar" becomes #FooBar). Only tested with LimeChat.
# gem install excon && gem install yajl-ruby -v "< 2.0"
%w[socket thread uri excon yajl yajl/http_stream].each { |lib| require lib }
Thread.abort_on_exception = true
[:INT, :TERM].each { |sig| trap(sig) { exit } }
server = TCPServer.new('127.0.0.1', 6667)
loop do
@rkh
rkh / chat.rb
Created December 14, 2011 12:55
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@rkh
rkh / warning_filter.rb
Created February 21, 2014 07:45
Run Ruby with warnings enabled. Without going crazy.
require 'delegate'
module Support
class WarningFilter < DelegateClass(IO)
def write(line)
super if line !~ /^\S+gems\/ruby\-\S+:\d+: warning:/
end
end
end
@rkh
rkh / rack_example.ru
Created December 8, 2011 16:19 — forked from mattetti/rack_example.ru
Very basic rack application showing how to use a router based on the uri and how to process requests based on the HTTP method used.
#########################################
# Very basic rack application showing how to use a router based on the uri
# and how to process requests based on the HTTP method used.
#
# Usage:
# $ rackup rack_example.ru
#
# $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:9292/ideas
# $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:9292/ideas
# $ curl localhost:9292/ideas

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
  • NBC
require 'thread'
class Worker
def initialize(count = 1)
@queue, @closing, @threads, @mutex = Queue.new, false, [], Mutex.new
add_worker(count)
end
def add_worker(count = 1)
@mutex.synchronize do
#define STRING char *
#define IF if(
#define THEN ){
#define ELSE } else {
#define FI ;}
#define WHILE while (
#define DO ){
#define OD ;}
#define INT int
#define BEGIN {
@rkh
rkh / Gemfile
Created December 14, 2011 11:16 — forked from blambeau/Gemfile
jquery-sinatra-streaming
source "http://rubygems.org/"
gem "sinatra", "~> 1.3.0"
gem "thin"
require 'eventmachine'
require 'socket'
require 'kgio'
server = Kgio::TCPServer.new('0.0.0.0', 4242)
module Dispatch
def notify_readable
io = @io.kgio_tryaccept or return
EventMachine.attach(io, Server)
@rkh
rkh / gist:1011964
Created June 7, 2011 09:43
Conferences in the Americas

Conferences in the Americas

Only conferences included starting from late August and where the CFP is still open.

Conference Place Date CFP Deadline