Skip to content

Instantly share code, notes, and snippets.

This is a markdown file with a Python code block:
:::python
#!/usr/bin/env python
print "Hello world!"
@billagee
billagee / gist:46a1ea83b59f13146567cb779dd003b0
Last active August 20, 2016 17:36
VS 2012 example of using SHDocVw.ShellWindows and SHDocVw.IWebBrowser2 in C#
// Using SHDocVw.ShellWindows and SHDocVw.IWebBrowser2 in C#
//
// VS 2012 edition!
//
// To do this you must add a reference to the COM component
// named "Microsoft Internet Controls" (AKA SHDocVw)
using SHDocVw;
// ... snip boilerplate code ...
# Borrowed from
# https://github.com/jfrazelle/dockerfiles/blob/master/kiwi-builder/Makefile
.PHONY: all build run shell clean
repo_name = myrepo/ghostdriver-py27
all: run
build:
@billagee
billagee / screenshot-listener.py
Created January 22, 2015 10:22
Python script that demos how to use EventFiringWebDriver to capture screenshots after test failures
#!/usr/bin/env python
# * Note: phantomjs must be in your PATH
#
# This script:
# - Navigates to www.google.com
# - Intentionally raises an exception by searching for a nonexistent element
# - Leaves behind a screenshot in exception.png
import unittest
@billagee
billagee / test_google_ghost_driver.py
Created April 17, 2013 07:21
Python unittest demo script that uses Selenium WebDriver and GhostDriver to perform a Google search.
#!/usr/bin/env python
import unittest
from selenium import webdriver
class TestGoogleGhostDriver(unittest.TestCase):
def setUp(self):
# The phantomjs executable is assumed to be in your PATH:
self.driver = webdriver.PhantomJS('phantomjs')
@billagee
billagee / print_root_element_name.rb
Created April 14, 2012 11:26
Pure Ruby snippet that prints the name of the root (Desktop) MS UI Automation element using IUIAutomation::GetRootElement and wprintf
# Find me at https://gist.github.com/2383726
#
# This script shows how to use wprintf() and a few functions from the
# MS UI Automation COM interface (IUIAutomation) to print the name
# of the desktop's IUIAutomationElement on a Windows machine.
# For more information see the MS docs on:
#
# IUIAutomation::GetRootElement
# IUIAutomationElement::get_CurrentName
#
@billagee
billagee / gist:2267093
Last active August 20, 2016 17:36
VS 2008 example of using SHDocVw.ShellWindows and SHDocVw.IWebBrowser2 in C#
// Using SHDocVw.ShellWindows and SHDocVw.IWebBrowser2 in C#
//
// VS 2008 edition!
//
// To do this you must add a reference to the COM component
// named "Microsoft Internet Controls" (AKA SHDocVw)
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
foreach (SHDocVw.IWebBrowser2 ie in shellWindows)
@billagee
billagee / netcat_wrapper.pl
Last active October 2, 2015 11:08
Perl snippet showing how to use netcat (nc) to poll a port, waiting for it to open
# Perl snippet showing how to use netcat (nc) to poll a port,
# waiting for it to open
#
# NOTE: You could also increase the value passed to -w to 60
# to do this, but you wouldn't get an up-to-the minute status
# message printed each second...
my $host = '192.168.1.100';
my $port = '443';
my $MAX_ATTEMPTS = 60; # Number of times to repeat the port check