Skip to content

Instantly share code, notes, and snippets.

View spoon16's full-sized avatar
:shipit:

Eric Schoonover spoon16

:shipit:
  • Snohomish WA, Alexandria VA, and Costa Mesa CA
  • 21:07 (UTC -04:00)
View GitHub Profile
## convert HTML POST data or HTTP GET query string to JSON
## get the raw post data from the AWS built-in variable and give it a nicer name
#if ($context.httpMethod == "POST")
#set($rawAPIData = $input.path('$'))
#elseif ($context.httpMethod == "GET")
#set($rawAPIData = $input.params().querystring)
#set($rawAPIData = $rawAPIData.toString())
#set($rawAPIDataLength = $rawAPIData.length() - 1)
#set($rawAPIData = $rawAPIData.substring(1, $rawAPIDataLength))
java.lang.IllegalStateException: Current state not XML_START_ELEMENT (1) but 6
at com.fasterxml.jackson.dataformat.xml.deser.XmlTokenStream.repeatStartElement(XmlTokenStream.java:228)
at com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.addVirtualWrapping(FromXmlParser.java:280)
at com.fasterxml.jackson.dataformat.xml.deser.WrapperHandlingDeserializer._configureParser(WrapperHandlingDeserializer.java:140)
at com.fasterxml.jackson.dataformat.xml.deser.WrapperHandlingDeserializer.deserialize(WrapperHandlingDeserializer.java:108)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:230)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:207)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:23)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:464)
at com.fa
;; Anything you type in here will be executed
;; immediately with the results shown on the
;; right.
;; Anything you type in here will be executed
;; immediately with the results shown on the
;; right.
(defn- flatten-item
([item]
@spoon16
spoon16 / defprotocol_ArityException.clj
Last active December 17, 2015 06:19
Trying to figure out why line 13 is throwing an `ArityException` instead of yielding `"hello world"`
(defn slice
([]
(slice "hello world"))
([v]
(-slice v)))
(defprotocol Pizza
(-slice [this]))
(extend-type String
@spoon16
spoon16 / hiccup_problem.clj
Created October 16, 2012 06:57
Key must be integer - (class java.lang.IllegalArgumentException)
(ns myns
(:use [noir.core :only [defpage]]
[hiccup.form]))
(defpage "/my-form"
[]
(form-to [:post "/group-exporter/group.zip"]
(label "fristname" "First Name: ")
(text-field "firstname")
(submit-button "Submit")))
@spoon16
spoon16 / terminal.out
Created September 30, 2012 00:57
Troubleshooting Opscode Chef Knife EC2 Setup
poon16@desk ~/src$ gem install knife-ec2
Fetching: knife-ec2-0.5.14.gem (100%)
Successfully installed knife-ec2-0.5.14
1 gem installed
Installing ri documentation for knife-ec2-0.5.14...
Installing RDoc documentation for knife-ec2-0.5.14...
spoon16@desk ~/src$ knife ec2
FATAL: Cannot find sub command for: 'ec2'
The ec2 commands were moved to plugins in Chef 0.10
You can install the plugin with `(sudo) gem install knife-ec2
@spoon16
spoon16 / gist:3689043
Created September 10, 2012 05:27 — forked from Chouser/gist:3687532
Lazy seq as event subscription mechanism
;; Here is a spike of a lightweight in-process pubsub mechanism that allows pure ;; functional consumers, both blocking and asynchronous.
;; This defines the event stream, in this case just a series of numbers,
;; a new one produced each second
(defn timer []
(lazy-seq
(do
(Thread/sleep 1000)
(cons (System/nanoTime) (timer)))))
@spoon16
spoon16 / gist:2403227
Created April 17, 2012 03:34
lein clojurescript issue
$ lein repl
Deleting files generated by lein-cljsbuild.
Copying 1 file to /src/test/lib
Compiling ClojureScript.
Compiling "resources/public/js/test.js" from "src-cljs"...
Successfully compiled "resources/public/js/test.js" in 3.193873 seconds.
REPL started; server listening on localhost port 53484
user=> (require '[cljs.repl :as repl])
FileNotFoundException Could not locate cljs/repl__init.class or cljs/repl.clj on classpath: clojure.lang.RT.load (RT.java:430)
@spoon16
spoon16 / filter_nil_from_map.clj
Created February 18, 2012 08:51
filtering nil values from a map
(into {} (filter second {"DelaySeconds" DelaySeconds
"MessageRetentionPeriod" MessageRetentionPeriod
"MaximumMessageSize" MaximumMessageSize
"VisibilityTimeout" VisibilityTimeout
"Policy" Policy}))
@spoon16
spoon16 / util.clj
Created December 6, 2011 06:07
Protocol that normalizes different country representations
(defprotocol PCountryId
(country-id [c]))
(extend-protocol PCountryId
String (country-id [c] (country-id (NFCountry/findInstance c)))
clojure.lang.Keyword (country-id [c] (country-id (name c)))
NFCountry (country-id [c] (.getId c)))