Skip to content

Instantly share code, notes, and snippets.

View smrchy's full-sized avatar

Patrick Liess smrchy

View GitHub Profile
@smrchy
smrchy / redisZsetWorker.js
Created February 16, 2011 12:26
Create an easy to use object from a Redis sorted set
// ## redisZsetWorker
// Requires Underscore.js
// http://documentcloud.github.com/underscore/
//
// Creates an easy to use object from a Redis sorted set.
//
// * Calculate to total, min and max of all scores
// * Calculate a font size (default: 1-10) to create a tag cloud
// * Calculate the percentage for each item
//
@smrchy
smrchy / redis_migrate_keys.js
Created March 1, 2011 13:45
Move some keys from one redis to another redis instance
var sys = require("sys"),
url = require("url"),
_ = require('./underscore-min'),
redisclient = require("redis"),
redisNEW = redisclient.createClient(6379,'127.0.0.1');
redisOLD = redisclient.createClient(6379,'192.168.11.18')
function moveHash(rep) {
@smrchy
smrchy / aws_public.cfc
Created March 17, 2011 14:03
Amazon Webservices CFC for Coldfusion
<!---
Parts of this are based on Tim Dawe's
http://amazonsig.riaforge.org
and
Joe Danziger's Amazon S3 REST Wrapper
http://amazons3.riaforge.org/
Written by Patrick Liess
@smrchy
smrchy / example.cfm
Created September 16, 2011 19:55
queryToObject
<!--- suppose your query you did with cfquery is stored in the variable myQuery --->
<script>
var q = #SerialzeJSON(myQuery,true)#;
// make an easy to use object
var newQuery = queryToObject(q);
console.log(newQuery);
</script>
@smrchy
smrchy / arraydiffupdate.html
Created November 4, 2011 12:09
Difference and intelligent update of two arrays
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.1.7/underscore-min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
@smrchy
smrchy / hack.sh
Created March 31, 2012 11:53 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get upgrade
@smrchy
smrchy / fisher-yates-coffeescript.coffee
Created July 12, 2012 13:29
Fisher-Yates shuffle in Coffeescript
# Fisher-Yates shuffle in Coffeescript
#
# _shuffle(array)
#
# Returns a shuffled version of the array leaving the original untouched.
_shuffle = (obj) ->
shuffled = []
for e, i in obj
@smrchy
smrchy / gist:3414678
Created August 21, 2012 11:23 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
# Redis ZSET to Leaderboard
#
# Transform a Redis ZREVRANGE result which should be something like this:
# `["userid123",1234,"userid567",952,"someotherUser",200]`
#
# Result is an array like this:
# [
# {"u":"userid123","s":1234},
# {"u":"userid567","s":952},
# {"u":"someotherUser","s":200}