Skip to content

Instantly share code, notes, and snippets.

View funvit's full-sized avatar
:shipit:
Hmm...

Vitaliy F. funvit

:shipit:
Hmm...
  • Russia, Moscow
View GitHub Profile
@funvit
funvit / comparision.py
Created October 29, 2018 18:56 — forked from dmahugh/comparision.py
comparison of asynchronous HTTP requests (aiohttp/asyncio) and traditional sequential requests (with Requests library)
"""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
@funvit
funvit / promise-router.js
Created June 13, 2018 19:18 — forked from joepie91/promise-router.js
Using Express.js with Promises
/* 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(){
@funvit
funvit / Default (OSX).sublime-keymap -- User
Created April 9, 2018 10:04 — forked from coldnebo/Default (OSX).sublime-keymap -- User
Sublime Text 2 fix for OSX home/end keys
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} }
@funvit
funvit / docker-compose.yml
Created February 20, 2018 01:07 — forked from pwaller/docker-compose.yml
selenium hub docker-compose file
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
"""
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 ...
# 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:
import socket
import pickle
import random
import time
import struct
import threading
import urllib2
#from sc_watchdog.logger import log
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration
#!/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
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)