Skip to content

Instantly share code, notes, and snippets.

@raggleton
raggleton / saveWebsite.md
Created November 19, 2014 09:58
How to save website offline

wget -k -p -e robots=off -r -l2 http://www.parashift.com/c++-faq-lite/index.html

or

wget --mirror --convert-links --adjust-extension --page-requisites --no-parent http://example.org

aka

wget -mkEpnp http://example.org

@raggleton
raggleton / loopTest.cpp
Created November 13, 2014 18:04
How to loop over TFile with BRanches etc
#include <iostream>
#include <TChain.h>
#include "TFile.h"
#include "TDirectoryFile.h"
#include "TTree.h"
#include "DeltaR_Matcher.h"
int main() {
std::cout << "Looping test" << std::endl;
@raggleton
raggleton / loopingTHStack.py
Last active November 1, 2017 13:36
How to loop over a TList / histograms in a THStack
"""Iterate over hists in a THStack.
Turns out it's way easier than in C++
"""
for hist in my_stack.GetHists():
print type(hist)
print hist.Integral()
@raggleton
raggleton / rmSymbolics.sh
Created July 10, 2014 11:36
Remove symbolic links
find -type l -exec rm {} \;
@raggleton
raggleton / deleteEmpties.sh
Created June 2, 2014 10:36
Deletes empty files in the current directory. -type f required as directories have size 0 even if not empty!
find . -type f -empty -delete
@raggleton
raggleton / rootNotes.cc
Created April 4, 2014 09:58
ROOT notes
/**
* For reminders about ROOT idiosyncrasies
*
* /
// Put tick marks on inside of all axis of a plot (ie right hand y and top x axes)
// NOT a fn of the TH1, but of the pad instead (sigh)
myPad->SetTicks(1,1);
@raggleton
raggleton / printFileContent.py
Created February 21, 2014 18:29
Prints out event content during path run (like edmDumpEventContent)
process.eca= cms.EDAnalyzer("EventContentAnalyzer"
#getData = cms.untracked.bool(True),
#listContent = cms.untracked.bool(False)
)
then later on
process.p = cms.Path( ... + process.eca + ... )
# https://github.com/cms-sw/cmssw/blob/e858790c803839263e8b9c67ba6a07273d953af3/FWCore/Modules/python/printContent_cfi.py
find . -type f -name "example-*.txt" -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "
@raggleton
raggleton / profileBash
Created December 5, 2013 15:22
This prints out time (in s since 1970) and line number+content to aid in profiling a bash script. Taken from: http://stackoverflow.com/questions/4336035/performance-profiling-tools-for-shell-scripts Note, that sometimes the first digit gets chopped off the date :/
PS4='$(date "+%s.%N ($LINENO) + ")' bash -x scriptname