This file contains hidden or 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 os | |
TXT_PATH = "" | |
QUERY_PATH = "" | |
text = "" | |
queries = [] | |
with open(TXT_PATH, "r") as f: | |
text = f.read().strip() |
This file contains hidden or 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 com.optum.giraffle.tasks.* | |
import com.optum.giraffle.* | |
buildscript { | |
this.dependencies{ | |
this.classpath("com.opencsv:opencsv:3.8") | |
} | |
} |
This file contains hidden or 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
const sendMessage = (toastMessage) => { | |
chrome.tabs.query({currentWindow:true, active:true}, (tabs) => { | |
const tab = tabs[0]; | |
chrome.tabs.sendMessage(tab.id, { | |
toastMessage: toastMessage | |
}); | |
}); | |
} | |
chrome.contextMenus.onClicked.addListener(({menuItemId}) => { | |
if (menuItemId === "show-toast") { |
This file contains hidden or 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
const showToast = (message) => { | |
//append html element to webpage | |
let toastContainer = document.createElement("div"); | |
toastContainer.innerText = message; | |
toastContainer.className = "toast"; | |
document.body.appendChild(toastContainer); | |
//remove element after 2 seconds | |
setTimeout(()=>{ | |
document.body.removeChild(toastContainer); |
This file contains hidden or 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
.toast{ | |
display: block !important; | |
box-sizing: border-box !important; | |
position: fixed !important; | |
right: 50% !important; | |
top: 0 !important; | |
padding: 0 !important; | |
width: 378px !important; | |
z-index: 2147483647 !important; | |
background-color: black; |
This file contains hidden or 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> | |
<body> | |
<style> | |
#main { | |
width: 300px; | |
height: 500px; | |
align-content: center; | |
text-align: center; | |
} |
This file contains hidden or 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
const onHandleSubmit = () => { | |
const newMessage = document.getElementById("message").value; | |
chrome.storage.sync.set({message: newMessage}, () => { | |
console.log("Finished Setting!"); | |
}); | |
} | |
const setupHandlers = () => { | |
const submitButton = document.getElementById("submit"); | |
submitButton.onclick = onHandleSubmit; | |
} |
This file contains hidden or 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 app import db | |
class Day(db.Model): | |
__tablename__ = 'day' | |
id = db.Column('id', db.Date(), primary_key=True) | |
views = db.Column('views', db.Integer) | |
reads = db.Column('reads', db.Integer) | |
def __init__(self, id, views, reads): |
This file contains hidden or 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 app import db | |
from .day import Day | |
class IpView(db.Model): | |
__tablename__ = "ip_view" | |
ip = db.Column("ip", db.String(20), primary_key=True) | |
date_id = db.Column("date_id", db.Date(), db.ForeignKey(Day.id), primary_key=True) | |
def __init__(self, ip, date_id): |
This file contains hidden or 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
@app.route("/view", methods=["GET"]) | |
def on_view(): | |
try: | |
day_id = get_current_day() # get our day_id, which is the date string in the format "yyyy-mm-dd" | |
client_ip = request.remote_addr # get the ip address of where the client request came from | |
query = Day.query.filter_by(id=day_id) # try to get the row associated to the current day | |
if query.count() > 0: | |
# the current day is already in table, simply increment its views | |
current_day = query.first() |