This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function connectToCloudSQL() { | |
var params = { | |
ip: "INSERT IP", | |
user: "INSERT USER", | |
password: "INSERT PASSWORD", | |
database: "INSERT DATABASE" | |
} | |
var dbUrl = 'jdbc:mysql://' + params.ip + '/' + params.database; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: SSH tightening | |
hosts: all | |
sudo: True | |
tasks: | |
- name: Disable root's ssh account | |
action: > | |
lineinfile | |
dest=/etc/ssh/sshd_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import unicode_literals | |
from django.db import models | |
from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor # noqa | |
class RelationNotLoaded(Exception): | |
pass | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse_git_branch { | |
ref=$(git-symbolic-ref HEAD 2> /dev/null) || return | |
echo "("${ref#refs/heads/}")" | |
} | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
PS1="$RED\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)$GREEN[\h]\\$ " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CONFIGURATION FOR USING SMS KANNEL WITH RAPIDSMS | |
# | |
# For any modifications to this file, see Kannel User Guide | |
# If that does not help, see Kannel web page (http://www.kannel.org) and | |
# various online help and mailing list archives | |
# | |
# Notes on those who base their configuration on this: | |
# 1) check security issues! (allowed IPs, passwords and ports) | |
# 2) groups cannot have empty rows inside them! | |
# 3) read the user guide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you have more than one modem, I guess you can do thi in `RapidSMS` : | |
INSTALLED_BACKENDS = { | |
"message_tester": { | |
"ENGINE": "rapidsms.backends.database.DatabaseBackend", | |
}, | |
"kannel-usb0-smsc" : { | |
"ENGINE": "rapidsms.backends.kannel.KannelBackend", | |
"sendsms_url": "http://127.0.0.1:13013/cgi-bin/sendsms", | |
"sendsms_params": {"smsc": "usb0-modem", |
NewerOlder