Skip to content

Instantly share code, notes, and snippets.

@mp4096
mp4096 / pdf2png.bat
Created November 24, 2015 17:44
Convert all PDF documents in a folder to PNG images using ImageMagick
@ echo off
for /r %%i in (*.pdf) do convert -density 1200 -resize 25%% "%%i" "%%i.png"
@mp4096
mp4096 / py-help.md
Last active December 18, 2015 16:19
How to install Python and all other packages on a Windows x86-64 system
@mp4096
mp4096 / kewlgitlog.sh
Last active December 22, 2015 09:02
Colourful and cool git log in shell
git log --graph --full-history --all --color --date=short --pretty=format:"%x1b[0m%h%x09%x1b[33m%d%x1b[32m%x20[%ad] %x1b[0m%s %x1b[36m(%an)"
@mp4096
mp4096 / rescale.py
Created February 25, 2016 20:04
Rescale TikZ coordinates
import re
def main(filename_in, filename_out):
re_coord_pattern = "\((?P<x>[-.\d]*),(?P<y>[-.\d]*)\)"
re_coord = re.compile(re_coord_pattern)
with open(filename_in, "r") as f_in, open(filename_out, "w") as f_out:
for line in f_in:
@mp4096
mp4096 / normalize_whitespaces_tabs.py
Created April 15, 2016 15:52
Strip trailing whitespaces and replace hard tabs
import codecs
import os
import fnmatch
def delete_if_exists(filename):
if os.path.exists(filename):
os.remove(filename)
@mp4096
mp4096 / AsyncCall.m
Created April 20, 2016 09:16
Asynchronous processes in MATLAB
function AsyncCall(arg1, arg2)
batchFileLocation = 'mybatch.bat';
cmdArgs = sprintf('""%s" "%s" "%s""', batchFileLocation, arg1, arg2);
proc = System.Diagnostics.Process();
proc.StartInfo.FileName = 'cmd.exe';
proc.StartInfo.Arguments = ['/C', cmdArgs];
proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
proc.Start();
end
@mp4096
mp4096 / latin1_to_utf8.py
Created October 5, 2016 09:04
Convert Latin 1 encoding to UTF-8
from __future__ import print_function
import codecs
import os
import fnmatch
def delete_if_exists(filename):
if os.path.exists(filename):
os.remove(filename)
@mp4096
mp4096 / hacking_scipy.sh
Last active October 23, 2016 21:11
Hacking scipy on Linux
# Install dependencies
sudo apt install -y libblas3 gcc gfortran python-dev libblas-dev liblapack-dev cython
# Create a virtualenv and activate it
virtualenv scipy-dev
source ./scipy-dev/bin/activate
# Install Python dependencies
pip install Numpy Nose Cython
@mp4096
mp4096 / rust_on_pi.sh
Created March 31, 2017 12:21
Rust on Raspberry Pi cross-compilation toolchain
# We use ARMv7, so Raspberry Pi >= 2 is required
rustup target add armv7-unknown-linux-gnueabihf
sudo apt-get install gcc-arm-linux-gnueabihf