Skip to content

Instantly share code, notes, and snippets.

View vegarsti's full-sized avatar

Vegard Stikbakke vegarsti

View GitHub Profile
https://twitter.com/thorstenball/status/1576619567488475137?s=20&t=KaBdUrc5-M1bnNTMU6tuQA
Working with Unix Processes
Working with TCP Sockets
Working with Ruby Threads
Zed Shaw's C book
Programming From The Ground Up
Destroy All Software
PeepCode Play by Play
Pragmatic Programmer
Install Karabiner Elements.
Follow this
https://github.com/tekezo/Karabiner-Elements/issues/638
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/vegard/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="sobole"
def pairwise(iterable, n):
iterator = iter(iterable)
items = [None]*n
for i in range(n):
try:
items[i] = next(iterator)
except StopIteration:
return
yield tuple(items)
def pairwise(it):
iterator = iter(it)
try:
i = next(iterator)
except StopIteration:
return
yield
try:
j = next(iterator)
except StopIteration:
  • tee from itertools is cool! link
from itertools import tee
i, j = tee(data)
next(j)
for first, second in zip(i, j):

Given array a, count occurrences and stack.

e.g. a = np.array([0, 0, 1, 1, 2, 1, 0, 2, 3, 0, 1])

then counts = np.dstack(np.unique(a, return_counts=True)) gives

array([[[0, 4],
        [1, 4],
 [2, 2],
  • current_date - interval '1 days'*extract(isodow from now()) sunday before this week