This file contains 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 join(op): return lambda *args: "".join(op(*args)) | |
@join # [d]: sometime Tg make offset/length increase by 1 | |
def applySpans(dmsg, op, d, kP="offset", kN="length"): | |
s = dmsg["text"]; i0 = 0 | |
span = lambda e: (e[kP]+d, e[kP]+d+e[kN], e) | |
for (iBeg, iStop, e) in map(span, dmsg["entities"]): | |
yield s[i0:iBeg]; yield op(e["type"], e.get("url"), s[iBeg:iStop]) | |
i0 = iStop | |
yield s[i0:] | |
def transTable(deft="{0}", **d): return lambda tag, data, text: (d.get(tag) or deft).format(text, data) |
This file contains 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
import java.util.*; | |
/** | |
* Cosmic Number | |
* License: Unlicensed | |
**/ | |
public class Cosmic { | |
private static final int ONE = 1; //$ tac - | |
private static final int TEN = ONE*10; | |
private static final int HUNDRED = TEN*10; |
This file contains 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
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.geom.Path2D; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.Arrays; | |
import java.util.stream.Collectors; | |
/** |
This file contains 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
import org.jcodec.api.FrameGrab; | |
import org.jcodec.common.io.NIOUtils; | |
import org.jcodec.common.model.Picture; | |
import org.jcodec.scale.AWTUtil; | |
import java.awt.image.BufferedImage; | |
import java.io.*; | |
import javax.sound.sampled.AudioInputStream; | |
import javax.sound.sampled.AudioSystem; | |
import javax.sound.sampled.Clip; |
This file contains 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 CollapseFrame(Frame): | |
def __init__(self, parent, expanded_text ="Collapse <<", collapsed_text ="Expand >>"): | |
super().__init__(parent) | |
self.parent = parent | |
self._expanded_text = expanded_text | |
self._collapsed_text = collapsed_text | |
self.columnconfigure(1, weight = 1) #grow in grid | |
self._variable = BooleanVar(value=False) | |
self._button = Button(self, command = self.toggle) |
This file contains 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
import _tkinter | |
import threading | |
import traceback | |
from functools import wraps | |
MSG_CALL_FROM_THR_MAIN = "call from main thread" | |
MSG_CALLED_TWICE = "called twice" | |
NOT_THREADSAFE = RuntimeError("call init_threads() first") | |
class FutureResult: |
This file contains 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
那些口口声声“前浪死在沙滩上”的人 | |
应该看看你们 | |
就像我一样 | |
我看着你们 | |
满怀羡慕 | |
新中国成立以来最开放的时代 | |
全球的知识、观点、科技和艺术 | |
像是仅仅只为你们准备的礼物 | |
改革开放、拥抱世界、闷声发大财 | |
地球村的美好乌托邦被逐步构建 |
This file contains 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
霸权威胁--暂停资助世卫组织 | |
认为世卫组织应当听其指挥-- | |
支持捐助--在前期向世卫组织捐款 | |
2000万美元现汇的基础上 | |
增加3000万美元现汇捐款 | |
== | |
合理惩罚--在维尼快乐组织(WHO) | |
前期错误判断的基础上 | |
暂停资助并调查世卫组织, | |
合理冻结4亿美元的捐款 |
This file contains 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
import kotlin.math.abs | |
private val max = CustomBase.from(Long.MAX_VALUE) | |
private val maxLength = max.length | |
object CustomBase { | |
val radix = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toList().toCharArray() | |
val base = radix.size.toLong() | |
fun from(long: Long): String { |
This file contains 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 { fst, snd, identity }; | |
//export { show, read }; | |
const | |
fst = <T0, T1> (xs: [T0, T1]) => xs[0], | |
snd = <T0, T1> (xs: [T0, T1]) => xs[1], | |
identity = <T> (x: T) => x; | |
class Stream<T> { | |
seq: ArrayLike<T>; position: number |