Skip to content

Instantly share code, notes, and snippets.

View brianbancroft's full-sized avatar
🌲

Brian Bancroft brianbancroft

🌲
View GitHub Profile
@brianbancroft
brianbancroft / README.md
Created December 5, 2022 18:31
test markdown new tab link

Testing target:blank

Here is the page: page{:target="_blank"}

[page](https://google.com){:target="_blank"}
@brianbancroft
brianbancroft / JEST_VITE_APP.md
Created February 9, 2022 19:37
Integrate Jest & React Testing Library in a React Vite Project.

Integrate Jest & React Testing Library in a React Vite Project

  1. Install Dependencies
yarn add --dev jest babel-jest @babel/preset-env @babel/core @babel/plugin-syntax-jsx @babel/preset-react @testing-library/dom @testing-library/jest-dom @testing-library/react @testing-library/user-event babel-preset-react-app identity-obj-proxy jest-circus jest-scss-transform jest-watch-typeahead
  1. Set Jest & babel configs in package.json
"jest": {
    "roots": [
const [online, setOnline] = useState(true)
useEffect(() => {
let offlineToast
const goOffline = () => {
setOnline(false)
}
const goOnline = () => {
setOnline(true)
}
window.addEventListener('offline', goOffline)
@brianbancroft
brianbancroft / custom-task.js
Created April 16, 2019 12:34 — forked from CITguy/custom-task.js
Basic pattern for creating a custom Transform stream for use with gulp tasks.
var gulp = require('gulp');
var myTransform = require('./myTransform');
gulp.task('foobar', function (){
return gulp.src("foobar.js")
.pipe(myTransform())
.pipe(gulp.dest('.'));
});
@brianbancroft
brianbancroft / 1_decipher-richText.js
Last active April 2, 2019 14:04
Deciphering Contentful Rich Text Blocks in React. The second file is an example of the graphql output that would go into this.
import React from 'react'
const classList = marks => marks.map(i => i.type).join(' ')
const elementMap = {
paragraph: 'p',
'heading-1': 'h1',
'heading-2': 'h2',
'heading-3': 'h3',
'heading-4': 'h4',
@brianbancroft
brianbancroft / .env
Last active November 10, 2018 20:59
Basic Nodemailer App
EMAIL_ADDRESS=''
EMAIL_PASSWORD=''
@brianbancroft
brianbancroft / README.md
Last active October 15, 2018 20:36
Census DIM Dictionary

Census DIM

This is a supplement to https://github.com/adventice/census, and contains content you need to make a table with:

  • Headings for each value
  • Subheadings for each value

Building the table

Carry out the following to build the table

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brianbancroft
brianbancroft / test.xml
Created October 1, 2018 17:30
QGIS Imhof Hillshade Gadient
<!DOCTYPE qgis_style>
<qgis_style version="1">
<symbols/>
<colorramps>
<colorramp name="imhof_hillshade_dark" type="gradient">
<prop k="color1" v="119,66,70,255"/>
<prop k="color2" v="255,220,115,51"/>
<prop k="discrete" v="0"/>
<prop k="rampType" v="gradient"/>
<prop k="stops" v="0.278729;21,27,30,230:0.449878;0,132,168,51:0.603912;171,107,212,0:0.809291;255,193,127,38"/>
@brianbancroft
brianbancroft / grab.py
Last active September 5, 2018 19:36
Get bounding boxes for all CMAs in Canada using QGIS
bounding_boxes = []
features = iface.activeLayer().selectedFeatures()
for feature in features:
bounding_boxes.append({
'city': feature.attributes()[2],
'max_x': feature.geometry().boundingBox().toRectF().topRight().x(),
'max_y': feature.geometry().boundingBox().toRectF().topRight().y(),
'min_x': feature.geometry().boundingBox().toRectF().bottomLeft().x(),