Skip to content

Instantly share code, notes, and snippets.

View 4ndrej's full-sized avatar

Andrej 4ndrej

View GitHub Profile
@4ndrej
4ndrej / thestoryofus.sh
Created February 22, 2023 07:47 — forked from dirkjanfaber/thestoryofus.sh
Download the story of us as epub (waitbutwhy)
#/bin/bash
dir=$(mktemp --directory)
declare -a input=()
cat <<__EOT__ > ${dir}/metadata.txt
---
title: The Story of Us
author: Tim Urban
rights: Creative Commons Non-Commercial Share Alike 3.0
@4ndrej
4ndrej / ford-m.js
Created January 31, 2023 16:02
ford radio code generator
// radio code generator for ford radio with serial starting with "M"
// stolen from https://github.com/OlegSmelov/ford-radio-codes
// get the radio serial by holding 1+6 while powering radio on
'use strict';
function generateSerial(serial) {
const lookup = [
[9, 5, 3, 4, 8, 7, 2, 6, 1, 0],
[2, 1, 5, 6, 9, 3, 7, 0, 4, 8],
@4ndrej
4ndrej / certbot-authhook-az-cli-annotated.sh
Created September 1, 2020 23:28 — forked from colindekker/certbot-authhook-az-cli-annotated.sh
CertBot manual auth hook for Azure DNS using Azure CLI
#!/bin/bash
# The hook supports 2 actions, 'create' and 'delete', passed as the first argument.
# When 'create' is passed in, a validation TXT record is added,
# 'delete' cleans up that record after validation
ACTION=$1
# The second the name of the Azure Account that contains the DNS Zone Resource
AZ_ACCOUNT=$2
echo $AZ_ACCOUNT
# set the name of the Azure Resource Group that contains the DNS Zone Resource
@4ndrej
4ndrej / nginx.conf
Created August 14, 2020 13:51
nginx yyyy-mm logging without if
http {
#access_log logs/access.log main;
# parse \d{4}-\d{2} from $time_iso8601 into $yyyy_mm
map $time_iso8601 $yyyy_mm {
"~^(?<temp>\d{4}-\d{2})" $temp;
}
server {
listen 80;
@4ndrej
4ndrej / Test.java
Created October 14, 2019 20:56 — forked from nogweii/Test.java
A quick test to see if you have the JCE Unlimited Strength Jurisdiction Policy files installed. If you don't, in Java 6 you'll see 128. If you do, you'll see 2147483647. Thanks to http://stackoverflow.com/questions/11538746/check-for-jce-unlimited-strength-jurisdiction-policy-files
import javax.crypto.Cipher;
class Test {
public static void main(String[] args) {
try {
System.out.println("Hello World!");
int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
System.out.println(maxKeyLen);
} catch (Exception e){
System.out.println("Sad world :(");
@4ndrej
4ndrej / gist:6d58f2e9a77e1aa2581d21e39b4411d9
Created November 14, 2018 09:34
sublimetext ebook merge paragraphs regexp pattern
sublimetext ebook merge paragraphs regexp pattern
search pattern:
(\n\n)([\w])
replace pattern:
\2
before:
„Elfové a draci, řek jsem svýmu klukovi, zelí a brambory jsou pro nás
@4ndrej
4ndrej / xva2raw.sh
Created October 1, 2018 14:22
stitch xva's Ref/* files into raw image
#!/bin/bash
# stolen from now defunct http://wiki.sysconfig.org.uk/display/howto/Convert+Citrix+XenServer+images+to+plain+Xen
#
# To summarize the .xva format:
# - it's a tar file
# - it contains a folder
# - the folder contains chunks of 1MB each
# - they can be concatenated, but blank space needs to be filled
dd if=/dev/zero of=blank bs=1024 count=1k
@4ndrej
4ndrej / bashrc.sh
Last active June 6, 2018 11:59
bashrc git status
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
echo ""
fi
@4ndrej
4ndrej / detect.js
Created April 27, 2018 10:05
detect mobile device using javascript
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
@4ndrej
4ndrej / pfx2cer-key.sh
Last active March 22, 2018 17:56
pfx to key/cer chain
# convert from pfx to passwordless key/crt chain
# based on https://gist.github.com/ericharth/8334664
# params
PFX="hostname.pfx"
PASSWORD="pfxpassword"
OUT="hostname-2018"
# key
openssl pkcs12 -in $PFX -password pass:$PASSWORD -nodes -nocerts -out $OUT.key