Random ramblings about Mac, Python, TeX, programming, and more  |     |          |     |  


Using PlistBuddy when I want to open Emacs from a link in an HTML file on OS X

December 14, 2017  |  os-x, web, programming

Previously, I have discussed How to open Emacs from a link in an HTML file on Mac OS X. This post is just to give a complete overview of how this can be done without to many manual tasks. My complete AppleScript program and its Makefile is available for download. It should only be used with your own modification.  It includes the usage of cvs to commit the changes in the bib files to my local cvs- …

Last updated: December 14, 2017

Run all Airmail rules

October 26, 2017  |  tools, os-x, programming

I currently use Airmail as my Mac (and iOS) mail client. With many email accounts I found that Airmail fits my needs OK. And I have created a large number of rules that is automatically performed on new emails in my inbox. However, for different reasons I would sometimes like to perform all my rules manually. As far as I know this is not possible in the Mac version of Airmail. So I had to implemen …

Last updated: October 26, 2017

Open Emacs from a link in an HTML file on Mac OS X

December 14, 2015  |  os-x, web, programming

Since I do most of my writing in LaTeX, I have all my references (publications I cite when I write papers) in a series of bib-files (for BibTeX). To easier browse and search these references I have created a small Python script that generates a HTML document with all these references. Each reference also includes a link to the bib-file this reference was found in. In the link I include the key of …

Last updated: December 14, 2015

Non breakable spaces in Word

September 22, 2015  |  publ

I prefer TeX and friends (LaTeX, MetaPost, BibTeX) when writing papers. But sometimes I have to use Microsoft Word. One annoyance I have observed in many documents written in Word is line breaks (word wrapping) on wrong places. Not all spaces are a correct place to break lines in a text. In TeX I would write the tilde (~) character instead of a space, and in HTML I would use the character entity   …

Last updated: September 22, 2015

Cryptography with Python 3

May 15, 2015  |  tools, os-x, programming, python, crypto

In 2012 I posted a post on using PyCrypto with Python 3 and some AES and RSA examples. Now, I usually use the cryptography Python library (implemented for both Python 2 and 3). I have ported all my PyCrypto examples from 2012 (see the README file) to the cryptography library.

pycryptex.py / pycryptex-cbc.py

pycryptex.py [src] is a small example using AES to encrypt and decrypt a text:

> python3 pycry …
Last updated: May 15, 2015

Run automator workflow with keyboard shortcuts

April 27, 2015  |  tools, os-x, programming

In the last post we demonstrated how to automate a task using AppleScript and the Fake scriptable web browser. Often, I use automator included on every Mac to perform such task. To activate them, we bind them to a keyboard shortcut in the given application. The example we will use today is to press the a keyboard shortcut to load the remote content of an email in Mail.app (you have of course turne …

Last updated: April 27, 2015

Automate tasks with AppleScript, Fake, and the keychain

April 27, 2015  |  tools, os-x, web, programming

You can make life a lot easier on your Mac if you learn how to automate things. The standard approach to do this on Macs are to use Automator (see How to use Automator: What Automator is and how it works from Macworld UK). If you include AppleScript, Fake, and the keychain in your toolchain, you can achieve even more. As an example I will develop an automated task to create a new email alias usin …

Last updated: April 27, 2015

Including source code in papers and on the web

March 20, 2015  |  tools, programming, python, publ, web

I've written many papers and a lot of web pages that includes source code. Since Python code was an important part of my Dr. thesis, I even wrote a tool to generate a pretty-printed Python code for LaTeX (this was written in 1997, but since I've been using it ever since it has had a few minor bug fixes since then; however, it needs Python 1.6 and it was the first Python program I ever wrote!). Jus …

Last updated: March 20, 2015

The Swift (short) history

June 3, 2014  |  os-x, programming

The language announced at WWDC yesterday came as a big surprise to almost everyone. At Chris Lattner's Homepage you can find a short summary on the history of the Swift programming language. He started work on the language in July 2010, and it became a major focus for the Apple Developer Tools group 3 years later. Other people started to contribute to the project in late 2011. He mentions Objectiv …

Last updated: June 3, 2014

A new language: Swift from Apple

June 3, 2014  |  os-x, programming, python

I've just developed my first application in Swift, the new language announced by Apple yesterday. I downloaded the Swift book on my iPad during the Keynote, and started programming immediately. When I got hold of Xcode beta 6 I got it running in seconds.

My first impression: Swift is a modern language. It is closely related to popular scripting languages, like Python and Ruby, but is is a compiled …

Last updated: June 3, 2014

How to use Interface Builder to create OS X Cocoa applications with Python

April 20, 2014  |  os-x, programming, python

