Skip to content

Instantly share code, notes, and snippets.

View andy23512's full-sized avatar

Tangent Chang andy23512

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import json
# the file to be converted
filename = 'data.txt'
# resultant
list1 = []
# fields in the sample file
import time
import threading
import queue
class Worker(threading.Thread):
def __init__(self):
super().__init__() # 此行等同於呼叫 threading.Thread.__init__(self) 詳細搜尋python super的用法
self.queue = queue.Queue() # queue改成創在裡面 把邏輯封裝起來 避免外面使用時漏創
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andy23512
andy23512 / inject.sh
Created December 16, 2019 01:14
Inject javascript to html via shell
#!/bin/sh
BASE_HREF=${WEB__FRONTEND__BASE_HREF:-/}
BASE_HREF=${BASE_HREF/\//\\\/}
cat output.html | \
sed -e "\/head/s/<script>window\.__baseHref = '.*';<\/script>//g" | \
sed -e "\/head/s/<\/head>/<script>window.__baseHref = '${BASE_HREF}';<\/script><\/head>/"
from numba import jit
import numpy as np
import matplotlib.pyplot as plt
from scipy import fftpack
from multiprocessing import Pool
import time
@jit
def rho_m_p(x,y,t,tg):
if (x-0.08*np.cos(2.*np.pi*f*t))**2+(y-0.08*np.sin(2.*np.pi*f*t))**2-0.025**2<0.:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import requests
import json
from urllib.parse import urljoin
import csv
shop_url = "https://shopee.tw/api/v2/search_items/?by=pop&fe_categoryids=69&limit=50&newest=0&order=desc&page_type=search&version=2"
ur_lf = "https://cf.shopee.tw/file/"
header = {
'cookie': '_gcl_au=1.1.1987342463.1572686968; welcomePkgShown=true cto_lwid=2a4e4fc0-d508-4a4e-86de-52612a1d244d; csrftoken=ZJ47Qz7EPFSThuJdgkS4Udol2azRld5l; SPC_IA=-1; SPC_EC=-; SPC_U=-; SPC_F=ZAL47XshGSkEkQ4jL9QVr0WxFjTBgn3M; REC_T_ID=45ce213e-fd53-11e9-a5ab-b4969146215a; SPC_SI=n7okof36mnln2cld5l2bhc9tft1yijjv; welcomePkgShown=true; __BWfp=c1572686972851xf197594b1; cto_lwid=2a4e4fc0-d508-4a4e-86de-52612a1d244d; _ga=GA1.2.1595656738.1572686973; _gid=GA1.2.378337183.1572686973; _med=refer; AMP_TOKEN=%24NOT_FOUND; SPC_T_IV="GgObPrWQxcA66TWJ7gmD0Q=="; SPC_T_ID="FwDYMyOZa8MakiQSZLHLk8NK1OxxaffoZrZUHnVc8WGRj9+BYUR39q0VicgQ5hh/e2WCw0Ax7s2V+1aWfiRNhktFwqJpoA9hLQ6aQHZ1mlA="',
@andy23512
andy23512 / folium.ipynb
Last active October 27, 2019 04:50
Show lat lng of mark cluster on folium map
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andy23512
andy23512 / plot.py
Created October 13, 2019 04:46
animated scatter plot
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
from matplotlib import animation
#######
# Func.
#######
f = 0.125 # t是0,1,2,3,...這樣跳,所以你這裡用整數會每個tick跑一圈,我這改成跑1/8圈