Skip to content

Instantly share code, notes, and snippets.

View aheissenberger's full-sized avatar

Andreas Heissenberger aheissenberger

View GitHub Profile
aheissenberger /
Last active September 30, 2023 10:19
Exclude package folder e.g. node_modules from being backuped by MacOS Time Machine
#set -x
get_realpath ()
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
SEARCHPATH="$(get_realpath ${2:-"${HOME}"})"
aheissenberger /
Last active October 5, 2022 13:13
patch creation with diff from files where a copy of the file with the extension ".old" exists, there is a patch file per found file
#set -x
APP_NAME=$(basename -- "$0")
if [ -z "$1" ]; then
echo -e "\n$APP_NAME [base dir (Default:.)] [base search dir (Default:".")] [search glob (Default:**/*.php.old)] [patches dir (Default:patches]"
echo -e "\tThe base search and patches dir are relative to basedir!"
echo -e "\tExpample: $APP_NAME: wordpress web/wp patches"
aheissenberger / localeDateTimeString.js
Last active February 18, 2021 15:16
locale time Date time string for file names
new Date().toLocaleString( 'sv', { timeZoneName: 'short' } ).replace(/(-|:| )/g,'').substr(0,12)
// uses 'sv' for Sweden as they use something similar to ISO format
aheissenberger /
Created September 23, 2019 19:43
Mac OS / add text file to key chain as Note
security add-generic-password -a $USER -s name-of-the-note -C note -w "$(cat file-to-include)"
aheissenberger /
Created September 23, 2019 19:49
Mac OS / retrieve key chain note
security find-generic-password -a $USER -C note -s name-of-a-note -w | xxd -r -p -
# when input includes new lines - content is returned as hex and needs to be converted with "xxd"
aheissenberger / polyfill-loader.html
Created September 15, 2019 14:32
Insert Script Tag to load polyfill
if (featureText()) {
<script src="/polyfill.js" ><\/script>
`); // closing tag needs to use an escaped backslash
aheissenberger /
Created May 4, 2019 14:43
Wrapper for AWS CodeCommit git credential helper to fix problem with MacOS keystore
# SETUP: add to local git config:
# git config --local credential.helper '!~/bin/awsCredentialHelperOSX AWS_PROFILE'
# replace AWS_PROFILE with the relevant profile name, replace "~/bin/" with path to this file
# get aws_access_key_id for aws_profile
aws_access_key_id=$(sed -n '/^[ \t]*\[${aws_profile}\]/,/\[/s/^[ \t]*aws_access_key_id[ \t]*=[ \t]*//p' ~/.aws/credentials)
security -q delete-internet-password -a "${aws_access_key_id}" >/dev/null 2>&1
/usr/local/bin/aws --profile "${aws_profile}" codecommit credential-helper $@
aheissenberger / create-wallet.js
Created March 2, 2019 09:25
create a wallet address (ethereum)
const crypto = require("crypto");
var ethUtils = require("ethereumjs-util");
var getRandomWallet = function() {
var randbytes = crypto.randomBytes(32);
var address = "0x" + ethUtils.privateToAddress(randbytes).toString("hex");
return { address: address, privKey: randbytes.toString("hex") };
aheissenberger /
Created June 26, 2017 10:06
Convert a zip to a bzip2 compressed tar (.tbz)
# Usage: <ZIP name>
if [ -z $1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ];then
echo "Convert a zip to a bzip2 compressed tar (.tbz)"
echo " <ZIP name>"
for file in "$@"
if [ ! -f "$file" ];then
aheissenberger / html-table-resposive
Created February 18, 2015 19:27
HTML Table responsive - flip Tableheader to first column
@media screen and (max-width: 600px) {
table.responsive caption { background-image: none; }
table.responsive thead { display: none; }
table.responsive tbody td { display: block; padding: .6rem; }
table.responsive tbody tr td:first-child { background: #333; color: #fff; }
table.responsive tbody td:before {
content: attr(data-th); font-weight: bold;
display: inline-block; width: 6rem;