Skip to content

Instantly share code, notes, and snippets.

View andy23512's full-sized avatar

Tangent Chang andy23512

  • Tainan, Taiwan
  • 23:42 (UTC +08:00)
View GitHub Profile
# copy html to clipboard
javascript:!function(e){var t=document.createElement("textarea"),o=document.getSelection();t.textContent=e,document.body.appendChild(t),o.removeAllRanges(),t.select(),document.execCommand("copy"),o.removeAllRanges(),document.body.removeChild(t),window.alert("Copied")}(document.querySelector('.yearly-aqi').innerHTML);
# download html file
javascript:!function () { var element = document.createElement('a'); var yearlyAqiElement = document.querySelector('.yearly-aqi'); var text = yearlyAqiElement.innerHTML; var city = window.location.href.match('https://aqicn.org/city/([A-Za-z]+)/')[1]; var specie = yearlyAqiElement.querySelector('.active-specie').innerText; var data = new Blob([text], { type: 'text/html' }); var url = window.URL.createObjectURL(data); element.setAttribute('href', url); element.setAttribute('download', (city + '_' + specie + '.html').toLowerCase()); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); }
from tkinter import *
import time
class Rectangle:
objects = []
@classmethod
def all_move_right(cls, event):
for obj in cls.objects:
import pandas as pd
df = pd.read_excel('data.xlsx')
print("""
Mode 1: Search with locus
Mode 2: Search with chr and pos
""")
mode = input('Input query mode: ')
if mode == '1':
query_locus = input('Input locus: ')
@andy23512
andy23512 / wrong_async_download_youtube.py
Last active March 7, 2020 09:49
ATTENTION! This program do not actually download youtube video asynchronously!
import asyncio
import youtube_dl
async def progress(url):
print('Progressing: ', url)
await asyncio.sleep(1)
with youtube_dl.YoutubeDL({}) as ydl:
ydl.download([url])
print('End: ', url)
.anchor-menu {
background-color: rgba(255, 255, 255, 0);
position: fixed;
bottom: 0;
left: 0;
z-index: 1000;
font-family: 'Roboto';
font-size: 14px;
width: 20px;
transition: all 0.3s ease;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from selenium import webdriver
import time
web = webdriver.Chrome()
web.implicitly_wait(10)
web.get(USE_YOUR_URL_HERE)
tmp = web.find_elements_by_xpath("//div[@class='section-review-review-content']")
while len(tmp) < int(TOTAL_NUMBER_OF_ITEMS):
web.execute_script('''
@andy23512
andy23512 / code.py
Last active February 20, 2020 02:48
Sample Program for using zxing
import zxing
reader = zxing.BarCodeReader()
barcode_text = reader.decode('./sample-image.png')
print(barcode_text)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.