Skip to content

Instantly share code, notes, and snippets.

View nickleefly's full-sized avatar

Xiuyu Li nickleefly

  • Shanghai
View GitHub Profile
@nickleefly
nickleefly / answers.md
Created February 27, 2014 02:53 — forked from jpsim/answers.md
  1. Plain Strings (207): foo
  2. Anchors (208): k$
  3. Ranges (202): ^[a-f]*$
  4. Backrefs (201): (...).*\1
  5. Abba (169): ^(.(?!(ll|ss|mm|rr|tt|ff|cc|bb)))*$|^n|ef
  6. A man, a plan (177): ^(.)[^p].*\1$
  7. Prime (286): ^(?!(..+)\1+$)
  8. Four (199): (.)(.\1){3}
  9. Order (198): ^[^o].....?$
  10. Triples (507): (^39|^44)|(^([0369]|([147][0369]*[258])|(([258]|[147][0369]*[147])([0369]*|[258][0369]*[147])([147]|[258][0369]*[258])))*$)
git branch -vv --color=always | while read; do echo -e $(git log -1 --format=%ci $(echo "_$REPLY" | awk '{print $2}' | perl -pe 's/\e\[?.*?[\@-~]//g') 2> /dev/null || git log -1 --format=%ci)" $REPLY"; done | sort -r | cut -d ' ' -f -1,4-

git for-each-ref --format='%(committerdate:iso8601) %(committerdate:relative) %(refname)' --sort -committerdate
git for-each-ref --format='%(committerdate:iso8601) %(committerdate:relative) %(refname)' --sort -committerdate refs/heads/
git for-each-ref --format='%(committerdate:short),%(authorname),%(refname:short)' --sort=committerdate refs/heads/ | column -t -s ','

for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
for branch in `git branch -l | grep -v '*'`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@nickleefly
nickleefly / .zshrc
Last active August 29, 2015 14:14 — forked from SlexAxton/.zshrc
gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@nickleefly
nickleefly / GIF-Screencast-OSX.md
Last active August 29, 2015 14:16 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@nickleefly
nickleefly / nextTick.js
Created August 1, 2012 05:10 — forked from mmalecki/nextTick.js
process.nextTick vs setTimeout(fn, 0)
for (var i = 0; i < 1024 * 1024; i++) {
process.nextTick(function () { Math.sqrt(i) } )
}
@nickleefly
nickleefly / readme-outline.md
Created October 9, 2012 16:22 — forked from indexzero/readme-outline.md
A quick outline of a README.md

README.md Outline

  • Header and a Brief description (should match package.json)
  • Example (if applicable)
  • Motivation (if applicable)
  • API Documentation: This will likely vary considerably from library to library.
  • Installation
  • Tests
  • Contributors
  • License
@nickleefly
nickleefly / 1-view-events.js
Created October 13, 2012 14:58 — forked from mxriverlynn/1-view-events.js
zombies! run!
MyView = Backbone.View.extend({
events: {
"click #someButton": "doThat",
"change #someInput": "changeIt"
},
doThat: function(){ ... },
changeIt: function(){ ... }
});
function runSpecs() {
// configure the spec runner
var specRunner = new Hilo.SpecRunner({
src: "Hilo",
specs: "specs",
helpers: "specs/Helpers"
});
// Handle any errors in the execution that
// were not part of a failing test
@nickleefly
nickleefly / promises.md
Created October 25, 2012 04:45 — forked from domenic/promises.md
You're Missing the Point of Promises

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
    // the rest of your code goes here.
});
@nickleefly
nickleefly / gist:3970960
Created October 29, 2012 01:58 — forked from bpaquet/gist:3922818
Zlib leak node v0.8.12
var zlib = require('zlib');
var completed = 0;
function printProcMem() {
if (completed % 100 == 0) {
var mem = process.memoryUsage();
console.log('%d %d %d %d',
completed, mem.rss / 1000000, mem.heapTotal / 1000000, mem.heapUsed / 1000000);
}