Skip to content

Instantly share code, notes, and snippets.

View paurkedal's full-sized avatar

Petter A. Urkedal paurkedal

View GitHub Profile
open String
(* Author: Alain Frisch, from ocaml PR 626 *)
let rec split_limit sep s len i0 i acc lim =
if i = len then
List.rev (sub s i0 (i - i0) :: acc)
else if unsafe_get s i = sep then
let acc = sub s i0 (i - i0) :: acc in
if lim = 1 then
List.rev (sub s (i + 1) (len - i - 1) :: acc)
(* Ad comment to https://github.com/ocaml/ocaml/pull/722
*
* E.. Everything indented to even columns.
* O.. Patterns indented to odd columns, the rest to even columns.
* .L. Loose layout, delimiters above and below cases.
* .C. Compact layout, end delimiter attached to last case.
* ..P Delimited with parentheses, as allowed by the current syntax.
* ..B Delimited with brackets, as in the PR.
* .XX Pointed form.
*)
[Unit]
Description=OCSIGEN Server Instance
After=network.target
[Service]
EnvironmentFile=/etc/sysconfig/ocsigen-%i
User=ocsigen
ExecStart=/usr/local/bin/opam-env ${OPAMSWITCH} ocsigenserver -c /etc/ocsigen/%i-${OPAMSWITCH}.conf
ExecStop=/usr/bin/echo shutdown >/var/run/ocsigen/%i-command.pipe
ExecReload=/usr/bin/echo reload >/var/run/ocsigen/%i-command.pipe
#! /bin/bash
OPAMSWITCH="$1"
shift
export PATH="/opt/opam/$OPAMSWITCH/bin:$PATH"
export CAML_LD_LIBRARY_PATH=/opt/opam/$OPAMSWITCH/lib/stublibs
exec "$@"
#! /bin/bash
set -e
if [ -r /etc/opam-deploy.conf ]; then
. /etc/opam-deploy.conf
fi
rsync_options="-rlptD --delete"
backlog=3
@paurkedal
paurkedal / crosspad.ml
Last active January 11, 2017 21:04
Crosspad with full update (origin: https://github.com/martindemello/crosspad.jsoo)
open Xword.Types
open Lwt.Infix
type coords = { x : int; y : int }
module Model = struct
open Cursor
type t = {
xw : xword;
type 'a io = 'a Lwt.t
type ic = Lwt_io.input_channel
type oc = Lwt_io.output_channel
type tls_lib = [`OpenSSL | `Native]
module X509_key : sig
type t = private {
key: string;
@paurkedal
paurkedal / base-with-tupled-9.svg
Last active October 3, 2017 22:24
faster-map with new base implementation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
(* guestfs-inspection
* Copyright (C) 2009-2017 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@paurkedal
paurkedal / mariadb_nonblocking_connect_stress_test.c
Created December 20, 2017 08:23
MariaDB nonblocking connect stress test
#include <mariadb/mysql.h>
#include <stdlib.h>
#include <stdio.h>
#include <poll.h>
static int wait_for_mysql(MYSQL *mysql, int status) {
struct pollfd pfd;
int timeout, res;
pfd.fd = mysql_get_socket(mysql);