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 / parsejson.js
Last active November 5, 2015 09:28
when jQuery.parseJSON() throws an invalid json excepion for a Json retrieved from a django backend
// get the json object in the django template :
var data = "{{object|safe}}";
// Parse the JSON data
try
{
// Use jquery's default parser
data = $.parseJSON(data);
}
catch(e)
{
@srugano
srugano / add_key.sh
Created December 16, 2015 11:09
Add secret keys to a Django environmet on Heroku
heroku config:set SECRET_KEY=`openssl rand -base64 32`
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",
@srugano
srugano / kannel.conf
Last active October 29, 2021 08:05
Example of Kannel configurations to be used with a Huawei modem.
# 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
@srugano
srugano / bashrc
Last active May 24, 2019 11:48
Color prompts I use in all my machines
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]\\$ "
@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