Skip to content

Instantly share code, notes, and snippets.

View ferdinandurban's full-sized avatar

Ferdinand Urban ferdinandurban

  • Brno, Czech Republic
View GitHub Profile
@ferdinandurban
ferdinandurban / client.py
Created January 27, 2022 16:04
wss client
#
# for self signed certificate
# openssl req -x509 -nodes -new -sha256 -days 1024 -newkey rsa:2048 -keyout key.pem -out cert.pem -subj "/C=US/CN=localhost"
# cat key.pem cert.pem > key_cert.pem
#
import asyncio
import pathlib
import ssl
import websockets
@ferdinandurban
ferdinandurban / server.py
Last active January 27, 2022 16:03
WSS server
#
# to create self signed certificate:
# openssl req -x509 -nodes -new -sha256 -days 1024 -newkey rsa:2048 -keyout key.pem -out cert.pem -subj "/C=US/CN=localhost"
# cat key.pem cert.pem > key_cert.pem
#
import asyncio
import pathlib
import ssl
@ferdinandurban
ferdinandurban / FULogger.swift
Created February 24, 2016 21:09
swift logger
public class FULogger {
public class func debug(message:String? = nil, function: String = __FUNCTION__, file: String = __FILE__, line: Int = __LINE__) {
#if DEBUG
if let message = message {
print("\(file):\(function):\(line): \(message)")
} else {
print("\(file):\(function):\(line)")
}
#endif
}
@ferdinandurban
ferdinandurban / gitbranch_in_cli
Created April 1, 2014 09:31
show git branch name in command line
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
PS1="$GREEN\u@\h$NO_COLOR:\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "
@ferdinandurban
ferdinandurban / base64
Last active January 13, 2026 21:49
Base63 encoder/decoder
#include <iostream>
#include <string>
#include <sstream>
const unsigned char lookupTable[65] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
const unsigned char lookdownTable[256] = {