Skip to content

Instantly share code, notes, and snippets.

View gist:9494002
julia> s = sprint() do io
println(io, "hello")
println(io, "world"
end
"hello\nworld\n"
@StefanKarpinski
StefanKarpinski / threadzmq.c
Created Apr 8, 2014
thread communication with ZMQ
View threadzmq.c
// gcc -shared -fPIC -I$JULIAHOME/usr/include -L$JULIAHOME/usr/lib -lzmq -luv -o libthreadzmq.so threadzmq.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <math.h>
#include <zmq.h>
#include <uv.h>
View julia-users headers
Precedence: list
Mailing-list: list julia-users@googlegroups.com; contact julia-users+owners@googlegroups.com
List-ID: <julia-users.googlegroups.com>
X-Google-Group-Id: 756090033396
List-Post: <http://groups.google.com/group/julia-users/post>, <mailto:julia-users@googlegroups.com>
List-Help: <http://groups.google.com/support/>, <mailto:julia-users+help@googlegroups.com>
List-Archive: <http://groups.google.com/group/julia-users
Sender: julia-users@googlegroups.com
List-Subscribe: <http://groups.google.com/group/julia-users/subscribe>, <mailto:julia-users+subscribe@googlegroups.com>
List-Unsubscribe: <mailto:googlegroups-manage+756090033396+unsubscribe@googlegroups.com>,
View excellent.csv
perl1 2 4.38690185546875e-05
perl2 2 2.78949737548828e-05
perl1 2 2.09808349609375e-05
perl2 2 1.97887420654297e-05
perl1 2 2.00271606445312e-05
perl2 2 2.09808349609375e-05
perl1 2 2.09808349609375e-05
perl2 2 2.09808349609375e-05
perl1 2 1.9073486328125e-05
perl2 2 2.00271606445312e-05
View excellent.pl
use Time::HiRes qw(time);
sub perl1 {
my $k = $_[0];
foreach my $n (10**($k-1) .. 10**($k)-1) {
my $front = $n * (10**$k + $n);
my $root = int(sqrt($front));
foreach my $t ($root-2 .. $root+2) {
my $back = $t * ($t - 1);
View excellent.jl
using Compat
function julia1(k)
for n = 10^(k-1):10^k-1
front = n*(10^k + n)
root = floor(Int,sqrt(front))
for t = root-2:root+2
back = t * (t - 1)
length(string(t)) > k && break
View excellent_analysis.jl
using DataFrames, Gadfly
exl = readtable("excellent.csv", names=[:variant,:digits,:time])
agg = aggregate(groupby(exl,[:variant,:digits]), median)
agg = agg[sortperm(agg[:variant], by=first, rev=true),:]
rel = join(
agg[agg[:variant].!="julia3",:],
agg[agg[:variant].=="julia3",:],
on=:digits, kind=:left
)
View gist:778679
jewelry jewwlry 1.0
jewelry jewlwry 1.0
jewelry jewlwery 0.875
jewelry jewlwer 1.0
jewelry jewls 0.7142857142857143
jewelry jewlry 0.8571428571428571
jewelry jewlrey 1.0
jewelry jewllery 0.875
jewelry jewlewry 0.875
jewelry jewleryjust 0.6363636363636364
View gist:778680
jewelry jewwlry 1.0
jewelry jewlwry 1.0
jewelry jewlwery 0.875
jewelry jewlwer 1.0
jewelry jewls 0.7142857142857143
jewelry jewlry 0.8571428571428571
jewelry jewlrey 1.0
jewelry jewllery 0.875
jewelry jewlewry 0.875
jewelry jewleryjust 0.6363636363636364