Skip to content

Instantly share code, notes, and snippets.

View shahwan42's full-sized avatar

Ahmed Shahwan shahwan42

View GitHub Profile
@camara90100
camara90100 / remove_migrations
Created March 21, 2022 08:28
Remove (squash) Django Migrations without worrying about dependencies.
### Remote db state must be at the same exact state of the local DB
### Steps will be done on two stages:
### 1. local db stage
1. make sure you are in your django project path, and run `find . -path "*migrations*" -name "*.py" -not -path "*__init__*" -exec rm {} \;`
2. pip install --upgrade --force-reinstall Django, because this path usually removes django's own migrations.
3. Remove django migrations history table from your local database.
from django.db import connections
with connections["default"].cursor() as cursor:
@jefftriplett
jefftriplett / magic-link.py
Last active April 5, 2021 09:29
Django Management Command to print a "Magic Link" for one-click log-in. This is nice for people who project switch or don't want to remember passwords.
@mhashim6
mhashim6 / pi2.py
Created March 21, 2019 11:32
RaspberyPi-ultrasonic
import RPi.GPIO as GPIO
import time
TRIGGER = 18
ECHO = 24
GPIO.setmode(GPIO.BCM)
GPIO.setup(TRIGGER, GPIO.OUT)
GPIO.setup(ECHO, GPIO.IN)
@BenSampo
BenSampo / deploy.sh
Last active April 30, 2024 03:41
Laravel deploy script
# Change to the project directory
cd $FORGE_SITE_PATH
# Turn on maintenance mode
php artisan down || true
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin $FORGE_SITE_BRANCH
@oleoneto
oleoneto / nginx.conf
Last active October 1, 2020 11:16 — forked from asmallteapot/nginx.conf
Generic Nginx configuration for serving Django projects [updated]
# file: /etc/nginx/sites-available/example.com
# nginx configuration for example.com
server {
listen 80;
server_name example.com;
access_log /var/www/example.com/logs/access.log;
error_log /var/www/example.com/logs/error.log;
# pass root to django
@SanderTheDragon
SanderTheDragon / postman-deb.sh
Last active April 3, 2024 05:30
A shellscript to create a Postman .deb file, for simple installation on Debian-based Linux distro's. Also creates a .desktop file.
#!/bin/sh
# SPDX-FileCopyrightText: 2017-2022 SanderTheDragon <sanderthedragon@zoho.com>
#
# SPDX-License-Identifier: MIT
curlExists=$(command -v curl)
echo "Testing Postman version"

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by