Skip to content

Instantly share code, notes, and snippets.

View redoPop's full-sized avatar
☁️
cheering at clouds

Joe Bartlett redoPop

☁️
cheering at clouds
View GitHub Profile
@redoPop
redoPop / .gitignore
Created June 18, 2010 22:08
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@redoPop
redoPop / README.md
Last active December 20, 2023 19:36
Hazel: "photo taken" custom date attribute

At the time of writing, Hazel's default date attributes all refer to an image file's creation date rather than the date on which the photo was originally taken. The two dates may differ.

This script provides a custom date attribute reflecting the time the photo was actually taken. As written, it's intended to be added as an embedded script in a "Run JavaScript" rule action, so that it's custom attribute can be used in subsequent "Sort into subfolder" patterns.

The date this script exposes is obtained via sips -g creation [filename]. It's not clear to me exactly which EXIF attribute the sips "creation" property comes from, but it seems reasonable to assume it's either DateTimeOriginal or DateTimeDigitized.

@redoPop
redoPop / tzAbbr.js
Last active June 6, 2023 21:22
JavaScript: friendly timezone abbreviations in the client ("EDT", "CST", "GMT", etc.)
/*
Given a date, tzAbbr returns a short, friendly name for the
user's time zone on that date, or an empty string if their
client's Intl support is missing or incomplete.
For example, a user in New York might see:
tzAbbr(new Date()) // => "EST"
Time zones are locale-dependent. Users traveling outside of
@redoPop
redoPop / useClampCheck.ts
Created May 9, 2022 01:01
React hook to test for content clamping.
import * as React from 'react';
type ElRef = React.RefCallback<HTMLElement>;
/**
* Uses content height to determine if an element has been clamped.
*
* Useful for creating "Read more" buttons with CSS line-clamp.
*
* #### Example:
@redoPop
redoPop / stream-file.ts
Last active January 10, 2021 00:04
Simple file streamer for Deno.
function streamFile(path: string) {
let file: Deno.File,
iter: AsyncIterableIterator<Uint8Array>;
return new ReadableStream({
async start() {
file = await Deno.open(path);
iter = Deno.iter(file);
},
@redoPop
redoPop / anki_mobile_card.html
Created February 7, 2015 19:22
HTML used by AnkiMobile to render card templates; a reference for creating advanced Anki card templates with special HTML/CSS. When used by AnkiMobile, the card's HTML replaces the `<!-- (Card contents) -->` comment in this gist, with the shared styles dropped inline inside a `<style>` tag.
<!doctype html>
<html class=" webkit safari mobile iphone js">
<head>
<meta name="viewport" content="width=device-width;">
<style id="ss"></style>
<style>
body {
text-align: center;
font-size: 1em;
-webkit-transform: translate3d(0,0,0);
@redoPop
redoPop / timezones.php
Created August 25, 2009 18:33
CakePHP helper to produce an array of times for various zones.
<?php
class TimezonesHelper extends AppHelper {
function show() {
$zones = array(
'Pacific/Apia' => 'Apia, Upolu, Samoa', // UTC-11:00
'US/Hawaii' => 'Honolulu, Oahu, Hawaii, United States', // UTC-10:00
'US/Alaska' => 'Anchorage, Alaska, United States', // UTC-09:00
'US/Pacific' => 'Los Angeles, California, United States', // UTC-08:00
'US/Mountain' => 'Phoenix, Arizona, United States', // UTC-07:00
#!/bin/sh
say -v cello i am a cat and i\'m small very small oh so small i am a cat and i\'m probably eating pancakes om nom nom nom nom nom nom om nom nom nom nom nom om nom nom nom nom nom nom nom om nom nom nom nom
@redoPop
redoPop / mechanical-friends.md
Last active December 18, 2019 19:36
I get sentimentally attached to technology.

Mechanical friends

I get sentimentally attached to technology. These are some of the mechanical friends I've made over the years:

Name Service Details
2-XL 2004-2016 iPod (Click Wheel Gen 4, 40 GB)
Eddie 2005-2008 PowerBook G4 (12" 1.5 GHz)
K9 2008-2009 MacBook Pro (15" Early 2008)
EVE 2009-2012 MacBook Pro (13" Mid 2009)
@redoPop
redoPop / sublp.sh
Last active October 26, 2017 13:56
Bash script to generate and open Sublime Text Projects.
#!/bin/bash
# Bash script to generate and open Sublime Text Projects
#
# If the current directory is part of a git repo, this script will
# look for a .sublime-project file in that repo root and open it.
# If no such file exists, it'll generate one based on the dir name.
#
# If the current directory is _not_ a git repo, no .sublime-project
# will be generated and if none is found in the current directory then