Skip to content

Instantly share code, notes, and snippets.

View kylebarron's full-sized avatar

Kyle Barron kylebarron

View GitHub Profile
@kylebarron
kylebarron / pydantic.py
Created October 4, 2021 17:30 — forked from danielhfrank/pydantic.py
Pydantic with Numpy
from typing import Generic, TypeVar
import numpy as np
from pydantic.fields import ModelField
JSON_ENCODERS = {
np.ndarray: lambda arr: arr.tolist()
}
DType = TypeVar('DType')
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylebarron
kylebarron / scrape-sitemap.sh
Created April 1, 2019 23:15 — forked from pix0r/scrape-sitemap.sh
Use wget to scrape all URLs from a sitemap.xml Usage: scrape-sitemap.sh http://domain.com/sitemap.xml
#!/bin/sh
SITEMAP=$1
if [ "$SITEMAP" = "" ]; then
echo "Usage: $0 http://domain.com/sitemap.xml"
exit 1
fi
XML=`wget -O - --quiet $SITEMAP`
@kylebarron
kylebarron / TrueColour.md
Created October 19, 2018 16:29 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Colours in terminal

It's a common confusion about terminal colours... Actually we have this:

  • plain ascii
  • ansi escape codes (16 colour codes with bold/italic and background)
  • 256 colour palette (216 colours + 16 ansi + 24 gray) (colors are 24bit)
  • 24bit true colour ("888" colours (aka 16 milion))
printf "\x1b[${bg};2;${red};${green};${blue}m\n"
@kylebarron
kylebarron / tmux-cheatsheet.markdown
Last active August 13, 2018 15:36 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

Printable version. Just delete this line and use pandoc tmux-cheatsheet.markdown -o tmux.pdf -V geometry="margin=1in"

tmux shortcuts & cheatsheet

kill session:

tmux kill-session -t myname

Sessions

@kylebarron
kylebarron / deleteStataComments.py
Created August 7, 2018 16:56 — forked from mcaceresb/deleteStataComments.py
Delete all comments from a Stata do file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# TODO: Comment code; include regexp? explanations
# TODO: parse with delimit in separate file; note this is imperfect. It
# has to be because of the way it works, which is super messy (specially
# for multi-line strings; i.e. stuff in quotes spanning many lines).
# TODO: scan code for `/*/`, `*/*`, and similar constructs. 'Please open
@kylebarron
kylebarron / pandoc-svg.py
Last active June 6, 2018 18:00 — forked from jeromerobert/pandoc-svg.py
Pandoc filter to create PDF files from SVG
#! /usr/bin/env python
"""
Pandoc filter to convert svg files to pdf as suggested at:
https://github.com/jgm/pandoc/issues/265#issuecomment-27317316
rsvg-convert or inkscape must be installed
"""
__author__ = "Jerome Robert"
@kylebarron
kylebarron / statab
Last active June 28, 2018 19:28 — forked from pschumm/statab
Wrapper for "stata -b" which issues an informative error msg and appropriate (i.e., non-zero) return code
#! /usr/bin/env bash
# Wrapper for "stata -b" which issues an informative error msg and appropriate
# (i.e., non-zero) return code
# The basic idea for this script (including grepping the log file to determine
# whether there was an error) was taken from a similar script posted by Brendan
# Halpin on his blog at http://teaching.sociology.ul.ie/bhalpin/wordpress/?p=122
# This script was forked from https://gist.github.com/pschumm/b967dfc7f723507ac4be