Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am nickyleach on github.
  • I am nleach (https://keybase.io/nleach) on keybase.
  • I have a public key whose fingerprint is 2CDE C5B4 5CCE 7DE7 360E 502C 1931 C762 BE52 E7C5

To claim this, I am signing this object:

@nickyleach
nickyleach / concat.sh
Created October 2, 2012 05:06
De-sharding Redis
scp redis-server-1:/var/lib/redis/appendonly.aof /var/lib/redis/appendonly.aof.1
scp redis-server-2:/var/lib/redis/appendonly.aof /var/lib/redis/appendonly.aof.2
cat /var/lib/redis/appendonly.aof.* > /var/lib/redis/appendonly.aof
@nickyleach
nickyleach / Lock.php
Created September 10, 2012 22:54
Simple redis-backed Mutex
<?
class Lock {
const TIMEOUT = 20;
const SLEEP = 100000;
/**
* Stores the expire time of the currently held lock
* @var int
@nickyleach
nickyleach / counter.css
Created January 17, 2012 23:50
Odometer Counter
.counter {
display:block;
float:left;
font-size:2em;
line-height:1.2em;
-webkit-box-reflect: below -15px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(60%, transparent), to(rgba(255,255,255,0.3)));
}
.counter span.digit {
background:#161616;
$(window).bind('facebook.liked', function(href, widget){
// Do whatever stuff you need to here
});
@nickyleach
nickyleach / Foo.php
Created April 16, 2011 17:20
PHP class which allows you to magically memcache method calls (with example)
<?
require 'Memcacheable.php';
class Foo extends Memcacheable {
public function __construct(){
$this->widget = "widget";
}
public function bar($arg){
<?
include 'ActivityFeed.php';
$feed = new ActivityFeed();
$feed->add(123, 'Nicky followed Kelly', time() + 5);
$feed->add(123, 'Nicky followed Josh', time() + 10);
$feed->add(123, 'Nicky earned 1200 points for being awesome!', time() + 30);
<?
include_once 'iredis.php';
class ActivityFeed {
private $redis;
public function __construct(){
$this->redis = new iRedis();
@nickyleach
nickyleach / git-sync
Created March 9, 2011 20:12
git alias to sync the current branch
[alias]
sync = "!f(){ local branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e \"s/* \\(.*\\)/\\1/\"`; git pull origin $branch && git push origin $branch; }; f"
cat /dev/null | tee *.log