Skip to content

Instantly share code, notes, and snippets.

View derrandz's full-sized avatar
☝️

hrt/derrandz derrandz

☝️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am derrandz on github.
  • I am derrandz (https://keybase.io/derrandz) on keybase.
  • I have a public key ASCYR_2eQm232WZF83V--UAvQLiVP7bkAkLzrk2xu04bgQo

To claim this, I am signing this object:

package main
type (
Contextual interface {
GetContext() interface{}
SetContext() interface{}
}
Eventful interface {
Consume(reporting chan interface{}, msg interface{})
This post links my 3Box profile to my Github account! Web3 social profiles by 3Box.
✅ did:muport:QmUC5exZn4Q1DemvKeDFumWPWq5Pd3PKSLgTXQarGCcur2 ✅
Create your profile today to start building social connection and trust online at https://3Box.io/
@derrandz
derrandz / goreducerinterface.go
Created September 16, 2017 21:47
js reducer style in go, with interfaces
// a hack
package main
import "fmt"
type auto interface{}
type reduceClosure func(auto, auto, int, auto) auto
type Reducable interface{
@derrandz
derrandz / routes.js
Created September 16, 2017 19:27
Old snippet I used to play with when I had to route assets manually back then
var Path = require('path');
var express = require('express');
var router = express.Router();
function render(_fn, path, param, req, res, next) {
if (req.params[param]) {
res[_fn].call(res, Path.join(...[global.appRoot].concat(path(req.params[param]).split("/"))));
}else {
next();
}
@derrandz
derrandz / goreducer.go
Created September 16, 2017 19:21
Messing around with go and js style reducers
package main
import "fmt"
type reducer func(int, string, int, []string) int
func ReduceStringArr(arr []string, fn reducer, acc int) int {
for i, str := range arr {
acc = fn(acc, str, i, arr)
}
@derrandz
derrandz / event.js
Created January 2, 2017 12:50 — forked from wildlyinaccurate/event.js
Really simple Javascript custom event system
var Event = function() {
var self = this;
self.queue = {};
self.fired = [];
return {
fire: function(event) {
@derrandz
derrandz / divergence.py
Last active May 27, 2016 19:09
This is a class decorator for divergent classes, link to the definition of such term
"""
To understand what 'divergent' classes mean, please refer to the link: https://coderwall.com/p/hnaroq/divergent-classes-in-python
Nothing special, just I like to put fancy names on things from time to time ;)
Ofcourse, we can acheive the same thing using inheritence, but some of us design in a way that inheritence would not fit in,
This is the solution.
@derrandz
derrandz / dragon-comment.txt
Last active December 25, 2015 00:25
To use when you need to warn people from the dragon in the code
// .==. .==.
// //`^\\ //^`\\
// // ^ ^\(\__/)/^ ^^\\
// //^ ^^ ^/6 6\ ^^ ^ \\
// //^ ^^ ^/( .. )\^ ^ ^ \\
// // ^^ ^/\| v""v |/\^ ^ ^\\
// // ^^/\/ / `~~` \ \/\^ ^\\
// -----------------------------
/// HERE BE DRAGONS