When programming Python I prefer to use native GUI on OS X. Very Simple OS X Cocoa Application using Python and Interface Builder is a good place to start. The example works with Python 3 on OS X 10.9.2 when PyObjC is installed following the instructions in one of my earlier posts: Python 3 and PyObjC.

Last updated: April 20, 2014

Perl modules on Mac

April 20, 2014  |  os-x, programming

I needed a few Perl modules that weren't installed on the standard Perl installation on my Mac (OS X 10.9.2). In How to install Perl modules on Mac OS X in 4 easy steps I found all the details needed. I didn't need to do step 1 (and 1.5) since this is the first thing I do on every new Mac instance. To summarize what I did in 3 steps to install the two modules I needed:

sudo perl -MCPAN -e 'install …
Last updated: April 20, 2014

A suggestion for backup on Mac

January 8, 2014  |  tools, os-x

A lot of options for backup on your Mac exists. I use Time MachineBackblaze, Crash PlanTransporterCarbon Copy Cloner, and other tools for different types of backup on different Macs. The challenging backup for me are my pictures. I want at least one backup not in my house. The size of this backup is large, and since I am using Aperture, the meta-data of the file-system has to be preserved. L …

Last updated: January 8, 2014

PyGame for Python 3 on OS X Mountain Lion

May 8, 2013  |  os-x, programming, python

These are my steps to install PyGame for Python 3 on OS X Mountain lion:

  1. Download (and unpack) the following:
  • Install the png and jpeg libraries:
  • Last updated: May 8, 2013

    Snowman shell prompt

    April 6, 2013  |  tools

    My new bash shell prompt:

    Snow term

    Matching the large amount of snow outside. A more detailed picture of the snowman:

    Old snowman

    Inspired by put a burger in your shell.

    Last updated: April 6, 2013

    Python 3 and PyObjC

    November 27, 2012  |  os-x, programming, python

    My main programming platform is OS X 10.8 and Python 3 (currently Python 3.3). In earlier blog posts I have discussed installing and using PyCrypto in this environment. My next attempt was to find a GUI solutions for this platform. I usually prefer native approaches when programming, and for OS X the Cocoa framework is the native approach. To get access to this from Python we need a bridge, and th …

    Last updated: November 27, 2012

    AES and RSA PyCrypto examples with Python 3

    November 14, 2012  |  os-x, crypto, programming, python

    Earlier today I wrote about installing PyCrypto for Python 3 on OS X 10.8. I will use the opportunity to provide a few examples using PyCrypto to do AES and RSA encryption and decryption. I have created 3 programs. The first one, pycrypto-mkkey.py [src], generates an RSA key and saves it in two different files. One including the private key and one with only the public key (using the .pub extensio …

    Last updated: November 14, 2012

    PyCrypto with Python 3 on OS X 10.8

    November 14, 2012  |  os-x, crypto, programming, python

    On an updated Mac (in my case 10.8.2) with an updated version of Xcode  (in my case 4.5.2) compiling and installing PyCrypto for Python 3 (in my case 3.3) is not just simply running the setup.py script. The latest release of PyCrypto is 2.6 and it supports Python 3 (it has supported Python 3 since version 2.4). But my earlier attempts using Python 3.2 on OS X 10.8 failed since it couldn't locate t …

    Last updated: November 14, 2012

    Coding fonts

    October 11, 2012  |  tools, fonts, programming

    I consider myself a programmer, and to perform this task I rely on a set of tools. I need a text editor, compilers and/or run-times, build-systems, code repositories, documentation, and sometimes even an IDE. Since the late 80s my text editor of choice has been Emacs (and Aquamacs on OS X), but I am also comfortable with vi (including Vim) and ed. Currently, I am investigating time in newer text e …

    Last updated: January 3, 2022

    Generating a BibTeX file from Cristin data

    October 8, 2012  |  publ, web, python

    Based on the previous script generating HTML from Cristin data, I created another script generating a BibTeX file from the same JSON data. The script has the same limitations as the previous one, but it should be easy to modify for your needs. Have fun!

    Last updated: October 8, 2012

    Fetch and process information from Cristin

    October 6, 2012  |  publ, web, python

    Yesterday I wrote a small Python script to fetch and generate a publication list for web-pages. I use a web-services (ws) provided by Cristin (Current research information system in Norway). Cristin is a research information system for hospitals, research institutes, and universities and university colleges. From the provided ws I use the method hentVarbeiderPerson (see Brukerdokumentasjon Cristin …

    Last updated: October 6, 2012

    Almost two years in silence

    October 5, 2012  |  blog

    I restart my blog today.  November 16th 2010 was my last post (on Beatles available in iTunes). Since many of my old post were dated, I've deleted them all.  The main reason for the silence is that other tools have replaced the purpose of the blog for me. I used the blog to remind myself on interesting software, web-pages, music and articles/text that I wanted to dig into later. Kippt and Instapap …

    Last updated: October 5, 2012