Skip to content

Instantly share code, notes, and snippets.

View ktf's full-sized avatar

Giulio Eulisse ktf

View GitHub Profile
@ktf
ktf / example.cxx
Last active November 4, 2019 20:47
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
@ktf
ktf / constexpr-typeid.cxx
Last active October 31, 2019 09:48
constexpr typeid
#include <cstddef>
#include <cstdint>
// Adapted from https://github.com/Manu343726/ctti
struct TypeIdHelpers {
// From https://github.com/foonathan/string_id. As usually, thanks Jonathan.
using hash_t = uint64_t;
// See http://www.isthe.com/chongo/tech/comp/fnv/#FNV-param
FILES=$(git grep -l -e 'namespace[[:space:]]*framework[[:space:]]*[{]' Framework/)
git reset --hard HEAD
for x in $FILES; do
echo $x
ed -s $x<< \EOF
g/namespace[ ]*o2[ ]*{/s/[ ]*{//
a
{
.
@ktf
ktf / fix-iostream.sh
Created May 14, 2018 20:46
Fix a few trivial `#include <iostream>` in an headerfile
#!/bin/bash -ex
FILES=`git grep iostream | grep /include/ | grep \.h: | sed -e 's/:.*//'`
for HEADER in $FILES; do
CXX=`echo $HEADER | sed -e's|include/[^/]*|src|;s|\.h$|.cxx|'`
HEADER_SHORT=`echo $HEADER | sed 's|.*/include/||g'`
echo $HEADER
echo $HEADER_SHORT
echo $CXX
# If there is no src Directory, we cannot simply amend the build like this.
if [ ! -d `dirname $CXX` ]; then

Keybase proof

I hereby claim:

  • I am ktf on github.
  • I am ktf77 (https://keybase.io/ktf77) on keybase.
  • I have a public key ASCMCAlg8ByqDKCWwuf09m1jRqJHmGpw2MZxK5YXZqrUpQo

To claim this, I am signing this object:

@ktf
ktf / run.sh
Created April 1, 2015 13:01
Run a Marathon + Mesos cluster on your laptop
docker run --net=host -it cmssw/zookeeper &
docker run --net=host -it cmssw/mesos-master &
docker run --net=host -it cmssw/marathon &
docker run --net=host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/local/bin/docker:/usr/bin/docker \
-v /sys:/sys \
-it \
cmssw/mesos-slave
@ktf
ktf / gist:6211006
Last active December 20, 2015 23:18
Clean up CVS keywords
FOO=<your-package-to-cleanup>
git cms-addpkg $FOO
cd $CMSSW_BASE/src
find . -type f -exec sed -i "/[$][Dd]ate:[^$]*[$]/d" {} \;
find . -type f -exec sed -i "/[$][Ii]d:[^$]*[$]/d" {} \;
find . -type f -exec sed -i "/[$][Aa]uthor:[^$]*[$]/d" {} \;
find . -type f -exec sed -i "/[$][Rr]evision[^$]*[$]/d" {} \;
find . -type f -exec sed -i "/[$][Ll]og:[^$]*[$]/d" {} \;
find . -type f -exec sed -i "/[$][Ss]ource:[^$]*[$]/d" {} \;
@ktf
ktf / gist:5282656
Created April 1, 2013 00:49
Simple selectable table.
$("#table_" + currentRelease).selectable({
selected: function (event, ui) {
var checkBoxes = $(ui.selected).find("input");
if ($(ui.selected).hasClass('click-selected')) {
$(ui.selected).removeClass('ui-selected click-selected');
checkBoxes.prop("checked", !checkBoxes.prop("checked"));
} else {
$(ui.selected).addClass('click-selected');
checkBoxes.prop("checked", !checkBoxes.prop("checked"));
}
@ktf
ktf / gist:3293569
Created August 8, 2012 08:50
Key-Value maps using const expressions.
namespace {
template <class T>
struct entry {
char const* label;
T value;
};
constexpr bool same(char const *x, char const *y) {
return !*x && !*y ? true
: /* default */ (*x == *y && same(x+1, y+1));
@ktf
ktf / non_cms_python.py
Created July 29, 2012 18:25
A simple way of executing the first python in path which can import a given module
def usePythonWithModule(modulename):
import os
import sys
from os.path import exists, dirname, basename, join
try:
__import__(modulename)
except:
pythonpath = os.path.dirname(sys.executable)
check = False
for x in [x for x in os.environ["PATH"].split(":") if x]: