Skip to content

Instantly share code, notes, and snippets.

# Normal person mode
def next_server_number(l):
if len(l) < 1:
return 1
for i in xrange(1, max(l)):
if i not in l:
return i
return max(l) + 1
@waprin
waprin / gist:7aee67aefd7530d3587a
Last active June 21, 2018 15:29
Verify Splunk Regex Matches Against Your Entire Log File
#!/usr/bin/env python
# usage ./verify_splunk_coverage.py <log_file>
# set these from splunk-apps/apps/<service-name>/default/props.conf
BREAK_ONLY_BEFORE_REGEX=r'^\d\d:\d\d:\d\d\s\[[^\]]+\]'
EXTRACT_REGEX=r'^\d?\d:\d\d:\d\d\s\[(?P<thread>[^\]]+)\]\s\[(?P<loglevel>\w+)\]\s\[(?P<class>[^\]]+)\]\s\[(?P<username>[^\]]*)\](?P<message>.*)$'
import re,sys
f = open(sys.argv[1])
@waprin
waprin / cat_literals.py
Created August 6, 2014 18:47
Concatenate Multi-Line Java String Literals
import fileinput
x = ""
for line in fileinput.input():
x += line
s = ""
i = 1
while i < len(x):
if x[i] == '"':
i += 1