Skip to content

Instantly share code, notes, and snippets.

@zspecza
zspecza / number-base-conversion.js
Last active August 29, 2015 13:57
A little brainstorm on converting between number bases in JavaScript. Feedback is welcome.
;(function(undefined) {
'use strict';
var debug = function(err) {
console.error(err.message + '\n' + err.stack);
};
try {
@zspecza
zspecza / modernizr.styl
Last active August 29, 2015 14:02
modernizr helper mixins for stylus
/* private modernizr mixin
*
* downside - only works on single-element selectors. nesting still works though.
*
* @param features - a list of modernizr test classes e.g.: csstransitions opacity OR csstransitions, opacity
* @param declaration - the {block} of content passed by the block mixins +yep()/+nope()
* @param support - boolean, true if testing support, false if testing no support
*
* 1. if testing for support, set selector to empty string
* if testing for no support, set selector to ".no-js" appended by
@zspecza
zspecza / react-page.js
Last active August 29, 2015 14:24
A simple, isomorphic, state-based routing component wrapper around Page.js for React
import page from 'page'
import pathToRegExp from 'path-to-regexp'
import querystring from 'querystring'
import HomePage from './components/HomePage'
import ProfilePage from './components/ProfilePage'
import NotFoundPage from './components/NotFoundPage'
// generate expression for iterating over object keys
function entries(obj) {
@zspecza
zspecza / index.html
Created February 11, 2013 21:51
A CodePen by Declan de Wet. One Div CSS3 Animated Spinner - A futuristic HUD style animated loading spinner. Makes extensive use of keyframes. The intricate detailing is with thanks to CSS3 and it's :after and :before pseudo-elements. Strange case with this one is that it doesn't work as intended in Chrome. Feel free to contribute something to m…
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Futuristic HUD single-div no-image CSS3 loading spinner" />
<title>CSS3 Loading Spinner</title>
</head>
<body>
<div id="spinner"></div>
</body>
</html>
###
# Solo Pong - Declan de Wet
# TODO: Prevent paddle from going out of the viewport
# TODO: Implement collision animations
# TODO: Music and sound
# TODO: Keyboard controls
###
# Create a self-instantiating shim/polyfill for the requestAnimationFrame API, if it does not exist,
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme",
"create_window_at_startup": false,
"default_line_ending": "unix",
"detect_slow_plugins": false,
"draw_minimap_border": true,
"ensure_newline_at_eof_on_save": true,
@zspecza
zspecza / brainfuck.coffee
Created December 13, 2013 02:27
Brainf*ck Interpreter
###
brainfuck() function
description: takes a string of Brainfuck code and returns the parsed result
usage: brainfuck('++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.')
// output: 'Hello World.'
###
brainfuck = (code) ->
inp = '23\n'
out = ''
@zspecza
zspecza / index.js
Created February 15, 2016 17:02
requirebin sketch
// vars ending in $ are streams
var flyd = require('flyd')
var botkit = require('botkit')
var controller = botkit.slackbot(/*...*/)
var direct_message$ = flyd.stream()
var conversation$ = flyd.stream()
const getValidatedTransformation = sequentialCallback(
findSomething,
transformSomething,
validateTransformed
)
getValidatedTransformation((error, validated) => {
if (error) {
console.error(new Error(error))
} else {
findSomething()
.then(transformSomething)
.then(validateTransformed)
.then((validated) => console.log('data is valid:', validated))
.catch((error) => console.error(new Error(error))