Skip to content

Instantly share code, notes, and snippets.

View cmoore's full-sized avatar
🆑

Clint Moore cmoore

🆑
View GitHub Profile
Tue Aug 14 07:44:16 [initandlisten] MongoDB starting : pid=32549 port=27017 dbpath=./data 64-bit host=preston.local
Tue Aug 14 07:44:16 [initandlisten]
Tue Aug 14 07:44:16 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Tue Aug 14 07:44:16 [initandlisten] db version v2.2.0-rc0, pdfile version 4.5
Tue Aug 14 07:44:16 [initandlisten] git version: 33dc8445316479bbaa062db00f179fa5c39bbddb
Tue Aug 14 07:44:16 [initandlisten] build info: Darwin bs-osx-106-x86-64-1.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_49
Tue Aug 14 07:44:16 [initandlisten] options: { dbpath: "./data", logpath: "./out.log" }
Tue Aug 14 07:44:16 [initandlisten] journal dir=./data/journal
Tue Aug 14 07:44:16 [initandlisten] recover : no journal files present, no recovery needed
Tue Aug 14 07:44:16 [websvr] admin web console waiting for connections on port 28017
@cmoore
cmoore / damnit.lisp
Created August 26, 2012 19:50
To functional, or not to functional...
(defmacro with-x (login pass &rest body)
`(let ((the-connection (connect ,login ,pass)
,@body))
(defun test ()
(with-x "name" "pass"
(do-something the-connection)))
(defun number-to-word (number)
(cond ((string-equal number "12") "twelve")
(t "what")))
(defun test-it ()
`(format nil "~a" ,(number-to-word "12")))
(defmacro test-it-m ()
`(format nil "~a" ,(number-to-word "12")))
@cmoore
cmoore / servicle.lisp
Last active December 14, 2015 15:19
A quickie serve-the-current-directory script.
(ql:quickload 'cl-fad)
(ql:quickload 'hunchentoot)
(defun serve-this (args)
(declare (ignore args))
(hunchentoot:start (make-instance 'hunchentoot:easy-acceptor
:document-root (probe-file #P".")
:port 4040))
(read-char *standard-input*)

Reader Macros in Common Lisp

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.

Macros and read-macros see your program at different stages. Macros get hold of the program when it has already been parsed into Lisp objects by the reader, and read-macros operate on a program while it is still text. However, by invoking read on this text, a read-macro can, if it chooses, get parsed Lisp objects as well. Thus read-macros are at least as powerful as ordinary macros.

@HookHandler
public void onBlockRightClickHook(BlockRightClickHook hook) {
if (hook.getPlayer().getWorld().getFqName().equals("ctf_NORMAL")) {
hook.getBlockClicked().getPropertyKeys().forEach(new Consumer<BlockProperty>() {
@Override
public void accept(BlockProperty prop) {
hook.getPlayer().notice("P: ".concat(prop.getName()));
}});
}
}
private void show_tags(CompoundTag ctag, Player player) {
ctag.keySet().forEach(new Consumer<String>() {
@Override
public void accept(String s) {
player.notice("S: " + s + " V: " + ctag.get(s).toString());
}});
}
}
package me.swiftymove.Command;
import net.canarymod.Canary;
import net.canarymod.commandsys.CommandDependencyException;
import net.canarymod.plugin.Plugin;
public class Main extends Plugin{
@Override
public void disable() {
// The listener class for Beton...
package io.ivy.fawkes.beton;
import pl.betoncraft.betonquest.core.QuestEvent;
public class TestEvent extends QuestEvent {
public TestEvent(String playerID, String instructions) {
super(playerID, instructions);
System.out.println("TEST EVENT");
}
public class Utils {
public static List<Chest> find_all_chests(World world) {
List<Chest> chests = new ArrayList();
int tile_entities = 0;
for (Chunk c : world.getLoadedChunks()) {
for (BlockState b : c.getTileEntities()) {
tile_entities++;