Skip to content

Instantly share code, notes, and snippets.

View Dante83's full-sized avatar
💭
Let's write some code!

David Evans Dante83

💭
Let's write some code!
View GitHub Profile
#My first Genetic Algorithm
#By David Evans
#05/29/2016
import random as rnd
import numpy as np
import matplotlib.pyplot as plt
from genotype import Genotype
def main():
momAndDad = np.random.choice(genotypeList, 2, p=probabilityDistribution)
#My first Genetic Algorithm
#By David Evans
#05/29/2016
import random as rnd
import numpy as np
import matplotlib.pyplot as plt
from genotype import Genotype
def main():
import random as rnd
#My gene class
class Genotype:
def __init__(self, fitness_test, parent1, parent2):
#If either parent chromosome starts off as null than make this chromosome a
#random collection of 1s and 0s ten digits long
if(parent1 == None or parent2 == None):
self.chromosome = ''.join(rnd.choice('01') for i in range(10))
self.chromosomeList = list(self.chromosome)
//The stuff in our TODO section, we've also added the variables wind_speed and amplitude to the variable list
//at the top of the application.
frames_per_second = 24;
frames_in_animation = 34;
frame = 0;
float wind_speed = llWind().x
if(wind_speed > 25.0){
amplitude = PI / 2.0; //25 * PI /50;
}
//As a good programming practice, let's instantiate all of our variables out here so they're available
//to us in the scopes below.
float frames_per_second;
integer frames_in_animation;
integer frame;
default
{
state_entry()
{
def groupfinder(userid, request):
userGroup = request.db.query(UserGroup.name).join(RegisteredUser, UserGroup.id == RegisteredUser.group_id).\
group_by(UserGroup.id).filter(UserGroup.id == userid).first()
if(userGroup):
return userGroup
else:
return None
#What we do when we save the user state
if(user and crypto_manager.check(user.getPassword(), password)):
headers = remember(request, user.id)
self.request.session.flash("You have successfully logged in to your account.", "success")
return HTTPFound(location=came_from, headers=headers)
@Dante83
Dante83 / populate_postgres_search_feature.py
Created January 18, 2016 21:08
Another fun weekend project, moving my word data over to a Postgres Database for faster search suggestions.
import psycopg2
import pgdb
from py2neo import authenticate, Graph, Node, Relationship
import os
p_connection = psycopg2.connect(host = 'localhost',
user='USER',
password='SECRET',
dbname='lexinomicon')
from lxml import etree
from py2neo import authenticate, Graph, Node
import re
import time
import sys
import os
def save_definitions(filNum, gdb, start_page = 1):
#For the given file in the xml file list
filLoc = '../../../wikitionary_files/enwikitionary_%s.xml'%filNum