Skip to content

Instantly share code, notes, and snippets.

@dshipp
dshipp / RemoteScheduleJob
Created June 16, 2014 13:20
Remotely executing commands on Windows XP can be achieved through Cygwin and OpenSSH. However, some commands will not work correctly if executed like this, for example running Selenium requires correct access to the Desktop that Cygwin doesn't seem to achieve. This can be worked around by setting up a Windows Schedule Task to execute the command…
# To run the restart-all Windows Scheduled Task from the command line (either cmd or Cygwin):
(windows box)$ schtasks /run /tn restart-all
To run that command remotely from a linux box:
(linux box)$ ssh windows-user@windows-machine "schtasks /run /tn restart-all"
# Ensure that you have setup public key authentication on the windows box, to allow this command to work without password entry
# Jenkins can be scheduled to execute the above command to allow Windows Selenium instances to be restarted between builds (so as not to clash with running builds).
@dshipp
dshipp / PublicKeyAuth.sh
Created June 16, 2014 13:22
Enable public key authentication
(local machine) $ scp ~/.ssh/id_rsa.pub remoteuser@remotemachine:~
(remote machine) $ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
@dshipp
dshipp / SSH run command in screen.sh
Created October 15, 2014 12:50
Create screen session around an SSH executed command
ssh -t username@server screen "command"
@dshipp
dshipp / GetIPAddress.sh
Created October 21, 2014 15:25
Retrieve IP address for hostname. This will also take into account any entries in /etc/hosts
gethostip -d [hostname]
@dshipp
dshipp / ssh_authorise.sh
Created October 21, 2014 16:43
Generates an RSA keypair and installs it in a remote machine's authorized_keys, so you can ssh to that machine without a password prompt
# Generate a new ID without passphrase if one doesn't exist
if [ ! -e ~/.ssh/id_rsa.pub ] ; then
yes | ssh-keygen -f ~/.ssh/id_rsa -N ''
ssh-add
fi
# Copy the id to the target machine (this will prompt you for a password)
ssh-copy-id [email protected]
@dshipp
dshipp / Open-port.sh
Created October 31, 2014 17:44
Lokkit adds an iptables rule to open the specified port
lokkit -p 8090:tcp
@dshipp
dshipp / reboot-required.sh
Created November 3, 2014 17:16
Find out whether a reboot is required (e.g. after an unattended upgrade)
ls /var/run/reboot-required
@dshipp
dshipp / sshuttle.sh
Last active April 12, 2016 14:42
Tunnel all traffic over SSH
sudo pip install sshuttle
sshuttle -r user@host 0/0
@dshipp
dshipp / split_zip.sh
Created April 22, 2016 14:30
Split and compress
split --bytes=1024M --filter='gzip > $FILE.gz' /path/to/input /path/to/output
@dshipp
dshipp / postcode_task.md
Last active December 13, 2016 12:25 — forked from edhiley/postcode_task.md
Please read the instructions fully and ensure you meet all the constraints/instructions listed at the end. You should complete this task as if you were carrying it out in a work environment, i.e. you may perform web searches to help with your solution. However plagiarism is absolutely unacceptable.

Technical Task

Part 1 - Postcode validation

Write code that will validate UK postcodes.

You are given a regular expression that validates postcodes (shown in verbose form below):

    (GIR\s0AA) |

(