Skip to content

Instantly share code, notes, and snippets.

@sguzman
sguzman / pycurses.py
Created May 9, 2020 19:13 — forked from claymcleod/pycurses.py
Python curses example
import sys,os
import curses
def draw_menu(stdscr):
k = 0
cursor_x = 0
cursor_y = 0
# Clear and refresh the screen for a blank canvas
stdscr.clear()
@sguzman
sguzman / rss.txt
Created May 6, 2020 02:31
Some rss url feeds
https://blog.wolfram.com/feed/
https://writings.stephenwolfram.com/feed/
http://feeds.hbr.org/harvardbusiness/
https://feeds.feedburner.com/visualcapitalist
https://seekingalpha.com/news/tech/feed
https://seekingalpha.com/news/top-news/feed
https://seekingalpha.com/news/us-economy/feed
https://seekingalpha.com/news/m-a/feed
https://seekingalpha.com/news/energy/feed
https://seekingalpha.com/news/healthcare/feed
@sguzman
sguzman / nominal_to_real.math.nb
Created April 25, 2020 19:35
Mathematica expression that converts nominal pricing for some time series (I use stock price) to today's dollars
With[{data = Out[9]},
Map[
With[{modate = DateValue[First@#, {"Year", "Month", "Day"}]},
{First@#,
Quantity[
QuantityMagnitude@
InflationAdjust[
Quantity[QuantityMagnitude@Last@#,
DatedUnit["USDollars", modate]]
, Today], "USDollars"]
@sguzman
sguzman / as.sh
Created May 29, 2019 02:01
Get cidr ipv4 blocks from a given as
whois -h whois.radb.net -- '-i origin <ASN>' | grep 'route:'
@sguzman
sguzman / YouTubeURLFormats.txt
Created May 21, 2019 21:12 — forked from rodrigoborgesdeoliveira/ActiveYouTubeURLFormats.txt
Example of the various YouTube url formats
http://www.youtube.com/watch?v=-wtIMTCHWuI
http://www.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
http://youtu.be/-wtIMTCHWuI
http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare
@sguzman
sguzman / bytes_split.go
Created April 22, 2019 16:28 — forked from xlab/bytes_split.go
Golang split byte slice in chunks sized by limit
func split(buf []byte, lim int) [][]byte {
var chunk []byte
chunks := make([][]byte, 0, len(buf)/lim+1)
for len(buf) >= lim {
chunk, buf = buf[:lim], buf[lim:]
chunks = append(chunks, chunk)
}
if len(buf) > 0 {
chunks = append(chunks, buf[:len(buf)])
}
@sguzman
sguzman / Dockerfile
Created November 4, 2018 20:33
Dockerfile for rustup with building deps first
FROM liuchong/rustup:musl AS base
RUN mkdir app
WORKDIR ./app
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
RUN rustup target add x86_64-unknown-linux-musl
RUN rustup install nightly
RUN cargo install cargo-build-deps --verbose --color always
@sguzman
sguzman / kube.sh
Created November 4, 2018 20:31
Script to run on kubernetes worker node to get to join
#!/bin/sh
apt-get update \
&& apt-get install -qy docker.io
apt-get update && apt-get install -y apt-transport-https \
&& curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
@sguzman
sguzman / Dockerfile
Created November 1, 2018 00:35
A good image for building golang static executables then tranferring executable to alpine
FROM golang as base
RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go get -u "github.com/gin-gonic/gin"
RUN go get -u "github.com/lib/pq"
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s -extldflags -static" -o main .
@sguzman
sguzman / python-async-print.py
Created October 9, 2018 05:34
Be able to print in a multi-threaded env with a simple call to asyncio
async def print_async(*args):
print(*args)
def p(*args):
asyncio.run(print_async(*args))
p('It works')
p('Still works')