Nipon

Wednesday, November 28, 2012

Problem with opening iWeb files on Mac OS 10.7

Problem: When I open a previously designed homepage with iWeb it opens the default website

Solution: Copy your iweb file to "Home/Library/Application Support/iWeb/" and rename it to "Domain". Unfortunately you have to do this everytime you want to switch your file.

Thursday, November 08, 2012

Permutation in Python using arrays


def perms(X, perm_sample= array([],'uint8') , allPerms = None,ind = 0):
    # Returns all permutations and number of permutations
    # X = [2 3]
    # res,perm_count = ([[0,0],[0,1],[0,2],[1,0],[1,1],[1,2], 6)
    
    if allPerms is None:
        #Get memory
        size        = prod(X)
        allPerms    = zeros((size,len(X)),'uint8')
    if len(X) == 0:
        allPerms[ind,:] = perm_sample
        perm_sample = array([],'uint8')
        ind = ind + 1;
    else:
        for x in arange(X[0]):
            allPerms, ind = perms(X[1:],hstack((perm_sample, [x])), allPerms, ind)
    return allPerms, ind