Skip to content

Instantly share code, notes, and snippets.

View nrk's full-sized avatar
🤔
はい、猫のように見えます。

Daniele Alessandri nrk

🤔
はい、猫のように見えます。
View GitHub Profile
@addyosmani
addyosmani / visibly.js
Created August 3, 2011 12:44
Cross-browser Page Visibility API polyfill
/*!
* isVis - v0.5.5 Aug 2011 - Page Visibility API Polyfill
* Copyright (c) 2011 Addy Osmani
* Dual licensed under the MIT and GPL licenses.
*/
(function () {
window.visibly = {
b: null,
q: document,
# igrigorik { ~ } > rvm use jruby
# Using /Users/igrigorik/.rvm/gems/jruby-1.6.2
# igrigorik { ~ } > gem install mvn:org.clojure:clojure
# Successfully installed mvn:org.clojure:clojure-1.3.0.b.1-java
# 1 gem installed
require 'rubygems'
require 'java'
require 'maven/org.clojure/clojure'
@ircmaxell
ircmaxell / Brainfuck.php
Created September 23, 2011 13:58
Brainfuck PHP Interpreter
<?php
require_once 'Memory.php';
require_once 'Stack.php';
require_once 'Expressions.php';
class Brainfuck {
public function run($code, $input, $eof = 0) {
$memory = new Memory(array_map('ord', str_split($input)), $eof);
@markoa
markoa / deploy.rb
Created October 10, 2011 13:31
Ingredients to monitor Resque with God automatically via Capistrano (on Ubuntu)
namespace :deploy do
desc "Hot-reload God configuration for the Resque worker"
task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}"
sudo "god start resque"
end
end
# append to the bottom:
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@daurnimator
daurnimator / ec.lua
Created November 22, 2011 03:56
A replacement for lua errors; based on coroutines.
local select = select
local error = error
local cocreate , coresume , corunning , costatus , coyield = coroutine.create , coroutine.resume , coroutine.running , coroutine.status , coroutine.yield
local getinfo = debug.getinfo
local err_signifier = { }
local ec = { }
local function xpcall_resume ( co , hand , ok , ... )

Redis + LibUV prototype README

Special thanks to Dušan Majkic (dmajkic, https://github.com/dmajkic/redis/) for his project on GitHub that gave us the opportunity to quickly learn some on the intricacies of Redis code. His project also helped us to build our prototype quickly.

Get source repository

First clone the Redis sources from https://github.com/antirez/redis.

  • On your computer create a working folder and cd into it.
  • Clone antirez/redis repository:
@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
@ircmaxell
ircmaxell / hash_pbkdf2.patch
Created January 19, 2012 18:30
hash_pbkdf2() addition patch
Index: ext/hash/php_hash.h
===================================================================
--- ext/hash/php_hash.h (revision 322459)
+++ ext/hash/php_hash.h (working copy)
@@ -127,6 +127,7 @@
PHP_FUNCTION(hash_update_file);
PHP_FUNCTION(hash_final);
PHP_FUNCTION(hash_algos);
+PHP_FUNCTION(hash_pbkdf2);
@ebouchut
ebouchut / LighttpdReverseProxyURLRewriting
Last active December 28, 2025 17:46
Lighttpd reverse-proxy to that matches an URL _and_ does URL rewriting #web #server #lighttpd
#server.modules += ( "mod_rewrite")
# Workaround to have a working reverse-proxy that matches an URL does URL rewriting in Ligghtpd.
#
# Ligtthpd 1.4.28 cannot perform both matching and URL rewriting at the same time.
# Therefore we need to define 2 proxies, one does the matching and bounce the request
# to the other one, in charge of rewriting the URL before proxying the request to the target server.
#
# More about this here:
# http://redmine.lighttpd.net/issues/164#note-9