Skip to content

Instantly share code, notes, and snippets.

@portertech
portertech / tailable.rb
Created November 7, 2010 05:46
tailable cursor (MongoDB)
#!/usr/bin/ruby -w
require 'rubygems'
require 'mongo'
require 'thread'
include Mongo
db = Connection.new('localhost',27017,:slave_ok => true).db('test')
coll = db['cappedCollection']
@akitaonrails
akitaonrails / Gemfile
Created January 8, 2011 19:55
AkitaOnRails.com Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
platforms :jruby do
gem 'activerecord-jdbc-adapter', :require => false
gem 'activerecord-jdbcmysql-adapter', :require => false
@viktorklang
viktorklang / PostStart.scala
Created March 5, 2011 23:13
PostStart implementation for Akka
trait PostStart { actor: Actor =>
def postStart: Unit
override def preStart {
actor.become {
case "PostStart" => try { postStart } finally { actor.unbecome }
}
actor.self ! "PostStart"
}
}
@ayosec
ayosec / README.md
Created November 17, 2011 00:18
Custom keyboard for X

So, what's this?

A little modification over the default spanish keyboard.

With this rules you can type á with «AltGr»+«a», é with «AltGr»+«e», whatever. The symbol is on «AltGr»+«e», and ® is on «AltGr»+«Shift»+«e»

Installation

  • Create a directory ~/.xkb and download the custom and load_custom_xkb.sh
  • Add /home/.../.xkb/load_custom_xkb.sh to your session. In GNOME you can use the gnome-session-propertiescommand.
@rafalrusin
rafalrusin / fbtest.c
Created December 15, 2011 20:22
Linux Frame Buffer Test
#include <linux/fb.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>
@vasilisvg
vasilisvg / HTML-presentation-tools.md
Created January 14, 2012 13:53
HTML presentation tools

#HTML presentation tools

There are many HTML presentation tools and they are all created for slightly different reasons. Here's an overview. Please let me know if I forgot any.

##CSSS

CSS-based SlideShow System

@ayosec
ayosec / .bashrc
Last active September 30, 2015 03:08
Some dot-files
# For devel machines
# PS1 in use, one per chroot jail
PS1='\[\e[36m\]\u@'`cat ~/.machine_name`' \[\e[32m\][$rvm_env_string] \[\e[35m\]($(git symbolic-ref HEAD 2> /dev/null | xargs -r basename))\[\e[36m\] \w\$\[\e[m\] '
PS1='\[\e[0;48;5;229m\]\u@'`cat ~/.machine_name`' \[\e[32m\][$rvm_env_string] \[\e[35m\]($(git symbolic-ref HEAD 2> /dev/null | xargs -r basename))\[\e[36m\] \w\$\[\e[m\] '
@jaju
jaju / pi.rb
Created March 25, 2012 16:30
Akka.io - Pi calculating actors example ported to JRuby
require 'java'
require 'mvn:org.scala-lang:scala-library'
require 'case'
module Akka
include_package 'akka.actor'
include_package 'akka.util.duration'
java_import 'akka.routing.RoundRobinRouter'
java_import 'akka.util.Duration'
end
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"

Inheritance is a key concept in most object-oriented languages, but applying it skillfully can be challenging in practice. Back in 1989, M. Sakkinen wrote a paper called Disciplined inheritance that addresses these problems and offers some useful criteria for working around them. Despite being more than two decades old, this paper is extremely relevant to the modern Ruby programmer.

Sakkinen's central point seems to be that most traditional uses of inheritance lead to poor encapsulation, bloated object contracts, and accidental namespace collisions. He provides two patterns for disciplined inheritance and suggests that by normalizing the way that we model things, we can apply these two patterns to a very wide range of scenarios. He goes on to show that code that conforms to these design rules can easily be modeled as ordinary object composition, exposing a solid alternative to tradi