This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export abstract class Either<L, R> { | |
left!: L; | |
right!: R; | |
static Right = <T>(v: T) => new Right(v); | |
static Left = <T>(v: T) => new Left(v); | |
abstract map<T>(f: (a: R) => T): Either<L, T>; | |
abstract flatMap<T>(f: (a: R) => Either<L, T>): Either<L, T>; | |
abstract orElse<T>(a: Either<L, T>): Either<L, R>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// i tried to add retry button on antd upload list | |
// but no easy way to do it | |
// so i hack it in the following way | |
// the idea is interesting because i am kind of "modifying" React Node children | |
import produce from "immer" | |
const itemRender = (originNode: React.ReactElement, file: UploadFile, fileList: UploadFile[]) => { | |
if(file.status === "error") { | |
const {prefix} = this.props |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def camel_to_snake_case(name: str) -> str: | |
# ord('a') == 97 | |
r = [] | |
new_group = [name[0].lower()] | |
for c in name[1:]: | |
if 97 <= ord(c) <= 122: | |
new_group.append(c) | |
else: | |
r.append("".join(new_group)) | |
new_group = [c.lower()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def invertTree(self, root): | |
""" | |
:type root: TreeNode | |
:rtype: TreeNode | |
""" | |
if root is None: | |
return root | |
if root.left: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var threadNames = []; | |
$('th').each(function(i){ | |
threadNames.push($(this).html()); | |
}); | |
var style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = "@media "+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy from easy_thumbnails | |
from PIL import Image, ImageChops | |
def is_transparent(image): | |
""" | |
Check to see if an image is transparent. | |
""" | |
if not isinstance(image, Image.Image): | |
# Can only deal with PIL images, fall back to the assumption that that | |
# it's not transparent. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gen_permutation(string): | |
if len(string) == 1: | |
yield string | |
for char in string: | |
rest = string.replace(char, "") | |
for p_string in gen_permutation(rest): | |
yield char + p_string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import codecs | |
STATE = "IDEL" # INSERT, SEQUENCE | |
f = open("1.sql", "r") | |
f_w = codecs.open("test.sql", 'w', 'utf-8') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngrok: https://ngrok.com/ # Introspected tunnels to localhost | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Redressed: [https://www.google.com/fonts/specimen/Redressed](https://www.google.com/fonts/specimen/Redressed) | |
NewerOlder