Skip to content

Instantly share code, notes, and snippets.

View catharinejm's full-sized avatar
🐶

Catharine Manning catharinejm

🐶
View GitHub Profile
#!/usr/bin/env bash
set -e
mkdir -p /app/vendor/openssl
tar zxf openssl-1.0.1e.tar.gz
cd openssl-1.0.1e
./Configure linux-x86_64 shared --prefix=/app/vendor/openssl
make all install_sw
#!/usr/bin/env bash
set -e
curl -L https://github.com/Originate/heroku-ruby200p247-openssl101e/raw/master/openssl-1.0.1e.tgz > /tmp/openssl-1.0.1e.tgz
mkdir -p /app/vendor/openssl
tar zxf /tmp/openssl-1.0.1e.tgz -C /app/vendor/openssl
mkdir -p /app/vendor/postgres
CFLAGS='-I/app/vendor/openssl/include' LDFLAGS='-L/app/vendor/openssl/lib -Wl,-rpath,/app/vendor/openssl/lib' ./configure --prefix=/app/vendor/postgres --with-openssl --with-gnu-ld
@catharinejm
catharinejm / interp.clj
Last active December 27, 2015 14:19
Interpolate points with lazy-seq
(ns interpolation.core)
(defn full-list [prtl-lis st end]
(if (<= st end)
(let [lis (drop-while #(< (first %) st) prtl-lis)
slope (fn slope
[[x1 y1 :as p1] [x2 y2 :as p2]]
(if (and p1 p2)
(/ (- y2 y1) (- x2 x1))
0))
(define (read-vec port)
(if (eq? (peek-char port) #\])
(begin (read-char port) '())
(cons (read) (read-vec port))))
(set-read-syntax! #\[ (lambda (port)
(cons 'vector (read-vec port))))
;; REPL
#1> [1 2 [3 4]]
@catharinejm
catharinejm / protocols.scm
Created December 15, 2013 06:07
Rough protocols implementation in Chicken Scheme
(use srfi-69)
(define-record protocol name impls sigs)
(define (protocol-dispatch-type obj)
(cond
((and (not (##sys#immediate? obj))
(##sys#generic-structure? obj))
(##sys#slot obj 0))
((pair? obj) 'pair)
@catharinejm
catharinejm / persistent_vector.c
Last active January 2, 2016 20:29
Simple implementation of Clojure's PersistentVector in C with Boehm GC (bdw-gc).
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include <sys/time.h>
#include <gc.h>
#define MIN(x, y) \
(((x) < (y)) ? (x) : (y))
@catharinejm
catharinejm / funcMethod.go
Last active August 29, 2015 13:56
Defining a method on a function
package main
import (
"fmt"
)
type F func(x int) int
func (f F) doit (y int) int {
return f(y) + 3
irb> require 'webrick'
#=> true
irb> server = WEBrick::HTTPServer.start :Port => 4000
#=> #<WEBrick::HTTPServer:0x007fc349081ec0 ...>
irb> server.mount_proc("/foo") { |req, res| res.status = 400; res.body = "WHOOPS\n" }
#=> [#<WEBrick::HTTPServlet::ProcHandler:0x007fc34a1131f8 @proc=#<Proc:0x007fc34a113248@(irb):4>>, []]
irb> server.start
# [2014-05-14 10:51:28] INFO WEBrick::HTTPServer#start: pid=77103 port=4000
# Meanwhile, in the shell...
From f39fa6b9c44a70123735db1e8333ade226a4485f Mon Sep 17 00:00:00 2001
From: Jon Distad <[email protected]>
Date: Sat, 17 May 2014 11:44:15 -0400
Subject: [PATCH] Fix map unquote-splicing
`{~@[1 2]} ;=> {1 2}
(meta `^{~@[:foo :bar]} asdf) ;=> {:foo :bar}
---
src/jvm/clojure/lang/LispReader.java | 53 +++++++++++++++++++++++++++++++-----
test/clojure/test_clojure/reader.clj | 19 +++++++++++++
http://youtu.be/_ahvzDzKdB0