Skip to content

Instantly share code, notes, and snippets.

View cvanelteren's full-sized avatar

Casper van Elteren cvanelteren

View GitHub Profile
test-microphone() {
arecord -vvv -f dat /dev/null
}
@cvanelteren
cvanelteren / vispy_networkx_numpy.py
Last active October 19, 2020 16:41
Using networkx layouts and numpy coordinates for vispy.
from vispy.visuals.graphs.util import _straight_line_vertices, issparse
import networkx as nx, numpy as np
class NetworkxCoordinates:
def __init__(self, graph, layout = None, *args, **kwargs):
self.graph = graph
self.positions = np.zeros((len(graph), 2), dtype = np.float32)
# default random positions
if type(layout) is type(None):
self.positions = np.random.rand(*self.positions.shape)
@cvanelteren
cvanelteren / convert.py
Last active May 25, 2020 12:55
convert using k2pdfopt to e-reader friendly format
from subprocess import run
from multiprocessing import cpu_count
import os, click
@click.command()
@click.option('--source', default = "~/Phd/ereader")
@click.option('--target', default = "~/Calibre Library")
@click.option('--args', default = f"-as -w -ocr -nt {cpu_count()} -ocr -x -ui-")
def run_reader(source, target, args):
eReaderConverter(source, target, args).convert()
@cvanelteren
cvanelteren / nested_pybind.cpp
Last active May 12, 2020 11:46
Binding nested subclasses in pybind11
#include <pybind11/stl.h>
#include <pybind11/pybind11.h>
#include <pybind11/operators.h>
namespace py = pybind11;
using namespace pybind11::literals;
using namespace std;
template<typename T>
class Property{
@cvanelteren
cvanelteren / spacemacs-keybindings
Created April 4, 2020 01:33 — forked from adham90/spacemacs-keybindings
spacemacs keybindings that i need to learn
SPC s c remove highlight
**** Files manipulations key bindings
Files manipulation commands (start with ~f~):
| Key Binding | Description |
|-------------+----------------------------------------------------------------|
| ~SPC f c~ | copy current file to a different location |
| ~SPC f C d~ | convert file from unix to dos encoding |
| ~SPC f C u~ | convert file from dos to unix encoding |
git clone --bare https://github.com/cvanelteren/dots.git $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";