Skip to content

Instantly share code, notes, and snippets.

Avatar

Konstantin A. Olkhovskiy Lupus

View GitHub Profile
@Lupus
Lupus / lwt_echo_post2.ml
Last active Oct 2, 2019
lwt_echo_post2.ml
View lwt_echo_post2.ml
open Base
open Lwt.Infix
module Arg = Caml.Arg
open Httpaf_lwt_unix
module Reqd = Httpaf.Reqd
module Request = Httpaf.Request
module Headers = Httpaf.Headers
module Response = Httpaf.Response
module Body = Httpaf.Body
@Lupus
Lupus / lwt_echo_post.ml
Created Aug 2, 2019
Sample app illustrating httpaf chunked encoding issue
View lwt_echo_post.ml
open Base
open Lwt.Infix
module Arg = Caml.Arg
open Httpaf_lwt_unix
module Reqd = Httpaf.Reqd
module Request = Httpaf.Request
module Headers = Httpaf.Headers
module Response = Httpaf.Response
module Body = Httpaf.Body
@Lupus
Lupus / Image_utils.re
Last active Jun 15, 2019
Some simple set of functions to manipulate RGB images in ReasonML (only PPM output format is supported)
View Image_utils.re
module Image = {
type channel_t =
Bigarray.Array2.t(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout);
type t = {
width: int,
height: int,
r_channel: channel_t,
g_channel: channel_t,
b_channel: channel_t,
};
View error_example.re
module Errors: {
type t;
type baseError = {
name: string,
info: string,
message: string
};
type noHostAvailableError = {
name: string,
info: string,
View errors.re
module Errors = {
type t;
type errors = {
.
"_NoHostAvailableError": t,
"_ResponseError": t,
"_DriverInternalError": t,
"_AuthenticationError": t,
"_ArgumentError": t,
"_OperationTimedOutError": t,
View result.js
// Generated by BUCKLESCRIPT VERSION 1.9.2, PLEASE EDIT WITH CARE
'use strict';
var Caml_missing_polyfill = require("stdlib/caml_missing_polyfill");
function foo (x) {
if (x == 0) return null;
else if (x == 1) return 0;
return "bar";
View node.re
module EventEmitter = {
module Event = {
type t('e, 'v) = ..;
type t(_, _) +=
| NewListener : t([>`EventEmitter], string)
| RemoveListener : t([>`EventEmitter], string);
type pkg =
| Pkg(t('e, 'v)): pkg;
};
module Listener = {
@Lupus
Lupus / ssl_test2.c
Created Oct 18, 2017 — forked from roxlu/ssl_test2.c
Compact example of how to use openSSL with self signed (no password) keys/certificates, DTLS and memory BIOs
View ssl_test2.c
/*
Create server/client self-signed certificate/key (self signed, DONT ADD PASSWORD)
openssl req -x509 -newkey rsa:2048 -days 3650 -nodes -keyout client-key.pem -out client-cert.pem
openssl req -x509 -newkey rsa:2048 -days 3650 -nodes -keyout server-key.pem -out server-cert.pem
*/
#include <stdio.h>
@Lupus
Lupus / jira_oauth.go
Last active Nov 10, 2020
Example of using OAuth authentication with JIRA in Go
View jira_oauth.go
/*
To the extent possible under law, Konstantin Olkhovskiy has waived
all copyright and related or neighboring rights to this snippet.
CC0 license: http://creativecommons.org/publicdomain/zero/1.0/
*/
package main
import (
"crypto/x509"
@Lupus
Lupus / terra_lua_c_api_issue.t
Created Nov 28, 2016
Second repro with shared library, problem appears only in jit mode
View terra_lua_c_api_issue.t
local S = require("std")
-- some helper declarations
local size_t = uint64
local LUA_TSTRING = 4
local struct lua_State