Bị theo dõi (Permanent Record) - Edward Snowden
2020-07-15
- 6 tuổi: vặn đồng hồ chậm lại để chơi cho đã
- 7 tuổi: tháo tung con máy Nintendo ra vì đang chơi Super Mario thì bị hỏng
- 7 tuổi rưỡi: chép những dòng code “Hello world” đầu tiên trong một lần được đến công ty ba chơi
- 12 tuổi: làm quen với máy tính trên chiếc Compaq Presario 425 (Intel 486, ổ cứng 200MB)
- 13 tuổi: hack website của Phòng thí nghiệm Quốc gia Los Alamos (sau đó thì được cảm ơn và hẹn liên lạc lại khi nào 18 tuổi)
Save draft mail in Zimbra web client using ChromeDP
2020-07-03
As an engineer, I want to automate everything as much as possible. This CLI tool is created to save a draft mail in Zimbra web client.
Read config file:
1func initConfig() { 2 if cfgFile != "" { 3 // Use config file from the flag. 4 viper.SetConfigFile(cfgFile) 5 } else { 6 // Find home directory. 7 home, err := homedir.Dir() 8 if err != nil { 9 fmt.Println(err) 10 os.Exit(1) 11 } 12 13 // Search config in home directory with name ".zwc" (without extension). 14 viper.AddConfigPath(home) 15 viper.SetConfigName(".zwc") 16 } 17 18 viper.AutomaticEnv() // read in environment variables that match 19 20 // If a config file is found, read it in. 21 if err := viper.ReadInConfig(); err != nil { 22 log.Fatal(err) 23 } 24 25 fmt.Println("Using config file:", viper.ConfigFileUsed()) 26}
How to trigger build steps based on modified directory?
2020-06-26
Using monorepo with multiple micro services, every single commit will trigger a full lint/test/build/publish for every service. What can I do to limit the scope?
To do that, we can use git diff
to show changes between commits:
1 if [[ -n "${DRONE_PULL_REQUEST}" ]]; then 2 most_recent_before="origin/${DRONE_TARGET_BRANCH}" 3 elif [[ "${DRONE_BUILD_EVENT}" = "push" && ("${DRONE_COMMIT_BRANCH}" = "master" || "${DRONE_COMMIT_BRANCH}" = "release-"*) ]]; then 4 if [[ "${DRONE_COMMIT_BEFORE}" = "$zero" ]]; then 5 exit 0 6 else 7 most_recent_before="${DRONE_COMMIT_BEFORE}" 8 fi 9 fi 10 modified_files=$(git --no-pager diff --name-only "${DRONE_COMMIT_SHA}".."${most_recent_before}");
Hanoi tour
2020-05-16
The big church, Hanoi.
Hà Nội Tour (nửa ngày, 0 đêm):
- 6h30: các bạn được đánh thức bởi tiếng nhạc du dương: https://www.youtube.com/watch?v=QMEt8_7uBhY
- 6h35: di chuyển bằng xe “căng hải” từ phòng ngủ ra William C.
- 6h45: trang phục tự chọn
- 7h: lúc này “xe ôm” đã đứng ở dưới để sẵn sàng phục vụ.
- 7h30: các bạn đang có mặt ở Phan Đình Phùng, một trong những con đường đẹp nhất HN. Tại đây, các bạn thoải mái chụp hình, ngắm lá vàng trong ánh nắng đầu hè dễ chịu.
Drone build is not triggered after pushing code to Gitea?
2020-05-06
I pushed code to Gitea and nothing happens in Drone. Why?
But if I go to Settings -> Webhooks, then click “Test Delivery” -> build pipeline will be executed. Why?
First, look at the “Recent Deliveries” to see if a webhook is triggerd here when you pushing code. In my case, it’s not. So, looks like the problem is on Gitea side.
By pay close attention to the git output when pushing:
1Counting objects: 4, done. 2Delta compression using up to 4 threads. 3Compressing objects: 100% (4/4), done. 4Writing objects: 100% (4/4), 2.02 KiB | 2.02 MiB/s, done. 5Total 4 (delta 2), reused 0 (delta 0) 6hint: The 'hooks/pre-receive' hook was ignored because it's not set as executable. 7hint: You can disable this warning with `git config advice.ignoredHook false`. 8hint: The 'hooks/update' hook was ignored because it's not set as executable. 9hint: You can disable this warning with `git config advice.ignoredHook false`. 10hint: The 'hooks/post-receive' hook was ignored because it's not set as executable. 11hint: You can disable this warning with `git config advice.ignoredHook false`. 12To gitea.pi:quanta/blog.git 13 + d29f63d...47e9ed3 master -> master (forced update)
How a gRPC message uses length-prefixed framing?
2020-05-06
Once we have the encoded data to send to the other end, we need to package the data in a way that other end can easily extract the information. gRPC uses a message framing technique called length-prefixed framing.
Filter gRPC messages:
1$ tshark -r grpc.pcapng -Y 'grpc'
Find out a stream: DATA
:
1216 923.033355 127.0.0.1 → 127.0.0.1 GRPC 108 DATA[1] (GRPC) (PROTOBUF)
and show the packet details:
1tshark -r grpc.pcapng -Y "frame.number == 216" -V
How to show all HTTP2 headers using tshark?
2020-05-05
After sniffing with tcpdump, how can I show all HTTP2 header using tshark?
First, find the frame number based on method:
1$ tshark -r grpc.pcapng -Y 'http2.headers.path contains "getBook"' 2214 923.033174 127.0.0.1 → 127.0.0.1 HTTP2 150 HEADERS[1]: POST /book.BookInfo/getBook
and then show the packet details:
1tshark -r grpc.pcapng -Y "frame.number == 214" -V 2 3HyperText Transfer Protocol 2 4 Stream: HEADERS, Stream ID: 1, Length 85, POST /book.BookInfo/getBook 5 Length: 85 6 Type: HEADERS (1) 7 Flags: 0x04 8 .... ...0 = End Stream: False 9 .... .1.. = End Headers: True 10 .... 0... = Padded: False 11 ..0. .... = Priority: False 12 00.0 ..0. = Unused: 0x00 13 0... .... .... .... .... .... .... .... = Reserved: 0x0 14 .000 0000 0000 0000 0000 0000 0000 0001 = Stream Identifier: 1 15 [Pad Length: 0] 16 Header Block Fragment: 8386459162339faaf74e7eb92a94ec4c54dd39faff418b08… 17 [Header Length: 216] 18 [Header Count: 8] 19 Header: :method: POST 20 Name Length: 7 21 Name: :method 22 Value Length: 4 23 Value: POST 24 :method: POST 25 [Unescaped: POST] 26 Representation: Indexed Header Field 27 Index: 3 28 Header: :scheme: http 29 Name Length: 7 30 Name: :scheme 31 Value Length: 4 32 Value: http 33 :scheme: http 34 [Unescaped: http] 35 Representation: Indexed Header Field 36 Index: 6 37 Header: :path: /book.BookInfo/getBook 38 Name Length: 5 39 Name: :path 40 Value Length: 22 41 Value: /book.BookInfo/getBook 42 :path: /book.BookInfo/getBook 43 [Unescaped: /book.BookInfo/getBook] 44 Representation: Literal Header Field with Incremental Indexing - Indexed Name 45 Index: 5 46 Header: :authority: 127.0.0.1:50051 47 Name Length: 10 48 Name: :authority 49 Value Length: 15 50 Value: 127.0.0.1:50051 51 :authority: 127.0.0.1:50051 52 [Unescaped: 127.0.0.1:50051] 53 Representation: Literal Header Field with Incremental Indexing - Indexed Name 54 Index: 1 55 Header: content-type: application/grpc 56 Name Length: 12 57 Name: content-type 58 Value Length: 16 59 Value: application/grpc 60 content-type: application/grpc 61 [Unescaped: application/grpc] 62 Representation: Literal Header Field with Incremental Indexing - Indexed Name 63 Index: 31 64 Header: user-agent: grpc-go/1.24.0 65 Name Length: 10 66 Name: user-agent 67 Value Length: 14 68 Value: grpc-go/1.24.0 69 user-agent: grpc-go/1.24.0 70 [Unescaped: grpc-go/1.24.0] 71 Representation: Literal Header Field with Incremental Indexing - Indexed Name 72 Index: 58 73 Header: te: trailers 74 Name Length: 2 75 Name: te 76 Value Length: 8 77 Value: trailers 78 [Unescaped: trailers] 79 Representation: Literal Header Field with Incremental Indexing - New Name 80 Header: grpc-client: evans 81 Name Length: 11 82 Name: grpc-client 83 Value Length: 5 84 Value: evans 85 [Unescaped: evans] 86 Representation: Literal Header Field with Incremental Indexing - New Name
brew info gets stuck
2020-04-25
I managed my Mac with SaltStack.
For some reasons, it gets stuck when running brew
state:
1[INFO ] Executing command '/usr/local/bin/brew info --json=v1 --installed' as user 'quanta' in directory '/Users/quanta'
As usual, whenever you get a problem, let’s enable debug mode to see what happens:
1brew info --json=v1 --installed -d
Now I can see that it stucked at drone/drone repo. By just untap this repo, and it’s solved.
Google Calendar CLI
2020-04-13
Our company allows us to work from home some days a week. To do that, we have to create an event in Google Calendar.
I created this tool to run it from CLI.
First, take a look at this quickstart.
Create initical code by running:
1$ cobra init 2 3$ tree -L 2 4. 5├── LICENSE 6├── cmd 7│ └── root.go 8├── main.go
Create event
command:
1$ cobra add event 2$ cobra add insert -p 'eventCmd' 3 4$ tree -L 2 5. 6├── LICENSE 7├── cmd 8│ ├── event.go 9│ ├── event_insert.go 10│ └── root.go 11├── main.go
Kể tên 10 ứng dụng mà bạn muốn có
2020-04-12
- Tổng hợp các co-working spaces ở Hà Nội, gửi mail khi có khuyến mại
- Ước lượng thời gian đi từ A đến B, kết hợp với tình hình thời tiết xem có nên đi không
- Chia sẻ tài liệu, cách thực hành, … để cải thiện khả năng nghĩ ra các ý tưởng
- Tự động đặt lịch rửa xe nếu cả tuần tới không mưa
- Ứng dụng cho phép mọi người ghi lại những khó khăn trong công việc hàng ngày để người khác hoặc chính họ tìm cách giải quyết