This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var child_process = require('child_process'), | |
sys = require('sys'), | |
net = require('net'), | |
netBinding = process.binding('net'); | |
var fd = netBinding.socket('tcp4'); | |
netBinding.bind(fd, 8080); | |
netBinding.listen(fd, 128); | |
for (var i = 0; i < 4; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# change paths according to your repl setup | |
USER_HOME="/Users/antonio.garrote" | |
CLJR_HOME="/Users/antonio.garrote/.cljr" | |
CLASSPATH=src:test:. | |
if [ ! -n "$JVM_OPTS" ]; then | |
JVM_OPTS="-Xmx1G" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# bash completion support for core Git. | |
# | |
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> | |
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
# Distributed under the GNU General Public License, version 2.0. | |
# | |
# The contained completion routines provide support for completing: | |
# | |
# *) local and remote branch names |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== clj-stacktrace.repl | |
I regret to inform you that you are doing it wrong. | |
trace_test.clj:4 user/biz | |
... (defn biz [] ... | |
trace_test.clj:8 user/bat[fn] | |
... (let [f (fn [] (biz))] ... | |
trace_test.clj:9 user/bat | |
... (f)))) ... | |
trace_test.clj:13 user/bar | |
... (bat) ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; helper method | |
(defn grant-resource | |
[location resource buildings players] | |
(let [building (@buildings location) | |
building-type (if-not (nil? building) (building :type) :none)] | |
(case building-type | |
:settlement (dosync (alter players update-in [(building :owner) resource] (partial + 1))) | |
:city (dosync (alter players update-in [(building :owner) resource] (partial + 2))) | |
:none nil))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nthr(1, [X|_], X). | |
nthr(I, [_|Y], Z) :- N is I - 1, | |
nthr(N, Y, Z). | |
% :- nthr(3, [a,b,c], X). | |
% X = c ? | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn-e nth-o [n l o] | |
((1 (?a . ?d) a)) | |
((_ (?a . ?d) _) (nth-o (dec n) d o))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defprotocol ISeqable | |
(seqable? [x])) | |
(defmacro extend-to-seqable [& xs] | |
`(extend-protocol ISeqable | |
~@(mapcat (fn [x] [x `(~'seqable? [~'x] true)]) xs))) | |
(extend-to-seqable | |
clojure.lang.ISeq | |
clojure.lang.Seqable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(set! *unchecked-math* true) | |
(defmacro iloop [[b t n] & body] | |
`(loop [~@b] | |
(when ~t | |
~@body | |
(recur ~n)))) | |
(defn count-primes [^long n] | |
(let [c (inc n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns dcg | |
(:refer-clojure :exclude [reify == inc]) | |
(:use (clojure.core.logic minikanren prelude))) | |
(declare sentence noun-phrase verb-phrase det noun verb) | |
(defn sentence [s1 s3] | |
(exist [s2] | |
(noun-phrase s1 s2) | |
(verb-phrase s2 s3))) |