Skip to content

Instantly share code, notes, and snippets.

View seanwu1105's full-sized avatar
💱
Write colorful texts on a dark screen for living.

Shuang Wu seanwu1105

💱
Write colorful texts on a dark screen for living.
View GitHub Profile
@seanwu1105
seanwu1105 / crud-with-cache.kt
Last active June 1, 2022 19:29
Random thought on this
data class RepositoryItem<T>(
val value: T,
val status: Adding | AddingFailed | Added | Removing | RemovingFailed
override fun equals(other: RepositoryItem<T>) {
return value == other.value
}
)
interface ListRepository<T> {
@seanwu1105
seanwu1105 / rxjs-wtf.md
Last active November 27, 2020 07:21
RxJS WTF

RxJS WTF

tap(_ => func()) != mapTo(func())

Assume func is a synchronized function. tap(_ => func()) will call the function lazily. However, mapTo(func()) will call the function eagerly.

forkJoin

  • forkJoin will not emit anything if the input is an empty array.
  • forkJoin only emit one value than complete.
@seanwu1105
seanwu1105 / capture_schema.json
Last active November 5, 2020 03:06
Information Schema for Capture with Numbers Backend
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"description": "Assertion provided by Starling Capture.",
"examples": [
{
"proof": {
"hash": "b08714406df079733fdbc0566aa28ff4b20abd13e3a2042ddd214bc4d4f81f7c",
"mimeType": "image/jpeg",
"timestamp": 1600177819743
@seanwu1105
seanwu1105 / numbersprotocol.starling.json
Last active September 18, 2020 05:53
Starling Schema for CAI Assertion Spec
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"description": "Assertion provided by Starling Capture.",
"examples": [
{
"device_board": "sdm845",
"device_brand": "htc",
"current_address": "No. 77, Jinshan North Road, Zhongzheng District, Taipei City, Taiwan 100",
"current_gps_latitude": "25.045234",
@seanwu1105
seanwu1105 / Dockerfile
Created September 10, 2019 09:28
Textile Dockerfile
FROM ubuntu:latest
SHELL ["/bin/bash", "-c"]
RUN apt-get update && \
apt-get install -y \
git \
build-essential \
wget
@seanwu1105
seanwu1105 / macOSInUbuntu.md
Last active July 11, 2019 10:18
Install macOS with Virtual Box in Ubuntu

Install macOS with Virtual Box in Ubuntu

Install Virtual Box 6.x

Download and install Virtual Box 6.x from the website.

Deal with Annoying Secure Boot

You have 2 options: disable secure boot or sign the kernel modules. We only mention how to sign kernel modules without disabling secure boot.

@seanwu1105
seanwu1105 / README.md
Last active March 3, 2019 08:32
Change the last modified, creation and access time of files in Windows.

Change Timestamps in Windows

Get Started

Open PowerShell

Open PowerShell in the target directory. Normally, you can open PowerShell in current directory by holding shift and right-clicking the context menu Open PowerShell Here.

Use the Following Commands

@seanwu1105
seanwu1105 / remove_last_element_comparison.py
Last active December 2, 2018 09:48
Compare the performance about removing last element from iterables (string, tuple, list, deque, numpy.ndarray and bitarray).
import timeit
import collections
import itertools
import numpy as np
from bitarray import bitarray as b
def test_slice(data):
for i in reversed(range(len(data))):
@seanwu1105
seanwu1105 / pyqt5.py
Created August 14, 2018 05:26
PySide2 QThread Issue
import sys
from PyQt5.QtCore import QThread
from PyQt5.QtWidgets import (QApplication, QMainWindow, QPushButton,
QComboBox, QWidget, QVBoxLayout)
class Task(QThread):
def run(self):
print('task started')
@seanwu1105
seanwu1105 / articles_list_spider.py
Last active July 21, 2018 11:52
Wikipedia zhTW Article Names Spider
import scrapy
class ArticlesListSpider(scrapy.Spider):
name = "articles_list"
page_counter = 0
def start_requests(self):
urls = [
r'https://zh.wikipedia.org/wiki/Special:%E6%89%80%E6%9C%89%E9%A1%B5%E9%9D%A2'