This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
query=$(echo "$@" | sed 's/ /%20/') | |
w3m -no-cookie "https://duckduckgo.com/?q=$query" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 |
NewerOlder