This file contains hidden or 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
| local function my_ipairs(t) | |
| local i = 1 | |
| return function() | |
| local v = t[i] | |
| if v then | |
| local ii = i | |
| i = i + 1 | |
| return ii, v | |
| else | |
| return nil |
This file contains hidden or 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" | |
| func main() { | |
| count := 60 | |
| diff := float64(1.0) | |
| for i := 0; i <= count; i++ { | |
| diff *= float64((365 - float64(i)) / 365) // would be all different day. | |
| fmt.Printf("times %d, diff [%.2f%%], same [%.2f%%]\n", i, diff*100, (1-diff)*100) |
This file contains hidden or 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
| x = { | |
| value = 1, | |
| text = "test", | |
| inest = { | |
| aaaa = "1", | |
| eee = { | |
| abc = 1 | |
| }, | |
| bl = true, | |
| } |
This file contains hidden or 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" | |
| "reflect" | |
| "unsafe" | |
| ) | |
| type NestType struct { | |
| S string |
This file contains hidden or 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" | |
| "os" | |
| "runtime" | |
| "time" | |
| ) | |
| // Results of this program on my machine: (linux amd64, go 1.4): |
This file contains hidden or 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
| #!/bin/bash | |
| curl -v "http://localhost:8080/" | |
| curl -v --data-urlencode "value=1" "http://localhost:10888" | |
| curl -v --data-urlencode "value=2" "http://localhost:10888" | |
| curl -v --data-urlencode "value=3" "http://localhost:10888" | |
| curl -v --data-urlencode "value=4" "http://localhost:10888" | |
| curl -v --data-urlencode "value=5" "http://localhost:10888" | |
| curl -v "http://localhost:8080/" |
This file contains hidden or 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
| mkdir C:\DailyBuild\%date:~10,4%%date:~4,2%%date:~7,2% | |
| cd C:\MyGame | |
| copy /Y ProjectSettings.asset MyGame\Project\ProjectSettings\ | |
| "C:\Program Files\Unity\Editor\Unity.exe" -batchmode -nographics -quit -projectPath "C:\MyGame\Project" -buildTarget Win -buildWindowsPlayer "C:\DailyBuild\%date:~10,4%%date:~4,2%%date:~7,2%\cm.exe" |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| typedef struct node { | |
| int val; | |
| struct node* next; | |
| } node_t; | |
| void print_list(node_t* head) { | |
| node_t* cur = head; |
This file contains hidden or 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
| #!/bin/bash | |
| # Ensure that you have compiled the entire go source. | |
| # set -x | |
| set -e | |
| [ ! -d go ] && { echo "There is no go source code here."; exit 1; } | |
| [ -d go_bootstrap ] && { echo "You have had go_bootstrap directory."; exit 1;} | |
| mkdir -p go_bootstrap/pkg | |
| echo "Create go_bootstrap directory successful" | |
| cp -r go/{bin,src} go_bootstrap/ | |
| cp -r go/pkg/{include,linux_amd64,tool} go_bootstrap/pkg/ |
This file contains hidden or 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 ( | |
| "encoding/json" | |
| "fmt" | |
| ) | |
| func dumpMap(space string, m map[string]interface{}) { | |
| for k, v := range m { | |
| if mv, ok := v.(map[string]interface{}); ok { |