Skip to content

Instantly share code, notes, and snippets.

View jamiecook's full-sized avatar

Jamie Cook jamiecook

View GitHub Profile
#!/usr/bin/ruby
raise "USAGE: convert_job_folder job_folder bedrock_version" unless ARGV.size == 2
jobs_folder = ARGV[0]
bedrock_version = ARGV[1]
time_stamp = Time.now.strftime('%Y%m%d-%H%M')
puts "Converting folder #{jobs_folder} (timestamp: #{time_stamp})"
Dir.glob(File.join(jobs_folder, '**', '*.rb')).reject { |e| e =~ /settings.rb/ }.each { |file|
backup_file = "#{file}#{time_stamp}"
#!/usr/bin/ruby
# This script adds a new line to the start of each rb file in your jobs folder
# Store this outside your job folder (or it will try to convert itself) and then invoke it from the command line
# ruby convert_job_folder d:/16089/foo 918
# I would advise you to make a backup of that folder before running :)
require 'fileutils'
def convert_folder(jobs_folder)
time_stamp = Time.now.strftime('%Y%m%d-%H%M')

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
# 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
@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;
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 / 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
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)
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'
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 }.