Skip to content

Instantly share code, notes, and snippets.

@alishutc
alishutc / login_helper.rb
Created March 15, 2012 12:59
Login in using HTTP basic authentication with Capybara selenium driver
def login(username, password)
page.visit("http://#{username}:#{password}@#{page.driver.rack_server.host}:#{page.driver.rack_server.port}/")
end
@alishutc
alishutc / gist:a6b1b0fc11a28a627897
Last active May 19, 2024 05:48
Play a random embedded youtube video
<!DOCTYPE html>
<html>
<head>
<script>
var videos = ["https://www.youtube.com/embed/9bZkp7q19f0", "https://www.youtube.com/embed/dQw4w9WgXcQ"];
window.onload = function () {
var playerDiv = document.getElementById("random_player");
var player = document.createElement("IFRAME");
var randomVideoUrl = videos[Math.floor(Math.random() * videos.length)];