Skip to content

Instantly share code, notes, and snippets.

@dshipp
dshipp / restart-all.bat
Last active August 29, 2015 14:01
Kills all command processes (agressive) and restarts the processes for Selenium hub, node and PhantomJS, without killing itself!
title restart-all
call taskkill /F /t /IM cmd.exe /fi "Windowtitle ne restart-all"
call taskkill /F /IM cmd.exe /fi "Windowtitle ne restart-all"
call taskkill /F /IM iexplore.exe
call taskkill /F /IM IEDriverServer.exe
start cmd.exe /k hub.bat
start cmd.exe /k node.bat
start cmd.exe /k phantomjs.bat
@dshipp
dshipp / find-and-delete.sh
Last active August 29, 2015 14:01
Find and delete all files matching a pattern (e.g. *.pyc files) recursing from the current directory
sudo find . -type f -name "*.pyc" -delete
@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 username@target.host
@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 / pylint_environment_vars.src
Created February 14, 2013 10:04
A virtualenv can also be invoked by setting environment variables, rather than the normal activate script
VIRTUAL_ENV=/opt/myenv
PATH=$VIRTUAL_ENV/bin:$PATH