Skip to content

Instantly share code, notes, and snippets.

View dtynn's full-sized avatar

Caesar Wang dtynn

  • None
  • Shanghai China
View GitHub Profile
#coding=utf-8
from bs4 import BeautifulSoup
import urllib2
request_header = dict()
request_header['User-Agent'] = "kanjianbox spider"
url = "http://www.kanjian.com/"
request = urllib2.Request(url, None, request_header)
{
"agentNames": {
"fMMJNda6xN": "dtynn"
},
"customerNames": {
"XebA6tvhbf": "d@dtynn.me"
},
"ticket": {
"assignedTo": "fMMJNda6xN",
"belongToOrganization": "RNPnzmohvD",
package main
import (
"log"
"github.com/blevesearch/bleve"
)
func main() {
indexMapping := bleve.NewIndexMapping()
@dtynn
dtynn / gist:7d7fd0003ec6c43ce952
Created May 14, 2015 06:33
bleve highlight panic
panic: runtime error: slice bounds out of range
goroutine 1 [running]:
github.com/blevesearch/bleve/search/highlight/fragmenters/simple.(*Fragmenter).Fragment(0x2088f6f40, 0x208972299, 0x3, 0x3, 0x2089200a0, 0x1, 0x1, 0x0, 0x0, 0x0)
/Users/dtynn/work/gopj/src/github.com/blevesearch/bleve/search/highlight/fragmenters/simple/fragmenter_simple.go:57 +0x927
github.com/blevesearch/bleve/search/highlight/highlighters/simple.(*Highlighter).BestFragmentsInField(0x208927290, 0x20891e640, 0x20891e7c0, 0x208972328, 0x4, 0x1, 0x0, 0x0, 0x0)
/Users/dtynn/work/gopj/src/github.com/blevesearch/bleve/search/highlight/highlighters/simple/highlighter_simple.go:84 +0x3c0
github.com/blevesearch/bleve.(*indexImpl).Search(0x2088fc230, 0x208922230, 0x0, 0x0, 0x0)
/Users/dtynn/work/gopj/src/github.com/blevesearch/bleve/index_impl.go:447 +0x13a0
main.main()
@dtynn
dtynn / gist:8be6ed079fa6df8f0270
Created May 14, 2015 06:55
bleve highlight incorrect result
package main
import (
"log"
"github.com/blevesearch/bleve"
)
func main() {
indexMapping := bleve.NewIndexMapping()
@dtynn
dtynn / gist:b52f0a4c21babbeeafc0
Last active August 29, 2018 05:32
mgo query select
package main
import (
"log"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
func main() {
package main
import "fmt"
func main() {
for i := 0; i < 5; i++ {
fmt.Println("Hello, World!")
}
}
func restore(repos []string) error {
errChan := make(chan error, 1)
sem := make(chan int, 4) // four jobs at once
var wg sync.WaitGroup
wg.Add(len(repos))
for _, repo := range repos {
sem <- 1
go func() {
defer func() {
wg.Done()
package code
import (
"fmt"
)
type Stack struct {
stack []int
minIdx int
}