Skip to content

Instantly share code, notes, and snippets.

@masonicboom
masonicboom / spiked_waffle.scad
Created February 24, 2019 22:16
Destroyer of Scum Rings
N = 9; // Number of cells vertically and horizontally. Must be odd.
wall_thickness = 2;
cell_radius = 3.8;
cell_depth = 4;
foot_depth = 3;
foot_radius = wall_thickness/2;
width = 2 * cell_radius + wall_thickness;
height = 2 * sin(360/6) * cell_radius + wall_thickness;
# install.packages("quantmod")
library(quantmod)
ticks <- getSymbols.yahoo("spy", env=globalenv(), from="2003-01-01", to="2018-01-01", return.class="ts")
par(oma=c(4,4,3,0), pch='.', xaxs="i", yaxs="i")
plot(index(SPY), SPY[,4])
lines(index(SPY), SPY[,4], col="red")
title(main="You need a 4K monitor for timeseries analysis.", xlab="Day", ylab="Close ($)", outer=TRUE)
library(ggplot2)
library(scales)
min <- 1
max <- 1000
f <- function(b) { sqrt(1 + b**2)/(1 + b) }
x <- seq(min, max, 0.01)
y <- 1 - f(x)
@masonicboom
masonicboom / ddg.sh
Created September 10, 2013 18:05
DuckDuckGo from the command line, using w3m.
#!/bin/bash
query=$(echo "$@" | sed 's/ /%20/')
w3m -no-cookie "https://duckduckgo.com/?q=$query"
@masonicboom
masonicboom / html5-storage-bench.js
Created August 11, 2011 23:34
A benchmark to compare inserts into HTML5 localStorage vs. HTML5 WebSQL.
/* A benchmark to compare inserts into HTML5 localStorage vs.
* HTML5 WebSQL. Only tested on Google Chrome.
*
* Written by Mason Simon (https://plus.google.com/113533580716771345509).
*/
/* Returns a function to for timing incremental progress towards
* a goal, N. When N is reached, calls finishedHandler with the
* total time to reach N, in milliseconds.
#!/usr/bin/env ruby
# Count co-occurences of all characters in words given 1-per-line from STDIN.
# count has the form { char_i => { char_j => # of co-occurences }, ... }.
# The block initialization here just sets up a default of 0 co-occurences.
count = Hash.new do
|hash, key| hash[key] = Hash.new { |h, k| h[k] = 0 }
end
#!/bin/bash
# This script prints each word in $dict_file, one per line.
# $dict_file is a file from http://www.csse.monash.edu.au/~jwb/edict_doc.html.
# See http://www.csse.monash.edu.au/~jwb/jmdict_dtd_h.html to understand why
# <keb> and </keb> are used.
start_marker="<keb>"
end_marker="</keb>"
dict_file=JMdict_e
@masonicboom
masonicboom / multibro.rb
Created February 8, 2011 00:29
Example of how to run a set of tests against multiple browsers using Selenium, Capybara, and RSpec
require 'spec_helper'
require 'capybara/rspec'
Capybara.register_driver :selenium_chrome do |app|
Capybara::Driver::Selenium.new(app, :browser => :chrome)
end
SELENIUM_DRIVERS = [:selenium_chrome, :selenium]
// spring pixels, by mason simon, 1-10-2010
import processing.video.*;
float BASE_INTENSITY = 0.3; // this is the steady-state intensity of each Spring
float t = 0;
float dt = 1;
<div><script type="text/javascript">
function thoughtful_evaluate(expression) {
var x = '';
var chunks = expression.split(/\s/);
for (i in chunks) { var chunk = chunks[i];
if (chunk.match(/^[\+\-\/\*]$/) != null)
// this chunk is a single operator
x += chunk;
else