Skip to content

Instantly share code, notes, and snippets.

View ehsania's full-sized avatar

Ali Ehsanfar ehsania

View GitHub Profile
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com
@ehsania
ehsania / maximum subarray.py
Created May 30, 2013 17:16
Simple implementation of maximum subarray (divide-and-conquer) in python
def findMaxCrossingSubArray(lst, low, high, mid):
l, h = 0, 0
i = mid
s = 0
leftsum = lst[i] - 1
while i >= low:
s = s + lst[i]
if s > leftsum:
leftsum = s
l = i
@ehsania
ehsania / merge sort.py
Created May 28, 2013 19:05
Simple implementation of merge sort in python
def merge_sort(lst):
if len(lst) <= 1 :
return lst
left = merge_sort(lst[:len(lst)/2])
right = merge_sort(lst[len(lst)/2:])
return merge(left, right)
def merge(left, right):
lst = []
while len(left) > 0 and len(right) > 0:
@ehsania
ehsania / insertion sort.py
Last active December 17, 2015 19:50
Very simple implementation of "Insertion sort" in python
def insertion_sort(lst):
for i in xrange(1,len(lst)):
for j in xrange(0,i):
if lst[i] < lst[j]:
lst[i], lst[j] = lst[j], lst[i]
return lst