Jan27

How to fix an upsized Apple TV stuck in 1.0 software

Tagged with: ,,,.
17 Responses

Some months ago, I swapped some hard drives, and ended up upgrading my Apple TV’s 40GB hard drive. The process was the standard procedure you can find in many sites: back-up the drive, create the correct partition map on the new drive and restore the data into the new drive.

When I upgraded the hard drive, the software version was already 2.x. However, the Apple TV restore partition was still the original 1.0. Here is where the problem started. Whenever new software upgrades were downloaded, they just failed. I’m not sure the upgrades check the hard disk size. Most likely, when restoring into the larger hard drive, some permissions got messed up. A “factory restore” takes the Apple TV back to 1.0 (no YouTube, no Apple Store menus) but once again the upgrades fail.

The process I document here doesn’t require to re-open the Apple TV case. You could go that route, of course, but I think it may even take longer.

You will need:

  • External USB drive that can be completely wiped (512MB or more)
  • A copy of ATV USB Creator
  • A DMG from Apple with the latest firmware. At the time of writing 2Z694-5573-24.dmg. I believe ATV USB Creator tries to download it automatically. However, we’ll need the file for the extra step described here, so you’d be better off by getting the DMG yourself.

(more…)

Dec18

Dynamic DNS woes

Closed

My home network has the typical configuration NAT behind a hardware firewall with a dynamic IP address provided by the ISP. I use DynDNS to have a fixed name that I can use anywhere on the internet to access the home network.

The Linksys WRT54G I use supports DynDNS updates, however, from some weeks ago, I started having issues with the updates. A cryptic error -1 wasn’t of much help.

To avoid the hassle of debugging what’s going on, I decided to give the responsibility of the updates to a Linux box inside my home network, instead of the router.

The software I used is ddclient, which is in the list of recommended clients for DynDNS. From version 3.7.0 ddclient supports SSL, so the password isn’t traveling in cleartext.

Installing ddclient in Gentoo Linux is a breeze: emerge -a ddclient

The configuration file /etc/ddclient/ddclient.conf is quite straightforward and the sample file installed should get you going right away. Mine now looks as follows.

daemon=300                              # check every 300 seconds
syslog=yes                              # log update msgs to syslog
#
## To obtain an IP address from Web status page (using the proxy if defined)
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
login=yourlogin
password=yourpassword
protocol=dyndns2                                # default protocol
server=members.dyndns.com
ssl=yes
#mx=mx.for.your.host                            # default MX
#backupmx=yes|no                                # host is primary MX?
wildcard=yes

your.domain.net

To get there, I had to jump through some hoops, which I hope this post avoids you:
1. Do not use members.dyndns.org as the documentation states. Use .com
2. The ssl option doesn’t seem to work and it is not because IO::Socket::SSL is not installed, as hinted in the DynDNS FAQ and the ddclient FAQ — well, you DO need it installed but I’ve read the fine manual already and that was not my problem for sure.

I discover #1 after starting the ddclient daemon as usually in Gentoo /etc/init.d/ddclient start and discovering syslog errors like

Dec 17 03:24:50 host ddclient[9348]: WARNING:  cannot connect to members.dyndns.org:8245 socket: IO::Socket::SSL: connect: Connection timed out IO::Socket::INET configuration failederror:00000000:lib(0):func(0):reason(0)
Dec 17 03:24:50 host ddclient[9348]: FAILED:   your.domain.net: Could not connect to members.dyndns.org:8245.

It may be that I’m in China and dyndns.org is blocked from there. I don’t know. But you can check easily on any web browser. Browse to http://checkip.dyndns.com/ and you should get Current IP Address: 111.222.333.444. For me dyndns.com works.

Next it was the ssl issue. Fortunately, debugging ddclient is very easy. Stop the daemon /etc/init.d/ddclient stop and then run ddclient -daemon=0 -noquiet -debug from a terminal. Doing that I was able to see that even with the ssl=yes in the config file, the request was done using http. On the output of the command I was able to see

DEBUG:     nic_dyndns2_update -------------------
DEBUG:    proxy  =
DEBUG:    url    = http://members.dyndns.org/nic/update?system=dyndns&hostname=your.domain.net&myip=111.222.333.444&wildcard=ON
DEBUG:    server = members.dyndns.org

I changed the file /etc/init.d/ddclient — I know it is not recommended because any update to ddclient will overwrite the change. However, these days I’m always rushed and therefore less of a purist :)

The change was adding the -ssl switch in front of --exec /usr/sbin/ddclient to the start function, as seen below

