Skip to content

Instantly share code, notes, and snippets.

View larshb's full-sized avatar
🏎️

Lars Henrik Bolstad larshb

🏎️
View GitHub Profile
#!/usr/bin/env python3
import re
from argparse import ArgumentParser
from pathlib import Path
import logging as log
SRT_REGEX = r"(?P<index>\d+)\n(?P<time>[\d\:\ \-\>\,]+)\n(?P<text>(?:.|\n)*?)\n\n"
EPILOG = f'''Example:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@larshb
larshb / axi_slave.vho
Created March 4, 2020 15:42
Transaction interface for VHDL AXI slave
sync: process (S_AXI_ACLK) begin
if rising_edge(S_AXI_ACLK) then
if S_AXI_ARESETN = '0' then
axi_awready <= '0';
aw_en <= '1';
axi_awaddr <= (others => '0');
axi_wready <= '0';
axi_bvalid <= '0';
axi_bresp <= "00";
@larshb
larshb / bashCommand.ahk
Created January 8, 2020 15:07
AutoHotkey script to prompt for WSL/Ubuntu/Bash command on win+shift+r press
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#+r::
; [Win] + [Shift] + [R]
InputBox, BashCommand, Enter Linux command,,,,100
Run, bash -ic "%BashCommand%; sleep 5"
return
@larshb
larshb / tasks.json
Last active October 22, 2019 14:46
VS Code problems matcher for Synplify
{
"version": "2.0.0",
"tasks": [
{
"label": "Synplify compile",
"type": "shell",
"command": "<compile-script which outputs .srr-logfile>",
"group": {
"kind": "build",
"isDefault": true
@larshb
larshb / config.py
Last active September 22, 2019 13:13
Python script (wrapper for jsfiddle-downloader) for downloadning and modularizing fiddles.
from logging import *
LOGLEVEL = DEBUG
USE_NODE = True
CLEAN = True
FILES = ['.html', '.js', '.css']
basicConfig(level=LOGLEVEL)
CUSTOM_REPLACEMENTS = {
@larshb
larshb / readme.md
Last active September 16, 2019 18:02
Minimal example of a REST API in Python

Depending on your operating system, environment and python version all that should be needed is the following:

pip install -r requirements.txt
python server.py

Tested, working in Windows Subsystem for Linux with Python 3.5.

When running the server test the following addresses in your browser:

@larshb
larshb / arpscan.py
Last active July 20, 2023 19:36
ARP-scan for Windows
import re
from subprocess import CalledProcessError, check_output as echo
from sys import platform
from socket import gethostbyaddr
# Config
IGNORE_BROADCAST = True
LOOKUP_HOSTNAMES = True
def get_host(ip):
@larshb
larshb / charmap.py
Last active July 12, 2019 00:04
Character Map: Dump all supported characters to console
print(''.join(chr(x) for x in range(2**15)))
@larshb
larshb / findpdf.vbs
Created April 11, 2019 11:09
Tiny VBS-script to search and download PDF-files on demand
Dim query, wsh
Set wsh=WScript.CreateObject("WScript.Shell")
query = InputBox("Find PDF for: ")
wsh.Run "http://www.google.com/search?q=ext:pdf%20" & query & "&btnI"