Skip to content

Instantly share code, notes, and snippets.

@jdunkerley
jdunkerley / spline.py
Created May 14, 2020 08:02
Cubic Spline
from typing import Tuple, List
import bisect
def compute_changes(x: List[float]) -> List[float]:
return [x[i+1] - x[i] for i in range(len(x) - 1)]
def create_tridiagonalmatrix(n: int, h: List[float]) -> Tuple[List[float], List[float], List[float]]:
A = [h[i] / (h[i] + h[i + 1]) for i in range(n - 2)] + [0]
B = [2] * n
C = [0] + [h[i + 1] / (h[i] + h[i + 1]) for i in range(n - 2)]
@jdunkerley
jdunkerley / azure-pipelines.xml
Created April 13, 2020 14:09
React CI Pipeline for Azure DevOps
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
module.exports = {
env: {
browser: true,
es6: true,
"jest/globals": true
},
extends: [
'plugin:react/recommended',
'standard'
],
@jdunkerley
jdunkerley / GeoProjection.html
Last active January 4, 2019 20:32
AlterD3 Geo Projections
<!-- ref: https://d3js.org/d3.v5.min.js //-->
<!-- Input Expected: SpatialObj //-->
<div id="ChartHtml">
<div id="chart1" style="background-color: white;">
<svg id="chartSVG" style="width:1400px; height:700px;background-color: white;"></svg>
</div>
<script>
const getSpatial = r => r['SpatialObj']
const baseProjection = d3.geoAzimuthalEquidistant()
@jdunkerley
jdunkerley / StackedBarChart.html
Last active November 14, 2018 16:01
AlterD3 Stacked Bar Chart
<!-- ref: https://d3js.org/d3.v5.min.js -->
<!-- Input Expected: Group, Set, Value -->
<div id="ChartHtml">
<div id="chart1" style="background-color: white;">
<svg id="chartSVG" style="width:800px; height:600px;background-color: white;"></svg>
</div>
<script>
const svg = d3.select("#chartSVG")
const width = +svg.style("width").replace(/px/,"")
const height = +svg.style("height").replace(/px/,"")
@jdunkerley
jdunkerley / Chart.html
Created November 13, 2018 09:10
AlterD3 Coloured Bar Chart
<!-- ref: https://d3js.org/d3.v5.min.js //-->
<!-- Input Expected: Name, Value, Set //-->
<style>
</style>
<div id="ChartHtml">
<div id="chart1" style="background-color: white;">
<svg id="chartSVG" style="width:800px; height:600px;background-color: white;"></svg>
</div>
<script>
@jdunkerley
jdunkerley / BarChart.html
Last active November 14, 2018 16:11
AlterD3 Simple Bar Chart
<!-- ref: https://d3js.org/d3.v5.min.js //-->
<!-- Input Expected: Name, Value //-->
<div id="ChartHtml">
<div id="chart1" style="background-color: white;">
<svg id="chartSVG" style="width:800px; height:600px;background-color: white;"></svg>
</div>
<script>
const svg = d3.select("#chartSVG")
const width = +svg.style("width").replace("px","")
const height = +svg.style("height").replace("px","")
@jdunkerley
jdunkerley / GroupedRecordIDGUI.html
Created December 3, 2017 20:34
GroupedRecordIDGUI
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>GroupedRecordID</title>
<script type="text/javascript">
document.write(`<link rel="import" href="${window.Alteryx.LibDir}2/lib/includes.html">`)
</script>
</head>
<body>
@jdunkerley
jdunkerley / spark_pricePaid.py
Created December 20, 2016 08:18
Completed Spark Job Script In Python To Compute Statistics From Prices Paid Data
import math
import statistics
import copy
from pyspark import SparkConf, SparkContext
indexPostcode = 3
indexPrice = 1
indexDate = 2