Skip to content

Instantly share code, notes, and snippets.

(function () {
const initialTeams = Array.prototype.slice.call(document.querySelectorAll('#schedsubnav li'));
const scores = [];
// gets results based on what is displayed, clicks to change selected team need to happen before this
const getResults = () => {
const res = document.querySelectorAll('table.Table.Table-interactive tbody tr');
const arr = Array.prototype.slice.call(res);
return arr.map(row => {
const score = row.querySelector('td span.yfa-score').textContent;
@TGOlson
TGOlson / scraper.js
Last active August 17, 2019 15:31
yahoo draft value scraper
// setup
// install if you don't have the below packages already
//
// $ npm install node-fetch --save
// $ npm install jsdom --save
// imports
const fs = require('fs');
const fetch = require('node-fetch');
const jsdom = require("jsdom");
(async function() {
// Volume,Symbol,Date Acquired,Date Sold,Proceeds,Cost Basis,Gain,Currency
const csv = [];
const formatDate = dateStr => dateStr.slice(5).replace('-', '/') + '/' + dateStr.slice(0, 4);
const rows = csv.map(row => {
const [volume, symbol, acquired, sold, proceeds, costBasis, gain, currency] = row.split(",");
const description = `${volume} ${symbol}`;
function test() {
var ids = getIds();
var batches = createBatches(ids);
for (var id in batches) {
if (batches.hasOwnProperty(id)) {
var pages = batches[id];
var start = pages[0];
var end = pages[pages.length -1];
/*
* Thread configuration for each thread. Make sure it matches the number above.
* low_power_mode - This mode will double the cache usage, and double the single thread performance. It will
* consume much less power (as less cores are working), but will max out at around 80-85% of
* the maximum performance.
*
* no_prefetch - Some sytems can gain up to extra 5% here, but sometimes it will have no difference or make
* things slower.
*
* affine_to_cpu - This can be either false (no affinity), or the CPU core number. Note that on hyperthreading
hasMatchingBrackets :: String -> Bool
hasMatchingBrackets = fst . foldr reducingFn (True, mempty)
where
reducingFn _ (False, xs) = (False, xs) -- short circuit if already false
reducingFn char (True, tokens) | char `elem` openingTokens = (True, char : tokens)
reducingFn char (True, []) | char `elem` closingTokens = (False, [])
reducingFn char (True, x:xs) | char `elem` closingTokens = if isClosingToken x char then (True, xs) else (False, x:xs)
reducingFn _ st = st
tokenPairs :: [(Char, Char)]
var DCData = { /* ... */ }
var TestData = { /* ... */ }
var PanelCodes = {
"LABS, Inc": {
"CT Panel": "3328",
"WU Panel": "3223"
},
"ViroMed Laboratories": {
"CT Panel": "139467",
okcoin :: Exchange
okcoin = Exchange
{ exchageName = OkCoin
, fetchTicker = fetchOkCoinTicker
}
fetchOkCoinTicker :: IO Ticker
fetchOkCoinTicker = do
r <- Wreq.asJSON =<< Wreq.get tickerUrl
let OkCoinTicker{..} = r ^. responseBody
@TGOlson
TGOlson / NestedHashMap.hs
Last active May 8, 2016 03:54
Nested HashMap implementation.
module NestedHashMap where
import Control.Lens
import Data.Hashable (Hashable)
import Data.HashMap.Strict (HashMap, empty)
type NestedHashMap a b c = HashMap a (HashMap b c)
lookup
:: (Eq a, Hashable a, Eq b, Hashable b, Eq c)
@TGOlson
TGOlson / Typer.hs
Created April 9, 2016 18:22
Simple typing interface with FRP
module ReactionTest
( main
) where
import Control.Event.Handler
import Reactive.Banana
import Reactive.Banana.Frameworks
import System.IO
import System.Console.ANSI