Skip to content

Instantly share code, notes, and snippets.

View MohamedElashri's full-sized avatar

Mohamed Elashri MohamedElashri

View GitHub Profile
@MohamedElashri
MohamedElashri / argus.py
Created August 4, 2023 13:57
roofit standard example in pyroot
from ROOT import RooFit
# Observable
mes = ROOT.RooRealVar("mes", "m_{ES} (GeV)", 5.20, 5.30)
# Parameters
sigmean = ROOT.RooRealVar("sigmean", "B^{#pm} mass", 5.28, 5.20, 5.30)
sigwidth = ROOT.RooRealVar("sigwidth", "B^{#pm} width", 0.0027, 0.001, 1.)
# Build a Gaussian PDF
@MohamedElashri
MohamedElashri / README.md
Created July 26, 2023 08:47
Generic subplot function for fit classes plots for Qnet summer school

Lets say that we have a two fits that we are trying to implement. I will assume that you have this version of double gaussian and exp class.

You really should use this one instead. It includes more sanity checks and allows you to pass iminuit limits as optional. This means that you don't have to always put (-np.inf, np.inf) for each limit anymore.

class DoubleGaussian_plus_Exp:
    def __init__(self, bins, nC, minuit_limits=None):
        self.xMin, self.xMax, self.bin_width, self.x_vals, self.y_vals, self.y_errs = self.Fit_Setup(nC, bins)
@MohamedElashri
MohamedElashri / rebase_merge.md
Created July 20, 2023 19:30
git rebase vs git rebase

Both are designed to integrate changes from one branch into another; however, they do this in very different manners and with different end results

Merge

The merge command is a way to take the contents of one branch and integrate them into another. It does this by creating a new commit that incorporates changes from other commits.

When we issue a git merge, Git will create a new commit that has pointers to both the branches we're merging. This is referred to as a merge commit, and it is a clear way to see when a file history was altered due to a merge.

Merge Example

@MohamedElashri
MohamedElashri / ufw.sh
Created July 14, 2023 20:16
utility for managing country-specific network traffic rules using UFW
#!/bin/bash
# json file can be found here
wget https://gist.githubusercontent.com/ssskip/5a94bfcd2835bf1dea52/raw/3b2e5355eb49336f0c6bc0060c05d927c2d1e004/ISO3166-1.alpha2.json
# Help message
read -r -d '' HELP << EOM
Usage: ./script.sh [action] [country codes]
Actions:
@MohamedElashri
MohamedElashri / disable_homebrew_analytics.sh
Created June 18, 2023 20:14
Disable Homebrew user behavior analytics
echo '--- Disable Homebrew user behavior analytics'
command='export HOMEBREW_NO_ANALYTICS=1'
declare -a profile_files=("$HOME/.bash_profile" "$HOME/.zprofile")
for profile_file in "${profile_files[@]}"
do
touch "$profile_file"
if ! grep -q "$command" "${profile_file}"; then
echo "$command" >> "$profile_file"
echo "[$profile_file] Configured"
else
@MohamedElashri
MohamedElashri / CERN.js
Created June 17, 2023 08:54
Bookmarklet for CERN and University of Cincinnati library proxy access
javascript:void(location.href='https://ezproxy.cern.ch/login?url='+location.href);
@MohamedElashri
MohamedElashri / julia_in_colab.md
Created June 13, 2023 17:11
Add Julia runtime to google colab

Add this cell code at the beginning and run it

%%shell
set -e

#---------------------------------------------------#
JULIA_VERSION="1.6.0" # any version ≥ 0.7.0
JULIA_PACKAGES="IJulia BenchmarkTools Plots" # add julia package you want to use here
@MohamedElashri
MohamedElashri / ipv6_test.sh
Last active June 13, 2023 16:59
bash script to test the accessibility of a website using IPv6 with optional whois
#!/bin/bash
# Usage ./ipv6_test.sh example.com
# Or to add whois ./ipv6_test.sh example.com --whois
# Check if the website URL is provided as an argument
if [ $# -eq 0 ]; then
echo "Please provide the website URL as an argument."
echo "Example: ./ipv6_test.sh example.com [--whois]"
exit 1
fi
@MohamedElashri
MohamedElashri / kagi_key_moments.js
Last active May 28, 2023 04:33
Kagi's universal summary bookmarklet (summary and key moments)
javascript:(function() {
try {
var url = new URL(window.location.href);
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
alert("Unsupported protocol. HTTP and HTTPS URLs are supported.");
} else {
window.open('https://kagi.com/summarizer/index.html?url=' + encodeURIComponent(url) + '&expand=true');
}
} catch (error) {
alert("Invalid URL or an error occurred: " + error.message);
@MohamedElashri
MohamedElashri / gauss_nightly_dev.sh
Created May 12, 2023 04:44
Get a gauss development environment from a specific nightly build number
#!/bin/bash
# bash script that takes a night build number as input and sets up a development version and compiles Gauss
# Author: Mohamed Elashri
# Date: 05/12/2023
# Get the night build number from the user
echo "Enter the night build number: "
read night_build_number