Out

Hi all, I’ve moved my blog to http://yitznewton.blogspot.com/

iOS development

So, I went through my seduction cycle of want, not-want with Macbooks. I finally satisfied myself with upgrading my work ThinkPad T420 with a good SSD and running Linux Mint, this being a great web dev environment, as far as I’m concerned.

Recently I started fooling around with native mobile app dev, in the form of Android. The laptop works great for this, although the 14” screen is too small to work comfortably with Eclipse.

When I started thinking about learning iOS dev, I ran into the evil truth: there is no good way to do it other than on a Mac. I was unsuccessful in running a Mac VM on my laptop. So now, possibilities…

  • Mac Mini
  • Macbook Pro 13 or 15
  • Macbook Air 13

Seems to me, if I’m buying a Mac anything, it’s gonna become my main machine, and so must be a laptop. (My last personal Windows laptop is effectively in retirement, with my experiments taking place on my work laptop.) So the Mini is out.

I tried some iOS tutorial action on the office Macbook Pro 13, and honestly it seemed like Xcode UI was pretty well engineered WRT fitting all the collapsing widgets onto a 13” display, unlike Eclipse. The price cut and default SSD of the Air was very attractive, so I thought about getting me an Air 13.

Hopped down to the Apple Store, and was disappointed that I wasn’t able to test-drive Xcode on any of the hardware in the store. But worse: the Air has only the one Thunderbolt and 2 USB ports, with no Ethernet. So the only way to get Ethernet and display-out at the same time is to buy a $300-400 Thunderbolt dock. Hopefully I’d never need both at the same time. If this is going to be my main machine, I must also have a DVD drive for… well, watching DVDs - and the Air lacks that as well.

So it’s either settle for the Air 13 and rely on an external DVD drive, which is pewey, or get a Pro, and hopefully upgrade to SSD and anti-glare screen. That’s a lot of coin. Sigh.

New dev environment: Linux?

After yet another round of seduction by the MacBook Pro and yet another conclusion that it’s not worth it (current ThinkPad with Win7 works fine for me), I got to thinking differently. (Different?)

As a web developer who does not currently do any Apple-platform-specific work (e.g. iOS), the one major advantage of the MBP over Windows for me: native Unixy environment. I normally run a Linux VM on which I do my dev work, with Vim as my creation tool, but the fact that it’s in a VM and the filesystems are different, leads to headaches sometimes.

So what about running a Linux environment on my ThinkPad?

So, I decided to try dual-booting. Years ago (like 2008), I converted a virus-ridden family castoff HP laptop to Ubuntu, and the experience was pretty good. I could only imaging it’d be great now.

After nuking my Win7 install by messing up the partitioning (D’OH!) and reinstalling (WOOHOO, vanilla reduced-bloatware Windows), I had a 500GB HDD with 160GB Win partition, and the rest available. So I grabbed Mint KDE (‘cause I like Kate as a second to Vim), and set to work.

After a day of work, so far so good. The one reeeal annoyance of KDE is the fact that I work with a dock and monitor and frequently de-dock for meetings, and windows from the monitor display get caught in limbo when you de-dock. That bites.

Hoping to work around that; I hear that XFCE may possibly not have this issue.

But overall the experience has been great. Excelsior!

Setting up shared folders on VirtualBox

Man, what a headache. I just had to set up a share for a Win7 host and a Ubuntu Server guest with VirtualBox.

Here’s how it went.

  • Install VirtualBox guest additions
    • On the VB container window, use menu option Devices > Install Guest Additions
    • Restart the VM
    • In the VB Devices > Shared Folders dialog box, add a Machine Folder with the host folder as Folder Path, and hostshare (or whatever you want) as Folder Name. Set Auto-Mount (?) and Make Permanent
    • Within the VM, look in /media/cdrom/ for the appropriate Linux binary, and sudo it. Disregard error regarding X11 if you are a Server installation
  • In /etc/fstab, add the following, with appropriate permissions for you:

    hostshare /path/to/mount/point vboxsf uid=www-data,gid=adm,fmode=664,dmode=775 0 0

You should be able to mount this now.

Additional info: https://www.virtualbox.org/manual/ch04.html#sharedfolders

Programming is…

http://www.mrclay.org/2011/04/01/programming-is/

What are programmers actually doing? I liked these related items:

  • Searching for existing code that does what you want, maybe without knowing what that’s called
  • Evaluating if code you found solves your problem/would perform acceptably/fits in your environment/has a compatible license/has a lasting support community
  • Installing, configuring, and testing a codebase then finding it won’t work for you
  • Digging through public code repositories to see “how [some open source project] does it”

I learned to program…

Posting at http://ilearnedtoprogram.com/ made me think about my beginnings as programmer. I started out blundering around in Applesoft BASIC with our ][e, circa 1986. I wrote a small suite of WordBasic macros with dialogs to boilerplate my homework in middle/high school. I went to computer camp (NCC) for two years, where I continued learning basic. This was around 1992-94; that’s where I made my first acquaintance with Star Wars. The first year was good; the second year, I woke up the last day to a bed full of cookie crumbs. But I digress.

