Skip to content

Instantly share code, notes, and snippets.

View alidevhere's full-sized avatar
🏠
Working from home

mohammad ali alidevhere

🏠
Working from home
View GitHub Profile
@alidevhere
alidevhere / gist:1cb1e05c2182bd671e4f5fe2e7ea2c37
Created March 7, 2023 18:05
Install Latest protocol buffer
https://lindevs.com/install-protoc-on-ubuntu

Turn on keyboard lights on ubuntu

Install brightnessctl

sudo apt update
sudo apt install brightnessctl

@alidevhere
alidevhere / update-golang.md
Created January 25, 2023 21:32 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@alidevhere
alidevhere / python-docker.yml
Last active November 13, 2022 15:23
we can't activate venv, we are doing what source activate will do
#FROM python:3.9-slim-bullseye
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install dependencies:
#COPY requirements.txt .
#RUN pip install -r requirements.txt
// sleep function is updated as below
func sleepForWait(ctx context.Context,t time.Duration) {
select {
case <-ctx.Done():
return
case <-time.After(t):
return
}
}
@alidevhere
alidevhere / sleep.go
Last active September 23, 2022 15:05
func sleepForWait(t time.Duration) {
for startTime := time.Now(); time.Since(startTime) < t; time.Sleep(10 * time.Second) {
if !*IsCampaigRunning {
// We use logrus for logging
logrus.Info("LEFT SLEEPING !!! IMMEDIATELY STOPING CAMPAIGNS PROCESSING")
return
}
}
}

Run Azure Power shell commands from Linux - Ultimate Guide:

Install Powershell on linux

# Update the list of packages
sudo apt-get update

# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common

Append to file in go

f, err := os.OpenFile("text.log",
	os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
	log.Println(err)
}
defer f.Close()
if _, err := f.WriteString("text to append\n"); err != nil {
	log.Println(err)
@alidevhere
alidevhere / ft2build_sol.md
Created August 3, 2022 06:23
setup-python-3.8.13-linux-x86_64: will use package libart 2.3.21 cannot find ft2build.h

This error occurs when trying to install reportlab on alpine image in docker:

Alpine image has some missing dependencies for reportlab, add following command too before installing reportlab

apk add python3-dev freetype-dev
@alidevhere
alidevhere / reset_Django_Migrations.md
Last active May 28, 2022 10:51
Reset Django Database migrations

Reset Django Migrations

1-Delete Schemma 2- find . -path "/migrations/.py" -not -name "init.py" -delete 3- find . -path "/migrations/.pyc" -delete 4- python manage.py makemigrations 5- python manage.py migrate