Skip to content

Instantly share code, notes, and snippets.

@ntuaha
ntuaha / 1. Install python3.6 & pip3.md
Created September 26, 2018 23:27 — forked from alyssaq/1. Install python3.7 & pip3.md
Python3.6 setup on Mac 10.13 (High Sierra)
  1. Install Python 3.6.x from https://www.python.org/downloads/ or via homebrew.
$ brew install python3   # Installed at /usr/local/Cellar/python3

Check that python3 has been installed by running it at the terminal:

$ python3
>>> Python 3.6.5
  1. Download get-pip.py from https://bootstrap.pypa.io/get-pip.py and install (this should already be installed if python was installed from python.org or homebrew):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ntuaha
ntuaha / index.js
Created November 26, 2018 03:10
FB bot on Google Cloud Functions
/**
* Responds to any HTTP request.
*
* @param {!express:Request} req HTTP request context.
* @param {!express:Response} res HTTP response context.
*/
function getToken(req,res){
// Your verify token. Should be a random string.
let VERIFY_TOKEN = "test"
@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')
@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):
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",
import pyaudio
import wave
from array import array
import subprocess
import numpy
import soundfile as sf
import io
import base64
import requests
import json
@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.
@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