Skip to content

Instantly share code, notes, and snippets.

:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
Block or report user

Report or block moimikey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@moimikey
moimikey / callback.js
Created Nov 23, 2015
a callback in javascript for dummies
View callback.js
// callbacks != promises
function doSomeAction() {
return true
}
function appleTree() {
return doSomeAction()
}
appleTree()
@moimikey
moimikey / index.js
Last active Nov 20, 2015
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var locale2 = require('locale2');
document.write(locale2);
View wait-for-localstorage.js
/**
* Michael Scott Hertzberg <mshertzberg@gmail.com> (http://hertzber.gs)
*
* recursively check for set localStorage value every 100ms.
* this will also safely clear the timeout once found.
* can be used callback style or directly.
* functionally pure.
*/
function waitForLocalStorage(key, cb, timer) {
if (!localStorage.getItem(key)) return (timer = setTimeout(waitForLocalStorage.bind(null, key), 100))
@moimikey
moimikey / cubic-bezier.js
Last active Nov 3, 2015
named easing/cubic bezier lookups
View cubic-bezier.js
{
easeOutCubic: "cubic-bezier(.215,.61,.355,1)",
easeInOutCubic: "cubic-bezier(.645,.045,.355,1)",
easeInCirc: "cubic-bezier(.6,.04,.98,.335)",
easeOutCirc: "cubic-bezier(.075,.82,.165,1)",
easeInOutCirc: "cubic-bezier(.785,.135,.15,.86)",
easeInExpo: "cubic-bezier(.95,.05,.795,.035)",
easeOutExpo: "cubic-bezier(.19,1,.22,1)",
easeInOutExpo: "cubic-bezier(1,0,0,1)",
easeInQuad: "cubic-bezier(.55,.085,.68,.53)",
@moimikey
moimikey / .editorconfig
Last active Aug 29, 2015
Project Boilerplate
View .editorconfig
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 Apr 27, 2019
30 bytes to coerce "23" to Number, keep "apple" as String
View coerce.js
/**
* 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 Aug 29, 2015
requirebin sketch
View index.js
// 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 Aug 29, 2015
requirebin sketch
View index.js
var locale = require('locale2');
document.write(locale);
@moimikey
moimikey / syncWith.md
Last active Aug 29, 2015
Idea for React sync with store via HOC
View syncWith.md

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 Mar 18, 2015
React recursive timer animation
View react-cursive-timer.jsx
'use strict';
var React = require('react');
var Switch = React.createClass({
getInitialState: function() {
return {
switch: true
}
},
You can’t perform that action at this time.