Skip to content

Instantly share code, notes, and snippets.

@ntuaha
ntuaha / pg_test.py
Created April 30, 2022 07:44
做相關實驗設計
import logging
from psycopg2 import connect
import contextlib
import psycopg2
import datetime
import random
import pickle
import os
import time
import time
from email.mime.text import MIMEText
import smtplib
import os
def main():
gmailUser = os.environ['EMAIL_USER']
gmailPasswd = os.environ['EMAIL_PWD']
message = MIMEText(f'lol', 'plain', 'utf-8')
message['Subject'] = 'hello world'
@ntuaha
ntuaha / 台灣地址名稱.ipynb
Created March 28, 2020 13:00
擷取台灣地址NER
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ntuaha
ntuaha / funny.py
Created March 18, 2020 05:21
使 test==1 and test==2 and test==3 會等於 True 的 python3 version
from functools import total_ordering
@total_ordering
class TEST:
def __init__(self,a):
self.a = a
def __eq__(self, other):
ans = self.a == other
self.a += 1
@ntuaha
ntuaha / god.ipynb
Created November 16, 2019 17:01
神奇計算
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pyaudio
import wave
from array import array
import subprocess
import numpy
import soundfile as sf
import io
import base64
import requests
import json
PRETRAINED_VOCAB_FILES_MAP = {
'vocab_file':
{
'bert-base-uncased': "https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-vocab.txt",
'bert-large-uncased': "https://s3.amazonaws.com/models.huggingface.co/bert/bert-large-uncased-vocab.txt",
'bert-base-cased': "https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-cased-vocab.txt",
'bert-large-cased': "https://s3.amazonaws.com/models.huggingface.co/bert/bert-large-cased-vocab.txt",
'bert-base-multilingual-uncased': "https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-multilingual-uncased-vocab.txt",
'bert-base-multilingual-cased': "https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-multilingual-cased-vocab.txt",
'bert-base-chinese': "https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-chinese-vocab.txt",
@ntuaha
ntuaha / fugle-realtime-api.py
Created September 18, 2019 05:16 — forked from frieadgood/fugle-realtime-api.py
Fugle realtime API demo code(#2884)
import websocket
def on_message(ws, message):
print(message)
def on_error(ws, error):
print(error)
def on_close(ws):
@ntuaha
ntuaha / main.py
Last active November 28, 2018 01:54
Python version of FB bot Google Cloud Functions
from flask import abort
import requests
def getToken(request):
VERIFY_TOKEN = "test"
mode = request.args.get('hub.mode')
token = request.args.get('hub.verify_token')
challenge = request.args.get('hub.challenge')