Skip to content

Instantly share code, notes, and snippets.

View srugano's full-sized avatar
😀
I may be slow to respond.

Allan Stockman RUGANO srugano

😀
I may be slow to respond.
View GitHub Profile
@srugano
srugano / recuperation
Last active December 26, 2015 23:38
recouvrir un fichier que vous avez déjà supprimé sous git
Premièrement si vous n’êtes pas sur du nom du fichier supprimé, vous pouvez le retrouver dans les logs de git ...
git log --diff-filter=D --summary
Puis retrouvez le dernier commit qui a affecté le fichier
git rev-list -n 1 HEAD -- ./path/to/file/
.. on va appeler cela par [NUMERO_DE _REVISION]
@srugano
srugano / models.py
Created December 20, 2018 13:38 — forked from kyle-eshares/models.py
Strict ForeignKeys
from __future__ import unicode_literals
from django.db import models
from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor # noqa
class RelationNotLoaded(Exception):
pass
@srugano
srugano / playbook.yml
Created January 13, 2019 15:19 — forked from marklit/playbook.yml
Setup a load-balanced, two-node Django cluster
---
- name: SSH tightening
hosts: all
sudo: True
tasks:
- name: Disable root's ssh account
action: >
lineinfile
dest=/etc/ssh/sshd_config
function connectToCloudSQL() {
var params = {
ip: "INSERT IP",
user: "INSERT USER",
password: "INSERT PASSWORD",
database: "INSERT DATABASE"
}
var dbUrl = 'jdbc:mysql://' + params.ip + '/' + params.database;
@srugano
srugano / update_git_repos.sh
Created April 26, 2021 12:12 — forked from douglas/update_git_repos.sh
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
@srugano
srugano / remove_duplicates.py
Created September 27, 2021 11:24 — forked from victorono/remove_duplicates.py
Django - remove duplicate objects where there is more than one field to compare
from django.db.models import Count, Max
unique_fields = ['field_1', 'field_2']
duplicates = (
MyModel.objects.values(*unique_fields)
.order_by()
.annotate(max_id=Max('id'), count_id=Count('id'))
.filter(count_id__gt=1)
)
@srugano
srugano / noroot_tcpdump.sh
Created October 9, 2021 12:23
Enable tcpdump for non-root users on Debian/Ubuntu.
#!/usr/bin/env bash
# NOTE: This will let anyone who belongs to the 'pcap' group
# execute 'tcpdump'
# NOTE2: User running the script MUST be a sudoer. It is
# convenient to be able to sudo without a password.
sudo groupadd pcap
sudo usermod -a -G pcap $USER
@srugano
srugano / custom_django_checks.py
Created July 2, 2022 08:49 — forked from hakib/custom_django_checks.py
Custom django checks using Django check framework, inspect and ast.
"""
Custom django checks.
H001: Field has no verbose name.
H002: Verbose name should use gettext.
H003: Words in verbose name must be all upper case or all lower case.
H004: Help text should use gettext.
H005: Model must define class Meta.
H006: Model has no verbose name.
H007: Model has no verbose name plural.