Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@philz
philz / reading-list.py
Created February 12, 2024 04:39
# Reads OS X / Safari reading list and dumps out URLs.
#!/usr/bin/env python3
# Reads OS X / Safari reading list and dumps out URLs.
import plistlib
import os
for p in [
y["URLString"]
for y in [
x
for x in plistlib.load(
{
"config": {
"view": {
"continuousWidth": 300,
"continuousHeight": 300
}
},
"layer": [
{
"mark": {

$x^2$

@philz
philz / timeline.json
Created May 18, 2022 02:47
Vegalite Timeline Example
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Timeline",
"title": "Hey there",
"width": 600,
"height": 200,
"data": {
"values": [
{"idx": 0, "start": 0, "name": "Took a minute", "end": 60000},
{"idx": 1, "start": 60000, "name": "Took half a minute", "end": 90000},
// https://adventofcode.com/2021/day/5 in SQL with some algebra.
// I only checked this with the example, not the full data set :)
//
// Run this with `sqlite < aoc2021-day-5-sqlite.sql`.
WITH
RECURSIVE ints(v) AS (
SELECT 0 UNION ALL
SELECT v + 1 FROM ints
WHERE v + 1<= 10
#!/bin/bash
set -x -euo pipefail
git show HEAD^:$1 > $1
git add $1
git commit --fixup HEAD
git revert --no-edit HEAD
git commit --amend -m"$1"
EDITOR=/usr/bin/true git rebase -i --autosquash HEAD^^^
@philz
philz / jq-example.sh
Created August 8, 2019 19:04
Using jq to compute relative timestamps of JSON log files
#!/bin/bash
#
# Given a log file of JSON objects with timestamps, adds a new field called
# "relativeTimeMs" for the duration between successive log lines, and then
# sorts by that field to pull out the "longest" log lines.
echo '{"time":"2019-08-08T17:08:08.343Z","msg":"foo"}
{"time":"2019-08-08T17:08:08.347Z","msg":"bar"}
{"time":"2019-08-08T17:08:08.349Z","msg":"baz"}
{"time":"2019-08-08T17:08:09.322Z","msg":"booooom"}
This file has been truncated, but you can view the full file.
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["timeline", "corechart"]});
google.charts.setOnLoadCallback(drawChart);
function ts_to_hms(secs) {
var s = secs % 60;
var m = Math.floor(secs / 60) % 60;
@philz
philz / impala-branch-image.pdf
Last active January 12, 2018 23:56
branch image
.
@philz
philz / test.md
Last active October 29, 2017 04:22
Hey There
NewLine Bar