Skip to content

Instantly share code, notes, and snippets.

View phiat's full-sized avatar

Patrick Ryan phiat

  • East Coast, US
View GitHub Profile
@phiat
phiat / dabblet.css
Created April 11, 2013 07:40
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
body {
border-bottom-color: #ffd300;
border-bottom-width: 10px;
border-collapse: collapse;
border-left-color: #fcfa02;
border-right-color: #fcfa02;
border-style: groove;
@phiat
phiat / gmaps-test.clj
Created October 14, 2013 23:52
A simple static google maps img using compojure (ring/jetty for server) and hiccup (for html generation).
(ns gmaps-test.handler
(:use compojure.core)
(:require [compojure.handler :as handler]
[compojure.route :as route]
[hiccup.core :as h]))
(defn index-page []
(h/html [:img {:src "http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false"}]
))
@phiat
phiat / gist:9968800
Created April 4, 2014 05:42
clojure best hand
(defn best-hand [hand]
(let [suit (fn [c] (first c))
rank (fn [c] (last c))
ranks [\2 \3 \4 \5 \6 \7 \8 \9 \T \J \Q \K \A]
four-of-a-kind? (fn [h] (if (some #(= 4 %) (vals (frequencies (map rank h)))) true false))
flush? (fn [h] (= 1 (count (vals (frequencies (map suit h))))))
straight? (fn [h] (let [indexed-ranks (sort (map #(.indexOf ranks %) (map rank h)))
ends-diff (- (first indexed-ranks) (last indexed-ranks))]
(cond
(and (= 5 (count (frequencies indexed-ranks)))