Skip to content

Instantly share code, notes, and snippets.

@jiahao
jiahao / events.json
Created September 5, 2015 17:16
JSON from GitHub API query, https://api.github.com/repos/JuliaLang/julia/events, 2015-09-05T13:16:07
[{"id":"3121457012","type":"IssueCommentEvent","actor":{"id":11798751,"login":"ScottPJones","gravatar_id":"","url":"https://api.github.com/users/ScottPJones","avatar_url":"https://avatars.gitubusercontent.com/u/11798751?"},"repo":{"id":1644196,"name":"JuliaLang/julia","url":"https://api.github.com/repos/JuliaLang/julia"},"payload":{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/12835","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/12835/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/12835/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/12835/events","html_url":"https://github.com/JuliaLang/julia/pull/12835","id":103615789,"number":12835,"title":"let's release this thing !","user":{"login":"carnaval","id":5307791,"avatar_url":"https://avatars.githubusercontent.com/u/5307791?v=3","gravatar_id":"","url":"https://api.github.com/users/carnaval","html_url":"https://github.com/carnaval","follow
function normtypes(S) #For the first post, comparing vector outputs with naive definitions
try
R0 = typeof(abs(one(S))^0+abs(one(S))^0)
R1 = typeof(abs(one(S))+abs(one(S)))
Rp = typeof(sqrt(abs(one(S))^2+abs(one(S))^2))
Ri = typeof(maximum(abs(one(S))))
Ri2 = typeof(abs(one(S)))
R0i = typeof(norm([one(S)], 0))
R1i = typeof(norm([one(S)], 1))
Rpi = typeof(norm([one(S)]))
"""
estimate_coeffs
August, 2015
Anna C. Gilbert
input: xs = samples of signal
Λ = list of (freq,coeff) pairs in current approx
Ω = list of (freq,coeff) pairs found in this iteration
k = length of short filter
@jiahao
jiahao / julia.jl
Created November 24, 2015 02:58
Rank calculus for JuliaLang/julia#4774
include("rankstability.jl")
info("Julia semantics")
axiomsused = Dict()
@axiom matmul Mat * Mat --> Mat
@axiom mattrans transpose(Mat) --> Mat
@axiom matdiv Mat / Mat --> Mat
@axiom matvec Mat * Vec --> Vec
@jiahao
jiahao / Hypergeometric.jl
Created October 18, 2013 21:13
Hypergeometric random variate generators implemented in Julia
# Hypergeometric random variate generators
#
# (c) 2013 Jiahao Chen <jiahao@mit.edu>
#
# This file implements several random variate generators as described in the
# reference paper.
#
# Algorithm Function
# HBU randhg_hbu
# HIN randhg_hin
Process: julia-readline [12132]
Path: /Users/USER/*/julia-readline
Identifier: julia-readline
Version: ???
Code Type: X86-64 (Native)
Parent Process: Vim [11995]
Responsible: MacVim [11340]
User ID: 502
Date/Time: 2013-10-28 23:52:40.788 -0400
@jiahao
jiahao / parallel_cumsum.jl
Last active December 27, 2015 08:29
An implementation of parallel cumsum (cumulative sum) in Julia.
import Base.fetch; fetch(t::Vector) = [fetch(tt) for tt in t]
import Base.length; length(r1::RemoteRef)=length(fetch(r1))
addprocs(8-nprocs()) #Run on 8 processors
chunkrange(i, nc) = floor((i-1)*nc)+1:floor(i*nc)
function chunk(z, n)
nc = length(z)/n
y = Vector{typeof(z[1])}[]
for i=1:n #Number of chunks
push!(y, (typeof(z[1]))[])
@jiahao
jiahao / custom.css
Created December 1, 2013 08:28
Experimental typographically tinkered IJulia stylesheet To use, place in ~/.ipython/profile_julia/static/custom/custom.css and refresh IJulia
/* Experimental typographically tinkered IJulia stylesheet
* Copyright © 2013 Jiahao Chen <jiahao@mit.edu>
* MIT License
*
* To use, place in ~/.ipython/profile_julia/static/custom/custom.css
* and refresh IJulia
*
* Based on suggestions from practicaltypography.com
*/
using Images
using JSON
auth_token=#Put your auth_token here
download("https://api.github.com/repos/JuliaLang/julia/contributors?access_token=$(auth_token)", "julia_contribs.json")
authors=JSON.parse(open("julia_contribs.json"))
for (idx, author) in enumerate(authors)
authorname=author["login"]
gravatar_filename = string("avatar_", authorname, ".png")
download(author["avatar_url"], gravatar_filename)
theimage = Images.imread(gravatar_filename)
@jiahao
jiahao / perf.scilab
Created December 9, 2013 07:16
Performance benchmarks for Scilab
warning off;
function assert(bool)
if ~bool
error('Assertion failed')
end
endfunction
function timeit(name, func, varargin1)
lang = 'scilab';