Skip to content

Instantly share code, notes, and snippets.

Avatar
🐘
making stuff

Michael Campagnaro sir-pinecone

🐘
making stuff
View GitHub Profile
@sir-pinecone
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)
fi
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
sir-pinecone / augmented.c
Created Jul 19, 2017 — forked from gingerBill/augmented.c
Augmented C - 002
View augmented.c
#ifndef AUGMENTED_C_GUARD
#define AUGMENTED_C_GUARD
#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)
(cond
((variable? form) form)
((literal? form) form)
((macro? (car form))
(expand ((macro-function (car form)) form)))
@sir-pinecone
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)
ret
(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
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)
ret
(iter (bf rest) (f ret (first rest)))))
(iter coll start))
View user32.def
LIBRARY user32
EXPORTS
UserGetPrecisionTouchPadConfiguration @2548
UserSetPrecisionTouchPadConfiguration @2549
@sir-pinecone
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]
(try
(letfn [(helper [rdr]
(lazy-seq
(if-let [line (.readLine rdr)]
(cons line (helper rdr))
(do (.close rdr) nil))))]
(helper (clojure.java.io/reader file)))
(catch Exception e nil)))
View ratelimit.clj
(ns x.ratelimit
(:require
[taoensso.carmine :as car :refer [wcar]]
[ring.util.response :as response]
[ring.mock.request :as mock])
(:import
[java.util Calendar]))
;; Util ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
You can’t perform that action at this time.