Skip to content

Instantly share code, notes, and snippets.

@rampion
rampion / try-catch-ex.c
Created April 8, 2009 02:35
TRY/CATCH/FINALLY macros for C
// gcc -o try-catch-ex try-catch.c try-catch-ex.c
#include <stdio.h>
#include "try-catch.h"
// Example of use for try-catch.h
int main(int argc, char *argv[])
{
int i = 101;
printf("before try block...\n");
@codedot
codedot / Makefile
Created March 31, 2011 11:03
Makefile to determine Shell subgrammars
RULES = \
complete_command \
list \
and_or \
pipeline \
pipe_sequence \
command \
compound_command \
compound_list \
term \
@hSATAC
hSATAC / 256color.pl
Created July 20, 2011 14:48
256color.pl
#!/usr/bin/perl
# Author: Todd Larason <[email protected]>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
# use the resources for colors 0-15 - usually more-or-less a
# reproduction of the standard ANSI colors, but possibly more
# pleasing shades
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < 6; $red++) {
@certik
certik / a.f90
Created January 23, 2012 21:32
transfer() example
program a
use types, only: dp
use compute, only: init, register_func, run, eq, destroy, get_context
use my_data_type, only: my_data, type2data, data2type
type(eq), pointer :: d
type(my_data), target :: data1, data2
data1%a11 = 0
data1%a12 = -1
@chadbrewbaker
chadbrewbaker / Roman.rb
Created January 15, 2013 23:05
Iowa Ruby Brigade kata showing Roman numeral computation is a monoid.
# Roman Numeral Evaluation is a Monoid
# Chad Brewbaker | Software Engineer | Telligen.org
# [email protected]
# Initial release January 15, 2013
class RomanMonoid
attr_accessor :prefix, :prefix_size, :suffix, :suffix_size, :suffix_credit, :sum, :homo
def initialize(val)
@flada-auxv
flada-auxv / grand_theft_wumps.lisp
Created March 19, 2013 20:35
Land of Lisp 第8章
(load "graph_util")
(defparameter *congestion-city-nodes* nil)
(defparameter *congestion-city-edges* nil)
(defparameter *visited-nodes* nil)
(defparameter *node-num* 30)
(defparameter *edge-num* 45)
(defparameter *worm-num* 3)
(defparameter *cop-odds* 15)
@ormaaj
ormaaj / reftest.bash
Last active March 30, 2021 13:39
Broken namerefs.
#!/usr/bin/env bash
# Only ksh93 has "real" C++-like references (called namerefs). They can be used
# as reference parameters for passing data structures like arrays in and out of
# functions. Bash 4.3+ and mksh also have a nameref feature, but unlike ksh93,
# which has three different kinds of nameref, bash supports just two of these
# and mksh only one (the for-loop type won't be illustrated here). It is the
# "dynamic" kind of nameref that is supported by all three, which is mostly
# just sugar for Bash's old "${!var}" behavior (ksh93 also uses this kind when
# a nameref doesn't refer to a positional parameter).
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active July 4, 2025 22:26
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.

anonymous
anonymous / sample1.c
Created April 25, 2014 03:41
sample 1
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
static void bout(char *msg) __attribute__((noreturn));
static int calc_expr(int val, int op);
static int calc_term(int val, int op);
static int calc_factor(void);
anonymous
anonymous / sample2.c
Created April 25, 2014 03:42
sample 2
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
static void bout(char *msg) __attribute__((noreturn));
static int calc_expr(void);
static int calc_term(void);
static int calc_factor(void);