Skip to content

Instantly share code, notes, and snippets.

@cdzombak
cdzombak / Sample Template
Last active March 15, 2021 17:48
Bear templates for Things projects
# Sample Bear-Things Template
* item a
notes for item A
* item b
* item c
notes for item C
; comments/empty lines begin with `;`
a second line of notes for C
---
#!/usr/bin/env bash
set -u
WHITE='\033[0;37m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
NC='\033[0m'
if [ -e "/Volumes/Chris Dzombak's iPhone 11 co.brushedtype.doppler-ios" ] ; then
@cdzombak
cdzombak / git-google
Last active February 2, 2021 18:15
Shell script adding `git google *` to git subcommands. Put this file, named `git-google`, somewhere in your $PATH, and be sure to make this file executable. Then, type "git google commit," for example, to open a Google search for "git commit tutorial." Hacky AF, but it does generally work.
#!/usr/bin/env bash
set -e
urlencode() {
# from https://gist.github.com/cdown/1163649
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
@cdzombak
cdzombak / CDZTableViewSplitDelegate.h
Created January 4, 2013 17:16
Separate concerns. `UIScrollViewDelegate` deals with a container, while `UITableViewDelegate` deals with content. It's often useful to have two different objects manage these concerns, but Cocoa Touch makes it difficult since `UITableViewDelegate` conforms to `UIScrollViewDelegate` and `UITableView` has only one delegate property. `CDZTableViewS…
#import <Foundation/Foundation.h>
@interface CDZTableViewSplitDelegate : NSObject <UIScrollViewDelegate, UITableViewDelegate>
@property (nonatomic, weak) id<UITableViewDelegate> tvDelegate;
@property (nonatomic, weak) id<UIScrollViewDelegate> svDelegate;
- (id)initWithScrollViewDelegate:(id<UIScrollViewDelegate>)scrollViewDelegate tableViewDelegate:(id<UITableViewDelegate>)tableViewDelegate;
@end
@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)}();
@cdzombak
cdzombak / 10-banner
Last active September 26, 2019 16:31
automatic figlet based banner
#!/bin/sh
figlet -f big "$(hostname --fqdn)" | grep -v "^ *$"

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"
@cdzombak
cdzombak / Drop Action.scpt
Created June 3, 2015 03:13
OmniFocus AppleScript to move an action to my "❌ Dropped" context and mark it completed.
property droppedContext : "Dropped"
tell application "OmniFocus"
tell front document
try
set theDroppedContextID to id of item 1 of (complete droppedContext as context)
set theDroppedContext to first flattened context whose id is theDroppedContextID
on error
display alert "No context found whose name contains “" & droppedContext & "”"
return
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