Skip to content

Instantly share code, notes, and snippets.

View aheissenberger's full-sized avatar

Andreas Heissenberger aheissenberger

View GitHub Profile
@aheissenberger
aheissenberger / html-table-resposive
Created February 18, 2015 19:27
HTML Table responsive - flip Tableheader to first column
<style>
@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;
}
@aheissenberger
aheissenberger / ziptotar.sh
Created June 26, 2017 10:06
Convert a zip to a bzip2 compressed tar (.tbz)
#!/bin/bash
# Usage: ziptotar.sh <ZIP name>
if [ -z $1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ];then
echo "Convert a zip to a bzip2 compressed tar (.tbz)"
echo "ziptotar.sh <ZIP name>"
exit
fi
for file in "$@"
do
if [ ! -f "$file" ];then
@aheissenberger
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
aheissenberger / awsCredentialHelperOSX.sh
Created May 4, 2019 14:43
Wrapper for AWS CodeCommit git credential helper to fix problem with MacOS keystore
#!/bin/bash
# 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
aws_profile="$1"
shift
# 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
aheissenberger / polyfill-loader.html
Created September 15, 2019 14:32
Insert Script Tag to load polyfill
<script>
if (featureText()) {
document.currentScript.insertAdjacentHTML(
"afterend",`
<script src="/polyfill.js" ><\/script>
`); // closing tag needs to use an escaped backslash
}
</script>
@aheissenberger
aheissenberger / getnote.sh
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
aheissenberger / add2keychain.sh
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
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
aheissenberger / create-patch.sh
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
#/bin/bash
#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"
exit
fi
@aheissenberger
aheissenberger / timemachine.sh
Last active October 26, 2024 19:56
Exclude package folder e.g. node_modules from being backuped by MacOS Time Machine
#!/bin/sh
#set -x
EXCLUDEFOLDERNAME=${3:-"node_modules"}
get_realpath ()
{
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
}
SEARCHPATH="$(get_realpath ${2:-"${HOME}"})"