Skip to content

Instantly share code, notes, and snippets.

View philsmy's full-sized avatar

Phil Smy philsmy

View GitHub Profile
@philsmy
philsmy / patient_datum.rb
Created May 11, 2020 06:06
Class to read in patient data
# frozen_string_literal: true
require 'csv'
class PatientDatum < ApplicationRecord
def self.import_from_csv
columns = %i[external_id episode_date age_group gender acquisition_info outcome reporter reporter_address reporter_city reporter_postal_code reporter_website reporter_latitude reporter_longitude country region]
upsert_columns = %i[episode_date age_group gender acquisition_info outcome reporter reporter_address reporter_city reporter_postal_code reporter_website reporter_latitude reporter_longitude]
values = CSV.read(Rails.root.join('data/conposcovidloc.csv'))[1..-1]
@philsmy
philsmy / index.html.erb
Last active May 13, 2020 04:00
Some of the code for the Ontario index page of the Covid19 Visualization app
<% content_for :page_header do %>
<style>
#map {
height: 80%;
margin-top: 30px;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
@philsmy
philsmy / ontario_controller.rb
Created May 13, 2020 04:10
Getting the data for the Map
# frozen_string_literal: true
class OntarioController < ApplicationController
protect_from_forgery except: :map_data
def map_data
@patients = PatientDatum.where(region: 'ON').group(:reporter, :reporter_latitude, :reporter_longitude, :reporter_website).count
@patient_map = @patients.keys.map do |key|
{
'type': 'Feature',
@philsmy
philsmy / debug_rails.md
Created August 8, 2021 07:18
Debugging Ruby on Rails Cheatsheet
@philsmy
philsmy / .env
Created January 30, 2022 12:01
The files needed for getting a rails app running with postgres and pulling in the data from your old mysql database. As per my video here: https://youtu.be/2SOfvPZJZoM
PORT=3000
# postgresql
POSTGRES_HOST=localhost
POSTGRES_PORT=54323
POSTGRES_DBUSER=postgres
POSTGRES_PASSWORD=philsmy123
# mysql
MYSQL_DBNAME=lotteryportal_development