Skip to content

Instantly share code, notes, and snippets.

View moimikey's full-sized avatar
:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
View GitHub Profile
@moimikey
moimikey / .editorconfig
Last active August 29, 2015 14:27
Project Boilerplate
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 2
indent_style = space
@moimikey
moimikey / coerce.js
Last active April 27, 2019 13:51
30 bytes to coerce "23" to Number, keep "apple" as String
/**
* function coerce(x) {
* return ''+x===x?(p=~~+x?r=+x:r=x):r=x
* }
* > undefined
* coerce(123)
* > 123
* coerce('123')
* > 123
* coerce('apple')
@moimikey
moimikey / index.js
Last active August 29, 2015 14:19
requirebin sketch
// look at your console!
var ISO3166 = require('iso3166-1')
console.log(ISO3166.from('USA').to3()) // USA
console.log(ISO3166.from('USA').to2()) // US
console.log(ISO3166.from('US').to3()) // USA
console.log(ISO3166.from('US').to2()) // US
console.log(ISO3166.fromLocale('en-US').to3()) // USA
console.log(ISO3166.fromLocale('en-US').to2()) // US
@moimikey
moimikey / index.js
Last active August 29, 2015 14:19
requirebin sketch
var locale = require('locale2');
document.write(locale);
@moimikey
moimikey / syncWith.md
Last active August 29, 2015 14:18
Idea for React sync with store via HOC

Did I steal this idea? Did I read this briefly once and all of a sudden it hit me? Maybe there's a Flux implementation that does something like this? Perhaps I should understand Flux a little more? Seems legit.

// wrapper

let syncWith = function syncWith(store) {
  return React.createClass({
    getInitialState() {
      return store.getState();
 },
@moimikey
moimikey / react-cursive-timer.jsx
Created March 18, 2015 04:34
React recursive timer animation
'use strict';
var React = require('react');
var Switch = React.createClass({
getInitialState: function() {
return {
switch: true
}
},
"use strict";
const assert = require('assert') // for tests
const deparam = url => {
const decodeUri = global.decodeURIComponent
const reduce = Array.prototype.reduce
const query = url.substr(url.indexOf('?') + 1).split('&')
return reduce.call(query, (memo, keyValue) => {
let key = keyValue.substr(0, keyValue.indexOf('='))
@moimikey
moimikey / gist:76584ce3bf0d7de36f53
Created February 11, 2015 16:07
auto `nvm use` for `zsh`
function chpwd() {
emulate -L zsh
[ -f .nvmrc ] && nvm use
}
❯ npm s /\^strip- htdocs/git/master
NAME DESCRIPTION AUTHOR DATE VERSION
strip-ansi Strip ANSI escape codes =sindresorhus… 2015-01-16 2.0.1
strip-attributes Strip attributes from HTML tags. =jonschlinkert 2014-10-16 0.1.0
strip-banner Strip banners from code. =jonschlinkert 2014-02-13 0.1.1
strip-bom Strip UTF-8 byte order mark (BOM) from a… =sindresorhus 2014-08-22 1.0.0
strip-bomify browserify transform to remove UTF-8 byte order mark from… =michailsmith 2014-10-23 0.1.0
strip-coffee-comments Strip comments from CoffeScript. Remove both line comments… =jonschlinkert 2014-07-10 0.1.1
strip-combining-marks Easily remove Unicode combining marks from strings. =mathias
❯ npm s /\^gulp- htdocs/git/master
NAME DESCRIPTION AUTHOR
gulp-6to5 Turn ES6 code into vanilla ES5 with no runtime required =sindresorhus…
gulp-9-patch Utilities for android-9-patch images. =manse
gulp-a11y A Gulp plugin for a11y to run accessibility audits on html… =mpezzi
gulp-absolute Filter files by absolute path =jeromedecoster
gulp-absolute-image =spud
gulp-absurd AbsurdJS plugin for Gulp =krasimir
gulp-accord a unified interface to compiled javascript languages =jenius
gulp-acss