Skip to content

Instantly share code, notes, and snippets.

@orientalperil
orientalperil / .bash_aliases.sh
Last active May 3, 2026 20:26
Debian Bash Aliases
# Enable bash history
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
# general aliases
alias l="ls -lhaF"
alias u='cd ..'
alias uu='cd ../..'
alias uuu='cd ../../..'
alias uuuu='cd ../../../..'
@orientalperil
orientalperil / test_unmanaged_models.md
Created November 1, 2023 00:04 — forked from raprasad/test_unmanaged_models.md
Ignoring migrations during Django testing (unmanaged databases, legacy databases, etc)

Scenario

  • Django 1.9 application with two databases:
    • Legacy database with readonly access via unmanaged models. Both Django models (models.py) and related migrations have "managed" set to False
      • 'managed': False
    • Default database holding django specific tables (e.g. auth_user, django_content_type, etc)

Testing Woes

@orientalperil
orientalperil / multipartify.py
Created April 16, 2021 15:39 — forked from kazqvaizer/multipartify.py
Python dict to multipart/form-data converter to use it requests
"""
Here is a way to flatten python dictionaries for making multipart/form-data POST requests.
{"some": ["balls", "toys"], "field": "value", "nested": {"objects": "here"}}
->
{"some[0]": "balls", "some[1]": "toys", "field": "value", "nested[objects]": "here"}
@orientalperil
orientalperil / global-protect.sh
Last active April 11, 2021 05:43 — forked from kaleksandrov/global-protect.sh
Simple script that starts and stops GlobalProtect.app on Mac OSX.
#!/bin/bash
case $# in
0)
echo "Usage: $0 {start|stop}"
exit 1
;;
1)
case $1 in
start)
var convertStringToSeconds = function (s) {
var array = s.split(':');
array = array.map(function(x){return parseInt(x);});
var hours;
var minutes;
var seconds;
if (array.length === 2) {
hours = 0;
minutes = array[0];
seconds = array[1];
@orientalperil
orientalperil / gist:8c1abc94204053f23f849e63cef50fce
Created May 7, 2018 21:18
Convert ES6 string formatting to sprintf()
def find_string_formatting(text):
first = text.find('`')
second = text.find('`', first+1)
match = text[first:second+1]
match = match[1:len(match)-1]
vars = []
format_string = match
while '${' in format_string:
var = find_var(format_string)
vars.append(var)
@orientalperil
orientalperil / sssl.js
Last active September 20, 2015 03:27 — forked from aFarkas/sssl.js
simple, small script loader
/*!
* SSSL: smallest, simpelst script loader
* version: 1.0.1
*
* API:
* Normal usage
* sssl(source [,complete]);
*
* Example:
* sssl('jquery.js', function(){
@orientalperil
orientalperil / template_graph.py
Created December 10, 2014 18:15
Create Graphviz diagrams of Django templates
import os
import functools
import fnmatch
import re
import collections
import pydot
def Walk(root='.', recurse=True, *patterns):
"""
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite