Skip to content

Instantly share code, notes, and snippets.

View denispeplin's full-sized avatar

Denis denispeplin

View GitHub Profile
iex> So.Exclude.exclude1
Name ips average deviation median
substract 9.18 M 0.109 μs ±358.78% 0.100 μs
mapset_difference 4.00 M 0.25 μs ±17781.86% 0.0 μs
enum_filter 3.70 M 0.27 μs ±1712.25% 0.20 μs
ordsets 2.63 M 0.38 μs ±1348.35% 0.30 μs
Comparison:
substract 9.18 M
mapset_difference 4.00 M - 2.30x slower
@denispeplin
denispeplin / pre-commit
Created October 1, 2018 11:23
mix format pre-commit hook
#!/bin/sh
#
# Place in .git/hooks and make executable
MIX_LOCATION=mix
cd `git rev-parse --show-toplevel`
$MIX_LOCATION format --check-formatted
@denispeplin
denispeplin / README.md
Created September 2, 2018 16:13
primitive fsm with hardcoded rules

Usage

den@den-vb:~/projects$ iex fsm.ex
Erlang/OTP 20 [erts-9.3.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.7.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Fsm.transition!(%{status: "draft", data: "payload"}, :rejected)  
%{data: "payload", status: "rejected"}
iex(2)> Fsm.transition!(%{status: "rejected", data: "payload"}, :signed) 
@denispeplin
denispeplin / README.md
Last active December 10, 2017 06:53
Source code to Etherscan
@denispeplin
denispeplin / Rinkeby.md
Last active December 2, 2017 17:29 — forked from learner-long-life/Rinkeby.md
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

uint saleTime = period * 1 days;
if(now < start + saleTime.div(4)) {
bonusTokens = tokens.div(4);
} else if(now >= start + saleTime.div(4) && now < start + saleTime.div(2)) {
bonusTokens = tokens.div(10);
} else if(now >= start + saleTime.div(2) && now > saleTime.div(4).mul(3)) {
bonusTokens = tokens.div(20);
}
@denispeplin
denispeplin / new.ex
Created June 15, 2017 17:48
try elixir
defmodule New do
def sum(a, b) do
a + b
end
end
@denispeplin
denispeplin / pre-push.sh
Last active November 16, 2016 07:29
Git pre-push hook to prevent force pushing or removing any branch in origin
#!/bin/bash
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`

xmlns:misc

misc:location various data regarding location, organisation, etc.

@denispeplin
denispeplin / commands
Created February 22, 2013 09:11
CentOS Ruby
# build esseintails
yum -y install gcc gcc-c++ kernel-devel
# make tools
yum -y install gcc automake autoconf libtool make
# ruby related stuff
yum -y install libxslt-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel postgresql-devel ImageMagick-devel ImageMagick
# libyaml-devel