Skip to content

Instantly share code, notes, and snippets.

Ashley Davis ashleydavis

Block or report user

Report or block ashleydavis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ashleydavis
ashleydavis / parsing log data.md
Last active Nov 6, 2019
An example of parsing log data for later transformation, analysis and visualization with Data-Forge
View parsing log data.md

This markdown was exported from Data-Forge Notebook

Example of parsing log files so you have structured data to use with Data-Forge

First define some test data:

@ashleydavis
ashleydavis / Node.js require hook.js
Last active Sep 22, 2019
This snippet of code sets up a hook to intercept calls to require in Node.js. Put this code at the entry point of your app. It's a great debugging tool for Node.js and it even works under Electron!
View Node.js require hook.js
//
// Original code here.
//
// https://stackoverflow.com/a/41674522/25868
//
const m = require('module');
const originalLoader = m._load;
m._load = function(request, parent, isMain) {
View Example sales data.json
[
{
"ORDERNUMBER": 10107,
"QUANTITYORDERED": 30,
"PRICEEACH": 95.7,
"ORDERLINENUMBER": 2,
"SALES": 2871,
"ORDERDATE": "2/24/2003 0:00",
"STATUS": "Shipped",
"QTR_ID": 1,
@ashleydavis
ashleydavis / prototype.ts
Last active Mar 5, 2019
A prototype multi-core task processing API
View prototype.ts
/*
This a prototype / pseudo-code in TypeScript for a new multi-core task scheduler that I'm planning to open source.
This is based on my earlier private code that I've used to munge masses of stock market data and also talked about in my
book Data Wrangling with JavaScript.
To give me private feedback on this please email me on ashley@codecapers.com.au.
The basic premise of this is that we can split up a complex data processing job into mulitple 'tasks' each of
which can potentially run in parallel on a multi-core machine.
@ashleydavis
ashleydavis / event-source.ts
Created Jan 15, 2019
C# style events in JavaScript
View event-source.ts
// https://stackoverflow.com/a/15964759/25868
export type BasicEventHandler = () => void;
export type SenderEventHandler<SenderT> = (sender: SenderT) => void;
//
// Simulate C# style events in JS.
//
export interface IEventSource<HandlerType extends Function> {
//
@ashleydavis
ashleydavis / server.js
Created Dec 7, 2018 — forked from bencentra/server.js
An HTTPS server for static content (Node.js)
View server.js
/*
This module creates an HTTPS web server and serves static content
from a specified directory on a specified port.
To generate a new cert:
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365
To remove the passphrase requirement:
@ashleydavis
ashleydavis / grademark-first-example.md
Last active Dec 24, 2018
This notebook exported from Data-Forge Notebook is an example trading strategy that demonstrates the grademark API for backtesting financial trading strategies.
View grademark-first-example.md

Grademark mean reversion example

This notebook demonstrate backtesting of very simple mean reversion trading strategy.

It uses the Grademark JavaScript API for backtesting.

For a version of this code runnable on Node.js - please see the Grademark first example repo.

To keep up with what I'm doing checkout my blog or YouTube channel.

@ashleydavis
ashleydavis / example-vega-lite-chart-with-independent-y-axis.json
Created Aug 21, 2017
Example vega-lite chart with independent y axis'
View example-vega-lite-chart-with-independent-y-axis.json
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"layer": [
{
"data": {
"url": "https://vega.github.io/vega-lite/data/seattle-weather.csv"
},
"mark": "line",
"encoding": {
"x": {
@ashleydavis
ashleydavis / example-vega-lite-chart-with-series-that-have-different-scales.vl.json
Last active Mar 22, 2019
An example vega lite chart with two series that have two different scales. This shows a problem that the scales aren't independent.
View example-vega-lite-chart-with-series-that-have-different-scales.vl.json
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"layer": [
{
"data": {
"url": "https://vega.github.io/vega-lite/data/seattle-weather.csv"
},
"mark": "line",
"encoding": {
"x": {
@ashleydavis
ashleydavis / example-vega-lite-chart-with-second-series-on-the-right.vl.json
Created Aug 11, 2017
Example vega-lite chart with two time series and multiple layers - the second Y axis is moved to the right hand side of the chart.
View example-vega-lite-chart-with-second-series-on-the-right.vl.json
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"data": {
"url": "https://vega.github.io/vega-lite/data/seattle-weather.csv"
},
"layer": [
{
"mark": "line",
"encoding": {
"x": {
You can’t perform that action at this time.