Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
@mdeous
mdeous / pgmigrate.sh
Created February 2, 2014 13:31
Automated schema migration for PostgreSQL
#!/bin/bash
#
# Script: pgmigrate.sh
# Author: Mathieu D. (MatToufoutu)
# Description: Automated schema migration for PostgreSQL
# Usage: ./pgmigrate.sh DATABASE MIGRATIONS_FOLDER
#
# Details:
# Just store the .sql migrations scripts in a folder, file
# names must be incremental numbers (1.sql, 2.sql, ...).
@mdeous
mdeous / color.py
Created January 5, 2014 15:45
Python Shell Output Color
COLOR_CODES = {
'green': '\033[32m',
'bgreen': '\033[1;32m',
'bgrey': '\033[1;30m',
'reset': '\033[0m'
}
def color(text, color_name):
return COLOR_CODES[color_name]+text+COLOR_CODES['reset']
@mdeous
mdeous / curly.py
Created December 26, 2013 18:32
Si t'as une API, prend un curly!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# curly.py - Easily communicate with JSON APIs.
#
# TODO:
# - allow any http method
# - output equivalent curl command
# - allow http basic auth
#
@mdeous
mdeous / restest.py
Created December 25, 2013 17:11
Easily communicate with JSON APIs
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# restest.py - Easily communicate with JSON APIs.
#
import sys
from argparse import ArgumentParser
from urllib import urlencode
from urllib2 import build_opener, HTTPError
@mdeous
mdeous / singleton.py
Created December 24, 2013 17:05
Python Implementation of the Singleton Design Pattern
class Singleton(type):
def __init__(cls, *args, **kwargs):
# When creating the class object (class ClassName), set the shared instance variable.
super(Singleton, cls).__new__(*args, **kwargs)
cls.__instance = None
def __call__(cls, *args, **kwargs):
# When instanciating (obj = ClassName()), return shared instance (or create it if 1st time).
if cls.__instance is None:
cls.__instance = super(Singleton, cls).__call__(*args, **kwargs)
@mdeous
mdeous / gist:7750103
Last active December 30, 2015 00:29
zsh theme
function loadavg_info() {
local -h one five fifteen rest
read one five fifteen rest < /proc/loadavg
print "$one $five $fifteen"
}
function prompt_char {
if [[ `whoami` == 'root' ]]; then
print "#"
else
import os
from time import sleep
file_path = '/foo/bar/suce.txt'
while True:
if os.path.exists(file_path):
data = open(file_path).read()
# faire des trucs avec le contenu du fichier ici
break
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from threading import Thread
from Queue import Empty, Queue
from urlparse import urlparse
todo = Queue()
-N PORTSCAN
-A PORTSCAN -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
-A PORTSCAN -p tcp --tcp-flags ALL ALL -j DROP
-A PORTSCAN -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
-A PORTSCAN -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A PORTSCAN -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP