Skip to content

Instantly share code, notes, and snippets.

View mattwang44's full-sized avatar
🦈

Wei-Hsiang (Matt) Wang mattwang44

🦈
View GitHub Profile
import logging
from pymongo import MongoClient
from sshtunnel import SSHTunnelForwarder
# local
SSH_PASSPHRASE = 'you ssh passphrase (if any)'
LOCAL_BIND_PORT = 27017
SSH_KEYPATH = '/your/path/to/key/file'
@mattwang44
mattwang44 / structuredLogger.py
Created May 19, 2020 11:39
Simple python structured logger
import logging
import json
# modified from https://docs.python.org/3/howto/logging-cookbook.html#implementing-structured-logging
class StructuredLogger:
''' The wrapper of logger that handles structurizing logs
and passing logs to the root logger '''
@mattwang44
mattwang44 / findOneOrCreate.js
Created April 20, 2020 18:38
Mongo query tips
// findOneOrCreate in Mongoose:
// Return the original doc (no modification) if it can be found and create a new doc if cannot be found.
// Without `$setOnInsert`, it will update the doc if it can be found.
Model.findOneAndUpdate(
{name: 'Matt'},
{$setOnInsert: {score: 60}},
{upsert: true, new: true}
)
// Set `setDefaultsOnInsert` to true in option if need to insert with setting the default value.
@mattwang44
mattwang44 / downloadFromS3_async.py
Last active April 2, 2024 07:56
async download from AWS S3 using aiobotocore
import os
import asyncio
import aiobotocore
import io
from PIL import Image
AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']

台灣人工智慧學校新竹分校第一期技術領袖培訓班資格考試考古題

gist僅為備份用檔案,完整rendered題目請見hackmd

參考解答會在選項前以星號(*)標記,不過目前並不保證一定正確,各位高手可以自行編輯(需登入)更正答案或提供各題詳解。 感謝一同討論解題的各位: Paul, 陳彥吉, 游聲峰Robert, Sean, Moony Hsieh, johnson, 怡中

Calculus

  1. Let the function $f(x)=ax^3+bx^2+cx+d$. Suppose that $f(0)=4$ is a critical point of $f$ and $f(1)=-2$ is a point of inflection, find $a$, $b$, $c$ and $d$.

台灣人工智慧學校(台北)第二期技術領袖培訓班資格考試考古題

gist僅為備份檔案,rendered題目請見hackmd

參考解答會在選項前以星號(*)標記,不過目前並不保證一定正確,各位高手可以自行編輯(需登入)提供各題詳解。

感謝提供題目的Anio俊傑和一同討論解題的各位: Sean, Moony Hsieh, johnson, 怡中, Jacky Chang

Calculus