This file contains 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/zsh | |
echo "making quil project $1." | |
mkdir $1 | |
cd $1 | |
mkdir src | |
mkdir spec | |
cat >deps.edn << EOF | |
{:paths ["src" "resources"] | |
:deps {org.clojure/clojure {:mvn/version "1.11.1"} | |
quil/quil {:mvn/version "4.3.1563"} |
This file contains 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/zsh | |
echo "making speclj project $1." | |
mkdir $1 | |
cd $1 | |
mkdir src | |
mkdir spec | |
cat >deps.edn << EOF | |
{:paths ["src" "resources"] | |
:deps {org.clojure/clojure {:mvn/version "1.11.1"} | |
speclj/speclj {:mvn/version "3.4.5"}} |
This file contains 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
Today I gave a keynote at ACCU in Oxford. In the midst of it I made two (count them) two statements that I should have known better than to make. I was describing the late '70s, and the way we felt about the C language at the time. My slide said something like: "C was for real men." Emily Bache, whom I know and hold in high regard, spoke up and said "What about women?". And I said something like: "We didn't allow women in those days." It was a dumb crack, and should either not have been said, or should have been followed up with a statement to the effect that that was wrong headed. | |
The second mistake I made was while describing Cobol. I mentioned Adm. Grace Hopper. I said something like "May she rest in peace." I don't know that any of the words were actually demeaning, but the tone was not as respectful as it should have been to an Admiral in the United State Navy, and one who was so instrumental in our industry; despite what I feel about Cobol. | |
I am a 59 year old programmer who was brought up |
This file contains 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 commatize [n] | |
(if (nil? n) | |
"" | |
(let [s (str n)] | |
(apply str | |
(reverse (drop-last | |
(interleave | |
(reverse s) | |
(take (count s) (flatten (repeat [nil nil \,])))))))))) |
This file contains 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 mad-libs-test | |
(:use clojure.test midje.sweet)) | |
(defn find-prompt [t]) | |
(defn get-response [t]) | |
(defn mad-libs [text] | |
(let [ | |
[pre prompt post] (find-prompt text)] | |
(if (nil? prompt) |
This file contains 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 prime-factors-test | |
(:use clojure.test midje.sweet)) | |
(defn factors-starting-at [f n] | |
(cond | |
(> f (Math/sqrt n)) (if (= n 1) [] [n]) | |
(= 0 (mod n f)) (cons f (factors-starting-at f (/ n f))) | |
:else (recur (inc f) n))) | |
(defn prime-factors-of [n] |
This file contains 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
public class Wrapper { | |
public static String wrap(String s, int col) { | |
return new Wrapper(col).wrap(s); | |
} | |
private int col; | |
private Wrapper(int col) { | |
this.col = col; | |
} |
This file contains 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
@Test | |
public void wrapJustBeforeWordBoundary() throws Exception { | |
assertThat(wrap("word word", 4), equalTo("word\nword")); | |
} |
This file contains 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
@Test | |
public void wrapWellBeforeWordBoundary() throws Exception { | |
assertThat(wrap("word word", 3), equalTo("wor\nd\nwor\nd")); | |
} |
This file contains 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
public class Wrapper { | |
public static String wrap(String s, int col) { | |
if (s.length() <= col) | |
return s; | |
int space = (s.substring(0, col).lastIndexOf(' ')); | |
if (space != -1) | |
return (s.substring(0, space) + "\n" + wrap(s.substring(space+1), col)); | |
else | |
return (s.substring(0, col) + "\n" + wrap(s.substring(col), col)); | |
} |
NewerOlder