Skip to content

Instantly share code, notes, and snippets.

java.net.SocketException: Connection reset
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:181)
at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:115)
at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:122)
at org.apache.http.entity.StringEntity.writeTo(StringEntity.java:170)
at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:89)
at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:108)
at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:117)
(with-resource [c (consumer config)]
shutdown
(doseq [message (messages c "topic")]
(process-message message)))
@dpick
dpick / copy
Last active August 27, 2016 00:51
Clojure postgres copy table
(ns backfill-spike.core
(:require [byte-streams :as bs]
[clojure.java.jdbc :as jdbc]
[clojure.string :as string]
[clojure.java.io :as io]
[environ.core :refer [env]])
(import org.postgresql.copy.CopyManager)
(import org.postgresql.copy.PGCopyInputStream)
(import org.postgresql.util.PSQLException)
(import java.io.IOException)

Keybase proof

I hereby claim:

  • I am dpick on github.
  • I am davidpick (https://keybase.io/davidpick) on keybase.
  • I have a public key whose fingerprint is 6960 FDA3 4FEA BD3A 8244 7F84 66E0 8334 4DE3 1424

To claim this, I am signing this object:

def delete(value, node = @root)
return if node.nil?
if x < node.value
node.left = delete(x, node.left)
elsif x > node.value
node.right = delete(x, node.right)
else
if node.left.nil?
return node.right
bonus: Stealthed
ability_score:
primary: dexterity
secondary:
- strength
- charisma
powers:
cloud_of_steel:
name: Cloud Of Steel
type: at_will
@dpick
dpick / gist:5071762
Created March 2, 2013 16:17
Anonymous users with friend
(defn credential-fn [guid]
(if-let [user (persistence/find-user-by-guid guid)]
(assoc user :roles #{:fashion.server/user})))
(defn guid [request]
(if (empty? (:session request))
(let [user (persistence/create-user {:guid (java.util.UUID/randomUUID) :password (str (java.util.UUID/randomUUID))})]
(workflows/make-auth (assoc user :roles #{:fashion.server/user} :identity (:guid user)) {:cemerick.friend/workflow :guid}))
(let [user (persistence/find-user-by-guid (get-in request [:session :cemerick.friend/identity :current]))]
(when user
(defn find-user
[id]
{:id id})
@dpick
dpick / gist:4704719
Last active December 12, 2015 03:09
(time (map #(score %) (take 10000 (range 144115222435594240 149551225103187968))))
; "Elapsed time: 0.107 msecs"
(time (sort (map #(score %) (take 10000 (range 144115222435594240 149551225103187968)))))
; "Elapsed time: 672.586 msecs"
require 'rubygems'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open(ARGV[0]))
title = doc.css('title').first.content.scan(/\r\n\t(.*) -/).first
puts title
image = doc.css('img#imgPhoto').first.attributes['src'].value