Skip to content

Instantly share code, notes, and snippets.

@pao
pao / qc.md
Last active October 11, 2015 10:17
An in-development Julia implementation of QuickCheck

Now being developed at https://github.com/pao/QuickCheck.jl and available via Pkg as "QuickCheck".

Package documentation is at https://quickcheckjl.rtfd.org/.

# A Julia implementation of QuickCheck, a randomized specification-based tester
#
# QuickCheck was originally written for Haskell by Koen Claessen and John Hughes
# http://www.cse.chalmers.se/~rjmh/QuickCheck/
@pao
pao / ccall_wrapper.jl
Created September 19, 2012 12:46 — forked from dcampbell24/gist:3470851
julia ccall macro
macro ccallWrap(lib, fnSym, retType, argTypes)
args = [gensym() for i in 1:length(argTypes.args)]
fnArgs = [:($(args[i])::$(argTypes[i]))
for i in 1:length(argTypes)]
:(($fnSym)($fnArgs...) = ccall(dlsym($lib, $fnSym), $retType, $argTypes, $args...))
end
@pao
pao / CONTRIBUTING.md
Created September 18, 2012 15:38
Julia CONTRIBUTING file (started by Jeffrey Sarnoff)

Contributing

We welcome contributions to Julia and appreciate your interest. There are capabilities to grow, interfaces to write, and bugs to squish. Area experts may contribute by writing software that supports work in their own field. To keep things percolating as smoothly as possible, we ask that you follow the advice and guidelines given here.

ready, get set

Before contributing to Julia, you should join the dev list, read the user manual and library guide, and create a free GitHub account. Follow these steps to get Julia copied to your machine in a way that lets you to work locally, rewind your edits, keep a remote backup, and safely contribute to Julia.

@pao
pao / monads.md
Last active July 29, 2019 15:15
Work in progress overkill solution to final 7L7W exercise
@pao
pao / README.md
Last active October 5, 2015 16:07
Using strpack.jl as an FFI

Note

strpack.jl is deprecated. Use the StrPack package or Julia's native C struct interop instead, depending on your needs.

Using strpack.jl as an FFI

This gist demonstrates calling C code which expects a structure pointer by writing and reading a buffer using the functions provided by strpack.jl. This takes advantage of the new align_native alignment strategy, which queries libLLVM for the platform-preferred alignment of the standard bits types.

Build the shared library

@pao
pao / iface_test.jl
Created April 20, 2012 23:10
Julia interfaces prototype
load("interface.jl")
type Blah; end
type Bluh; end
@interface FooBar{T} [
(:foo, :(T, Integer,))
(:bar, :(T, String, Integer))
]
LLRU
UnboundedLLRU(), 50 items
Assignment:
elapsed time: 0.09373784065246582 seconds
Lookup, random access:
elapsed time: 0.018180131912231445 seconds
Random mixed workload:
elapsed time: 0.0008568763732910156 seconds
UnboundedLLRU(), 500 items
Assignment:
VLRU w/MRU at vector end (same timings as 240590 but with this explanatory note)
UnboundedVLRU(), 50 items
Assignment:
elapsed time: 0.09535598754882812 seconds
Lookup, random access:
elapsed time: 0.015466928482055664 seconds
Random mixed workload:
elapsed time: 0.0009279251098632812 seconds
UnboundedVLRU(), 500 items
Assignment:
@pao
pao / png.jl
Created April 8, 2012 00:36
Sample of struct.jl usage
# Sample of struct.jl: Reading a .png header
load("struct.jl")
fpng = open(ARGS[1])
# check the signature
signature = unpack(s"BcccBBBB", fpng)
@assert isequal(signature, struct(s"BcccBBBB", 0x89, 'P', 'N', 'G', 0x0D, 0x0A, 0x1A, 0x0A))
# read the header
@pao
pao / banner.txt
Created April 2, 2012 05:26
Helper to write the MLP Music Archive update script
==============================================
= MLP MUSIC ARCHIVE UPDATER =
==============================================
= v007ab: "Sneak Attack! Huge Album Update!" =
==============================================
This program will delete any unnecessary, duplicated, or buggy files from the
previous update.
Be sure this file is at the ROOT of the Archive folder (With the README.TXT,