Skip to content

Instantly share code, notes, and snippets.

View josephwilk's full-sized avatar
💭
💻 🎨 🎵

Joseph Wilk josephwilk

💭
💻 🎨 🎵
View GitHub Profile
defmodule Bench do
@sample 100
defp average(time) do
time / @sample
end
defp bench(fun) do
f = fn ->
Enum.each 1..@sample, fn _ -> fun.() end
(defun clojure-in-tests-p ()
(or (string-match-p "test\." (clojure-find-ns))
(string-match-p "/test" (buffer-file-name))))
(defun midje-test-for (namespace)
(let* ((namespace (clojure-underscores-for-hyphens namespace))
(segments (split-string namespace "\\."))
(main-namespace (first segments))
(filename (last segments))
(test-segments (append (list "test" main-namespace "unit") (rest (butlast segments)))))
<testsuite>
<testcase classname="as-documentation.about-privates.how-to-refer-to-privates-in-facts" name="allows direct testing"></testcase>
<testcase classname="as-documentation.about-privates.how-to-refer-to-privates-in-facts" name="works with `provided`"></testcase>
<testcase classname="as-documentation.about-privates.how-to-refer-to-privates-in-facts" name="a private has been exposed"></testcase>
<testcase classname="as-documentation.about-privates.how-to-refer-to-privates-in-facts" name="as_documentation/about_privates/how_to_refer_to_privates_in_facts.clj:35"></testcase>
<testcase classname="as-documentation.about-privates.how-to-refer-to-privates-in-facts" name="as_documentation/about_privates/how_to_refer_to_privates_in_facts.clj:35"></testcase>
<testcase classname="as-documentation.about-privates.how-to-refer-to-privates-in-facts" name="Here is how you must use them"></testcase>
<testcase classname="as-documentation.about-privates.how-to-refer-to-privates-in-facts" name="testable-privates allows dire
* ring (like RACK):
"Clojure web application library"
https://github.com/mmcgrana/ring
https://github.com/weavejester/lein-ring
* cljsbuild:
CloureScript helper
https://github.com/emezeske/lein-cljsbuild
* midje
(clojure.string/replace (str (type "")) "class" ""\)
(defn gen-fn
[n as b]
(let [n (symbol n)
as (vec (map symbol as))
fn-value (eval `(fn ~n ~as ~b))]
(intern *ns* n fn-value)))
(gen-fn "user" [] '(println "I'M BEING CALLED!"))
((resolve (symbol (name :user))))
@josephwilk
josephwilk / gist:4452758
Last active December 10, 2015 15:09
Detect "dead code" or "delete me" in comments.
grep -irIsE '#[[:space:]]*[[:alpha:][:digit:]]' $(find . | grep .rb) | grep -iIsE 'dead[[:space:]]*code|delete[[:space:]]*me' | wc -l
@josephwilk
josephwilk / first_feature.feature
Created November 28, 2012 20:24 — forked from pipmossop/first_feature
first feature
Feature: Member joins a local community
In order to easily limit the items I buy and sell # WHY? Whats the value?
As a member
I want to join a local trading community
Background:  
Given I have installed the Retrade app
And I am on the join a community page
Scenario: Allow access to browser location
@josephwilk
josephwilk / gist:3620978
Created September 4, 2012 13:04
Example information provided by various dictionaries relating to the word "young"
WORD "young"
SYLLABLES ("young")
SOUNDS ("y" "uh" "ng")
SYLLASOUNDS (("y" "uh" "ng"))
STRESS 1
RHYME ("uh" "ng")
RHYTHM (1)
beep:
YOUNG y ah ng
@josephwilk
josephwilk / emr.py
Created June 11, 2012 16:23
Wrapper around elastic-mapreduce to make it easier to use
#!/usr/bin/env python
EMR_COMMAND = os.path.expanduser('~/elastic-mapreduce/elastic-mapreduce')
EMR_LOGGING_DIR = "s3://songkick/emr-logs"
def create_pig_job_flow(pigscript, num_instances=1, extraArguments=[]):
jobname = "Pig_Daily_" + datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
print "Creating pig job flow", jobname, pigscript
args = [EMR_COMMAND,
"--create",