Skip to content

Instantly share code, notes, and snippets.

View johngh's full-sized avatar
🏝️
Looking forward to enjoying time on Aotea

John Harrison johngh

🏝️
Looking forward to enjoying time on Aotea
View GitHub Profile
@johngh
johngh / gist:4ac7b348cdc4e4af2b3f2faf8647a100
Created December 31, 2018 19:30
Python print SyntaxError doesn't give reason if the line contains a '('
$ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
# Print a string
>>> print("string")
string
# Try to print a string but forget the parentheses
@johngh
johngh / host_locations.sql
Created July 25, 2014 19:08
SQL query to build single row results from data in multiple rows
--
-- Create table for testing
--
BEGIN TRANSACTION;
CREATE TABLE host_locations(
name VARCHAR(30),
qualifier VARCHAR(30),
value VARCHAR(30)
@johngh
johngh / find_long_running_processes.txt
Last active August 29, 2015 14:01
Find any processes over 8 hours old
On your boxes, does this:
ps -e -o user,pid,ppid,etime,stime,args
work to show the time that the process has been running for (ELAPSED), and when it was started (STIME)?
If so, they will be in the format:
root 10331 1 31-09:25:11 Apr_08 su -c su oracle -c /u03/app/batch/scripts/import_locatn.sh …
@johngh
johngh / .Xresources
Created April 22, 2014 23:32
Configure your xterm colours
!
! For all [xa]term,put this in your
! ~/.Xdefaults or ~/.Xresources:
!
! Defaults for all xterm clients
XTerm*background: black
XTerm*foreground: gray
! XTerm*highlightColor: white
! XTerm*highlightTextColor: black
@johngh
johngh / add_wrapper.ahk
Last active December 15, 2015 00:08
Press <Windows+N> to add JIRA "{noformat}" tags around the selected text, or by themselves if no text is selected.
$#N::
;; insert {noformat} tags
cb_tmp := SelectedViaClipboard()
StringReplace cb_tmp, cb_tmp, `n,, All
if ( cb_tmp ) {
SendInput {{}noformat{}}`n%cb_tmp%{{}noformat{}}`n
}
else
{
@johngh
johngh / transpose-table
Created February 10, 2013 03:28
Transpose an HTML table
#!/usr/bin/perl
#
#
#
use warnings;
use strict;
use HTML::TreeBuilder;
my $tree = HTML::TreeBuilder->new_from_file(shift);
@johngh
johngh / MoveMsgToFolder.ahk
Created January 31, 2013 11:11
AutoHotkey macro to bind Alt-J to Alt-6 to run Outlook macro in message window.
!j::
WinGet, Active_ID, ID, A
WinGet, Active_Process, ProcessName, ahk_id %Active_ID%
if ( Active_Process ="OUTLOOK.EXE" )
{
; Match strings anywhere in the window title
SetTitleMatchMode, 2
numericPrefix = 1
ctrlXPrefix = 0
@johngh
johngh / MoveMsgToFolder.vba
Last active December 12, 2015 00:09
Outlook 2007 macro to move the currently focussed open message to a pre-defined folder. I assigned this macro to a button on the Quick Access Toolbar.
Sub MoveMsgToFolder()
'Outlook VB Macro to move currently open mail item to a target folder
On Error Resume Next
Dim ns As Outlook.NameSpace
Dim moveToFolder As Outlook.MAPIFolder
Dim myItem As Outlook.MailItem
;; Start SSH session using the currently selected text as the target hostname.
$#S::
; Putty copies selected text to the clipboard so you don't need to copy it
; doing Ctrl-Insert throws away what you already have in the Clipboard.
; Can't use Ctrl-C in putty, because it sends that to your session as ^C
WinGet, Active_ID, ID, A
WinGet, Active_Process, ProcessName, ahk_id %Active_ID%
if ( Active_Process ="putty.exe" )
{
@johngh
johngh / Context SSH Links
Created December 27, 2012 22:32
Add ssh:// (and rdp://) URLs after recognised hostnames found in web pages.