Skip to content

Instantly share code, notes, and snippets.

View Khoulaiz's full-sized avatar
🏠
Working from home

Andreas Sahlbach Khoulaiz

🏠
Working from home
View GitHub Profile
@Khoulaiz
Khoulaiz / main.go
Created June 12, 2023 13:31
JSON marshalling with dynamic omitempty setting
package main
import (
"encoding/json"
"fmt"
)
type Nullable[T any] struct {
val *T
}
@Khoulaiz
Khoulaiz / turn-off-window-reopening-macosx.sh
Last active January 16, 2023 08:44
Turn off annoying window reopening in macosx after reboot (persistent)
# create a clean reboot without the windows you don't want to have
# by rebooting your mac (uncheck the reopen windows checkbox in the reboot dialog
# take over this file
sudo chown root ~/Library/Preferences/ByHost/com.apple.loginwindow*
# and prevent further changes (checkbox in reboot dialog doesn't matter)
sudo chmod 000 ~/Library/Preferences/ByHost/com.apple.loginwindow*
# to undo it, simply delete the file. It will be recreated automatically
@Khoulaiz
Khoulaiz / init.el
Created September 7, 2022 14:03
Emacs Org-Mode: Inserts a timestamp into an exported org-file for the time of the export. Original org-file is untouched.
;; in your init.el
(defun ace/org-export-insert-export-date(&optional backend)
"Searches for %%DATE_EXPORTED%% in the buffer and replaces all occurrences
Just put the keyword somewhere in your org buffer and the time stamp of the
export is inserted in the exported buffer. The original buffer is untouched."
(goto-char (point-min))
(while (search-forward "%%DATE_EXPORTED%%" nil t)
(replace-match (format-time-string "%0e.%0m.%Y %R"))))
@Khoulaiz
Khoulaiz / gist:a19c04f8b95415ff5de3177ae214b382
Created September 27, 2021 13:38
create an alias for a colorful git changelog with `git lg`
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@Khoulaiz
Khoulaiz / uncolor
Created September 27, 2021 13:35
Removes ansi stuff from a text
#!/usr/bin/env perl
## uncolor — remove terminal escape sequences such as color changes
while (<>) {
s/ \e[ #%()*+\-.\/]. |
\e\[ [ -?]* [@-~] | # CSI ... Cmd
\e\] .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL)
\e[P^_] .*? (?:\e\\|\x9c) | # (DCS|PM|APC) ... ST
\e. //xg;
print;
}
// ==UserScript==
// @name Amazon Prevent language switch away from German
// @description Some amazon urls will change your language settings. Only use german versions
// @namespace https://sahlbach.com/misc/greasemonkey/
// @match https://*.amazon.de/-/*/dp/*
// @exclude https://*.amazon.de/-/de/dp/*
// @run-at document-start
// @version 1
// @grant none
// @icon https://www.amazon.com/favicon.ico
@Khoulaiz
Khoulaiz / opensslcmds.md
Last active February 22, 2022 09:13
Common Open SSL Commands

OpenSSL Commands

General Commands

These commands allow you to generate CSRs, Certificates, Private Keys and do other miscellaneous tasks.

Generate a new private key and Certificate Signing Request

openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key
@Khoulaiz
Khoulaiz / spacemacs-cheatsheet.md
Created August 22, 2017 11:17 — forked from davoclavo/spacemacs-cheatsheet.md
Spacemacs cheatsheet

emacs --daemon to run in the background. emacsclient.emacs24 <filename/dirname> to open in terminal

NOTE: "M-m and SPC can be used interchangeably".

  • Undo - C-/
  • Redo - C-?
  • Change case: 1. Camel Case : M-c 2. Upper Case : M-u
  1. Lower Case : M-l
@Khoulaiz
Khoulaiz / ec
Last active May 16, 2017 20:56 — forked from tasmo/ec
Start Emacs Client in GUI (and launch Emacs server if not already running)
#!/usr/bin/env bash
# Shamelessly taken from http://mjwall.com/blog/2013/10/04/how-i-use-emacs/
# This script starts emacs daemon if it is not running, opens whatever file
# you pass in and changes the focus to emacs. Without any arguments, it just
# opens the current buffer or *scratch* if nothing else is open. The following
# example will open ~/.bashrc
# ec ~/.bashrc
@Khoulaiz
Khoulaiz / .profile
Created May 16, 2017 20:54 — forked from tasmo/.profile
snipped for ediff with emacsclient for POSIX shells
### editor
export ALTERNATE_EDITOR=emacs
export EDITOR="emacsclient -tc -a emacs"
export VISUAL="emacsclient -c -a emacs"
# emacsclient as difftool
function ediff () {
if [ "X${2}" = "X" ]; then
echo "USAGE: ediff <FILE 1> <FILE 2>"
else
quoted1=${1//\\/\\\\}; quoted1=${quoted1//\"/\\\"}