Skip to content

Instantly share code, notes, and snippets.

@korya
korya / service-registry-example.go
Last active December 15, 2016 17:28
An example demonstrating basic service registry implemented in Go
// Go play example: https://play.golang.org/p/5eoIRYy5Bn
package main
import (
"fmt"
"reflect"
)
type Policy interface {
IsAllowed() bool

This is my response to an email asking about Domain-Driven Design in golang project.

Thank you for getting in touch. Below you will find my thoughts on how golang works with DDD, changing it. This is merely a perception of how things worked out for us in a single project.

That project has a relatively well-known domain. My colleagues on this project are very knowledgeable, thoughtful and invested in quality design. The story spelled out below is a result of countless hours spent discussing and refining the approach.

Conclusions could be very different, if there was a different project, team or a story-teller.

Short story

@korya
korya / cmds.sh
Created October 19, 2016 19:47
S3: read latest version of removed object
getLatestVersion() {
local path="$1"
aws s3api list-object-versions --output json --bucket iguides.plntr.ca --prefix "$path" | jq '.Versions[0].VersionId' -r
}
filename=[remove-file-name]
path="ig8OKNNO6IIPDD1/gallery/${filename}"
versionId="$(getLatestVersion "$path")"
echo "filename: $filename"
@korya
korya / README.md
Last active August 23, 2016 13:11
CSS 3-state checkbox

sci-hub.io is down. Use the IP address directly:

# echo '31.184.194.81 sci-hub.io' >> /etc/hosts
# echo '31.184.194.81 sci-hub.org' >> /etc/hosts
# echo '31.184.194.81 sci-hub.club' >> /etc/hosts

Alternative option: scihub22266oqcxt.onion

@korya
korya / Reflows.md
Created April 11, 2016 20:59
Browser rendering: reflows, repaints...

Functions flushing browser's "reflow" queue:

  • offsetTop, offsetLeft, offsetWidth, offsetHeight
  • scrollTop/Left/Width/Height
  • clientTop/Left/Width/Height
  • getComputedStyle(), or currentStyle in IE

All of these above are essentially requesting style information about a node, and any time you do it, the browser has to give you the most up-to-date value. In order to do so, it needs to apply all scheduled changes, flush the queue, bite the bullet and do the reflow.

@korya
korya / handler.js
Created April 11, 2016 12:45 — forked from ThisIsMissEm/handler.js
The better way to execute Go on Amazon Lambda (see: http://blog.0x82.com/2014/11/24/aws-lambda-functions-in-go/)
var child_process = require('child_process');
exports.handler = function(event, context) {
var proc = spawn('./test', [ JSON.stringify(event) ], { stdio: 'inherit' });
proc.on('close', function(code){
if(code !== 0) {
return context.done(new Error("Process exited with non-zero status code"));
}
@korya
korya / transform.js
Created March 11, 2016 14:45
CSS3 transform matrix in JS
// Based on https://github.com/enepomnyaschih/jwcanvas/blob/master/jwidget/public/jwcanvas/transform.js
class Transform {
constructor() {
// / a c e \
// | b d f | => [a, b, c, d, e, f]
// \ 0 0 1 /
this.matrix = [1, 0, 0, 1, 0, 0];
}
@korya
korya / bithacks.html
Created February 16, 2016 18:30
Bit Hacks
<html>
<head>
<title>
Bit Twiddling Hacks
</title>
</head>
<body>
@korya
korya / bug-in-design-zayin-in-debug.md
Created February 11, 2016 17:16
Bug in design, zayin in debug (explanation)

"Bug ba-design, zayin ba-debug" (Hebrew: באג בדיזיין, זין בדיבאג)

I feel sorry for the majority here - non-Israelis who can't get this joke - because it's truly one of the funniest things I've heard in a while. It is a clever play on words, even though it mixes English and Hebrew and isn't all that grammatically correct (it's not even a complete sentence). Remarkably, it is a fact of life as well.

The word zayin (slang for "dick" in Hebrew, pronounced similarly to "sign" in "design") has some of the connotations the word shit has in English. The phrase, therefore, can be translated as "A bug in the design (is) shit in the debugging" or "A bug in the design (is) shit to debug". Another way to interpret this usage of "zayin" is as a shorthand for "lekabel zayin" (lit. "to get dick" - to get screwed; carries very rude connotations), and then a loose translation could be "If there's a bug in the design, you get screwed when you debug".

The original writeup above (which is no longer with us) said this was a com