Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bxt's full-sized avatar

Bernhard Häussner bxt

View GitHub Profile
@bxt
bxt / file-extensions.sh
Created March 14, 2024 10:46
Get repo file extensions and extensionless paths
git ls-files | sed 's/.*\.//' | sort | uniq -c | sort -u
@bxt
bxt / inverting-the-testing-pyramid.md
Last active February 17, 2024 00:30
Inverting the testing pyramid

Inverting the testing pyramid

Why avoid bugs?

Annoyance, money loss, on AWS, missing out on customers, data loss, damages, lawsuites

What is a testing pyramid?

Horizontal axis: Amount of tests.

@bxt
bxt / webmsg.py
Created August 27, 2012 19:11
Really simple python web server to serve a maintenance message to the web
import string,cgi,time, datetime
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
try:
self.send_response(503) # let bots know whats up
self.send_header('Content-type','text/html')
self.end_headers()
self.wfile.write('<!DOCTYPE html>\n<meta charset=utf-8 />\n<title>Notification page</title>\n')
@bxt
bxt / iceWMdual.mkd
Created July 18, 2011 17:15
IceWM Dual Screen expanding howto (very basic)

Step 1: Make sure xrandr works fine

Check your screen's names by typing:

xrandr -q

Step 2: Expand your screen

Then disable one of them: (notice VGA-1 is the name of the screen, will differ, e.g. HDMI-1 if the screen is connected via HDMI)

@bxt
bxt / 1_working.rs
Last active December 13, 2022 18:32
Using a peekable iterator in a function in Rust
use std::iter::Peekable;
fn take_when_3(peeky: &mut Peekable<impl Iterator<Item = u8>>) -> Option<u8> {
if let Some(3) = peeky.peek() {
peeky.next()
} else {
None
}
}
@bxt
bxt / 0-recur.php
Created March 26, 2011 20:55
A sample recursive php function producing excessive stack (from Common PHP)
<?php
/*
I wanted to know if it pays off to refactor some recursive code, and
if or not PHP does tail call optimization and i found this post:
http://commonphp.blogspot.com/2010/12/tail-call-optimization-in-php-53.html
A good place to check how much faster an itarative solution would be.
I started with executing the functions.
Result: PHP does not do TCO.
*/
@bxt
bxt / setup_osx.md
Last active November 3, 2021 11:09
Setup macOS / OS X so that is does not suck quite that hard (living doc)

Setting up OS X macOS

Things to configure

  • Install latest software update
  • Enable touch ID
  • Make Dock hide and remove some silly apps (photobooth, ...) disable recently used apps
  • Finder:
@bxt
bxt / git-deletebranches.sh
Last active June 23, 2021 15:01
Git Delete Merged Branches
#!/bin/bash
MAIN=${1:-development}
BRANCHES=$(git branch --merged $MAIN | grep -v -e 'master\|staging\|development\|\*')
echo Branches merged into $MAIN:
echo $BRANCHES
read -p "Delete these branches (y/n)? " answer
@bxt
bxt / readme.txt
Created December 26, 2020 21:33
Anagramme
sport
prost
Bier-Tanke Antik-Rebe Eiter-Bank KI-beraten Bi-Raketen Bakterien Benkert-AI
@bxt
bxt / image.png
Last active December 26, 2020 17:33
Corona virus as an image
image.png