Skip to content

Instantly share code, notes, and snippets.

View fclairamb's full-sized avatar
🤖

Florent Clairambault fclairamb

🤖
View GitHub Profile
@fclairamb
fclairamb / round.cpp
Last active December 3, 2021 19:12
round.cpp
#ifdef __SHELL__
set -ex
if [ "$0" = "sh" ]; then
curl https://gist.githubusercontent.com/fclairamb/0387016387c5474e06476f0a84b6ad86/raw/round.cpp > round.cpp && \
chmod a+rx round.cpp && \
./round.cpp
exit $?
fi
BIN=test-$(arch)
MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)
panic(cpu 0 caller 0xffffff8021ac2838): nvme: "Fatal error occurred. ID=0xffffffff ARG1=0xffffffff ARG2=0xffffffff ARG3=0xffffffff EDD0=0xffffffff EDD1=0xffffffff EDD2=0xffffffff EDD3=0xffffffff EDD4=0xffffffff EDD5=0xffffffff EDD6=0xffffffff EDD7=0xffffffff NANDV=0x2, DRAMV=0x2, SSDC=512GB. FW Revision=16.14.01\n"@/System/Volumes/Data/SWE/macOS/BuildRoots/2288acc43c/Library/Caches/com.apple.xbs/Sources/IONVMeFamily/IONVMeFamily-557.100.13/Common/IONVMeController.cpp:5499
Backtrace (CPU 0), Frame : Return Address
0xffffffb0f5443960 : 0xffffff801f28e02d
0xffffffb0f54439b0 : 0xffffff801f3d48e3
0xffffffb0f54439f0 : 0xffffff801f3c4eda
0xffffffb0f5443a40 : 0xffffff801f232a2f
0xffffffb0f5443a60 : 0xffffff801f28d84d
0xffffffb0f5443b80 : 0xffffff801f28db43

Keybase proof

I hereby claim:

  • I am fclairamb on github.
  • I am fclairamb (https://keybase.io/fclairamb) on keybase.
  • I have a public key ASA3MsMSqP-rEvGEE4ps2nlLlSwZ_j2_TNiGGbJPUw8pIAo

To claim this, I am signing this object:

@fclairamb
fclairamb / gin_gokit_logger.go
Last active January 30, 2022 15:31
GIN Logger with go-kit/log
package ginlogger
// Directly inspired from the default gin.Logger
// This is to be used like this:
// r := gin.New()
// r.Use(gin.Recovery())
// r.Use(ginlogger.LoggerWithGoKit(mylogger))
import (
@fclairamb
fclairamb / rapidjson_gen_json.cpp
Created January 5, 2016 13:04
Write some JSON using a rapidjson library
#ifdef SHELL
g++ -Wall -Werror -g -I../../cclib/rapidjson/include $0 && ./a.out
exit 0
#endif
// Output is:
// {"project":"rapidjson","stars":11}
// {"Name":"XYZ","Rollnumer":2,"array":["hello","world"],"Marks":{"Math":"50","Science":"70","English":"50","Social Science":"70"}}
// {"FromEmail":"[email protected]","FromName":"Sender's name","Subject":"My subject","Recipients":[{"Email":"[email protected]"}],"Text-part":"this is my text"}
@fclairamb
fclairamb / svn_changes_notifications.sh
Created October 9, 2015 10:02
Jenkins SVN changes notifications (when your sysadmins don't want to add a post-commit hook to the SVN repository)
[ -f /usr/bin/svn ] || sudo apt-get install subversion -y
[ -f /usr/bin/mail ] || sudo apt-get install mailutils -y
[ -f /usr/bin/pip ] || sudo apt-get install python-pip -y
sudo pip install pygments >/dev/null
SVN_NEW=$SVN_REVISION_1
SVN_OLD=$(cat svn_old ||:)
echo $SVN_NEW >svn_old
svn log $SVN_URL -r $(expr $SVN_OLD + 1 ):$SVN_NEW >logs.txt
svn diff $SVN_URL -r $SVN_OLD:$SVN_NEW >diff.txt
cat diff.txt | pygmentize -l diff -f html -O noclasses,nobackground -o diff.html
@fclairamb
fclairamb / stack_trace.c
Last active August 29, 2015 14:26 — forked from banthar/stack_trace.c
stacktrace with libunwind and elfutils
// stack_trace.c
//
// gcc stack_trace.c -ldw -lunwind -g -o stack_trace
#define UNW_LOCAL_ONLY
#include <elfutils/libdwfl.h>
#include <libunwind.h>
#include <stdio.h>
@fclairamb
fclairamb / permutation.c
Last active August 29, 2015 14:20
string permutation
#ifdef SHELL
gcc -ansi -g $0 && ./a.out
exit 0
#endif
#include <stdio.h>
#include <string.h>
void permutation (char * prefix, char * str) {
int n = strlen(str);
@fclairamb
fclairamb / var_sized.c
Last active August 29, 2015 14:11
variable size object
#ifdef SHELL
gcc -std=c99 -Wall -Werror $0 && ./a.out
exit $?
#endif
#include <stdio.h>
/*
Output:
@fclairamb
fclairamb / tab.c
Created December 12, 2014 09:34
Multi-dimentionnal C array address
#ifdef SHELL
gcc -Wall -Werror $0 && ./a.out
exit $?
#endif
/*
Output:
Table : 0x7fff03ab7490
Row 0 : 0x7fff03ab7490
Cell 0:0 : 0x7fff03ab7490