Skip to content

Instantly share code, notes, and snippets.

@priyadarshan
priyadarshan / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@priyadarshan
priyadarshan / _reader-macros.md
Last active August 29, 2015 14:16 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@priyadarshan
priyadarshan / save-lisp-tree-shake-and-die.lisp
Last active August 29, 2015 14:14 — forked from burtonsamograd/save-lisp-tree-shake-and-die.lisp
A quick and dirty tree shaker for SBCL
;; -*- mode: lisp -*-
;;
;; A quick and dirty tree shaker for SBCL. Basically, it destroys the
;; package system and does a gc before saving the lisp image. Gives
;; about a 40% reduction in image size on a basic hello world test.
;; Would like to hear how it works on larger projects.
;;
;; Original idea from: https://groups.google.com/d/msg/comp.lang.lisp/6zpZsWFFW18/WMy4PyA9B4kJ
;;
;; Burton Samograd
(defmacro -> (x &rest args)
"A Common-Lisp implementation of the Clojure `thrush` operator."
(destructuring-bind (form &rest more)
args
(cond
(more `(-> (-> ,x ,form) ,@more))
((and (consp form)
(or (eq (car form) 'lambda)
(eq (car form) 'function)))
`(funcall ,form ,x))
;;; armitp-mode-line.el --- Mode line customisation and beautification by Armit P
;;; Author: Armit J Patel <[email protected]>
;;; Version: 1.0
;;; Commentary:
;; Just a lovely mode line customisation - Packaged from the blog post at
;; http://amitp.blogspot.sg/2011/08/emacs-custom-mode-line.html
;;; Licence: GPL
#!/usr/bin/sbcl --script
; Also see http://pleasegodno.wordpress.com/common-lisp-tutorials/common-lisp-gui-programming-with-commonqt/introduction-to-commonqt/
; or see http://kvardek-du.kerno.org/2011/12/setting-up-commonqt-on-osx.html if you're still using Mac OS
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
@priyadarshan
priyadarshan / zfs
Last active August 29, 2015 14:07 — forked from kiela/zfs
[root@rescue ~]# gpart destroy -F ada0
ada0 destroyed
[root@rescue ~]# gpart destroy -F ada1
ada1 destroyed
[root@rescue ~]# gpart create -s gpt ada0
ada0 created
[root@rescue ~]# gpart create -s gpt ada1
ada1 created
[root@rescue ~]# gpart add -s 128 -t freebsd-boot ada0
ada0p1 added
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.