Skip to content

Instantly share code, notes, and snippets.

View JMichaelTX's full-sized avatar

JMichaelTX JMichaelTX

View GitHub Profile
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active May 5, 2024 13:30
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@santisbon
santisbon / Search my gists.md
Last active April 26, 2024 18:39
How to #search gists

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@umireon
umireon / jxa-timeout.js
Created November 30, 2016 17:52
setTimeout, setInterval, clearTimeout, and clearInterval on JXA (JavaScript for Automation) on macOS
if (typeof exports === 'undefined') exports = {}
function timer (repeats, func, delay) {
var args = Array.prototype.slice.call(arguments, 2, -1)
args.unshift(this)
var boundFunc = func.bind.apply(func, args)
var operation = $.NSBlockOperation.blockOperationWithBlock(boundFunc)
var timer = $.NSTimer.timerWithTimeIntervalTargetSelectorUserInfoRepeats(
delay / 1000, operation, 'main', null, repeats
)
@RobTrew
RobTrew / KMVars.js
Last active March 9, 2024 04:37
Example: accessing Keyboard Maestro variables from Yosemite JXA Javascript for Applications
function run() {
// KEYBOARD MAESTRO VARIABLES IN YOSEMITE JXA JAVASCRIPT FOR APPLICATIONS
// FINDING, CREATING, READING, UPDATING
// SIMPLE EXAMPLE - TOGGLING A BOOLEAN KM VARIABLE FROM .js
var strKMVarName = "flag";
-- This script includes examples for using AppleScript to perform several
-- useful tasks with Evernote.
-- Each section illustrates a chunk of Evernote's AppleScript interface,
-- and each section also cleans up after itself.
-- Please refer to the Evernote application's scripting dictionary for
@ccstone
ccstone / References For Learning & Using Applescript.md
Last active February 21, 2024 05:34
References For Learning & Using Applescript

REFERENCES FOR LEARNING & USING APPLESCRIPT Modified: 2018/06/19 18:47


NOTES

AppleScript is a rather peculiar scripting language to learn.

@RobTrew
RobTrew / JXA_PersistentProperties.js
Last active January 30, 2024 09:07
Persistent 'properties' for OS X JavaScript for Applications (JXA)
(function () {
'use strict';
// OSX JavaScript for Applications lacks the persistent 'properties'
// of AppleScript (in which global variables and properties persist between script runs)
// but we can, of course, serialise to JSON or plist at the end of a script
// parsing it at the start of the next run.
// Here is one approach to persistence between script runs
// using JSON.stringify() and JSON.parse()
@cmackay
cmackay / gist:5863257
Last active January 29, 2024 17:16
AppleScript to save and restore window position and sizes.
-- allSettings is a list of records containing {width:? height:? apps:{{name:? pos:? size:?},...}
-- for each display setup store the apps and their associated position and size
property allSettings : {}
-- create a variable for the current settings
set currentSettings to {}
display dialog "Restore or save window settings?" buttons {"Restore", "Save"} default button "Restore"
set dialogResult to result
@RobTrew
RobTrew / safariXPathGoogleResultLinks.js
Created May 30, 2015 02:24
Harvest Google result links from Safari with XPATH (as MD) with //*[@Class='r']/a
@RobTrew
RobTrew / DraftsFunctions_ScriptEditor.js
Last active April 12, 2023 07:26
OS X 10.10 (Yosemite) definitions of the basic script editing functions used in iOS Drafts 4
// Ver 0.4 Rob Trew
// Library for using OSX Yosemite Script Editor scripts
// written in an idiom compatible with FoldingText, Drafts, 1Writer, TextWell
// In iOS Drafts 4 scripts, the header is simply:
// var drafts = this;
// For headers for FoldingText and other editors, see:
// See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7
// Call functions, after this header, with the prefix:
// drafts.