Skip to content

Instantly share code, notes, and snippets.

View ssfrr's full-sized avatar

Spencer Russell ssfrr

View GitHub Profile
julia> struct DupVector{T} <: AbstractVector{T}
A::Vector{T}
end
julia> Base.size(dv::DupVector) = size(dv.A) .* 2
julia> @inline function Base.getindex(dv::DupVector, idx)
@boundscheck checkbounds(dv, idx)
dv.A[div(idx+1, 2)]
end

Keybase proof

I hereby claim:

  • I am ssfrr on github.
  • I am ssfrr (https://keybase.io/ssfrr) on keybase.
  • I have a public key whose fingerprint is 4930 5D94 B9E9 0374 4A3A 0A43 3A19 7F2E 8259 4329

To claim this, I am signing this object:

// Build with gcc --shared -o cbtest.so
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
typedef void *(*callback_t)(void *);
pthread_t thread;
callback_t cb = NULL;
@ssfrr
ssfrr / gist:f129b321317aa5a735b2
Created February 29, 2016 16:09
GLVisualize Error
1 : #version 330
2 :
3 : #extension GL_ARB_conservative_depth: enable
4 :
5 : #define CIRCLE 0
6 : #define RECTANGLE 1
7 : #define ROUNDED_RECTANGLE 2
8 : #define DISTANCEFIELD 3
9 :
10 : in vec4 f_color;
@ssfrr
ssfrr / gist:aee377cbbf12baf8d404
Last active September 18, 2015 19:22
genstdlib.jl output
<MUCH MORE OF THE SAME ABOVE>
WARNING: Mod Base utf16
INFO: no docs for utf16(::Union{Ptr{UInt16},Ptr{Int16}} [, length]) in Base
ErrorException("Cannot find doc for utf32")
WARNING: Mod Base utf32
INFO: no docs for utf32(s) in Base
ErrorException("Cannot find doc for utf32")
WARNING: Mod Base utf32
INFO: no docs for utf32(::Union{Ptr{Char},Ptr{UInt32},Ptr{Int32}} [, length]) in Base
@ssfrr
ssfrr / dotest.jl
Created September 10, 2015 16:26
do block vs. begin block in Julia
dofun(f) = f()
macro gendo()
ex = Expr(:block)
for i in 1:10000
push!(ex.args, :(dofun() do
1+$i
end))
end
ex
[JavaScript Error: "No matching references found"]
version => 4.0.28, platform => MacIntel, oscpu => Intel Mac OS X 10.10, locale => en-US, appName => Zotero, appVersion => 4.0.28
=========================================================
(5)(+0000000): SELECT indexedPages, totalPages AS total FROM fulltextItems WHERE itemID=?
(5)(+0000000): Binding parameter 1 of type int: 67
@ssfrr
ssfrr / chain_websocketd-stdout---supervisor-7WaXCN.log
Created February 16, 2015 16:22
websocketd logfile with "too many openfiles" errors
This file has been truncated, but you can view the full file.
2015-02-13 11:47:59 chain-api chain.websocketd[48142] INFO websocketd.py started
2015-02-13 11:48:04 chain-api chain.websocketd[48142] INFO ws client connected for tag "site-15"
2015-02-13 11:48:04 chain-api chain.websocketd[48142] INFO ws client connected for tag "site-7"
2015-02-13 11:48:50 chain-api chain.websocketd[48142] INFO ws client connected for tag "site-5"
2015-02-13 11:50:08 chain-api chain.websocketd[48142] INFO ws client connected for tag "site-5"
2015-02-13 11:53:59 chain-api chain.websocketd[48142] INFO ws client connected for tag "site-15"
2015-02-13 11:55:04 chain-api chain.websocketd[48142] INFO ws client connected for tag "site-15"
2015-02-13 11:55:53 chain-api chain.websocketd[48142] INFO Caught Error sending to client: Socket is dead
2015-02-13 11:55:53 chain-api chain.websocketd[48142] INFO Disconnecting ZMQ Socket for tag "site-15"
2015-02-13 11:55:53 chain-api chain.websocketd[48142] INFO Caught Error sending to client: Socket is dead
@ssfrr
ssfrr / gist:0eba235321a21fac1e93
Created August 22, 2014 18:36
Segfault running RunTests test
~/.j/RunTests git:master ❯❯❯ julia-debug test/runtests.jl ⏎
WARNING: tty_cols() is deprecated, use tty_size() instead
in tty_cols at deprecated.jl:149
in include at /Users/srussell/local/src/julia/julia-3e30c5ab5f/lib/julia/sys.dylib
in include_from_node1 at /Users/srussell/local/src/julia/julia-3e30c5ab5f/lib/julia/sys.dylib
in include at /Users/srussell/local/src/julia/julia-3e30c5ab5f/lib/julia/sys.dylib
in include_from_node1 at /Users/srussell/local/src/julia/julia-3e30c5ab5f/lib/julia/sys.dylib
in reload_path at loading.jl:152
in _require at loading.jl:67
in require at loading.jl:51
@ssfrr
ssfrr / orders.json
Last active August 29, 2015 14:05
Simplified HAL
{
"self": {"href":"/orders"},
"rel-templates":[
{
"name":"ea",
"href":"http://example.com/docs/rels/{rel}",
"templated":true
}
],
"next":{"href": "/orders?page=2"},