Skip to content

Instantly share code, notes, and snippets.

View iandexter's full-sized avatar

Ian Dexter D Marquez iandexter

View GitHub Profile
@iandexter
iandexter / appname.wsgi
Created July 26, 2013 00:55
Using Flask in a virtual env on Python 2.6 mod_wsgi on RHEL 5.7. python26-mod_wsgi is part of EPEL.
# -*- coding: utf-8 -*-
import os
import sys
import site
import logging
site.addsitedir('/path/to/venv/lib/python2.6/site-packages')
sys.path.append('/path/to/venv')
sys.path.append('/path/to/venv/appname')
@iandexter
iandexter / avi2mp4.sh
Created July 9, 2013 03:15
ffmpeg conversions
#!/bin/bash
#
usage() {
echo "Usage: `basename $0` filename";
}
[ $# -eq 0 ] && usage && exit 65;
fn=`basename "$1" .avi`
@iandexter
iandexter / gencrypt.py
Last active December 19, 2015 06:59
Ansible playbook and helper script for resetting passwords.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Encrypt password for use with Ansible playbooks.
"""
import getpass
import random
import crypt
@iandexter
iandexter / xmlrpcclient.py
Created July 3, 2013 03:12
Simple XML-RPC server/client for remote execution of system calls.
#!/usr/bin/env python
# -*- coding: utf-8 -*
"""
Client for demonstrating XML-RPC Python calls.
"""
import xmlrpclib, sys
server_url = 'http://localhost:8888'
@iandexter
iandexter / list_routes.py
Last active December 18, 2015 20:29
List available routes, and the respective "help text" from the endpoints.
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/api', methods = ['GET'])
def this_func():
"""This is a function. It does nothing."""
return jsonify({ 'result': '' })
@app.route('/api/help', methods = ['GET'])
@iandexter
iandexter / date_photo.sh
Last active December 12, 2015 02:18
Date a photo using EXIF timestamp.
for img in *.JPG ; do
fn=$(basename ${img} .JPG);
convert ${fn}.JPG ${fn}.exif;
tstamp=$(strings ${fn}.exif | grep -E "^[0-9]{3}.*\:.*" | head -1 | sed 's/:/\//' | sed 's/:/\//');
[[ -n "${tstamp}" ]] && tdate=$(date -d "${tstamp}" +"%d %b %Y %H:%M") || tdate="";
if [[ -n "${tdate}" ]] ; then
touch -d "${tdate}" ${fn}.JPG;
status="Touched"
else
status="";
yum install httpd yum-utils createrepo
for img in IMG*.jpg; do
fn=$(basename ${img} .jpg)
convert ${fn}.jpg ${fn}.exif
tstamp=$(strings ${fn}.exif | grep -E "^[0-9].*\:.*")
convert ${fn}.jpg -fill red -gravity South -pointsize 72 -annotate +0+5 "${tstamp}" annotated_${fn}.jpg
rm -f ${fn}.exif
done
# cd /var/tmp
# wget http://kojipkgs.fedoraproject.org//packages/libimobiledevice/1.1.1/3.fc16/i686/libimobiledevice-1.1.1-3.fc16.i686.rpm
# yum localinstall libimobiledevice-1.1.1-3.fc16.i686.rpm
cd ~/bin
curl -0 http://gdata-python-client.googlecode.com/files/gdata-2.0.17.tar.gz | tar -xz
cd gdata-2.0.17
python setup.py install --home=~
cd ..
curl -0 http://googlecl.googlecode.com/files/googlecl-0.9.13.tar.gz | tar -xz
cd googlecl-0.9.13
python setup.py install --home=~