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
function [u_sig,u_paren] = pretty_errors(u,u_err) | |
% Convert a number and its error to a more readable version: | |
% Ex: | |
% u = 1.234567, u_err = 0.012345 -> u_sig = '1.23', u_paren = '1' | |
% (for use with notation u = 1.23(1)) | |
n = -1; | |
u_paren = 0; | |
while ~u_paren |
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
function comma_N = commatic(N) | |
% COMMATIC Insert commas into integers, e.g. 1234567 -> '1,234,567'. | |
% (c) Jack Peterson, 4/29/2013 | |
N = num2str(N); | |
num_digits = length(N); | |
comma_N = ''; | |
for j = 1:num_digits | |
comma_N = strcat(N(num_digits-j+1),comma_N); |
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 python | |
# -*- coding: utf-8 -*- | |
""" | |
Perceptron neural network. Can learn any linearly separable logic. | |
(c) Jack Peterson, 6/12/2008 | |
""" | |
from random import random | |
def hardlimit(row, col, bias): |
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/perl | |
foreach(<>){ | |
chomp; | |
} | |
exit; |
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
/** | |
* SockJS wrapper with some semantic sugar to make it look more like | |
* socket.io. Supports socket.emit and socket.on. Based on: | |
* http://simplapi.wordpress.com/2013/09/22/sockjs-on-steroids/ | |
* | |
* @author jack@tinybike.net (Jack Peterson) | |
*/ | |
var SOCKJSIO = (function (my, $) { | |
// Module exports | |
var _exports = my._exports = my._exports || {}; |
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
CC = mpic++ | |
CXXFLAGS = -g -W -Wall -Werror | |
LIBS = -lboost_mpi -lboost_serialization -lboost_system -lboost_filesystem -lboost_graph_parallel -lboost_iostreams | |
all: Boost | |
Boost: Boost.o | |
$(CC) $(CXXFLAGS) -o Boost Boost.o $(LIBS) | |
Boost.o: Boost.cpp |
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
# connect julia to mssql using the magic of pycall | |
# @author Jack Peterson (jack@tinybike.net) | |
using PyCall | |
@pyimport pymssql | |
# Connect to MSSQL Server | |
conn = pymssql.connect(server="SERVER:PORT", | |
user="USER", |
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 python | |
# -*- coding: utf-8 -*- | |
""" | |
calculate a weighted median | |
@author Jack Peterson (jack@tinybike.net) | |
""" | |
from __future__ import division | |
import numpy as np | |
def weighted_median(data, weights): |
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
using Base.Test | |
function weighted_median{T<:Real,W<:Real}(data::Array{T,1}, weights::Array{W,1}; | |
checknan::Bool=true) | |
isempty(data) && error("median of an empty array is undefined") | |
if length(data) != length(weights) | |
error("data and weight vectors must be the same size") | |
end | |
if checknan | |
for (i, x) in enumerate(data) |
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
# "Find a full-rank matrix with smallest singular value less than X." | |
# Question: is this a good way to do proof-of-work? | |
using Winston | |
using Distributions | |
function svd_work(N, target) | |
tic() | |
while true | |
A = rand(N, N) |