Skip to content

Instantly share code, notes, and snippets.

@ibab
ibab / progress.h
Last active August 29, 2015 14:01
A convenient iterator that prints a progress bar to the terminal.
#ifndef PROGRESS_H
#define PROGRESS_H
#include <iostream>
template <class T>
class Progress {
public:
class ProgressIterator {
@ibab
ibab / array2d.cpp
Created May 21, 2014 13:12
array2d
#include <vector>
#include <iostream>
#include <array>
#include <algorithm>
template <class T, unsigned I, unsigned J>
using array2d = std::array<std::array<T, J>, I>;
int main(int argc, char *argv[])
{
@ibab
ibab / plot_serial.py
Created April 6, 2014 21:20
Plot continuous stream of data from serial port.
from pylab import *
from matplotlib import pyplot as plt
import matplotlib.animation as animation
import serial
import time
arduino = serial.Serial('/dev/ttyACM0', 9600)
time.sleep(1)

Keybase proof

I hereby claim:

  • I am ibab on github.
  • I am ibab (https://keybase.io/ibab) on keybase.
  • I have a public key whose fingerprint is 144B 7F62 78AC 54BC 998F 2488 ADD1 A3AE ADCE E6BB

To claim this, I am signing this object:

@ibab
ibab / recompile.sh
Created April 1, 2014 08:53
A shell script for automatically recompiling a .tex file on Linux and viewing the result with mupdf.
#!/bin/sh
FILE=$1
red='\e[0;31m'
green='\e[0;32m'
reset='\e[0m'
mupdf ${FILE%.*}.pdf &
@ibab
ibab / diagram.tex
Created June 29, 2013 19:48
A simple particle interaction diagram
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{trees}
\usetikzlibrary{matrix,arrows}
\usetikzlibrary{positioning}
\usetikzlibrary{calc,through}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{pgffor}
@ibab
ibab / fermi.py
Last active March 2, 2021 17:11
Simulation that explores Fermi Dirac statistics
from pylab import *
from scipy import diff
from collections import Counter
from sympy.combinatorics.partitions import IntegerPartition
from scipy.optimize import curve_fit
rc('text', usetex=True)
rc('font', family='serif', serif='cm')
def fermi_dirac(E, μ, T):
@ibab
ibab / h2.py
Created May 6, 2012 12:56
Graphical solutions of the Schrödinger-equation for an idealised H_2 potential well
# encoding: utf-8
# Needs the python2 version of maplotlib because of a bug in the python3 version :(
from pylab import *
coth = lambda x: cosh(x)/sinh(x)
# ∞ ∞
# | |
# | |