Skip to content

Instantly share code, notes, and snippets.

View menxit's full-sized avatar

Federico Ginosa menxit

View GitHub Profile
@menxit
menxit / ProducersConsumers.scala
Last active November 8, 2017 11:05
Dijkstra Semaphore in Scala
object ProducersConsumers {
val N = 5
val NUMBER_OF_PRODUCERS = 10
val NUMBER_OF_CONSUMERS = 2
val PIENE = new Semaphore(0)
val VUOTE = new Semaphore(N)
0xD0D4a30F89f9dd7353694059aA949fC7170B9CCd

Keybase proof

I hereby claim:

  • I am menxit on github.
  • I am menxit (https://keybase.io/menxit) on keybase.
  • I have a public key ASCiu15L-4v-q_-P_b2LDGT4wZNOYAmbK9HWvTCTFN_w5wo

To claim this, I am signing this object:

@menxit
menxit / .spacemacs
Created April 6, 2018 21:12
.spacemacs
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@menxit
menxit / Docker_UFW_IPTABLES.md
Last active November 2, 2020 08:20
Docker UFW and iptables
  1. Disable iptables
$ sudo vim /etc/docker/daemon.json
{
  "iptables": false
}
const https = require('https')
const haversine = (a, b) => {
const R = 6373044
const { cos, sin, sqrt, PI, asin } = Math
const toRad = x => x * PI / 180
const dLat = toRad(a.lat - a.lon)
const dLon = toRad(b.lat - b.lon)
;; ido-mode
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
;; helm configuration
(use-package helm
:ensure t
:bind
("M-x" . helm-M-x)
;; ido-mode
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
;; helm configuration
(use-package helm
:ensure t
:bind
("M-x" . helm-M-x)
const test = (name, foo, measures = [10, 100, 1000, 10000, 100000, 1000000]) => {
console.log(name);
measures.forEach(async n => {
const start = new Date();
await Promise.all(new Array(n).fill(1).map(() => foo));
const end = new Date();
const time = end.getTime() - start.getTime();
console.log(`${n} requests`);
console.log(` Total time: ${time/1000} s`);
console.log(` Average time: ${time/n} ms`);
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}