Skip to content

Instantly share code, notes, and snippets.

@jsonbecker
jsonbecker / index.html
Created August 8, 2023 00:08
One page at a time, chronological for Tufte
{{ partial "head.html" . }}
<body>
<div class="content list h-feed">
{{ partial "header.html" . }}
{{ $paginator := .Paginate (where .Site.Pages "Type" "post").ByDate.Reverse 1 }}
{{ range $paginator.Pages }}
{{ partial "li.html" . }}
{{ end }}
{{ partial "pagination.html" . }}
{{ partial "footer.html" . }}
@jsonbecker
jsonbecker / adn_download.exs
Created June 3, 2023 16:12
An inefficient way to download your App Dot Net posts using Elixir
Mix.install([{:httpoison, "~> 2.0"}])
defmodule ADNDownloader do
require HTTPoison
@base_url "https://adn.micro.blog/"
def get_posts(user_name) do
url = @base_url <> "users/" <> String.at(user_name, 0) <> "/" <> user_name <> ".txt"
@jsonbecker
jsonbecker / glightbox.html
Last active December 31, 2019 04:19
GLightbox shortcode
<a href="{{ .Get "src" }}"
class="glightbox"
{{ if .Get "gallery"}}
data-gallery="{{ .Get "gallery" }}"
{{ end }}
{{ if or (.Get "title") (.Get "description") }}
data-glightbox="title:{{ .Get "title" | default "" }};description:{{ .Get "description" | default "" }}"
{{end}}
>
<img src="{{ .Get "src" }}"
@jsonbecker
jsonbecker / geom_bar_fill.R
Created December 1, 2016 04:01
How do I get labels on this plot?
library(ggplot2)
df <- data.frame(type = c(rep('Elementary', 2), rep('Middle', 2), rep('High', 2)),
included = rep(c('included','excluded'),3),
dollars = c(1000, 2500, 4000, 1000, 3000, 2800))
ggplot(data = df, aes(type, dollars, fill = included)) +
geom_bar(position = 'fill', stat = 'identity') +
geom_text()

Keybase proof

I hereby claim:

  • I am jsonbecker on github.
  • I am jsonbecker (https://keybase.io/jsonbecker) on keybase.
  • I have a public key ASDIgFzpTFWImOtO0Dw5-XJVu-LiDxUfqB53ZkGSUzla7go

To claim this, I am signing this object:

@jsonbecker
jsonbecker / timing.R
Created September 19, 2016 20:00
A small bit of code to log how long something took
# Ever want to log how long someting takes? I know I do. timing()
# isn't about benchmarking, it's about getting feedback from long running
# tasks, especially if they are scheduled in production. Anyway, I love
# this function because it's a simple wrapper that can go around anything.
# I use it inside our tools at Allovue when extracting data to get things
# like this:
#> accounts <- extract_data(config_file$accounts)
# Starting queries/accounts.sql at: Mon Sep 19 15:27:34 2016
# Completed at: Mon Sep 19 15:28:14 2016
## Current pattern
function(myList){
do_stuff_with(mylist$attribute1, myList$attribute2)
do_stuff_with(mylist$attribute3, myList$attribute4)
}
## Desired pattern
function(myList){
do_stuff_with(attribute1, attribute2)
do_stuff_with(attribute4, attribute4)
@jsonbecker
jsonbecker / gist:10a7210a10292b208d91
Last active August 29, 2015 14:22
providencefirefighters.R
install.packages('rvest')
library(rvest)
library(dplyr)
page <- html('http://app.providencejournal.com/topics/special-reports/tables/firefigher-salaries-fy2014/firefighter-salaries.htm')
data <- page %>%
html_node('table') %>%
html_table() %>%
.[c(-1,-2,-3),] %>%
as.data.frame
@jsonbecker
jsonbecker / cleanURL.py
Created February 19, 2014 15:40
A quick way to clean up an URL, removing common tracking and getting around proxy links to get the proper permanent link.
#!/usr/bin/python
import requests
import sys
from re import search
from subprocess import check_output
url = check_output('pbpaste')
r = requests.get(url)
@jsonbecker
jsonbecker / photoDate.py
Last active January 2, 2016 00:38
A few versions of getting date data from photos.
import sys
import os, shutil, time
import subprocess
import os.path
import exifread
from datetime import datetime
def photoDateSIPS(f):
"Return the date/time on which the given photo was taken."