Skip to content

Instantly share code, notes, and snippets.

View kadko's full-sized avatar
🍀
On vacation

kadko

🍀
On vacation
View GitHub Profile
@kadko
kadko / pubsub-simple.js
Created September 6, 2018 01:55 — forked from fatihacet/pubsub-simple.js
Simple PubSub implementation with JavaScript - taken from Addy Osmani's design patterns book -
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,
@kadko
kadko / ComputeHmac256.go
Created March 3, 2020 04:40 — forked from byrnedo/ComputeHmac256.go
Compute a hmac for a message in golang
func ComputeHmac256(message string, secret string) string {
key := []byte(secret)
h := hmac.New(sha256.New, key)
h.Write([]byte(message))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
@kadko
kadko / observable-pattern-pizza.js
Created September 6, 2020 20:22 — forked from boxgames1/observable-pattern-pizza.js
Observable pattern - Pizza Maker
const EventEmitter = require("events").EventEmitter;
class Pizza extends EventEmitter {
constructor(size = 1) {
super();
this.ovenTime = this._ovenTime(size);
this.maxIngredients = this._maxIngredients(size);
this.ingredients = [];
this.timeToReleasePizza = 5;
}