Skip to content

Instantly share code, notes, and snippets.

View gpakosz's full-sized avatar

Grégory Pakosz gpakosz

View GitHub Profile
@gpakosz
gpakosz / .gitconfig
Created September 26, 2013 10:59
Pretty git log.
[alias]
plog = log --graph --pretty=format:'%Cred%h%Creset %C(cyan)%an%Creset %C(yellow)%d%Creset %s %C(green)(%cr)%Creset' --abbrev-commit
@gpakosz
gpakosz / checkduplicatesymbols.sh
Created October 3, 2013 20:43
./checkduplicatesymbols.sh libFoo.a libBar.a
#!/bin/sh
# exit the script if any statement returns a non-true return value
set -e
# exit the script on dereferencing uninitialised variables
set -o nounset
self=$(basename $0)
origin=$(cd "$(dirname "$0")"; pwd)
@gpakosz
gpakosz / gist:9031730
Created February 16, 2014 09:32
Remove GA cruft
if (window.history && history.replaceState && (location.search.match(/utm_/) || location.hash.match(/utm_/))) {
search = location.search.replace(/(\?|\&)?utm_[a-z]+=[^\&]+/g, '')
hash = location.hash.replace(/(#|\&)?utm_[a-z]+=[^\&]+/g, '')
history.replaceState({}, '', location.pathname + search + hash);
}
@gpakosz
gpakosz / gist:53f19f167dbdbd889415
Created July 22, 2014 12:28
Git Branch Hall Of Fame alias
$ git config --global alias.branch-hof '!git for-each-ref --shell --format="printf '\''%%30s %%40s %%25s\n'\'' %(authorname) %(refname:short) %(committerdate:relative)" --sort=committerdate refs/remotes/origin | sh'
@gpakosz
gpakosz / ip-up
Created November 6, 2014 21:22
VPN, ppp /etc/ppp/ip-up example script
#!/bin/sh
# /etc/ppp/ip-up example script
# must have 0755 permissions
# must be owned by root
/sbin/route add -net 192.168.50 -interface $1
@gpakosz
gpakosz / main.cpp
Created February 2, 2015 12:22
C++ array_length, reply to http://www.g-truc.net/post-0708.html
#include <cstddef>
#include <iostream>
#define array_length(a) sizeof(implementation::array_length_requires_array_argument(a))
namespace implementation {
template<typename T, size_t N>
char (&array_length_requires_array_argument(T (&)[N]))[N];
} // namespace implementation
@gpakosz
gpakosz / .gitconfig
Created October 8, 2015 12:14
My global .gitconfig
[user]
name = Gregory Pakosz
email = redacted
[color]
ui = auto
[core]
autocrlf = false
excludesfile = /Users/gregory/.gitignore
editor = vim
whitespace = cr-at-eol
@gpakosz
gpakosz / main.c
Created November 11, 2015 08:08
printf format string for size_t
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1800)
#define SIZET_FMT "%Iu"
#elif defined(__linux__) || (defined(_MSC_VER) && (_MSC_VER >= 1800))
#define SIZET_FMT "%zu"
#elif defined(__APPLE__)
#define SIZET_FMT "%zu"
#else
#define SIZET_FMT "%u"
#endif
// gcc -O3 -march=native -o simplehashing simplehashing.c
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
#include <x86intrin.h>
// https://github.com/php/php-src/blob/PHP-7.1/Zend/zend_string.h#L325
@gpakosz
gpakosz / array_length.hpp
Created January 5, 2017 21:46
C++98 array_length
#include <cstddef>
#define array_length(a) sizeof(impl::array_length_requires_array_argument(a))
namespace impl {
template<typename T, size_t N>
char (&array_length_requires_array_argument(T (&)[N]))[N];
}