Skip to content

Instantly share code, notes, and snippets.

View pmalek's full-sized avatar
👋
Go and Open Source enthusiast

Patryk Małek pmalek

👋
Go and Open Source enthusiast
View GitHub Profile
@foonathan
foonathan / clz.cpp
Last active April 14, 2016 09:46
A clz() implementation wrapping __builtin_clz() - see blog post http://foonathan.github.io/blog/2016/02/11/implementation-challenge-2.html
#include <climits>
#include <cstdint>
#include <type_traits>
struct clzll_tag {};
struct clzl_tag : clzll_tag {};
struct clz_tag : clzl_tag {};
template <typename T, typename = typename std::enable_if<sizeof(T) <= sizeof(unsigned int)>::type>
unsigned clz_impl(clz_tag, T x)
@talwai
talwai / servefile.sh
Created January 23, 2015 19:57
One-shot HTTP webserver to serve file contents using netcat
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <some.file)\r\n\r\n"; cat some.file; } | nc -l 8080
@aginor
aginor / AMD-fglrx-3.17-3.19.patch
Last active August 29, 2015 14:09
Patch AMD/ATI catalyst/fglrx 14.301.1001 / 14.9 or 14.501.1003 /14.12 driver to work with linux 3.17.x to 3.19.x kernels (tested on Fedora 20)
--- a/common/lib/modules/fglrx/build_mod/firegl_public.c 2014-11-29 09:02:10.000000000 +1300
+++ b/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-04-18 22:31:06.673656387 +1200
@@ -4816,8 +4816,13 @@
{
unsigned long orig_level;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
orig_level = __get_cpu_var(kasExecutionLevel);
__get_cpu_var(kasExecutionLevel) = level;
+#else
@goldshtn
goldshtn / cpp11.cpp
Last active May 8, 2018 01:24
A single function that uses a bunch of C++11/14 features and for "old-school" C++ developers will not even read like C++ anymore.Specifically, it uses:- lambda functions (C++11) with generalized capture semantics (C++14)- rvalue references (C++11)- auto variables (C++11)- decltype and trailing function return type syntax (C++11)- std::move and s…
#include <iostream>
#include <future>
using namespace std;
template <typename Fn, typename... Args>
auto do_async_with_log(ostream& os, Fn&& fn, Args&&... args) ->
future<decltype(fn(args...))>
{
os << "[TID=" << this_thread::get_id()
@sturadnidge
sturadnidge / tmux-1.8-on-CentOS-6.x.txt
Last active May 10, 2021 18:31
Install tmux 1.8 on CentOS 6.x minimal (64bit)
# download latest libevent2 and tmux sources, and extract them somewhere
# (thx bluejedi for tip on latest tmux URL)
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://sourceforge.net/projects/tmux/files/latest/download?source=files
#
# install deps
yum install gcc kernel-devel make ncurses-devel
@msabramo
msabramo / git_prompt_info.zsh
Created April 11, 2012 00:07
The slowness of my zsh prompt when in a git-svn managed directory was killing me. I improved it by removing the git status stuff that slows it down...
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_SUFFIX"
}