Recently, I thought I needed to use
simpleldap–it turned out that I instead needed to reconfigure NGINX. At any rate, this was my experience with
Continue reading Using simpleldap
I learned a hard lesson today: to make Swift really fast you have to know what you’re doing. You can’t just slap some code together and expect it to be zippy without understanding some of how Swift was designed and how it works. There is a very good presentation by some of the team members that built Swift here. My initial takeaway was that it was important to finalize any classes you didn’t plan on subclassing, incrementally check the timing analyzer, and finally, employ whole module optimization.
Continue reading Swift Optimization
I use cURL quite a bit when debugging APIs and I found this neat trick for pretty-printing JSON output. Add the following line to your
alias json="python -m json.tool"
Then you can pipe your cURL output through your new
json tool and print everything nicely,
curl -g http://some.domain/api/call | json
In this post we’ll cover solving a system of linear equations using Swift and Accelerate. It get’s a little bit hairy, but it’s not so bad once you get the hang of it.
Continue reading Solving Linear Equations with Swift and Accelerate
I found out how to invert a matrix on SO, but I didn’t understand the solution, so I thought I’d talk more about it here. First of all, there isn’t a one-off inverse function in the Accelerate framework. You need to calculate the LU facotrization first using
dgetrf_(), and then plug that data into
dgetri_() to calculate the inverse.
Continue reading Matrix Inversion Using Swift and Accelerate
In this post I’ll walk through setting up a hierarchical view with expanding nodes using NSOutlineView and NSTreeController. This is the sort of thing you’d want if you had to describe a file system. In this example I’ll be using Xcode 7 and Swift 2.
Continue reading Using NSOutlineView and NSTreeController to Create a Tree
I found this so helpful on StackOverflow, I thought I’d re-post it here for my personal reference. The snippet below is used to take a 1024-by-1024 pixel PNG file named
Icon1024.png, and create smaller resolution copies in an iconset directory, which can be used later when you deploy your app.
sips -z 16 16 Icon1024.png --out MyIcon.iconset/icon_16x16.png
sips -z 32 32 Icon1024.png --out MyIcon.firstname.lastname@example.org
sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_32x32.png
sips -z 64 64 Icon1024.png --out MyIcon.email@example.com
sips -z 128 128 Icon1024.png --out MyIcon.iconset/icon_128x128.png
sips -z 256 256 Icon1024.png --out MyIcon.firstname.lastname@example.org
sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_256x256.png
sips -z 512 512 Icon1024.png --out MyIcon.email@example.com
sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_512x512.png
cp Icon1024.png MyIcon.firstname.lastname@example.org
iconutil -c icns MyIcon.iconset
rm -R MyIcon.iconset
The next to last line uses the
iconutil utility to convert an
iconset into an
icns file, but it can also work the other way. (See
man iconutil for more information.)
I thought that .pex files were the way to go for distributing Python applications to OS X users, but it was only partially successful. For one, users needed to reinstall Python with Homebrew, which isn’t difficult, it’s just awkward explaining to people that the Python distribution that ships with Mac isn’t the same Python distribution that exists in the wild. Their next question is invariably, “how will this affect the rest of my system?” I can’t answer that. I can’t guarantee that things will be future-proof.
And then I found app2py (or five dollars) which creates a Mac application bundle out of a Python script. It worked like a charm. The best thing is that you don’t have to write a stupid
setup.py file, it writes one for you. That’s five minutes of your precious time you can look at cat videos with, or whatever.
You can install this using pip, so that’s cool. Next, you do as the tutorial explains,
py2applet --make-setup MyApplication.py
This will create a
setup.py file. Finally, for deployment, you build the distribution with a non-Mac Python installation. (If you haven’t already run
brew install python you’ll want to run that.) My brew installation of the Python landed somewhere in
/usr/local/Cellar/python/2.7.8_2/bin/python setup.py py2app
This will create a standalone Python application that you can distribute painlessly to your Mac colleagues.
This post is sort of an amalgamation of solutions I’ve found on several blogs, tutorials, and SO posts I’ve used regarding SSH keys. I cover key generation and authentication, removing passwords from keys, and identifying the key finger print.
Continue reading Operations on SSH Keys
I was interested in performing system calls from Swift, and I found a resource that I had to modify somewhat. I imagine that the language has changed since that post was written. At any rate, here is the working code,
Continue reading Perform System Calls from Swift