Skip to content

Instantly share code, notes, and snippets.

View gabriel-laddel's full-sized avatar

Gabriel Laddel gabriel-laddel

View GitHub Profile
(ns kits.test.homeless
(:use clojure.test)
(:require [kits.homeless :as h]))
;;
;; its rather silly to have homeless aliased - I should just use everything (via vi) :refer
;;
;;
(deftest raise
;; ((((CAST(CAST(delivery_date_key as CHAR(8)) as DATE format 'YYYYMMDD') - CAST(CAST(order_date_key as CHAR(8)) as DATE format 'YYYYMMDD'))*5)
;; - ((day_of_week(CAST(CAST(order_date_key as CHAR(8)) as DATE format 'YYYYMMDD'))) - (day_of_week(CAST(CAST(delivery_date_key as CHAR(8)) as DATE format 'YYYYMMDD')))) * 2)/7)
;; - CASE WHEN day_of_week(CAST(CAST(order_date_key as CHAR(8)) as DATE format 'YYYYMMDD')) = 1 THEN 1 ELSE 0 END
;; - CASE WHEN day_of_week(CAST(CAST(delivery_date_key as CHAR(8)) as DATE format 'YYYYMMDD')) = 7 THEN 1 ELSE 0 END as days_order_to_delivery
(defn- day-of-week [date-time]
(case (.getDayOfWeek date-time)
1 2
2 3
3 4
@gabriel-laddel
gabriel-laddel / gist:4651584
Last active December 11, 2015 19:58
Difference between lisp-1 and lisp-2
;; lisp-1
(define x "foo")
(define x (lambda () "bar"))
(eval (x)) => "bar"
;; lisp-2
(define x "foo")
(define x (function () "bar"))
(defn- referred-to-in-originals-pred [type originals]
(if-not (= type :require-refer)
(constantly false)
(fn [[ns1 _ [alias1]]]
(some (fn [[[ns2 _ alias2]]]
(if (symbol? alias2)
(and (= alias1 alias2) (= ns1 ns2))
(and (= alias1 (first alias2)) (= ns1 ns2))))
originals))))
@gabriel-laddel
gabriel-laddel / gist:4652896
Created January 28, 2013 03:55
Context: I ran slamhound's reconstruct on the hound_test.clj file (slamhound/test/slam/hound_test.clj) from the REPL - it blew up. I hacked in a quick-fix. Thinking that it was weird that no one had this particular error filed under 'issues' I decided to recursively slamhound the project and then the specific file via a vi the terminal - No erro…
; nREPL 0.1.3
user> (use 'slam.hound)
nil
user> (println (reconstruct "/Users/francis/work/runa/slamhound/test/slam/hound_test.clj"))
WARNING: ex-info already refers to: #'clojure.core/ex-info in namespace: slingshot.ex-info, being replaced by: #'slingshot.ex-info/ex-info
WARNING: ex-data already refers to: #'clojure.core/ex-data in namespace: slingshot.ex-info, being replaced by: #'slingshot.ex-info/ex-data
UnsupportedOperationException nth not supported on this type: Symbol clojure.lang.RT.nthFrom (RT.java:846)
user>
The situation:
I'm messing around with slamhound and run `(reconstruct "/Users/francis/work/runa/slamhound/test/slam/hound_test.clj")` at the REPL - it throws this stacktrace.
https://www.refheap.com/paste/9016
So I begin to creat a regresssion test - however when I run it - no exception, outputs exactly what one would expect.
FAIL in (foo) (regrow_test.clj:75)
expected: (= "" (reconstruct "/Users/francis/work/runa/slamhound/test/slam/hound_test.clj"))
1. build a tags file of all the clojure code (non-emacs) use find and xargs and etags
2. have emacs load the tags file via 'visit tags table'
3. tell emacs to preform some function on every tags match.
4. tell them to 'indent-sexp' for each matching tags
;; The issue
; products that are excluded using category ID 'odd' are receiving a pre-abandonment offer.
;; The plan
; Define problem scope - does this problem only exist for category ID?
;Hola, I'm have an issue with ELISP control structures - could anyone point me in the right direction?
;I currently have "\C-c\C-o" bound to rgrep via `global set key` I would like to automatically jump to the
;*grep* buffer when finished with grep, but I'm not sure how to say that without doing something like
(global-set-key "\C-c\C-o" (lambda (x)
(interactive "sSearch for:"
; then prompt for directory ect.
)
(rgrep %s)
;; the downside to this being that I lose the default behavior of rgrep (defaulting to the symbol under cursor, or selected text)
@gabriel-laddel
gabriel-laddel / might make a lib out of this
Created April 1, 2013 02:45
Some functions for cleaning/organizing data returned from http://en.wikipedia.org/w/index.php?title=Special:Export&action=submit I might make this into a library....
(def v1 (s/replace currying
#"[\[\[\]\]''']"
""))
;; (s/replace v1 #"\S+ \(\S+\s\S+\)\|" "") - this is almost what I want
(def content (let [relevent-content (first (s/split v1 #"== See also ==" ))
dirty-sections (re-seq #"==[A-Za-z ]*==" relevent-content)
clean-sections (map (fn [s] (s/trim (s/replace s #"==" ""))) dirty-sections)]
relevent-content
;; {:content relevent-content