Skip to content

Instantly share code, notes, and snippets.

Hiring developers in Oakland and the Bay area!

Eran Sandler erans

Hiring developers in Oakland and the Bay area!
View GitHub Profile
erans /
Created May 20, 2011
Get Latitude and Longitude from EXIF using PIL
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)
erans /
Created Jun 28, 2011
Twitter’s Kestrel init script for Ubuntu 10.04 Lucid
# kestrel init.d script.
# All java services require the same directory structure:
# /usr/local/$APP_NAME
# /var/log/$APP_NAME
# /var/run/$APP_NAME
erans /
Created Jul 17, 2011
Check if an Email address is Gmail or Google Apps for your domain
import sys
import re
import dns.resolver # Requires dnspython
email_host_regex = re.compile(".*@(.*)$")
gmail_servers_regex = re.compile("(|$", re.IGNORECASE)
def is_gmail(email):
""" Returns True if the supplied Email address is a Email or is a Google Apps for your domain - hosted Gmail address
Checks are performed by checking the DNS MX records """
erans /
Last active Apr 25, 2020
Clone S3 Bucket
import argparse
import time
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
erans / UIImage+Resize.m
Created Nov 7, 2011
UIImage+Resize.m Fix for Rotation / Orientation on iOS 5
View UIImage+Resize.m
- (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:
erans / encrypt_decrypt_example.js
Last active Sep 13, 2022
Example of encryption and decryption in node.js
View encrypt_decrypt_example.js
var crypto = require("crypto")
function encrypt(key, data) {
var cipher = crypto.createCipher('aes-256-cbc', key);
var crypted = cipher.update(data, 'utf-8', 'hex');
crypted +='hex');
return crypted;
erans / alert_areas_to_city_mappings
Created Jul 10, 2014
מיפוי איזורי התראה לערים
View alert_areas_to_city_mappings
var cities = [{label:"א דהאבשה", value:"124"},
{label:"א דיראת", value:"122"},
{label:"א דנפירי", value:"205"},
{label:"א זיאדנה דרומית לרהט", value:"179"},
{label:"א זיאדנה צפונית לרהט", value:"179"},
{label:"א זעיים", value:"96"},
{label:"א טבקה", value:"122"},
{label:"א טוואני", value:"122"},
{label:"א לובאן", value:"92"},
{label:"א נבארי", value:"199"},
erans /
Last active Oct 7, 2019
MongoDB ReplicaSet Backup Script on Google Compute Engine and Google Cloud Storage
# Path to boto config file, needed by gsutils
# Path in which to create the backup (will get cleaned later)
# DB name
# Google Cloud Storage Bucket Name
erans / main.go
Last active Jun 23, 2021
Go Example: Google CloudSQL with CloudSQL Proxy and GORM
View main.go
package main
import (
_ "database/sql"
_ ""
// You can read more in this post:
func main() {
erans / json-unmarshal-test.go
Created Jul 18, 2016
Unmarshaling JSON text with a long integer number to Struct with field of type interface{}
View json-unmarshal-test.go
package main
import (
type container struct {
Name string
Value interface{}