Skip to content

Instantly share code, notes, and snippets.

View jamiecook's full-sized avatar

Jamie Cook jamiecook

View GitHub Profile
@jamiecook
jamiecook / fails.log
Created July 16, 2015 12:05
There was some serious problems running this particular report_result
jetski@ams:~/shared/log$ grep 243244 show_this_to_nkpart.log | tail -n 50 | head -n 30
SQL (2.4ms) UPDATE "report_results" SET "status" = 'Queued' WHERE "report_results"."id" = 243244
2015-07-16 11:49:50 +0000 ReportResultQueue -> Running ReportResult 243244/96595 [Sydney -> Queued], API gave accepted
SQL (2.2ms) UPDATE "report_results" SET "status" = 'Running' WHERE "report_results"."id" = 243244
SQL (2.0ms) UPDATE "report_results" SET "status" = 'Failure' WHERE "report_results"."id" = 243244
2015-07-16 11:49:58 +0000 ReportResultQueue -> Kahuna Inconsistency for ReportResult 243244/96595 [Sydney -> Failure] - marking as failed
2015-07-16 11:49:58 +0000 ReportResultQueue -> ReportResult 243244/96595 [Sydney -> Failure] was marked as failed, lets try the next one
2015-07-16 11:50:09 +0000 ReportResultQueue -> Requeuing ReportResult 243244/96595 [Sydney -> Failure]
SQL (10.8ms) UPDATE "report_results" SET "status" = 'Queued' WHERE "report_results"."id" = 243244
2015-07-16 11:50:13 +0000 ReportRes
@jamiecook
jamiecook / enum.rb
Last active September 9, 2015 10:30
module Enumerable
def with_progress(msg, resolution=1, &blk)
return enum_for(:with_progress, msg) unless block_given? # Sparkling magic!
Logger.indentStart(msg)
pb = VlcProgressBar.new(msg, size.to_i)
each_with_index { |elem, i|
yield(elem)
pb.full_increment if i%resolution == 0
class AverageWageImporter
def setup_demog_cube
zonal_data = ZonalData.new
zonal_data.append_field(:avg_income) unless zonal_data.has_field?(:avg_income)
end
def load_avg_income_by_category
params = ZenithYamlParameters.hash_from_file('economics.yaml')
params.fetch('labour_supply_parameters').
map_values { |_ind_cat, params| params.fetch('avg_weekly_wage').to_f }.
require 'zenith_model_run'
require_relative '../zmr/lib/hooks/tools.rb'
require_relative '../zmr/Full model run/Mode choice'
require_relative '../zmr/lib/hooks/zmr_parameter_file.rb'
require_relative '../zmr/Full model run/create_stop_2_stop_selection'
zmr_assign_day = ZenithModelRun.new
zmr_assign_day.set_parameters(OtParameterListReader.read['ZMR_params_Assignment_Day'])
# assignable_day_hook = 'Pre_assignment_day_last_iter'
require 'utils/verifier/zenith_assignment_results_verifier'
p 7794.to_result_name
s2s_pmturi = [1, 200, nil, 1, 7794, 5].to_pmturi
load_pmturi = [1, 200..220, nil, 31..37, 132, 5].to_pmturi
ZenithAssignmentResultsVerifier.compare_stop_to_stop_with_stop_boardings(load_pmturi, s2s_pmturi)
@jamiecook
jamiecook / clear_and_concise.rb
Last active November 17, 2015 05:29
How to do data migration for site mixup
def read_site_ids(filename)
CSV.parse(File.read(filename), headers: true).map { |row| row.first.to_i }
end
site_ids_currently_pending = read_site_ids('pre_narendra_pending_sites.csv') # -> https://docs.google.com/spreadsheets/d/1vfCPqUGrnAT_wTjZdOAPxidXBHlZmzuoDj3Isi1PQBo/edit?usp=sharing
site_ids_to_remain_altered_and_archived = read_site_ids('archived_and_altered_sites.csv') # https://docs.google.com/spreadsheets/d/1moV7ImXYfQSq_LOOoGuhHORIwBGBN2_uJdddBcosQfE/edit#gid=867017539
site_ids_to_remain_altered = [122292, 136994, 137577, 137767]
# Update 11464 sites to be changed => authorised
site_ids_to_be_authorised = site_ids_currently_pending - site_ids_to_remain_altered - site_ids_to_remain_altered_and_archived
echo off
if exist d:\bdk\bedrock\lib\OtCustomZenith\zenith-cpp_%1 (
echo "File exists, skipping build and just running the test"
) else (
echo "File doesn't exist, trying to build it"
git checkout %1
rake build_quick
mkdir d:\bdk\bedrock\lib\OtCustomZenith\zenith-cpp_%1
@jamiecook
jamiecook / scoreboard_analysis.css
Created January 22, 2016 01:32
Displaying Scoreboard Analysis visually
/** choropleth visualization */
#sydney_scoreboard{
marker-fill-opacity: 0.8;
marker-line-color: #FFF;
marker-line-width: 1;
marker-line-opacity: 1;
marker-width: 10;
marker-fill: #dddddd;
marker-allow-overlap: true;
# The two companies in questions
qms_id = 96
goa_id = 7
# Get all QMS assets
Site.where(company_id: qms_id).size # => 1080
qms_sites = Site.where(company_id: qms_id)
qms_site_ids = qms_sites.map(&:id) # [133681, 129348, 129378, 133678, 132010, 132016, 132021, 132030, 132053, 131998, 131991, 132058, 139150, 132007, 139263, 132019, 132020, 132026, 132028, 132029, 140056, 139193, 132049, 132059, 132013, 132014, 132018, 140058, 132005, 132008, 132011, 132015, 132017, 132024, 132027, 129662, 129664, 140048, 140050, 140064, 142607, 126452, 132036, 132051, 132006, 129659, 129660, 132041, 129477, 126475, 126641, 126762, 126515, 126483, 126487, 126491, 126492, 126495, 126498, 126501, 126511, 126513, 126516, 126543, 126546, 126549, 126553, 126554, 126558, 126562, 126566, 126570, 126571, 126589, 126591, 126598, 126599, 126611, 126612, 126618, 126619, 126621, 126628, 126637, 126660, 126678, 126689, 126700, 126712, 126723, 126728, 126734, 126745, 126754, 126765, 126766, 126770, 126771, 126788, 126792, 126797, 126810, 12

How to Install No-Install Bedrock

Bedrock now has a shiny new way of installation, that actually isn't an installation at all !!! Follow the steps below to make your way to the brave new world.

Remove the .rba files from Omnitrans

  • OT/plugin/rb
    • Delete 1_bedrock_configure_load_paths.rba
  • Delete zz_bedrock_config.rba