Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# --slave /usr/bin/$1 $1 /usr/bin/$1-\${version} \\
function register_clang_version {
local version=$1
local priority=$2
update-alternatives \
--install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${version} ${priority} \

Git Cheat Sheet

Commands

Getting Started

git init

or

@ksophocleous
ksophocleous / unix_timestamp.cpp
Created September 8, 2014 12:20
cross platform unix timestamp in c++
#include <iostream>
#include <chrono>
int main(int argc, char *argv[])
{
auto tp = std::chrono::system_clock::now();
auto dur = tp.time_since_epoch();
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(dur).count();
@cillierburger
cillierburger / How to patch Ubuntu Lucid (10.04) against OpenSSL Heartbleed
Created April 8, 2014 11:23
How to patch Ubuntu Lucid (10.04) against OpenSSL Heartbleed
Add this to /etc/apt/sources.list
<snip>
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse
</snip>
@aras-p
aras-p / preprocessor_fun.h
Last active April 28, 2024 15:25
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@lichray
lichray / make_array.cc
Last active August 29, 2023 16:37
Factory function of std::array
#include <array>
#include <functional>
template <typename... T>
using common_type_t = typename std::common_type<T...>::type;
template <typename T>
using remove_cv_t = typename std::remove_cv<T>::type;
template <bool, typename T, typename... U>
@klmr
klmr / make_array.hpp
Last active March 18, 2024 07:14
C++11 make_array function template
template <typename... T>
constexpr auto make_array(T&&... values) ->
std::array<
typename std::decay<
typename std::common_type<T...>::type>::type,
sizeof...(T)> {
return {std::forward<T>(values)...};
}
@bgaff
bgaff / fizzbuzz.cpp
Created April 26, 2012 05:50
FizzBuzz C++: Template Recursion
/*
* fizzbuzz.cpp
*
* Created on: Apr 25, 2012
* Author: Brian Geffon
*
* fizzbuzz solved without looping or conditionals using only template recursion.
*/
#include <iostream>

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@snaewe
snaewe / read_with_timeout.cc
Created September 4, 2011 07:50
boost::asio - async read with timeout
void set_result(optional<error_code>* a, error_code b)
{
a->reset(b);
}
template <typename MutableBufferSequence>
void read_with_timeout(tcp::socket& sock,
const MutableBufferSequence& buffers)
{
optional<error_code> timer_result;
deadline_timer timer(sock.io_service());