Skip to content

Instantly share code, notes, and snippets.

@staydecent
staydecent / generate_keys.py
Created October 5, 2014 19:05
Generate secret keys for Flask app
#!/usr/bin/env python
# encoding: utf-8
"""
generate_keys.py
Generate CSRF and Session keys, output to secret_keys.py file
Usage:
generate_keys.py [-f]
var width = 460,
height = 300,
radius = Math.min(width, height) / 2,
twoPi = 2 * Math.PI,
progress = 0,
formatPercent = d3.format(".0%");
var arc = d3.svg.arc()
.startAngle(0)
@staydecent
staydecent / todo.ls
Last active August 29, 2015 14:07
LiveScript, mercury proof attempting to mimic Elm TodoMVC example.
document = require 'global/document'
nextTick = require 'next-tick'
HashRouter = require 'hash-router'
Event = require 'geval'
cuid = require 'cuid'
extend = require 'xtend'
hg = require 'mercury'
h = hg.h
@staydecent
staydecent / config.fish
Last active December 1, 2021 00:45
My Fish config
if status is-interactive
# Commands to run in interactive sessions can go here
end
set -gx PATH /usr/local/bin $PATH
set -gx PATH /opt/homebrew/bin $PATH
set -gx PATH /opt/homebrew/opt/[email protected]/libexec/bin $PATH
abbr gf "git fetch"
abbr gb "git branch"
@staydecent
staydecent / renamefiles.fish
Created November 17, 2014 17:46
File renaming pattern for Fish Shell with OSX sed
# 'Item*' it the pattern to look for
# sed "s/I/i/g" is the replacement pattern
for f in Item*; mv $f (echo {$f} | sed "s/I/i/g"); end
@staydecent
staydecent / autocompleter.jsx
Last active August 29, 2015 14:15
Mithril autocompleter
/** @jsx m */
'use strict';
var R = require('ramda');
var m = require('mithril');
var autocompleter = function() {
var autocompleter = {};
@staydecent
staydecent / functions.php
Last active April 30, 2016 22:28
Display child terms of any menu item in a wp_nav_menu that is a parent term.
<?php
add_filter('wp_nav_menu_args', 'modify_nav_menu_args');
function modify_nav_menu_args($args) {
if (!current_user_can('add_users')) {
return $args;
}
// we need the menu to be an object, so we can inspect it
if (gettype($args['menu']) !== 'object') {
return $args;
@staydecent
staydecent / boiled-down-vdom.js
Created March 14, 2015 04:30
proof of minimal DOM updates based on a strict atom/state rather than output of vdom functions.
var atom = {"things": []};
function Thing() {
this.isNew = true;
}
function thingView(thing) {
var cls = ['thing'];
cls.push(thing.isNew ? 'new' : 'notNew');
@staydecent
staydecent / columns.js
Last active February 12, 2016 02:27
With an array of arrays, get an array of each column (using Ramda)
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var R = require('ramda');
var ls = [
['a1', 'b1', 'c1'],
['a2', 'b2', 'c2'],
['a3', 'b3', 'c3'],
['a4', 'b4', 'c4'],
['a5', 'b5'],
@staydecent
staydecent / index.js
Created June 10, 2015 01:01
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var deku = require('deku');
var dom = deku.element;
var render = deku.render;
var tree = deku.tree;
var App = {