Skip to content

Instantly share code, notes, and snippets.

@mk270
mk270 / convert-heic.sh
Created March 15, 2022 20:44
convert HEIC files in place
#!/bin/bash
# Warning: converts file in place
# Usage:
# convert-heic kittens009142.heic
set -eu
if [ $# != 1 ]; then
@mk270
mk270 / ghost-add-user.py
Created August 7, 2021 20:03
A tool for adding Ghost CMS users from the command line
#!/usr/bin/env python3
# ghost-add-user, (c) Martin Keegan 2021
# Copyright licence: Apache Software Licence 2.0
# A tool for adding new users to Ghost CMS from the command line
# please excuse this pre-alpha code. I was in a massive hurry.
import logging
@mk270
mk270 / badly_formatted.adb
Created April 28, 2016 18:45
Badly formatted Ada code from science paper
with Text_IO,Ada.Numerics.Generic_Elementary_Functions;
with Ada.Numerics;
use Text_IO,Ada.Numerics;
procedure Eutecticmain is
package Real_Io is new FLOAT_IO(Float);
use Real_Io;
package Integer_IO is new Text_IO.INTEGER_IO(Integer); use Integer_IO;
use Integer_Io;
package Elem_Fct is new Ada.Numerics.Generic_Elementary_Functions (Float);
@mk270
mk270 / dynamic_allocation_experiment.adb
Last active February 17, 2016 22:38
Ada container example
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
with Ada.Containers.Vectors; use Ada.Containers;
package body Dynamic_Allocation_Experiment
is
type Side is (Left, Right);
package Side_Container is new Vectors (Natural, Side);
use Side_Container;
@mk270
mk270 / unchecked_deallocation_experiment.adb
Created February 16, 2016 20:49
practice returning a dynamically allocated array
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
with Ada.Unchecked_Deallocation;
package body Dynamic_Allocation_Experiment
is
type Side is (Left, Right);
type Side_Array is array (Integer range <>) of Side;
type Side_Array_Ptr is access Side_Array;
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
int main(int argc, char *argv[], char *env[]) {
char *arena;
char hex[100];
char *target;
@mk270
mk270 / gist:4a148b07cbfffed7bb3f
Created May 7, 2015 08:13
word generator compile error
mk270@cornford ~/Src/word_generator> cargo build
Updating git repository `https://github.com/rust-lang/rand.git`
Downloading unicode-segmentation v0.1.0
Downloading regex v0.1.30
Compiling rustc-serialize v0.3.14
Compiling regex v0.1.30
Compiling libc v0.1.6
Compiling unicode-segmentation v0.1.0
Compiling rand v0.3.8 (https://github.com/rust-lang/rand.git#93544850)
Compiling word_generator v0.1.0 (file:///home/mk270/Src/word_generator)
@mk270
mk270 / websocket_app.erl
Created September 2, 2014 00:32
websocket routing
%% Feel free to use, reuse and abuse the code in this file.
%% @private
-module(websocket_app).
-behaviour(application).
%% API.
-export([start/2]).
-export([stop/1]).
@mk270
mk270 / ws_handler.erl
Created September 2, 2014 00:30
Websocket handler attempt
-module(ws_handler).
-behaviour(cowboy_websocket_handler).
-export([init/3]).
-export([websocket_init/3]).
-export([websocket_handle/3]).
-export([websocket_info/3]).
-export([websocket_terminate/3]).
init({tcp, http}, _Req, _Opts) ->