Skip to content

Instantly share code, notes, and snippets.

View arsham's full-sized avatar

Arsham Shirvani arsham

View GitHub Profile
@arsham
arsham / TwoSpacesToFourIndention.sublime-macro
Created January 7, 2015 11:52
A Sublime Text Macro to convert 2 spaces indentions to 4
[
{
"args": null,
"command": "select_all"
},
{
"args": {
"setting": "tab_size",
"value": 2
},
@arsham
arsham / md5dir
Created January 12, 2015 10:30
Returns the md5sum of the folder. It's recursive
#!/bin/bash
find $1/ -type f -exec md5sum {} + | awk '{print $1}' | sort | md5sum
@arsham
arsham / install_package_in_env_env
Last active August 29, 2015 14:14
Installing external package in virtualenv for edit purposes
# Do this in your environment
python setup.py develop --install-dir /path/to/virtualen/lib/python3.4/site-packages
# or: python setup.py develop --multi-version --exclude-scripts --install-dir /path/to/virtualen/lib/python3.4/site-packages
@arsham
arsham / database_size
Last active August 29, 2015 14:14 — forked from cmlenz/gist:1992369
-- PostgreSql
SELECT
pg_database.datname AS "Database Name",
pg_database_size(pg_database.datname) / 1024.0 / 1024.0 AS "Database Size (MB)"
FROM pg_database;
-- MySql
SELECT
table_schema "Database Name",
sum( data_length + index_length ) / 1024 / 1024 "Database Size (MB)"
//This function was used in my test rig to convert elasticsearch results to a KML structure which is
// later fed to an iFrame wrapping the GoogleEarth plugin
var data=[];
var buckets=inData.aggregations.map.buckets;
function addCommas(nStr)
{
nStr += '';
@arsham
arsham / update_auto_val
Created March 6, 2015 09:09
Updates the incremental value of the PK.
SELECT setval('TEABLE_NAME_id_seq', (SELECT MAX(id) FROM TEABLE_NAME));
@arsham
arsham / python_email_debugger
Created March 6, 2015 09:14
Python SMTP debugger in shell
#!/bin/bash
python -m smtpd -n -c DebuggingServer localhost:1025
@arsham
arsham / request_generator.py
Created March 6, 2015 17:16
Creates a django request object for test purposes
from django.test.client import RequestFactory
factory = RequestFactory()
request = factory.get('/')
@arsham
arsham / list_ssh_tunnels
Created April 1, 2015 13:23
Lists ssh tunnles
sudo lsof -i -n | egrep '\<ssh\>'
@arsham
arsham / purge_queue.sh
Created April 20, 2015 09:42
Purges a rabbimq queue with celery
manage.py celery amqp queue.purge <QUEUE_NAME>