This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* npm install jsdom | |
* npm install jquery | |
*/ | |
var html = "<!doctype html><html><body><h1>Hello world!</h1></body></html>"; | |
/* parse the html and create a dom window */ | |
var window = require('jsdom').jsdom(html, null, { | |
// standard options: disable loading other assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var phantom = require('phantom'), | |
vows = require('vows'), | |
assert = require('assert'); | |
// nesting tests inside phantom callback so we only | |
// have to create it once | |
phantom.create(function(ph) { | |
var get_page_result = function(url, fn, result) { | |
ph.createPage(function(page) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>ZombieJS test</title> | |
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script> | |
</head> | |
<body> | |
<a href='#' id='clicker1'>Clicker one</a> | |
<a href='#' id='clicker2'>Clicker two</a> | |
<a href='#' id='clicker3'>Clicker three</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadScript(url, fn) { | |
var script = document.createElement('script'); | |
script.async = true; | |
script.src = '//' + url; | |
var entry = document.getElementsByTagName('script')[0]; | |
entry.parentNode.insertBefore(script, entry); | |
script.onload = script.onreadystatechange = function() { | |
var rdyState = script.readyState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code { background: #f8f8f8; } | |
code .hll { background-color: #ffffcc } | |
code .c { color: #8f5902; font-style: italic } /* Comment */ | |
code .err { color: #a40000; border: 1px solid #ef2929 } /* Error */ | |
code .g { color: #000000 } /* Generic */ | |
code .k { color: #204a87; font-weight: bold } /* Keyword */ | |
code .l { color: #000000 } /* Literal */ | |
code .n { color: #000000 } /* Name */ | |
code .o { color: #ce5c00; font-weight: bold } /* Operator */ | |
code .x { color: #000000 } /* Other */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The database recipe should be included by any server running a DB. It creates | |
# a /data directory and, if on EC2, will mount an EBS volume here | |
directory '/data' do | |
mode '0755' | |
end | |
if node[:app][:ec2] || node[:cloud][:provider] == 'ec2' | |
aws = data_bag_item('aws', 'main') | |
include_recipe 'aws' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.logout').on 'click', (e) -> | |
link = $(e.currentTarget) | |
csrf_token = $('meta[name="csrf-token"]').attr('content') | |
form = $('<form>') | |
form.hide() | |
form.attr('method', 'post').attr('action', link.attr('href')) | |
$("<input type='hidden' name='authenticity_token' value='#{csrf_token}'>").appendTo(form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toggleUserMenu: (e) -> | |
e.preventDefault() if e | |
container = @$('.user') | |
# remove body listener if present | |
$('body').off 'click.menu' | |
$('.menu', container).toggleClass('visible') | |
container.toggleClass('open') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
line = '127.0.0.1 gateway.internal gateway' | |
file = Chef::Util::FileEdit.new('/etc/hosts') | |
file.insert_line_if_no_match(/#{line}/, line) | |
file.write_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var browser = new Browser(); | |
browser.visit('/hello', function() { | |
// do some checks | |
// I'm not sure if browser.resources is an official part of the Zombie API (I found it by searching the src) | |
// so be wary in case it changes | |
browser.resources.post( | |
'/[email protected]&password=' + auth_token, |
OlderNewer