Skip to content

Instantly share code, notes, and snippets.

View nlw0's full-sized avatar

Nicolau Leal Werneck nlw0

View GitHub Profile
@nlw0
nlw0 / pwsumtimetest.jl
Created April 17, 2022 10:11
Test speed of julia `sum` compared to a for-loop over Float32 values
using BenchmarkTools
using Statistics
using GLMakie
function simpsum(a)
y = zero(eltype(a))
ll = length(a)
@inbounds @simd for i in 1:ll #eachindex(a)
y += a[i]
end
@nlw0
nlw0 / sirfit.ipynb
Last active January 17, 2022 04:12
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nlw0
nlw0 / gist:2ad73c71d561e9fe5ff102ce880a6941
Last active February 26, 2020 13:11
xmonad installation
https://brianbuccola.com/how-to-install-xmonad-and-xmobar-via-stack/
sudo apt install curl wget
sudo apt install libxrandr-dev libxrender-dev
sudo apt install libxft-dev libxss-dev libxinerama-dev
sudo apt install libiw-dev libxpm-dev
stack install --flag xmobar:all_extensions
@nlw0
nlw0 / mergemasks.jl
Last active November 30, 2019 16:06
UNet in Flux (work in progress!)
## Process data from https://www.kaggle.com/c/data-science-bowl-2018/
## Merge a bunch of binary masks into a single one
using Glob, Images
root = "/home/user/src/data/data-science-bowl-2018/train/"
for case in glob("*", root)
labels = glob("*png", case * "/masks")
mergedlabels = sum(map(load, labels))
save(case * "/mergedmasks.png", mergedlabels)
@nlw0
nlw0 / Eigvec2fromeigval.ipynb
Last active July 28, 2020 16:36
Eigenvectors from eigenvalues (Julia demo)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nlw0
nlw0 / Eig.ipynb
Created November 16, 2019 12:17
Eigenvectors from eigenvalues (Julia demo)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We couldn’t find that file to show.
@nlw0
nlw0 / dirmap.c
Created October 12, 2019 15:37
Iterating over a directory contents with Julia and libuv's readdir
#include "uv.h"
typedef void (*callback)(const char *, int, void*);
void dirmap(const char path[], callback cb, void* thunk) {
uv_fs_t readdir_req;
uv_fs_opendir(NULL, &readdir_req, path, NULL);
uv_dirent_t dirent;
@nlw0
nlw0 / file-count.c
Last active October 10, 2019 21:44
Counting files based on libuv's readdir and scandir via C and Julia
#include "uv.h"
#include "stdio.h"
#include "string.h"
#include <sys/time.h>
int min(int a, int b) { return (a < b)? a : b; }
int get_file_count_read(const char path[], int chunklen) {
uv_fs_t readdir_req;