Skip to content

Instantly share code, notes, and snippets.

@fcamel
fcamel / active.go
Last active Feb 17, 2019
active object pattern in go
View active.go
package main
import "fmt"
type One int
type Ten int
type work struct {
object interface{}
result chan error
@fcamel
fcamel / LD_DEBUG_symbols.sh
Last active Jul 22, 2018
Example of LD_DEBUG=symbols
View LD_DEBUG_symbols.sh
$ LD_LIBRARY_PATH=. ./prog
foo
foo-xyz
bar
foo-xyz
$ LD_DEBUG=symbols LD_LIBRARY_PATH=. ./prog
...
foo
21169: symbol=xyz; lookup in file=./prog [0]
21169: symbol=xyz; lookup in file=./libfoo.so [0]
@fcamel
fcamel / LD_DEBUG_libs.sh
Last active Jul 22, 2018
Example of LD_DEBUG=libs
View LD_DEBUG_libs.sh
$ LD_DEBUG=libs out/Debug/chrome
30970: find library=libpthread.so.0 [0]; searching
30970: search path=/home/fcamel/dev/chromium/src/out/Debug/./tls/x86_64:/home/fcamel/dev/chromium/src/out/Debug/./tls:/home/fcamel/dev/chromium/src/out/Debug/./x86_64:/home/fcamel/dev/chromium/src/out/Debug/. (RPATH from file out/Debug/chrome)
30970: trying file=/home/fcamel/dev/chromium/src/out/Debug/./tls/x86_64/libpthread.so.0
30970: trying file=/home/fcamel/dev/chromium/src/out/Debug/./tls/libpthread.so.0
30970: trying file=/home/fcamel/dev/chromium/src/out/Debug/./x86_64/libpthread.so.0
30970: trying file=/home/fcamel/dev/chromium/src/out/Debug/./libpthread.so.0
30970: search cache=/etc/ld.so.cache
30970: trying file=/lib/x86_64-linux-gnu/libpthread.so.0
30970:
View ldd_example.sh
$ ldd /bin/ls
linux-vdso.so.1 => (0x00007ffe7a5fe000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fd64b7a1000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd64b3d7000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fd64b167000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd64af63000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd64b9c3000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd64ad46000)
@fcamel
fcamel / elf_shared_lib_order.sh
Created Jul 21, 2018
ELF shared library order
View elf_shared_lib_order.sh
$ cat prog.c
#include <stdio.h>
void foo();
void bar();
int main(void) {
foo();
bar();
return 0;
@fcamel
fcamel / elf_visibility_test.sh
Last active Jul 29, 2018
ELF visibility test
View elf_visibility_test.sh
$ cat prog.c
#include <stdio.h>
void func();
void xyz() {
printf("main-xyz\n");
}
void xyz2() {
View benchmark_gzip_brotli.sh
#!/bin/bash
rm -rf output
mkdir output
ls -l input | awk '{ s += $5 } END { print s }'
# compress
begin=$(date +%s%N)
for f in input/*
@fcamel
fcamel / skia_stap_output.txt
Created Jan 7, 2018
SystemTap output for Skia viewer
View skia_stap_output.txt
process("/home/fcamel/dev/study/skia/out/Debug/viewer").function("SkAutoCanvasRestore@../../include/core/SkCanvas.h:2788").call
process("/home/fcamel/dev/study/skia/out/Debug/viewer").function("getSaveCount@../../src/core/SkCanvas.cpp:874").call
process("/home/fcamel/dev/study/skia/out/Debug/viewer").function("SkCanvas@../../src/core/SkCanvas.cpp:710").call
process("/home/fcamel/dev/study/skia/out/Debug/viewer").function("init@../../src/core/SkCanvas.cpp:629").call
process("/home/fcamel/dev/study/skia/out/Debug/viewer").function("MCRec@../../src/core/SkCanvas.cpp:296").call
process("/home/fcamel/dev/study/skia/out/Debug/viewer").function("DeviceCM@../../src/core/SkCanvas.cpp:256").call
process("/home/fcamel/dev/study/skia/out/Debug/viewer").function("qr_clip_bounds@../../src/core/SkCanvas.cpp:606").call
process("/home/fcamel/dev/study/skia/out/Debug/viewer").function("setSurfaceBase@../../include/core/SkCanvas.h:2663").call
process("/home/fcamel/dev/study/skia/out/Debug/viewer").function("save@../../src/core/
@fcamel
fcamel / gist:878c843badde0d177c57734d0094ac01
Last active Jan 6, 2018
strace -f -s 1024 host ubuntu
View gist:878c843badde0d177c57734d0094ac01
[pid 32630] socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 6
[pid 32630] fcntl(6, F_DUPFD, 20) = 20
[pid 32630] close(6) = 0
...
[pid 32630] bind(20, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
...
[pid 32630] sendmsg(20, {msg_name(16)={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.1.1")}, msg_iov(1)=[{"J\311\1\0\0\1\0\0\0\0\0\0\6ubuntu\0\0\1\0\1", 24}], msg_controllen=0, msg_flags=0}, 0 <unfinished ...>
...
[pid 32630] recvmsg(20, {msg_name(16)={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.1.1")}, msg_iov(1)=[{"J\311\200\200\0\1\0\1\0\0\0\0\6ubuntu\0\0\1\0\1\300\f\0\1\0\1ZQ\1\343\0\4\300\250\1j", 65535}], msg_controllen=56, [{cmsg_len=32,
...
View tshark_tcp_quickack.txt
1 0.000000000 192.168.1.109 → 192.168.1.109 TCP 74 46672 → 8000 [SYN] Seq=0 Win=43690 Len=0 MSS=65495 SACK_PERM=1 TSval=40124281 TSecr=0 WS=128
2 0.000005978 192.168.1.109 → 192.168.1.109 TCP 74 8000 → 46672 [SYN, ACK] Seq=0 Ack=1 Win=43690 Len=0 MSS=65495 SACK_PERM=1 TSval=40124281 TSecr=40124281 WS=128
3 0.000010862 192.168.1.109 → 192.168.1.109 TCP 66 46672 → 8000 [ACK] Seq=1 Ack=1 Win=43776 Len=0 TSval=40124281 TSecr=40124281
4 0.000056512 192.168.1.109 → 192.168.1.109 TCP 76 8000 → 46672 [PSH, ACK] Seq=1 Ack=1 Win=43776 Len=10 TSval=40124281 TSecr=40124281
5 0.000088529 192.168.1.109 → 192.168.1.109 TCP 66 46672 → 8000 [ACK] Seq=1 Ack=11 Win=43776 Len=0 TSval=40124281 TSecr=40124281
6 0.000109539 192.168.1.109 → 192.168.1.109 TCP 1056 8000 → 46672 [PSH, ACK] Seq=11 Ack=1 Win=43776 Len=990 TSval=40124281 TSecr=40124281
7 0.000112096 192.168.1.109 → 192.168.1.109 TCP 66 46672 → 8000 [ACK] Seq=1 Ack=1001 Win=45696 Len=0 TSval=40124281 TSecr=40124281
8 0.000131095 192.168.1.10
You can’t perform that action at this time.