Skip to content

Instantly share code, notes, and snippets.

View andrewluetgers's full-sized avatar

Github Notification andrewluetgers

View GitHub Profile
@aasmith
aasmith / javascript option stuff.js
Created August 14, 2010 22:34
black scholes & IV in javascript
/* Returns probability of occuring below and above target price. */
function probability(price, target, days, volatility) {
var p = price;
var q = target;
var t = days / 365;
var v = volatility;
var vt = v*Math.sqrt(t);
var lnpq = Math.log(q/p);
@endolith
endolith / sinc_interp.m
Created October 19, 2011 01:05
Perfect sinc interpolation in Matlab and Python
% From http://phaseportrait.blogspot.com/2008/06/sinc-interpolation-in-matlab.html
% Ideally "resamples" x vector from s to u by sinc interpolation
function y = sinc_interp(x,s,u)
% Interpolates x sampled sampled at "s" instants
% Output y is sampled at "u" instants ("u" for "upsampled")
% (EXPECTS x, s, and u to be ROW VECTORS!!)
% Find the period of the undersampled signal
T = s(2)-s(1);
@neilj
neilj / gist:1532562
Created December 29, 2011 07:22
Sugared DOM: Better Than Templates
var el = ( function () {
var doc = document;
var directProperties = {
'class': 'className',
className: 'className',
defaultValue: 'defaultValue',
'for': 'htmlFor',
html: 'innerHTML',
@salmonmoose
salmonmoose / bresenham3d.py
Created May 21, 2012 00:44
Generate unit locations along a 3D line
def bresenham(startPoint, endPoint):
startPoint = [int(startPoint[0]),int(startPoint[1]),int(startPoint[2])]
endPoint = [int(endPoint[0]),int(endPoint[1]),int(endPoint[2])]
steepXY = (abs(endPoint[1] - startPoint[1]) > abs(endPoint[0] - startPoint[0]))
if(steepXY):
startPoint[0], startPoint[1] = startPoint[1], startPoint[0]
endPoint[0], endPoint[1] = endPoint[1], endPoint[0]
@Protonk
Protonk / prng.js
Last active August 31, 2024 17:14
Various PRNGs, implemented in javascript.
// Linear Congruential Generator
// Variant of a Lehman Generator
var lcg = (function() {
// Set to values from http://en.wikipedia.org/wiki/Numerical_Recipes
// m is basically chosen to be large (as it is the max period)
// and for its relationships to a and c
var m = 4294967296,
// a - 1 should be divisible by m's prime factors
a = 1664525,
// c and m should be co-prime
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active November 10, 2024 03:45
A badass list of frontend development resources I collected over time.
@mathisonian
mathisonian / index.md
Last active August 10, 2024 20:59
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@GaelVaroquaux
GaelVaroquaux / mutual_info.py
Last active June 18, 2023 12:25
Estimating entropy and mutual information with scikit-learn: visit https://github.com/mutualinfo/mutual_info
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
This code is maintained at https://github.com/mutualinfo/mutual_info
Please download the latest code there, to have improvements and
bug fixes.
@zross
zross / shakespeare.csv
Created January 14, 2015 01:39
Shakespeare word count by work (from Google BigQuery)
We can't make this file beautiful and searchable because it's too large.
"","word","word_count","corpus","corpus_date"
"1","hive",1,"loverscomplaint",1609
"2","plaintful",1,"loverscomplaint",1609
"3","Are",1,"loverscomplaint",1609
"4","Than",1,"loverscomplaint",1609
"5","attended",1,"loverscomplaint",1609
"6","That",7,"loverscomplaint",1609
"7","moisture",1,"loverscomplaint",1609
"8","praised",1,"loverscomplaint",1609
"9","particular",1,"loverscomplaint",1609
@AlanPew
AlanPew / index.html
Last active April 17, 2020 05:08
Mapbox GL Streets with Watercolor
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.1/mapbox-gl.js'></script>
<script src='http://gpstrails.info/ex/gl/style/streets7.json'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.1/mapbox-gl.css' rel='stylesheet' />
<style>