Skip to content

Instantly share code, notes, and snippets.

View sardisson's full-sized avatar

sardisson

View GitHub Profile
@sardisson
sardisson / GetAPITokensSample.applescript
Last active February 21, 2019 06:29
AppleScript routines for reading and writing NSUserDefaults ("preferences") and for prompting for an API token and storing it in a NSUserDefault.
(*
* AppleScript routines for reading and writing NSUserDefaults ("preferences")
* and for prompting for an API token and storing it in a NSUserDefault.
*)
-- NSUserDefaults domain and key names
property theDomain : "info.johnjohnston.micro-blog-fav-images"
property mbKeyName : "micro-api-token"
property cloudKeyName : "cloud-api-token"
@sardisson
sardisson / Thumbnail image from Micro.blog post.applescript
Last active August 18, 2019 07:41
AppleScript to create a thumbnail from the first image present in a Micro.blog post
(*
* Thumbnail image from Micro.blog post
* Creates a thumbnail from the first image present in a given Micro.blog post
* v1.0.7
* 2019-08-18
* https://gist.github.com/sardisson/e50286e17c8f2f39bfec9429ed5f46cd
*)
on run
-- gruber's get browser routine, with a twist to exclude non-Apple/Google browsers
@sardisson
sardisson / instagram-embed.css
Last active April 14, 2021 11:56
CSS rules to declutter embedded Instagram posts
/*
* instagram-embed.css - v1.0, 3 August 2018
*
* In your favorite user CSS tool or stylesheet, set the following rules to
* apply to
* https://*.instagram.com/*
* (or equivalent; the entire instagram.com domain)
*
* N.B. Your user CSS tool must be able apply CSS rules to <iframe>s, rather
* than only applying them based on the URL in the browser's location bar.
@sardisson
sardisson / functions.php
Last active May 26, 2018 05:10 — forked from clreed87/functions.php
Populate image title, alt-text, caption, and description on upload (only for images uploaded via XML-RPC)
<?php
// Do not include the opening php tag.
// Populate image title, alt-text, caption, and description on upload
// but only if upload is via XML-RPC (thanks Colin Walker)
add_action ('xmlrpc_call', 'check_new_attachment' );
function check_new_attachment( $method ) {
if( 'metaWeblog.newMediaObject' === $method ) {
add_action( 'add_attachment', 'crt_set_image_meta' );
@sardisson
sardisson / linkify-microdotblog-names.php
Last active December 10, 2019 04:54
WordPress filter to auto-linkify @NAMEs for Micro.blog
/* Auto-linkify @names for Micro.blog */
/* Add to your child theme's functions.php or your site's functionality plugin */
/* You should not put this in a stock theme's functions.php because any update */
/* to that theme will overwrite functions.php and this code will have to be */
/* added back again. */
// Props to Chris Reed for his helpful pointers to make this only run on actual posts
function linkify_microdotblog_names( $data ) {
$content = $data['post_content'];
@sardisson
sardisson / iosify-bookmarklet.js
Last active July 8, 2017 20:16
Turns javascript: links (bookmarklets) into links that are bookmarkable in Mobile Safari (which can then be edited back into working bookmarklets)
(function() {
var i, elms = document.getElementsByTagName("a");
var bH = window.location.href.split(location.search||location.hash||/[?#]/)[0];
for (i=0; i<elms.length; i++) {
if (elms[i].href.lastIndexOf("javascript:", 0) === 0) {
elms[i].href = elms[i].href.replace("javascript:", bH+"?bookmarklet#javascript:");
}
}
})();