(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| var active = false; | |
| function changeRefer(details) { | |
| if (!active) return; | |
| for (var i = 0; i < details.requestHeaders.length; ++i) { | |
| if (details.requestHeaders[i].name === 'Referer') { | |
| details.requestHeaders[i].value = 'http://www.google.com/'; | |
| break; | |
| } |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| import inspect | |
| # Callable class to wrap functions | |
| class F: | |
| def __init__(self, func, *args): | |
| self.func = func | |
| self.args = args | |
| # Currying |
| import requests | |
| import json | |
| class AbstractDataProvider(): | |
| """A list of methods that data providers should implement or extend.""" | |
| def __init__(self, base_url, username=None, password=None): | |
| self.base_url = base_url.rstrip('/') | |
| self.username = username | |
| self.password = password |
| HTTP/1.1 204 No Content | |
| Server: GitHub.com | |
| Date: Fri, 12 Apr 2013 21:59:21 GMT | |
| Connection: keep-alive | |
| Status: 204 No Content | |
| Access-Control-Allow-Credentials: true | |
| Access-Control-Expose-Headers: Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-OAuth-Scopes, X-Accepted-OAuth-Scopes | |
| Access-Control-Max-Age: 86400 | |
| Access-Control-Allow-Headers: Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With | |
| Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE |
Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.
If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.
The spec has moved to a repo: https://github.com/defunctzombie/package-browser-field-spec to facilitate collaboration.
Locate the section for your github remote in the .git/config file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
| #!/bin/bash -ex | |
| # Paste this into ssh | |
| # curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex | |
| # When forking, you can get the URL from the raw (<>) button. | |
| ### Set some command variables depending on whether we are root or not ### | |
| # This assumes you use a debian derivate, replace with yum, pacman etc. | |
| aptget='sudo apt-get' | |
| chsh='sudo chsh' |
| from scrapy.spider import BaseSpider | |
| from twisted.internet import reactor, defer | |
| from scrapy.http import Request | |
| DELAY = 5 # seconds | |
| class MySpider(BaseSpider): | |
| name = 'wikipedia' |