Blog
Python Snippet – Get Exception Stack Trace
Every once in a while I just need to get the stack trace of an exception as a string so that I can log the error in a separate system. Here is a quick way to do that:
Every once in a while I just need to get the stack trace of an exception as a string so that I can log the error in a separate system. Here is a quick way to do that:
There have been so many times when I wanted to have a datetime show in UTC. I am not talking about simply looking at the time and acting as if it is in UTC. For example let’s say that I want to express the current time in UTC. This is Read more…
Recently I had to write a custom integration which would sync customers found in QuickBooks with accounts found in Salesforce. We have been using Python to write all of our custom integrations so I have been using python-quickbooks and simple-salesforce. One thing that we noticed when syncing the two datasources Read more…
If you execute the following code, what do you think will be the result? Will an assert error occur? The answer is yes! The reason why is because list1 = list1 + list2 is actually different from list1 += list2 in Python. Let’s see what happened when I ran the Read more…
One of the many cool things about Python is that you can often use builtin functions to either get a value from a dictionary (or an object with getattr) or default to a specified value. Unfortunately lists do not provide such a function. The simplest use case would be to Read more…
Today, I had to figure out a way to parse an HTML string in Python in order to find all of the attribute values of attributes starting with a specific string. Since we already have BeautifulSoup installed, I started researching how to use a lambda function in conjunction with the Read more…
A few days ago I was working on a very primitive version of a CSV reader for a quick JS project and while testing my regex out, I noticed that I was getting an extra match at the end. Here is the JavaScript function that I had: Interestingly, if you Read more…
First of all, i’m sure that the title is a bit confusing, but I couldn’t think of a good way to state in a few words the scope of a solution I was looking for today. Basically, I had a list of dictionaries and I wanted to create a new Read more…
A few days I wrote a post about how to convert an cell address into coordinates (column number, and row number). I am working a quick Python script for work to import CSV data into a DB. In order to allow the user the ability to enter either the column Read more…
Two very simple operations that you may have to deal with if writing a JavaScript that deals with trigonometry are Math.degrees() and Math.radians(). These function can be easily defined as follows: The name of these functions indicates the end result. Using the above definitions, you could run code such as Read more…