Skip to content

Instantly share code, notes, and snippets.

View edgargoncalves's full-sized avatar

Edgar Gonçalves edgargoncalves

  • https://www.businessdatapartners.com/
  • United Kingdom
View GitHub Profile
// Source code for the Priberam Ubiquity command
// By Edgar Gonçalves.
// Version 0.3
// Sun Jan 24 22:03:05 2010
// Adapted for new layout on the Priberam website (bugfix, preview wasn't working anymore - Thanks, Jorge Afonso).
// Version 0.2
// Sun Jun 28 2009
// Changed to use Parser 2 (requires Ubiquity 0.5 or above)
// Buxfer Slidebar jetpack, by Edgar Gonçalves
jetpack.future.import("slideBar");
function displayMessage(text) {
jetpack.notifications.show({title: 'Buxfer Jetpack',
body: text,
icon: 'https://www.buxfer.com/media/favicon/favicon-moneybag.ico'});
}
(defproject my-app "1.0.0-SNAPSHOT"
:description "A web application targetting the GAE, using its persistency layer."
:source-path "src"
:compile-path "war/WEB-INF/classes/"
:library-path "war/WEB-INF/lib/"
:dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]
[compojure "0.4.0-SNAPSHOT"] ;; remove commons-fileupload before uploading to gae
[hiccup "0.2.4"]
[ring-gae "0.2.0"]
(ns my-app.servlet
(:gen-class :extends javax.servlet.http.HttpServlet)
(:use ;; ring.adapter.jetty ;;uncomment this if you want a clojure jetty server
compojure.core
[hiccup core form-helpers page-helpers]
[ring.util.servlet :only [defservice]]
[ring.util.response :only [redirect]])
(:require [compojure.route :as route]
[appengine.users :as users]
[appengine.test :as test]
(defn init-app-engine
"Initialize the app engine services."
([] (init-app-engine "/tmp"))
([directory]
(let [proxy-factory (ApiProxyLocalFactory.)
environment (proxy [LocalServerEnvironment]
[]
(getAppDir [] (java.io.File. directory)))
api-proxy (.create proxy-factory environment)]
(ApiProxy/setDelegate api-proxy))))
(defmacro with-local-user [& body]
`(try (.setUp (test/local-service-test-helper (LocalUserServiceTestConfig.)))
~@body
(finally
(test/tear-down))))
(defn wrap-with-gae-local-user-service
"Ring middleware method that wraps an application so that every request will have
a user-info map assoc'd to the request under the key :appengine/user-info."
var pingTimer = null;
var pingServer = function () {
//make a background server request to a ping service
var x = $("<script/>", {src: "/servlet/ping"});
$("body").append(x);
x.remove();
};
var resetPingTimer = function () {
(ns clj-as.core
(:import [javax.script.ScriptEngine]
[javax.script.ScriptEngineManager]
[javax.script.ScriptEngineException]))
(defn order-itunes-to [command]
(let [mgr (javax.script.ScriptEngineManager.)
engine (.getEngineByName mgr "AppleScript")]
(.eval engine (str "tell application \"iTunes\" to " command))))
(require 'pc-select)
(defun slime-update-clojure-namespace ()
"Find the namespace in the current buffer and use SLIME's REPL
to switch to it, updating the namespace for all buffers."
(interactive)
(save-excursion
;; search for this buffer's namespace:
(goto-char 0)
(when (search-forward "(ns " nil t)
(let ((beg (point))
(defun slime-update-clojure-namespace (arg)
"Find the namespace in the current buffer and use SLIME's REPL
to switch to it, updating the namespace for all buffers.
Using an universal prefix will ask for the name of the namespace.
The actual namespace switch is done by calling `SLIME-REPL-SET-PACKAGE'."
(interactive "P")
(if arg
(call-interactively 'slime-repl-set-package)
(save-excursion
;; search for this buffer's namespace: