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 computeLPSList(pattern): | |
lps = [0] * len(pattern) | |
index = 1 | |
_len = 0 | |
while index < len(pattern): | |
if pattern[index] == pattern[_len]: | |
_len += 1 | |
lps[index] = _len |
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
<style> | |
.container { | |
display: flex; | |
align-items: center; | |
flex-direction: column | |
} | |
#counter { | |
font-size: 70px; | |
} |
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 match(template, ptr, char): | |
if ptr < len(template): | |
template_char = template[ptr] | |
if template_char == 'A' and char == 'T': | |
return True | |
if template_char == 'T' and char == 'A': | |
return True | |
if template_char == 'G' and char == 'C': | |
return True | |
if template_char == 'C' and char == 'G': |
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 match(template, ptr, char): | |
if ptr < len(template): | |
template_char = template[ptr] | |
if template_char == 'A' and char == 'T': | |
return True | |
if template_char == 'T' and char == 'A': | |
return True | |
if template_char == 'G' and char == 'C': | |
return True | |
if template_char == 'C' and char == 'G': |
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 match(template, ptr, char): | |
if ptr < len(template): | |
template_char = template[ptr] | |
if template_char == 'A' and char == 'T': | |
return True | |
if template_char == 'T' and char == 'A': | |
return True | |
if template_char == 'G' and char == 'C': | |
return True | |
if template_char == 'C' and char == 'G': |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> |
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 csv, psycopg2, re, json | |
class DataProcessor: | |
def __init__(self): | |
self.valid_date = "2019-05-21" | |
self.file_name = 'log-actions-follow_2019-05-20_08-50PM_subset.csv' | |
self.data = [] |
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 csv, psycopg2, re, json | |
class DataProcessor: | |
def __init__(self): | |
self.file_name = 'spreadsheet.csv' | |
self.data = [] | |
self.map = { | |
"ScrapedDate": "lead_find_date", | |
"Userid": "user_id", |
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 insert_data(self): | |
chunk_size = 1000 | |
query = """ | |
INSERT INTO test_ig_leads (lead_find_date, user_id, username, lead_find_keyword, is_private, follower_count, following_count, media_count) SELECT lead_find_date, user_id, username, lead_find_keyword, is_private, follower_count, following_count, media_count FROM json_populate_recordset(null::test_ig_leads, %s);""" | |
length = len(self.data) | |
start = 0 | |
while start <= length: | |
rowset = self.data[start:start+chunk_size] | |
cursor = self.conn.cursor() | |
cursor.execute(query, (json.dumps(rowset), )) |
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 insert_data(self): | |
query = """ | |
INSERT INTO test_ig_leads (lead_find_date, user_id, username, lead_find_keyword, is_private, follower_count, following_count, media_count) SELECT lead_find_date, user_id, username, lead_find_keyword, is_private, follower_count, following_count, media_count FROM json_populate_recordset(null::test_ig_leads, %s);""" | |
cursor = self.conn.cursor() | |
cursor.execute(query, (json.dumps(self.data), )) | |
self.conn.commit() |
NewerOlder