Skip to content

Instantly share code, notes, and snippets.

Flux research

desires

  • es6 friendly – this means no mixins
  • immutable friendly
  • no promises, because debugging them sucks

fluxible

http://fluxible.io/faq.html

  • es6 friendly
@joeybaker
joeybaker / On npm.md
Created May 22, 2015 00:31
Notes on an intro to using npm

On npm

Three "types" of modules

cli modules

  • "bin" in package.json
  • keeping index.js and bin/module separate. You want both programmatic and cli access
  • use yargs to parse options from the CLI. You can do this manually, but it's painful and error prone. yargs also helps you build a good UI.
  • make sure to set the "main" field

browser modules

"note6": "cirlce ci gives us the ability to run set-npm-token before npm i, heroku does not, so we have to detect the heroku env and manually run npm install because changing .npmrc from an npm hook isn't pick up until the next run of npm",
"set-npm-token": "if [ -n \"${NPM_TOKEN-}\" ]; then echo \"//registry.npmjs.org/:_authToken=$NPM_TOKEN\" >> .npmrc; fi",
"preinstall": "npm run set-npm-token && if [ -n \"${DEPLOY_ENV-}\" ]; then echo installing; npm install --unsafe-perm --userconfig .npmrc --ignore-scripts; fi",
"postinstall": "if [ -n \"${DEPLOY_ENV-}\" ]; then npm run build; fi"
@joeybaker
joeybaker / clickable.js
Created April 9, 2012 22:50
jQuery for a clickable element
/* Clickable elements
*/
// when any .clickable elem is clicked, we'll grab the first link in the elem and redirect to it.
$('body').on('click', '.clickable', function(e){
var link = $('a:first', this)
, href = link.attr('href')
// _blank, command key, ctrl key, middle click
if (link.attr('target') == '_blank' || e.metaKey || e.ctrlKey || e.which == 2)
window.open(href, '_blank')
alias tolf="find . -type f -not -iname '*.png' -not -iname '*.jpg' -not -iname '*.jpeg' -not -iname '*.gif' -not -iname '*.tif' -not -iname '*.tiff' -not -iname '.git' -exec perl -pi -e 's/\r\n?/\n/g' {} \;"
@joeybaker
joeybaker / gitinstall.sh
Created May 10, 2012 18:32
Turn a dir into a git repo
# add this to your .bash_profile
# usage: gitinstall http://github.com/path/to/git.git
function gitinstall(){ git init; git remote add origin "$@"; git config branch.master.remote origin; git config branch.master.merge refs/heads/master; git pull;}
@joeybaker
joeybaker / gist:2654948
Created May 10, 2012 18:36
Heatmap based on mouse movement
/*
Copyright (c) 2010, Patrick Wied. All rights reserved.
Code licensed under the BSD License:
http://patrick-wied.at/static/license.txt
*/
var heatmapApp = (function(){
// var definition
// canvas: the canvas element
// ctx: the canvas 2d context
// width: the heatmap width for border calculations
@joeybaker
joeybaker / gist:2654956
Created May 10, 2012 18:37
CSS spinner
<!doctype html>
<title>Image-free spinner</title>
<style>
@-webkit-keyframes fadeOut {
0% { opacity:1; }
100% { opacity:.1; }}
p {
position:absolute;
overflow:hidden;
top:50%;
@joeybaker
joeybaker / .htaccess
Created May 10, 2012 18:38
Security for WordPress
<files wp-config.php>
order allow,deny
deny from all
</files>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]