Skip to content

Instantly share code, notes, and snippets.

View jumpingchu's full-sized avatar
🎯
Focusing

Jia-Ping Chu jumpingchu

🎯
Focusing
View GitHub Profile
@jumpingchu
jumpingchu / text_detection_with_image_gray_scale.py
Created August 28, 2023 12:06
[Python] Text Detection with image in gray scale using PyTesseract.
import numpy as np
from PIL import Image
import pytesseract
# Open image
img = Image.open('path/to/image.png') # or .jpg
# Turn Image to "Gray scale" (灰階)
img = img.convert('L')
[MYSQL]
HOST = 127.0.0.1
USERNAME = mysql_root
PASSWORD = mysql_password
PORT = 3306
DATABASE = MYSQL_DATA
[MSSQL]
SERVER = test.database.windows.net
USERNAME = mssql_root
@jumpingchu
jumpingchu / 5. importLocalFile.html
Created June 2, 2022 08:17
PyScript demo files
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-env>
- numpy
- matplotlib
- paths:
- ./data.py
</py-env>
@jumpingchu
jumpingchu / 4. librayPlot.html
Created June 2, 2022 08:17
PyScript demo files
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-env>
- numpy
- matplotlib
</py-env>
</head>
@jumpingchu
jumpingchu / 3. writeToTag.html
Created June 2, 2022 08:16
PyScript demo files
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
</head>
<body>
<b><p>Today is <u><label id='today'></label></u></p></b>
<br>
@jumpingchu
jumpingchu / 2. math.html
Created June 2, 2022 08:15
PyScript demo files
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
<py-script>
print("Let's compute π:")
@jumpingchu
jumpingchu / 1. helloWorld.html
Last active June 2, 2022 08:17
PyScript HTML demo files
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body> <py-script> print('Hello, World!') </py-script> </body>
</html>
@jumpingchu
jumpingchu / enable_data_table.py
Last active January 17, 2022 13:38
Google Colab feature
from google.colab import data_table
# 開啟功能
data_table.enable_dataframe_formatter()
# 關閉功能
data_table.disable_dataframe_formatter()
@jumpingchu
jumpingchu / fastapi_aws.py
Last active April 29, 2023 13:40
AWS Lambda + API Gateway + FastAPI + MongoDB
from fastapi import FastAPI
from bson import json_util
import json
from pymongo import MongoClient
from typing import Optional
from mangum import Mangum
app = FastAPI()
mongo_connect = "<mongoDB_connection_URL>"
@jumpingchu
jumpingchu / fb_likes_unlikes.py
Last active June 8, 2021 09:45
利用 FB Graph API 取得按讚/退讚的用戶數 & 來源
import pandas as pd
import openpyxl
import requests
import json
from datetime import datetime, timedelta
from settings import URL, FB, TOKEN, metric, since, until
def extract_data(df, type_names):
dict_type_counts = {type_name: 0 for type_name in type_names}