Skip to content

Instantly share code, notes, and snippets.

@konfou
konfou / README.md
Created April 1, 2021 20:07
Fix gksqt error when plotting with Julia on NixOS

TL;DR Run julia-fix-gksqt.sh, then nix-shell julia-fix-gksqt.nix --run julia.

If you're running NixOS and trying to plot something in Julia you're probably getting the following error (where kon will and 9Vi4m may differ)

sh: /home/kon/.julia/packages/GR/9Vi4m/src/../deps/gr/bin/gksqt: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
@benmarwick
benmarwick / captions_and_crossrefs.rmd
Last active March 24, 2023 17:53
Auto-numbering and cross-referencing of figures and tables in rmarkdown
---
title: "Auto-numbering and cross-referencing of figures and tables in rmarkdown"
output: html_document
---
NOTE: I recommend using the bookdown package and `output: html_document2` to make captions and cross-references more easily than the method described below.
TODO: check this out: https://github.com/adletaw/captioner
Here's how to use:
@thugcee
thugcee / sxhkdrc
Last active May 18, 2022 09:46 — forked from jpentland/tabc.sh
Suckless' tabbed integration with BSPWM. This configuration supports joining any two neighbouring windows into a new tabbed, removing windows from tabbed and when last window is from tabbed removed then tabbed instance is closed. This slightly modified `tabc.sh` allows to omit id of the removed window (the current one is removed by default).
# Remove current tab from tabbed
super + mod1 + t; r
tabc.sh $(bspc query -N -n focused) remove
# At given direction: join two windows into a new tabbed or add window to an existing tabbed
super + mod1 + t; {Left,Down,Up,Right}
tabc.sh $(bspc query -N -n {west,south,north,east}) add $(bspc query -N -n focused)
@benmarwick
benmarwick / auto-install-and-load-packages.R
Last active February 21, 2021 01:20
A method to automatically download, install and load R packages that only requires the package name to be typed once. Credits: http://stackoverflow.com/a/8176099/1036500 & http://stackoverflow.com/a/4090208/1036500
list.of.packages <- c("xx", "yy") # replace xx and yy with package names
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(list.of.packages, require, character.only=T)
@sbos
sbos / HMM.jl
Created November 1, 2013 11:25
Hidden Markov Model in Julia
module HMM
using Distributions
import Distributions.rand
import Distributions.fit
immutable HiddenMarkovModel{TP, K}
theta::Vector{TP}
A::Matrix{Float64}