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
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
""" | |
AUTHOR: Gabriel Bassett | |
DATE: 11-19-2014 | |
DEPENDENCIES: py2neo | |
Copyright 2014 Gabriel Bassett | |
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 martha.core | |
(:require [clojurewerkz.titanium.graph :as g] | |
[clojurewerkz.titanium.vertices :as v] | |
[clojurewerkz.titanium.edges :as e] | |
[clojurewerkz.titanium.types :as t] | |
[ogre.core :as q])) | |
(def conf {:storage {:backend "embeddedcassandra" | |
:hostname "127.0.0.1" | |
:keyspace "martha" |
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] | |
(-> (->> n str seq reverse (partition-all 3) (interpose \,)) | |
flatten | |
reverse | |
(#(apply str %)))) | |
(commatize 1000) ;=> "100" | |
(commatize 100) ;=> "1,000" | |
(commatize 1000000) ;=> "1,000,000" |
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 people | |
(:use [clojure.string :only (join)] | |
[clojure.pprint :only (pprint simple-dispatch)])) | |
;; we can make maps using the special literal form: | |
{:a 100 | |
:b 200} | |
(class {:a 100 :b 200}) |
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
(comment "wildcardfilter from http://corfield.org/blog/post.cfm/real-world-clojure-powermta-log-files") | |
(defn- wildcard-filter | |
"Given a regex, return a FilenameFilter that matches." | |
[re] | |
(reify java.io.FilenameFilter | |
(accept [_ dir name] (not (nil? (re-find re name)))))) | |
(defn- nonhidden-filter | |
"return a FilenameFilter that ignores files that begin with dot or end with ~." |
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
(import '(org.joda.time LocalDate)) | |
(defn today [] (LocalDate.)) | |
;; basic functions to increment or decrement a date | |
(defn inc-date [#^LocalDate ds] (.plusDays ds 1)) | |
(defn dec-date [#^LocalDate ds] (.minusDays ds 1)) | |
;; generate infinite streams of LocalDate objects starting with start-ds | |
(defn inc-date-stream [#^LocalDate start-ds] (iterate inc-date start-ds)) |
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 dsstuff | |
"things i used to do in duckstreams in clojure 1.2.0") | |
;;read-lines from files | |
(defn read-lines-from-file [filename] | |
(with-open [rdr (clojure.java.io/reader filename)] | |
(line-seq rdr))) | |
;;thank you Abhinav Sarkar (http://stackoverflow.com/questions/4118123/read-a-very-large-text-file-into-a-list-in-clojure) |
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 gcount.core | |
"generates charts out of the result from google search term(s)." | |
(:use (incanter core charts)) | |
(:require [clj-http.client :as http-client])) | |
(def *search-provider* "http://www.google.com/search?hl=en&q=") | |
(def *search-pattern* #"About.*?([\d,]+).*?") | |
(defn search-for-term [term] | |
(let [encoded-term (.replaceAll (apply str term) " " "+") |
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
#(take (- %2 %1) (iterate inc %1)) |
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
reduce #(conj %1 %2 %2) [] |
NewerOlder