code
stringlengths
1
1.72M
language
stringclasses
1 value
import struct from Crypto.Cipher import AES """ http://www.ietf.org/rfc/rfc3394.txt quick'n'dirty AES wrap implementation used by iOS 4 KeyStore kernel extension for wrapping/unwrapping encryption keys """ def unpack64bit(s): return struct.unpack(">Q",s)[0] def pack64bit(s): return struc...
Python
from Crypto.Cipher import AES ZEROIV = "\x00"*16 def removePadding(blocksize, s): 'Remove rfc 1423 padding from string.' n = ord(s[-1]) # last byte contains number of padding bytes if n > blocksize or n > len(s): raise Exception('invalid padding') return s[:-n] def AESdecryptCBC(da...
Python
#!/usr/bin/env python import sys, os from PyQt4 import QtGui, QtCore from backups.backup4 import MBDB from keychain.keychain4 import Keychain4 from util.bplist import BPlistReader from keystore.keybag import Keybag from util import readPlist class KeychainTreeWidget(QtGui.QTreeWidget): def __init__(sel...
Python
import base64 def chunks(l, n): return (l[i:i+n] for i in xrange(0, len(l), n)) def RSA_KEY_DER_to_PEM(data): a = ["-----BEGIN RSA PRIVATE KEY-----"] a.extend(chunks(base64.b64encode(data),64)) a.append("-----END RSA PRIVATE KEY-----") return "\n".join(a) def CERT_DER_to_PEM(data): ...
Python
import struct def tlvToDict(blob): d = {} for tag,data in loopTLVBlocks(blob): d[tag] = data return d def tlvToList(blob): return list(loopTLVBlocks(blob)) def loopTLVBlocks(blob): i = 0 while i + 8 <= len(blob): tag = blob[i:i+4] length = struct.unp...
Python
import plistlib import struct import socket from datetime import datetime from progressbar import ProgressBar, Percentage, Bar, SimpleProgress, ETA from usbmux import usbmux from util import sizeof_fmt kIOAESAcceleratorEncrypt = 0 kIOAESAcceleratorDecrypt = 1 kIOAESAcceleratorGIDMask = 0x3E8 kIOAESAccele...
Python
from keystore.keybag import Keybag from keystore.effaceable import EffaceableLockers from util.ramdiskclient import RamdiskToolClient import plistlib COMPLEXITY={ 0: "4 digits", 1: "n digits", 2: "n alphanum" } def checkPasscodeComplexity(data_volume): p...
Python
""" http://github.com/farcaller/bplist-python/blob/master/bplist.py """ import struct import plistlib from datetime import datetime, timedelta class BPListWriter(object): def __init__(self, objects): self.bplist = "" self.objects = objects def binary(self): '''binary -> string ...
Python
""" /************************************************************** LZSS.C -- A Data Compression Program *************************************************************** 4/6/1989 Haruhiko Okumura Use, distribute, and modify this program freely. Please send me your improved versions. PC-VAN ...
Python
import os import sys from util import sizeof_fmt, hexdump from progressbar import ProgressBar from crypto.aes import AESdecryptCBC, AESencryptCBC class FileBlockDevice(object): def __init__(self, filename, offset=0, write=False): flag = os.O_RDONLY if not write else os.O_RDWR if sys.platfo...
Python
def print_table(title, headers, rows): widths = [] for i in xrange(len(headers)): z = map(len, [str(row[i]) for row in rows]) z.append(len(headers[i])) widths.append(max(z)) width = sum(widths) + len(headers) + 1 print "-"* width print "|" + title.center...
Python
import glob import plistlib import os from bplist import BPlistReader import cPickle import gzip def read_file(filename): f = open(filename, "rb") data = f.read() f.close() return data def write_file(filename,data): f = open(filename, "wb") f.write(data) f.close() def ma...
Python
#!/usr/bin/python from optparse import OptionParser from keystore.keybag import Keybag from keychain import keychain_load from keychain.managedconfiguration import bruteforce_old_pass from util import readPlist from keychain.keychain4 import Keychain4 import plistlib def main(): parser = OptionParser(usage="%prog ...
Python
from store import PlistKeychain, SQLiteKeychain from util import write_file from util.asciitables import print_table from util.bplist import BPlistReader from util.cert import RSA_KEY_DER_to_PEM, CERT_DER_to_PEM import M2Crypto import hashlib import plistlib import sqlite3 import string import struct KSECA...
Python
from crypto.aes import AESdecryptCBC import struct """ iOS 4 keychain-2.db data column format version 0x00000000 key class 0x00000008 kSecAttrAccessibleWhenUnlocked 6 kSecAttrAccessibleAfterFirstUnlock 7 ...
Python
""" 0 1:MCSHA256DigestWithSalt 2:SecKeyFromPassphraseDataHMACSHA1 """ from crypto.PBKDF2 import PBKDF2 import plistlib import hashlib SALT1 = "F92F024CA2CB9754".decode("hex") hashMethods={ 1: (lambda p,salt:hashlib.sha256(SALT1 + p)), 2: (lambda p,salt:PBKDF2(p, salt, iterations=1000).read(20)) ...
Python
import plistlib import sqlite3 import struct from util import readPlist class KeychainStore(object): def __init__(self): pass def convertDict(self, d): return d def returnResults(self, r): for a in r: yield self.convertDict(a) def get_i...
Python
import sqlite3 from keychain3 import Keychain3 from keychain4 import Keychain4 def keychain_load(filename, keybag, key835): version = sqlite3.connect(filename).execute("SELECT version FROM tversion").fetchone()[0] #print "Keychain version : %d" % version if version == 3: return Keychain3(fi...
Python
from keychain import Keychain from crypto.aes import AESdecryptCBC, AESencryptCBC import hashlib class Keychain3(Keychain): def __init__(self, filename, key835=None): Keychain.__init__(self, filename) self.key835 = key835 def decrypt_data(self, data): if data == None:...
Python
#!/usr/bin/env python '''Fisheries Economics Masterclass model''' import threading import wx from pylab import * import copy class Parameter(dict): """ Model parameter class A simple dict with some default values """ def __init__(self,value=0,min=0,max=1,units='',title='',description='',type...
Python
#import matplotlib as mp #mp.use('GTK') #from matplotlib.figure import Figure #from matplotlib.pyplot import show import matplotlib.pyplot as plt figure = plt.figure() pos = [.1,.1,.8,.8] pos2 = list(pos) pos2[2]=.75 print pos print pos2 ax1 = figure.add_axes(pos, frameon = False,label ='a') ax2 = figure.add_axes(pos...
Python
#!/usr/bin/env python """Fisheries Economics Masterclass GUI""" import wx import wx.html import fisheries_model import colourblind import matplotlib #matplotlib.use('WXAgg') from matplotlib.figure import Figure from matplotlib.backends.backend_wxagg import \ FigureCanvasWxAgg as FigCanvas import numpy import copy...
Python
#By running "python setup.py py2exe" this script generates a windows stand-alone #distribution of the Fisheries Explorer from distutils.core import setup import py2exe import matplotlib import shutil # Remove the build folder shutil.rmtree("build", ignore_errors=True) # do the same for dist folder shutil...
Python
#!/usr/bin/env python """Fisheries Economics Masterclass GUI""" import wx import wx.html import fisheries_model import colourblind import matplotlib #matplotlib.use('WXAgg') from matplotlib.figure import Figure from matplotlib.backends.backend_wxagg import \ FigureCanvasWxAgg as FigCanvas import numpy import copy...
Python
#!/usr/bin/env python '''Fisheries Economics Masterclass model''' import threading import wx from pylab import * import copy class Parameter(dict): """ Model parameter class A simple dict with some default values """ def __init__(self,value=0,min=0,max=1,units='',title='',description='',type...
Python
import numpy as np #A set of safe plotting colours from http://jfly.iam.u-tokyo.ac.jp/color/ rgb = np.array([[0,0,0],[230,159,0],[86,180,233],[0,158,115],[240,228,66],[0,114,178],[213,94,0],[204,121,167]]) rgbScaled = rgb/255.0 #Colormaps from #A. Light & P.J. Bartlein, "The End of the Rainbow? Color Schemes for #Im...
Python
#!/usr/bin/env python ''' Fisheries Economics Masterclass model Copyright 2010, University of Tasmania, Australian Seafood CRC This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. ''' import threading import wx from pylab import * import copy class Parameter(dict): ...
Python
#import matplotlib as mp #mp.use('GTK') #from matplotlib.figure import Figure #from matplotlib.pyplot import show import matplotlib.pyplot as plt figure = plt.figure() pos = [.1,.1,.8,.8] pos2 = list(pos) pos2[2]=.75 print pos print pos2 ax1 = figure.add_axes(pos, frameon = False,label ='a') ax2 = figure.add_axes(pos...
Python
#!/usr/bin/env python """ Fisheries Economics Masterclass GUI Klaas Hartmann 2010 Copyright 2010, University of Tasmania, Australian Seafood CRC This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. """ import wx import wx.html import fisheries_model import colourblind ...
Python
#By running "python setup.py py2exe" this script generates a windows stand-alone #distribution of the Fisheries Explorer #Copyright 2010, University of Tasmania, Australian Seafood CRC #This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. from distutils.core import ...
Python
#!/usr/bin/env python """ Fisheries Economics Masterclass GUI Klaas Hartmann 2010 Copyright 2010, University of Tasmania, Australian Seafood CRC This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. """ import wx import wx.html import fisheries_model import colourblind ...
Python
#!/usr/bin/env python ''' Fisheries Economics Masterclass model Copyright 2010, University of Tasmania, Australian Seafood CRC This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. ''' import threading import wx from pylab import * import copy class Parameter(dict): ...
Python
import numpy as np # Colours and colourmaps that are readable by most colourblind people # Copyright 2010, University of Tasmania, Australian Seafood CRC # This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. #A set of safe plotting colours from http://jfly.iam.u-tokyo....
Python
#!/usr/bin/env python ''' Fisheries Economics Masterclass model Copyright 2010, University of Tasmania, Australian Seafood CRC This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. ''' import threading import wx from pylab import * import copy class Parameter(dict): ...
Python
#import matplotlib as mp #mp.use('GTK') #from matplotlib.figure import Figure #from matplotlib.pyplot import show import matplotlib.pyplot as plt figure = plt.figure() pos = [.1,.1,.8,.8] pos2 = list(pos) pos2[2]=.75 print pos print pos2 ax1 = figure.add_axes(pos, frameon = False,label ='a') ax2 = figure.add_axes(pos...
Python
#!/usr/bin/env python """ Fisheries Economics Masterclass GUI Klaas Hartmann 2010 Copyright 2010, University of Tasmania, Australian Seafood CRC This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. """ import wx import wx.html import fisheries_model import colourblind ...
Python
#By running "python setup.py py2exe" this script generates a windows stand-alone #distribution of the Fisheries Explorer #Copyright 2010, University of Tasmania, Australian Seafood CRC #This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. from distutils.core import ...
Python
#!/usr/bin/env python """ Fisheries Economics Masterclass GUI Klaas Hartmann 2010 Copyright 2010, University of Tasmania, Australian Seafood CRC This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. """ import wx import wx.html import fisheries_model import colourblind ...
Python
#!/usr/bin/env python ''' Fisheries Economics Masterclass model Copyright 2010, University of Tasmania, Australian Seafood CRC This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. ''' import threading import wx from pylab import * import copy class Parameter(dict): ...
Python
import numpy as np # Colours and colourmaps that are readable by most colourblind people # Copyright 2010, University of Tasmania, Australian Seafood CRC # This program is released under the Open Software License ("OSL") v. 3.0. See OSL3.0.htm for details. #A set of safe plotting colours from http://jfly.iam.u-tokyo....
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2009 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or l...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2009 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or l...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
""" FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http://www.gnu.org/license...
Python
""" Selector classes implementing various selection algorithms """ import sys from random import choice, randint, shuffle, random class Selector(object): """ Abstract base selection object contains standard methods """ def select(self, organisms=None, n=None): """ @param list organism...
Python
"""Variator mockup used to test PISA functionality.""" import random import time import pisa try: ################################################################# # evolve_beats.py # # Configuration steps, command line arguments, basic file i/o. # Passes prefix and period. ####################...
Python
#!/usr/bin/env python """ pisa_beats.py Evolves a pattern of beats based on a collection of user-defined fitness trajectories. The genetic algorithm is based on the pygene library. @author John Huddleston """ import os import sys import pickle os.environ['DJANGO_SETTINGS_MODULE'] = "fitbeat_project.settings" from r...
Python
#!/usr/bin/env python """ evolve_beats.py Evolves a pattern of beats based on a collection of user-defined fitness trajectories. The genetic algorithm is based on the pygene library. @author John Huddleston """ import os import sys import pickle os.environ['DJANGO_SETTINGS_MODULE'] = "fitbeat_project.settings" from...
Python
#!/usr/bin/env python """ evolve_beats.py Evolves a pattern of beats based on a collection of user-defined fitness trajectories. The genetic algorithm is based on the pygene library. @author John Huddleston """ import os import sys import pickle os.environ['DJANGO_SETTINGS_MODULE'] = "fitbeat_project.settings" from...
Python
""" pattern.py Represents all elements population of organisms: * Gene * Organism * Population """ import Numeric import copy import time from random import random, choice from pygene.gene import IntGene from pygene.organism import Organism from pygene.population import Population from fitness import * from mutato...
Python
# Django settings for fitbeat_project project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( ('John Huddleston', 'huddlej@gmail.com'), ) MANAGERS = ADMINS DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = '/home/huddlej/fitbeats/fitbeat_project/research.db' DATABASE_USER = '' DATABASE_PASSWORD = '' DATABASE_HOST = '...
Python
from django.conf import settings def caslogin(user): print "Hello!" print "User: ", user def get_applications(clean=True): if clean: return [".".join(app.split(".")[1:]) for app in settings.INSTALLED_APPS if not app.startswith('django')] else: return [app for app in settings.INSTALLED_...
Python
#!/usr/bin/env python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to ...
Python
from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^login/$', 'fitbeat_project.fitbeats.views.user_login'), (r'^logout/$', 'fitbeat_project.fitbeats.views.user_logout'), (r'^admin/', include('django.contrib.admin.urls')), (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', ...
Python
# threadlocals middleware try: from threading import local except ImportError: from django.utils._threading_local import local _thread_locals = local() def get_current_user(): return getattr(_thread_locals, 'user', None) class ThreadLocals(object): """Middleware that gets various objects from the ...
Python
import sys sys.path.append('../') from django.db import models from django.db.models import permalink from django.contrib.auth.models import User from django.template.defaultfilters import slugify from functions import bezier TRAJECTORY_TYPES = ( ('coordinate', 'Coordinate'), (...
Python
# Forms from django import newforms as forms class PatternForm(forms.Form): length = forms.IntegerField(maxlength=100)
Python
from django.conf.urls.defaults import * from django.views.generic.list_detail import object_list import fitbeats from fitbeats.models import Pattern base_generic_dict = {'paginate_by': 20} pattern_info_dict = dict(base_generic_dict, queryset=Pattern.objects.all(), ...
Python
""" widgets.py Custom widgets for base_case forms. """ from django import newforms as forms class TextHiddenInput(forms.widgets.HiddenInput): """ A widget that allows split date and time inputs to have separate attributes """ is_hidden = False def __init__(self, attrs=None): if attrs ...
Python
""" functions.py Joining functions and helper functions. """ from random import randint from math import floor, ceil from collections import deque """ Joining Functions These are simple mathematical functions linearly parameterized by the constants "a" and "b" which shift the function domain to fit the user's requ...
Python
import pickle import random import subprocess import signal from xml.dom.minidom import parse from django import newforms as forms from django.db import transaction from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404 from django....
Python
#!/usr/bin/env python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to ...
Python
"""Lower level method to support the PISA variator interface.""" files = { "configuration": "cfg", "initial_population": "ini", "archive": "arc", "sample": "sel", "offspring": "var", "state": "sta" } STATE_0 = 0 STATE_1 = 1 STATE_2 = 2 STATE_3 = 3 STATE...
Python
from xml.dom.minidom import parse import Numeric SONG_TEMPLATE_PATH = "/home/huddlej/fitbeats/song_template.h2song" def savePatternToXml(pattern, fileobject, debug=False): """ Open the Hydrogen song template, write the new beats, and save the resulting XML into a new file. @param PatternOrganism ...
Python
""" fitness.py Fitness Functions Each of these functions calculates the actual fitness of a genetic individual based on the individual's dimensions and the expected fitness based on a joining function and its linear parameters, "a" and "b". """ from random import randint from math import floor, ceil from collections...
Python
""" Crossover classes implementing various Crossover algorithms """ from random import random, randint import sys class Crossover(object): """ Abstract base Crossover object contains standard methods """ def mate(self, parent1, parent2): """ @param Organism parent1 @param Organ...
Python
#!/usr/bin/env python """ pisa_beats.py Evolves a pattern of beats based on a collection of user-defined fitness trajectories. The genetic algorithm is based on the pygene library. @author John Huddleston """ import os import sys import pickle os.environ['DJANGO_SETTINGS_MODULE'] = "fitbeat_project.settings" from r...
Python
""" pygene is a library for genetic algorithms in python It aims to be very simple to use, and suitable for people new to genetic algorithms. """ version = "0.2.1" __all__ = [ 'gene', 'gamete', 'organism', 'population', 'xmlio', 'prog', ]
Python
""" mutator.py Base Mutator class for all mutation operators and extensions of this base class for the following organism-level mutations: * Classic - randomly mutate each bit in an individual with a given probability * Reverse - reverse the order of the beats in each instrument or in one random instru...
Python
import re from pygments.lexer import RegexLexer from pygments.token import Text, Name, Comment, String, Generic from sphinx import addnodes from docutils import nodes class FitykLexer(RegexLexer): name = 'fityklexer' tokens = { 'root': [ (r"'[^']*'", String.Single), ...
Python
# -*- coding: utf-8 -*- # Sphinx v1.0.7 # # sphinx-build -d ./doctrees/ -b html . html import sys, os sys.path.append(os.path.abspath('.')) extensions = ["sphinx.ext.pngmath", "sphinx.ext.extlinks", "fityk_ext"] exclude_trees = ['html', 'latex', '.svn'] exclude_patterns = ['index.rst', 'screens.rst'] templates_path...
Python
#!/usr/bin/env python import os.path, sys from fityk import Fityk class GaussianFitter(Fityk): def __init__(self, filename): Fityk.__init__(self) if not os.path.isfile(filename): raise ValueError("File `%s' not found." % filename) self.filename = filename self.execute("...
Python
#!/usr/bin/env python import os.path, sys from fityk import Fityk class GaussianFitter(Fityk): def __init__(self, filename): Fityk.__init__(self) if not os.path.isfile(filename): raise ValueError("File `%s' not found." % filename) self.filename = filename self.execute("...
Python
#!/bin/env python # -*- coding: utf-8 -*- import pygtk pygtk.require('2.0') import gtk from random import choice import os class LongText(object): def __init__(self, content=u'', generation=4, max_length=1000): assert(generation>1) assert(generation<=len(content)) # convert content to ...
Python
#!/bin/env python # -*- coding: utf-8 -*- import pygtk pygtk.require('2.0') import gtk from random import choice import os class LongText(object): def __init__(self, content=u'', generation=4, max_length=1000): assert(generation>1) assert(generation<=len(content)) # convert content to ...
Python
import mimetypes import urllib import string import settings import jinja2 import os import webapp2 from datetime import datetime from google.appengine.api import users from google.appengine.ext import db key_prefix = 'file_' log_prefix = 'log_' prefs_prefix = 'prefs_' segment_size = 10**6 column_name...
Python
# site name (used for display purposes) site_name = 'example.com' # email addresses authorized to upload, rename and delete files auth_emails = ( 'test@example.com', )
Python
#!/usr/bin/env python # # Copyright 2006, 2007 Google Inc. All Rights Reserved. # Author: danderson@google.com (David Anderson) # # Script for uploading files to a Google Code project. # # This is intended to be both a useful script for people who want to # streamline project uploads and a reference implementation for ...
Python
#!/usr/bin/python # # Run the script with path to the JSON file you downloaded from google.drive. # eg. checkin.py ~/Downloads/GmailDelaySendWeb.json # # Script will unpack JSON and edit/updates files in git for you. # # REMEMBER: You still need to commit & push import json import os import sys from subprocess import c...
Python
"""Graph.py Description: Simple, undirected and connected graph implementation for course 75.29 Teoria de Algoritmos at University of Buenos Aires. Provide simple graph operations, calculates the minimum spanning tree using Kruskal algorithm and work with Union and Set dataStructures defined on DisjointSet code, which ...
Python
from Graph import Graph def main(): graphFile = raw_input("Enter the file name containing a valid graph:") filep = open(graphFile) graph = Graph(filep) print "Evaluating the graph:\n" print graph T = graph.kruskal() print "Min. Spanning tree: \n" for edges in T: print edges return 0 if __name__ == '__mai...
Python