Skip to content

Instantly share code, notes, and snippets.

View NHQ's full-sized avatar

johnnyscript NHQ

View GitHub Profile
@NHQ
NHQ / less2stylus.coffee
Created February 9, 2012 19:50 — forked from lancejpollard/less2stylus.coffee
Convert LESS to Stylus for Twitter Bootstrap
# Quick hack of regular expressions to convert twitter bootstrap from LESS to Stylus
less2stylus = (string) ->
string = string
.replace(/^(\ *)(.+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/^(\ *)([^\ ]+)\ +\{\ *\n?\ *?/mg, "$1$2\n$1 ") # remove opening brackets
.replace(/\ *\{\ *\n*/g, "\n") # remove opening brackets again (some random cases I'm too lazy to think through)
.replace(/\ *\}\ *\n*/g, "\n") # remove closing brackets
.replace(/\;\ *?$/gm, "") # remove semicolons
.replace(/@(\w+):(\ *)\ /g, "\$$1$2 = ") # replace @variable: with $variable =
.replace(/\@/g, "\$")
@NHQ
NHQ / hack.sh
Created March 31, 2012 17:15 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@NHQ
NHQ / Websocket-speed-test.js
Created April 22, 2012 03:10
Test how fast your browser handles websockets with Node.js.
var server = require( 'http' ).createServer();
// our html template
var script = function( f ) {
// get just the content of this script
var s = /^[^\{]+\{\n?([\s\S]+)\}/.exec( f )[1];
return [
'<!DOCTYPE html><html>',
'<head>',
'<script type="text/javascript">',s,'</script>',
@NHQ
NHQ / test.js
Created August 18, 2012 07:58 — forked from getify/test.js
object JSON serialization that's circular-ref safe
// all this `toJSON()` does is filter out any circular refs. all other values/refs,
// it passes through untouched, so it should be totally safe. see the test examples.
Object.prototype.toJSON = function() {
function findCircularRef(obj) {
for (var i=0; i<refs.length; i++) {
if (refs[i] === obj) return true;
}
return false;
}
@NHQ
NHQ / make_touch_this.js
Created September 22, 2012 22:13
mc hammer javascript cross-compiler
#!/usr/bin/env node
// mc hammer javascript cross-compiler
// 1. youtube-dl http://www.youtube.com/watch?v=otCpCn0l4Wo -o cant_touch_this.flv
// 2. avconf -o cant_touch_this.flv cant_touch_this.wav
// 3. sox cant_touch_this.wav -t s16 -r 8k -o cant_touch_this.raw
// 4. run this file (node make_touch_this.js)
// 5. npm install -g baudio-party
// 6. baudio-party &
// 7. curl -sSNT cant_touch_this.js http://localhost:5000/0
@NHQ
NHQ / gist:4325215
Created December 18, 2012 05:06 — forked from anonymous/gist:4325197
// all values are of type [x, y]
// and are coordinates, x being time, y being amplitude
// ie. env = require('./')([1/16, 1], [1/32, .9], [3/32, .9], [1/2, 0])
// returns an amplitude to multiply yr sample by
module.exports = function(a, d, s, r){
function e(t, a, d, s, r){
for i in *; do
if [ -d "$i" ]; then
cd $i;
if [ -f "package.json" ]; then
zelda ../;
fi;
cd ..;
fi;
done
var asynth = require('../');
var jynth = require('jynth');
var synth = jynth();
var recording = true;
var playing = true;
var samples = [];
process.stdin.setRawMode(true);
@NHQ
NHQ / readme.md
Created December 20, 2015 22:58 — forked from max-mapper/readme.md
Video stabilization using VidStab and FFMPEG (Mac OS X)

Video stabilization using VidStab and FFMPEG

Examples here use the default settings, see the VidStab readme on GitHub for more advanced instructions.

Install ffmpeg with the vidstab plugin from homebrew

brew install ffmpeg --with-libvidstab
<!DOCTYPE html>
<html>
<head>
<title>CSS3 Checkbox</title>
<style type="text/css">
.checkbox {
width: 30px;
height: 30px;
background-color: #ddd;
position: relative;