Skip to content

Instantly share code, notes, and snippets.

@jdbrice
jdbrice / battery.applescript
Created September 5, 2018 02:16
battery widget applescript for better touch tools
set theList to paragraphs of text of (do shell script "pmset -g batt")
set percent to word 6 of theList's item 2
set charge to word 7 of theList's item 2
if (charge = "charging") then
set iconC to "⚡️"
else
set iconC to ""
end if
@jdbrice
jdbrice / jupyter.css
Created December 16, 2018 17:52
Styling for jupyter notebooks saved to html
/*!
*
* Twitter Bootstrap
*
*/
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
@jdbrice
jdbrice / arange.py
Last active January 31, 2019 21:30
Makes numpy arange ranges from the shell, even chain together with commas
#!/usr/bin/env python
import numpy
import sys
if len(sys.argv) < 4:
print( "Usage: arange start stop step [, ndecimals]" )
exit()
if not sys.stdin.isatty():
@jdbrice
jdbrice / linspace.py
Last active January 31, 2019 21:29
Makes numpy linspace ranges from the shell, even chain together with commas
#!/usr/bin/env python
import numpy
import sys
if len(sys.argv) < 4:
print( "Usage: linspace start stop step [, endpoint, ndecimals]" )
exit()
if not sys.stdin.isatty():
@jdbrice
jdbrice / moment.C
Created July 25, 2019 15:05
Calculate the moments of a histogram
//usr/bin/env root -l -b -q "$0( $1, \"$2\" )"; exit $?
/* Calculate the nth moment of a distribution
*
* int n : order of the moment to calculate
* TString filehist :
*/
double moment( int n = 1, TString filehist = "", float x1=0, float x2=-1 ){
cout << "Calculating moment " << n << " on " << filehist << endl;
@jdbrice
jdbrice / gitcommitstr.C
Created July 26, 2019 14:42
TAG your ROOT files with your codes git commit so you always know what version of the code produced output
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
// credit : https://stackoverflow.com/users/58008/waqas
// from : https://stackoverflow.com/questions/478898/how-do-i-execute-a-command-and-get-output-of-command-within-c-using-posix
@jdbrice
jdbrice / marp-example.md
Created July 13, 2020 20:48
Marp style block for custom css in preview AND export
theme gaia
_class lead
backgroundColor
marp true
footer Daniel Brandenburg | 07142020
tags
<style> /* this works for export */
@jdbrice
jdbrice / md-cal.sh
Last active October 8, 2024 11:49
Generate markdown table calendar. Use wiki links to individual days
# Author: Daniel Brandenburg
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@jdbrice
jdbrice / pair_pt.C
Last active January 24, 2021 02:15
Rho photonuclear STARLight MC
#include "TFile.h"
#include "TH1F.h"
#include "TH1D.h"
#include "TH2F.h"
#include "TH3F.h"
#include "TCanvas.h"
#include "TMath.h"
#include "TVector3.h"
#include "TLegend.h"
@jdbrice
jdbrice / rootSTGM.C
Created February 12, 2021 01:03
Rough STAR sTGC geometry using ROOT TGeo
// Globals
TGeoManager *geom;
TGeoElementTable *table;
// Materials
TGeoMedium *mediumAir;
TGeoMedium *mediumG10;
TGeoMedium *mediumNPC02;