start() {
        checkconfig || return 1
        ebegin "Starting ${SVCNAME}"
        start-stop-daemon \
                --start \
                --chuid ddclient \
                --exec /usr/sbin/ddclient -ssl \
                --name ddclient \
                --pidfile "${PIDFILE}" \
                -- -pid="${PIDFILE}"
        eend $?
}

I’d love to hear comments on a better way to get this problem fixed.

Dec3

ActiveScaffold summary fields

Closed

In one project I am the “gatekeeper” of a list of potential initiatives that the organization would like to explore as sources of revenue.

These initiatives are cross-regional in Asia, and best practice would call for the subject matter experts on each country to “own” and maintain the initiatives.

Thanks to the beauty of Rails, ActiveScaffold and other wealth of plug-ins available for Rails, in just 2 or 3 days of coding I was able to get the basics of a web application to handle this. Much better than a shared Excel Spreadsheet.

By the way, I tried using Sharepoint to maintain this list, and was underwhelmed. Anyway, recently added a summary field on the initiatives I track, to be able to show total (forecast) revenue and sales.  Followed the documentation on the ActiveScaffold website, and started receiving an error:

Showing vendor/plugins/active_scaffold/frontends/default/views/
_list_calculations.rhtml where line #12 raised:

undefined local variable or method `_erbout' for #<actionview ::Base:0xb518c850>

Extracted source (around line #12):

9:         override_formatter = "render_#{column.name}_#{column.calculate}"
10:         calculation = self.method(override_formatter).call(calculation) if respond_to? override_formatter
11:
12:         _erbout.concat calculation.to_s
13:         -%>
14:       < % else -%>
15:         &nbsp;

Trace of template inclusion: vendor/plugins/active_scaffold/frontends/
default/views/_list.rhtml, vendor/plugins/active_scaffold/frontends/
default/views/list.rhtml

The variable _erbout is the default output variable from an Erb object (see http://noobkit.com/show/ruby/ruby/standard-library/erb/new.html)

My proposed fix (I’ll send a patch to the ActiveScaffold devs) is to remove the _erbout reference and replace by

  < % if column.calculation? -%>
    < %
      calculation = column_calculation(column)

      override_formatter = "render_#{column.name}_#{column.calculate}"
      calculation = self.method(override_formatter).call(calculation) if respond_to? override_formatter
    -%>
    < %= calculation.to_s -%>
  < % else -%>
    &nbsp;
  < % end -%></actionview>

Feb15

Screencast composition application

Tagged with: .
Closed

I’ve been recently working on some screencasts to demonstrate data analysis techniques.

Two common features I needed for my screencasts, which I’ve seen many screencasters also use/need, are:

  • Overlay of a small frame on top of the screencast. For instance, you may want people to see you while you are talking. With computers taking more and more an active role on activities like interviewing, taking down patient records, etc., you may want to highlight some personal interaction tips while using your software. Perhaps you want to show a piece of hardware associated with the screencast. The limit is your imagination.
  • Watermark your screencast You may want to prevent others from using your screencast on other sites without the proper credits.
Frame of exported movie This image shows basically what I needed. By the way, it is actually created with my program.

 

I started last weekend trying to do it with Quicktime Pro, and found it quite cumbersome. I can record the screen activity fine on the PC, as well as recording myself talking. Here the easy part ends. Then I have to add a video track on QT Pro, guess the offset entering it with numbers, and recompress. No, I wanted something simpler. Searching on the internet, found people using higher end applications, like Final Cut Pro. Not wanting to fork $1,299 for Final Cut Pro or $299 for Final Cut Express, I coded a simple app to achieve what I need. It works nicely, and with that many people doing screencast these days, I think there may be interest for it. When it’s completely finished, I’ll release it as a $9.99 download, and will set up a permanent page for it so people can purchase it. Meanwhile, I’d like to gather some feedback, so if you are a brave soul that can deal with beta software, and have use for the tool, please contact me. The first 25 beta testers will get a full version of the software when it is done. Sorry, no plans to open source the code so far.
(more…)

Feb8

Complex validation in Rails through plugins

Tagged with: .
Closed

I’m writing a portfolio management application in Rails where complex validations are required between fields of instances. The MVC paradigm of Rails is very good to encapsulate all the business logic of the application in a very readable way.

I found an article here describing how to add validations to a model through plugins, making them reusable and semantically clear.

Even if you don’t have in mind reusability, which was my case, the added clarity if this method is worth the additional work of creating a plugin.

Complete information on how to write plugins can be found here

Jan25

Joining many jpeg files into one single PDF

Tagged with: .
2 Responses

I had old scans of many guitar tab books as a directory of JPEG files, sequentially numbered. That was the way the old scanner stored documents. My SnapScan has an automatic document feeder and scans directly to PDF, which is much nicer to use. I wanted to join these JPEGs into a single PDF. After looking for different ways to do it, AppleScript, available software, etc., decided none of them were acceptable for my needs.

To accomplish the task, I used the following process (not optimal, but works):

cd directory
ls *.jpg | sort | xargs SavePDF

Where SavePDF is a program I hacked in an hour or so, using the CoreImage interfaces on the Mac. The code for SavePDF is shown below. Compile it with XCode, as of this writing Version 2.4.1

Precompiled binary for Mac OS X Intel platform is available here (in some browsers you’ll need to right-click and select “Save As…”)

Note that there is no error checking at all for the arguments. The resulting file is left at the current directory with the hardwired name “joined.pdf”

Use at your own risk – Works for me, YMMV. Other formats besides JPEG are supported by CoreImage and this code will work also with BMPs, PNGs and others. I personally have not used it for any other format.
(more…)

Nov30

Normalize Excel tables

Tagged with: .
1 Response

Business data is quite often expressed across many dimensions. The profitability equation in a company is very simple in concept, but in practice those revenues come across regions, product lines, products etc., making them in fact multidimensional data.

Users of OLAP systems are very aware of multidimensional data. However, many spreadsheet users are not, so they manage to flatten the data the best they can, using pages or subtotals for dimensions beyond the second one.

Modern spreadsheets have “PivotTable” capabilities, which makes easier to deal with multidimensional data. To feed these pivot tables, the information has to be normalized. This post explains how to normalize data from non-normal representation, using a Visual Basic macro

If you are familiar with OLAP and normalized data, skip to the code. I’ll show samples of non-normalized data, how the same data would look normalized, and why this recipe is useful.

(more…)

Nov24

Adding a script menu to XCode to reformat code using astyle

Tagged with: .
3 Responses

Although XCode has its own “code beautifier” built-in function (Format->Re-indent), it didn’t make it for me. It seems it is more tuned up for Objective C, but with a lot of my code being C++, these are among the biggest annoyances:

  • The first line after private/public/protected were indented one more tab from what it should be
    XCode indent Desired Indent
  • Some of the Qt macros were also improperly indented
  • It didn’t do anything to other elements of code beautification, like spaces between operators, breaking up complex statementes, etc.

So, I reverted to the trusted astyle which I use in Linux. The integration with the XCode IDE works well. Here’s what I did:

1) Installed astyle. Strange enough not Fink or Darwinports have it at this time available on their default trees. So I had to compile it from source and install it on /usr/local/bin

2) On ~/Library/Application Support/Apple/Developer Tools/Scripts/ created a new script with the code shown below. On my particular setup, I had previously copied the scripts from /Library/Application Support/Apple/Developer Tools/Scripts/ into my personal directory, so it has the default structure Apple uses. You may have a different organization. In my case, the script is under 10-User Scripts/40-Code/30-astyle.sh

#! /bin/sh
#
# astyle.sh - Reformats code using astyle
#
# -- PB User Script Info --

# %%%{PBXName=Reformat with astyle}%%%
# %%%{PBXInput=AllText}%%%
# %%%{PBXOutput=ReplaceAllText}%%%
# %%%{PBXKeyEquivalent=}%%%

echo -n "%%%{PBXSelection}%%%"
/usr/local/bin/astyle --style=kr -s4SKNap < &0 2>/dev/null
echo -n "%%%{PBXSelection}%%%"

3) Reloaded the script menus in XCode. All set!

The script is taking all the text of the front window when it is called, running it through astyle and replacing all the text with the result. The settings –style=kr -s4SKNap are my personal preferences. You may want something different. However, don’t forget the 2>/dev/null, otherwise the greeting messages that astyle sends to stderr will mix into your code.

astyle can read a .astylerc on your home directory, which perhaps is nicer than specifying the switches as I did, but I’m lazy.

Happy reformatting!

Nov3

Linked del.icio.us bookmarks to my pages to avoid entries that are just a bookmark

Tagged with: .
Closed

Wordpress was an easy option to “bookmark” something while browsing the web, since I usually had one browser open on my blog. However, it’s quite annoying to sort through many little blog entries that are no less than a bookmark with minimal extra comment. Now I linked my del.icio.us bookmarks on the right sidebar, getting the best of both worlds: the links are accessible on the blog, and getting rid of the annoying entries.

Aug19

Some interesting source code for Mac applications

Tagged with: .
Closed

While developing the iPhoto add in I found these interesting sources for several Cocoa classes.