This file contains hidden or 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
| """Comparison of fetching web pages sequentially vs. asynchronously | |
| Requirements: Python 3.5+, Requests, aiohttp, cchardet | |
| For a walkthrough see this blog post: | |
| http://mahugh.com/2017/05/23/http-requests-asyncio-aiohttp-vs-requests/ | |
| """ | |
| import asyncio | |
| from timeit import default_timer |
This file contains hidden or 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
| /* Without using express-promise-router... | |
| * If either of the two Promise-returning methods ends up failing (ie. rejecting), | |
| * an uncaught exception will be printed to stdout, and the client will never get | |
| * a response - instead, they'll be stuck on an infinitely loading page. | |
| */ | |
| express = require("express").router(); | |
| router.get("/", function(req, res) { | |
| Promise.try(function(){ |
This file contains hidden or 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
| { "keys": ["home"], "command": "move_to", "args": {"to": "bol"} }, | |
| { "keys": ["end"], "command": "move_to", "args": {"to": "eol"} } |
This file contains hidden or 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
| hub: | |
| image: selenium/hub | |
| ports: | |
| - "127.0.0.1:4444:4444" | |
| chrome: | |
| image: selenium/node-chrome-debug | |
| links: [hub] | |
| external_links: | |
| - myapplication_frontend_1:pdftables |
This file contains hidden or 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
| """ | |
| A TestRunner for use with the Python unit testing framework. It | |
| generates a tabular report to show the result at a glance. | |
| The simplest way to use this is to invoke its main method. E.g. | |
| import unittest | |
| import TestRunner | |
| ... define your tests ... |
This file contains hidden or 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
| # python -m SimpleHTTPPutServer 8080 | |
| import SimpleHTTPServer | |
| import BaseHTTPServer | |
| class SputHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
| def do_PUT(self): | |
| print self.headers | |
| length = int(self.headers["Content-Length"]) | |
| path = self.translate_path(self.path) | |
| with open(path, "wb") as dst: |
This file contains hidden or 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 socket | |
| import pickle | |
| import random | |
| import time | |
| import struct | |
| import threading | |
| import urllib2 | |
| #from sc_watchdog.logger import log |
This file contains hidden or 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
| package httpclient | |
| import ( | |
| "net" | |
| "net/http" | |
| "time" | |
| ) | |
| type Config struct { | |
| ConnectTimeout time.Duration |
This file contains hidden or 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
| #!/usr/bin/python | |
| # Connects to servers vulnerable to CVE-2014-0160 and looks for cookies, specifically user sessions. | |
| # Michael Davis (mike.philip.davis@gmail.com) | |
| # Based almost entirely on the quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org) | |
| # The author disclaims copyright to this source code. | |
| import select |
This file contains hidden or 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
| from django.db.models.query import EmptyQuerySet | |
| class FakeQuerySet(EmptyQuerySet): | |
| """Turn a list into a Django QuerySet... kind of.""" | |
| def __init__(self, model=None, query=None, using=None, items=[]): | |
| super(FakeQuerySet, self).__init__(model, query, using) | |
| self._result_cache = items | |
| def count(self): | |
| return len(self) |
NewerOlder