Skip to content

Instantly share code, notes, and snippets.

@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 / alarm
Created November 24, 2010 08:42
Usage: ./alarm 8h 1337s
#!/bin/sh
sleep $@ && mplayer -loop 0 'Good Morning Starshine.mp3'
@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;
#include <algorithm>
#include <chrono>
#include <cmath>
#include <iostream>
#define STR_(X) (#X)
#define STR(X) (STR_(X))
#define ACTUAL 2.71828182845904523536028747135266249776
typedef long long int Int;
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
#define STR_(X) (#X)
#define STR(X) (STR_(X))
#define ACTUAL 2.71828182845904523536028747135266249776
from numpy.polynomial.polynomial import *
z=Polynomial([0,1])
def Gn(n, G):
if n == 0:
return z
else:
return G(Gn(n-1,G))
@skaslev
skaslev / pie.hs
Last active December 30, 2015 16:19
*Main> pie - pi 3.269553516815904e-10
fromDFE dfe n = iter 0
where
slip x = -1 / x
iter k | k == n = dfe k
| otherwise = (dfe k) + slip (iter (k+1))
pie = fromDFE dfe 500
where
dfe 0 = 3
dfe 1 = -8
@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: