Eran Sandler erans

View encrypt_decrypt_example.js
1 2 3 4 5 6 7 8 9
var crypto = require("crypto")
 
function encrypt(key, data) {
var cipher = crypto.createCipher('aes-256-cbc', key);
var crypted = cipher.update(text, 'utf-8', 'hex');
crypted += cipher.final('hex');
 
return crypted;
}
View UIImage+Resize.m
1 2 3 4 5 6 7 8 9 10
- (UIImage *)resizedImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality {
BOOL drawTransposed;
CGAffineTransform transform = CGAffineTransformIdentity;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
// Apprently in iOS 5 the image is already correctly rotated, so we don't need to rotate it manually
drawTransposed = NO;
} else {
switch (self.imageOrientation) {
case UIImageOrientationLeft:
View s3clonebucket.py
1 2 3 4 5 6 7 8 9 10
import argparse
 
from boto.s3.connection import S3Connection
from boto.exception import S3ResponseError
 
def run(args):
s3_connection = S3Connection(args.aws_access_key, args.aws_secret_access_key)
source_bucket = s3_connection.get_bucket(args.source_bucket)
destination_bucket = None
try:
View gmail_email.py
1 2 3 4 5 6 7 8 9 10
import sys
import re
import dns.resolver # Requires dnspython
 
email_host_regex = re.compile(".*@(.*)$")
gmail_servers_regex = re.compile("(.google.com.|.googlemail.com.)$", re.IGNORECASE)
 
def is_gmail(email):
""" Returns True if the supplied Email address is a @gmail.com Email or is a Google Apps for your domain - hosted Gmail address
Checks are performed by checking the DNS MX records """
View kestrel.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/sh
#
# kestrel init.d script.
#
# All java services require the same directory structure:
# /usr/local/$APP_NAME
# /var/log/$APP_NAME
# /var/run/$APP_NAME
 
APP_NAME="kestrel"
View get_lat_lon_exif_pil.py
1 2 3 4 5 6 7 8 9 10
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
 
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
Something went wrong with that request. Please try again.