Skip to content

Instantly share code, notes, and snippets.

@ityonemo
ityonemo / uppertriangular.jl
Created September 28, 2016 04:36
Iterates over upper triangular indices.
#upper triangular indices - iterates over upper triangular indices in a list of
#indices.
type uppertriangular; iterable; end
Base.start(x::uppertriangular) = (1, 1)
function Base.next(x::uppertriangular, state)
(idx1, idx2) = state
next1 = idx1
next2 = idx2 + 1
if next2 > length(x.iterable)
@SimonDanisch
SimonDanisch / lorenz.jl
Created September 23, 2016 12:01
Interactively plot Lorenz attractor with GLPlot
using GeometryTypes, Reactive, GLVisualize
using GLPlot;GLPlot.init()
"""
Lorenz function
"""
function lorenz(t0, a, b, c, h)
Point3f0(
t0[1] + h * a * (t0[2] - t0[1]),
t0[2] + h * (t0[1] * (b - t0[3]) - t0[2]),
using Plots;glvisualize()
using GLVisualize, FileIO, Colors, Images
using GeometryTypes, GLAbstraction
x = ["(。◕‿◕。)", "◔ ⌣ ◔","(づ。◕‿‿◕。)づ", "┬──┬ ノ( ゜-゜ノ)", "(╯°□°)╯︵ ┻━┻", "¯\\_(ツ)_/¯"]
y = [-4, -3, -2, -1, 6, 0]
scatter(x, y)
t = bounce(linspace(-1.0f0,1f0, 20))
translation = map(t) do t
rotationmatrix_y(1f0)*rotationmatrix_z(deg2rad(90f0)) * translationmatrix(Vec3f0(3,3,t))
@sultanqasim
sultanqasim / zram.sh
Created June 21, 2016 02:41
ZRAM config for Raspberry Pi 3
#!/bin/bash
# Raspberry Pi ZRAM script
# Tuned for quad core, 1 GB RAM models
# put me in /etc/init.d/zram.sh and make me executable
# then run "sudo update-rc.d zram.sh defaults"
modprobe zram
echo 3 >/sys/devices/virtual/block/zram0/max_comp_streams
echo lz4 >/sys/devices/virtual/block/zram0/comp_algorithm
@rknuu
rknuu / factorial-table.jl
Created February 10, 2016 02:57
Julia is awesome...
# Julia is fully unicode aware and if you use your variable and function
# names just right, you can express your anger like no other language.
⋰┛ಠДಠ┛⋱彡┻━┻(n) = n < 2 ? n : ⋰┛ಠДಠ┛⋱彡┻━┻(n - 1) + ⋰┛ಠДಠ┛⋱彡┻━┻(n - 2)
@elapsed ⋰┛ಠДಠ┛⋱彡┻━┻(25) # 0.00266
@Ismael-VC
Ismael-VC / .juliarc.jl
Last active May 24, 2017 09:29
Julia user configuration file.
const HOSTS = ASCIIString["hd$(i)" for i = 1:19]
const SEPARATOR = "#" ^ 79
separator() = (println(); print_with_color(:cyan, SEPARATOR); println())
function ssh_all(command, commands...; hosts=HOSTS)
separator()
for host in hosts
println()
@ZacCranko
ZacCranko / .juliarc.jl
Last active August 9, 2016 23:59
Current juliarc.jl
push!(LOAD_PATH, pwd())
# Run _init.jl at runtime if it exists
if VERSION < v"0.4-"
if isinteractive() && isfile("_init.jl")
info("Found ", joinpath(pwd(),"_init.jl"))
include(joinpath(pwd(),"_init.jl"))
end
else
atreplinit() do repl
@Ismael-VC
Ismael-VC / always_on_jupyter.sh
Last active September 11, 2015 16:57 — forked from jbn/always_on_jupyter.sh
Always On Jupyter
# Installation:
# - Put this in your .bash_profile
# - Replace my directory with your exobrain directory on line 10
#
# What you get:
# A Jupyter notebook open on a well-defined port that is always
# on for exobrain-ing your ideas...
exec 6<>/dev/tcp/localhost/10000 || (
source activate py27 &&
@jbn
jbn / always_on_jupyter.sh
Created September 10, 2015 14:12
Always On Jupyter
# Installation:
# - Put this in your .bash_profile
# - Replace my directory with your exobrain directory on line 10
#
# What you get:
# A Jupyter notebook open on a well-defined port that is always
# on for exobrain-ing your ideas...
exec 6<>/dev/tcp/localhost/10000 || (
source activate py27 &&
@jbn
jbn / julia_type_hierarchy.jl
Created July 17, 2015 22:44
Julia Type Hierarchy
# Requested gist of code to produce:
# https://www.scribd.com/doc/271871142/Julia-Type-Hierarchy
#
# I just redirected the output to a dot file, then executed:
# dot -Tpdf julia.dot -o julia.pdf
function print_type_tree(t, parent=Any, seen=Set{DataType}())
# Avoid redundant edges.
t ∈ seen && return
push!(seen, t)