If you’ve ever seen bots on reddit like qkme_transcriber, you may wonder how they’re able to make posts without human intervention. Well wonder no longer! By examining how OKCupid handles HTTP requests, I’ll show you how to first deconstruct the undocumented APIs of other sites, then manipulate them with nary a mouse click.
Category Archives: Python
Approximating Pi in Python, Part 2
In my last post, I discussed a method for approximating π which I later learned was a Monte Carlo method, thanks to some helpful Redditors. Today I’ll talk about technique that uses numerical integration (specifically, the rectangle method) to produce a more accurate result in less time. Continue reading
Approximating Pi in Python, Part 1
Consider a square with an inscribed circle of radius r which itself has an inscribed square rotated 45 degrees.
If we look at just the first quadrant, then the area of the outermost square Aouter is r2. The area of the circle Acircle is πr2/4, and the area of the inner triangle Atriangle is r2/2. Therefore, we can make two equations for π based on the ratios of these areas: π = 4Acircle/Aouter and π = 2Acircle/Atriangle. Notice how neither equation depends on the radius; so, if we can figure out an alternate way to calculate these areas, we can determine the value of π. Python to the rescue!
Continue reading