Skip to content

Instantly share code, notes, and snippets.

@adrienmo
adrienmo / erlang_common_test_to_junit_xml.sh
Last active September 11, 2015 04:37
Convert result of common_test into XUnit format for Jenkins use
#Output file
JUNIT_FILE=test_output.xml
#Jenkins ignores the testsuite properties, we add manually the header for the testsuite with arbitrary data
echo '<testsuites><testsuite name="App Name" tests="1" failures="0" timestamp="2012-08-23T14:40:44.874443-05:00">' > $JUNIT_FILE
#Assume there is only one run of ct_run in the logs folder
cat logs/*/*/*/suite.log |
sed '/=case \|=result/!d' |
sed 's/^=case[ ]*\(.*\)/<testcase name="\1">/g' |
@adrienmo
adrienmo / logstash-output-sentry.md
Last active June 20, 2021 09:21
Logstash output to Sentry plugin + logstash configuration example

To install the plugin you can create a folder for logstash plugins, e.g. :

/etc/logstash/plugins/

Be sure you respect logstash requirements about the plugin path "$PATH/logstash/TYPE/NAME.rb", e.g. :

/etc/logstash/plugins/logstash/outputs/sentry.rb

Then start logstash manually with the options :

@adrienmo
adrienmo / take_redis_sorted_set.lua
Created February 1, 2016 09:52
redis script to take atomically N elements from a redis sorted set according to score and limit
-- This script allow you to perform the following hypothetical operation in a transaction :
--
-- ZRANGEBYSCORE key min max LIMIT 0 count
-- ZREMRANGEBYSCORE key min max LIMIT 0 count
--
-- LIMIT on ZREMRANGEBYSCORE is not supported at the moment, this script resolve it
local keys = redis.call('zcount', KEYS[1], ARGV[1], ARGV[2]);
local count = math.min(keys, ARGV[3]);
if count == 0 then
-- This script allow you to get an incremented unique integer id from a string
-- EVAL "SCRIPT" 1 key member1 -> return 1
-- EVAL "SCRIPT" 1 key member2 -> return 2
-- EVAL "SCRIPT" 1 key member1 -> return 1
-- EVAL "SCRIPT" 1 key member3 -> return 3
local nb_keys = redis.call('zcard', KEYS[1]);
local score = redis.call('zscore', KEYS[1], ARGV[1]);
if score then
return tonumber(score);
@adrienmo
adrienmo / reverse_lookup_geolix.ex
Created September 25, 2017 01:33
reverse lookup for geolix
defmodule Location do
require Logger
def create do
Geolix.load_database(
%{
id: :city,
adapter: Geolix.Adapter.MMDB2,
source: "/test/GeoLite2-City_20170905.tar.gz"
}
)
@adrienmo
adrienmo / nash-proxy.pac
Last active November 10, 2020 02:56
proxy.pac
function FindProxyForURL(url, host) {
if (shExpMatch(host, "*.nash.io"))
{
return "SOCKS5 127.0.0.1:1086; SOCKS 127.0.0.1:1086; DIRECT;";
}
if (isInNet(host, "35.202.187.127", "255.255.255.255"))
{
return "SOCKS5 127.0.0.1:1086; SOCKS 127.0.0.1:1086; DIRECT;";
}
return "DIRECT;";