This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Double check file structure before use | |
task 'build:coffee', 'build src/client.js file from source files', (options) -> | |
files = content = [] | |
finished = {} | |
fs.readFile 'src/client/coffee/base.coffee', 'utf8', (err, contents) -> | |
content.push contents | |
for dir in ['views', 'collections', 'models'] then do (dir) -> | |
delay = (ms, func) -> setTimeout func, ms | |
if dir is 'models' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
distance = (lat1, lon1, lat2, lon2) -> | |
R = 6371 # km (change this constant to get miles) | |
dLat = (lat2 - lat1) * Math.PI / 180 | |
dLon = (lon2 - lon1) * Math.PI / 180 | |
a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) * Math.sin(dLon / 2) * Math.sin(dLon / 2) | |
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)) | |
d = R * c | |
if d > 1 | |
return d + "km" | |
else return Math.round(d * 1000) + "m" if d <= 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Select *, | |
acos(sin($lat)*sin(radians(event_latitude)) + cos($lat)*cos(radians(event_latitude))*cos(radians(event_longitude)-$lon))*$R As distance | |
From ( | |
Select search_view.*, images.image_url | |
From search_view, images | |
Where search_view.event_image_id = images.image_id | |
AND event_start > ? | |
And event_latitude>$min_lat And event_latitude<$max_lat | |
And event_longitude>$min_lon And event_longitude<$max_lon | |
) As FirstCut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rad2deg (angle) { | |
return angle * 57.29577951308232; // angle / Math.PI * 180 | |
} | |
function deg2rad (angle) { | |
return angle * .017453292519943295; // (angle / 180) * Math.PI; | |
} | |
function get_events (input_lat, input_lon) { | |
lat = input_lat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->facebook_id = $facebook_id; | |
$active_game = array_filter($games, function($game) { | |
return $game->active; | |
}); | |
if (count($active_game) > 1): | |
$active_game = array_filter($active_game, function($game) {return $game->creator === $this->facebook_id;}); | |
endif; | |
if (count($active_game)) $active_game[0]->garments = $this->get_garments($active_game[0]->game_id); | |
return $active_game[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$this->facebook_id = $facebook_id; | |
$active_game = array_filter($games, function($game) { | |
return $game->active; | |
}); | |
/* | |
# Not sure this is needed, the game with the lowest game_id should be returned. | |
if (count($active_game) > 1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$this->facebook_id = $facebook_id; | |
$active_game = array_filter($games, function($game) { | |
return $game->active; | |
}); | |
/* | |
# Not sure this is needed, the game with the lowest game_id should be returned. | |
if (count($active_game) > 1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getAllPrizes() { | |
return ORM::forTable("prizes")->findMany(); | |
} | |
var_dump( | |
$db->getAllPrizes()[0]->as_array() | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function enterNormalMode() { | |
console.log("entering normal mode"); | |
$(".editor > textarea").bind("keydown", blockAll); | |
$(".editor > textarea").addModalKeyboardShortcuts(normalKeybindings, insertKeybindings) | |
} | |
function enterInsertMode(e) { | |
e.preventDefault(); | |
console.log("entering insert mode"); | |
$(".editor > textarea").unbind("keydown", blockAll); | |
$(".editor > textarea").addModalKeyboardShortcuts(insertKeybindings, normalKeybindings) |