Skip to content

Instantly share code, notes, and snippets.

View jhsu's full-sized avatar
💀
compliant with future standards

Joe Hsu jhsu

💀
compliant with future standards
  • MineHub
  • New York, NY
  • X @jhsu
View GitHub Profile
#!/bin/bash
# from http://snippets.dzone.com/posts/show/10897
# source this file from bashrc
GOT_AGENT=0
for FILE in $(find /tmp/ssh-???*[0-9]* -type s -user ${LOGNAME} -name "agent.[0-9]*")
do
SOCK_PID=${FILE##*.}

redis @qrush

smart cache, job queues, high speed analytics

binary ops (2.2+)

> touch normal.txt
> stat -f "%Sp" normal.txt
var redis = require('redis');
var client = redis.createClient();
client.set('test', 'hello, world!');
console.log(client.get('test'));
// => undefined
client.get('test', redis.print);
// => Reply: hello, world!
#!/usr/bin/env ruby
require 'fileutils'
require 'colorize'
MUSIC_DIR="/home/jshsu/Media/music/"
songs = Dir.glob("*.mp3").select do |song|
(( Time.now - File.ctime(song) ) / 60 / 60 / 24) >= 1
end
awk 'function wl() {\
rate=64000; \
return (rate/160)*(0.87055^(int(rand()*10)))}; \
BEGIN {\
srand(); \
wla=wl(); \
while(1) {\
wlb=wla; \
wla=wl(); \
if (wla==wlb) \
@jhsu
jhsu / vmigrate.sh
Created February 11, 2011 16:47
edit the most recent rails migration
alias emigrate="$EDITOR db/migrate/$(ls -lp db/migrate | tail -1 | awk '{print $NF}')"
@jhsu
jhsu / bot.rb
Created February 9, 2011 01:13
require 'cinch'
require 'open-uri'
require 'simple-rss'
require 'twitter'
Twitter.configure do |config|
end
class WnyGroup
@jhsu
jhsu / svg
Created January 28, 2011 19:20
#!/usr/bin/env bash
for i in {1..572}; do
curl -O "http://thenounproject.com/site_media/zipped/svg_$i.zip"
done
unzip '*.zip'
a.button, .buttons a, .display_control, .action_list h2
color: white
background-color: #5f76ad
border: 1px solid #447
-webkit-border-radius: 3px
-moz-border-radius: 3px
border-radius: 3px
-webkit-box-shadow: 0 1px 2px #aaa
-moz-box-shadow: 0 1px 2px #aaa
box-shadow: 0 1px 2px #aaa
@jhsu
jhsu / modify.js
Created January 24, 2011 21:09
ajax response when a post is liked on FB
for (;;);{"error":0,"errorSummary":"","errorDescription":"","errorIsWarning":false,"silentError":0,"payload":null,"css":["fiMEj","Z87wv"],"onload":["(function(){fc_expand(this, false);;}).apply(DOM.find(this.getRelativeTo(),\"textarea\"))","(function(){DOM.replace(this, HTML(\"\\u003cbutton class=\\\"like_link stat_elem as_link\\\" title=\\\"Like this item\\\" type=\\\"submit\\\" name=\\\"like\\\" onclick=\\\"fc_click(this, false); return true;\\\">\\u003cspan class=\\\"default_message\\\">Like\\u003c\\\/span>\\u003cspan class=\\\"saving_message\\\">Unlike\\u003c\\\/span>\\u003c\\\/button>\"));;}).apply(DOM.find(this.getRelativeTo(),\".like_link\"))","(function(){DOM.replace(this, HTML(\"\\u003cli class=\\\"ufiItem uiUfiLike\\\">\\u003cdiv class=\\\"UIImageBlock clearfix\\\">\\u003ca class=\\\"UIImageBlock_Image UIImageBlock_ICON_Image\\\" tabindex=\\\"-1\\\">\\u003clabel onclick=\\\"this.form.like.click();\\\">\\u003ci class=\\\"img sp_axw93h sx_0d9f5d\\\" title=\\\"Like this item\\\">\\u003c\\\/i>\\u003c\\\