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
* * | |
* ^ * * | |
_/ \_ | |
<-^*^-> * * | |
/.-.\ * | |
* * /&\ | |
@.*.,@ * * * | |
(`-.*0..\ * | |
/``--.__._) |
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
require 'rubygems' | |
require 'watir' | |
require 'headless' | |
class Watir_Scraper | |
def initialize(url) | |
@headless = Headless.new | |
@headless.start | |
@b = Watir::Browser.new | |
@b.goto(url) |
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
require 'rubygems' | |
require 'mechanize' | |
agent = Mechanize.new | |
agent.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
page = agent.get('https://tradein.asda.com/Catalog/GetMakesForProductType?productTypeID=7') | |
puts page.content |
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
require 'nokogiri' | |
require 'rubygems' | |
doc = Nokogiri::XML(File.open("path-to-file-sitemap.xml")) | |
doc.xpath('//xmlns:loc').each do |item| | |
puts item.text | |
end |
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
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
url = 'http://www.greenmangaming.com/genres/action/' | |
doc = Nokogiri::HTML(open(url)) | |
File.open("scrape.txt", 'w') { |f| | |
doc.xpath('//h2').each do |item| | |
f.write "#{item.text}\n" |
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
require 'open-uri' | |
require 'nokogiri' | |
require 'benchmark' | |
url = 'http://stackoverflow.com/questions/8214299/xpath-or-css-parsing-faster-for-nokogiri-on-html-files' | |
page = Nokogiri::HTML(open(url)) | |
Benchmark.bmbm do |parser| | |
parser.report('Xpath') { 1000.times do page.at_xpath('//div[@id="sidebar"]//a[@class="question-hyperlink"]').text end } |
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
set nocompatible " be improved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" Plugins | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'digitaltoad/vim-jade' |
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
import configureMockStore from 'redux-mock-store'; | |
import thunk from 'redux-thunk'; | |
import nock from 'nock'; | |
import expect from 'expect'; | |
import sinon from 'sinon'; | |
import * as actions from './actions'; | |
import * as types from './constants'; | |
const middlewares = [thunk]; | |
const mockStore = configureMockStore(middlewares); |
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
'use strict' | |
var results = []; | |
function perm(list, memo) { | |
for(var i=0; i < list.length; i++) { | |
var current = list.splice(i,1)[0]; | |
if(list.length === 0) { | |
var permutation = memo.concat(current); |
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 _ = require('underscore'); // es6 can import what we need | |
// will return a function | |
function required(field, value) { | |
return value || 'Value is required'; | |
} | |
function minLen(value) { | |
return value.length >= 6 ? value : 'Value is too short'; | |
} |
OlderNewer