Skip to content

Instantly share code, notes, and snippets.

View druzn3k's full-sized avatar

Maurizio Del Corno druzn3k

View GitHub Profile
@druzn3k
druzn3k / after.dot
Created November 16, 2012 13:49 — forked from gnarg/after.dot
Graphviz files for reference graph refactoring example
digraph AlphaSoup {
"@state0"
"@state1"
"@state2"
node[shape=box]
"E.report"
node[color=green]
"A#ones"
@druzn3k
druzn3k / caller_method_name.rb
Created November 23, 2012 14:46 — forked from mikezter/caller_method_name.rb
Get calling method name in Ruby
module CallerMethodName
extend self
def caller_method_name
parse_caller(caller(2).first).last
end
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = Regexp.last_match[1]
line = Regexp.last_match[2].to_i
@druzn3k
druzn3k / install-node-redis.sh
Created November 23, 2012 16:19 — forked from nilakanta/install-node-redis.sh
Install Node.js & Redis on ubuntu
#!/bin/sh
##############################################################
#
# Rock-Solid Node.js Platform on Ubuntu (http://apptob.org/)
# Auto-config by apptob.org
# Author: Ruslan Khissamov, email: [email protected]
# GitHub: https://github.com/rushis
#
##############################################################
@druzn3k
druzn3k / changes.md
Created November 28, 2012 15:47 — forked from funny-falcon/changes.md
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@druzn3k
druzn3k / email.conf
Created December 5, 2012 02:19 — forked from rtanglao/email.conf
sendmail.rb
from_address = [email protected]
to_address = [email protected]
p = 'yourgmailpassword'

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Redirection</title>
</head>
<body>
<!-- iframe used for attempting to load a custom protocol -->
<iframe style="display:none" height="0" width="0" id="loader"></iframe>
@druzn3k
druzn3k / main.py
Created April 2, 2013 08:37 — forked from luuhq/main.py
from original import CallMe
CallMe()

This is a proof-of-concept of a couple of concurrent data structures written in Ruby.

The implementations are heavily commented for those interested. There are benchmarks (with results) included below. The results are interesting, but, as always, take with a grain of salt.

Data structures

AtomicLinkedQueue is a lock-free queue, built on atomic CAS operations.

# How Clearance / Hoptoad does it
module Clearance
class << self
attr_accessor :configuration
end
def self.configure
self.configuration ||= Configuration.new
yield(configuration)
end