Skip to content

Instantly share code, notes, and snippets.

@wehappyfew
wehappyfew / setup_selenium.sh
Created April 12, 2016 12:46 — forked from curtismcmullan/setup_selenium.sh
Setup Selenium Server on Ubuntu 14.04
#!/bin/bash
# Following the guide found at this page
# http://programmingarehard.com/2014/03/17/behat-and-selenium-in-vagrant.html
echo "\r\nUpdating system ...\r\n"
sudo apt-get update
# Create folder to place selenium in
docker_env = os.environ.get('DOCKER_ENV') # grab the docker env that the tests will run in docker [local]
stg_env = os.environ.get('STG_ENV')
root_vagrant_local = "http://localhost:9180/"
# Notice: Docker
# Whatever LIVE is, if the env is docker + local run to vagrant URL
if environment == "docker" and docker_env == "local" :
root = root_vagrant_local
# Run Docker Grid on deadpool
environment:
# only one of the two must be active
# - DOCKER_ENV=local # will hit vagrant box at http://localhost:9180/
- STG_ENV=deadpool # [deadpool, ironman etc]
docker-machine create \
--driver amazonec2 \
--amazonec2-access-key blablabla
--amazonec2-secret-key blublublu \
--amazonec2-vpc-id vpc-theid \
--amazonec2-zone d \
--amazonec2-subnet-id subnet-theid \
--amazonec2-instance-type m3.medium \
awsgrid
elif environment == "docker":
# Docker Hub setup: hub_ip="http://172.17.0.3", hub_port=4444
def setUp(self, hub_ip="http://172.17.0.3", hub_port=4444):
print "--Fixtures_docker in config.py trying to run on--: %s:%s"%(hub_ip, hub_port)
if platform.system() == 'Linux':
from pyvirtualdisplay import Display
self.display = Display(visible=0, size=(1024, 768))
self.display.start()
@wehappyfew
wehappyfew / install_scout_realtime.sh
Created March 24, 2016 12:44
Script to install Scout Realtime server monitoring tool
sudo apt-add-repository ppa:brightbox/ruby-ng && \
sudo apt-get update -y && \
sudo apt-get -y install ruby2.0 ruby-switch && \
sudo ruby-switch --set ruby2.0 && \
sudo apt-get install gem -y && \
sudo install libgemplugin-ruby&& \
sudo gem install json scout_realtime
@wehappyfew
wehappyfew / kill_stuck_firefox.sh
Created March 24, 2016 10:10
Bash script to kill any firefox instance that runs for more than 10 minutes [runs every 1 minute]
# Notice: to run it, create a cronjob with the line below
# */1 * * * * root sh /path/to/file/kill_stuck_firefox.sh
#!/bin/bash
# This script will kill process which running more than 10 minutes
# egrep: the selected process; grep: hours
PIDS="`ps eaxo etime,pid,comm | egrep "firefox" | grep " [1-5][0-9]:" | awk '{print $2}'`"
# Kill the process
echo "Killing firefox processes running more than 10 minutes..."
@wehappyfew
wehappyfew / docker_names_to_ips.sh
Created March 23, 2016 15:49
Print the name and the IP of every docker container
IDS=$(docker ps -q)
for ID in $IDS
do
echo $(docker inspect --format='{{.Name}}' $ID) " --> "$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ID)
done
@wehappyfew
wehappyfew / start-stop-virtuabox-vm.py
Last active February 10, 2016 10:37
Start and stop a Virtualbox VM from Python
# start the vm
subprocess.call(["C:\Program Files\Oracle\VirtualBox\VBoxManage.exe", "startvm", "Win7-IE8"])
time.sleep(50)
# stop a vm
# -set inside the VM from the 'control panel->power options' the os to shutdown when the power button is pressed-
subprocess.call(["C:\Program Files\Oracle\VirtualBox\VBoxManage.exe",
"controlvm",
"WIN7IE8",
"acpipowerbutton"])
@wehappyfew
wehappyfew / RemoteDriverExample.py
Last active February 10, 2016 08:04
Fixture class example to run python tests on a Selenium Grid
class Fixtures_docker(unittest.TestCase):
def setUp(self, hub_ip="http://HUB_TP", hub_port=4444):
print "--Fixtures_docker in config.py trying to run on--: %s:%s"%(hub_ip, hub_port)
if platform.system() == 'Linux':
from pyvirtualdisplay import Display
self.display = Display(visible=0, size=(1024, 768))
self.display.start()