Skip to content

Instantly share code, notes, and snippets.

View SBoudrias's full-sized avatar

Simon Boudrias SBoudrias

View GitHub Profile
@bsatrom
bsatrom / hook_stdout.coffee
Created November 8, 2011 21:56
Samples for hooking into STDOUT for unit testing in Node.js
exports = module.exports
exports.setup = (callback) ->
write = process.stdout.write
process.stdout.write = ((stub) ->
(string, encoding, fd) ->
stub.apply process.stdout, arguments
callback string, encoding, fd)(process.stdout.write)
@paulirish
paulirish / rAF.js
Last active April 17, 2025 15:06
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@ShirtlessKirk
ShirtlessKirk / luhn.js
Last active January 6, 2025 16:01
Luhn validation algorithm
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,
@domenic
domenic / README.md
Created March 29, 2012 16:01
Cross-platform git hooks for Node.js

Here's how this works:

  • Include a git_hooks/ directory in your project, with these two files (plus other hooks if you want, written in a similar style).
  • Add "npm" to your devDependencies in package.json, so that the pre-commit hook can do its magic.
  • Add test and lint scripts to your package.json, e.g.
    "scripts": {
        "test": "mocha",
 "lint": "jshint ./lib --show-non-errors"
@SBoudrias
SBoudrias / JsHint settings
Created June 4, 2012 14:41
my basic settings for jshint for komodo edit
bitwise=true boss=true browser=true debug=true eqeqeq=true eqnull=true es5=true esnext=true expr=true immed=true iterator=true lastsemic=true laxbreak=true laxcomma=true loopfunc=true maxlen=120 multistr=true newcap=true noarg=true onecase=true onevar=true plusplus=true proto=true regexdash=true regexp=true scripturl=true shadow=true smarttabs=true strict=true sub=true supernew=true undef=true validthis=true withstmt=true predef=["window","document"]
@remy
remy / dateutil.js
Created September 2, 2012 23:10
Super simple library for date time formatting.
var dateUtil = function () {
var monthDict = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
return {
time: function (date) {
var hour = date.getHours(),
min = date.getMinutes() + "",
ampm = 'AM';
if (hour == 0) {
hour = 12;
@include handhelds {
table.responsive {
width: 100%;
thead {
display: none;
}
tr {
display: block;
}
td, th {
@divanvisagie
divanvisagie / LED_Server.js
Last active May 1, 2020 08:03
Web server controlled LED on Arduino using johnny-five and the dev version of NARF( https://github.com/divanvisagie/NARF/tree/Dev ) , Five minute hack. LED is placed on pin 13.Once you get LED_Server running, the client at index.html can control the LED on your Arduino , you will have to change the GET urls in index.html if you are using it on a…
var five = require( 'johnny-five' ),
board,
narf = require( 'narf' );
board = new five.Board();
/*
Executes a command and fires event when done that
will return the command output
*/
@SlexAxton
SlexAxton / .zshrc
Last active March 24, 2025 17:35
My 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