Skip to content

Instantly share code, notes, and snippets.

View Lupus's full-sized avatar

Konstantin A. Olkhovskiy Lupus

View GitHub Profile
@Lupus
Lupus / jira_oauth.go
Last active February 20, 2023 11:44
Example of using OAuth authentication with JIRA in 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 / ipcalc.go
Created July 19, 2016 12:21 — forked from kotakanbe/ipcalc.go
get all IP address from CIDR in golang
package main
import (
"net"
"os/exec"
"github.com/k0kubun/pp"
)
func Hosts(cidr string) ([]string, error) {
@Lupus
Lupus / lwt_echo_post2.ml
Last active October 2, 2019 22:00
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 August 2, 2019 10:38
Sample app illustrating httpaf chunked encoding issue
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 June 15, 2019 11:47
Some simple set of functions to manipulate RGB images in ReasonML (only PPM output format is supported)
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,
};
module Errors: {
type t;
type baseError = {
name: string,
info: string,
message: string
};
type noHostAvailableError = {
name: string,
info: string,
module Errors = {
type t;
type errors = {
.
"_NoHostAvailableError": t,
"_ResponseError": t,
"_DriverInternalError": t,
"_AuthenticationError": t,
"_ArgumentError": t,
"_OperationTimedOutError": t,
// 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";
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 October 18, 2017 09:11 — forked from roxlu/ssl_test2.c
Compact example of how to use openSSL with self signed (no password) keys/certificates, DTLS and memory BIOs
/*
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>