Skip to content

Instantly share code, notes, and snippets.

View hdlim15's full-sized avatar

Hyuckin David Lim hdlim15

  • New York, New York
View GitHub Profile
import gym
import pybrain
import random
from pybrain.datasets import SupervisedDataSet
from pybrain.tools.shortcuts import buildNetwork
from pybrain.supervised.trainers import BackpropTrainer
name = "CartPole-v0"
env = gym.make(name)
#env.monitor.start("/tmp/CartPole-v0-6")
import time
start = time.time()
import re
# Returns the length of the recurring cycle of 1/num
def cycle_length(num):
decimals = str(10**2000 // num)
r = re.compile(r"([0-9]+?)\1+") # Looks for non-overlapping repeating sequences
length = max(r.findall(decimals), key=len) # Length of longest repeating sequence
import time
start = time.time()
# Given a string in the form 56**3, where * represents all possible digits, return
# True if and only if the size of the prime value family is >= famSize
def size_prime_family(num, famSize, primes):
firstDigit = 0
if num[0] == "*":
firstDigit = 1
#---------------------------- New method. Runs in ~0.23 seconds ----------------------------
import time
start = time.time()
# Create a prime sieve that tracks of the number of prime factors for each composite number
limit = 500000
numFactors = [0] * limit # Stores the number of prime factors for composite numbers (0 for primes)
for i in range(2, 10000):
if numFactors[i-2] == 0: # if i is prime
numFactors[i-2] = 1
@hdlim15
hdlim15 / nltk_fix.py
Last active November 23, 2016 13:44
import re
# Tests a re pattern against several tweets and sees how accurately it removes twitter handles
def test_re(pattern):
# An array of tweets to test
test_array = [
# Simple example. Handles with just numbers should be allowed
"@twitter hello @twi_tter_. hi @12345 @123news",
# Handles are allowed to follow any of the following characters
"@n`@n~@n(@n)@n-@n=@n+@n\\@n|@n[@n]@n{@n}@n;@n:@n'@n\"@n/@n?@n.@n,@n<@n>@n @n\n@n",
@hdlim15
hdlim15 / mp_sharing_testing_setup.md
Last active September 24, 2019 15:36
MP Sharing: Set up localhost Users for front end testing

How to set up localhost Users to test the front end for MP sharing

User 1: belongs to client group 'YCharts Staff'. This user will attempt to share model portfolios with 'YCharts Staff'. This user will alternate between share and view_only group_permission

User 2: also belongs to client group 'YCharts Staff. This user will be attempting to view / edit the model portfolios shared by User 1. This user will alternate between share and view_only group_permission

User 3: Does NOT belong to client group 'YCharts Staff'. This user should never be able to view or edit the model portfolios shared by User 1