Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am haochi on github.
  • I am haochi (https://keybase.io/haochi) on keybase.
  • I have a public key whose fingerprint is 5D47 389B 14DB 0FAB 4B89 5984 B94C E161 FDCC C0D7

To claim this, I am signing this object:

@haochi
haochi / rotate
Last active December 6, 2016 15:48
Turn an image into a rotating gif
#!/usr/bin/env bash
# usage: ./rotate in_file_name out_file_name
in_file="$1"
out_file="$2"
turns=12
degree=$((360 / $turns));
rotated=()
for (( i=0; i<$turns; i++ )); do
@haochi
haochi / messages.js
Created January 10, 2013 05:54
Simple reddit messages search. Idea from /r/SomebodyMakeThis, http://redd.it/169agn.
(function ($) {
search(prompt("Enter Search Term:"));
function search(term, after) {
$.getJSON("/message/messages.json", {after: after}, function (res) {
var messages = res.data.children
, stop = false;
for (var i = 0, l = messages.length; i < l; i++) {
var message = messages[i];
if (message_a_match(message, term)) {
@haochi
haochi / reddit_search.js
Created October 14, 2012 04:59
Reddit Search
(function(){
function reddit_search(needle, subreddit, next){
$.ajax({
url: 'http://www.reddit.com/r/'+subreddit+'.json',
dataType: 'json',
data: {after: next},
success: function(r){
$.each(r.data.children, function(i, thread){
var t = thread.data;
if(t.title.match(needle) || t.selftext.match(needle)){
@haochi
haochi / LICENSE.txt
Created August 14, 2011 19:41 — forked from 140bytes/LICENSE.txt
Haversine Formula
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@haochi
haochi / LICENSE.txt
Created July 10, 2011 23:23 — forked from 140bytes/LICENSE.txt
tofu: tiny templating engine
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Haochi Chen <http://ihaochi.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE