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 / gist:724227
Created December 1, 2010 21:08
Bookmarklet to convert from unixtime
javascript:ts = prompt("Unix timestamp:"); date = new Date(ts*1000); alert(date.toUTCString());
@nickyleach
nickyleach / gist:724230
Created December 1, 2010 21:09
Bookmarklet to convert to unixtime
javascript:ds = prompt("Date string:"); date = new Date(ds); alert(date.getTime()/1000);
@nickyleach
nickyleach / find_category.php
Created December 10, 2010 01:43
Simple example of parsing Yelps category structure to dereference an ID
<?
function find_category($id, $categories){
if(!count($categories)) return false;
foreach($categories as $set){
if($set['id'] == $id) return $set['t'];
$category = find_category($id, $set['c']);
if($category) break;
}
cat /dev/null | tee *.log
<?
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);
@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){
$(window).bind('facebook.liked', function(href, widget){
// Do whatever stuff you need to here
});
@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;
@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