Skip to content

Instantly share code, notes, and snippets.

@natereed
natereed / AnalogClock.js
Created September 5, 2023 23:07
Analog Clock rendered using SVG in React
import React, { useState, useEffect } from 'react';
import './AnalogClock.css';
function AnalogClock() {
const [time, setTime] = useState(new Date());
useEffect(() => {
const intervalID = setInterval(() => {
setTime(new Date());
}, 1000);
@natereed
natereed / install_minikube.sh
Created July 19, 2019 01:48
Install Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.23.0/minikube-darwin-amd64 \
&& chmod +x minikube && \
sudo mv minikube /usr/local/bin/
@natereed
natereed / gist:21fd438506e1d451bcfcf166d0cbc3fa
Created July 18, 2019 21:21
Deploy a node.js app on kubernetes
kubectl run kubia --image=luksa/kubia --port=8080 --generator=run/v1
import json
import csv
# REPLACE THIS with json input
#input = '{"Parent": "Roy", "Children": [{"Name": "Todd"}, {"Name": "Shirley"}]}'
f = open("my.json", "r")
contents = f.read()
obj = json.loads(contents)
@natereed
natereed / CIKgetter.R
Created January 21, 2016 19:46 — forked from ddd1600/CIKgetter.R
get SEC CIK number from ticker symbol
getCIK = function(ticker) {
stopifnot(is.character(ticker))
uri = "http://www.sec.gov/cgi-bin/browse-edgar"
response = getForm(uri,CIK=ticker,action="getcompany")
html = htmlParse(response)
CIKNode = getNodeSet(html, "//acronym[@title=\"Central Index Key\"][text() = \"CIK\"]")
CIKNodeText = sapply(CIKNode, function(x) xmlValue(getSibling(getSibling(x))))
CIK = sub(" .*","",CIKNodeText)
CIK = sub("^0*","",CIK)
@natereed
natereed / split_filename.py
Created December 17, 2015 01:14
Split a filename into name and extension
import os
basename = os.path.basename(path)
(root, extension) = os.path.splitext(basename)
@natereed
natereed / make_regex.py
Created December 9, 2015 17:02
Make a regex from an input string
import re
text = '''Information to be included in statements filed
pursuant to Rule 13d-1 (b) (c) and (d) and Amendments thereto
filed pursuant to Rule 13d-2 (b).'''
text = text.replace('(', '\(')
text = text.replace(')', '\)')
text = re.sub(r'\s+', '\s+', text)
text = re.sub(r'\.', '\.', text)
@natereed
natereed / inspect-scrapy-response.py
Created November 13, 2015 16:53
Inspect a Scrapy response
from scrapy.shell import inspect_response
inspect_response(response, self)
@natereed
natereed / set_encoding_utf8.py
Created November 5, 2015 21:15
Set system default encoding to UTF-8
reload(sys)
sys.setdefaultencoding('utf8')
@natereed
natereed / set_encoding_utf8.py
Created November 5, 2015 21:14
Set system default encoding to UTF-8
reload(sys)
sys.setdefaultencoding('utf8')