Skip to content

Instantly share code, notes, and snippets.

View paulsmith's full-sized avatar
😀
Hi, friends

Paul Smith paulsmith

😀
Hi, friends
View GitHub Profile
@paulsmith
paulsmith / Makefile
Last active October 5, 2022 09:26
Simple integer sum function, JIT'ed with the LLVM C API
CC=clang
CXX=clang++
all: sum
sum.o: sum.c
$(CC) -g `llvm-config --cflags` -c $<
sum: sum.o
$(CXX) `llvm-config --cxxflags --ldflags --libs core executionengine jit interpreter analysis native --system-libs` $< -o $@
@paulsmith
paulsmith / webserver
Last active August 29, 2015 14:02
start a file-serving web server in a directory on an OS-assigned port and opens browser to the root
#!/bin/bash
#
# Copyright 2014 Paul Smith
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@paulsmith
paulsmith / README.md
Last active August 29, 2015 13:58
Medicare provider payment data SQL

The Centers for Medicare and Medicaid Services (CMS) today released a 9m row dataset detailing payment data about doctors and other providers who get paid by Medicare. [Read more about the release.][2]

The data, along with a description PDF, is [here][1], and it's roughly 400MB zipped, 1.3GB unzipped, tab-delimited.

I stashed the tab-delimited [data file itself on S3][3], it's public, you can grab it.

It's not a huge file, so you could load it with the schema I made into a local pgsql instance on your laptop, but it's fun to play around with it on AWS Redshift. To load it in Redshift, start up a cluster, connect to it with psql, execute the schema SQL, and run the following commands:

dev=# copy medicare_physician from 's3://paulsmith/medicare/medicare.txt.gz' credentials 'aws_access_key_id=<YOUR ACCESS KEY>;aws_secret_access_key=<YOUR SECRET KEY>' delimiter '\t' gzip ignoreheader 1;
@paulsmith
paulsmith / pizza-dough-recipe.md
Created April 9, 2014 00:30
Pizza dough recipe

Adapted from "Roberta's," by Carlo Mirarchi, Brandon Hoy, Chris Parachini and Katherine Wheelock.

By SAM SIFTON

SUMMARY

This recipe, adapted from Roberta’s, the pizza and hipster haute-cuisine utopia in Bushwick, Brooklyn, provides a delicate, extraordinarily flavorful dough that will last in the refrigerator for up to a week. It rewards close attention to weight rather than volume in the matter of the ingredients, and asks for a mixture of finely ground Italian pizza flour (designated “00” on the bags and available in some supermarkets, many specialty groceries and always online) and regular all-purpose flour. As ever with breads, rise time will depend on the temperature and humidity of your kitchen and refrigerator.

@paulsmith
paulsmith / keybase.md
Created March 7, 2014 01:52
keybase proof

Keybase proof

I hereby claim:

  • I am paulsmith on github.
  • I am paulsmith (https://keybase.io/paulsmith) on keybase.
  • I have a public key whose fingerprint is ADE0 B338 6493 A843 A705 6F90 3632 F0EE 0AF0 D06B

To claim this, I am signing this object:

@paulsmith
paulsmith / pre-commit
Created September 4, 2013 20:26
gofmt git pre-commit hook
#!/bin/bash
if git rev-parse HEAD >/dev/null 2>&1; then
FILES=$(git diff --staged --name-only | grep -e '\.go$')
else
FILES=$(git ls-files -c | grep -e '\.go$')
fi
for file in $FILES; do
if test -n "$(gofmt -l $file)"; then
echo "Error: git pre-commit failed, file needs gofmt: $file"
@paulsmith
paulsmith / uni-ascii-translit.txt
Last active February 15, 2019 19:55
Unicode code points transliterated into ASCII characters (using `iconv(1)`). The code points are the printable (i.e., non-control) characters in the Latin-1 Supplement and Latin Extended-A blocks. The first column is the code point in decimal, then code point in hex, then the Unicode character, finally the ASCII transliterated character(s).
160 U+00a0  
161 U+00a1 ¡ !
162 U+00a2 ¢ c
163 U+00a3 £ lb
165 U+00a5 ¥ yen
166 U+00a6 ¦ |
167 U+00a7 § SS
168 U+00a8 ¨ "
169 U+00a9 © (c)
170 U+00aa ª a
@paulsmith
paulsmith / logproxy.go
Created July 11, 2013 04:05
Logging TCP proxy, with SSL/TLS support
package main
import (
"crypto/tls"
"flag"
"fmt"
"io"
"log"
"net"
"os"
@paulsmith
paulsmith / appendgopkg.vim
Created April 29, 2013 18:00
A simple Vim command to quickly append a package to the list of imports in a Go source code file.
" AppendGoPackage() prompts you for the name of a Go package, searches for
" the import statement at the top of the file, appends the package to the
" list of names, and restores the cursor's location.
function! AppendGoPackage()
call inputsave()
let s:pkg = input("Go package: ")
call inputrestore()
let s:cmd = "normal! ma?^import (\<CR>%O\t\"" . s:pkg . "\"\<ESC>`a"
execute s:cmd
endfunction