snippets

[bash] See live output from a job in an LSF system (ETH Euler cluster)

$ bjobs
JOBID      USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
50960495   mrawlik RUN   normal.24h eu-login-08 eu-c7-056-1 *il_output Oct  6 08:55
$ watch bpeek 50960495

The screen refreshes every 2 seconds by default.

[julia] load a local module from a subdir with PyCall

unshift!(PyVector(pyimport("sys")["path"]), "subdirectory_name")
@pyimport myfile

Ref. https://github.com/JuliaPy/PyCall.jl/issues/48#issuecomment-143603067

If the file imports matplotlib, than using PyPlot needs to be called before.

[julia] sigma confidence levels

using SpecialFunctions
sigmalevel(n) = erf(n / 2)
sigmapvalue(n) = erfc(n / 2)

julia> for n in 1:8
           println("$(n)σ : ", sigmalevel(n), " : ", sigmapvalue(n))
       end
1σ : 0.6826894921370859 : 0.31731050786291415
2σ : 0.9544997361036416 : 0.04550026389635844
3σ : 0.9973002039367398 : 0.0026997960632601913
4σ : 0.9999366575163338 : 6.334248366623993e-5
5σ : 0.9999994266968563 : 5.733031437583892e-7
6σ : 0.9999999980268247 : 1.973175290075403e-9
7σ : 0.9999999999974404 : 2.5596250877716703e-12
8σ : 0.9999999999999988 : 1.2441921148543639e-15

[Python] brighten any color in matplotlib

def brighten(color, v):
    return np.array(matplotlib.colors.to_rgb(color)) ** (1 - v)

x = linspace(-1, 1)
clrs = ["C%d" % i for i in range(10)]
for i, clr in enumerate(clrs):
    scatter(x, ones_like(x) * i, color = [ brighten(clr, v) for v in x ], s = 60)
yticks(range(10), clrs)
xlabel("brighten(..., v)")

brighten any color in matplotlib

[julia] change lightness of a matplotlib's color

@pyimport colorsys
changelightness(c, l) = colorsys.hls_to_rgb((colorsys.rgb_to_hls(matplotlib[:colors][:to_rgb](c)...) .* [1, 0, 1] .+ [0, l, 0])...)

[fish] Update all pip packages

pip3 list -o | tail -n +3 | string match -r '^[\w-]+' | xargs pip3 install -U

[fish] Sync a jekyll website to the server

rsync -rt --delete _site/ $DEST