Skip to content

Instantly share code, notes, and snippets.

making stuff

Michael Campagnaro sir-pinecone

making stuff
View GitHub Profile
sir-pinecone / pre-commit
Last active Sep 21, 2020
Stop a Git commit if a staged file contains the word "nocheckin".
View pre-commit
#!/usr/bin/env bash
# Stops the commit if the changes include the word `nocheckin`.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
View gist:01161c1620147c93ccb5ed7980958a1f
#define BINKGL_LIST \
/* ret, name, params */ \
GLE(void, LinkProgram, GLuint program) \
GLE(void, GetProgramiv, GLuint program, GLenum pname, GLint *params) \
GLE(GLuint, CreateShader, GLenum type) \
GLE(void, ShaderSource, GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length) \
GLE(void, CompileShader, GLuint shader) \
GLE(void, GetShaderiv, GLuint shader, GLenum pname, GLint *params) \
GLE(void, GetShaderInfoLog, GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) \
GLE(void, DeleteShader, GLuint shader) \
sir-pinecone / augmented.c
Created Jul 19, 2017 — forked from gingerBill/augmented.c
Augmented C - 002
View augmented.c
#include <stddef.h>
typedef ptrdiff_t isize;
#define offset_of(Type, element) ((isize)&(((Type *)0)->element))
#define JOIN2_IND(a, b) a##b
#define JOIN2(a, b) JOIN2_IND(a, b)
View gist:9914ab506e34230846a72d3b9fcc897e
;; outlet code for implementing traditional macro expansion
;; macros
(define (expand form)
((variable? form) form)
((literal? form) form)
((macro? (car form))
(expand ((macro-function (car form)) form)))
sir-pinecone / range.scm
Created Apr 12, 2017
Experiments with writing range functions in Scheme.
View range.scm
; Uses Berkeley's (sentence) helper - slow after 1-5k, but supports larger range than `range-se-recur`
(define (range-se-iter start end)
(define (iter c ret)
(if (= c end)
(iter (+ c 1) (se ret c))))
(iter start '()))
; Uses Berkeley's (sentence) helper - quite slow after 1-5k, seg faults around 1-15k
(define (range-se-recur start end)
sir-pinecone / collection_api.scm
Last active Apr 12, 2017
Having some fun with Scheme by implementing sequence operations in various ways. All tests are done on my computer using the very primitive method of wrapping the call with (time).
View collection_api.scm
;; ======================================================================================
;; # Uses the Berkeley simple stk package for the `bf` and `se`.
;; ======================================================================================
(define (reduce-berk f start coll)
(define (iter rest ret)
(if (empty? rest)
(iter (bf rest) (f ret (first rest)))))
(iter coll start))
View user32.def
LIBRARY user32
UserGetPrecisionTouchPadConfiguration @2548
UserSetPrecisionTouchPadConfiguration @2549
sir-pinecone / csv-parsing.clj
Created Jun 10, 2016
A very simple csv parser in Clojure
View csv-parsing.clj
(defn lazy-file-lines [file]
(letfn [(helper [rdr]
(if-let [line (.readLine rdr)]
(cons line (helper rdr))
(do (.close rdr) nil))))]
(helper ( file)))
(catch Exception e nil)))
View ratelimit.clj
(ns x.ratelimit
[taoensso.carmine :as car :refer [wcar]]
[ring.util.response :as response]
[ring.mock.request :as mock])
[java.util Calendar]))
;; Util ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
You can’t perform that action at this time.