Skip to content

Instantly share code, notes, and snippets.

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

Milad Rahimi miladrahimi

🏠
Working from home
View GitHub Profile
@miladrahimi
miladrahimi / @ Set Up Debian Server As A Router with NAT .sh
Last active November 24, 2024 22:23
Set Up Debian Server As A Router with NAT
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ens192 -j MASQUERADE
iptables -A INPUT -i ens224 -j ACCEPT
iptables -A INPUT -i ens192 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -j ACCEPT
@ssi-anik
ssi-anik / Dockerfile
Created June 27, 2020 19:17
PHP dockerfile for rdkafka/kafka/libkafka
FROM php:7.4-fpm
RUN apt-get update
RUN apt-get install -y librdkafka-dev
RUN pecl install channel://pecl.php.net/rdkafka-beta
RUN rm -rf /tmp/pear
@miladrahimi
miladrahimi / @ Revert changed file permissions in Git (before commit).bash
Last active March 10, 2023 09:12
Revert changed file permissions in Git (before commit)
git diff -p \
| grep -E '^(diff|old mode|new mode)' \
| sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/' \
| git apply
@miladrahimi
miladrahimi / @ Config LVM to use all available space
Last active March 10, 2023 09:12
Extend LVM to use all the remained space on Ubuntu
It is a few commands that you can run to configure LVM to use all the available space left on the device (server).
$ lvm
lvm> lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
lvm> exit
$ resize2fs /dev/ubuntu-vg/ubuntu-lv
$ df -h
@aymericbeaumet
aymericbeaumet / delete-likes-from-twitter.md
Last active May 3, 2025 05:36
[Recipe] Delete all your likes/favorites from Twitter

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
    d.click()
 }
@andre3k1
andre3k1 / install-gnu-sed-on-mac-osx.sh
Created July 26, 2018 18:39
How to install gnu sed on Mac OS X and set it as the default
# Check which version of sed is used when you run the `sed` command
# The version that ships with Mac OS X is
# /usr/bin/sed
which sed
# Install gnu-sed using Homebrew
# The `--with-default-names` option configures `sed` to use gnu-sed
# Without that option, you'll need to type `gsed` to use gnu-sed
brew install --default-names gnu-sed
@chronon
chronon / ext.txt
Created February 18, 2017 15:38
List of docker-php-ext-install extension names
Possible values for ext-name:
bcmath
bz2
calendar
ctype
curl
dba
dom
enchant
@wojteklu
wojteklu / clean_code.md
Last active May 9, 2025 18:43
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@alibo
alibo / iran-sanctions_blocker-sites.csv
Last active February 17, 2025 13:58
List of sites which block IPs come from Iran [UPDATING... (July 16, 2020)] #SANCTIONS
Title URI
Flurry by Yahoo https://dev.flurry.com/secure/signup.do
Google NikCollection https://dl.google.com/edgedl/photos/nikcollection-full-1.2.11.dmg
Bitbucket http://bitbucket.org/
SoftLayer http://softlayer.com/
VirtualBox http://download.virtualbox.org/virtualbox/5.0.16/VirtualBox-5.0.16-105871-OSX.dmg
Docker Hub https://hub.docker.com/
Oracle http://oracle.com/
Java http://java.com
Sun http://sun.com
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE