Skip to content

Instantly share code, notes, and snippets.

View tomlobato's full-sized avatar
🎯
Focusing

Tom Lobato tomlobato

🎯
Focusing
View GitHub Profile
@tomlobato
tomlobato / memory_layout.md
Created August 12, 2017 01:06 — forked from CMCDragonkai/memory_layout.md
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@tomlobato
tomlobato / throttle-and-debounce.sh
Created February 2, 2018 17:38 — forked from niieani/throttle-and-debounce.sh
throttle and debounce commands in bash
#!/usr/bin/env bash
declare -i last_called=0
declare -i throttle_by=2
@throttle() {
local -i now=$(date +%s)
if (($now - $last_called >= $throttle_by))
then
"$@"
@tomlobato
tomlobato / benchmark_results.rb
Last active March 10, 2018 19:44 — forked from havenwood/benchmark_results.rb
Benchmarking serialization speed of YAML, JSON, Marshal, and MessagePack in MRI
# 2.4.2p198 on MBP 2017 i7
user system total real
-- YAML size=86 delta_vsz=0 delta_rss=2092
17.730000 0.060000 17.820000 ( 17.851288)
-- JSON size=83 delta_vsz=0 delta_rss=4
0.850000 0.000000 0.870000 ( 0.892370)
@tomlobato
tomlobato / gist:71e2815ff210dc24a1717df2afd8048a
Last active July 7, 2019 06:00 — forked from nevans/gist:9374041
simple ruby console histogram generator
require 'pry' # gem install pry
# Pass in an enumeration of data and
# (optionally) a block to extract the grouping aspect of the data.
#
# Optional: sort_by lambda (operates on group key and count)
def puts_hist(data, sort_by:nil, &blk)
data = data.map(&blk) if blk
counts = data.each_with_object(Hash.new(0)) {|k,h| h[k]+=1}