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
// Extended DateTime constants and strinify | |
class DateTimeEx | |
{ | |
public static DateTime NextYear { get { return DateTime.Today.AddDays(-DateTime.Today.DayOfYear + 1).AddYears(1); } } | |
public static DateTime NextMonth { get { return DateTime.Today.AddDays(-DateTime.Today.Day + 1).AddMonths(1); } } | |
public static DateTime NextWeek { get { return DateTime.Today.AddDays(7 - (DateTime.Today.DayOfWeek - CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek)); } } | |
public static DateTime Tomorrow { get { return DateTime.Today.AddDays(1); } } | |
public static DateTime Now { get { return DateTime.Now; } } | |
public static DateTime Today { get { return DateTime.Today; } } | |
public static DateTime Yesterday { get { return DateTime.Today.AddDays(-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
# Calculates the levenshtein distance and the edits between two strings | |
def levenshtein(s1, s2, key=hash): | |
rows = costmatrix(s1, s2, key) | |
edits = backtrace(s1, s2, rows, key) | |
return rows[-1][-1], edits | |
# Generate the cost matrix for the two strings | |
# Based on http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#Python | |
def costmatrix(s1, s2, key=hash): |
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
# Calculates the hamming distance and the edits between two strings | |
def hamming(s1, s2, key=hash): | |
assert len(s1) == len(s2) | |
dist = 0 | |
edits = [] | |
for i in xrange(len(s1)): | |
if s1[i] == s2[i]: | |
edits.append({'type':'match', 'i':i, 'j':i}) |
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
(Python 2.7.3 on linux2) Traceback (most recent call last): | |
File "/vagrant/edk2/BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py", line 1828, in Main | |
MyBuild.Launch() | |
File "/vagrant/edk2/BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py", line 1595, in Launch | |
self._MultiThreadBuildPlatform() | |
File "/vagrant/edk2/BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py", line 1402, in _MultiThreadBuildPlatform | |
self.Progress | |
File "/vagrant/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py", line 130, in __new__ | |
if not AutoGenObject._Init(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs): | |
File "/vagrant/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py", line 300, in _Init |
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
OS Name: Microsoft Windows 7 Enterprise | |
OS Version: 6.1.7601 Service Pack 1 Build 7601 | |
java version "1.6.0_65" | |
Java(TM) SE Runtime Environment (build 1.6.0_65-b14) | |
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04, mixed mode) |
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
OS Name: Microsoft Windows 7 Enterprise | |
OS Version: 6.1.7601 Service Pack 1 Build 7601 | |
java version "1.6.0_65" | |
Java(TM) SE Runtime Environment (build 1.6.0_65-b14) | |
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04, mixed mode) |
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
input { | |
udp { | |
port => 5959 | |
type => "Win32-EventLog" | |
format => "json" | |
} | |
} | |
output { | |
stdout { |
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 urllib2 | |
opener = urllib2.build_opener(urllib2.HTTPHandler) | |
request = urllib2.Request('http://<TEAMCITY>/httpAuth/app/rest/agents/id:1/enabled', data='false') | |
request.add_header('Content-Type', 'text/plain') | |
request.get_method = lambda: 'PUT' | |
url = opener.open(request) |
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
string address = "http://<TEAMCITY>/httpAuth/app/rest/agents/id:1/enabled"; | |
byte[] data = Encoding.UTF8.GetBytes("false"); | |
using (var client = new System.Net.WebClient()) | |
{ | |
client.UseDefaultCredentials = true; | |
client.Credentials = new NetworkCredential("<USER>", "<PASSWORD>"); | |
byte[] response = client.UploadData(address, "PUT", 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
// 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) | |
{ |