Skip to content

Instantly share code, notes, and snippets.

// Adds, then removes an alias IP from a VM
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"time"
let decode = Angstrom.(
advance 2 >>= fun () -> (* skip length prefix *)
LE.any_uint16 >>= fun s_type ->
LE.any_int32 >>= fun s_dev ->
Qid.decode >>= fun s_qid ->
LE.any_int32 >>= fun s_mode ->
LE.any_int32 >>= fun s_atime ->
LE.any_int32 >>= fun s_mtime ->
LE.any_int64 >>= fun s_length ->
decode_string >>= fun s_name ->
@droyo
droyo / ddex.go
Created November 1, 2020 01:23
output for go-xml issue #123
// Code generated by xsdgen. DO NOT EDIT.
package ws
import (
"bytes"
"encoding/xml"
"time"
)
// Code generated by xsdgen. DO NOT EDIT.
package ws
import (
"bytes"
"encoding/xml"
)
type Anon1 string
// Code generated by xsdgen. DO NOT EDIT.
package ws
// Must be at least 1 items long
type Email string
// Must be at least 1 items long
type ВерсПрог string
@droyo
droyo / ast.ml
Created February 19, 2021 03:44
type t = term list
and term =
| Int of int
| Bool of bool
| Float of float
| Id of string
| Str of string
| Expr of t
(* pp_term calls pp *)
Fmt.(pf ppf "type %s = {@[<v>@,%a@;<1 -2>@]}" name (list ~sep:(any ";@ ") gen_record_field))
result:
type t = {
bar : BarEnum;
baz : BazMsg;
bum : BazMsg.Data;
foomap : (BarEnum * BazMsg)
}
(* service definition
message SeekRequest {
string subscription = 1;
oneof target {
google.protobuf.Timestamp time = 2;
string snapshot = 3;
}
}
message SeekResponse {
}
@droyo
droyo / ratelimitproxy.go
Last active July 25, 2024 01:33
Proxy GCE metadata server
// go build ratelimitproxy.go
// ./ratelimitproxy -n 2
// export http_proxy=http://localhost:8080
package main
import (
"sync/atomic"
"flag"
"log"
"net/http"