Skip to content

Instantly share code, notes, and snippets.

View jordaaash's full-sized avatar
🌴
Not on vacation, I just love palm trees

Jordan jordaaash

🌴
Not on vacation, I just love palm trees
View GitHub Profile
@jordaaash
jordaaash / public_path.js
Created March 8, 2016 21:23
Deterministic filename-based CDN sharding
'use strict';
var publicPath = require('./static_path')(process.env.PUBLIC_PATH); // e.g. PUBLIC_PATH=https://static%d.domain.com/
module.exports = publicPath;
@jordaaash
jordaaash / esnextbin.md
Created February 14, 2016 02:46
esnextbin sketch
#!/usr/bin/env bash
for sha in `git rev-list HEAD..$1`; do
clear
git show --color $sha | less -XE
echo
while true; do
read -p "Do you wish to use this commit (y/n/q) ? " answer
case $answer in
[Yy]* ) git cherry-pick $sha;;
@jordaaash
jordaaash / resize_mixin.js
Created August 26, 2015 19:17
Resize mixin for responsive components
'use strict';
var ResizeMixin, raf;
if (typeof window === 'undefined') {
ResizeMixin = {};
}
else {
raf = require('raf');
ResizeMixin = {
irb(main):007:0> class Numeric
irb(main):008:1> def reverse
irb(main):009:2> self.class
irb(main):010:2> end
irb(main):011:1> end
=> :reverse
irb(main):012:0> 2.reverse
=> Fixnum
'use strict';
var React = require('react');
var P = React.PropTypes;
var PureRenderMixin = require('react/lib/ReactComponentWithPureRenderMixin');
var Waypoints;
if (typeof window !== 'undefined') {
Waypoints = require('waypoints/lib/noframework.waypoints');
Waypoints.Inview = require('waypoints/lib/shortcuts/inview');
@jordaaash
jordaaash / cover.styl
Last active May 23, 2017 08:10
Cross-browser object-fit: cover mixin
cover(width = inherit, height = inherit, min-width = 100%, min-height = 100%)
// Chrome, Safari
@media screen and (-webkit-min-device-pixel-ratio: 0)
object-fit cover
height height
width width
// Firefox
@-moz-document url-prefix()
&
object-fit cover
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#First released as C++ program by Hiroyuki Tsutsumi as part of the free software suite “Beer”
#I thought porting it to Python could be both a challenge and useful
from sys import argv, exit, getsizeof
from struct import pack_into, unpack_from
def ceil4(n):
'use strict';
var path = require('path');
var Class;
try {
Class = (new Function("'use strict'; return class Class {};"))();
}
catch (error) {}
@jordaaash
jordaaash / evil_eval.js
Last active August 29, 2015 14:19
Some crazy behavior discovered while playing around with "sandboxing" some indirectly eval'd code by shadowing in-scope variables. The first function works as expected (this and global have been shadowed in our indirect lexical scope). But if we run another call inside it without the same shadow, it doesn't inherit the indirect lexical scope, bu…
// The outer function can't access shadowed variables from the original scope ...
> (new Function('global', "'use strict'; return [typeof this, typeof global];"))();
[ 'undefined', 'undefined' ]
// ... but an inner function can (!)
> (new Function('global', "'use strict'; return (new Function(\"'use strict'; return [typeof this, typeof global];\"))();"))();
[ 'undefined', 'object ']
// It can read them.
> var foo = 'foo';