Skip to content

Instantly share code, notes, and snippets.

@gruber
gruber / Split Tabs to New Window.scpt
Last active May 5, 2024 16:58
An AppleScript for Safari to move all tabs in the frontmost window, from the current tab to the rightmost (last) tab, to a new window.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
(*
Original script: John Gruber (https://daringfireball.net/linked/2023/12/05/an-applescript-for-safari-split-tabs-to-new-window)
Much more elegant version: Leon Cowle (https://github.com/leoncowle)
Even more elegant version: https://stackoverflow.com/questions/54066100/applescript-to-split-safari-tabs-into-new-window/54089865#54089865
Worth a warning: "moving" tabs with this script doesn't actually move them like
drag-and-drop does. The tabs "moved" by this script will reload in the new window,
@caseywatts
caseywatts / bookmarkleting.md
Last active May 5, 2024 10:18
Making Bookmarklets

This is one chapter of my "Chrome Extension Workshops" tutorial, see the rest here: https://gist.github.com/caseywatts/8eec8ff974dee9f3b247

Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book

Making Bookmarklets

I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!

A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.

@gruber
gruber / make_bookmarklet.pl
Last active May 5, 2024 21:11
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
@p120ph37
p120ph37 / gdrive-dropbox-sync.plist
Last active February 20, 2019 11:55
This is the launchd.plist file that keeps my Dropbox and Google Drive folders synchronized.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>local.gdrive-dropbox-sync</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string><string>-c</string>
<string>/usr/local/bin/unison \
-times \
@n8henrie
n8henrie / UpdateiOSApps.applescript
Last active March 7, 2018 17:22
Uses UI Scripting to Update iOS Apps in iTunes
(*
Many thanks to those unknowing contributers that share their Applescript on the web. A few that helped with this script include:
- Most of the UI Scripting came from Yoshimasa Niwa here: https://gist.github.com/4223249
- Code for checking if an app is running came from here: http://codesnippets.joyent.com/posts/show/1124
#### n8henrie Sat Mar 16 14:41:41 MDT 2013
* Added several delays that seemed to be responsible for breaking this script in iTunes 11
#### n8henrie Sun Mar 17 09:57:47 MDT 2013
* Added compatibility with iTunes 10 (untested, please confirm if you can)
#!/bin/sh
# script to change the sleep mode of an OS X machine
usage () {
echo "supported sleep modes:"
echo " sleep"
echo " safesleep"
echo " hibernate"
echo " secure"
echo " insecure"
@henrik
henrik / disable_google_maps_scroll_zoom.user.js
Created July 3, 2011 22:33
Userscript to disable Google Maps scroll zoom in Google Chrome.
// ==UserScript==
// @name Disable Google Maps scroll zoom in Google Chrome
// @namespace http://henrik.nyh.se
// @description Disables Google Maps scroll zoom because it's unusable with Apple's Magic Mouse. Confirmed to work in Google Chrome.
// @include http://maps.google.com/*
// ==/UserScript==
// Adapted from the Safari extension by Mario Tausch/Tiago Rodrigues (https://public.me.com/ix/mariotausch/dev/index.html)
// via http://www.leancrew.com/all-this/2011/05/the-google-maps-scrollzoom-confusion/.
#!/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;