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
(def m {:from #<IMAPAddress [email protected]>, | |
:subject "Re: A friendly message", | |
:sender #<IMAPAddress foo.com>, | |
:multipart? true, | |
:content-type "multipart/ALTERNATIVE; boundary=bcaec5524106840d9e04d4ee1246", | |
:body [{"TEXT/PLAIN; charset=ISO-8859-1" "Lol.\r\n\r\n\r\nOn"} {"TEXT/HTML; charset=ISO-8859-1" "<div dir=\"ltr\">Lol.</div>"}]}) | |
(defn- plain-key [m] (first (filter #(re-find #"TEXT/PLAIN" %) (keys m)))) | |
(defn- plain-body [m] (let [body (first (:body m))] | |
(body (plain-key body)))) |
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
± lein ring server | |
Exception in thread "main" java.lang.StackOverflowError | |
at clojure.lang.Util.hasheq(Util.java:126) | |
at clojure.lang.PersistentHashMap.hash(PersistentHashMap.java:121) | |
at clojure.lang.PersistentHashMap.valAt(PersistentHashMap.java:153) | |
at clojure.lang.PersistentHashMap.valAt(PersistentHashMap.java:157) | |
at clojure.lang.RT.get(RT.java:634) | |
at ns_tracker.dependency$transitive.invoke(dependency.clj:15) | |
at ns_tracker.dependency$transitive$fn__748.invoke(dependency.clj:14) | |
at clojure.core.protocols$fn__5871.invoke(protocols.clj:76) |
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
; first attempt | |
(let [e (into {} (System/getenv))] | |
(into {} (for [[k v] e] [(keyword k) v])))))) | |
; a little nicer | |
(let [e (into {} (System/getenv))] | |
(zipmap (map keyword (keys e)) (vals e))) |
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
;;; Expansion of YetiBot's cmd-hook | |
;;; https://github.com/devth/yetibot/blob/master/src/yetibot/util.clj#L16-48 | |
(clojure.pprint/pprint | |
(macroexpand '(cmd-hook #"wordnik" | |
#"define\s(\w+)" (define (second p)) | |
#"random" (random) | |
#"wotd" (wotd)))) | |
;;; result |
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
scala> trait B { def build: Int } | |
defined trait B | |
scala> case class B1() extends B { val build = 1 } | |
defined class B1 | |
scala> case class B2() extends B { val build = 2 } | |
defined class B2 | |
scala> val l: List[() => B] = List(B1, B2) |
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
# IronCore::Logger.logger.level = ::Logger::DEBUG | |
IronCore::Logger.logger = Rails.logger | |
# Reference any workers to be uploaded | |
worker = IronWorkerNG::Code::Base.new(:workerfile => '../../workers/email_export.worker') | |
Rails.logger.info("Uploading #{worker.name}") | |
# Initialize the client | |
client = IronWorkerNG::Client.new | |
# Upload the code |
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
services | |
| | |
site-converter-replacement (scala, json endpoint) | |
/ | \ | |
webapp api emails |
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
# Email the file | |
# | |
ActionMailer::Base.smtp_settings = smtp_settings.merge({"port" => '25'}) | |
puts "Using smtp config" | |
puts ActionMailer::Base.smtp_settings | |
ActionMailer::Base.delivery_method = :smtp | |
# Set AM's view path | |
ActionMailer::Base.view_paths = ['.'] |
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
Backbone.History.prototype.getFragment = _.wrap(Backbone.History.prototype.getFragment, | |
function(getFragment, fragment, forcePushState) { | |
// If we disabled hashChange, forcePushState should always be true | |
forcePushState = forcePushState || (!this._wantsHashChange); | |
return getFragment.call(this, fragment, forcePushState); | |
}); |
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
lazy val (expertScoreCount, expertReviewList, expertAverageScore) = reviewSummary match { | |
case Some(rs) => (Option(rs.getExpertAverageScore), Option(rs.getReviewList), | |
Option(rs.getExpertAverageScore)) | |
case _ => (None, None, None) | |
} |