Related Posts
Python: How to debug HTTP while using urllib2
… import urllib import urllib2 #this is just to prepare a dynamic uri (this is actual code from a system I’m building, sorry) fileDownloadServiceURL = ‘%s://%s:%s/%s’ % (transport,server,port,pathToController) postData = {‘URI’:fileUri} #add more post stuff here postData = urllib.urlencode(postData) #make sure you encode your post data #add some custom headers if you need them headers={“Host”: […]
How to shuffle a List (or Array) in Javascript
[javascript] /** * Returns number starting from offset up to n-1 */ function getRandomWithOffset(n,offset) { return Math.floor(Math.random()*n+offset); } /** * Returns random integer from 0 to n-1 */ function getRandom(n) { return getRandomWithOffset(n,0); } /** Fisher–Yates shuffle algorithm O(n) */ function shuffleList(list) { for (var i=list.length-1; i>0; i–) { var j = getRandom(i+1); var buffer […]
[CODE] Detecting if a VPN connection is active programmatically (Jan/2017)
This method of programatic detection works as of January 24, 2017 with the latest versions of Express VPN and PIA (Private Internet Access) On Mac OSX/ This works for Mac OSX 10.2.2. The trick is to request your ip routing table and examine through which network interface your default traffic is going through. (To do […]
