View go-urlencode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func urlencode(s string) (result string){ | |
for _, c := range(s) { | |
if c <= 0x7f { // single byte | |
result += fmt.Sprintf("%%%X", c) | |
} else if c > 0x1fffff {// quaternary byte | |
result += fmt.Sprintf("%%%X%%%X%%%X%%%X", | |
0xf0 + ((c & 0x1c0000) >> 18), | |
0x80 + ((c & 0x3f000) >> 12), | |
0x80 + ((c & 0xfc0) >> 6), | |
0x80 + (c & 0x3f), |
View main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"encoding/xml" | |
"ieee1888" | |
"os" | |
"fmt" | |
"bytes" | |
"io/ioutil" |
View httpserver.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"strconv" | |
) |
View client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"net" | |
"os" | |
"runtime" | |
"time" | |
) |
View server.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"os" | |
) | |
var data []byte | |
var length = 1024 * 100 |
View mgoExample.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"labix.org/v2/mgo" | |
"labix.org/v2/mgo/bson" | |
"time" | |
) | |
type Person struct { |
View mutilcore.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//package main | |
//author: Lubia Yang | |
//create: 2013-12-6 | |
//refer: www.lubia.me/multicore-scheduler-design | |
package main | |
import ( | |
"fmt" | |
"math/rand" |
View Sort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Sort{ | |
private int []letterArray; | |
private void sortLetter(int length) { | |
if (length == 1){ | |
return; | |
} | |
for (int i = 0;i < length-1;i++){ | |
letterArray[i] = letterArray[i] + letterArray[i+1]; | |
System.out.printf("%d ",letterArray[i]); |
View Sort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Sort{ | |
private int []letterArray; | |
private void sortLetter(int length) { | |
for (int i = 0;i < length-1;i++){ | |
System.out.printf("%d ",letterArray[i]); | |
letterArray[i] = (letterArray[i] + letterArray[i+1]) % 10; | |
} | |
System.out.printf("%d \n",letterArray[length-1]); |
View profilingtool.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"runtime" | |
"runtime/debug" | |
"runtime/pprof" | |
"strconv" |
OlderNewer