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 / after.js
Last active Nov 16, 2019
object literals for redux reducers
View after.js
// O(1)
const todo = (state, action) => {
const actions = {
ADD_TODO: () => {
return {
id: action.id,
text: action.text,
completed: false
}
},
View rick-roll.js
var music, musicParse;
musicParse = function(f) {
return eval("for(var t=0,S='RIFF_oO_WAVEfmt " + atob('EAAAAAEAAQBAHwAAQB8AAAEACAA') + "data';++t<3e5;)S+=String.fromCharCode(" + f + ")");
};
music = function() {
var audio, formula;
formula = '(t<<3)*[8/9,1,9/8,6/5,4/3,3/2,0][[0xd2d2c8,0xce4088,0xca32c8,0x8e4009][t>>14&3]>>(0x3dbe4688>>((t>>10&15)>9?18:t>>10&15)*3&7)*3&7]&255';
audio = new Audio("data:audio/wav;base64," + (btoa(musicParse(formula))));
@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 / deepFlat.js
Created Mar 31, 2019
deep flatten array in javascript
View deepFlat.js
export const deepFlat = (arr) => arr.flat(Infinity)
@moimikey
moimikey / pricechecker.coffee
Last active Mar 16, 2019
Neopets.com SDB Price Checker
View pricechecker.coffee
# This is best when used in conjunction with the Injector chrome extension:
# http://neocotic.com/injector
#
# Add this snippet of code and launch Chrome or Canary in no sec mode:
#
# alias chrome-nosec="open /Applications/Google\ Chrome.app --args --disable-web-security --disable-prompt-on-repost"
# alias canary-nosec="open /Applications/Google\ Chrome\ Canary.app --args --disable-web-security --disable-prompt-on-repost"
#
# Then pretty much just keep your dev console open and everytime you visit a page in the SDB, the code will
# automatically reach out to the JellyNeo item database and tell you if anything in your SDB is worth over x nps.
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 / README.md
Last active May 29, 2018
inline props as styled-component css
View README.md

@moimikey

Usage

// valid css properties in camelCase (checked by `css-key`)
const props = {
  gridColumnStart: ...,
  gridColumnEnd: ...,
@moimikey
moimikey / a.js
Created Jan 6, 2018
filter out only `on` event props from react component
View a.js
// ...
renderMenu() {
const { children, ...rest } = this.props || {};
// only store props that startWith `on` in case the parent component
// wants to send event callbacks down, for subsequent use.
const eventProps = Object.keys(rest)
.filter(key => key.substr(0, 2) === 'on') // if startsWith 'on' (ie. onMouseOver)
.reduce((obj, key) => Object.assign(obj, { [key]: rest[key] }), {});
// ...
@moimikey
moimikey / fill-array.js
Created Dec 5, 2017
fill array with value of variable in javascript in 49 bytes
View fill-array.js
const o = { a: true };
[...Array(9)].map(Function.prototype.valueOf, o);
View gist:e884ddc0115b1229f5b5
❯ 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
You can’t perform that action at this time.