0 Replies - 1075 Views - Last Post: 07 April 2010 - 12:48 AM

#1 Raynes   User is offline

  • D.I.C Lover
  • member icon

Reputation: 614
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

[Lisp] [Clojure] Code to post to gist.github.com using it's API

Posted 07 April 2010 - 12:48 AM

Description: You need to have http://github.com/rn...clj-apache-http on the classpath to use this snippet, along with http://github.com/da...ojure-json.This snippet uses the Gist API to post Gists. Gist is a very awesome pastebin.
(ns sexpbot.gist
  (:require [com.twinql.clojure.http :as http]
	    [org.danlarkin.json :as json])
  (:import (java.net URI)))

(def posturl "http://gist.github.com/api/v1/json/new")

(defn cull [js] (-> js json/decode-from-str :gists first :repo))

(defn post-gist [fname contents]
  (->> (http/post posturl :query {(str "files[" fname "]") contents} :as :string) 
       :content 
       cull
       (str "http://gist.github.com/")))


Is This A Good Question/Topic? 0
  • +

Page 1 of 1