Skip to content

Instantly share code, notes, and snippets.

@murtaza52
murtaza52 / gist:2883717
Created June 6, 2012 18:19
enlive to enfocus
;;;Server Side code which retrieves a html fragment from client
(ns faiz.client.transforms
(:require [enfocus.core :as ef])
(:use-macros [enfocus.macros :only [append defsnippet content at set-attr html-content]])
(:require-macros [fetch.macros :as fm])
(:use [faiz.client.utils :only [log]]))
(defn doc [] js/document)
@sherbondy
sherbondy / facebook.js
Created June 2, 2012 01:28
externs for clojurescript
var FB = {};
FB.api = function(location, callback){};
FB.getLoginStatus = function(callback){};
FB.init = function(options){};
FB.login = function(callback, scope){};
FB.logout = function(callback){};
FB.Event = {};
FB.Event.subscribe = function(evt, callback){};
@stepankuzmin
stepankuzmin / geolocation.cljs
Created May 13, 2012 04:29
Geolocation using ClojureScript
(def urls (array "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png"
"http://b.tile.openstreetmap.org/${z}/${x}/${y}.png"
"http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"))
(def OSM (js/OpenLayers.Layer.XYZ. "OSM (with buffer)" urls (extend-object! (js-obj) {"transitionEffect" "resize"
"buffer" 2
"wrapDateLine" true
"sphericalMercator" true})))
(def plot (js/OpenLayers.Map. (extend-object! (js-obj) {"div" "plot"
@pelle
pelle / accounts.clj
Created May 8, 2012 14:37
Using database functions in Datomic transactions and annotating transaction history
(use '[datomic.api :only [q db] :as d])
(def uri "datomic:mem://accounts")
;; create database
(d/create-database uri)
;; connect to database
(def conn (d/connect uri))
(setq indent-tabs-mode nil)
(setq load-path
(append
(list
(expand-file-name "~/emacs-setup")
)
load-path))
(setq-default split-width-threshold 77)
@jackie
jackie / dabblet.css
Created May 7, 2012 15:05
FizzBuzz with CSS
/**
* FizzBuzz with CSS
*/
body {
counter-reset: fizzbuzz;
}
div {
@alexeypro
alexeypro / Server.java
Created May 6, 2012 15:25
Server.java example for vert.x
import org.vertx.java.core.Handler;
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.deploy.Verticle;
/*
Compile:
$ javac Server.java -Xlint:unchecked -cp $VERTX_HOME/lib/jars/vert.x-core.jar:$VERTX_HOME/lib/jars/vert.x-platform.jar
Run
@jespada
jespada / duckduckgo
Created April 13, 2012 02:38
emacs duckduckgo
;;DuckDuckgo search
(defun duckduckgo-search (text)
"Search DuckDuckGo from Emacs."
(interactive "sSearch: ")
(browse-url
(concat "https://duckduckgo.com/?q="
(replace-regexp-in-string " " "+" text))))
@alandipert
alandipert / reinvoke.cljs
Last active June 22, 2019 00:20
It's sweet that IFn is a protocol in ClojureScript
(extend-type js/RegExp
cljs.core/IFn
(-invoke ([this s] (re-matches this s))))
(#"foo.*" "foobar") ;=> "foobar"
(#"zoo.*" "foobar") ;=> nil
(filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz")
@stuarthalloway
stuarthalloway / gist:2321773
Created April 6, 2012 18:15
Datomic schema query, constrained by attribute namespace
;; Datomic sample code
;; schema query for attribute types in specified namespaces
(q '[:find ?attr
:in $ [?include-ns ...] ;; bind ?include-ns once for each item in collection
:where
[?e :db/valueType] ;; all schema types (must have a valueType)
[?e :db/ident ?attr] ;; schema type name
[(datomic.Util/namespace ?attr) ?ns] ;; namespace of name
[(= ?ns ?include-ns)]] ;; must match one of the ?include-ns