Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
View GitHub Profile
@moimikey
moimikey / web-application-stack.md
Last active Sep 29, 2021
web-application-stack.md
View web-application-stack.md

Packages

dependencies

  • Apollo
  • Babel
  • Serverless or CDK
  • GraphQL
  • MobX
  • MobX State Tree
  • NextJS
View my.zsh
echo starting antigen...
source /usr/local/share/antigen/antigen.zsh
antigen init $HOME/.antigenrc
export EDITOR="vim"
export HISTSIZE=9999999999
export LANG="en_US.UTF-8"
export NVM_DIR="$HOME/.nvm"
export SSH_KEY_PATH="$HOME/.ssh/id_rsa"
export JAVA_HOME=$(/usr/libexec/java_home)
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 / deepFlat.js
Created Mar 31, 2019
deep flatten array in javascript
View deepFlat.js
export const deepFlat = (arr) => arr.flat(Infinity)
@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);
@moimikey
moimikey / whatis.js
Last active Mar 18, 2016
really simple javascript type detection
View whatis.js
const assert = function (condition) {
if (condition !== true && condition !== false) {
throw new TypeError("Assertions should be only of booleans; you're writing your spec wrong.");
}
if (!condition) {
throw new Error("Specification-level assertion failure");
}
};
function whatIs(this$) {
@moimikey
moimikey / after.js
Last active Sep 28, 2021
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
}
},
@moimikey
moimikey / babel.md
Last active Jan 24, 2016
babel notes of wisdom
View babel.md
lib notes
babel-cli basically what you need always
babel-register this is only for dev or local use and not production or browser
babel-core only necessary if using babel programatically
babel-polyfill shims inconsistent browser functions like Array.from, etc.
babel-runtime only helps at a code level by optimizing babel helpers into a single runtime

use presets