List of helpful shortcuts for faster coding
If you have any other helpful shortcuts, feel free to add in the comments of this gist :)
#include <stdio.h> | |
// Compile with cc -o gray gray.c -framework UniversalAccess -F /System/Library/PrivateFrameworks | |
extern void UAGrayscaleSetEnabled(int isEnabled); | |
extern int UAGrayscaleIsEnabled(); | |
int main() { | |
UAGrayscaleSetEnabled(!UAGrayscaleIsEnabled()); | |
} |
;; This is free and unencumbered software released into the public domain. | |
;; Assume nothing works, and you may be pleasantly surprised; and when it breaks, you get to keep both pieces. | |
;; A Simple macro that enables you to change your testing groups to pending | |
(defmacro pending [name & body] | |
(let [message (str "\n" name " is pending !!")] | |
`(testing ~name (println ~message)))) |
/******************************************************************************* | |
* | |
* A minimal Forth compiler in C | |
* By Leif Bruder <[email protected]> http://defineanswer42.wordpress.com | |
* Release 2014-04-04 | |
* | |
* Based on Richard W.M. Jones' excellent Jonesforth sources/tutorial | |
* | |
* PUBLIC DOMAIN | |
* |
#!/bin/bash | |
rm -Rf ~/.m2 | |
rm -Rf ~/.lein | |
rm -Rf ./target | |
lein self-install | |
lein clean | |
lein version |
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.
In the mid-80s, while reading through my roommate's collection of Scientific American back issues, I encountered this introduction to Lisp written by Douglas Hofstadter. I found it very charming at the time, and provide it here (somewhat illegally) for the edification of a new generation of Lispers.
In a testament to the timelessness of Lisp, you can still run all the examples below in emacs if you install these aliases:
(defalias 'plus #'+)
(defalias 'quotient #'/)
(defalias 'times #'*)
(defalias 'difference #'-)
;; Based on a queue polling function from Chas Emerick's bandalore: | |
;; https://github.com/cemerick/bandalore/blob/master/src/main/clojure/cemerick/bandalore.clj#L124 | |
(defn wait-for | |
"Invoke predicate every interval (default 10) seconds until it returns true, | |
or timeout (default 150) seconds have elapsed. E.g.: | |
(wait-for #(< (rand) 0.2) :interval 1 :timeout 10) | |
Returns nil if the timeout elapses before the predicate becomes true, otherwise |