Skip to content

Instantly share code, notes, and snippets.

View ngryman's full-sized avatar

Nicolas Gryman ngryman

View GitHub Profile
@ngryman
ngryman / code.asm
Created May 30, 2015 14:02
Strange deopt.
[deoptimize global object @ 0x30ea29d106e9]
--- FUNCTION SOURCE (optCompare) id{0,0} ---
(a, b) {
return a['foo'] === b['foo']
}
--- END ---
--- FUNCTION SOURCE (deoptCompare) id{1,0} ---
(a, b) {
var prop = 'foo'
@ngryman
ngryman / trace.js
Created May 31, 2015 22:20
Trace optimizations in v8
// warm up
fn()
fn()
// try to optimize
;%OptimizeFunctionOnNextCall(compare)
// call optimized
fn()
@ngryman
ngryman / css3.scss
Created November 1, 2011 11:18
SASS compact CSS3
@mixin border-radius($values) {
@include css3-prefix(3, border-radius, $values);
}
@mixin box-shadow($x, $y, $offset, $color) {
@include css3-prefix(4, box-shadow, $x $y $offset $color);
$iecolor: '#' + red($color) + green($color) + blue($color);
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}');
-ms-filter: quote(progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}'));
@ngryman
ngryman / Jakefile
Created September 15, 2012 16:44
git deploy
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
var fs = require('fs');
task('install-deps', ['setup'], function() {
console.log('\n\n > Attempting to install dependencies via npm\n'.blue);
console.log('\tExecuting command:\n\t$ npm install\n'.grey);
var npm = spawn('npm', ['install']);
@ngryman
ngryman / service.sh
Created October 4, 2012 16:50
Post: System V with forever for your node.js application
#! /bin/sh
### BEGIN INIT INFO
# Provides: your_application
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: your fancy description that no one will see ;)
@ngryman
ngryman / index.html
Created November 6, 2012 15:50
html5shiv & set(Timeout|Interval) fix
<!-- html5shiv & set(Timeout|Interval) fix -->
<!--[if lte IE 9]>
<script>
/*@cc_on(function(a,b){function r(a){var b=-1;while(++b<f)a.createElement(e[b])}if(!(!window.attachEvent||!b.createStyleSheet||!function(){var a=document.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}())){a.iepp=a.iepp||{};var c=a.iepp,d=c.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",e=d.split("|"),f=e.length,g=new RegExp("(^|\\s)("+d+")","gi"),h=new RegExp("<(/*)("+d+")","gi"),i=/^\s*[\{\}]\s*$/,j=new RegExp("(^|[^\\n]*?\\s)("+d+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),k=b.createDocumentFragment(),l=b.documentElement,m=l.firstChild,n=b.createElement("body"),o=b.createElement("style"),p=/print|all/,q;c.getCSS=function(a,b){if(a+""===undefined)return"";var d=-1,e=a.length,f,g=[];while(++d<e){f=a[d];if(f.disabled)continue;b=f.media||b,p.test(b)&&g.push(c.getCSS(f.imports,b),f.c

CSS

Put custom CSS properties like -js-myprop: myval ().

@ngryman
ngryman / camecase.js
Created March 7, 2013 22:22
camel case sanitizing
function sanitize(obj) {
if ($.isArray(obj)) {
for (var i = 0, len = obj.length; i < len; i++) {
obj[i] = sanitize(obj[i]);
}
}
else {
for (var p in obj) {
if (!obj.hasOwnProperty(p)) continue;
if ('object' == typeof obj[p]) {
@ngryman
ngryman / octo-search.js
Created February 11, 2016 17:04
Search something on Github - wip
function checkValidity(url) {
return /https:\/\/github.com\/[\w-.]+\/[\w+.]/i.test(url)
}
function setup(baton) {
baton.baseUrl = 'https://api.github.com/repos/' + baton.owner + '/' + baton.repo + '/git'
return Promise.resolve(baton)
}
function fetchMasterRef(baton) {
@ngryman
ngryman / index.js
Last active May 26, 2016 17:57
Browserify incremental memory cache bug
'use strict'
const browserify = require('browserify')
const concat = require('concat-stream')
const delay = require('delay')
const fs = require('fs')
const incremental = require('browserify-incremental')
const forceMode = '--force' === process.argv[2]