Skip to content

Instantly share code, notes, and snippets.

@blackstrip
blackstrip / logger_utils.py
Created November 25, 2022 02:54 — forked from tapanhp/logger_utils.py
Python Logging module utilities
import datetime
import logging
import os
import re
import constants
log_separator = "\n===================================================================================================="
@blackstrip
blackstrip / postgres-json-cheatsheet.md
Created August 11, 2019 13:43 — forked from rmtsrc/postgres-json-cheatsheet.md
Using JSON in Postgres by example

PostgreSQL JSON Cheatsheet

Using JSON in Postgres by example.

Quick setup via Docker

  1. Download and install: Docker Toolbox
  2. Open Docker Quickstart Terminal
  3. Start a new postgres container:
    docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
@blackstrip
blackstrip / lighter-graphite-rpi.sh
Created September 18, 2017 02:38 — forked from rothwerx/lighter-graphite-rpi.sh
Bash: Graphite for Raspbian
#!/bin/bash
# A lighter graphite for raspberry pi/raspbian wheezy.
# For when you don't need memcache/rabbitmq/full uWSGI server/etc
# Not fully tested on a clean install. This is just what it *should* take.
# Installing supervisor because upstart conflicts with sysvinit
aptitude update && aptitude install gcc python-dev python-pip python-cairo python-pysqlite2 supervisor
pip install django==1.4.3

Set up L2TP/IPsec VPN on Debian

Set up IPsec

Set up networking

@blackstrip
blackstrip / lpm.py
Created November 22, 2016 15:24 — forked from aleksclark/lpm.py
Little Ping Monitor in python
# get this: https://github.com/jedie/python-ping.git
import os
import string
from time import time, sleep
from ping import Ping
class QuietPing(Ping):
def print_failed(self):
@blackstrip
blackstrip / index.php
Created November 4, 2015 14:48 — forked from ziadoz/index.php
Simple PHP / jQuery CSRF Protection
<?php
// See: http://blog.ircmaxell.com/2013/02/preventing-csrf-attacks.html
// Start a session (which should use cookies over HTTP only).
session_start();
// Create a new CSRF token.
if (! isset($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = base64_encode(openssl_random_pseudo_bytes(32));
}