At Quantego.com we love working with Pandas Dataframes. We use them to store and analyze results from simulation runs. On top of our data matrix and a multi-level index we also need to accommodate custom plotting functions and attributes from the previous simulation run.
pandas.DataFrame for this task was a no-brainer. The new version 0.16.1 (to be released in the next days) includes some fixes to make working with subclasses of complex data-frames (DF) easier. Here an example of what can be done. First define two new classes for
pandas.Series (single col DF) and
pandas.DataFrame . You can define new functions or attributes, as needed.
"My custom dataframe"
_constructor_sliced . They make sure you get the correct class back, when slicing the DF.
self you have convenient access to all Pandas functions and can even roll your own.
I couldn’t find a truly universal regular expression (regex) to match phone numbers, no matter from which country and in which format. They all seemed to be limited in some way. Even named entity extraction APIs require you to set a country to find phone numbers.
In the end I rolled my own regex. It simply looks for a certain amount of numbers and characters generally used to make phone numbers human-readable. If you are looking to match longer or shorter numbers, you can just change the quantifiers. Some examples it will match:
Let me know, if this is useful for you or if you find space for improvement. Currently the biggest issue I see is that the matching ranges between numbers and total chars are unrelated. Due to many filling chars higher values are needed. Those can lead to false negatives. Best test it for yourself.
I like to write my notes and reports in Markdown and then send them out in PDF. Gimli worked OK for a while but rasterizes files and doesn’t work with UTF8-characters. I finally came across a similar project in Python and now I’m very happy with it. You can define a custom style sheet in your .profile and md2pdf will use it.
Ansible is a great automation solution. I mainly use it to provision servers and launch Docker instances on them. Sometimes I need container attributes, like PID or Port to configure Nginx or monitoring tools.
While the Ansible documentation gives you some hints, I didn’t find it 100% obvious on how to solve this. Basically all your newly-created containers will end up in a list called docker_containers. It has the same structure as docker inspect.
I really like the password generator, built into Apple’s keychain and System preferences. Passwords are secure and memorable. Only problem is that accessing it takes many steps. Running it from the command line would be much faster.
Are you already hosting your own mail- or webserver and do you enjoy the flexibility, control and freedom self-hosting gives you? Besides the many advantages like better privacy and the power to customize it gives you personally, you can also offer your services to other people. Even tough there are a large number of budget hosting companies, many customers are willing to pay for better support or the comfort to have you around for questions. Continue reading →
Despite some notions that SSDs or HFS drives don’t need defragmenting, I have often read and experienced myself that defragmenting your Mac every few years will clearly make it faster.
I had some trouble running iDefrag and would like to share a little trick I learnt. Basically it will refuse to run a full defrag, while your system drive is mounted. Restarting didn’t help. Here is what I did in the end: Continue reading →
Many times I get upset with websites, who display accounting data in a table, but don’t offer a way to download it. This includes banks, payment processors, etc. Even if they offer it, there is a chance it’s the wrong format for your purpose. Continue reading →
When you have a large number of blogs to look after, it can be a challenge to keep on top with security updates for plugins and WordPress Core. At the same time the bad guys are getting faster and faster to exploit these kinds of holes. Continue reading →
Forecasts are rather difficult, especially when they’re about the future. Or so the saying goes. While predictiong returns is a pointless exercise, there is some value in keeping an eye on correlations. Continue reading →
I use SSH for pretty much anything from VPN, server administration, database connections or iPython work on remote machines. When working from weird places and with weird internet connections SSH become painfully slow. I already use Mosh, but that also relies on ordinary SSH to initiate the connection.
Last week we discussed Linux Debian’s apt-get update mechanism and how to fully automate essential updates. This week I’d like to demonstrate how to do the same thing for Python. I admit that keeping Python packages up-to-date is probably not half as essential as keeping internet-facing server infrastructure updated. Nonetheless I like to work with the latest versions of packages, as they might fix problems or add features. Continue reading →