Skip to content

Instantly share code, notes, and snippets.

View 4ndrej's full-sized avatar

Andrej 4ndrej

View GitHub Profile
@4ndrej
4ndrej / SSLPoke.java
Last active January 3, 2024 09:50
Test of java SSL / keystore / cert setup. Check the comment #1 for howto.
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
@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;

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
@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 / 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 / decrypt-remmina.sh
Created February 9, 2018 15:54
remmina decrypt oneliner
# this works only as oneliner
# stolen from comments to https://askubuntu.com/a/379545/123435
python -c "import base64,sys;from Crypto.Cipher import DES3;pc=open('/home/andrej/.config/remmina/remmina.pref').read();pci=pc.index('secret=');secret=pc[pci:pc.index('\n',pci)].split('=',1)[1];cc=open(sys.argv[1]).read();cci=cc.index('password');password=cc[cci:cc.index('\n',cci)].split('=',1)[1];secret,password=base64.decodestring(secret),base64.decodestring(password); print DES3.new(secret[:24], DES3.MODE_CBC, secret[24:]).decrypt(password)" 1486132120333.remmina
# remmina config is at ~/.config/remmina/remmina.pref
# config files are at ~/.local/share/remmina/
@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