Skip to content

Instantly share code, notes, and snippets.

View jamesstout's full-sized avatar

James Stout jamesstout

View GitHub Profile
@jamesstout
jamesstout / gist:5990309
Created July 13, 2013 10:47
AppleScript to close all Finder Get Info windows
tell application "Finder"
set theWindowList to windows (* get all Finder windows *)
repeat with i from 1 to number of items in theWindowList (* loop through them *)
set this_item to item i of theWindowList (* get a window from the *)
set windowName to name of this_item (* get the window's name*)
if windowName ends with " Info" then (* see if the window name ends in " Info" - NOTE the space *)
close this_item (* ENHANCEMENT: Would also close a Finder window that had a folder open that ended in " Info" *)
end if
@jamesstout
jamesstout / BTPicks.php
Created July 9, 2013 20:22
Scans http://brettterpstra.com/otherstuff/systematic-linkage/ and attempts to output the "Top Picks" in markdown format producing HTML like this: http://cloud.zoooot.com/Q8Wr
<?php
$curl_error_str = "";
$curl_error_no = 0;
$httpCode = 0;
$curl_info = "";
$page="";
$html="";
@jamesstout
jamesstout / uniqRename.sh
Last active April 9, 2021 18:48
rename files to a random filename with 5 digits that contain random numbers and letters
#!/usr/bin/env bash
# IRC Issue from helperW
# Network: freenode
# Channel: #macosx
# I have a directory with 001.png 023.png 003.png ( around 800 files)
# I have to rename them to a random filename with : 5 digits that contain random numbers and letters
# ensure all vars are initialised and exit on error
@jamesstout
jamesstout / HKOHist.php
Last active December 19, 2015 02:19
Get historical HKO warning and signals data
<?php
include dirname(__FILE__) . '/KLogger.php';
$logDir = dirname(__FILE__) . '/logs';
$file = $logDir . '/HKOLog.txt';
$log = KLogger::instance($logDir, KLogger::DEBUG, false);
include dirname(__FILE__) . '/tz.php';
@jamesstout
jamesstout / HKOHistW.php
Last active February 20, 2016 13:50
Scripts to parse data from the HKO Warnings and Signals Database for all Rainstorm Warnings from 1998 - present
<?php
include dirname(__FILE__) . '/KLogger.php';
header('Content-type: text/html');
outputHeader();
$logDir = dirname(__FILE__) . '/logs';
$file = $logDir . '/HKOLog.txt';
@jamesstout
jamesstout / CocoaStandard.sdef.xml
Created May 28, 2013 07:28
CocoaStandard.sdef (not.xml - just for syntax highlighting) - Cocoa Standard Suite - Common classes and commands for all applications.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary title="Standard Terminology">
<suite name="Standard Suite" code="????" description="Common classes and commands for all applications.">
<command name="open" code="aevtodoc" description="Open a document.">
<direct-parameter description="The file(s) to be opened.">
<type type="file"/>
@jamesstout
jamesstout / availableLocaleIdentifiers.mm
Last active December 17, 2015 18:59
List Lithuanian locales in OS X
NSArray *test = [NSLocale availableLocaleIdentifiers];
for (int i = 0; i < [test count]; i++) {
NSLocale *tmpLocale = [[[NSLocale alloc] initWithLocaleIdentifier:[test objectAtIndex:i]] autorelease];
NSString *localeIdentifier = [tmpLocale objectForKey: NSLocaleIdentifier];
NSString *localeIdentifierDisplayName = [tmpLocale displayNameForKey:NSLocaleIdentifier value:localeIdentifier];
@jamesstout
jamesstout / lastfm-tabs-nofollow.diff
Created May 18, 2013 14:45
Patch to Last.fm-Tabs to add the option to add rel="nofollow"' to links [http://wordpress.org/extend/plugins/lastfm-tabs/]
Index: lastfm_options.php
===================================================================
--- lastfm_options.php (revision 714873)
+++ lastfm_options.php (working copy)
@@ -346,6 +346,15 @@
'type' => 'checkbox',
'section' => 'general'
);
+
+ $this->settings['nofollow'] = array(
@jamesstout
jamesstout / checkDodgyIPs.php
Created April 29, 2013 13:21
Script to look up the location of a list of IP addresses. Uses ipinfodb.com. Writes known IP info to a file to prevent repeat lookups.
<?php
// URL is http://api.ipinfodb.com/v3/ip-city/?key=526979f6d541396cee8be6452c39419e6d7eff9433febf55fe0bb1c27b14bb95&ip=74.125.45.100
/* response should be something like
{
"statusCode" : "OK",
"statusMessage" : "",
"ipAddress" : "180.169.76.237",
@jamesstout
jamesstout / allTZ.sh
Created April 24, 2013 21:05
Get the current time in all the timezones known to your machine
#!/bin/bash
# Error logging
e_error() {
printf "$(tput setaf 1)x %s$(tput sgr0)\n" "$@"
}
# only do this if you know how to set it back
# set date/time to 10:00 AM PDT
# export TZ=PST8PDT