Skip to content

Instantly share code, notes, and snippets.

@kaskavalci
kaskavalci / keybase.sh
Last active February 1, 2021 13:24
How to import / export PGP keys with keybase
# Import local keys to keybase
keybase pgp select --import --multi
# Export keybase keys to local GPG
keybase pgp export --secret | gpg --allow-secret-key --import
#!/bin/bash
# Author: kdecherf
# This script is copied directly from https://kdecherf.com/blog/2015/04/10/show-the-certificate-chain-of-a-local-x509-file/
# License: CC BY-NC-SA 3.0
# https://creativecommons.org/licenses/by-nc-sa/3.0/
chain_pem="${1}"
if [[ ! -f "${chain_pem}" ]]; then
echo "Usage: $0 BASE64_CERTIFICATE_CHAIN_FILE" >&2
@kaskavalci
kaskavalci / unique-strings.go
Created July 19, 2018 15:15
Remove duplicates from a string array in go
func unique(tokens *[]string) {
v := reflect.ValueOf(tokens).Elem()
if v.Len() <= 1 {
return
}
sort.Strings(*tokens)
i := 0
for j := 1; j < v.Len(); j++ {
if (*tokens)[i] == (*tokens)[j] {
@kaskavalci
kaskavalci / download.js
Created March 15, 2018 09:29
humble bundle download all
// Execute this from browser console
// Tested on Chrome. Firefox does not work. Even pop-up blocker is disabled it still blocks opening new windows.
// Things to do:
// Enable option Download PDF files instead of automatically opening them in Chrome in chrome
// Allow popups
Array.from(document.querySelectorAll('a')).filter(a => a.hostname.startsWith('dl.')).map((v)=>{v.setAttribute('target','_blank'); v.classList.remove('a'); return v}).forEach(v=>{window.open(v.href,'_blank'); console.log(v.href)})

Keybase proof

I hereby claim:

  • I am kaskavalci on github.
  • I am kaskavalci (https://keybase.io/kaskavalci) on keybase.
  • I have a public key whose fingerprint is E6F2 56B2 165E 1C63 2120 D327 1A9E 56C5 C682 88F3

To claim this, I am signing this object:

@kaskavalci
kaskavalci / pre-commit.bash
Created January 25, 2018 15:35
pre-commit hook for sqlinter
if [[ ! $(which gem) ]]; then
echo "You don't have gem installed. Go install it."
exit 1
fi
if [[ ! $(which sqlint) ]]; then
gem install sqlint
fi
git diff --cached --name-status | xargs -0 | while read st file; do
@kaskavalci
kaskavalci / untar-dir.sh
Created September 15, 2017 06:36
Untar all files in a directory to unique directories
# Change file extension if needed
for f in *.tgz ; do mkdir "${f%%.*}" && tar xzf $f -C "${f%%.*}" ; done
�ò���l�$X������`�@��!4I4ԡ7�,�2�
~1�~�GET /v1/agent/services HTTP/1.1
Host: localhost:8500
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
l�$X �hh��`2@!4��7�,I4��u:
~1�~1�HTTP/1.1 200 OK
Content-Type: application/json
Date: Thu, 10 Nov 2016 18:46:04 GMT
##
##You better change these:
##
git config --global user.name "Name Surname?"
git config --global user.email "[email protected]"
##
##Paste as it is
##
git config --global alias.s "status -suno"
git config --global alias.l "log --oneline --decorate"
Runnable runner = new Runnable() {
@Override
public void run() {
File index = new File(getMyURL());
if (index.exists()) {
browser.setUrl(getMyURL());
}
browser.refresh();
}
}