Skip to content

Instantly share code, notes, and snippets.

@markcheno
markcheno / NTP_System_Time.ino
Created February 27, 2023 22:43 — forked from Tech500/NTP_System_Time.ino
Use NTP time to schedule events to run at specific times.
// NTP_System_Time.ino
//schufti --of ESP8266.com Forum provided source for NTP time.
//Developer of code not given
#include <WiFi.h>
#include <WiFiUdp.h>
#include <sys/time.h>
#include <time.h>
@markcheno
markcheno / csv-to-json.js
Created October 27, 2020 13:19 — forked from jssuttles/csv-to-json.js
CSV to JSON Conversion in JavaScript
//var csv is the CSV contents with headers
function csvJSON(csv){
var lines=csv.split('\n');
var result = [];
var headers=lines[0].split(',');
lines.splice(0, 1);
lines.forEach(function(line) {
@markcheno
markcheno / slugify.js
Created December 18, 2019 04:03 — forked from hagemann/slugify.js
Slugify makes a string URI-friendly
function slugify(string) {
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
@markcheno
markcheno / register-jupyter-env
Created April 18, 2019 02:38 — forked from thvitt/register-jupyter-env
Register a jupyter kernel for the current pyenv.
#!/bin/sh
if [ "$PYENV_VERSION" -ne "" ]
then
name=`pyenv version-name`
python=`pyenv which python`
else
name=`basename "$VIRTUAL_ENV"`
python="$VIRTUALENV/bin/python"
fi
import matplotlib.pyplot as plt
from datetime import datetime
import alpaca_trade_api as tradeapi
import numpy as np
from positionhandling import positionHandler
import loader
api = tradeapi.REST()
@markcheno
markcheno / .about+license.md
Created November 18, 2018 16:09 — forked from anilnairxyz/.about+license.md
Candlestick Chart

A zoomable candlestick chart.

Copyright © 2015, Anil Nair - MIT License

@markcheno
markcheno / d3-candlestick-chart.markdown
Created November 18, 2018 04:13
D3 Candlestick Chart

D3 Candlestick Chart

Colors borrowed from bitcoin wisdom, but chart engine is custom and using SVG instead of Canvas.

A Pen by kryo on CodePen.

License.

@markcheno
markcheno / backtest.py
Created October 5, 2018 18:07 — forked from nicoforteza/backtest.py
backtest code
import pandas as pd
import numpy as np
# names for the asset selection
NAMES = ['6M_Momentum', '1Y_Momentum', '6M_LowVol']
# allocation algorithm names (equally weighted)
ALLOCATION = ['EW']
class Backtest:
@markcheno
markcheno / .crostini-setup
Created September 16, 2018 14:57 — forked from tjpalanca/.crostini-setup
Crostini Setup
These scripts set up Crostini on my Pixelbook
@markcheno
markcheno / index.haml
Created September 13, 2018 02:51
React Chips component
%h2#title React Chips!
#react-mount