PHP in Everyday Life (Counting)

It's amazing how code can be used to solve everyday problems that could take a long time or forever. Recently, my wife, who is a teacher, needed to make tiles with letters for her students to compose their names. Normally, she would have to write out the names on paper and count exactly how many of each letter she would need. But with the following simple piece of PHP code, I was able to achieve the same: $names = str_split('listofnameswithoutanyspaces'); print_r(array_count_values($names)); Sometimes you just have to stay on the lookout to see where…Read more

Send POST Data as JSON with Python Requests

I began using Flask and the AWS API Gateway at work for a public website we are building. I didn't need to do any parameter mapping on the AWS side, so I went straight to work. It turns out that Python Requests doesn't send POST data as JSON by default and this had my head spinning as I was trying to figure out why the response was throwing an error. This is the usual way of doing a POST request with Python Requests (notice the "data" variable): r = requests.post(url, data={"key": "value"}) But…Read more