Skip to content

Instantly share code, notes, and snippets.

View ptim's full-sized avatar

Tim Osborn ptim

View GitHub Profile
@ptim
ptim / obsidian-web-clipper.js
Created January 29, 2022 14:01 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@ptim
ptim / swr.ts
Created August 26, 2021 04:46 — forked from wilsonpage/swr.ts
An implementation of stale-while-revalidate for Cloudflare Workers
export const CACHE_STALE_AT_HEADER = 'x-edge-cache-stale-at';
export const CACHE_STATUS_HEADER = 'x-edge-cache-status';
export const CACHE_CONTROL_HEADER = 'Cache-Control';
export const CLIENT_CACHE_CONTROL_HEADER = 'x-client-cache-control';
export const ORIGIN_CACHE_CONTROL_HEADER = 'x-edge-origin-cache-control';
enum CacheStatus {
HIT = 'HIT',
MISS = 'MISS',
REVALIDATING = 'REVALIDATING',
@ptim
ptim / .block
Created August 20, 2021 02:06 — forked from jrzief/.block
bar chart races
license: mit
@ptim
ptim / tradingview-extract-pt-results.js
Created February 20, 2021 00:57 — forked from marktellez/tradingview-extract-pt-results.js
Extract your tradingview paper trade journal into a csv file
trs = $($(".paper_trading table.balances")[2]).find(".tv-data-table__tbody tr").map((_, value) => $(value).find("td").map((_, value) => value.innerText))
trades = Object.values(trs.map((_, tr) => [Object.values(tr).slice(0,5)]))
var toTimestamp = val => {
var parts = val.split(' ')
switch(parts[1]) {
case "Minutes":
var d = new Date(new Date().getTime() - (parts[0] * 60 * 60))
break;
case "Hours":
@ptim
ptim / trade.py
Created February 18, 2021 01:35 — forked from slapglif/trade.py
def generate_nonce(length=8):
"""Generate pseudorandom number."""
return ''.join([str(random.randint(0, 9)) for i in range(length)])
def trade(signal,volume,pair):
try:
trade = 'TRADE|OPEN|' + signal + '|' + pair + '|0|0|0|IcarusBot Trade|' + generate_nonce() + '|' + volume
s.send_string(trade, encoding='utf-8')
print("Waiting for metatrader to respond...")
@ptim
ptim / Readmail.py
Created February 18, 2021 01:33 — forked from slapglif/Readmail.py
def readmail(volume):
time.sleep(1.5)
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user, pwd)
m.select('"[Gmail]/All Mail"')
resp, items = m.search(None,
"NOT SEEN FROM tradingview")
items = items[0].split()
for emailid in items:
resp, data = m.fetch(emailid,
@ptim
ptim / notion_task_manager.py
Created August 27, 2020 13:14 — forked from jamalex/notion_task_manager.py
Notion task manager toy example
import datetime
import random
import time
from multiprocessing import Lock
from notion.client import *
from notion.block import *
mutex = Lock()
@ptim
ptim / aust.json
Created April 12, 2020 12:21 — forked from GerardoFurtado/aust.json
Australia map
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ptim
ptim / db-open
Created February 22, 2020 03:41 — forked from helderco/db-open
Script to open a mysql database in Sequel Pro from a service in docker-compose.
#!/bin/bash
set -e
show_help() {
cat << EOF
Usage: ${0##*/} [-u USER] [-p PASS] [-P PORT] [-H HOST] [DATABASE]
${0##*/} -h
Open a standard connection in Sequel PRO.
@ptim
ptim / airbus_data.tsv
Created December 3, 2019 12:54 — forked from atmccann/airbus_data.tsv
Animated path multi-series line chart
date Airbus Boeing
2000-07-31 0 0
2000-08-31 -0.884 9.8912
2000-09-29 9.6685 32.1383
2000-10-31 32.5967 38.9245
2000-11-30 33.1492 41.4853
2000-12-29 30.7182 35.2113
2001-01-31 27.0718 19.8464
2001-02-28 24.3094 27.4264
2001-03-30 16.0773 14.1306