Skip to content

Instantly share code, notes, and snippets.

@ivaravko
ivaravko / rotator.log
Created July 26, 2012 09:25
rotator log
======= banner log started =======
2012-26-Jul 13:24:03 0.03206000 1343294643 || index {{{
2012-26-Jul 13:24:03 0.03211700 1343294643 || create request {{{
2012-26-Jul 13:24:03 0.03216700 1343294643 || Request URI: http://ro.alan.plus1.oemtest.ru/?area=simpleJsBanner&id=6920&version=2&tplVersion=2&encoding=1&pageId=f074fb1534142422708adbb482943e89934f65ec&showCodeInclude=1&customTemplate=1&blockId=main_wapstart_block_71138
2012-26-Jul 13:24:03 0.03235800 1343294643 || create request }}}
2012-26-Jul 13:24:03 0.03240700 1343294643 || front controller request handling {{{
2012-26-Jul 13:24:03 0.03264500 1343294643 || handle request {{{
2012-26-Jul 13:24:03 0.03273800 1343294643 || make controller chain {{{
2012-26-Jul 13:24:03 0.03350400 1343294643 || add filters {{{
2012-26-Jul 13:24:03 0.03435600 1343294643 || add filters }}}
require 'selenium/webdriver'
driver = Selenium::WebDriver.for :firefox
driver.get "http://jqueryui.com/demos/slider/range.html"
amount = driver.find_element(:id => "amount")
left, right = driver.find_elements(:class => "ui-slider-handle")
driver.action.click_and_hold(left).perform
until amount[:value].include? "150"
@ivaravko
ivaravko / posturl.js
Created May 1, 2012 18:24
Post site address using node.js and selenium webdriver
var http = require('http');
var request = http.request({
method: "POST",
host: "localhost",
port: 4444,
path: "/wd/hub/session/1335895401910/url",
headers: {
'content-type': 'application/json',
'charset': 'charset=UTF-8'
@ivaravko
ivaravko / request post node.js
Created April 29, 2012 20:08 — forked from alessioalex/request post node.js
request post node.js
var request = require('request'), default_headers, site_root = 'http://localhost:3000';;
default_headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-us,en;q=0.5',
'Accept-Encoding': 'gzip, deflate',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
// 'Connection': 'keep-alive',
'Cache-Control': 'max-age=0'
@ivaravko
ivaravko / node-httprequest
Created April 29, 2012 19:46 — forked from bdickason/node-httprequest
Simple HTTP Request in NodeJS
getRequest: (callback) ->
options = {
host: config.host or 'yourserver'
port: config.port or 80
path: config.path or '/api/'
method: config.method or 'GET'
tmp = [] # Russ at the NYC NodeJS Meetup said array push is faster
http.request _options, (res) ->
@ivaravko
ivaravko / gist:2415869
Created April 18, 2012 19:14 — forked from cheezy/gist:2415279
Using PageObject with RSpec
# spec_helper.rb
require 'rspec'
require 'watir-webdriver'
require 'page-object'
require 'page-object/page_factory'
require 'require_all'
require_all 'lib/pages'
RSpec.configure do |config|
@ivaravko
ivaravko / abs-fatal.php
Created April 6, 2012 15:05 — forked from rgantt/abs-fatal.php
php 5.4 traits
<?php
/**
* This gives a fatal error
*/
class AbsTest {
abstract public function saySomething( $something );
public function saySomething( $something ) {
echo "{$something}\n";
}
}
$ irb -r selenium-webdriver
>> require 'net-http-spy'
=> true
>> Net::HTTP.http_logger_options = {:verbose => true}
=> {:verbose=>true}
>> driver = Selenium::WebDriver.for :firefox
opening connection to 127.0.0.1...
opened
<- "POST /hub/session HTTP/1.1\r\nAccept: application/json\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 193\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: 127.0.0.1:7056\r\n\r\n"
<- "{\"desiredCapabilities\":{\"browserName\":\"firefox\",\"version\":\"\",\"platform\":\"ANY\",\"javascriptEnabled\":true,\"cssSelectorsEnabled\":true,\"takesScreenshot\":true,\"nativeEvents\":false,\"rotatable\":false}}"
@ivaravko
ivaravko / test_button_css.rb
Created March 8, 2012 20:23
Don`t find button element using :css
require 'selenium-webdriver'
require 'page-object'
browser = Selenium::WebDriver.for :ff
=begin
browser.get "data:text/html;content-type=utf-8,#{URI.escape DATA.read}"
element = browser.find_element(:css => "input[type='submit']")
element.click
ensure

Problem 1: Stacks and Bags

Our goal is to make it so that we have a stack equality operator that is both a stand-in replacement for bag's equality operator and does the right thing when dealing with a stack operation. Liskov suggests that you could define something like Bag#bag_equal?, which Stack must expose and implement to match Bag's behavior, and that you could add a second stack_equal? method for doing ordered comparisons. However, this feels like a kludge to me, and so I tried to take another angle, following a pattern found in Ruby's Numeric class (i.e. its integer? and float? methods):

require "set"

class Bag  
  def ==(other)
    [Set.new(data), limit] == [Set.new(other.send(:data)), other.send(:limit)]