Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Work work work

Leechael Leechael

💭
Work work work
View GitHub Profile
@Leechael
Leechael / run_cmd.py
Created Oct 5, 2019
Extract from whooey
View run_cmd.py
#!/usr/bin/env python
import os
import sys
import shlex
import subprocess
from threading import Thread
try:
from Queue import Empty, Queue
except ImportError:
@Leechael
Leechael / fs_ossfs.py
Created Oct 5, 2019
fs-s3fs for Aliyun OSS
View fs_ossfs.py
#!/usr/bin/env python
from fs_s3fs import S3FS
import boto3
from botocore.client import Config
class OSSFS(S3FS):
@property
@Leechael
Leechael / parse_lc_logs.py
Last active May 4, 2019
Parsing exported JSON log from LeanCloud
View parse_lc_logs.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Export logs from leancloud:
`lean logs --format=json --from=2019-03-12 --to=2019-03-13 > 20190312.log`
Then use this script parse the log file.
"""
View recycleview.d.ts
import { Component } from '@tarojs/taro'
interface RecycleContext {
append(list: any[], callback: () => any)
splice(begin: number, count: number, list: any[], callback: () => any)
update(begin: number, list: any[], callback: () => any)
destroy()
forceUpdate(callback: () => any, reinitSlot: boolean)
getBoundingClientRect(index:number)
@Leechael
Leechael / _.js
Created Aug 29, 2018
Resolving Promises Sequentially: Kefir.js version
View _.js
// https://hackernoon.com/functional-javascript-resolving-promises-sequentially-7aac18c4431e
// Kefir.js version.
// Just a demo.
var ids = [1, 2, 3, 4];
var thenables = ids.map(i => {
let thenable = fetch(`https://httpbin.org/anything?id=${i}`)
.then(r => r.json())
.then(obj => obj.args.id);
return Kefir.fromPromise(thenable);
})
@Leechael
Leechael / set-alicdn-ssl-cert.py
Last active Mar 17, 2018
通过脚本设置阿里云 CDN 的证书
View set-alicdn-ssl-cert.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
通过脚本设置阿里云 CDN 的证书
https://help.aliyun.com/document_detail/45014.html
$ pip install aliyun-python-sdk-cdn click
@Leechael
Leechael / Setup Let's Encrypt with Dehydrated.md
Last active Mar 15, 2018
Setup Let's Encrypt with Dehydrated
View Setup Let's Encrypt with Dehydrated.md

Letsencrypt SSL cert 设置笔记

Step 1: 下载 dehydrated

wget https://raw.githubusercontent.com/lukas2511/dehydrated/116386486b3749e4c5e1b4da35904f30f8b2749b/dehydrated

UPDATE: 下载最新版本:

wget https://raw.githubusercontent.com/lukas2511/dehydrated/master/dehydrated
View maybe.py
# maybe.py - a Pythonic implementation of the Maybe monad
# Copyright (C) 2014. Milan Oberkirch <milan.py@oberkirch.org>
# Copyright (C) 2014. Senko Rasic <senko.rasic@goodcode.io>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@Leechael
Leechael / result.py
Last active Jan 16, 2019
Thanks Rust!
View result.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import copy
PY2 = sys.version_info[0] == 2
class Result(object):
@Leechael
Leechael / fputils.py
Created Nov 30, 2016
Buggy: inspect.iscoroutinefunction and inspect.isfunction :(
View fputils.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import inspect
def iscoroutinefunction(fn):
if inspect.iscoroutinefunction(fn):
return True
if inspect.iscoroutinefunction(getattr(fn, "__call__", None)):
return True
You can’t perform that action at this time.