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
(take 100 (map #(let [s (str %2 %3) ] (if (seq s) s (inc %)) ) | |
(range) | |
(cycle [ "" "" "Fizz" ]) | |
(cycle [ "" "" "" "" "Buzz" ]))) |
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 pipe | |
"Returns a pair: a seq (the read end) and a function (the write end). | |
The function can takes either no arguments to close the pipe | |
or one argument which is appended to the seq. Read is blocking." | |
[] | |
(let [promises (atom (repeatedly promise)) | |
p (second @promises)] | |
[(lazy-seq @p) | |
(fn | |
([] ;close the pipe |
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 logicfun.core | |
;(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic :rename {== ?==}])) | |
(def data [ | |
{:id 1 :type :t1 :name "one" :other1 :o2} | |
{:id 2 :type :t2 :name "two" :other2 :o1 :another :ao2} | |
{:id 3 :type :t3 :name "three" :other2 :o1 :another :ao1} | |
]) |
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
(def suites [:heart :club :diamond :spade]) | |
(def ranks | |
{ | |
:ace [1 11] | |
:two [2] | |
:three [3] | |
:four [4] | |
:five [5] | |
:six [6] | |
:seven [7] |
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 iterate-while-1 | |
[f x] | |
(when x | |
(cons x (lazy-seq (iterate-while f (f x)))))) | |
(defn iterate-while | |
[f x] | |
(take-while identity (iterate f x))) | |
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
(import (java.net NetworkInterface Inet4Address)) | |
(defn ip-filter [inet] | |
(and (.isUp inet) | |
(not (.isVirtual inet)) | |
(not (.isLoopback inet)))) | |
(defn ip-extract [netinf] | |
(let [inets (enumeration-seq (.getInetAddresses netinf))] | |
(map #(vector (.getHostAddress %1) %2) (filter #(instance? Inet4Address %) inets ) (repeat (.getName netinf))))) |
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 topoged.tt | |
(:require [clj-time.core :refer [epoch]])) | |
(epoch) |
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
(require 'clojure.core.async :refer :all) | |
(def MOVES [:rock :paper :scissors]) | |
(def BEATS {:rock :scissors, :paper :rock, :scissors :paper}) | |
(defn rand-player | |
"Create a named player and return a channel to report moves." | |
[name] | |
(let [out (chan)] | |
(go (while true (>! out [name (rand-nth MOVES)]))) |
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
javax.servlet.ServletException: javax.jdo.JDODataStoreException: Insert request failed: INSERT INTO JDOAUTHENTICATIONKEY (DATE_CREATED,PURPOSE,MODEL_ENCODING,DATE_EXPIRES,FOR_PRINCIPAL,AUTHKEY) VALUES (?,?,?,?,?,?) | |
NestedThrowables: | |
SQL Exception: An SQL data change is not permitted for a read-only connection, user or database. | |
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515) | |
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) | |
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118) | |
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52) | |
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) |
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
<?php | |
/* | |
* Written by Matthew O. Smith <[email protected]> | |
* With {delicious}user/tag{/delicious} insert links from the user and tags | |
* With {delicious}user/tag?count=50{/delicious} you can spcifiy the number of items returned | |
*/ | |
class Delicious | |
{ | |
var $desc = array( |