Skip to content

Instantly share code, notes, and snippets.

View cscheid's full-sized avatar

Carlos Scheidegger cscheid

View GitHub Profile
@cscheid
cscheid / gist:5449235
Last active December 16, 2015 14:29
testing weirdness on http://developer.github.com docs
This is a test file
@cscheid
cscheid / another_test.txt
Last active December 16, 2015 13:58
Some gist
hoaskdhskldf
@cscheid
cscheid / crash.cpp
Last active December 12, 2015 08:39
This crashes g++ 4.2.1 (the default OS X 10.8 compiler) with an ICE.
template <typename T>
void fun(T* obj) {}
template <typename T, void Fun(T*) = fun<T> >
struct S {
S(int m_sexp) {};
};
template <typename T>
S<T> ptr(int s) { return S<T>(s); }
@cscheid
cscheid / README.md
Created November 28, 2012 18:41 — forked from mbostock/.block
Gradient Along Stroke

This example demonstrates how to create a gradient that follows a stroke. This technique is sometimes used to indicate directionality along a curved edge, such as with hierarchical edge bundling.

To start, take any SVG path element and uniformly sample points along the path using getPointAtLength. (This method can also be used for path tweening.) Then, for each segment between adjacent points, compute the miter joint via line-line intersection. Lastly fill each segment by interpolating the start and end colors, here green to red, using the normalized length t along the path. Although each segment is a constant color, there are many segments to give the appearance of a continuous gradient.

This example uses a thin stroke in addition to filling the segments. This avoids antialiasing artifacts due to most

@cscheid
cscheid / index.html
Created August 22, 2012 22:47
Some d3 tests
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.5.0"></script>
</head>
<body><div id="test"></div>
<script>
var names = ["v1",
"v2",
"v3",
"v4",
@cscheid
cscheid / prob.py
Last active August 29, 2015 14:14
probabilities, how do they work
import math
from pylab import *
def fact(x):
return math.gamma(x+1)
def choose(n,k):
return fact(n) / (fact(k) * fact(n-k))
def hypergeom_mass_at_k(N, K, n, k):
@cscheid
cscheid / README.md
Last active August 29, 2015 14:09 — forked from mbostock/.block

The scatterplot matrix visualizations pairwise correlations for multi-dimensional data; each cell in the matrix is a scatterplot. This example uses Anderson's data of iris flowers on the Gaspé Peninsula. Scatterplot matrix design invented by J. A. Hartigan; see also R and GGobi. Data on Iris flowers collected by Edgar Anderson and published by Ronald Fisher.

See also this version with brushing.

@cscheid
cscheid / README.md
Last active August 29, 2015 14:08 — forked from mbostock/.block
@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
@cscheid
cscheid / main.md
Created September 10, 2014 19:51
A monotonic transformation from IEEE 754 floats to unsigned ints

You need to get to the bit representation of the float, and then:

inline unsigned int float2fint(unsigned int f) {
    return f ^ ((-(f >> 31)) | 0x80000000);
}

Callahan et al. used this trick in this paper.

Caveats: