Skip to content

Instantly share code, notes, and snippets.

View mwfogleman's full-sized avatar

Tasshin Fogleman mwfogleman

View GitHub Profile
;; try this form-by-form at a REPL
(require '[clojure.spec.alpha :as s])
;; create an inline DSL to describe the FizzBuzz world
(defmacro divides-by
[nm n]
`(s/def ~nm (s/and pos-int? #(zero? (mod % ~n)))))
;; specify FizzBuzz
(divides-by ::fizz 3)
@JKirchartz
JKirchartz / goodreadsquotes.py
Created January 31, 2017 21:33
Download all quotes from GoodReads by author's quote URL, print in fortune format
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyleft (ↄ) 2016 jkirchartz <[email protected]>
#
# Distributed under terms of the NPL (Necessary Public License) license.
"""
Download all quotes from GoodReads by author's quote URL, print in fortune format
@sam217pa
sam217pa / tufte-book.tex
Last active March 2, 2021 21:57
a template to export from org-mode to latex
\usepackage[scaled=0.95]{roboto}
\usepackage{mathpazo}
\linespread{1.05}
\usepackage{eulervm}
\usepackage[usenames]{xcolor}
%% footnote color
\renewcommand{\thefootnote}{\textcolor{Gray}{\arabic{footnote}}}
\makeatletter
;;; -*- lexical-binding: t -*-
(require 'dash)
(defun var (c) (vector c))
(defun var? (x) (vectorp x))
(defun var=? (x1 x2) (= (elt x1 0) (elt x2 0)))
(defun assp (pred l)
(-first (lambda (i) (funcall pred (car i))) l))
@igorw
igorw / mu.scm
Created January 7, 2015 09:23
GEB MU puzzle in miniKanren
; Douglas Hofstadter's MU puzzle from Gödel, Escher, Bach
; written in miniKanren
;
; https://github.com/miniKanren/miniKanren/blob/master/mk.scm
(load "mk.scm")
(define print
(lambda (exp)
(display exp)

Macros Crash Course

Firstly, a macro is evaluated at compile-time, not runtime.

;; Define a function and macro that both
;; return the current time.
(defun get-current-time-fn ()
  (second (current-time)))

(defmacro get-current-time-mac ()

@john2x
john2x / 00_destructuring.md
Last active August 23, 2024 07:45
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@nifl
nifl / grok_vi.mdown
Created August 29, 2011 17:23
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)