Skip to content

Instantly share code, notes, and snippets.

Daniel Moscufo dmozzy

Block or report user

Report or block dmozzy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dmozzy / project.clj
Created May 17, 2012
project.clj showing the new :aot outpur
View project.clj
(defproject GeoTaskList "1.0.0-SNAPSHOT"
:description "Geolocated Tasklist mobile application"
:dependencies [[org.clojure/clojure "1.3.0"] [cheshire "2.2.0"] [compojure "1.0.1"]]
:dev-dependencies [[appengine-magic "0.4.7"]]
:aot [GeoTaskList.app_servlet GeoTaskList.core GeoTaskList.persistence])
dmozzy / persistence.clj
Created May 11, 2012
Adding user to the persistence.clj file
View persistence.clj
;Loads all locations. Retrieves the location field map for all locations
; and then adds in the locationId key value pair for each location.
(defn get-all-locations [user]
(fn [k]
(assoc (:location k) :locationId (ds/key-id k)));This line sets the id onto the map at load time
(ds/query :kind Location :filter (= :user user))))
;Deletes a location by locationId, note we need to check that the user is the one who owns the location
(defn delete-location [user locationId]
dmozzy / core.clj
Created May 11, 2012
Adding User to the Application
View core.clj
; Get Email function
(defn getEmail []
(.getEmail (aeu/current-user)))
;Example of adding user to the routes
(GET "/locations" []
(json-response {:locations (persist/get-all-locations (getEmail))}))
dmozzy / core.clj
Created May 11, 2012
Adding Google Authentication
View core.clj
;Middleware to add authentication
(defn require-login [application]
(fn [request]
(application request)
dmozzy / CalcDistance.js
Created Apr 16, 2012
Calculate Distance using google.maps.geometry.spherical.computeDistanceBetween
View CalcDistance.js
<script src="" type="text/javascript"></script>
<script type="text/javascript">
function calcDistance (fromLat, fromLng, toLat, toLng) {
return google.maps.geometry.spherical.computeDistanceBetween(
new google.maps.LatLng(fromLat, fromLng), new google.maps.LatLng(toLat, toLng));
View Locations.html
<!-- Task Page -->
<div data-role="page" id="task-page">
<div data-role="navbar">
<li><a href="#location-page" >Location</a></li>
<li><a href="#task-page" class="ui-btn-active ui-state-persist">Tasks</a></li>
<div data-role="content">
dmozzy / Locations.js
Created Apr 16, 2012
Task List javascript
View Locations.js
function getTasks() {
$.mobile.showPageLoadingMsg("a", "Loading Tasks", false);
$.getJSON( '/tasks',
function(data) {
navigator.geolocation.getCurrentPosition(function(position) {
$.each( data.tasks, function(i, task) {
var distance = calcDistance(position.coords.latitude, position.coords.longitude, task.taskLat, task.taskLng)/1000.0;
dmozzy / Locations.js
Created Apr 14, 2012
Task Edit Submit function
View Locations.js
$("form[name='task-edit-form']").submit(function() {
if ($("form[name='task-edit-form']").validate().numberOfInvalids()==0) {
$.post("/task", $("form[name='task-edit-form']").serializeArray(), function(){
$.mobile.changePage($("#task-page"), { transition: "pop", role: "page", reverse: false } );
return false;
View Locations.html
<!-- Edit Task Popup-->
<div data-role="page" id="task-edit-page">
<div data-role="header">
<div data-role="content">
<form name="task-edit-form">
<input id="taskId" name="taskId" type="hidden"/>
<label for="taskName">Task Name</label>
<input id="taskName" name="taskName" type="text" class="required" minlength="2"/>
dmozzy / persistence.clj
Created Apr 11, 2012
Blog #3 Task persistence changes Defentity
View persistence.clj
(ds/defentity Task [^:key taskId, locationId, ^:clj task])
You can’t perform that action at this time.