Skip to content

Instantly share code, notes, and snippets.

View wu-s-john's full-sized avatar

John Wu wu-s-john

View GitHub Profile
@wu-s-john
wu-s-john / tasks.json
Created May 4, 2023 21:54
Common Tasks to easily run Elixir Code quickly
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "MIX_ENV=dev mix compile",
"group": {
"kind": "build",
"isDefault": true
@wu-s-john
wu-s-john / gadt_demo.ml
Created February 27, 2020 17:21
Demo of GADTs
open Core
(* sum type *)
type weekday =
| Monday
| Tuesday
| Wednesday
let to_string (weekend: weekday) =
match weekend with
@wu-s-john
wu-s-john / prover.error
Created October 11, 2019 17:24
Bad snark proof
2019-10-11 17:22:46 UTC [Error] Prover failed: $error
error: "( \"Snarky.Checked_runner.Runtime_error(_, _, _, _)\\\n \\n\\\n \\nEncountered an error while evaluating the checked computation:\\\n \\n (Failure\\\n \\n \\\"Constraint unsatisfied (unreduced):\\\\\\\n \\n \\\\nfield_inverse\\\\\\\n \\n \\\\nChecked.inv\\\\\\\n \\n \\\\nassert_non_zero: File \\\\\\\"lib/snarky/src/snark0.ml\\\\\\\", line 337, characters 4-114\\\\\\\n \\n \\\\nany: File \\\\\\\"lib/snarky/src/snark0.ml\\\\\\\", line 544, characters 8-101\\\\\\\n \\n \\\\nFile \\\\\\\"lib/coda_base/transition_system.ml\\\\\\\", line 203, characters 17-24\\\\\\\n \\n \\\\nmain: File \\\\\\\"lib/coda_base/transition_system.ml\\\\\\\", line 138, characters 4-3126\\\\\\\n \\n \\\\n\\\\\\\n \\n \\\\nConstraint:\\\\\\\n \\n \\\\n(((basic(R1CS(Add(Add(Constant 0)(Scale 1(Var 48427)))(Scale 1(Var 48426)))(Var 48429)(Constant 1)))(annotation(field_inverse))))\\\\\\\n \\n \\\\nData:\\\\\\\n \\n \\\\nR1CS 0 0 1\\\")\\\n \\n\\\n \\nLabel stack tr
@wu-s-john
wu-s-john / gist:fe5396f08100d0c874c228f8009b47ba
Created October 10, 2019 23:44
Can't broadcast snark work to my peers :(
peer: {
"host": "34.222.1.217",
"discovery_port": 8303,
"communication_port": 8302
}
error: "(src/connection.ml.Handshake_error.Handshake_error\n (Eof (\"Client connected via TCP\" (34.222.1.217 8302))))"
2019-10-10 23:43:26 UTC [Warn] Node banned by peer "34.222.1.217" until "2019-10-11 23:43:21.878839Z"
2019-10-10 23:43:27 UTC [Error] RPC call raised an exception: $exn
exn: "(src/connection.ml.Handshake_error.Handshake_error\n (Eof (\"Client connected via TCP\" (34.222.1.217 8302))))"
2019-10-10 23:43:27 UTC [Error] Broadcasting message "snark pool diff" to $peer failed: $error
@wu-s-john
wu-s-john / gist:e05eee7a7cdfaf47275bfda852c3c9a7
Created October 10, 2019 23:39
Snark Worker Process cannot talk to daemon
{"timestamp":"2019-10-10 23:33:47.470534Z","level":"Info","source":{"module":"Snark_worker__Functor","location":"File \"lib/snark_worker/functor.ml\", line 117, characters 59-66"},"message":"SNARK work received from $address. Starting proof generation","metadata":{"address":"127.0.0.1:8301","pid":11843,"process":"Snark Worker"}}
2019-10-10 23:34:44 UTC [Error] RPC call error: $error, same error in machine format: $machine_error
error: "((rpc_error (Connection_closed (\"No heartbeats received for 30s.\")))\n (connection_description (\"Client connected via TCP\" (83.85.216.247 8302)))\n (rpc_tag get_chain_id) (rpc_version 1))"
machine_error: "((rpc_error(Connection_closed(\"No heartbeats received for 30s.\")))(connection_description(\"Client connected via TCP\"(83.85.216.247 8302)))(rpc_tag get_chain_id)(rpc_version 1))"
2019-10-10 23:34:44 UTC [Error] RPC call error: $error, same error in machine format: $machine_error
error: "((rpc_error (Connection_closed (\"No heartbeats received for 30s.\")))\n (connect
module Rel_insert_input = struct
type ('data, 'on_conflict) t =
< data: 'data ; on_conflict: 'on_conflict option >
type nonrec ('data, 'on_conflict) array = ('data array, 'on_conflict) t
end
module On_conflict = struct
type ('constraint_, 'update_columns) t =
< constraint_: 'constraint_ ; update_columns: 'update_columns array >

User_command_insert

{"query": "mutation transaction_insert($user_commands: [user_commands_insert_input!]!)  {
insert_user_commands(objects: $user_commands, on_conflict: {constraint: user_commands_hash_key, update_columns: first_seen})  {
returning  {
id  
hash  
first_seen  

Keybase proof

I hereby claim:

  • I am wu-s-john on github.
  • I am johnswu (https://keybase.io/johnswu) on keybase.
  • I have a public key ASB3SRBomnIHmcE3mVsuyRp9KIpNOvdFQO_JYUxdAibq8wo

To claim this, I am signing this object:

@wu-s-john
wu-s-john / keybase.md
Created August 31, 2019 03:24
keybase.md

Keybase proof

I hereby claim:

  • I am wu-s-john on github.
  • I am johnswu (https://keybase.io/johnswu) on keybase.
  • I have a public key ASB3SRBomnIHmcE3mVsuyRp9KIpNOvdFQO_JYUxdAibq8wo

To claim this, I am signing this object:

@wu-s-john
wu-s-john / database_demo.ml
Created August 18, 2019 17:17
Made postgres request using Postgres and Async
open Core
open Async
let () =
Sexp.to_string_hum [%sexp ([3;4;5] : int list)]
|> print_endline
let create_table =
Caqti_request.exec
Caqti_type.unit