Skip to content

Instantly share code, notes, and snippets.

@skaslev
skaslev / .Xmodmap
Created April 22, 2014 10:12
Rotate Ctrl, Win and Alt keys
clear control
clear mod1
clear mod4
keycode 37 = Super_L Hyper_L
keycode 64 = Control_L
keycode 133 = Alt_L Meta_L
add control = Control_L Control_R
add mod1 = Alt_L Meta_L
add mod4 = Super_L Super_R Hyper_L
@skaslev
skaslev / init.el
Last active August 29, 2015 14:03
init.el
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(let ((path (shell-command-to-string ". ~/.bashrc; echo -n $PATH")))
(setenv "PATH" path)
(setq exec-path
(append
(split-string-and-unquote path ":")
exec-path)))

Keybase proof

I hereby claim:

  • I am skaslev on github.
  • I am skaslev (https://keybase.io/skaslev) on keybase.
  • I have a public key whose fingerprint is BEC3 2DE7 FB2B 879C F12C DC64 08E8 A589 5281 30FB

To claim this, I am signing this object:

@skaslev
skaslev / zeta.py
Last active August 29, 2015 14:06
Computing Riemann's zeta function on the critical strip.
'''
Computing Riemann's zeta function on the critical strip. For reference, see:
"An electro-mechanical investigation of the Riemann zeta function in the critical strip" Balth. van der Pol
For computing FFT of continous functions see:
Also see http://stackoverflow.com/questions/24077913/discretized-continuous-fourier-transform-with-numpy
'''
from matplotlib.pyplot import plot, show, xlim, ylim
from numpy import *
from numpy.fft import fft, fftfreq, fftshift
@skaslev
skaslev / complex_step.cc
Last active August 29, 2015 14:07
Complex Step Differentiation
#include <stdio.h>
#include <complex>
#include <tuple>
namespace {
// See http://blogs.mathworks.com/cleve/2013/10/14/complex-step-differentiation/
template<class R, class F>
std::tuple<R, R> dF(F f, R x, R h=1e-8) {
using C = std::complex<R>;
@skaslev
skaslev / .bashrc
Last active August 29, 2015 14:08
Bash config
export PROMPT_DIRTRIM=3
export PS1='\[\033[0;35m\]\u@\h\[\033[0;33m\] \w\[\033[00m\]$ '
export TERM=xterm-256color
export PATH="$HOME/bin:$PATH"
export GOPATH="$HOME/.go"
export USE_CCACHE=1
export CCACHE_DIR="$HOME/.ccache"
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
@skaslev
skaslev / timer.cpp
Last active September 14, 2015 07:20
Nanosecond precision timer
#include <stdint.h>
#include <stdio.h>
#include <time.h>
namespace {
const int64_t SEC = 1;
const int64_t MILI = 1000; // 10^3
const int64_t MICRO = 1000 * 1000; // 10^6
const int64_t NANO = 1000 * 1000 * 1000; // 10^9
@skaslev
skaslev / alarm
Created November 24, 2010 08:42
Usage: ./alarm 8h 1337s
#!/bin/sh
sleep $@ && mplayer -loop 0 'Good Morning Starshine.mp3'
@skaslev
skaslev / pull.py
Last active September 24, 2015 07:37
Update all local repositories in parallel
#!/usr/bin/env python
import os
import subprocess
src = os.path.expandvars('$HOME/src')
ignored = set(['x'])
repo_cmd = { '.git': 'git pull',
@skaslev
skaslev / tree_path.cc
Created November 28, 2012 01:16
Given a binary tree, find the longest possible path.
// Given a binary tree, find the longest possible path.
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <random>
struct Node {
int id;
Node* left;
Node* right;