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
# STEP 1: draw tree from a fully annotated dict | |
adict = { | |
'items': [ | |
{ | |
'value': 'a', | |
'last_item': False, | |
'children': { | |
'items': [ | |
{'value': 1, 'last_item': False}, |
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
def draw_tree(case, lcase, icase): | |
if case == '' or case == [] or case == {}: | |
return '' | |
elif type(case) is int or type(case) is str: | |
if lcase[case] == True: | |
return f'{icase[case]}└── {case}\n' | |
else: | |
return f'{icase[case]}├── {case}\n' | |
elif type(case) is list: |
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
from bs4 import BeautifulSoup | |
import random | |
import functools | |
import re | |
htmlfile = open('output_newest_html.html') | |
index = htmlfile.read() | |
S = BeautifulSoup(index, 'lxml') |
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 datetime | |
import psycopg2 | |
conn = psycopg2.connect(user="user", password="password", database="iot", host="localhost", port="5433") | |
cur = conn.cursor() | |
cur.execute("insert into telemetries (timestamp, device, data) values(%s, %s, %s)",(datetime.datetime.utcnow(), "sol", "{\"temp\": 22}")) | |
def insertone(ts, dv, da): | |
cur.execute("insert into telemetries (timestamp, device, data) values(%s, %s, %s)",(ts, dv, da)) | |
insertone(datetime.datetime.now(), 'sol', '{\"temp\": 23}') |
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
from selenium import webdriver | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.common.keys import Keys | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support.expected_conditions import presence_of_element_located | |
#This example requires Selenium WebDriver 3.13 or newer | |
# with webdriver.Firefox() as driver: | |
# wait = WebDriverWait(driver, 10) | |
# driver.get("https://google.com/ncr") |
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
def on_data(data: EventData): | |
job_title = data.title | |
if job_title.find("economic") > -1 or job_title.find("developer") > -1 or job_title.find("engineer") > -1 or job_title.find("research") > -1 or job_title.find("analytic") > -1: | |
print('[ON_DATA]', data.title, data.company, data.date, data.link, len(data.description)) | |
lines = ['\n', data.title, data.company, wordcloud(data.description), data.job_function, data.link, "--------------"] | |
with open('output.txt', 'a') as f: | |
f.writelines('\n'.join(lines)) | |
def on_error(error): | |
print('[ON_ERROR]', error) |
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
# Write your max_num function here: | |
def max_num(num1, num2, num3): | |
max = num1 | |
tie = "" | |
for num in [num2, num3]: | |
if num == max: | |
tie = "It's a tie!" | |
elif num > max: | |
max = num |
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
#include <stdlib.h> | |
static int in_set(char c, char *charset) | |
{ | |
int i; | |
i = 0; | |
while (charset[i]) | |
{ | |
if (c == charset[i]) |
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
#include <stddef.h> | |
#include "libft.h" | |
char *ft_strrchr(const char *s, int c) | |
{ | |
int l; | |
l = ft_strlen(s) + 1; | |
while (l-- != 0) |
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
#include <stdlib.h> | |
#include "libft.h" | |
char *ft_strjoin(char const *s1, char const *s2) | |
{ | |
size_t i; | |
size_t l1; | |
size_t l2; | |
char *str; |
NewerOlder