Skip to content

Instantly share code, notes, and snippets.

View bombsimon's full-sized avatar
🍕

Simon Sawert bombsimon

🍕
View GitHub Profile
@bombsimon
bombsimon / jj
Last active April 23, 2024 06:45
Wrapper around `just` to help finding the right recipe
#!/usr/bin/env sh
set -eu
_get_user_input() {
editor=${EDITOR:-vi}
tempfile=$(mktemp)
echo "$@" > "$tempfile"
"$editor" "$tempfile"
args=$(cat "$tempfile")
@bombsimon
bombsimon / arr.sh
Created August 16, 2021 06:27
Check if reboot is required on Arch
#!/bin/sh
NEXTLINE=0
FIND=""
for I in `file /boot/vmlinuz*`; do
if [ ${NEXTLINE} -eq 1 ]; then
FIND="${I}"
NEXTLINE=0
else
if [ "${I}" = "version" ]; then NEXTLINE=1; fi
@bombsimon
bombsimon / go.mod
Created November 9, 2020 21:04
Reverse proxy ignoring TLS
module github.com/bombsimon/reverse-proxy
go 1.15
@bombsimon
bombsimon / README.md
Last active March 3, 2020 22:20
Formatt code with AI

Code formatting with AI

Since I wrote wsl I find it of interest to read about code formatting and how one could improve readability of code. Static analyzers are great and I love tools like black but if there were an even easyer way I would love that!

Towards a Universal Code Formatter through Machine Learning

I got some interesting links while chatting about [v

@bombsimon
bombsimon / git-init-gist
Last active February 5, 2024 13:15
✏️ Easily clone a gist to a regular git repository
#!/bin/sh
set -eu
gi() {
name="${1:-}"
gist="${2:-}"
if [ "$name" = "" ]; then
echo "Missing gist name"
@bombsimon
bombsimon / README.md
Last active January 31, 2023 13:52
A modern toolbox

Shell toolbox

This is a list of the tools I've been or am using in my daily work. The main idea behind this list is to acknowledge new tools which heavy improves many users existing toolbox.

I love oneliners, I love awk, grep, sed and the whole family but it just... It's a bit last century! This list might help you improve your productivity!

@bombsimon
bombsimon / zip.go
Created January 23, 2020 09:34
Create zip archive of files
package zip
import (
"archive/zip"
"io"
"os"
)
// Service represents a service that knows about compressing files into zip
// archives.
@bombsimon
bombsimon / outer_coordiantes.py
Created December 11, 2019 14:51
Get the outer frame coordiantes from a 2D array
def outer_coordiantes(arr):
"""
Get the outer most coordiantes for a 2D array, starting at 0,0.
>>> outer_coordiantes([[0,0,0],[0,0,0][0,0,0]])
[(0,0), (0,1), (0,2), (1,2), (2,2), (2,1), (2,0), (1,0)]
"""
# Top row
frame_coordiantes = [(0, x) for x in range(len(arr[0]) - 1)]
@bombsimon
bombsimon / find.php
Created September 23, 2019 21:08
Find first occurrence of key in PHP array
<?php
$test_arr = array(
"a" => array(
"aa" => 0,
"ab" => 1
),
"b" => array(
"ba" => array(
"baa" => 3,
"bab" => 4
@bombsimon
bombsimon / shortest-route.py
Last active July 22, 2019 13:40
Example to show shortes route
#!/usr/bin/env python3
""" Find shortest path """
import networkx as nx
def main():
""" Main method """
objs = [
{"src": "SWE", "dst": "LDN"},