Skip to content

Instantly share code, notes, and snippets.

There's a problem with https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/kernel/cli.ex#L327
### with Erlang 17.1
# /usr/local/bin/mix
No file named /usr/local/bin/mix
# ls -l /usr/local/bin/mix
lrwxr-xr-x 1 root wheel 21 Jun 29 11:52 /usr/local/bin/mix -> ../lib/elixir/bin/mix
@mprymek
mprymek / gist:e257abc5e39afe01d928
Created June 25, 2014 22:19
R - set values in vector to the nearest value from the given boundaries vector
to_nearest = function(d,bounds) {
lapply(d,FUN=function(x){
idx=which.min(abs(bounds-x))
bounds[idx]
})
}
# Define 2 vectors
cars <- c(1, 3, 6, 4, 9)
trucks <- c(2, 5, 4, 5, 12)
# Graph cars using a y axis that ranges from 0 to 12
plot(cars, type="o", col="blue", ylim=c(0,12))
# Graph trucks with red dashed line and square points
lines(trucks, type="o", pch=22, lty=2, col="red")
#
# library part
#
defprotocol PerxistentProto do
def refresh o
def save! o
end
defmodule Perxistent do
@mprymek
mprymek / encfs-agent
Last active February 25, 2020 14:06
encfs-agent - mount encfs filesystems using ssh-agent
#! /usr/bin/env python2
"""
encfs-agent
Mounts encfs filesystems with passwords generated using private keys stored in ssh-agent.
You can have any number of encrypted filesystems ("vaults") under VAULTS_DIR. Password for
each of them is derived from its name and given private key stored in ssh-agent.
You can use ssh-askpass for ssh-agent if you want.
@mprymek
mprymek / gist:8379066
Last active July 22, 2022 09:18
Elixir metaprogramming example
# This is an example of metaprogramming in the Elixir language.
#
# We will define a domain specific language (DSL) for the definition
# of a service which is watched by several sensors.
# Each sensor watches some property/functionality of the service and
# returns the result of the check.
#
# To determine if the service is functioning properly, we need functions
# to run all the sensors' code and gather the returned data.
#