Skip to content

Instantly share code, notes, and snippets.

@antoni
antoni / clang-format_config.md
Last active August 30, 2015 08:08 — forked from Uflex/clang-format_config.md
Configuration of clang-format for QtCreator

Clang-format in QtCreator

Edit: QtCreator 3.1 introduced a new plugin called Beautifier that supports clang-format. You still have to install the clang tools separately but you don't have to add them as external tools anymore. The plugin can be configured in the options dialog under the beautifier tab > Clang Format. Add a new style and copy the configuration below without the curly braces.

QtCreator doesn't allow using clang-format by default. Watch QTCREATORBUG-10111 for a better integration. As of today, you should use it as an external tool, either replacing your selection or the entire file. If you choose to replace the file, you will have to save it before launching the tool and QtCreator will reload the file, making it impossible to undo/redo afterwards. If you choose to replace your selection, you often have to select the whole function, otherwise you will lose the indentation; clang-format doesn't seem to k

@antoni
antoni / union_endianness.c
Created July 9, 2015 20:16
Detecting endianness at runtime
/*
* Source:
* http://stackoverflow.com/a/1001373/963881
*/
int is_big_endian(void)
{
union {
uint32_t i;
char c[4];

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@antoni
antoni / cuda.snippets
Last active August 29, 2015 14:24
CUDA snippets for Vim, should be put in: `~/.vim/bundle/vim-snippets/snippets`
extends cpp
# CUDA
## CUDA Functions
snippet sync
__syncthreads();
${1}
snippet thsync
@antoni
antoni / python-shorts.py
Created May 31, 2015 21:06
python-shorts.py
# Time functions
import timeit
timeit.timeit(a, number=1)
@antoni
antoni / bash_scripts.sh
Created May 21, 2015 10:56
Various bash scripts
# (1) mv with regexp
for i in *; do mv -n "$i" "${i/_*dpi*}".png; done;
# (2) Loop over array of strings
declare -a arr=("element1" "element2" "element3")
## now loop through the above array
for i in "${arr[@]}"
do
echo "$i"
@antoni
antoni / lxc-centos
Last active August 29, 2015 14:21 — forked from hagix9/lxc-centos
#!/bin/bash
#
# template script for generating CentOS container for LXC
#
#
# lxc: linux Container library
# Authors:
#!/bin/bash
# From ScalaCourses.com Introduction to Play Framework with Scala course
set -eo pipefail
function help {
echo "Download or update Typesafe Activator on Linux and Cygwin"
echo "Usage: $(basename $0) [options]"
echo "Options are:"
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
@antoni
antoni / tmux.md
Last active August 29, 2015 14:19 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a