Skip to content

Instantly share code, notes, and snippets.

View imcotton's full-sized avatar
💭
Set your status

Cotton Hou imcotton

💭
Set your status
View GitHub Profile

Keybase proof

I hereby claim:

  • I am imcotton on github.
  • I am imcotton (https://keybase.io/imcotton) on keybase.
  • I have a public key ASB8tlpScf4P4pm4kJkTZtn6DcOc2UvPfnUE3xp9POVrbQo

To claim this, I am signing this object:

@imcotton
imcotton / gist:5276331
Last active December 15, 2015 14:39
git commits reorder by rebase
$ git init
$ touch {a,b,c,d}
$ git status -s | awk '{print "git add",$2,";git commit -qm",toupper($2)}' | sh
$ git log --one-line
xxxxxxx D
xxxxxxx C
xxxxxxx B
@imcotton
imcotton / gist:3455299
Created August 24, 2012 20:31
jQuery pipe in CoffeeScript
each = (list) ->
return $.Deferred().resolve 'done' if not list?.length
t = new Date
$.post('/echo/json/', json: list.shift()).pipe (n) ->
console.log "round (#{n}) in #{ new Date - t }ms"
each list
@imcotton
imcotton / test.html
Created May 29, 2012 19:52
do in coffee-script
<html>
<head>
<script type="text/javascript" src="http://goo.gl/suRSw"></script>
</head>
<body>
<ul>
<li><a href="#" title="red">red</a></li>
<li><a href="#" title="blue">blue</a></li>
</ul>
@imcotton
imcotton / gist:1929997
Created February 28, 2012 06:01
Array random in CoffeeScript
Array::random = ->
[t, l] = [@concat(), @length]
while --l
r = (Math.random() * (l + 1)) | 0
[t[r], t[l]] = [t[l], t[r]]
return t
Array::random2 = ->
@sort -> Math.random() < 0.5
@imcotton
imcotton / tester.py
Created December 10, 2010 17:50
My first Python test drive
from shutil import rmtree, copytree, ignore_patterns
import StringIO
import os
import struct
import sys
import time
import zipfile
import zlib
import codecs
@imcotton
imcotton / SWFReader.as
Created April 20, 2010 13:14
lightweight SWF Tag reader
package
{
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.utils.Endian;
[SWF(width="400", height="300", frameRate="50")]