Skip to content

Instantly share code, notes, and snippets.

View MohamedElashri's full-sized avatar

Mohamed Elashri MohamedElashri

View GitHub Profile
@MohamedElashri
MohamedElashri / auto_continue.js
Created October 2, 2023 12:08
Userscript for auto clicking Continue generating button for ChatGPT
// ==UserScript==
// @name Auto Continue for ChatGPT
// @namespace http://melashri.net
// @version 0.1
// @description Automatically clicks "Continue generating" button on OpenAI's ChatGPT website.
// @author Mohamed Elashri
// @match https://chat.openai.com/*
// @grant none
// ==/UserScript==
@MohamedElashri
MohamedElashri / HDF5_Metadata_Reader.c
Created August 28, 2023 21:56
A C program to read and display key metadata of an HDF5 file, including its signature and superblock information
#include <stdio.h>
#include <string.h> // For strncmp
#define SIGNATURE_SIZE 8
#define MAX_OFFSET 2048
int main() {
FILE* file = fopen("data.h5", "rb");
if (!file) {
printf("Unable to open file!\n");
@MohamedElashri
MohamedElashri / pytorch_CUDA12.1.sh
Created August 21, 2023 08:51
Install pytorch with CUDA12.1 driver (nightly build)
pip uninstall torch
pip cache purge
pip install torch torchvision --pre -f https://download.pytorch.org/whl/nightly/cu121/torch_nightly.html
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
@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