Skip to content

Instantly share code, notes, and snippets.

View zmaril's full-sized avatar
🌹
Crawling the web

Zack Maril zmaril

🌹
Crawling the web
View GitHub Profile
@zmaril
zmaril / gist:1820909
Created February 13, 2012 22:11
Schedule Genetic
#This was an attempt to do genetic algorithms in python for the 2012 MCM competition.
#http://www.comap-math.com/mcm/index.html
#It usually works.
#How many boats get passed through for each 10?
#Make a table
import random
import pygame
from operator import itemgetter, attrgetter
@zmaril
zmaril / _colors.scss
Created February 24, 2012 18:48
Easy customization of octopress blogs
// If you need a handy color picker try http://hslpicker.com
// Or look at octopress/sass/base/solarized.scss for inspiration. The colors in there are excellent.
// The following are ordered in terms of vague importance.
//Pick your favorite color. If you picked a thoughtful blue, try again.
$main-color: #6c71c4;
//This controls the background.
$page-bg: lighten($main-color,20);
@zmaril
zmaril / gist:2217191
Created March 27, 2012 15:41
R code for verifying TCE
eZ <- function(u){x=rnorm(1000000);mean(x[x>u])}
eP <- function(u){dnorm(u)/(1-pnorm(u))}
ep = eP((-400:400)/100)
ez = sapply((-400:400)/100,eZ)
png("qqplot.png")
qqplot(ez,ep)
dev.off()
@zmaril
zmaril / gist:2599321
Created May 5, 2012 03:09
Inverse fizzbuzz
;;Solution to inverse fizzbuzz
;;http://www.jasq.org/2/post/2012/05/inverse-fizzbuzz.html
;;TODO: Uses the top comment from hacker news
(ns faster.core
(:use clojure.test))
;;Simple fizzbuzz function
(defn fizzbuzz [n]
(str (when (zero? (mod n 3)) "fizz")
(when (zero? (mod n 5)) "buzz")))
@zmaril
zmaril / gist:2896110
Created June 8, 2012 15:15
Generating schema
#Not valid coffeescript, but close
generate = {}
generate.ip = ()->
numbers = (Math.round(Math.random()*255)+1) for i in [0..4]
numbers.join(".")
generate.user_agent = ()->
["Mozilla","Apple","Windows","Etc"].random()
@zmaril
zmaril / gist:2921087
Created June 13, 2012 00:50
Global Bindings
//With statement doesn't do what I hoped, which was overriding the whole smear of things.
//Actually, just not possible with closures at all I don't think. Once a value has been bound, there isn't much you can do.
Function.prototype.bind_global = function bind_global(ctx) {
return (function(t,args){
return function() {
var g = [].slice.call(args,1,2);
g = g ? g : window;
with(g){
return t.apply(ctx, [].slice.call(args, 2));
}
@zmaril
zmaril / index.html
Created June 16, 2012 14:08 — forked from ilyabo/index.html
D3 tooltip using Bootstrap
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src=https://raw.github.com/gist/2941416/24172d26b3c802f5be54b3411863822cad6b8538/tooltip.custom.js"></script>
<script type="text/javascript" src="https://raw.github.com/gist/2941416/39fbe358eb3256e62401e2403735907fbe3f7a75/popover.js"></script>
</head>
<body>
<div id="chart"></div>
@zmaril
zmaril / index.html
Created June 24, 2012 03:16 — forked from mbostock/.block
d3 bootstrap tooltips
<!doctype html>
<head>
<style>
body {
font: 10px sans-serif;
}
#main {
left: 25%;
position: absolute;
}
@zmaril
zmaril / index.html
Created June 24, 2012 15:57 — forked from njvack/LICENSE
Voronoi-based point picker
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js"></script>
</head>
<body>
<div id="chart">
</div>
<script type="text/javascript">
var w = 960,
@zmaril
zmaril / BubbleChart.js
Created June 24, 2012 22:39
Animated Bubble Chart
var BubbleChart, root,
__bind = function(fn, me){
return function()
{ return fn.apply(me, arguments);
};
};
BubbleChart = (function() {
BubbleChart.name = 'BubbleChart';