Blog

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 […]

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 […]

Python, Diacritics and translate function

Did you know that Dutch uses the following list of special (diacritic) characters? åéíóĂșĂ ĂšĂ«ĂŻĂ¶ĂŒĂĂ‰ĂĂ“ĂšĂ€ĂˆĂ‹ĂĂ–Ăœ While I was working on a python script, I figured I could simply use python’s translate function to “translate” them to their base character. It probably is the worst idea ever, but hey, it is what it is. According to tutorialspoint.com you […]

Scroll to top