Skip to content

Instantly share code, notes, and snippets.

View abertschi's full-sized avatar
💭
writing code

Andrin Bertschi abertschi

💭
writing code
View GitHub Profile
@abertschi
abertschi / how-to-ssh-agent.md
Created September 1, 2023 17:16 — forked from nepsilon/how-to-ssh-agent.md
Remember passphrases with ssh-agent — First published in fullweb.io issue #31

How to use ssh-agent to cache your SSH credentials?

Contributed by Fabien Loudet, Linux SysAdmin at Rosetta Stone

Tired of always having to enter your SSH key passphrase when logging in to remote machines? Here comes ssh-agent. Enter the passphrase once and it will keep it in memory for you

Using ssh-agent in your shell session:

@abertschi
abertschi / nsui-via-wine.md
Created June 14, 2022 15:14 — forked from bmaupin/nsui-via-wine.md
Run New Super Ultimate Injector with Wine
@abertschi
abertschi / pagemap.c
Created October 26, 2021 16:33 — forked from rumpelsepp/pagemap.c
Read the pagemap of a given process id
// Public Domain; Feel free to copy and steal it!
// Based on:
// http://fivelinesofcode.blogspot.de/2014/03/how-to-translate-virtual-to-physical.html
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <stdint.h>
@abertschi
abertschi / benchmark+go+nginx.md
Created October 14, 2021 16:04 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@abertschi
abertschi / Good taste.md
Created March 6, 2020 20:54 — forked from santisbon/Good taste.md
What makes good taste?

On Good Taste

Linus Torvalds in an interview talked about the idea of good taste in code or what I like to call elegance. As one might expect from two slides meant to make a point during a talk, he omits a lot of details to keep it short and simple. This post digs into the specifics of his example (deleting an element from a list) and adds another example (inserting an element in a list) including working code.

Example from Linus

This is an example of removing an element from a singly-linked list. It's one of the first data structures you learn about when you start learning about computer science and programming. The reason it doesn't show particularly good taste is because we have that condition at the end where we take a different action depending on whether the element we want to remove is at the beginning of the list or somewhere in the middle.

![Bad taste](http://

@abertschi
abertschi / log.c
Created October 9, 2019 13:50 — forked from fclairamb/log.c
Simple C logging code
#include "log.h"
unsigned char log_run_level = LOG_LVL_DEBUG;
const char * log_level_strings [] = {
"NONE", // 0
"CRIT", // 1
"WARN", // 2
"NOTI", // 3
" LOG", // 4
@abertschi
abertschi / extend.sh
Created May 23, 2019 15:59 — forked from wvengen/extend.sh
Extend non-HiDPI external display above HiDPI internal display
#!/bin/sh
# extend non-HiDPI external display on DP* above HiDPI internal display eDP*
# see also https://wiki.archlinux.org/index.php/HiDPI
# you may run into https://bugs.freedesktop.org/show_bug.cgi?id=39949
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/883319
EXT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^eDP | head -n 1`
INT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^DP | head -n 1`
ext_w=`xrandr | sed 's/^'"${EXT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
@abertschi
abertschi / gnome-flashback-stumpwm
Created February 11, 2019 19:37 — forked from jmbr/gnome-flashback-stumpwm
StumpWM with Gnome Flashback: all the amenities of Gnome plus the slick features of StumpWM.
This file goes in /usr/lib/gnome-flashback/
#! /bin/sh
exec gnome-session --session=gnome-flashback-stumpwm --disable-acceleration-check "$@"
@abertschi
abertschi / bluetoothctl-connect-speaker.sh
Created November 11, 2018 20:35
connect to (previously paired) Bluetooth device with bluetoothctl
#!/bin/bash
# connect to (previously paired) bluetooth device with bluetoothctl
device="74:19:F8:00:14:26"
connected=0
IFS=
while [ $connected -ne 1 ]
do
out=$(bluetoothctl <<EOF
power on
@abertschi
abertschi / EmacsKeyBinding.dict
Created December 14, 2017 14:18 — forked from jwreagor/EmacsKeyBinding.dict
Global Emacs Key Bindings for OS X
{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
* BEWARE:
* This file uses the Option key as a meta key. This has the side-effect
* of overriding Mac OS keybindings for the option key, which generally