Skip to content

Instantly share code, notes, and snippets.

@reusee
reusee / a.go
Last active November 2, 2019 17:40
package main
import "fmt"
func cached(
fn func(int) int,
) (
decorated func(int) int,
) {
cache := make(map[int]int)
package main
import (
"crypto/md5"
"encoding/binary"
"runtime"
"sync"
)
func main() {
package main
import (
"encoding/json"
"fmt"
)
type Item struct {
Raw json.RawMessage
Values map[string][]int
@reusee
reusee / a.js
Created June 9, 2019 15:26
batch delete zhihu answers
fetch('/api/v4/members/aaaaaaa/answers').then(resp => { return resp.json() }).then(j => { for (const row of j.data) { fetch('/api/v4/answers/' + row.id, { method: 'DELETE', credentials: 'same-origin' } ).then(resp => { console.log(resp) }) } })
package main
import (
"fmt"
)
func main() {
run := func(str string, wait chan struct{}, sig chan struct{}) {
for i := 0; i < 10; i++ {
<-wait
@reusee
reusee / e.go
Created November 8, 2013 15:25
extract subtitle stream from mkv file, using libav
package main
/*
#cgo LDFLAGS: -lavformat -lavutil -lavcodec
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
*/
import "C"
import (
"fmt"
@reusee
reusee / a.go
Created January 11, 2019 09:03
a.go
var data struct {
Status int
Content string
Data struct {
Seats map[int]struct{
NickName string
Avatar string
UID int
}
}
@reusee
reusee / malformed.go
Last active November 15, 2018 02:39
malformed.go
package main
import (
"encoding/json"
"fmt"
"strings"
)
func main() {
j := `
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="report.js"></script>
<script src="system-production.js"></script>
<script src="aff.js"></script>
</head>
@reusee
reusee / priority.go
Created October 15, 2017 10:24
priority
package main
import (
"fmt"
"sync"
"time"
)
func main() {
pt := fmt.Printf