Skip to content

Instantly share code, notes, and snippets.

View troyscott's full-sized avatar

Troy Scott troyscott

View GitHub Profile
@troyscott
troyscott / index.html
Created December 26, 2021 21:44
Caching JSON Files with Axios
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Get Contacts Demo - Axios</title>
</head>
<body>
<h2>Contacts Caching Demo</h2>
from decimal import Decimal
from bson.decimal128 import Decimal128
import datetime
import time
import config
import json
import requests
from pymongo import MongoClient
from cryptolib import utils
@troyscott
troyscott / vagrantfile_docker
Created November 11, 2018 02:23
Using vagrant with docker provisioning.
Vagrant.configure("2") do |config|
config.vm.hostname = "docker-host"
config.vm.box_check_update = false
config.ssh.insert_key = false
config.vm.box = "puphpet/ubuntu1404-x64"
config.vm.synced_folder "./", "/vagrant", type: "smb"
config.vm.network "forwarded_port", guest: 8081, host: 8081
config.vm.provision "docker",
images: ["alpine"]
@troyscott
troyscott / UpdateWordDoc.bas
Created June 28, 2018 16:31
Write data to word from another Office Program using the Microsoft Word Object Library. Checkout this link https://msdn.microsoft.com/en-us/vba/excel-vba/articles/exporting-a-table-to-a-word-document
Sub ModifyWordDoc()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdbmRange As Word.Range
Application.ScreenUpdating = False
Set wdApp = New Word.Application
@troyscott
troyscott / sma.py
Created March 13, 2018 16:48
Calculate simple moving average using talib and pandas.
import datetime
import time
import config
import json
from pymongo import MongoClient
from cryptolib import utils
# technical analysis libraries
import talib as ta
import pandas as pd
@troyscott
troyscott / binance-candlestick.js
Last active December 21, 2017 06:23
Binance API Example using Node.
const Promise = require('promise');
const binance = require('node-binance-api');
const jsonfile = require('jsonfile');
binance.options({
'APIKEY':'xxxxxx',
'APISECRET':'xxxxx'
});
// Binance Candlestick Promise
@troyscott
troyscott / binance-data.js
Created December 16, 2017 04:10
Binance API Snippet
var tickers = ['BNBBTC', 'BNBLTC'];
// For each ticker
tickers.forEach(function(item, index){
binance.candlesticks(item[index], '1M', function(ticks, symbol) {
console.log(item);
});
});

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@troyscott
troyscott / apply_call.js
Last active August 29, 2015 14:06
JavaScript: apply versus call // source http://jsbin.com/nejufu/4
// apply versus call
// apply passes the array as a set of arguments to the function
function splat(fun) {
console.log('splat');
return function(array) {
console.log("fun.apply");
return fun.apply(null, array);
@troyscott
troyscott / jsbin.diteto.js
Last active August 29, 2015 14:06
Eloquent JS - Functions // source http://jsbin.com/diteto/11
function forEach(array, action) {
for(var i = 0; i < array.length;i++) {
action(array[i]);
}
}
function sum(numbers) {
var total = 0;