Skip to content

Instantly share code, notes, and snippets.

View Hazem-Ben-Khalfallah's full-sized avatar

Hazem Ben Khalfallah Hazem-Ben-Khalfallah

View GitHub Profile
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / disable_foreign_key_constraint.sql
Last active November 15, 2025 06:09
[Disable a foreign key constraint in MySQL] #sql #mysql
#disable
SET FOREIGN_KEY_CHECKS=0;
#reenable
SET FOREIGN_KEY_CHECKS=1;
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / git-credentials.sh
Created May 17, 2019 10:17
[Save git credentials] I want to use a push and pull automatically without entering my user and password in a prompt, every time. #git
# run
git config credential.helper store
#then
git pull
# user credentials will be saved in ~/.git-credentials in PLAIN text
# if user credentials are changed in the future, simply execute
git pull
# and provide a new password and it will work like before.
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / arguments.sh
Last active January 2, 2019 15:32
[Bash args] Bash positional arguments and command line options usage #linux #bash
#see link: http://linuxcommand.org/lc3_wss0120.php
# Positional args
# $#: number of items on the command line in addition to the name of the command
# $0: name of the command
> some_program word1 word2 word3
# $# would be 3
# $0 would contain "some_program"
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / connect-ssh.sh
Created December 26, 2018 10:50
[Connect via ssh using pem key] Connect to a remote server via #ssh using a pem key #linux
ssh -i ~/.ssh/[KEY_NAME].pem [REMOTE_USER]@[SERVER_IP_or_DNS]
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / pc type.sh
Last active December 17, 2018 09:10
[PC model] get PC model #linux
sudo lshw | grep product
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / env vs arg in Docker
Last active November 5, 2018 15:53
[Docker ARG vs ENV] #docker
https://vsupalov.com/docker-arg-env-variable-guide/
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / port usage detection.sh
Last active August 31, 2018 14:21
[Port usage] Check if a port is being used #linux
sudo lsof -i :8080
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / remove a big file.sh
Last active August 31, 2018 14:21
[remove a big file] remove a big file quickly #linux
ls -il [FILE_PATH]
sudo find [PARENT_DIRETORY] -inum [FILE_INUM] -exec rm -i {} \;
exemple:
>ls -il test.txt
1135865 -rw-r--r-- 1 user user 4525 Nov 15 2017 test.csv
>sudo find /home/user/folder -inum 1135865 -exec rm -i {} \;
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / disk space usage.sh
Last active August 31, 2018 14:20
[Disk usage] command-line disk usage analyser #linux
ncdu
@Hazem-Ben-Khalfallah
Hazem-Ben-Khalfallah / remote-branche-list.sh
Last active August 31, 2018 14:26
[Formatted list remote branches] list remote git branches ordered by username. This command will display: last modification - author - branch name #git
git for-each-ref --format='%(color:cyan)%(authordate)) %(color:yellow)%(authorname) %(color:reset)%(refname)' --sort=authorname refs/remotes