Skip to content

Instantly share code, notes, and snippets.

View fredchu's full-sized avatar
🏠
Working from home

Fred Chu fredchu

🏠
Working from home
View GitHub Profile
// 引入所需的模組
const https = require('https');
const fs = require('fs');
const winston = require('winston');
// 創建 Winston 日誌紀錄器
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
// 引入所需要的套件
const express = require('express');
const winston = require('winston');
const expressWinston = require('express-winston');
// 創建一個新的 Express 應用
const app = express();
const port = 3000;
// 創建一個 Winston 日誌紀錄器,設置輸出檔案
@fredchu
fredchu / twitterBot.py
Last active March 16, 2023 00:44
Twitter bot sample
import tweepy
import schedule
import time
# 填入你的 API Key 和 API Secret
api_key = 'YOUR_API_KEY_HERE'
api_secret = 'YOUR_API_SECRET_HERE'
# 填入你的 Access Token 和 Access Token Secret
access_token = 'YOUR_ACCESS_TOKEN_HERE'
@fredchu
fredchu / tmp_fix_data_reader_yahoo.py
Last active July 12, 2021 08:40
Use pandas_datareader with user agent and session
# reference:
# _get_response without headers doesn't work (at least with 'yahoo' source #867 https://github.com/pydata/pandas-datareader/issues/867
from pandas_datareader import DataReader
import requests
USER_AGENT = {
'User-Agent': ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'
' Chrome/91.0.4472.124 Safari/537.36')
}
@fredchu
fredchu / meta-tag-for-mobile-browsers.md
Last active March 11, 2020 03:07
HTML meta tag in <head> for controlling layouts on mobile browsers
---
parserOptions:
ecmaVersion: 6
env:
browser: true
es6: true
phantomjs: true
jquery: true
globals:
angular: true
[alias]
co = checkout
br = branch
st = status
[color]
ui = true
status = auto
[core]
editor = vim
[filter "media"]
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@fredchu
fredchu / .eslintrc.json
Last active May 18, 2017 02:34
.eslintrc.json
{
"parserOptions": {
"ecmaVersion": 6
},
"env": {
"browser": true,
"es6": true,
"amd": true,
"phantomjs": true,
"jquery": true
@fredchu
fredchu / .eslintrc.yaml
Last active June 2, 2017 01:35
.eslintrc.yaml
---
root: true
env:
browser: true
es6: true
amd: true
phantomjs: true
jquery: true
globals: