Skip to content

Instantly share code, notes, and snippets.

View maxweber's full-sized avatar

Max Weber maxweber

View GitHub Profile
@maxweber
maxweber / pomodoro.sh
Created October 19, 2015 09:21
A very plain pomodoro timer (only for Mac)
#!/bin/bash
# 25 minutes
sleep 1500 && osascript -e 'tell app "System Events" to display dialog "Pomodoro: 25 minutes are over"' &
(ns sortable-table.core
(:require [reagent.core :as reagent :refer [atom]]))
(def data
(atom
{:header ["Id" "Name" "City"]
:rows [["1" "Joe" "New York"]
["2" "Harry" "Boston"]
["3" "Alicia" "Miami"]]}))
@maxweber
maxweber / cartesian_product.clj
Last active August 31, 2015 10:49
Cartesian Product
(def data [[1 2] [11 22] [111 222]])
(defn combine [a b]
(mapcat
(fn [x]
(map
(fn [y]
(flatten [x y]))
b))
a))
(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]))