Skip to content

Instantly share code, notes, and snippets.

View cherian's full-sized avatar

Cherian Thomas cherian

View GitHub Profile
def orientation(self):
exif = self._img._getexif()
if exif is None:
return 0
orientation = 0x0112
return exif.get(orientation, 0)
from PIL import Image
class CTImage(object):
def rotate(self, degree):
self._img = self._img.rotate(degree, expand=True)
(self.width,self.height) = self._img.size
return self
def orientation(self):
exif = self._img._getexif()
if exif is None:
return 0
import ExifTags
import Image
img = Image.open(filename)
print(img._getexif().items())
exif=dict((ExifTags.TAGS[k], v) for k, v in img._getexif().items() if k in ExifTags.TAGS)
if not exif['Orientation']:
img=img.rotate(90, expand=True)
img.thumbnail((1000,1000), Image.ANTIALIAS)
img.save(output_fname, "JPEG")
@cherian
cherian / .tmux.conf
Created June 1, 2012 00:24
Tmux config
set-option -g prefix `
set-option -g pane-active-border-fg green
set-option -g pane-active-border-bg yellow
#set-option -g pane-border-fg white
set-option -g pane-border-bg black
unbind %
bind-key s split-window
bind-key v split-window -h
@cherian
cherian / uri.js
Created May 9, 2012 04:35 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@cherian
cherian / eyewonder.js
Created October 26, 2011 03:23 — forked from kemayo/eyewonder.js
Eyewonder XSS
document.write('<style type="text/css">body{padding); margin:0}</style>');
document.write('<iframe id="iwonder_hack" src="http://' + location.host + '/" width="100%" height="100%" style="border:0;padding:0;margin:0"></iframe>');
setTimeout(function(){
var frmdoc = document.getElementsByTagName('iframe')[0].contentWindow.document
,rotation = 0
,links = frmdoc.getElementsByTagName('a')
,images = frmdoc.getElementsByTagName('img')
,props = ['transform', 'WebkitTransform', 'msTransform', 'MozTransform', 'OTransform']
,transform = function(elem, trans) {
for (var i = 0; i < props.length; i++) {
@cherian
cherian / .inputrc
Created September 13, 2011 02:23
Inputrc
set completion-ignore-case on
set completion-prefix-display-length 2
Control-j: menu-complete
Control-k: menu-complete-backward
set show-all-if-ambiguous on
set show-all-if-unmodified on
set completion-map-case on
@cherian
cherian / setup-statsd.sh
Created July 10, 2011 07:24 — forked from jqr/setup-statsd.sh
Minor changes to statsd installation
# install git
sudo apt-get install -y g++ curl libssl-dev apache2-utils
sudo apt-get install -y git-core
mkdir ~/src
cd ~/src
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
import sys
import os , shutil
rootdir = None
try:
rootdir = sys.argv[1]
except IndexError:
print 'Directory not specified. Specify it in the format ' + sys.argv[0] + ' c:\songs'
sys.exit()
if not os.path.isdir(rootdir):
@cherian
cherian / .vimrc
Created July 20, 2010 06:08
Cherian Vim settings
set ic
set lines=75
set history=1000
set incsearch
set shell=\"cmd.exe\"
set softtabstop=2
set nobomb
set nu
set smartcase
set scrolloff=2