Skip to content

Instantly share code, notes, and snippets.

View andferrari's full-sized avatar

André Ferrari andferrari

View GitHub Profile
### A Pluto.jl notebook ###
# v0.19.12
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
@andferrari
andferrari / JoyDivision.jl
Last active January 21, 2022 11:17
Julia Unknown Pleasures plot
using CSV, Tables, Plots
pulsar = CSV.read(download("https://gist.githubusercontent.com/borgar/31c1e476b8e92a11d7e9/raw/0fae97dab6830ecee185a63c1cee0008f6778ff6/pulsar.csv"), Tables.matrix)
α = 2
p = plot(border=:none, bg = :black)
for k in 79:-1:1
plot!(pulsar[80 - k ,:] .+ α*k, label="", fillrange = α*k,
fillalpha = 1, fillcolor = :black, c=:white)
end
p
@andferrari
andferrari / sort_gpus.jl
Created November 15, 2021 08:08
sort GPUs
function sort_gpus()
mems = Int[]
gpus = collect(CUDA.devices())
for k in 1:length(gpus)
CUDA.device!(k-1)
push!(mems, CUDA.available_memory())
end
ind = sortperm(mems, rev=true)
hcat(gpus[ind], mems[ind])
end
@andferrari
andferrari / predict_skylens.py
Created April 3, 2017 08:28 — forked from SpheMakh/predict_skylens.py
Predict visibilities from a FITS image
import stimela
INPUT = 'input'
OUTPUT = 'output'
MSDIR = 'msdir'
MODEL = 'skylens.fits'
MS = 'test_predict_with_custom_fits.ms'
PREFIX = MS[:-3]
@andferrari
andferrari / gist:fda78fbc851b81a1d4012e6265904a96
Created February 14, 2017 19:53
MPI with anaconda on OSX
conda uninstall mpi4py
conda uninstall ompenmpi
brew install --build-from-source openmpi
pip install mpi4py
resqconf = readlines(`qconf -sel`)
listnodes = [strip(k) for k in resqconf]
addprocs(listnodes)