Skip to content

Instantly share code, notes, and snippets.

View StefanKarpinski's full-sized avatar

Stefan Karpinski StefanKarpinski

View GitHub Profile
@unix_only begin
const path_separator = "/"
const path_separator_regex = r"/+"
const path_absolute_regex = r"^/"
const path_parse_regex = r"^(.*?/|)([^/]+?)(\.[^\.]+|)$"
splitdrive(path::String) = ("",path)
end
@windows_only begin
const path_separator = "\\"
julia> (+) = 1
1
julia> +
1
Eight miles deep the well forgotten by mortals
Oh, I drank it empty in one single sip
Eight miles wide the valley beyond all hope
Oh, I filled the whole with one single fist
Five million christians on a ride towards us
Oh, I slaughtered the bunch with one single hit with my spear
Five million women so alone in the night
Oh, I had them all satisfied profusely every night by myself
JULIA test/all
From worker 2: * core
From worker 3: * numbers
From worker 2: * strings
exception on 1: ERROR: read: end of file
in read at iobuffer.jl:54
in read at stream.jl:373
in anonymous at task.jl:804
From worker 2: exception on 2: ERROR: read: end of file
From worker 2: in read at iobuffer.jl:54
julia> s = sprint() do io
println(io, "hello")
println(io, "world"
end
"hello\nworld\n"
@StefanKarpinski
StefanKarpinski / threadzmq.c
Created April 8, 2014 02:26
thread communication with ZMQ
// 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>
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>,
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);
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
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
)