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 / 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 / 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
@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)
#!/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 / 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.

Keybase proof

I hereby claim:

  • I am redopop on github.
  • I am redopop (https://keybase.io/redopop) on keybase.
  • I have a public key whose fingerprint is BD5E 80B7 1064 E817 8170 6D51 CF73 4474 7775 9DD1

To claim this, I am signing this object:

@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 / file-actions.applescript
Last active May 10, 2017 19:19
Alfred workflow to show file actions for an open document.
on alfred_script()
-- Replace with path to dir where your nvALT notes are kept as individual files
set nvFolder to "/Users/redoPop/Dropbox/Notes"
set docPath to false
try
tell application "System Events"
set frontApp to (name of first process whose frontmost is true)
end tell
@redoPop
redoPop / gist:9050999cebcd7e50934a
Created September 8, 2014 14:15
IE10 & IE11 don't trigger touch events (e.g., touchstart). If you want to differentiate touches from clicks, you must use the pointer events API and the event object's pointerType property:
function onPointerDownHandler (event) {
if (event.pointerType === 'touch') {
// Equivalent to a touchstart on MS Surface
}
}
// For IE 10
element.addEventListener('MSPointerDown', onPointerDownHandler);
// For IE 11+