Skip to content

Instantly share code, notes, and snippets.

View larshb's full-sized avatar
🏎️

Lars Henrik Bolstad larshb

🏎️
View GitHub Profile
@larshb
larshb / ntnu_venus.xw32
Created January 31, 2018 15:14
X-Win32 session script for connecting to NTNU's Venus cluster and opening a browser window
<Session>
<HideOnStart>false</HideOnStart>
<Module>ssh</Module>
<Name>Venus Browse</Name>
<NewInstance>never</NewInstance>
<Settings>
<Command>nautilus --no-desktop --browser</Command>
<Host>venus.tele.ntnu.no</Host>
<UseCompression>true</UseCompression>
</Settings>
@larshb
larshb / raw2bmp.py
Last active October 12, 2018 14:15
A simple python script to convert a raw binary coded image into a bitmap file. (applying metadata to a header)
import struct
# Filenames
IFILE = "raw.bsq"
OFILE = IFILE + ".bmp"
# Image dimensions
NX = 512
NY = 2000
@larshb
larshb / bash_colors.sh
Created October 23, 2018 20:14
Visual representation of bash text and background colors
#/bin/bash
# Based on https://askubuntu.com/a/279014
for x in {0..8}; do
for i in {30..37}; do
for a in {40..47}; do
echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "
done
echo
@larshb
larshb / Badges.md
Last active December 24, 2018 01:30

@larshb
larshb / bitmap.py
Last active December 25, 2018 18:12
Convert bitmap images to ASCII-art
from struct import *
class Pixel:
def __init__(self, byte):
self.r = byte[0]
self.g = byte[1]
self.b = byte[2]
def bytestr(self, x):
return "{0:0{1}X}".format(x,2)
def __repr__(self):
@larshb
larshb / readme.md
Last active January 8, 2019 14:05
SVN clean and delete all unversioned/ignored files/folders in my working directory
@larshb
larshb / svn_status_color.sh
Created January 9, 2019 13:49
A shell script (using awk) to colorize output of svn status (st)
# Based on colorize (https://unix.stackexchange.com/a/318779)
awk '
function color(c,s) {
printf("\033[%dm%s\033[0m\n",30+c,s)
}
/?/ {color(1,$0);next}
/M/ {color(3,$0);next}
{print}
' $1
@larshb
larshb / README.md
Last active March 3, 2019 20:49
A simple script to parse your ancestry in a compact raw-text format.

GEDCOM ancestry to raw text converter

A simple script to parse your ancestry in a compact raw-text format.

Prerequisite: Python GEDCOM Parser

pip install python-gedcom
@larshb
larshb / unwrap.py
Last active April 8, 2019 09:22
Python script to make (un)wrappers for .exe-files in a subdirectory (eg. to run myprog.exe <args> as ./myprog <args>)
'''
NOTE: Must be run from shell environment (eg. WSL Bash or CygWin mintty)
Put this script in a subdirectory of the .exe files you want to unwrap.
'''
import os
BINDIR = '/'.join(os.getcwd().split('/')[:-1]) # Superdirectory
print("Unwrapping " + BINDIR)
@larshb
larshb / Log Highlight.sublime-settings
Last active March 12, 2019 07:54
Generic Sublime Log Highlight settings suitable for Synplify, Quartus, etc.
{
"log_ext": [ ".log", ".rpt" ],
"severity" : {
"error" : {
"enable" : true,
"summary" : true,
"pattern" : [
[ "^Error-\\[", "^\\s*[\\n]" ], // Error-[ ~ next empty line (multi-line)