Skip to content

Instantly share code, notes, and snippets.

Massimo Ronca wstucco

Block or report user

Report or block wstucco

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View wait_for_processes.ex
defmodule App do
def bench do
:timer.tc(fn -> start() end)
end
defp start do
run()
wait()
end
View apply_after_vs_send_after.ex
defmodule A do
use GenServer
def start do
GenServer.start_link(__MODULE__, [])
end
def send_after(pid) do
1..10
|> Enum.each(fn _ -> Process.send_after(pid, :message, 1_000) end)
@wstucco
wstucco / one_million_processes.exs
Last active Sep 27, 2017
One million threads VS one million Erlang processes
View one_million_processes.exs
defmodule Processes do
@compile :native
def create_and_forget do
1..1_000_000
|> Enum.each(fn x ->
Task.async(fn -> x + 1 end) |> Task.await
end)
IO.puts("Maximum number of threads per process is = 1000000")
@wstucco
wstucco / find_similar_ip.ex
Last active Jul 21, 2017
most similar ip Elixir
View find_similar_ip.ex
{:ok, ips} = :inet.getif()
ips
|> Enum.map(fn {ip, _broadaddr, _mask} -> ip |> Tuple.to_list |> Enum.map_join(".", &to_string/1) end)
|> Enum.map(fn ip -> {ip, String.jaro_distance(ip, "192.168.99.100")} end)
|> Enum.sort(fn {_, score1}, {_, score2} -> score1 > score2 end)
|> List.first
|> elem(0)
@wstucco
wstucco / build.sh
Last active Oct 12, 2015
Writing Ruby Extensions in go
View build.sh
go build -buildmode=c-shared -o hello.so hello.go
# if no error is returned you can check that the shared library is exporting
# the right symbols by executing
# $ nm -gU ./hello.so | grep hello
# 0000000000002050 T __cgoexp_d4a435ec6890_hello_world
# 0000000000001ae0 T _hello_world <--- ALL SYSTEMS ARE GO
View keybase.md

Keybase proof

I hereby claim:

  • I am wstucco on github.
  • I am massimo (https://keybase.io/massimo) on keybase.
  • I have a public key whose fingerprint is 4538 9292 4496 E67A 6CE2 BF39 5D2C 6772 9E02 C529

To claim this, I am signing this object:

@wstucco
wstucco / main.rb
Last active May 28, 2019
Opal Meteor
View main.rb
if Meteor.client?
user = User.new('Admin')
puts user
puts user.admin?
puts "hello from client #{user.name}!"
end
if Meteor.server?
user = User.new('Massimo')
puts user
View vector_realloc.cpp
/*
* Copyright (C) 2012, Tino Didriksen Consult
* Developed by Tino Didriksen <tino@didriksen.cc>
* Modified by Massimo Ronca
*
* This file is part of Benchmarks
*
* Benchmarks is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
View app.json
{
"env": "2.0.7.0",
"startup_app": {
"name": "Hello Open Fin",
"url": "http:/localhost:5000/index.html",
--> "uuid": "OpenFinHelloWorld",
.
.
.
}
@wstucco
wstucco / elixir_brainfuck_interpreter_part_2.exs
Last active Aug 29, 2015
elixir_brainfuck_interpreter_part_2.exs
View elixir_brainfuck_interpreter_part_2.exs
defmodule Brainfuck do
# opcodes
@op_vinc "+" # increment value at memory address
@op_vdec "-" # decrement value at memory address
@op_pinc ">" # increment memory address
@op_pdec "<" # decrement memory address
@op_putc "." # output byte at memory address
@op_getc "," # input byte into memory address
@op_lbeg "[" # loop begin
You can’t perform that action at this time.