Skip to content

Instantly share code, notes, and snippets.

Krzysztof Mioduszewski tauzen

Block or report user

Report or block tauzen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tauzen
tauzen / barber.clj
Created Jul 27, 2019
7 languages in 7 weeks, Clojure day 3, sleeping barber
View barber.clj
(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 Mar 28, 2017
Python DDD - Value Object idea. Immutable attributes, methods, structural equality.
View money.py
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')
View 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 Mar 26, 2017
openssl keys and cert generation, signed digest generation, verification of signed digest
View openssl
# 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 Oct 28, 2014
Joins multiple Uint8Arrays (or regular Arrays) passed as arguments into one combined Uint8Array.
View joinUint8Arrays.js
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 Sep 5, 2019
Hex string to byte and other way round conversion functions.
View hexstring.js
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 Aug 29, 2015
FirefoxOS tag writing example, requires NFC capable device running FirefoxOS 2.1. App needs to be certified! Privileged APIs comming soon!
View app.js
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 Aug 29, 2015
Setting NFC debug_all = true without gecko rebuild
View debug_all.sh
$ 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 Mar 29, 2014
Domains ACL definition in freeswitch/conf/autoload_configs/acl.conf.xml with static gw address.
View acl.conf.xml
<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 Mar 29, 2014
Freeswitch demo ivr definition in freeswitch/conf/dialplan/default.xml
View 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>
You can’t perform that action at this time.