Skip to content

Instantly share code, notes, and snippets.

View z5ottu's full-sized avatar
👾
hopeful

Szloboda Zsolt z5ottu

👾
hopeful
View GitHub Profile
@z5ottu
z5ottu / ListMemcached.md
Created May 20, 2024 14:03 — forked from abullrd/ListMemcached.md
List Memcached Keys
@z5ottu
z5ottu / erlang-elixir-on-amazon-linux.md
Last active May 25, 2020 11:34 — forked from techgaun/erlang-elixir-on-amazon-linux.md
Running elixir 1.8.1 on amazon linux

Script

set your locale:

add these lines to /etc/environment

LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@z5ottu
z5ottu / tsung.emqx.mqtt.example.xml
Last active February 24, 2020 18:57
Tsung emqx mqtt benchmark example with username and password
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="error" version="1.0">
<!-- t1 and t2 host record should be in /etc/hosts file (on t1,t2 machnines too) -->
<clients>
<client host="t1" weight="1" cpu="4" maxusers="51000">
</client>
<client host="t2" weight="1" cpu="4" maxusers="51000">
</client>
</clients>
@z5ottu
z5ottu / ESP32_HID.ino
Created May 17, 2019 15:02 — forked from sabas1080/ESP32_HID.ino
Example of HID Keyboard BLE with ESP32
include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include "BLE2902.h"
#include "BLEHIDDevice.h"
#include "HIDTypes.h"
#include "HIDKeyboardTypes.h"
#include <driver/adc.h>
BLEHIDDevice* hid;
@z5ottu
z5ottu / util_convert_cowboy_ipv6_string_to_string.ex
Created March 1, 2019 16:08
Erlang cowboy IPv6 address string conversion to readable string in Elixir.
defmodule Utils.Cowboy do
use Bitwise
#
# ipv4 cowboy string example: "0.0.0.0.0.65535.20060.31747"
# ipv6 cowboy string example: "10754.43916.45826.36224.35230.44219.15941.63302"
def erlangCowboyIpv6StringToString(string) do
if String.starts_with?(string, "0.0.0.0.0.65535") do
String.split(string,".") |> Enum.take(-2) |> Enum.map(fn(x)-> String.to_integer x end) |> Enum.map(fn(x)-> [x >>> 8,x &&& 255] end) |> List.flatten |> Enum.join(".")
Top 10 DTrace scripts for Mac OS X
Since version 10.5 “Leopard”, Mac OS X has had DTrace, a tool used for performance analysis and troubleshooting. It provides data for Apple’s Instruments tool, as well as a collection of command line tools that are implemented as DTrace scripts. I’m familiar with the latter as I wrote the originals for the DTraceToolkit, which Apple then customized and enhanced for Mac OS X where they are shipped by default (great!). I use them regularly to answer this question:
why is my MacBook slow?
I work in an office where everyone has MacBook Pros, and “why is my MacBook slow?” is a common question. Applications can become slow or unresponsive while waiting for CPU work, memory requests or disk I/O to complete.
For people who try to ignore the slowdown, the question can become:
why is my MacBook fan so loud?
@z5ottu
z5ottu / riak_mapreduce_map_for_groupby.erl
Last active May 25, 2018 15:20
Riak Mapreduce map phase for reduce_plist_sum. Together is like sql "count" - "group by" functionality
%% -------------------------------------------------------------------
%%
%% riak_mapreduce_map_for_groupby:
%% Map phase for reduce_plist_sum.
%% Together is like sql "count" - "group by" functionality)
%%
%% Copyright (c)2018, Szloboda Zsolt, z5ottu@gmail.com All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
-module(riak_postcommit_hook_example).
-export([postcommitcounter/1, postcommitmapcounter/1]).
%% Refreshing counters from commithook is very expensive!
%%
%% requirements: bucket-type: maps(Type::map), bucket-type: counters(Type::counters)
%%
%% riak-admin bucket-type create maps '{"props":{"datatype":"map"}}'
%% riak-admin bucket-type activate maps
%% riak-admin bucket-type create counters '{"props":{"datatype":"counter"}}'
% Update Counter
increment
decrement
{increment, 4}
{decrement, 9}
% Update Set
{add, <<"Value">>}
{add_all, [<<"Value">>]}
{remove, <<"Value">>}
{remove_all, <<"Value">>}
%% -------------------------------------------------------------------
%%
%% riak_csv_etl: etl tools for csv files in Riak
%%
%% Copyright (c) 2011 Bradley Taylor. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at