Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl
# Description: http://daringfireball.net/2010/08/open_urls_in_safari_tabs
# License: See below.
# http://gist.github.com/507356
use strict;
use warnings;
use URI::Escape;
@gruber
gruber / make_bookmarklet.pl
Last active September 13, 2023 23:22
JavaScript Bookmarklet Builder
#!/usr/bin/env perl
#
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder
use strict;
use warnings;
use URI::Escape qw(uri_escape_utf8);
use open IO => ":utf8", # UTF8 by default
":std"; # Apply to STDIN/STDOUT/STDERR
@gruber
gruber / New Folder or Window.scpt
Last active September 21, 2023 22:37
Finder: Use Cmd-N to Create a New Folder or a New Finder Window
(*
This script is for anyone who still has the classic Mac OS era habit of using
Command-N to create a new folder in the Finder. It's intended for use with
Red Sweater Software's excellent FastScripts utility -- a replacement for the
system's build-in Scripts menu that allows for assigning keyboard shortcuts
to scripts, on a per-application basis.
FastScripts: https://red-sweater.com/fastscripts/
Install the script here: ~/Library/Scripts/Applications/Finder/
@gruber
gruber / JavaScript Blacklist
Last active November 8, 2023 22:46
My list of blocked sites for use with Drew Thaler's JavaScript Blacklist extension for Safari (https://code.google.com/p/jsblacklist/downloads/list)
adclick.g.doubleclick.net, addthis.com, adgardener.com, adnxs.com, ads.pointroll.com, ads.shorttail.net, apture.com, bop.fm, cdn.taboolasyndication.com, chartbeat.com, chartbeat.net, d1.openx.org, doubleclick.net, doubleverify.com, exitjunction.com, fyre.co, getconnected.southwestwi-fi.com, googleadservices.com, gravity.com, grvcdn.com, imrworldwide.com, intellitxt.com, jetpackdigital.com, kontera.com, livefyre.com, luminate.com, meebo.com, moovmanage.com, outbrain.com, parsely.com, po.st, pointroll.com, pubmatic.com, quantserve.com, s.ppjol.net, scorecardresearch.com, serving-sys.com, sharethis.com, snap.com, superclick.com, taboola.com, taboolasyndication.com, tynt.com, wibiya.com, zergnet.com
# Copy the URL or tweet ID for a tweet, and the script will send it to Aaron's Twitter Viewer
set _old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set _tweet_url to get the clipboard
set _tweet_id to last text item of _tweet_url
try
get _tweet_id as integer
on error
@gruber
gruber / gist:647224
Created October 26, 2010 16:26 — forked from dpk/gist:646570
Slight tweaks to dpkendal's script. Gives the BBEdit document a name (rather than "untitled <integer>", and skips the \n to \r stuff, which I don't think is necessary in recent versions of BBEdit.
tell application "Safari"
set _source to do JavaScript "window.document.documentElement.outerHTML" in document 1
set _name to name of document 1
end tell
tell application "BBEdit"
make new text window with properties ¬
{contents:_source, source language:"HTML", name:"Generated source: " & _name}
select insertion point before character 1 of text window 1
#!/usr/bin/perl
# This filter changes all words to Title Caps, and attempts to be clever
# about *un*capitalizing small words like a/an/the in the input.
#
# The list of "small words" which are not capped comes from
# the New York Times Manual of Style, plus 'vs' and 'v'.
#
# 10 May 2008
# Original version by John Gruber:
@gruber
gruber / AppleNewsURLRedirect.pl
Last active March 5, 2024 16:33
Given an Apple News URL, prints the original URL for the story.
#!/usr/bin/perl
# Given an Apple News URL, prints the original URL for the story.
#
# Usage:
# % AppleNewsURLRedirect.pl 'https://apple.news/Ae78KIEmMOHCVXD4VA7ysKw'
# or
# % echo 'https://apple.news/Ae78KIEmMOHCVXD4VA7ysKw' | AppleNewsURLRedirect.pl
#
# Author: John Gruber <https://daringfireball.net/>
@gruber
gruber / Liberal Regex Pattern for All URLs
Last active March 20, 2024 20:28
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:foo@example.com", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))
@gruber
gruber / gist:1063574
Last active April 15, 2024 20:00
Walken in LA: Hot Dogs

By Christopher Walken

Do you enjoy eating hot dogs? I hope you won’t be put off by my frankness when I tell you that I absolutely love them. In fact, I enjoy no food item more than a freshly-boiled hot dog. Now, I’ve done a lot of movies, and it’s true that I’ve worked with quite a few celebrities who did not share this opinion. I’m sorry to say that these people have always angered me.

There are two types of people in this world: those who eat hot dogs whenever it is possible to do so, and those who opt to do other things with their free time. Who do the latter think they are kidding? What pastime could be more rewarding than the consumption of hot dogs? I haven’t yet found one, and I don’t expect to in my lifetime. Unlike other foods, hot dogs can be eaten at any time, in any place, and it is not necessary to cook them. Now, I ask you: Why not eat hot dogs? They are delicious.

I carry a bag of hot dogs with me wherever I go. I eat them from the bag whenever I get the urge, regardless of the circumstances