Blog

Swift 4: Convert Unix Timestamp to a nicely formatted Date & Time

I needed to convert a Unix Timestamp, which for some inexplicit reason was being returned as a String by an API I was using and this is the super foolish function I ended up with. I am not going to shame the API Provider for returning a timestamp as a String 😉 func createDateTime(timestamp: String) […]

Swift 4: scale image to width

For an app that I was writing I needed an easy function to scale an image to a specific width, the function below will accomplish this: func scaleImageWidth(sourceImage:UIImage, scaledToWidth: CGFloat) -> UIImage { let oldWidth = sourceImage.size.width let scaleFactor = scaledToWidth / oldWidth let newHeight = sourceImage.size.height * scaleFactor let newWidth = oldWidth * scaleFactor […]

PHP – use a regular expression to extract a URL from XML attribute

I was working on an API response, which provided data in a custom XML markup within the string, which was returned. I wanted to simply extract the “linkTerm”. The snippet I got looked like this: <link linkTarget=”URL” linkTerm=”https://some.provider.com/lib/something/detail.action?docID=5176530″ linkWindow=”_blank”>Online-Zugang</link> Now surely there will be more elegant ways of doing it, but I felt that I […]

pymarc – Python MARC record processing (convert MARCXML to MARC)

This will sound very boring to anyone not involved with Library data, but pymarc totally blew my mind the other day. The library – available from https://pypi.org/project/pymarc/ or via pip install pymarc allows super simple processing of MARC data. My personal need was to quickly and efficiently convert records from MARCXML to MARC21. To do that you obviously […]

python Webscraping

Writing a web scraper with python is easy, if you allow yourself a little help by two beautiful libraries BeautifulSoup Requests import sys, requests from BeautifulSoup import BeautifulSoup # we want UTF8 reload(sys) sys.setdefaultencoding(‘utf8’) #lets define the URLs we will use to scrape url = ‘https://www.somepageortheother.nl/bladeren’ # let’s scrape the first URL and get all […]

Scroll to top