Skip to content

Instantly share code, notes, and snippets.

View johnmyleswhite's full-sized avatar

John Myles White johnmyleswhite

View GitHub Profile
@cscheid
cscheid / main.jl
Created September 10, 2014 22:51
bare-bones stress majorization in julia
# You should totally ignore this because it's the first piece of Julia I've ever written.
# 2-clause BSD, blah.
function make_cycle(n)
result = Dict{Int32, Array{Int32}}()
for i = 1:n
ii = i - 1
push!(result, i, [1 + ((i+n-2) % n), 1 + i % n])
end
result
@quinnj
quinnj / juliacon2015.jl
Last active August 29, 2015 14:23
Managing Data in Julia: Old Tricks, New Tricks Code
Pkg.clone("https://github.com/quinnj/Mmap.jl")
Pkg.clone("https://github.com/quinnj/CSV.jl")
Pkg.add("ODBC")
Pkg.checkout("SQLite","jq/remodel")
Pkg.add("SQLite")
Pkg.checkout("SQLite","jq/updates")
reload("Mmap")
reload("CSV")
type DataFrame{N,D}
data::D
end
immutable Field{s}
end
Field(s::Symbol) = Field{s}()
function DataFrame(;kwds...)
@simonbyrne
simonbyrne / jbug.jl
Created October 15, 2012 19:48
A bugs-type sampler in julia
require("extras/distributions.jl")
require("slicesampler.jl")
import Distributions.*
macro buildslicesampler(model)
# pull apart the model into variables and distributions
variables = Dict{Symbol,Expr}()
unboundvars = Set{Symbol}()
for line in model.args
@kjhealy
kjhealy / st2binding
Created November 5, 2012 16:22
R and ST2's REPL. Keybinding Example
[
// Modified Sublime-REPL keybindings for an "R-friendly" set of shortcuts.
// Copy and paste this text into the Key Bindings - User (under Preferences menu).
// For more information, see http://tomschenkjr.net/2012/05/17/using-sublime-text-2-for-r/
// Executes a selection of text in REPL, latter only displays code and does not execute
{ "keys": ["super+shift+enter"], "command": "repl_transfer_current", "args": {"scope": "selection"}},
// I disabled this one
//{ "keys": ["super+shift+enter", "r"], "command": "repl_transfer_current", "args": {"scope": "selection", "action":"view_write"}},
anonymous
anonymous / Chutes.jl
Created December 24, 2012 03:32
Graphs in Julia... some preliminary thoughts
module Chutes
abstract Graph
abstract DGraph <: Graph
abstract UGraph <: Graph
typealias LabelType Dict{Int,Any}
type DenseGraph <: Graph
mat :: Matrix{Uint8}
@dmbates
dmbates / gist:5303570
Last active December 15, 2015 18:28
Formula, ModelFrame and ModelMatrix types

Formula, ModelFrame and ModelMatrix types

In R, the functions for fitting statistical models based on a linear predictor usually allow for a formula/data specification of the model. The data part is a data.frame object in R. In Julia the corresponding type is a DataFrame as implemented in the DataFrames package.

A formula object in R is an expression whose top-level operator is a unary or binary tilde, ~. The interpretation of many operators, including +, *, ^, \ and : are overridden in the formula language. See the result of

?formula

in R for the details.

@cykl
cykl / HLLMergeBenchmark.java
Created June 2, 2013 18:32
Benchmarks for stream-lib/faster_hll
package bench;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.BenchmarkType;
import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.State;
@carlobaldassi
carlobaldassi / nzipperf.jl
Last active December 18, 2015 04:29
Alternative Zip iterator, with better performance than the one in base, but whose performance degrades if calls to start,next,done are inlined.
module NZipTest
import Base.start, Base.next, Base.done, Base.length
using Benchmark
immutable NZip0
end
immutable NZip1{I1}
i1::I1
@romainfrancois
romainfrancois / gist:6981372
Last active December 25, 2015 13:09
Reading the internal function table
#include <Rcpp.h>
using namespace Rcpp;
typedef SEXP (*CCODE)(SEXP, SEXP, SEXP, SEXP);
/* Information for Deparsing Expressions */
typedef enum {
PP_INVALID = 0,
PP_ASSIGN = 1,
PP_ASSIGN2 = 2,