Skip to content

Instantly share code, notes, and snippets.

{
"global": {
"red": {
"value": "#E60D4E",
"type": "color"
},
"blue": {
"value": "#0D7EE6",
"type": "color"
},
@ejfox
ejfox / setWidthAndHeight.js
Created May 13, 2022 13:38
Vue method to set width and height based on component element size
setWidthAndHeight() {
const cs = getComputedStyle(this.$el)
const paddingX = parseFloat(cs.paddingLeft) + parseFloat(cs.paddingRight)
const paddingY = parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom)
const borderX =
parseFloat(cs.borderLeftWidth) + parseFloat(cs.borderRightWidth)
const borderY =
parseFloat(cs.borderTopWidth) + parseFloat(cs.borderBottomWidth)
// CLEAR DATA
MATCH (n:Officer) DETACH delete n;
MATCH (n:Incident) DETACH delete n;
MATCH (n:Precinct) DETACH delete n;
MATCH (n:Penalty) DETACH delete n;
// SET CONSTRAINTS
CREATE CONSTRAINT officerIdConstraint ON (officer:Officer) ASSERT officer.id IS UNIQUE
CREATE CONSTRAINT incidentIdConstraint ON (incident:Incident) ASSERT incident.id IS UNIQUE
CREATE CONSTRAINT precinctIdConstraint ON (precinct:Precinct) ASSERT precinct.id IS UNIQUE
@ejfox
ejfox / import.cypher
Created May 6, 2021 17:10
Import CSV with Neo4J Cypher
// clear data
MATCH (n:Officer) delete n;
MATCH (n:Incident) delete n;
MATCH (n:Precinct) delete n;
MATCH (n:Penalty) delete n;
CREATE CONSTRAINT officerIdConstraint ON (officer:Officer) ASSERT officer.id IS UNIQUE
Parsed Date happiness total social energy wellness
2019-07-10 48.25351918 83.88230576 97.03125003 148.7255695 238.6566667
2019-07-11 149.6123334 98.34205408 185.3835502 94.47351362 249.3607796
2019-07-12 151.5025529 100 181.2305023 131.2680142 335.0919097
2019-07-13 104.975604 76.02830081 130.5435739 24.72176457 93.05885718
2019-07-14 106.9930615 79.22556595 70.54415526 50.38911631 176.7435962
2019-07-15 48.49782752 69.34323403 134.5885842 49.3129526 116.4604166
2019-07-16 65.89493656 88.01984618 181.9219129 94.17121736 127.9488072
2019-07-17 65.7430037 87.16667812 133.5655477 91.4792567 234.0841979
2019-07-18 78.91884416 86.8878136 95.92553568 80.09017738 245.2977639
@ejfox
ejfox / ndplayer.processing
Created February 10, 2021 23:00
Doomscroller Processing Script
PImage img; // Declare a variable of type PImage
float yScroll = 0;
// float scrollAmt = 50;
float threshold = 127;
PImage destination;
int lines = 1;
int scrollStart = 768;
float scrollScreens;
int revealAmt;
import find from 'lodash/find'
import filter from 'lodash/filter'
import sortBy from 'lodash/sortBy'
import fs from 'fs'
//import nest from 'd3-collection'
import * as collection from 'd3-collection'
let argv = process.argv
{
"name": "prerender",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
@ejfox
ejfox / alex4.js
Last active August 5, 2020 03:17
const { load } = require("@alex.garcia/observable-prerender");
const puppeteer = require("puppeteer");
async function main() {
let mapWidth = 1920
let mapHeight = 1080
// let startDate = "20200301"
let startDate = "20200122"
// Modified from https://github.com/siegfriedgrimbeek/cheerio-pagination-tutorial
// Thanks to Siegfried for open sourcing this
// I only modified it a tiny bit to work for qmap
// External dependencies
const axios = require('axios')
const cheerio = require('cheerio')
const fs = require('fs')
const chalk = require('chalk')