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 asyncio | |
import aiohttp | |
def fetch_page(url, idx): | |
url = 'https://yahoo.com' | |
response = yield from aiohttp.request('GET', url) | |
if response.status == 200: | |
print("data fetched successfully for: %d" % idx) | |
else: |
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
#!/usr/bin/env python | |
""" | |
NOTE: | |
This gist has been moved to EZmomi: | |
https://github.com/snobear/ezmomi | |
Give it a star or fork. Contributions are more than welcome. I'm hoping it will become an easy cli tool for | |
common VMware tasks. |
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 socket | |
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
mysock.connect(('www.py4inf.com', 80)) | |
mysock.send('GET www.py4inf.com/code/romeo.txt HTTP/1.1\n\n'.encode('UTF-8')) | |
while True: | |
data = mysock.recv(4096) | |
print data |
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
""" | |
Previous task | |
""" | |
for host in hosts.view: | |
if re.match(regex, host.name): | |
vim.HostSystem.Shutdown(host, True) | |
print("Shutting down {0}".format(host.name)) | |
""" | |
Connect through ssh |
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
#!/usr/bin/python | |
import objc | |
import ping, socket | |
import time | |
import socket | |
from urllib2 import urlopen, URLError, HTTPError | |
objc.loadBundle('CoreWLAN', bundle_path='/System/Library/Frameworks/CoreWLAN.framework', | |
module_globals=globals()) |
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
from bottle import run, request, Bottle | |
from selenium import webdriver | |
from jinja2 import Environment, FileSystemLoader | |
import re | |
import os | |
app = Bottle() | |
path = os.getcwd() | |
urls = path + '/urls.txt' |
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 multiprocessing | |
import sys | |
import zmq | |
def worker(): | |
context = zmq.Context() | |
socket = context.socket(zmq.SUB) | |
print("Collecting updates from weather server...") | |
socket.connect("tcp://localhost:5556") |
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
# | |
# Weather update server | |
# Binds PUB socket to tcp://*:5556 | |
# Publishes random weather updates | |
# | |
import zmq | |
from random import randrange | |
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
#!/bin/bash | |
# See the original work from William Lam at http://www.virtuallyghetto.com/ | |
## DO NOT EDIT BEYOND HERE ## | |
echo "Accepting EULA ..." | |
/usr/sbin/vpxd_servicecfg eula accept | |
echo "Setting default ports ..." |
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
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) | |
context.verify_mode = ssl.CERT_NONE | |
SI = connect.SmartConnect(host=host, user=user, | |
pwd=password, | |
port=443, | |
sslContext=context) |