Skip to content

Instantly share code, notes, and snippets.

View philtomson's full-sized avatar

Phil Tomson philtomson

View GitHub Profile
@joelreymont
joelreymont / 0001-fast-track-the-case-where-executable-name-matches-ma.patch
Created May 27, 2011 07:09
Avoid copying and invoke ocamlbuild once for all targets where executable name matches MainIs
From 618b4efb183fcd49256b43e04ef9e07fa67dcce6 Mon Sep 17 00:00:00 2001
From: Joel Reymont <joelr1@gmail.com>
Date: Fri, 27 May 2011 09:07:29 +0200
Subject: [PATCH] fast-track the case where executable name matches main, avoid copying
---
src/base/BaseBuilt.ml | 9 ++++++++-
src/plugins/ocamlbuild/OCamlbuildPlugin.ml | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
@NicolasT
NicolasT / binsec.ml
Created June 21, 2011 18:45
Monadic binary (de)serialization API for OCaml
type 'a writer = Buffer.t -> 'a -> unit;;
type 'a reader = string -> int -> ('a * int);;
let ($) a b = a b;;
let id x = x;;
let lift_llio_writer (l: Buffer.t -> 'b -> unit): ('a -> 'b) -> 'a writer =
fun f -> fun b a ->
let v = f a in
l b v;;
@jackrusher
jackrusher / gist:5139396
Last active October 19, 2024 14:08
Hofstadter on Lisp: Atoms and Lists, re-printed in Metamagical Themas.

Hofstadter on Lisp

In the mid-80s, while reading through my roommate's collection of Scientific American back issues, I encountered this introduction to Lisp written by Douglas Hofstadter. I found it very charming at the time, and provide it here (somewhat illegally) for the edification of a new generation of Lispers.

In a testament to the timelessness of Lisp, you can still run all the examples below in emacs if you install these aliases:

(defalias 'plus #'+)
(defalias 'quotient #'/)
(defalias 'times #'*)
(defalias 'difference #'-)
@rmcgibbo
rmcgibbo / Install Intel-CPU OpenCL on Ubuntu.md
Last active November 6, 2021 10:00
Installing Intel CPU OpenCL on Ubuntu 12.04

Open Computing Language (OpenCL) is a language and framework for writing computationally intensive kernels that run accross heterogenious platforms, including GPUs, CPUs, and perhaps other more esoteric devices.

Intel provides an OpenCL implementation for Intel CPUs, but there's not a lot of instructions on how to get it set up. Here's what I did.

Installing Intel CPU OpenCL on Ubuntu (12.04)

  1. Download the Intel® SDK for OpenCL* Applications XE 2013 from the Intel website, here http://software.intel.com/en-us/vcsource/tools/opencl-sdk-xe. The download is a tarball -- the one I got is called intel_sdk_for_ocl_applications_2013_xe_sdk_3.0.67279_x64.tgz
  2. Unpack the tarball and cd into the new directory
@PhDP
PhDP / harr1.jl
Last active August 29, 2015 14:16
First example of Harrison's "Handbook of Practical Logic and Automated Reasoning" in Julia.
abstract Expr
type Const <: Expr; value::Int end
type Var <: Expr; name::String end
type Add <: Expr; left::Expr; right::Expr end
type Mult <: Expr; left::Expr; right::Expr end
add(x::Const, y::Const) = Const(x.value + y.value)
add(x::Const, y::Expr) = x.value == 0? y : Add(x, y)
add(x::Expr, y::Const) = add(y, x)
@akabe
akabe / maze_solver.ml
Last active October 13, 2019 16:34
A maze solver by A* algorithm on OCaml
(* ========================================================================== *
* General implementation of A-star algorithm
* ========================================================================== *)
module Astar :
sig
type 'a t =
{
cost : 'a -> 'a -> int;
goal : 'a;

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

Neural Style Transfer

Neural Style Transfer is the process of using Deep Neural Networks to migrate the semantic content of one image to different styles.

Usage

This gist implements NST in Owl, and provides a simple interfaces to use. Here is an example:

#zoo "6f28d54e69d1a19c1819f52c5b16c1a1"
@nicebyte
nicebyte / dyn_arr.h
Last active July 1, 2024 10:44
dyn_arr
#pragma once
#define DYN_ARR_OF(type) struct { \
type *data; \
type *endptr; \
uint32_t capacity; \
}
#if !defined(__cplusplus)
#define decltype(x) void*
@hirrolot
hirrolot / CoC.ml
Last active October 5, 2024 22:16
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)