Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
self=$(readlink -f $(dirname $0))
cd $self
inoticoming \
--logfile logs/inoticoming.log \
--pid-file tmp/inoticoming.pid \
incoming \
--suffix .changes \
#!/usr/bin/env bash
function pid_files()
{
ls -l /proc/$1/fd/* | awk -v p=$pattern '$0 ~ p {fd=$(NF-2); sub(/^.*\/fd\//, "", fd); printf("%s %s\n", fd, $NF);}'
}
function pid_files_offsets()
{
ls -1 /proc/$1/fdinfo/* | awk '{ fd=f=$NF; sub(/^.*\/fdinfo\//, "", fd); getline < f; pos=$NF; printf("%s %s\n", fd, pos); }'
}
#!/usr/bin/env bash
#
# Compile and run under sanitizers, that compiler have (we will use clang).
# Sanitizers will check more then valgrind, because under valgrind we check
# only {db,db-indexes,db-ck} while using sanitizers we can test all utils.
#
set -e
@azat
azat / lto-odr
Created September 15, 2015 14:35
/usr/include/c++/5/bits/stl_list.h:207:50: error: type ‘const struct _Node’ violates one definition rule [-Werror=odr]
typedef const _List_node<_Tp> _Node;
^
/usr/include/c++/5/bits/stl_list.h:207:50: note: a different type is defined in another translation unit
typedef const _List_node<_Tp> _Node;
^
/usr/include/c++/5/bits/stl_list.h:109:11: note: the first difference of corresponding definitions is field ‘_M_data’
_Tp _M_data;
^
/usr/include/c++/5/bits/stl_list.h:109:11: note: a field of same name but different type is defined in another translation unit
// gcc -ggdb -pthread -o test_timeout test_timeout.c -levent -levent_pthreads
#include <event2/dns.h>
#include <event2/event.h>
#include <event2/http.h>
#include <event2/thread.h>
#include <event2/bufferevent.h>
#include <pthread.h>
#include <stdio.h>
start
p (1ULL<<31)+1ULL
# $1 = 2147483649
p malloc(sizeof(struct sockaddr))
# $2 = (void *) 0x646010
p malloc(sizeof(int))
# $3 = (void *) 0x646030
p malloc($1)
# $4 = (void *) 0x7fff76a2a010
p memset($4, 1, $1)
set $PROT_NONE=0x0
set $PROT_READ=0x1
set $PROT_WRITE=0x2
set $MAP_ANONYMOUS=0x20
set $MAP_SHARED=0x01
set $MAP_FIXED=0x10
set $MAP_32BIT=0x40
start
#!/usr/bin/env bash
# uncrustify git commits, IOW not the whole files, but only parts of them
# XXX: not 100% correct
function uncrustify_frag()
{ command uncrustify -l C --frag "$@"; }
function indent_off() { echo '/* *INDENT-OFF* */'; }
function indent_on() { echo '/* *INDENT-ON* */'; }
function hunk()
@azat
azat / .clang-format
Last active February 17, 2016 10:12
clang-format config for libevent
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlinesLeft: true
# AlignOperands: true
AlignTrailingComments: true
/**
libevent
user-triggered event example
*/
#include <event2/event.h>
void cb(int fd, short events, void *arg)
{
puts("cb");