Skip to content

Instantly share code, notes, and snippets.

View maxweber's full-sized avatar

Max Weber maxweber

View GitHub Profile
(def app-state
(atom {:form {:email {:label "Email"
:error "invalid email"
:value "max@example.com"}}}))
(defn form-element [key]
(reagent/cursor app-state [:form key]))
(def cur (form-element :email))
@maxweber
maxweber / gist:1177947
Created August 29, 2011 07:34
Vijual Swing example
(ns prototype.graph
(:use vijual)
(:import [javax.swing JFrame JLabel]
java.awt.image.BufferedImage
java.awt.Dimension))
(defn draw []
(let [frame (new JFrame)
image (draw-tree-image [[:north-america [:usa [:miami] [:seattle] [:idaho [:boise]]]] [:europe [:germany] [:france [:paris] [:lyon] [:cannes]]]])
canvas (proxy [JLabel] [] (paint [g] (.drawImage g image 0 0 this)))
@maxweber
maxweber / gist:1156682
Created August 19, 2011 12:19
pathWithComponents
(ns path.core
(:use clojure.test)
(:require [clojure.string :as s]))
(defn clean-component [component]
(s/replace component #"/+" ""))
(defn path-prefix [components]
(if (re-find #"/+" (first components))
"/"
(def facebook-app-info {:client-id "107582059321384"
:client-secret "2022b10bce2b619aa9aee7b8a5f13aa7"
:redirect-uri "http://localhost:8080/facebook-callback"
:permissions ["user_photos" "friends_photos"]})
http://localhost:8080/albums/Max_Mustermann
http://localhost:8080/albums/me
clj-facebook-graph.example> (with-facebook-auth-by-name "Max Weber"
(client/get [:me :likes] {:query-params {:limit 2} :extract :data :paging true}))
clj-facebook-graph.example> (with-facebook-auth-by-name "Max Weber" (client/get [:me :home]))
clj-facebook-graph.example> (with-facebook-auth-by-name "Max Weber" (client/get [:me :friends]))
(with-facebook-auth {:access-token "134211159981787|2._UqBc68omALVTLR_FM6DZg__.3600.129951..."}
(client/get "https://graph.facebook.com/me/friends"))
@maxweber
maxweber / gist:858684
Created March 7, 2011 16:00
A list of friends fetched by clj-facebook-graph
clj-facebook-graph.example> (with-facebook-auth-by-name "Max Weber" (client/get "https://graph.facebook.com/me/friends"))
{:status 200, :headers {"content-type" "text/javascript; charset=UTF-8",
"date" "Mon, 07 Mar 2011 15:56:41 GMT",
"cache-control" "private, no-cache, no-store, must-revalidate",
"expires" "Sat, 01 Jan 2000 00:00:00 GMT",
"etag" "\"bb3aff0d25be9397d666254583743b7a8bcfb60e\"",
"x-powered-by" "HPHP", "content-length" "4462",
"pragma" "no-cache", "connection" "close", "x-fb-server" "10.32.53.102"},
:body {:data [{:name "Friend 1", :id "id of friend one"} {:name "Friend 2", :id "id of friend two"} ...