Skip to content

Instantly share code, notes, and snippets.

Avatar

Mohamed Rajab Mohammed MohamedRajabMohammed

View GitHub Profile
View reset.js
function createTimer() {
clearInterval(interval);
count = 0;
numbersArea.style.transform = 'translateY(0)'
// other code goes here...
// interval = setInterval(() => {...
}
View timer.js
// create the interval that creates the timer
function createTimer() {
interval = setInterval(() => {
// 1. increment our count
count++;
// 2. calculate the offset and apply it
const offset = height * count;
View variables.js
// grab parts of our HTML
const countdownArea = document.querySelector('.countdown');
const numbersArea = document.querySelector('.numbers');
const resetBtn = document.querySelector('.reset');
// create an interval and counter
let interval;
let count = 0;
// calculate the height of our numbers
@MohamedRajabMohammed
MohamedRajabMohammed / countdown.css
Created Jul 21, 2020
Positioning the Countdown and Numbers
View countdown.css
.countdown {
position: relative;
display: block;
text-indent: -9999px;
overflow: hidden;
margin-left: 6px;
}
.numbers {
position: absolute;
View style.css
/_ button styles are here _/
button {
background: white;
border-radius: 5px;
border: none;
padding: 15px 30px;
font-size: 24px;
font-family: 'Muli';
display: block;
text-transform: uppercase;
View Index.html
<div>
<button class="next">
<span class="icon">👉</span>
Next Episode Starts in
<span class="countdown">
10
<span class="numbers">
<span>10</span>
<span>9</span>
<span>8</span>
View tracker.py
import db
import scraper
import time
URL = "https://www.amazon.in/dp/B077Q42J32/"
def track():
details = scraper.get_product_details(URL)
result = ""
if details is None:
View db.py
{
'asin': 'B077Q42J32',
'details': [
{
'name': 'Nokia 8.1 (Iron, 4GB RAM, 64GB Storage)',
'price': 19139.0,
'deal': False,
'url': 'https://www.amazon.in/dp/B077Q42J32',
'date': datetime.datetime(2019, 8, 7, 9, 51, 35, 648000)
},
View db.py
def get_product_history(asin):
new = db["products"]
try:
find = new.find_one({"asin": asin}, {"_id": 0})
if find:
return find
except Exception as identifier:
print(identifier)
return None
View db.py
def add_product_detail(details):
new = db["products"]
ASIN = details["url"][len(details["url"])-10:len(details["url"])]
details["date"] = datetime.datetime.utcnow()
try:
new.update_one(
{
"asin":ASIN