Skip to content

Instantly share code, notes, and snippets.

View songtianyi's full-sized avatar
😈
Focusing

songtianyi

😈
Focusing
View GitHub Profile
@songtianyi
songtianyi / padding_space.go
Last active March 16, 2021 11:53
padding space between en and zh words
package main
import (
"bufio"
"fmt"
"os"
"unicode"
"unicode/utf8"
)
@songtianyi
songtianyi / legacy.go
Last active July 3, 2020 11:02
add init options for legacy code
package main
type AnyOther struct{}
type Module interface {
Classify(*AnyOther)
}
type SomeModule struct {
Param string
@songtianyi
songtianyi / check_udp_tcp_port_open.go
Last active July 3, 2020 10:52
udp/tcp port open check
package main
import (
"fmt"
"net"
"strings"
"time"
"github.com/ziutek/telnet"
)
@songtianyi
songtianyi / douban_ebooks.go
Last active July 13, 2020 11:30
A cli tool to crawl available e-books from your wish list(eg. douban)
package main
import (
"fmt"
"os"
"strconv"
"github.com/songtianyi/laosj/spider"
"github.com/urfave/cli"
)
@songtianyi
songtianyi / go_stream_like_java.go
Last active January 29, 2023 02:35
program golang slices like java Stream API
package main
import (
"fmt"
"reflect"
)
type Data struct {
foo string
bar string
@songtianyi
songtianyi / groovy_demo
Last active July 13, 2020 11:31
groovy demos
public class GroovyTest {
// sum method
def static sum(n, closure) {
for(int i = 2; i <= n; i += 2) {
closure(i)
}
// return 2
2
}
@songtianyi
songtianyi / cards_shuffle
Last active July 13, 2020 11:32
cards shuffle algorithm
START WITH FRESH DECK
GET RANDOM SEED
FOR CT = 1, WHILE CT <= 52, DO
X = RANDOM NUMBER BETWEEN CT AND 52 INCLUSIVE
SWAP DECK[CT] WITH DECK[X]
@songtianyi
songtianyi / import_google_package
Last active July 13, 2020 11:33
golang.org/x installation
mkdir $GOPATH/src/golang.org/x
cd $GOPATH/src/golang.org/x
git clone https://github.com/golang/net.git
@songtianyi
songtianyi / mxnet.Dockerfile
Last active July 13, 2020 11:33
(ML with go)mxnet env Dockerfile sharing
FROM daocloud.io/library/ubuntu:wily-20160706
MAINTAINER songtianyi <[email protected]>
RUN echo "deb http://mirrors.aliyun.com/ubuntu xenial main restricted universe multiverse\n" > /etc/apt/sources.list
# Pick up some dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
clang \