Skip to content

Instantly share code, notes, and snippets.

View tauzen's full-sized avatar

Krzysztof Mioduszewski tauzen

View GitHub Profile
@tauzen
tauzen / barber.clj
Created July 27, 2019 18:57
7 languages in 7 weeks, Clojure day 3, sleeping barber
(def cut-count (atom 0))
(def client-count (atom 0))
(def cutting (atom false))
(def client-approaching (atom false))
(def client-queue (atom []))
(defn cut [client-id]
(reset! cutting true)
(future
@tauzen
tauzen / money.py
Last active May 5, 2024 17:23
Python DDD - Value Object idea. Immutable attributes, methods, structural equality.
from collections import namedtuple
class Money(namedtuple('Money', ['amount', 'currency'])):
def add(self, amount):
return Money(self.amount + amount, self.currency)
m = Money(20, 'USD')
print(m)
# Money(amount=20, currency='USD')
@tauzen
tauzen / keybase.md
Created July 30, 2016 20:56
keybase.md

Keybase proof

I hereby claim:

  • I am tauzen on github.
  • I am tauzen (https://keybase.io/tauzen) on keybase.
  • I have a public key whose fingerprint is 6F3E 6BAF 57AD 3CE1 97B1 FE0B C429 5266 1A58 88BD

To claim this, I am signing this object:

@tauzen
tauzen / openssl
Last active March 26, 2017 20:44
openssl keys and cert generation, signed digest generation, verification of signed digest
# Creating a RSA private key
$ openssl genrsa -out rsaprivkey.pem 1024
# Creating a cert file from priv key
$ openssl req -new -x509 -key rsaprivkey.pem -out rsacert.pem
# Converting from PEM to DER
$ openssl x509 -outform der -in rsacert.pem -out rsacert.der
# Convertin from DER to PEM
@tauzen
tauzen / joinUint8Arrays.js
Created October 28, 2014 12:06
Joins multiple Uint8Arrays (or regular Arrays) passed as arguments into one combined Uint8Array.
function joinUint8Arrays() {
var args = Array.prototype.slice.call(arguments);
var length = args.reduce(function(a, b) { return a + b.length; }, 0);
var out = new Uint8Array(length);
args.reduce(function(previousLen, buffer) {
out.set(buffer, previousLen);
return previousLen + buffer.length;
}, 0);
@tauzen
tauzen / hexstring.js
Last active September 9, 2024 18:13
Hex string to byte and other way round conversion functions.
function byteToHexString(uint8arr) {
if (!uint8arr) {
return '';
}
var hexStr = '';
for (var i = 0; i < uint8arr.length; i++) {
var hex = (uint8arr[i] & 0xff).toString(16);
hex = (hex.length === 1) ? '0' + hex : hex;
hexStr += hex;
@tauzen
tauzen / app.js
Last active August 29, 2015 14:07
FirefoxOS tag writing example, requires NFC capable device running FirefoxOS 2.1. App needs to be certified! Privileged APIs comming soon!
window.addEventListener('DOMContentLoaded', function() {
'use strict';
console.log('DOMContentLoaded, checking for NFC');
if (!navigator.mozNfc) {
console.log('NFC not available');
return;
}
navigator.mozSetMessageHandler('activity', (activity) => {
@tauzen
tauzen / debug_all.sh
Last active August 29, 2015 14:05
Setting NFC debug_all = true without gecko rebuild
$ adb remount
$ adb pull /system/b2g/omni.ja
$ unzip omni.ja -d Omni
$ sed -i 's/this.DEBUG_ALL = false;/this.DEBUG_ALL = true;/g' Omni/modules/nfc_consts.js
$ cd Omni
$ zip -r omni.ja *
$ adb push omni.ja /system/b2g
$ adb reboot
@tauzen
tauzen / acl.conf.xml
Created March 29, 2014 11:24
Domains ACL definition in freeswitch/conf/autoload_configs/acl.conf.xml with static gw address.
<list name="domains" default="deny">
<node type="allow" domain="$${domain}"/>
<node type="allow" cidr="192.168.0.2/32"/>
</list>
@tauzen
tauzen / default.xml
Created March 29, 2014 10:45
Freeswitch demo ivr definition in freeswitch/conf/dialplan/default.xml
<extension name="ivr_demo">
<condition field="destination_number" expression="^5000$">
<action application="answer"/>
<action application="sleep" data="2000"/>
<action application="ivr" data="demo_ivr"/>
</condition>
</extension>