Skip to content

Instantly share code, notes, and snippets.

View hyper0x's full-sized avatar
🏠
Working from home

HaoLin hyper0x

🏠
Working from home
  • Freelancer
  • Beijing, China
  • 23:33 (UTC +08:00)
View GitHub Profile
@hyper0x
hyper0x / spell-correct.go
Created October 21, 2015 08:40
Peter Norvig’s Spelling Corrector in Go by Yi.Wang
package main
import (
"fmt"
"io/ioutil"
"regexp"
"strings"
"time"
)
@hyper0x
hyper0x / chan_hotrepl_fixed.go
Last active July 21, 2020 21:14
The hot replacement method of Golang's Channel
package main
import (
"fmt"
"sync"
"time"
)
const CHANGE_SIGN = -1 // The last element of the useless chan1
@hyper0x
hyper0x / tcp_demo.go
Last active August 15, 2023 12:34
The interaction demo via TCP in Golang.
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"net"
"os"
@hyper0x
hyper0x / assignment_copy.go
Created July 25, 2015 16:36
The value is assigned means that generate a copy.
package main
import "fmt"
type Pool struct {
array [3]int
}
func main() {
a := [...]int{1, 2, 3}
package main
import "fmt"
type Person struct {
name string
}
type Dept struct {
persons [4]Person
@hyper0x
hyper0x / copy_demo.go
Last active August 29, 2015 14:21
No deep copy
package main
import "fmt"
type S1 struct {
SS []int
N int
}
func main() {
package main
import (
"fmt"
)
func main() {
i, j := 0, 0
go func() {
for i < (1 << 30) {
@hyper0x
hyper0x / icommand.go
Created November 27, 2012 07:02
executing command in the every sub directory
// These codes is in order to fulfill a need that batch pull from the git repo.
package main
import (
"os"
"os/exec"
"path/filepath"
"log"