This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current: | |
def __init__(self, listVals): | |
self.listVals = listVals | |
self.currentIndex = -1 | |
def sample(self, ignoredValue): | |
self.currentIndex = self.currentIndex + 1 if self.currentIndex < len(self.listVals) - 1 else 0 | |
return self.listVals[self.currentIndex] | |
# % variation: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mysql.connector | |
conn1 = mysql.connector.connect(database='test', user='test', password='test') | |
curs1 = conn1.cursor() | |
curs1.execute("create table foo(id text)") | |
curs1.execute("select * from foo where random()") | |
# -> mysql.connector.errors.ProgrammingError: 1305 (42000): FUNCTION test.random does not exist | |
conn2 = mysql.connector.connect(database='test', user='test', password='test') | |
curs2 = conn2.cursor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# forked for my own reference | |
import urllib.request | |
import urllib.parse | |
from bs4 import BeautifulSoup as bs | |
import nltk | |
def extract_named_ents_from_url(url): | |
url_bytes = get_bytes_for_url(url) | |
soup = bs(url_bytes, "lxml") |