Skip to content

Instantly share code, notes, and snippets.

View billdozr's full-sized avatar

Alen Ribic billdozr

View GitHub Profile
(defn preview-essay-body []
(let [body-el (dom/getElement "body_id")
preview-el (dom/getElement "preview_pane")
b-txt (.value body-el)
safe "false"]
(dom/removeChildren preview-el)
(dom/appendChild
preview-el
(dom/htmlToDocumentFragment
(js* "new Showdown.converter().makeHtml(~{b-txt},~{safe})")))))
(defn essay [slug]
(render-request
(temp/base {:title "Essay"
:navigation (temp/nav)
:content (temp/essay [(essays/fetch slug)])}))
(def core
(app
wrap-params
(wrap-static "src/alen_blog/static" ["/js" "/css"])
(defn do-build-slug [s]
(if-let [slug-el (dom/getElement "slug_id")]
(.value slug-el (js* "~{s}.replace(/^\\s+|\\s+$/g, '').replace(/[^a-z0-9 -]/g, '').replace(/\\s+/g, '-').replace(/-+/g, '-')"))))
:dependencies [[org.clojure/clojure "1.2.1"] ;"1.3.0-beta1"
[org.clojure/clojure-contrib "1.2.0"]
[enlive "1.0.0"]
[net.cgrand/moustache "1.0.0"]
[postgresql "8.4-701.jdbc4"]
[org.clojure/java.jdbc "0.0.5"]
[ring/ring-core "0.3.11"]
[ring/ring-devel "0.3.11"]
[ring/ring-jetty-adapter "0.3.11"]]
:dev-dependencies [[swank-clojure "1.4.0-SNAPSHOT"]]
@billdozr
billdozr / jquerytest.cljs
Created July 25, 2011 23:32 — forked from ryancrum/jquerytest.cljs
How to use jQuery from ClojureScript
(ns jquerytest.core)
(def jquery (js* "$"))
(jquery
(fn []
(-> (jquery "div.meat")
(.html "This is a test.")
(.append "<div>Look here!</div>"))))
(ns blog
(:require
[goog.Uri :as uri]
[goog.net.XhrIo :as xhrIo]
[goog.events :as events]
[goog.dom :as dom]))
(def essays-uri (goog.Uri. "http://localhost:8080/essays/part"))
(defn retrieve [url callback]
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Ham" instead of the number and for the multiples of five print "Jam". For numbers which are multiples of both three and five print "HamJam".
Process: TermKit [41551]
Path: /Users/alen/Development/javascript/node/TermKit/Build/TermKit.app/Contents/MacOS/TermKit
Identifier: net.acko.TermKit
Version: 0.3.2-alpha (0.3.2)
Code Type: X86-64 (Native)
Parent Process: launchd [147]
Date/Time: 2011-05-19 13:20:52.676 +0200
OS Version: Mac OS X 10.6.6 (10J567)
Report Version: 6
@billdozr
billdozr / gist:765280
Created January 4, 2011 19:42
First shot at Tic-Tac-Toe
module Main
where
import Data.Maybe (isNothing, fromJust)
import Data.List (intercalate)
import Char (toUpper)
import System.IO (hFlush, stdout)
data Move = O | X
deriving (Eq, Show, Enum, Ord)
SELECT r.name, b.amount_incl_tax,
(SELECT l.name from labeling_label l INNER JOIN labeling_labeleditem li
ON li.label_id=l.id AND li.object_id=b.id AND li.content_type_id=28 LIMIT 1) AS labels
FROM billing_genericbill b
INNER JOIN billing_recipient r ON b.recipient_id=r.id
ORDER BY labels