Skip to content

Instantly share code, notes, and snippets.

@dburger
dburger / sma
Created February 8, 2021 20:51
Composition of functions to calculate an SMA in Google Sheets.
=AVERAGE(INDEX(GOOGLEFINANCE(A2 , "close" , WORKDAY(TODAY(), -$C$17, holidays) , TODAY()), 0, 2))
@dburger
dburger / finviz.js
Created January 27, 2021 16:08
Google sheets apps script custom finviz function.
/**
* Returns a ticker's numeric data from finviz.com. If the (row, col)
* contains a "-", 0.0 is returned. Note that this is somewhat equivalent
* to the following composition of built in sheet functions:
*
* =VALUE(SUBSTITUTE(SUBSTITUTE(INDEX(IMPORTHTML("http://finviz.com/quote.ashx?t="&A3, "table", 8), 12, 6), "*", ""), "%", ""))
*
* @param {string} ticker - The security's ticker.
* @param {number} row - The row to return data from.
* @param {number} col - The column to return data from.
@dburger
dburger / gist:e0bea3d4135932be13bf80b1ca2f66f4
Created January 27, 2021 15:58
Google Sheets finviz lookup function.
=VALUE(SUBSTITUTE(SUBSTITUTE(INDEX(IMPORTHTML("http://finviz.com/quote.ashx?t="&A3, "table", 8), 12, 6), "*", ""), "%", ""))
#!/usr/bin/env bash
if [[ $# -eq 0 ]]; then
exec google-chrome &
exit 0
elif [[ $1 == "incognito" ]]; then
exec google-chrome --incognito &
exit 0
else
for preffile in ~/.config/google-chrome/{Default*,Profile*}/Preferences; do
@dburger
dburger / .bashrc
Last active December 18, 2015 09:08
bash shell function to add chrome profile name completion to a "gchrome" command.
function _gchrome_profile() {
local IFS=$'\n'
local param=${COMP_WORDS[COMP_CWORD]}
local profiles=""
local preffile
for preffile in ~/.config/google-chrome/{Default,Profile*}/Preferences; do
# The profile name appears to always be the last "name:" in the json
# of the Preferences file. Yes, fragile, but appears to work for now.
local name=$(grep \"name\" "$preffile" | tail -1 | sed -e 's/.*"\([^"]*\)",\?$/\1/')
profiles="$profiles
@dburger
dburger / gchrome
Created June 11, 2013 17:23
Shell script to launch google chrome under a profile with a given name.
#!/usr/bin/env bash
if [ $# -eq 0 ]; then
exec google-chrome &
exit 0
else
for preffile in ~/.config/google-chrome/{Default,Profile*}/Preferences; do
# The profile name appears to always be the last "name:" in the json
# of the Preferences file. Yes, fragile, but appears to work for now.
profname=$(grep \"name\" "$preffile" | tail -1 | sed -e 's/.*"\([^"]*\)",\?$/\1/')
-- Say I have a very large table with a composite primary key with four parts,
-- primary key = (A, B, C, D) where these are all integers. I would like to be
-- able to select blocks of records of 10,000 in ORDER BY (A, B, C, D) primary
-- key order. I can get my first block with the query:
SELECT * FROM BigTable
ORDER BY (A, B, C, D)
LIMIT 10000;
-- Given the last block where the final
UPDATE
Task t INNER JOIN
TaskDescriptor td ON t.TaskDescriptorId = td.Id
SET
t.StartTime = NOW()
WHERE
td.Type = 'nefarious plan' AND
t.Id % 10 = 0;
@dburger
dburger / gist:1008323
Created June 4, 2011 20:28
Javascript Tree Binary Heap
/*
tree implementation of a binary heap, example usage:
// can optionally provide a comparison function, a function for a max
// heap is the default if no comparison function is provided
var bh = binaryHeap();
bh.push(5);
bh.push(34);
bh.push(16);
var max = bh.pop(); // 34
@dburger
dburger / gist:1008320
Created June 4, 2011 20:26
Javascript Array Binary Heap
/*
array implementation of a binary heap, example usage:
// can optionally provide a comparison function, a function for a max
// heap is the default if no comparison function is provided
var bh = binaryHeap();
bh.push(5);
bh.push(34);
bh.push(16);
var max = bh.pop(); // 34