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 ( | |
| "bytes" | |
| "fmt" | |
| "image/color" | |
| "log" | |
| "github.com/hajimehoshi/ebiten/v2" | |
| "github.com/hajimehoshi/ebiten/v2/examples/resources/fonts" |
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
| W0F1dG9Qcm94eSAwLjIuOV0KISBDaGVja3N1bTogNkNjTERsU2UwNVhIdWRPTnNz | |
| Y2p6dwohIEV4cGlyZXM6IDZoCiEgVGl0bGU6IEdGV0xpc3Q0TEwKISBHRldMaXN0 | |
| IHdpdGggRVZFUllUSElORyBpbmNsdWRlZAohIExhc3QgTW9kaWZpZWQ6IEZyaSwg | |
| MjUgRGVjIDIwMjAgMTE6MzQ6MjMgLTA1MDAKIQohIEhvbWVQYWdlOiBodHRwczov | |
| L2dpdGh1Yi5jb20vZ2Z3bGlzdC9nZndsaXN0CiEgTGljZW5zZTogaHR0cHM6Ly93 | |
| d3cuZ251Lm9yZy9saWNlbnNlcy9vbGQtbGljZW5zZXMvbGdwbC0yLjEudHh0CiEK | |
| ISBHRldMaXN0IGlzIHVubGlrZWx5IHRvIGZ1bGx5IGNvbXByaXNlIHRoZSByZWFs | |
| CiEgcnVsZXMgYmVpbmcgZGVwbG95ZWQgaW5zaWRlIEdGVyBzeXN0ZW0uIFdlIHRy | |
| eQohIG91ciBiZXN0IHRvIGtlZXAgdGhlIGxpc3QgdXAgdG8gZGF0ZS4gUGxlYXNl | |
| CiEgY29udGFjdCB1cyByZWdhcmRpbmcgVVJMIHN1Ym1pc3Npb24gLyByZW1vdmFs |
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
| fn print_type_of<T>(_: &T) { | |
| println!("{}", std::any::type_name::<T>()) | |
| } |
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
| use std::mem; | |
| #[derive(Debug)] | |
| enum Node { | |
| Valued { val: i32, next: Box<Node> }, | |
| Nil, | |
| } | |
| #[derive(Debug)] | |
| struct LinkedList { |
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
| import datetime as dt | |
| import mysql.connector | |
| sql_load_users = "SELECT user_id, superior_user_id, indentor_level_id FROM yx_wechat_user" | |
| sql_load_orders = "SELECT order_id, user_id, total_price, end_time FROM yx_store_order WHERE status = 3" | |
| sql_insert_history = ("INSERT INTO yx_purchase_history(" | |
| "order_id," # 该记录的关联订单号 | |
| "uid," # 订单消费的用户 id | |
| "team_uid," # 记录所属团队(订单产生的业绩、分佣、奖励金额算在谁头上)的 id | |
| "purchase_time," # 记录发生时间(一般是订单完成时间,等) |
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
| // Get preferred outbound ip of this machine | |
| func GetOutboundIP() net.IP { | |
| conn, err := net.Dial("udp", "8.8.8.8:80") | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| defer conn.Close() | |
| localAddr := conn.LocalAddr().(*net.UDPAddr) | |
| return localAddr.IP | |
| } |
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 jsonsampler | |
| import ( | |
| "encoding/json" | |
| "reflect" | |
| "testing" | |
| ) | |
| type Struct1 struct { | |
| Name 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 ( | |
| "log" | |
| "reflect" | |
| "time" | |
| "github.com/golang/protobuf/jsonpb" | |
| "github.com/golang/protobuf/proto" | |
| "golang.org/x/net/context" |
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
| // NOT completed! | |
| // should consider about non-full count: | |
| // 10, is 2-digi int, but not using fully count(2) | |
| func rotatedDigits(N int) int { | |
| switch { | |
| case N<=10000 && N>=1000: return count(4) | |
| case N<1000 && N>=100: return count(3) | |
| case N<100 && N>=10: return count(2) | |
| case N<10 && N>=1: return count(1) |
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
| func rotateString(A string, B string) bool { | |
| if len(A) != len(B) { | |
| return false | |
| } | |
| l := len(A) | |
| if l == 0 { | |
| return true | |
| } | |
NewerOlder