Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Heissenberger aheissenberger

View GitHub Profile
@aheissenberger
aheissenberger / html-table-resposive
Created Feb 18, 2015
HTML Table responsive - flip Tableheader to first column
View html-table-resposive
<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 Jun 26, 2017
Convert a zip to a bzip2 compressed tar (.tbz)
View ziptotar.sh
#!/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 Mar 2, 2019
create a wallet address (ethereum)
View create-wallet.js
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
Wrapper for AWS CodeCommit git credential helper to fix problem with MacOS keystore
View awsCredentialHelperOSX.sh
#!/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 Sep 15, 2019
Insert Script Tag to load polyfill
View polyfill-loader.html
<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 Sep 23, 2019
Mac OS / retrieve key chain note
View getnote.sh
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 Sep 23, 2019
Mac OS / add text file to key chain as Note
View add2keychain.sh
security add-generic-password -a $USER -s name-of-the-note -C note -w "$(cat file-to-include)"
@aheissenberger
aheissenberger / localeDateTimeString.js
Last active Feb 18, 2021
locale time Date time string for file names
View localeDateTimeString.js
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 / timemachine.sh
Last active Sep 8, 2022
Exclude package folder e.g. node_modules from being backuped by MacOS Time Machine
View timemachine.sh
#!/bin/sh
#set -x
EXCLUDEFOLDERNAME=${3:-"node_modules"}
get_realpath ()
{
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
}
SEARCHPATH="$(get_realpath ${2:-"${HOME}"})"