Skip to content

Instantly share code, notes, and snippets.

Avatar

Hamlet Batista hamletbatista

View GitHub Profile
View get_search_console_data.py
#let's build a pandas dataframe with the search console data
import pandas as pd
def get_search_console_data(webproperty, days=-365):
if webproperty is not None:
query = webproperty.query.range(start='today', days=days).dimension('date', 'query')
r = query.get()
df = pd.DataFrame(r.rows)
return df
View misplaced_canonical_test.py
from requests_html import HTMLSession
#Builds a DOM path recursively
def build_dom_path(element, path):
if element is None:
return path
else:
path.append(element.tag)
View wordpress_ping_cloudfunction.py
from git import Repo
from lxml import etree
import advertools as adv
from datetime import datetime
import yaml
import os
full_path="/tmp/wordpress-updates"
#get credentials from environment variables
View faqpage_generated.js
<title>Google Ads to Start Hiding Some Search Query Data</title>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
View que_generator.py
class QueGenerator():
def __init__(self):
self.que_model = T5ForConditionalGeneration.from_pretrained('./t5_que_gen_model/t5_base_que_gen/')
self.ans_model = T5ForConditionalGeneration.from_pretrained('./t5_ans_gen_model/t5_base_ans_gen/')
self.que_tokenizer = T5Tokenizer.from_pretrained('./t5_que_gen_model/t5_base_tok_que_gen/')
self.ans_tokenizer = T5Tokenizer.from_pretrained('./t5_ans_gen_model/t5_base_tok_ans_gen/')
self.device = 'cuda' if torch.cuda.is_available() else 'cpu'
View keyworksFromUrl.py
from urllib.parse import urlparse
import re
url="https://www.amazon.com/SanDisk-128GB-microSDXC-Memory-Adapter/dp/B073JYC4XM/"
print(set(re.split("[/-]", urlparse(url).path)))
#output
#{'', 'B073JYC4XM', 'dp', '128GB', 'microSDXC', 'Memory', 'SanDisk', 'Adapter'}
View detectnet_to_automl.py
from glob import glob
import os
from collections import defaultdict
from pprint import pprint
import PIL
def detectnet_input():
#images = glob(os.path.join(FLAGS.data_dir, '*.jpg'))
exclude= ["page tabs", "original price", "product name0055-0922", "promotion text"]
View draw_bounding_boxes.py
import cv2
def draw_bounding_boxes(file_path, prediction_result):
## read image file from disk
img = cv2.imread(file_path, cv2.IMREAD_COLOR)
height = img.shape[0] # Image height
width = img.shape[1] # Image width
View shopify_theme_link_spider.py
You can’t perform that action at this time.