Skip to content

Instantly share code, notes, and snippets.

View ngryman's full-sized avatar

Nicolas Gryman ngryman

View GitHub Profile
@ngryman
ngryman / em.scss
Created March 3, 2013 19:03
sass px to em mixin
// http://viljamis.com/blog/2013/prototyping-responsive-typography/?utm_source=Responsive+Design+Weekly&utm_campaign=76e7785581-Responsive_Design_Weekly_046&utm_medium=email
$browser-context: 16; // Default
@function em($pixels, $context: $browser-context) {
@return #{$pixels/$context}em
}

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]) {
// via http://twitter.com/izs/statuses/17744109574
var foo = 1;
var bar = 2;
foo = [bar, bar = foo][0];
$('.elem').on(VirtualPointer.MOVE_EVENT, function(e) {
if (!e.isTrigger) return;
// handler code
});
$(document).ready(function() {
var prefix = "https://gist.github.com/";
$('a[href^="' + prefix + '"]').each(function(i) {
var $anchor = $(this),
$el = $("<p></p>");
$anchor.replaceWith($el);
writeCapture.html($el, '<script src="'+$anchor.text()+'"></scr' + 'ipt>');
$anchor.remove();
});
});
@ngryman
ngryman / snippet.js
Last active February 14, 2019 23:55 — forked from necolas/snippet.js
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(d, u) {
var s = d.scripts[0],
i = u.length, g;
@ngryman
ngryman / _mq.scss
Created June 4, 2013 19:16
scss media queries.
$mq-small: 32rem /* 320px */ !default;
$mq-normal: 40rem /* 400px */ !default;
$mq-large: 68rem /* 680px */ !default;
$mq-xlarge: 100rem /* 1000px */ !default;
$mq-xxlarge: 128rem /* 1280px */ !default;
//
// small size
//
@ngryman
ngryman / rAF.js
Created June 19, 2013 03:41 — forked from paulirish/rAF.js
// 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'];