Skip to content

Instantly share code, notes, and snippets.

View fangpenlin's full-sized avatar
🚀

Fang-Pen Lin fangpenlin

🚀
View GitHub Profile
app = XCUIApplication()
app.launchEnvironment["ENV_VAR"] = "Env value"
app.launchArguments = ["-user-id", "12345"]
app.launch()
client = MockAPIClient()
client.returnValueForGetUser = "MOCK_DATA"
class MockAPIClient: APIClientProtocol {
var returnValueForGetUser: String
func getUser(id: String) {
return returnValueForGetUser
}
}
import Embassy
import EnvoyAmbassador
let loop = try! SelectorEventLoop(selector: try! KqueueSelector())
let router = Router()
let server = HTTPServer(
eventLoop: loop,
app: router.app,
port: 8080
)
public typealias SWSGI = (
environ: [String: Any],
startResponse: ((String, [(String, String)]) -> Void),
sendBody: ([UInt8] -> Void)
) -> Void
import time
import threading
import pytest
import psycopg2
def acquire(conn, poll_period=0.1):
cur = conn.cursor()
while True:
@fangpenlin
fangpenlin / gist:640c0e1aa647d905c587
Created August 11, 2014 07:16
parse_setup ansible module
#!/usr/bin/python
import os
import sys
import ast
import textwrap
def parse_setup(setup_filename):
"""Parse setup.py and return args and keywords args to its setup
function call
import winsound
import time
# Base tune
D_BASE = 264
# How long a meter is
METRE = 500
DO = 0
#!/bin/sh
FILES=$(git diff HEAD^ HEAD --name-only --diff-filter=ACM | grep -e '\.py$')
for f in $FILES
do
# auto pep8 correction
autopep8 --in-place --ignore=E309,E501,W293 $f
done
import datetime
begin = datetime.time(11, 48)
end = datetime.time(12, 15)
#timedelta = end - begin
#print timedelta
timedelta = datetime.timedelta(seconds=26)
def time_add(t, delta):