Skip to content

Instantly share code, notes, and snippets.

View krukid's full-sized avatar

Viktors Buls krukid

  • Juro
  • Riga, Latvia
View GitHub Profile
@tmm1
tmm1 / gist:89588
Created April 3, 2009 00:54
simple EM chat server
require 'rubygems'
require 'eventmachine'
module ChatClient
def self.list
@list ||= []
end
def post_init
@name = "anonymous_#{rand(99999)}"
@ebisawa
ebisawa / ruby_skype_api_example.rb
Created September 20, 2009 08:34
Skype API example in Ruby
require 'dbus'
MYNAME = 'com.example.skype_api_client'
class SkypeAPI
def initialize(name = MYNAME)
bus = DBus.session_bus
service = bus.service("com.Skype.API")
objs = service.object("/com/Skype")
objs.introspect
@jstorimer
jstorimer / 016_session_store.rb
Created November 17, 2010 21:14
Multiple session store implementation
RedisSessionStore.logger = Rails.logger
session_options = {:expire_after => 1.day, :key_prefix => 'sessions'}
MultiSessionStore.stores[:plain] = [RedisSessionStore, session_options.merge(:key => '_session_id')]
MultiSessionStore.stores[:secure] = [RedisSessionStore, session_options.merge(:key => '_secure_session_id', :secure => ['production', 'staging'].include?(Rails.env))]
MultiSessionStore.default_store = :plain
MultiSessionStore.routes = [
['/admin', :secure],
]
@gvarela
gvarela / Gemfile
Created May 5, 2011 16:30
web sockets with eventmachine and redis pub/sub
# A sample Gemfile
source "http://rubygems.org"
gem "redis"
gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git'
gem "em-hiredis"
# gem "em-synchrony"
gem "em-websocket"
@sanjayk
sanjayk / gist:1174519
Created August 26, 2011 21:55
redis-rb, EventMachine::Synchrony::ConnectionPool and pipelined command
require 'benchmark'
require 'redis/connection/synchrony'
require 'redis/connection/hiredis'
require 'redis'
redis = EventMachine::Synchrony::ConnectionPool.new(size: 1) do
Redis.new(:password => 'my password',
:host => 'my host',
:port => my port)
end
require 'rubygems'
require 'em-http-request'
# Monkey-patched Gzip Decoder to handle
# Gzip streams.
#
# This takes advantage of the fact that
# Zlib::GzipReader takes an IO object &
# reads from it as it decompresses.
#
@waynezhang
waynezhang / gist:1495626
Created December 19, 2011 05:59
Tag Cloud for Jekyll on Github Pages
<div id='tag_cloud'>
{% for tag in site.tags %}
<a href="#{{ tag[0] }}" title="{{ tag[0] }}" rel="{{ tag[1].size }}">{{ tag[0] }}</a>
{% endfor %}
</div>
<ul id='tag_list'>
{% for tag in site.tags %}
<li class='tag_item' id='{{ tag[0] }}'>
<span class='tag_name'>{{ tag[0] }}</span>
@bartlomiejdanek
bartlomiejdanek / god
Created February 1, 2012 14:54
/etc/init.d/god
#!/bin/sh
### BEGIN INIT INFO
# Provides: god
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: God
@visnup
visnup / lock.css
Created May 5, 2012 20:31
"lock" orientation of a website for mobile (iPad, iPhone)
/* if portrait mode is detected, rotate the entire site -90 degrees to hint rotating to landscape */
@media (orientation: portrait) {
body {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);
}
}
@xdite
xdite / gist:3072362
Created July 8, 2012 19:10
deploy/asset.rb
# -*- encoding : utf-8 -*-
set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
namespace :deploy do
namespace :assets do
desc <<-DESC
Run the asset precompilation rake task. You can specify the full path \
to the rake executable by setting the rake variable. You can also \