Skip to content

Instantly share code, notes, and snippets.

collected links on rewriting software (or not)

@cdzombak
cdzombak / mastodon-streaming-healthcheck.sh
Created June 11, 2019 17:27
Mastodon health checks, run every minute via cron on a separate server
#!/usr/bin/env bash
set -u
NOW=$(date +"%F %T %Z")
OK=
if curl -s https://a2mi.social/api/v1/streaming/health | grep -c OK > /dev/null ; then
OK="1"
else
OK="0"
# based on sidekiq.chart.sh by codl <codl@codl.fr>
#
# apt install netdata-plugin-chartsd redis-tools
# put this in /usr/libexec/netdata/charts.d
# chown root:netdata /usr/libexec/netdata/charts.d/sidekiq.chart.sh && chmod +x /usr/libexec/netdata/charts.d/sidekiq.chart.sh
sidekiq_update_every=5
sidekiq_priority=9000
sidekiq_check() {
@cdzombak
cdzombak / bookmarklet.js
Last active September 26, 2019 16:32
Bookmarklet which builds a Markdown link to the current page
javascript:!function(){var%20e=window.getSelection().toString(),t=document.title.replace(%22%20-%20Jira%22,%22%22),n=e%3Fe:t,o=%22[%22+n+%22](%22+location.href+%22)%22;(function(e){var%20t=document.createElement(%22textarea%22),n=document.getSelection();t.textContent=e,document.body.appendChild(t),n.removeAllRanges(),t.select(),document.execCommand(%22copy%22),n.removeAllRanges(),document.body.removeChild(t)})(o)}();
it makes sense, and I suspect you’d see something similar on any device with a worn battery (edited)
basically everything battery powered changes clock speeds based on battery voltage level and whether you’re plugged in (_edit:_ also based on workload, so you’re not running at full speed and burning battery power when you’re not doing anything) (edited)
you can’t run a CPU at full speed when the battery voltage is low (edited)
so it follows that when the battery is worn out (and its top voltage is presumably lower), performance is consistently lower
the phone knows about battery age/wear, and takes that into account for the user-facing battery percentage meter
@cdzombak
cdzombak / cdz.dump1090.plist
Created January 29, 2017 22:41
launchd plists for dump1090 and the QEMU Pi emulator. Will require changing to use your OS X username. See: https://www.dzombak.com/blog/2017/01/Monitoring-aircraft-via-ADS-B-on-OS-X.html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
@cdzombak
cdzombak / CDZScalingButton.h
Created January 21, 2017 16:34
A UIButton with a nice scaling effect when the user touches down on it.
//
// CDZScalingButton.h
// ScalingButton
//
// Created by Chris Dzombak on 10/17/15.
// Copyright © 2015 Chris Dzombak. All rights reserved.
//
@import UIKit;
//
// FileURL.swift
// Created by Chris Dzombak on 11/16/16.
//
import Validated
public typealias FileURL = Validated<URL, FileURLValidator>
public struct FileURLValidator: Validator, _FileURL_Validating {

Hello Everyone,

The Swift 3 release is nearing completion, so it is time to look back on the release, learn from what happened, and use it to shape what we (the Swift community) do in the year ahead. Overall, Swift 3 is going to be an absolutely amazing release, and it is impressive how much got done. Thank you to everyone who contributed to making it happen. Instead of diving into a flurry of new proposals immediately, it is important to take stock of where we are, and look at the bigger picture.

Metapoint: this email is ridiculously long and covers multiple topics. Instead of replying to it directly, it is best to start new threads on individual topics that you’d like to discuss. Just tag them with “[Swift 4]” in the subject line.

Swift 3 Retrospective

Every year of Swift’s development has been completely different from the previous one, and I expect Swift 4 to continue this trend. With a goal of learning and improving year over year, here are some observations & retrospective about Swi

protocol ThingDelegate: class {
var fooString: String { get }
func foo()
}
class Controller: ThingDelegate {
let fooString: String
func foo() {
print("foo")
}