Skip to content

Instantly share code, notes, and snippets.

View kennethkalmer's full-sized avatar

Kenneth Kalmer kennethkalmer

View GitHub Profile

Graphics

CLJC

  • Quil Graphics and animation sketches, based on Processing
  • th.ing/geom a comprehensive and modular geometry & visualization toolkit. WebGL, OpenGL, SVG.
  • Iglu Turning data into GLSL shaders for use by OpenGL and WebGL. By Zach Oakes, part of play-cljc.

Clojure

@bravepickle
bravepickle / cors.nginx.conf
Last active February 25, 2021 23:10
CORS config for handling in NGINX
# Handling CORS headers for handling cross-origin requests example
# See https://developer.mozilla.org/en/docs/Web/HTTP/CORS
# TODO: check if origin is set. If missing then do not add CORS headers
# TODO: handle ports in origin
# check if origin header is among allowed ones
map $http_origin $cors_origin {
hostnames;
# all domains and subdomains for my-site.com or *.my-site.com can request contents
@bhb
bhb / ex.clj
Created February 13, 2018 20:06
Expound error when using fully-qualified symbol in let binding
(require '[clojure.core.specs.alpha])
(require '[clojure.spec.alpha :as s])
(require '[clojure.spec.test.alpha :as stest])
(require '[expound.alpha :as expound])
(set! s/*explain-out* (expound/custom-printer {:print-specs? false})) ; The "relevant specs" are very long, so let's omit them
(stest/instrument)
(let [foo/bar 42])
;; CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/let did not conform to spec:
@stuarthalloway
stuarthalloway / clojure_spec_missing_piece.clj
Created March 17, 2017 01:11
Clojure spec's missing piece
;; clojure.spec's missing piece, work in progress
;; this is only halfway done, somebody else will need to do the other 95%
(require
'[clojure.spec :as s]
'[clojure.spec.test :as test])
(defn naive-english-explain
"Copy and paste this into your app. Figure out what it does by
trying it in production."
(ns sunshine.disk-read
(:require [clojure.core.async :as async :refer [>! <! go-loop chan close! <!!]]])
(:import (java.io BufferedReader FileReader FileInputStream BufferedInputStream InputStreamReader)))
(def ten-gb-filename "ten.json")
(def one-meg (* 1024 1024))
(defn ^FileInputStream input-stream [^String fname]
(FileInputStream. fname))
@wojteklu
wojteklu / clean_code.md
Last active May 11, 2024 07:48
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@robert-stuttaford
robert-stuttaford / translate.clj
Last active March 24, 2019 20:44
Language translations for Datomic entities with fallback to base entity
(ns cognician.db.translate
(:require [datomic.api :as d])
(:import [clojure.lang MapEntry]
[datomic.query EntityMap]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Language
(def default-language :en-GB)
@kennethkalmer
kennethkalmer / invite-to-code-of-conduct.clj
Created August 13, 2016 15:02
Simple clojure code used to invite all the members of the ZA Developer slack team into a specific channel to discuss amendments to the code-of-conduct :)
(require 'clj-slack.users)
(require 'clj-slack.channels)
(def connection {:api-url "https://slack.com/api" :token "TOKEN"})
;; Get all the users and channels
(def users (clj-slack.users/list connection))
(def channels (clj-slack.channels/list connection))
;; Find the channel we care about
@thisismitch
thisismitch / haproxy.cfg
Last active November 11, 2023 04:08
Let's Encrypt Auto-Renewal script for HAProxy
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
@grantspeelman
grantspeelman / Gemfile
Last active December 16, 2020 13:11
Example Gemfile files preparing for the next rails upgrade (https://grant-ps.blog/2017/07/03/upgrading-ruby-on-rails-in-smallish-steps/)
@next_upgrade ||= false
source 'https://rubygems.org'
if @next_upgrade
gem 'rails', '6.0.0.rc2'
else
gem 'rails', '~> 5.2.0'
end
# rest of gems below ....