Uncategorized
January 18, 2020

Stop onClick events propagating to children

Sometimes in React I may want to build a clickable component like a button but have an SVG or some other more complicated content like some divs. <Button onClick={doSomething()}> <div> <div>Left</div> <div>Right</> </div> </Button> In…
Read More
Uncategorized
May 29, 2019

React & iOS app icons

Photo by Yoann Boyer on Unsplash Safari on iOS allows a web page to be saved to the home screen so that it can be launched like an app. This feature can be accessed for any page in…
Read More
Uncategorized
May 29, 2019

Deploying Next.js on Heroku

Photo by Ankush Minda on Unsplash Ref: https://medium.com/@jacoboakley/deploy-a-next-js-app-on-heroku-69bcb01db1b7 Make sure you add this "start" script to your package.json. "scripts": { "dev": "next", "build": "next build", "start": "next start -p $PORT", "heroku-postbuild": "npm run build", }, Without this "start"…
Read More
Uncategorized
May 23, 2019

Immutable updates to react state

Photo by Lwin Kyaw Myat on Unsplash I spent an hour yesterday trying to figure out why my React component using useState and hooks wasn't updating when it appeared the state was updating. Ultimately the problem was that…
Read More
javascriptreact
May 15, 2019

Custom hook for firebase user management

Photo by Timon Wanner on Unsplash Rather than using Redux or similar to manage global state (e.g. whether the user is authenticated or not), since React 16.8 you can now use hooks and context. Below is a simple…
Read More
javascriptreact
May 15, 2019

Custom hook for data fetching

This post is based on information on customer hooks and data fetching provided by others such as Robin Wieruch (https://www.robinwieruch.de/) and Kent Dodds (https://kentcdodds.com/blog/how-to-optimize-your-context-value). This is a customer hook to fetch energy market data from…
Read More
cssjavascriptreact
May 15, 2019

Adding fonts to Create react app

Photo by Jeroen den Otter on Unsplash If you use create-react-app to create react applications, there are multiple ways you can include custom fonts, such as Google Fonts such as linking to them in Google's CDN. However, the…
Read More
reactUncategorized
April 16, 2019

Next.js and SVG images

To use SVG images inline in Next.js apps install babel-plugin-inline-react-svg add the following .babelrc file to the root of your app { 'presets': , 'plugins': } restart your app import SVG as react component import…
Read More
Data science
March 12, 2019

AI bias – Benedict Evans

Twitter thread from Benedict Evans.  https://twitter.com/benedictevans/status/1098047158593277952 When a machine learning system mistakenly diagnoses an imminent failure in a hydroelectric generator because the manufacturers of the telemetric sensors constituted an unrecognised skew in the training data ...…
Read More
react
March 4, 2019

Dealing with CORS when developing React apps locally

When developing React apps, a common use pattern is to use something like Python and Flask to build a REST API server. However, if you run both the development server and the client server locally,…
Read More
Data sciencePython
October 3, 2018

Filling out dates in Pandas dataframes

Often when working with time-series data, there isn't data for every interval.  For example, consider the following transaction data: You may want to look at a pivot of that data, grouped by Category dfPiv =…
Read More
Data sciencePython
September 30, 2018

Fast processing with Pandas

https://gist.github.com/Skyentific/4f581e23e54486080810724e48773ba3
Read More
Data science
September 14, 2018

Installing fbprophet on Windows 10

Installing Facebook's timeseries library fbprophet on Windows can be troublesome. A solution that works for me, assuming you use Anaconda, is: Update PIP python -m pip install -U pip Install pystan from Anaconda conda install…
Read More
Culture and ethics
August 29, 2018

Leadership and Courage

John McCain, a well respected American politican, wrote an essay about courage in 2004.  It was recently republished by FastCompany, following his death. The essay provides an important counterpoint to the apparent lack of accountability…
Read More
Quotes and sayings
August 12, 2018

Sharing is caring

This video from facebook is from a young Australian woman who lost her life to cancer at the age of 27. When I first saw it I was so touched.  Most of us don't "live" our…
Read More
Data science
August 11, 2018

Jupyter magics

Jupyter notebooks have a series of built-in commands known as magic.  Magics are built into the Jupyter kernel being used (e.g. python) and perform various functions such as the following which tells the kernel to display…
Read More
Data science
August 8, 2018

Share a Jupyter notebook in WordPress

These instructions cover embedding a Github Gist on a self hosted WordPress site, using the oEmbed plugin.  Wordpress sites hosted by Wordpress.com come with this feature already built in. Step 1 Take a Jupyter notebook…
Read More
Data science
April 5, 2018

Simpsons paradox

Data science is an exceedingly widely used term these days, and pretty generally misunderstood by non-practitioners. When working on a data science problem, the data is obviously important as the "fuel" for the problem, but…
Read More
Data sciencePython
March 5, 2018

Date stops

When working with time series data in python, you frequently need to split the data into date ranges such as financial years. For a full list of Pandas breaks see the documentation http://pandas.pydata.org/pandas-docs/stable/timeseries.html#anchored-offsets.  As an example,…
Read More
Data scienceMachine Learning
February 23, 2018

Calculate daily averages across multiple years

When working with time series data, especially data which is seasonal in nature, it is often useful to calculate the average of the same date and/or time across multiple years. For example, in electricity markets…
Read More