Skip to content

Instantly share code, notes, and snippets.

@nsfmc
nsfmc / training.md
Last active February 28, 2017 23:35

Getting started

getting started using dynamic labels is as easy as 1 2 4! First copy the following text:

<first name> is a dynamic label for someone's <name>

@nsfmc
nsfmc / readme.md
Created January 25, 2017 19:20
returns the most common padding/margin values

assuming you got a list of margin/padding values from your css with

ack --css margin > margin.txt
ack --css padding > padding.txt

you can run

@nsfmc
nsfmc / git-music.sh
Last active January 25, 2017 17:54 — forked from mroth/git-music.sh
Adds the currently playing iTunes/Spotify track to your prepared git commit message.
#!/bin/bash
# Adds the currently playing iTunes track to your prepared commit message.
#
# To install, save in repo as chmod +x to .git/hooks/prepare-commit-msg
# save music.js somewhere like ~/.bin
# if you don't use a commit template $SONG should precede $1 to allow --verbose
# commits to work, otherwise change the echo to "$(cat $1)\n\n$SONG"
SONG=`osascript -l JavaScript ~/.bin/music.js`
if [[ $SONG ]]; then
echo -e "\n\n$SONG\n$(cat $1)" > $1
import typeof {Foo} from './foo'
class Bar extends Component {
props: {
foolike: Foo
}
render (){....}
}
@nsfmc
nsfmc / doodler.py
Created April 3, 2012 18:49
a small utility script to rasterize an illustrator file with ghostscript and graphicsmagick
"""
doodler.py - (c) 2012 Marcos Ojeda <marcos@khanacademy.org>
--"Quis leget haec?"
requires
graphicsmagick - brew install graphicsmagick
ghostscript - brew install ghostscript
"""
@nsfmc
nsfmc / .babelrc
Last active July 22, 2016 17:02
`unstable_handleError` and `ReactDOMServer.renderToString` test case
{
"presets": ["es2015", "react"]
}
@nsfmc
nsfmc / convert-from-markdown.js
Last active July 8, 2016 18:10
a barely working node module that uses markdown-it (and lodash) to build draft content states
import MarkdownIt from 'markdown-it';
import {convertFromRaw} from 'draft-js';
import util from 'util';
import _ from 'lodash';
const flog = (whatever) => {
console.log(util.inspect(whatever, {depth: null, colors: true}));
};
@nsfmc
nsfmc / require-default-codeshift.js
Created February 24, 2016 17:12
change .default-less require calls for certain modules to require().default
/**
* add .default to requires for 'stores/index' that don't already have them.
*
* this comes up because babel6 Does The Right Thing with es6 exports and
* commonjs requires now need to play by the rules of the es6 exported modules
* and specify the default argument. see more:
* https://medium.com/@kentcdodds/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution-ad2d5ab93ce0#.tjlvbfd4x
*
*/
export default function transformer(file, api) {
@nsfmc
nsfmc / jsx-require-codeshift.js
Last active February 24, 2016 03:25
change jsx requires to require extension-less version
/**
* jsx-require-codeshift changes all import/require calls for .jsx files to their root files
*
* this is not a very complicated jscodeshift transform, but the more the merrier imo, since there
* aren't very many out there to peek at. (it could probably be satisfied with a not-crazy regex).
*
* What this does is converts calls like `import Foo from 'foo.jsx';` to `import Foo from 'foo';`
* and similarly, it also converts require calls for jsx files to their extensionless versions.
*
*/
@nsfmc
nsfmc / main.js
Last active January 26, 2016 22:53
A bad idea
var Nest = (classlist) => {
// classlist = 'foo bar baz'
let classes = classlist.split(' ');
classes.reverse();
let nestReducer = (prev, current) => <div className={current}>{prev}</div>;
return (el) => (props) => classes.reduce(nestReducer, el)
}
var Hello = React.createClass({