Skip to content

Instantly share code, notes, and snippets.

Marek Kubica Leonidas-from-XIV

Block or report user

Report or block Leonidas-from-XIV

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Leonidas-from-XIV
Leonidas-from-XIV / ghget.sh
Created Mar 20, 2019
OPAMFETCH for private archives
View ghget.sh
#!/usr/bin/env bash
#
# Adapted and fixed from https://gist.github.com/josh-padnick/fdae42c07e648c798fc27dec2367da21
#
# This is an adaptation of code I wrote to download a private binary from GitHub. Such...pain.
# Why can't GitHub just offer a standardized URL you can download a release binary from and attach
# your Github Personal Access Token as a header?
#
# Since this code is an adaptation it hasn't been directly tested, but the code it was adapted from works
# and hopefully you can get the missing piece you're after by looking here.
View dune-out
File "lib_helpers/kafka_producer.ml", line 1:
Error: The implementation lib_helpers/kafka_producer.ml
does not match the interface lib_helpers/.kafka_helpers.objs/byte/kafka_helpers__Kafka_producer.cmi:
Values do not match:
val stream_to : ('a, unit) sink -> 'a iterable -> unit
is not included in
val stream_to : ('a, 'b) sink -> 'a iterable -> 'b
File "lib_helpers/kafka_producer.mli", line 9, characters 0-48:
Expected declaration
File "lib_helpers/kafka_producer.ml", line 4, characters 4-13:
View FNC2PMQP.ml
open Lwt.Infix
open Cohttp
open Cohttp_lwt_unix
let body () =
Client.get (Uri.of_string "https://hacker-news.firebaseio.com/v0/maxitem.json") >>= fun (resp, body) ->
let code = resp |> Response.status |> Code.code_of_status in
Lwt_io.printf "Response Code: %d\n" code >>= fun () ->
Lwt_io.printf "Headers: %s\n" (resp |> Response.headers |> Header.to_string) >>= fun () ->
body |> Cohttp_lwt.Body.to_string >>= fun body ->
@Leonidas-from-XIV
Leonidas-from-XIV / dune
Created Jan 28, 2019
Dune run custom binary
View dune
;; probably not how to do it
(executable
(name bench)
(flags (-safe-string))
(libraries yojson core_bench core))
(alias
(name bench)
(deps bench.json)
@Leonidas-from-XIV
Leonidas-from-XIV / lwt_ppx_let.ml
Last active Mar 19, 2019
Using Lwt with ppx_let instead of ppx_lwt
View lwt_ppx_let.ml
module Let_syntax = struct
let return = Lwt.return
let (>>=) = Lwt.Infix.(>>=)
let (>>|) = Lwt.Infix.(>|=)
module Let_syntax = struct
let bind m ~f = Lwt.bind m f
end
end
@Leonidas-from-XIV
Leonidas-from-XIV / compose_handling.ml
Created Jul 13, 2018
Looking for a way to handle polymorphic variants
View compose_handling.ml
type 'a resp = Handled of unit | Continue of 'a
let handle_x = function Handled () -> Handled () | Continue x -> match x with `X -> Handled () | rest -> Continue rest
let handle_y = function Handled () -> Handled () | Continue x -> match x with `Y -> Handled () | rest -> Continue rest
let handle_xy v = handle_x (handle_y v)
match handle_xy (Continue `X) with
| Handled () -> ()
| Continue v ->
match v with
@Leonidas-from-XIV
Leonidas-from-XIV / foo_broken.ml
Last active Jun 6, 2018
Unifying polymorphic variants
View foo_broken.ml
type foo = [`Hello | `World | `Other]
type bar = [`Yet | `Another | `Other]
type baz = [foo | bar]
type qux = Foo of foo | Bar of bar | Quux
let transform = function
| Foo x -> x
| Bar x -> x
View jbuild
(rule
((targets (foo_types.mli
foo_types.ml
foo_pb.mli
foo_pb.ml
foo_pp.mli
foo_pp.ml))
(deps (foo.proto))
(action (run ocaml-protoc -int32_type int_t -int64_type int_t -ml_out . ${<}))))
@Leonidas-from-XIV
Leonidas-from-XIV / github-iosevka.css
Created Feb 24, 2018
Apply on domain 'github.com'
View github-iosevka.css
#files .file .data pre,
#files .file .line-data,
#files .file .line-number,
.blob-code-inner,
#readme code,
#readme pre {
font-family: Iosevka, monospace !important;
}
@Leonidas-from-XIV
Leonidas-from-XIV / parser.mly
Created Feb 20, 2018
Shift-reduce conflict with arbitrary resolution
View parser.mly
Warning: one state has shift/reduce conflicts.
Warning: one shift/reduce conflict was arbitrarily resolved.
File "src/variable/parser.mly", line 16, characters 3-3:
Warning: production value_sequence -> is never reduced.
Warning: in total, 1 productions are never reduced.
You can’t perform that action at this time.