Skip to content

Instantly share code, notes, and snippets.

@ato
ato / debug.clj
Created December 9, 2009 11:42
Simpler debug-repl that works with unmodified Clojure
;; Inspired by George Jahad's version: http://georgejahad.com/clojure/debug-repl.html
(defmacro local-bindings
"Produces a map of the names of local bindings to their values."
[]
(let [symbols (map key @clojure.lang.Compiler/LOCAL_ENV)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))
(declare *locals*)
(defn eval-with-locals
@Pet3ris
Pet3ris / sokuza-kanren.scm
Created December 22, 2011 19:29
Mini-kanren like logic programming in Scheme
; Quick miniKanren-like code
;
; written at the meeting of a Functional Programming Group
; (Toukyou/Shibuya, Apr 29, 2006), as a quick illustration of logic
; programming. The code is really quite trivial and unsophisticated:
; it was written without any preparation whatsoever. The present file
; adds comments and makes minor adjustments.
;
; $Id: sokuza-kanren.scm,v 1.1 2006/05/10 23:12:41 oleg Exp oleg $
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 4, 2024 06:56
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@tristanfisher
tristanfisher / Ansible-Vault how-to.md
Last active June 11, 2024 13:23
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

Working with ansible-vault


I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

@kachayev
kachayev / css-parser.md
Last active November 12, 2022 04:20
Parsing CSS file with monadic parser in Clojure
@ptaoussanis
ptaoussanis / transducers.clj
Last active December 17, 2021 13:54
Quick recap/commentary: Clojure transducers
(comment ; Fun with transducers, v2
;; Still haven't found a brief + approachable overview of Clojure 1.7's new
;; transducers in the particular way I would have preferred myself - so here goes:
;;;; Definitions
;; Looking at the `reduce` docstring, we can define a 'reducing-fn' as:
(fn reducing-fn ([]) ([accumulation next-input])) -> new-accumulation
;; (The `[]` arity is actually optional; it's only used when calling
;; `reduce` w/o an init-accumulator).
@martintrojer
martintrojer / init.el
Last active January 9, 2021 16:12
init.el clojure bits
;; Clojure
(require 'clojure-mode)
(setq auto-mode-alist (cons '("\\.cljs$" . clojure-mode) auto-mode-alist))
(setq inferior-lisp-program "lein repl")
;; clj-refactor
(require 'clj-refactor)
(add-hook 'clojure-mode-hook (lambda ()
(clj-refactor-mode 1)
(cljr-add-keybindings-with-prefix "C-c C-o")))
@Deraen
Deraen / 00_notes.md
Last active October 1, 2019 08:40
Compojure-api and Buddy
  • (:identity req) is auth backend independent way to access user data
  • login and logout implementation depends on auth backend
  • :current-user doesn't imply that authentication is required, route should also have :auth-rules if authentication is required
@xeqi
xeqi / ukanren_transducers.clj
Last active November 13, 2018 06:38
ukanren in almost transducers
(ns ukanren-transducers
(:refer-clojure :exclude [== disj conj]))
(defrecord Lvar [name])
(defn lvar [] (->Lvar (gensym "lvar")))
(defn lvar? [v] (instance? Lvar v))
(def empty-state {})
(defn walk [u s]
@paultopia
paultopia / upload.cljs
Created December 21, 2016 21:50
clojurescript read uploaded text file in browser (derived from https://mrmcc3.github.io/post/csv-with-clojurescript/ )
(ns upload-file.core
(:require [reagent.core :refer [render atom]]
[cljs.core.async :refer [put! chan <! >!]])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
;; derived from https://mrmcc3.github.io/post/csv-with-clojurescript/
;; and based on reagent-frontend template.
;; dependencies from project.clj in addition to clojure, clojurescript, and reagent:
;; [org.clojure/core.async "0.2.395"]