Skip to content

Instantly share code, notes, and snippets.

(function(){
var log = console.log;
console.log = function(str) {
var css = 'background: linear-gradient(to right, red, yellow, lime, aqua, blue, fuchsia, red); color: white; font-weight: bold; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;';
var args = Array.prototype.slice.call(arguments);
args[0] = '%c' + args[0];
args.splice(1,0,css);
return log.apply(console, args);
}
@zikes
zikes / use.go
Created May 23, 2014 02:59 — forked from elithrar/use.go
r := mux.NewRouter()
// Single handler
r.HandleFunc("/form", use(http.HandlerFunc(formHandler), csrf, logging,)
// All handlers
http.Handle("/", recovery(r))
// Sub-routers
apiMiddleware := []func(http.Handler) http.Handler{logging, apiAuth, json}
@zikes
zikes / index.html
Last active August 29, 2015 14:02 — forked from mbostock/.block
Arc Tween Animation
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style>
body {
width: 900px;
padding-top:25px;
@zikes
zikes / index.html
Last active August 29, 2015 14:10 — forked from mbostock/.block
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://github.com/simplegeo/polymaps/raw/v2.2.0/polymaps.min.js"></script>
<script type="text/javascript" src="http://github.com/mbostock/polymaps/raw/586fbb0346548a5559b6edea8aab76ac51334da5/lib/crimespotting/crimespotting.js"></script>
<style type="text/css">
@import url("http://github.com/simplegeo/polymaps/raw/v2.2.0/examples/example.css");
html, body {
@zikes
zikes / fmt_currency.js
Created January 28, 2011 16:29
Javascript Currency Formatter
function fmt_currency(num){
var str=parseFloat(num).toFixed(2);
var arr=str.split('');
var out='';
var char='';
for(var x=0, len=arr.length;x<len;x++){
if(x<=2){
out=arr.pop()+out;
}else{
char=arr.pop();
@zikes
zikes / Alternator.js
Created August 30, 2012 16:00
Alternator Javascript Control
function Alternator(opts){
var options = {
activate:function(){},
deactivate:function(){},
elements: [],
active: 0
};
// Overwrite defaults with user options
for(var opt in opts) if(opts.hasOwnProperty(opt)){
@zikes
zikes / pager.php
Created October 8, 2012 17:24
PHP Pagination
<?php
// global configuration,
$page_size = 5; // how many items per page
$page_start = 1; // the starting page
// how many numbers will be shown before and after current, including current
$page_range_near = 3;
// The number of items to paginate through, most likely the result of
@zikes
zikes / index.html
Created December 14, 2012 14:37
Quartiles using numbers.js & d3.js
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Quartiles using numbers.js & d3.js</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="numbers.js"></script>
<style>
body {font: 10px sans-serif;}
@zikes
zikes / index.html
Last active November 21, 2015 21:19 — forked from mbostock/.block
Connected Particles III
<!DOCTYPE html>
<meta charset="utf-8">
<canvas width="960" height="500"></canvas>
<script>
/* https://github.com/d3/d3-timer Copyright 2015 Mike Bostock */
"undefined"==typeof requestAnimationFrame&&(requestAnimationFrame="undefined"!=typeof window&&(window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame)||function(e){return setTimeout(e,17)}),function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.timer={})}(this,function(e){"use strict";function n(){r=m=0,c=1/0,t(u())}function t(e){if(!r){var t=e-Date.now();t>24?c>e&&(m&&clearTimeout(m),m=setTimeout(n,t),c=e):(m&&(m=clearTimeout(m),c=1/0),r=requestAnimationFrame(n))}}function i(e,n,i){i=null==i?Date.now():+i,null!=n&&(i+=+n);var o={callback:e,time:i,flush:!1,next:null};a?a.next=o:f=o,a=o,t(i)}function o(e,n,t){t=null==t?Date.now():+t,null!=n&&(t+=+n),l.callback=e,l.time=t}function u(e){e=null==e?D
@zikes
zikes / index.html
Created December 19, 2012 16:45
Matrix Transpose
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Matrix Transpose</title>
<script src="numbers.min.js"></script>
<script src="http://d3js.org/d3.v3.js"></script>
<style>
.button {
fill: steelBlue;