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
def self.tiles_for(lat, lng, search_radius) | |
adj_lat = (lat + 90).floor | |
adj_lng = (lng + 180).floor | |
lat_interval = 110_574 # this is at the poles, its around 111km at the equator so we're using the shorter one - not worth calculating a more accurate value based on lat | |
# this one is from here: http://en.wikipedia.org/wiki/Longitude | |
# specifically: PI / 180 cos(theta) * N(theta), and we're using a fixed value | |
# of N(theta) because its close enough. Basically it is 0 at the poles | |
# and 68 miles at the equator. We'll allow a minimum of 10km though, which is | |
# basically at the poles, because I dont want to use a ton of tiles in |
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
-- filesystem | |
type Name = String | |
type Data = String | |
data FSItem = File Name Data | Folder Name [FSItem] deriving (Show) | |
myDisk :: FSItem | |
myDisk = | |
Folder "root" | |
[ File "goat_yelling_like_man.wmv" "baaaaaa" |
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
QCNFClauseList propagate_literal(const QCNFLiteral& lit, const QCNFClause& c) { | |
LOG_PRINT(LOG_DEBUG) << "propagate_literal called with lit=" << lit.first->toString() | |
<< " and clause c=" << convertFromQCNFClause(c).toString() << std::endl; | |
boost::shared_ptr<Sentence> cnfLit = lit.first; | |
// first figure out what kind of literal we have here. | |
std::queue<QCNFClause> toProcess; | |
QCNFClauseList processed; | |
toProcess.push(c); |
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
$ script/find_stale_asset_packages.rb /var/www/dev.lommekjent.no/current | |
Need to build these assets: {"js"=>["issues.show", "issues.index"], "css"=>["activities.index", "routes.new", "routes.new_planner", "trips.new", "trips.edit", "maintenances.index"]} | |
rake asset:packager:build_some BUILD_JS=issues.show,issues.index BUILD_CSS=activities.index,routes.new,routes.new_planner,trips.new,trips.edit,maintenances.index | |
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
rwgps.models.User.login(email, password) | |
.done(function(user) { | |
$('.logged_in').show().html(T.t('logged_in_as') + ' ' + user.get('email')); | |
$('.login_form').hide(); | |
$('.route_save_details').show(); | |
}) | |
.fail(function() { | |
$('.incorrect_password_message').show(); | |
}); |
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
def route_translations | |
return { | |
"distance.meters" => t('units.distance_in_words.x_meters'), | |
"distance.feet" => t('units.distance_in_words.x_feet'), | |
"distance.km" => t('units.distance_in_words.x_km'), | |
"distance.miles" => t('units.distance_in_words.x_miles'), | |
:yes => t('generic.yes'), | |
:no => t('generic.no'), | |
:routes => t('resources.routes'), | |
:new => t('path_names.new'), |
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
/** | |
* Get currently logged in user | |
* @method getCurrent | |
* @static | |
* @return {Promise} A promise for the currently authenticated user | |
*/ | |
User.getCurrent = function() { | |
if(this.currentDfd) | |
return this.currentDfd; |
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
login: function() { | |
var email = $('.email').val(), password = $('.password').val(); | |
rwgps.models.User.login(email, password) | |
.done(function(user) { | |
console.log('logged in as', user.get('email')); | |
}) | |
.fail(function() { | |
console.log('invalid username or password, please try again'); | |
}); | |
} |
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
class ScheduledReport | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
field :key, :type => String | |
index :key | |
field :name, :type => String | |
field :query, :type => String |
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
// example use: calculateMovingAverages('watts', [30, 60]) | |
calculateMovingAverages: function(metric, windowDurations) { | |
var points = this._points; | |
// need at least a couple points to not throw an error.. | |
if(points.length <= 2) return; | |
var baseMetric = 'watts'; | |
for(var durI=0; durI < windowDurations.length; durI++) { | |
n = windowDurations[durI]; | |
var avgMetric = baseMetric + '_ma_' + n; | |
var halfN = n/2; |
NewerOlder