Skip to content

Instantly share code, notes, and snippets.

View micimize's full-sized avatar

Michael Joseph Rosenthal micimize

  • San Francisco, CA
View GitHub Profile
@micimize
micimize / connect to OSX mysql from docker.sh
Last active October 17, 2015 15:49
docker -> brewed mysql
vim /usr/local/Cellar/mysql/5.6.21/homebrew.mxcl.mysql.plist # add the --bind-address
# <key>ProgramArguments</key>
# <array>
# <string>/usr/local/opt/mysql/bin/mysqld_safe</string>
# <string>--bind-address=0.0.0.0</string>
# <string>--datadir=/usr/local/var/mysql</string>
# </array>
mysql.server restart
tail -f /usr/local/var/mysql/$USER.local.err # verify bound address, check for 'could not be resolved'
mysql > GRANT ALL PRIVILEGES ON database.* TO 'root'@'%' identified by 'pass';
@micimize
micimize / abstraction-issues.eve.md
Last active November 24, 2016 23:18
DOM Component abstraction issues encountered with Eve

Abstraction Issues

This is a rundown of all the DOM Component abstraction issues I encountered while attempting to modularize my Eve code. I made each major issue an h2 header, provided examples as h3 headers.

Component system via search/bind very limited

The nested search/bind componentizing pattern only works for very simple data structures, as it seems the DOM is first rendered, then searched for tags.

Test Data

#time-string instead of #time to reduce surface area of what might be going wrong

commit
  [#experience
    title: "Morning Meditation"
@micimize
micimize / deepSum.js
Created April 24, 2017 05:26
recursion examples
// takes in any structure
// returns the sum of all numbers in all leaf nodes recursively
function deepSum (json) {
if (Array.isArray(json)) {
return json.reduce((sum, item) => sum + deepSum(item), 0)
} else if (typeof(json) === 'object') {
return Object.keys(json)
.reduce((sum, key) => sum + deepSum(json[key]), 0)
} else {
try {
@micimize
micimize / tic-tac-toe.js
Last active May 8, 2017 23:36
Core logic for a bitwise tic-tac-toe board checker
function flatten(arrays) {
return [].concat.apply([], arrays)
}
function zip(...arrays) {
let zipped = []
for(var index = 0; index < arrays[0].length; index++){
zipped.push(arrays.map(a => a[index]))
}
return zipped
@micimize
micimize / fantasy-collectable-sorted-set.ts
Created November 2, 2017 00:06
A warper around the collectablejs set that's more fantasy-land-y
import {
SortedSetStructure, isSortedSet, fromArray, toArray,
map, reduce, add, union, size, filter,
has, remove, first
} from '@collectable/sorted-set';
import * as s from '@collectable/sorted-set';
export namespace Sort {
export function Descending<A>(attr: string) {
return (a: A, b: A) => Number(b[attr]) - Number(a[attr])
@micimize
micimize / keybase.md
Created November 14, 2017 21:49
keybase proof

Keybase proof

I hereby claim:

  • I am micimize on github.
  • I am micimize (https://keybase.io/micimize) on keybase.
  • I have a public key ASDZ-3yLjAWQGkpLLnA_evD18Pwz6TvhOYwPHOVxwB5x9Ao

To claim this, I am signing this object:

@micimize
micimize / newgroup-20-to-json.py
Created December 10, 2017 19:40
example of flattening a data corpus with a semantically relevant directory structure to a single directory of json files
import glob, json, os
def makedirs_p(dir_name):
if not os.path.exists(dir_name):
os.makedirs(dir_name)
def contents_of(file_name):
with open(file_name, 'r', encoding='utf8') as f:
@micimize
micimize / slate-modal-grid.js
Last active May 7, 2020 16:11
slate modal grid
const grid = [
[ '1', '2', '3', '4', '5', '6', '7', /* '8' */ ],
[ 'q', 'w', 'e', 'r', 't', 'y', 'u', /* 'i' */ ],
[ 'a', 's', 'd', 'f', 'g', 'h', 'j', /* 'k' */ ],
[ 'z', 'x', 'c', 'v', 'b', 'n', 'm', /* ',' */ ]
]
// these are fixed-pixel "functional margins",
// changing the size of the final row and column
@micimize
micimize / fonts.js
Last active December 22, 2017 22:29
current native-base ./web set up
/* in ./index.web.tsx:
import injectFonts from './web/fonts'
injectFonts()
*/
import FontAwesome from 'react-native-vector-icons/Fonts/FontAwesome.ttf';
import Ionicons from 'react-native-vector-icons/Fonts/Ionicons.ttf';
import Roboto from 'native-base/Fonts/Roboto.ttf';
import Roboto_medium from 'native-base/Fonts/Roboto_medium.ttf';
function font(family, url){
@micimize
micimize / switch-experiments.ts
Created December 30, 2017 19:06
thoughts on how we might accomplish the power of reasonml with typescript
type NotFunction = object | string | boolean | number
type Block<Return> = () => Return
function isBlock<Return>(r: Return | Block<Return>): r is Block<Return> {
return typeof r === "function"
}
type Cases<Tuple, Return extends NotFunction = object> = Array<[
Tuple,
Return | Block<Return>
]>