Skip to content

Instantly share code, notes, and snippets.

View Ramko9999's full-sized avatar
🎯
Focusing

Ramko9999

🎯
Focusing
View GitHub Profile
import os
TXT_PATH = ""
QUERY_PATH = ""
text = ""
queries = []
with open(TXT_PATH, "r") as f:
text = f.read().strip()
import com.optum.giraffle.tasks.*
import com.optum.giraffle.*
buildscript {
this.dependencies{
this.classpath("com.opencsv:opencsv:3.8")
}
}
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") {
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);
.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;
<!DOCTYPE html>
<html>
<body>
<style>
#main {
width: 300px;
height: 500px;
align-content: center;
text-align: center;
}
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;
}
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):
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):
@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()