Skip to content

Instantly share code, notes, and snippets.

View dearsherlock's full-sized avatar

Sherlock Tsai dearsherlock

View GitHub Profile
#登入的角色
RoleArray=["Papa","MAMA","ELSA"]
randRole=RoleArray[new Random().nextInt(RoleArray.length)]
mFirebaseAnalytics.setUserProperty("Role", randRole);
#用戶本身訂購身分
AuthforArray=["電影199/好萊塢199","電影199","好萊塢199"]
randAuthfor=AuthforArray[new Random().nextInt(AuthforArray.length)]
mFirebaseAnalytics.setUserProperty("Authfor", randAuthfor);
#############以上只要設定一次,每次進電影館就重新設定一次,模擬不同用戶,但同一個對話中不用多次設定##################
@dearsherlock
dearsherlock / 1.py
Created January 11, 2019 06:32
mysql8
def favorite_colors() -> List[Dict]:
config = {
'user': 'root',
'password': 'root',
'host': 'db',
'port': '3306',
'database': 'knights',
'auth_plugin':'mysql_native_password'
}
connection = mysql.connector.connect(**config)
@dearsherlock
dearsherlock / test.py
Created January 11, 2019 06:28
mysqlconnect
def favorite_colors() -> List[Dict]:
config = {
'user': 'root',
'password': 'root',
'host': 'db',
'port': '3306',
'database': 'knights'
}
connection = mysql.connector.connect(**config)
cursor = connection.cursor()
@dearsherlock
dearsherlock / .log
Created January 11, 2019 01:50
log
Creating python-mysql-docker_db_1 ... error
ERROR: for python-mysql-docker_db_1 Cannot create container for service db: b'Drive has not been shared'
ERROR: for db Cannot create container for service db: b'Drive has not been shared'
ERROR: Encountered errors while bringing up the project.
@dearsherlock
dearsherlock / docker-compose.yml
Created January 10, 2019 03:09
docker-compose.yml
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
redis:
image: "redis:5.0.3"
@dearsherlock
dearsherlock / Dockerfile
Last active January 10, 2019 01:31
建立python容器
FROM python:3.7.2
# 從 python3.7 基礎上加工
ADD . /code
# 將本地端程式碼複製到 container 裡面 ./code 資料夾
WORKDIR /code
# container 裡面的工作目錄
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
@dearsherlock
dearsherlock / youtubedataapi.json
Created December 4, 2017 09:24
youtubedataapi.json
{
"kind": "youtube#channelListResponse",
"etag": "\"7991kDR-QPaa9r0pePmDjBEa2h8/1Ym_0imfWXTcQF1N7fVPwCcvX44\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
@dearsherlock
dearsherlock / c.coffee
Last active July 17, 2017 14:32
Non-regular shape mask
recTangleLayer=new Layer
width: 395
height: 223
backgroundColor: "transparent"
style:
WebkitMask: "url(images/MovieSession.png)"
WebkitMaskSize: "cover"
WebkitMaskType: "alpha"
parent:itemLayer
clip: true
@dearsherlock
dearsherlock / a.coffee
Created July 17, 2017 14:18
MOVIEINFO PRECOESS
isGetWebInfoKey.on Events.StateSwitchStop,(from,to)->
if to=="get"
result=JSON.parse(stringAuthResponse)
for item in result["data"]
catchplay =new CatchPlayInfo
catchplay.Title=item["title"]
catchplay.FeatureImage=item["assets"]["keyVisualUrl"]
catchplay.TypeLabel=item["typeLabel"]
CatchPlayInfos.push catchplay
loadDataOK.states.switch("get")
@dearsherlock
dearsherlock / A.Coffee
Created July 17, 2017 14:16
FAKE MOVIEINFO
GetMovieInfo=()->
r = new XMLHttpRequest
r.open 'GET', 'https://sunapi.catchplay.com/webcms/articles/all?limit=15&offset=1'
#catchplay第二個API需要把第一個API取得的資訊帶回去
r.setRequestHeader('Authorization', TheKey);
r.setRequestHeader('Accept-Language', "zh-TW");
r.onreadystatechange = ->
if(r.status >= 400)