Skip to content

Instantly share code, notes, and snippets.

View candera's full-sized avatar

Craig Andera candera

View GitHub Profile
@candera
candera / gist:326567
Created March 9, 2010 13:30
Function to return a lazy sequence of all the descendant files of a directory.
(defn dir-descendants
"Creates a lazy sequence of files by recursively walking
a directory tree and returning all the files it finds."
[dir]
(let [children (.listFiles (File. dir))]
(lazy-cat
(map (memfn getPath) (filter (memfn isFile) children))
(mapcat dir-descendants
(map (memfn getPath) (filter (memfn isDirectory) children))))))
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Threading;
using Timer = System.Windows.Forms.Timer;
using System.IO;
(ns com.wangdera.slideshow
(:use [clojure.contrib.test-is])
(:import (java.io File)
(javax.imageio ImageIO)
(javax.swing JFrame JPanel Timer)
(java.awt Dimension Frame Color)
(java.awt.event ActionListener WindowAdapter)))
(def imagelist (atom []))
(def current-image (atom nil))
(defn cartes5
[a b & [c & ds :as more]]
(let [so-far
(for [x a y b]
[x y])]
(if more
(recur so-far c ds)
(map flatten so-far))))
(defn nfe-test []
(try
(let [nums (map #(Integer/parseInt %) ["1" "2" "1234123412341234"])]
(when (every? #(< 3 %) nums)
nums))
(catch NumberFormatException nfe nil)))
(nfe-test) ;; throws NumberFormatException, but I would expect it to
;; return nil
@candera
candera / repro.core
Created December 4, 2010 16:42
Why does this fail when I uberjar and run it?
(ns repro.core
(:use [clojure.contrib.io :only [reader]])
(:gen-class))
(defn -main [& args]
(println (line-seq (reader (first args)))))
@candera
candera / DesignNotes.md
Created September 25, 2011 02:14
Clojure SASS Compiler Design Notes

-- mode: markdown --

Design Notes

Project Code Name

TODO!

lip? mouth? backtalk? guff? sauce?

Leading contender: sauce

@candera
candera / err.txt
Created October 7, 2011 19:57
Heroku push error
git push heroku master | xclip -selection clipboard
Counting objects: 70, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (53/53), done.
Writing objects: 100% (57/57), 6.97 KiB, done.
Total 57 (delta 29), reused 0 (delta 0)
-----> Heroku receiving push
-----> Clojure app detected
-----> Installing Leiningen
@candera
candera / gist:1279385
Created October 11, 2011 20:47
spec failures
1) Refine search can search for income ranges
Failure/Error: page.number_of_leads.should == initial_results
expected: 876
got: 68 (using ==)
# ./spec/acceptance/refine_search_acceptance_spec.rb:147:in `block (2 levels) in <top (required)>'
2) Refine search can search for home value
Failure/Error: page.number_of_leads.should == initial_results
expected: 876
@candera
candera / gist:1279418
Created October 11, 2011 20:58
More spec failures
1) Refine search can refine the search with sliders for zipcode radius and age
Failure/Error: results_for_18_to_22_year_olds.should < results_for_30_mile_radius
expected: < 12416
got: 12416
# ./spec/acceptance/refine_search_acceptance_spec.rb:54:in `block (3 levels) in <top (required)>'
# ./app/models/setting.rb:63:in `with_temp_setting'
# ./spec/acceptance/refine_search_acceptance_spec.rb:22:in `block (2 levels) in <top (required)>'
2) Refine search can search for income ranges