Skip to content

Instantly share code, notes, and snippets.

View digitalWestie's full-sized avatar

Rory digitalWestie

View GitHub Profile
@digitalWestie
digitalWestie / _explainer.md
Last active January 19, 2024 13:05
Rails nested attributes view strategy

Putting related 0 to many resources within a form

For example, we have Paper and EvidenceItem models. We want to let the user add/remove/edit EvidenceItems while they are adding or editing Paper records.

The Paper model looks like this:

class Paper < ApplicationRecord

 has_many :evidence_items, dependent: :destroy
@digitalWestie
digitalWestie / cool_icons_bro.md
Last active January 16, 2024 13:29
Unicode Icon Cheatsheet
@digitalWestie
digitalWestie / titanic.csv
Created September 18, 2023 20:11
Stanford cleaned Titanic passengers dataset
Survived Pclass Name Sex Age Siblings/Spouses Aboard Parents/Children Aboard Fare
0 3 Mr. Owen Harris Braund male 22 1 0 7.25
1 1 Mrs. John Bradley (Florence Briggs Thayer) Cumings female 38 1 0 71.2833
1 3 Miss. Laina Heikkinen female 26 0 0 7.925
1 1 Mrs. Jacques Heath (Lily May Peel) Futrelle female 35 1 0 53.1
0 3 Mr. William Henry Allen male 35 0 0 8.05
0 3 Mr. James Moran male 27 0 0 8.4583
0 1 Mr. Timothy J McCarthy male 54 0 0 51.8625
0 3 Master. Gosta Leonard Palsson male 2 3 1 21.075
1 3 Mrs. Oscar W (Elisabeth Vilhelmina Berg) Johnson female 27 0 2 11.1333
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@digitalWestie
digitalWestie / Scraping-fruit-pictures.md
Last active June 1, 2023 20:39
Scraping and data-prep code for USDA Pomological Watercolour Collection using NodeJS

Creating data-driven fabric designs with JavaScript

P1. Scraping and data preparation with nodejs

You've watched the screencast, here's the code! The screencast starts off with fruit-step-0.mjs, and progresses from there.

The changes for each step are as follows:

  • fruit-step-0.mjs: we start here
  • fruit-step-1.mjs: adds thumbnail url parsing and downloadResults function to download thumbnails from a single result page
  • fruit-step-2.mjs: adds parsing of each result's common name and adds skip condition for apples
@digitalWestie
digitalWestie / normaliser.rb
Last active September 27, 2022 13:18
Country name normaliser
{"Scotlan"=>"Scotland",
"Gb-Sct"=>"Scotland",
"Gb-Eng"=>"England",
"Uk"=>"United Kingdom",
"Usa/Colorado"=>"United States",
"United States of America"=>"United States",
"Texas, Usa"=>"United States",
"Gbr"=>"United Kingdom",
"Uk-Scotland"=>"Scotland",
"UK"=>"United Kingdom",
@digitalWestie
digitalWestie / message_queue.py
Created April 9, 2022 00:17
Experimenting with a message queue system with couchdb.
import threading, time
from cloudant.client import CouchDB
from cloudant.database import CouchDatabase
from cloudant.document import Document
client = CouchDB("username", "password", url="http://couch-main:5984", connect=True, auto_renew=True, timeout=4000)
db = CouchDatabase(client, "channel_queue")
def process_requets(myc):
print("Starting threaded func")
time.sleep(5)
@digitalWestie
digitalWestie / client-dev.md
Last active August 23, 2021 22:11
Bugbears I'm tired of

Stop leaving testing to the last minute

Most people building software these days follow some kind of agile practice where software is available to test as it gets built. Try using it and continue doing so as soon as it is available. Early feedback is very helpful, especially in terms of thinking through which features are high priority and which aren't.

Even if you're not going to do this, actually spend some time to test the software. It continues to surprise me how unwilling people are to actually just start using the thing they are paying money to get built. This is a problem that can't really be solved with money. Time needs to be allocated to appropriately steer development.

Enough with the task creep

@digitalWestie
digitalWestie / object-to-form.js
Last active April 30, 2021 12:46
JSON Object to form builder
const insertInput = (name, value, type, labelText) => {
// Create wrapper for input and label
const inputWrapper = document.createElement("div");
// Create label and input
let label = document.createElement("label");
let content = document.createTextNode(labelText);
let input = document.createElement("input");
input.setAttribute('type', type);
@digitalWestie
digitalWestie / README.md
Last active January 21, 2021 21:33
A Rasa tracker implementation for couchDB

This is a CouchDB implementation for a Rasa (2.0) tracker that makes use of the Cloudant CouchDB API wrapper.

To use, you'll need to install the cloudant package with pip, or add to your requirements.txt (cloudant==2.14.0)

Copy tracker.py into project-root/couch_tracker/ directory. Next, configure your endpoint details based on the example, and insert into your endpoints yml.

That should be it! Let me know if it works, or doesn't- @digitalWestie x

Licence