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 __future__ import print_function | |
from collections import namedtuple | |
agx = namedtuple('art', 'label size') | |
a = agx('gold', 12) | |
b = agx('silver', 4) | |
class MyProxy(object): |
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
#include<QCoreApplication> | |
#include<QNetworkAccessManager> | |
#include<QNetworkReply> | |
#include<QFile> | |
int getFile(char str[], char out[]) | |
{ | |
QUrl url(str); | |
QNetworkAccessManager manager(0); | |
QNetworkReply * reply = manager.get(QNetworkRequest(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
import re | |
import subprocess | |
host = 'google.com' | |
try: | |
output = subprocess.check_output(['ping', '-c', '4', '-q', host]) | |
output = output.decode('utf8') | |
statistic = re.search(r'(\d+\.\d+/){3}\d+\.\d+', output).group(0) | |
avg_time = re.findall(r'\d+\.\d+', statistic)[1] |
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
def get_all(data, key): | |
if type(data) is dict: | |
for jsonkey in data.keys(): | |
if jsonkey == key: | |
return data[jsonkey] | |
#Return the first pair only! | |
break | |
elif type(data[jsonkey]) in (list, dict): | |
if get_all(data[jsonkey], key): | |
return get_all(data[jsonkey], key) |