Skip to content

Instantly share code, notes, and snippets.

View nyrahul's full-sized avatar
🐞

Rahul Jadhav nyrahul

🐞
View GitHub Profile
Checks: '-*,readability-identifier-naming'
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
- { key: readability-identifier-naming.VariableCase, value: camelBack }
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.GlobalVariableCase, value: camelBack }
@nyrahul
nyrahul / Makefile
Last active April 10, 2019 10:39
Makefile trick: disable verbose compilation .. enable verbose only if 'make V=1'
CC=gcc
AR=ar
V = 0
ACTUAL_CC := $(CC)
CC_0 = @echo "CC [$<]"; $(ACTUAL_CC)
CC_1 = $(ACTUAL_CC)
CC = $(CC_$(V))
ACTUAL_AR := $(AR)
@nyrahul
nyrahul / perf-record.cmd
Created April 24, 2019 06:25
Perf record with single symbol reporting from multiple threads
perf record --call-graph dwarf -p PID
perf report --call-graph=graph,0.001,calle,function,percent --sort=symbol
perf report --call-graph=graph,0.001,calle,function,count --sort=symbol
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
// Example code which shows how to compare the two typedefs for size equivalency.
#define CONCAT_(a,b) a##b
#define CONCAT(a,b) CONCAT_(a, b)
#define STATIC_ASSERT(e) \
; enum { CONCAT(assert_line_, __LINE__) = 1/(int)(!!(e)) }
/* Note that ; is needed before enum if the STATIC_ASSERT is added right after case or label statement */
/* Note that multiple CONCATs are needed so that __LINE__ could be expanded .. Thus you can now have multiple STATIC_ASSERTs in the same code block */
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main"
sudo apt-get update
sudo apt-get install -y clang-6.0 clang-tidy
@nyrahul
nyrahul / example markdown for plantuml
Created July 5, 2019 11:48
Using plantuml to host the call flows
![QUIC/ngtcp2 handshake flow](http://www.plantuml.com/plantuml/proxy?src=https://raw.githubusercontent.com/nyrahul/ngtcp2-helper/master/res/ngtcp2-handshake.puml?cache=no)
@nyrahul
nyrahul / gdb.cmd
Last active July 22, 2019 11:52
runtime watch a global var ... cmd to use gdb -x gdb.cmd --arg <executable>
b StreamSetUserData
r
n
n
n
eval "watch *(int *)%p", &strm->userData
c
c
c
c
#!/bin/bash
set -E
trap 'echo Failed line: $LINENO command: $BASH_COMMAND && exit $?' ERR
lcnt=1
nw_pref="192.168.10"
create_node()
{
ns="$1"; shift;
@nyrahul
nyrahul / cfg_delayer.sh
Last active September 4, 2019 05:13
Use 'tc netem' to set delay/latency and loss parameters on an interface
#!/bin/bash
usage()
{
cat << EOF
USAGE: $0 [-hc] [-a <adapter>] [-d <delay-param>] [-l <loss-param>]
OPTIONS:
-h Show this message
-a <adapter> Set the adapter
-d <delay> Set delay/latency parameters (as accepted by netem[1])