Jump ahead to grad school (Library Science). I took an XML metadata course, which included some work with XSLT. This led to an XML-based digital collection of lectures, written in ASP. shudder

I started writing scripts in PHP, most significantly a library inventory suite. Around this time I learned regular expressions, and started creating an app in symfony. The rest is history: I learned OOP with Zandstra’s book, and like to believe I am a semi-serious intermediate-level web developer. I know symfony basics well, and have used some advanced techniques within that framework. I’m looking forward to continued growth, and presumably learning symfony2 once it is fully released. Excelsior!

That first Puppet module

So you’re having trouble getting started with Puppet, eh? I had a beast of a time with that too - getting a working practical configuration took some doing. Allow me to share my bare-bones apache setup with you. It consists of a simple Puppet module, plus a single manifest which I call directly with puppet apply

First, context. I have a single production Ubuntu server, which I more or less, sort of, mirror on my dev box. Recently I realized that my internal wiki posting of disaster recovery instructions was sorely out of date, and went about rewriting it, checking each step on a clean Ubuntu VM. Then I said, hey, I’m manually recreating this whole installation… maybe I can just rig up Puppet (which I’d heard about at a conference last year) to do it automatically! I get an added benefit if I do it TDD-style, and change config via the Puppet modules; then I don’t have random undocumented tweaks to configuration that are lost in the event of a disaster, or inadvertent deletion. Plus the automatic benefit of easily trickling changes down to dev and testing environments.

First, the module. I set up a puppet directory in my home directory on the clean testing install, with this tree:

yitznewton@syslib-restore:~/puppet$ tree .
.
├── modules
│   └── apache2
│       ├── files
│       │   ├── startssl.ca.pem
│       │   ├── startssl.sub.class2.server.ca.pem
│       │   ├── tuning.conf
│       │   ├── wildcard.mydomain.org.crt
│       │   └── wildcard.mydomain.org.key
│       ├── manifests
│       │   └── init.pp
│       └── templates
│           └── httpd.conf.erb
└── server.pp

The files directory includes some ssl certs and server-specific tuning settings for Apache. The main files are init.pp:

class apache2 {
  package { 'apache2':
    ensure => present,
  }

  service { 'apache2':
    ensure => running,
    enable => true,
    hasrestart => true,
    hasstatus => false,
  }

  file {
    '/etc/apache2/tuning.conf':
      owner => root,
      group => root,
      mode  => 644,
      require => Package[apache2],
      source => "modules/apache2/tuning.conf",
      replace => false,
      notify  => Service[apache2];
    '/etc/apache2/httpd.conf':
      owner => root,
      group => root,
      mode  => 644,
      require => Package[apache2],
      content => template("apache2/httpd.conf.erb"),
      replace => true,
      notify  => Service[apache2];
    '/etc/apache2/ssl':
      ensure => directory,
      owner => www-data,
      group => root,
      mode => 600;
    '/etc/apache2/ssl/wildcard.mydomain.org.crt':
      owner => www-data,
      group => root,
      mode => 600,
      source => 'modules/apache2/wildcard.mydomain.org.crt';
    '/etc/apache2/ssl/wildcard.mydomain.org.key':
      owner => www-data,
      group => root,
      mode => 600,
      source => 'modules/apache2/wildcard.mydomain.org.key';
    '/etc/apache2/ssl/startssl.ca.pem':
      owner => www-data,
      group => root,
      mode => 600,
      source => 'modules/apache2/startssl.ca.pem';
    '/etc/apache2/ssl/startssl.sub.class2.server.ca.pem':
      owner => www-data,
      group => root,
      mode => 600,
      source => 'modules/apache2/startssl.sub.class2.server.ca.pem';
  }
}

and httpd.conf.erb:

Include /etc/apache2/tuning.conf

NameVirtualHost <%= ip %>:80
NameVirtualHost <%= ip %>:443

ServerName www.<%= mydomain %>

SetEnv LD_LIBRARY_PATH /usr/lib

ServerAdmin yitznewton@mydomain.org

ErrorLog "|/usr/sbin/rotatelogs /www/logs/errorlog.%Y-%m-%d 5M"

#BrowserMatch ".*MSIE.*" \
#  nokeepalive ssl-unclean-shutdown \
#  downgrade-1.0 force-response-1.0

<Directory />
  Options -ExecCGI -Indexes +FollowSymLinks
  AllowOverride none
  Order deny,allow
  Deny from all
</Directory>

# This is the catch-all to redirect traffic that's not
# covered by one of the other active vhosts

<VirtualHost <%= ip %>:80>
  ServerName default.<%= mydomain %>
  CustomLog "|/usr/sbin/rotatelogs /www/logs/accesslog.%Y-%m-%d 86400" combined

  RewriteEngine On
  RewriteRule .* http://www.<%= mydomain %>/ [R=307,L]
</VirtualHost>

Then I just call the module in server.pp:

$ip = '192.168.65.180'
$mydomain = 'mydomain.org'

include apache2

and invoke it with sudo puppet apply server.pp --modulepath=modules

Huzzah!