Skip to content

Instantly share code, notes, and snippets.

View larshb's full-sized avatar
🏎️

Lars Henrik Bolstad larshb

🏎️
View GitHub Profile
@larshb
larshb / customize_windir.bat
Created April 7, 2019 12:24
Batch script to customize windows directories with a cosmetic name and icon.
@echo off
echo The script will create a desktop.ini file and make it and the icon file hidden.
echo Directory to be customized: %cd%
set /p name="Name (overlayed).....: "
set /p desc="Description (tooltip): "
set /p icon="Icon file (.ico).....: "
set /p confirmation=Ready to apply? [y]es
@larshb
larshb / finn.py
Created April 5, 2019 22:50
Scrabe apartment data based on id (Finn-kode) from finn.no
import urllib.request, re
from pprint import pprint
import os
# Apartment codes (Finn-kode)
codes = [143511428, 140785196]
FINNROOT = "https://www.finn.no/realestate/homes/ad.html?finnkode="
finnLink = lambda code : FINNROOT + str(code)
@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)
@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 / 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 / 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 January 8, 2019 14:05
SVN clean and delete all unversioned/ignored files/folders in my working directory
@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 / Badges.md
Last active December 24, 2018 01:30

@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