Skip to content

Instantly share code, notes, and snippets.

View MohamedElashri's full-sized avatar

Mohamed Elashri MohamedElashri

View GitHub Profile
@MohamedElashri
MohamedElashri / Fix.md
Last active May 7, 2023 04:45
[fix AttributeError: 'Polygon'] object has no property 'normed' #python

To fix the problem with matplotlib in some of coursera assignments with AttributeError: 'Polygon' object has no property 'normed'

we just need to chage normed=True with density=True

That's all you need.

@MohamedElashri
MohamedElashri / Workaround.md
Last active April 2, 2024 05:18
[Prevent Colab from sleeping]

run the following code in the console and it will prevent you from disconnecting.

  1. Ctrl+ Shift + i to open inspector view .
  2. go to console.
function ClickConnect(){
    console.log("Working"); 
    document.querySelector("colab-toolbar-button#connect").click() 
}
setInterval(ClickConnect,60000)
@MohamedElashri
MohamedElashri / overleaf_download.sh
Created March 15, 2021 02:57
Download all projects on overleaf all at once. #python
#!/bin/bash
now=`date +"%Y-%m-%d"`
directory=~/Documents//Overleaf/backup
outputTmpDirectory=$directory/tmp.zip
outputDirectory=$directory/$backup.zip
# To get the cookie
cookie=`python - << EOF
import re
# pip install mechanize
@MohamedElashri
MohamedElashri / invalid active developer path.md
Created March 15, 2021 09:05
Mac OS: xcrun: error: invalid active developer path, missing xcrun #Mac

When trying to install ROOT I ran into this error

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

To solve the problem I had to re-install developer toolkit

xcode-select --install

In case this doesn't work you can force reset.

@MohamedElashri
MohamedElashri / ROOT-Colab.sh
Last active March 20, 2025 23:01
Run ROOT on google colab, working with python 3.11 [latest python version on Colab]. More information at https://melashri.net/ROOT
# Step 1: Download the pre-built ROOT tarball from GitHub Releases
!wget -q --show-progress https://github.com/MohamedElashri/ROOT/releases/download/v6.30.04_python11/root_v6.30.04_Ubuntu_Python3.11.zip
# Step 2: Extract the ROOT files
!unzip -q root_v6.30.04_Ubuntu_Python3.11.zip
# Step 3: Install missing system dependencies for ROOT
!sudo ldconfig & apt-get install -y git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev tar gfortran subversion libpython3.11-dev
@MohamedElashri
MohamedElashri / time().py
Created April 12, 2021 18:08
How long python script takes to execute ? #python
import timeit
code_to_test = """
a = range(100000)
b = []
for i in a:
b.append(i*2)
"""
@MohamedElashri
MohamedElashri / code.md
Last active May 10, 2021 15:59
Use homebrew python #Mac #Python

Add this to .zshrc by

runnning nano .zshrc

Add this to the file

export PATH="/usr/local/opt/python/libexec/bin:$PATH"
@MohamedElashri
MohamedElashri / workaround.md
Last active June 23, 2021 17:12
NPM another instance bug

To renew or add new ssl certificates for now I have to do the following

  1. Run ps -ef | grep certb
  2. Identify the looping process
  3. Kill it using kill <process id>

Hint: In my case, usually it is the second process

root 25614 24813 0 17:54 ? 00:00:00 /bin/sh -c /opt/certbot/bin/certbot renew --non-interactive --config "/etc/letsencrypt.ini" --cert-name "npm-16" --preferred-challenges "dns,http" --disable-hook-validation 
@MohamedElashri
MohamedElashri / color_diff.md
Last active May 26, 2021 05:50
Create alias to show diff in colors #terminal

grc works great for this. It is installable with brew and colorizes a number of terminal commands out of the box, diff being one of them. To build on the approved answer: grc works great for this. It is installable with brew and colorizes a number of terminal commands out of the box, diff being one of them.

  1. First install grc via homebrew

brew install grc

  1. Then you need to set up your aliases, the brew caveat provides a solution. Simply add the following line to your ./bashrc or ./bash_profile

source "`brew --prefix`/etc/grc.bashrc"

@MohamedElashri
MohamedElashri / customization.md
Last active May 26, 2021 10:05
nano editor customization #syntax-highlighting
  1. Install Homebrew if you don't already have it: http://mxcl.github.io/homebrew/

  2. Install nano from homebrew brew install nano

  3. Update your nanorc file with the contents of the nanorc file below nano ~/.nanorc

  4. Add custom syntax files to nanorc include /opt/homebrew/Cellar/nano/5.7/share/nano/*.nanorc