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
| ParseResult(scheme='http', netloc='example.com', path='/over/there', params='', query='field1=value1&field2=value2&field3=value3', fragment='') | |
| [('field1', 'value1'), ('field2', 'value2'), ('field3', 'value3')] |
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 __builtin__ | |
| from StringIO import StringIO | |
| import os | |
| import ConfigParser | |
| import pytest | |
| class MockFileManager(): | |
| def __init__(self): | |
| self.files = {} |
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 mock | |
| import unittest | |
| class TestOpen(unittest.TestCase): | |
| def test_mock_open(self): | |
| m = mock.patch('__builtin__.open', | |
| mock.mock_open(read_data="some text")) | |
| m.start() | |
| with open('somefile.txt', 'rb') as fin: |
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 abc import ABCMeta, abstractmethod | |
| import threading | |
| class ClockInterface(object): | |
| __metaclass__ = ABCMeta | |
| @abstractmethod | |
| def time(self): | |
| pass |
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
| def __flatten(self, args): | |
| result = [] | |
| if isinstance(args, tuple) or isinstance(args, list): | |
| for i in args: | |
| result.extend(self.__flatten(i)) | |
| else: | |
| result.append(args) | |
| return tuple(result) |
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 execnet | |
| import sys | |
| # Boilerplate | |
| def remote_call(gw, method, args, kargs): | |
| module = sys.modules[__name__] | |
| channel = gw.remote_exec(module) | |
| channel.send((method, args, kargs)) |
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
| input { | |
| udp { | |
| port => 5959 | |
| format => 'json' | |
| } | |
| } | |
| output { | |
| stdout { } | |
| elasticsearch { |
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 paramiko | |
| client = paramiko.SSHClient() | |
| client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
| client.connect('HOST', port=22, username='USERNAME', password='PASSWORD') | |
| channel = client.get_transport().open_session() | |
| channel.invoke_shell() | |
| while channel.recv_ready(): |
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
| @-moz-document url-prefix("https://<TEAMCITY_SERVER>/viewLog.html") { | |
| /* Timestamp */ | |
| .log .ts, .log .time, .log .ts_in { | |
| color: #6C6C6C; | |
| } | |
| /* Messages */ | |
| .l0, .l1, .l2, .l3, .l4, .l5, .l6, .l7, .l8, .l9, .l10, .l11, .l12, .l13, .l14, .l15, .l16, .l17, .l18, .l19, .l20, .l21, .l22, .l23, .l24, .l25, .lDeep { | |
| color: white; | |
| } |
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 http://www.codeproject.com/Articles/13821/Adding-Descriptions-to-your-Enumerations | |
| public class EnumUtils<T> | |
| { | |
| public static string GetDescription(T enumValue, string defDesc) | |
| { | |
| FieldInfo fi = enumValue.GetType().GetField(enumValue.ToString()); | |
| if (null != fi) | |
| { |