Skip to content

Instantly share code, notes, and snippets.

@tdl
tdl / gist:3892056
Created October 15, 2012 11:41
Download file with HTTP basic auth, don't check SSL certificates
wget --no-check-certificate --user=xyz --password=abc <URL>
@tdl
tdl / gist:3879068
Created October 12, 2012 12:52
Print all system properties to the console
System.getProperties().list(System.out);
@tdl
tdl / gist:3558107
Created August 31, 2012 19:51
Get your MAC address
ifconfig en0 | grep ether | awk '{print $2}' | sed 's/://g'
@tdl
tdl / gist:3235729
Created August 2, 2012 09:19
Show most frequently used commands
history | cut -c8- | sort | uniq -c | sort -rn | head
@tdl
tdl / gist:3130382
Created July 17, 2012 16:18
Post soap-request XML to a service and save the results
curl -d @<inputfile> <URL> > <outputfile>
@tdl
tdl / gist:3090303
Created July 11, 2012 13:09
Validate an XML file against the HR-XML 2.4 schema
xmllint --noout --schema http://ns.hr-xml.org/2_4/HR-XML-2_4/StandAlone/Resume.xsd <filename>
@tdl
tdl / gist:2953090
Created June 19, 2012 08:53
Get all position titles from an HR-XML Resume file
require 'nokogiri'
doc = Nokogiri::XML(File.read(ARGV[0]))
puts doc.xpath("/xmlns:Resume/xmlns:StructuredXMLResume/xmlns:EmploymentHistory/xmlns:EmployerOrg/xmlns:PositionHistory/xmlns:Title/text()")
@tdl
tdl / gist:2788196
Created May 25, 2012 13:33
Base64-decode a dir of soap XMLs containing the data in <in1></in1> tags
for f in *.xml; do grep "<in1>" $f | cut -d">" -f2- | cut -d"<" -f1 | base64 -d | iconv -f UTF-16LE -t UTF-8 > decoded-$f ; done
@tdl
tdl / gist:1574471
Created January 7, 2012 11:18
Find longest palindrome in a string
# general solution for finding the longest palindrome in a string,
# which runs in O(n) time.
# converted from the Python code here: http://www.akalin.cx/longest-palindrome-linear-time
def find_longest_palindrome(string)
l = [] ; i=0 ; pal_len=0
while i<string.length
if i > pal_len and string[i-pal_len-1] == string[i]
pal_len += 2 ; i += 1
next
end
@tdl
tdl / gist:1221504
Created September 16, 2011 08:06
Remove doubled empty lines -> commandline
grep -v "^$" inputfile