Skip to content

Instantly share code, notes, and snippets.

View ktf's full-sized avatar

Giulio Eulisse ktf

View GitHub Profile
@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
// Some generic stack based tree walker.
template <class T>
class StackItem
{
public:
typedef T Node;
StackItem(Node *parent, Node *pre, Node *post)
: m_parent(parent),
m_pre(pre),
@ktf
ktf / SimpleSAXParser.h
Created April 15, 2010 16:52
Simple SAX like parser for xml
/* A simple SAX-like parser.
And yes, I know the S in SAX stands for Simple.
Copyright 2010 Giulio Eulisse. All rights reserved.
Licensed under GPLv3 license.
TODO: incomplete support for entities.
TODO: no support for DTD nor <?xml> preamble.
@ktf
ktf / gist:481231
Created July 19, 2010 10:13
Symbol information for callq and similar instructions
#!/usr/bin/env python
from optparse import OptionParser
from commands import getstatusoutput
from sys import exit
if __name__ == "__main__":
parser = OptionParser(usage="%prog <pid>")
parser.add_option("--json", "-j", dest="json", help="dump output as JSON dictionary", action="store_true", default=False)
opts, args = parser.parse_args()
if len(args) != 1:
@ktf
ktf / nv2iki
Created July 21, 2010 11:58
Convert a folder of markdown text to an ikiwiki hierarchy
#!/usr/bin/python
from glob import glob
from optparse import OptionParser
from os.path import join, basename
from email import message_from_file
from os import getenv
from os.path import splitext
import re
if __name__ == "__main__":
@ktf
ktf / callsites.py
Created January 3, 2011 10:05
A simple script which dumps all the addresses for call/callq instructions of a given process.
#!/usr/bin/env python
from optparse import OptionParser
from commands import getstatusoutput
from sys import exit
description="""A simple script which dumps all the addresses for call/callq instructions of a given process.
"""
if __name__ == "__main__":
@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]:
@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 / 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: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" {} \;