Skip to content

Instantly share code, notes, and snippets.

@WayneCui
WayneCui / viterbi.py
Created January 22, 2019 11:46
viterbi algorithm demo from wikipedia
states = ('Healthy', 'Fever')
observations = ('normal', 'cold', 'dizzy')
start_probability = {'Healthy': 0.6, 'Fever': 0.4}
transition_probability = {
'Healthy' : {'Healthy': 0.7, 'Fever': 0.3},
'Fever' : {'Healthy': 0.4, 'Fever': 0.6},
}
emission_probability = {
'Healthy' : {'normal': 0.5, 'cold': 0.4, 'dizzy': 0.1},
'Fever' : {'normal': 0.1, 'cold': 0.3, 'dizzy': 0.6},
import java.time.LocalDate;
public class WhichDayOfYear {
public static void main(String[] args) {
//获取系统时间
LocalDate today = LocalDate.of(2018, 8, 13);
//%tj表示一年中的第几天
String strDate =String.format("今天是今年的第%tj天!!",today);
//输出时间
System.out.println(strDate);
@WayneCui
WayneCui / CountDownLatchDemo.java
Created August 6, 2018 16:26
CountDownLatchDemo
import java.util.concurrent.CountDownLatch;
public class CountDownLatchDemo {
public static void main(String[] args) {
final CountDownLatch gate = new CountDownLatch(3);
Thread t1 = new Thread(){
public void run() {
try {
Thread.sleep(3000);
@WayneCui
WayneCui / converter.py
Last active July 3, 2018 08:14
yolov3 to TF converter, not finished!!!
#! /usr/bin/env python
"""
Reads Darknet config and weights and creates Tensorflow model.
"""
import argparse
import configparser
import io
@WayneCui
WayneCui / mnist-loader.red
Last active April 26, 2018 10:45
A mnist loader in Red
Red [
author: "Wayne Cui"
description: {Should first download the mnist data from http://yann.lecun.com/exdb/mnist/}
]
train-image-filename: "data/train-images-idx3-ubyte"
train-label-filename: "data/train-labels-idx1-ubyte"
test-image-filename: "data/t10k-images-idx3-ubyte"
test-label-filename: "data/t10k-labels-idx1-ubyte"
Red []
f: function[s][
print 10 * s
]
f1: function[s][
print 100 * s
]
@WayneCui
WayneCui / login2douban.reb
Created January 13, 2015 12:19
login to douban.com
Rebol [
title: %login2douban.reb
date: 13-Jan-2015
author: "Graham Chiu / Cui Wen"
purpose: {login to douban.com}
description: { based on Graham Chiu's login2so.reb: https://github.com/gchiu/Rebol3/blob/master/scripts/login2so.reb}
]
print "loading modified prot-http.r3"
do https://raw.githubusercontent.com/gchiu/Rebol3/master/protocols/prot-http.r3
@WayneCui
WayneCui / parse-file-uploads-data.reb
Last active August 29, 2015 14:10
Parse file uploads data by HTTP
Rebol [
Title: "Parse file uploads data by HTTP"
Author: "Cui Wen"
Description: {
simulate file-uploading via curl:
curl --form upload=@D:/a.txt --form upload=@D:/a.jpg --form press=OK http://localhost:8080
}
]
server: open tcp://:8080
@WayneCui
WayneCui / comment-cleaner.reb
Last active August 29, 2015 14:10
remove comments from JS source files
Rebol [
Title: {remove comments from JS source files}
Author: "Cui Wen"
File: %comment-cleaner.reb
Version: 0.1.0
Tabs: 4
]
data: {
/**
>> type? f: func[][print "foo"]
== function!
>> type? get 'f
== function!
>> type? f
"foo"
== unset!