Searching through Subversion history Searching through Subversion history
  • Home
  • Posts
  • Home
  • Posts

Searching through Subversion history

Occasionally I need to search back through old versions of projects to find a piece of code I want to resurrect or just use as reference — I haven’t found any easy built-in way to do this, so I adapted this useful script to allow me to grep through all history from within a Subversion working directory, like:

$ svngrep SecItemCopyMatching *
LSAddAccountController.m @r7: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
LSAddAccountController.m @r4: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
LSAddAccountController.m @r2: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
LSAddAccountController.m @r1: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:

$ svngrep SecItemCopyMatching * LSAddAccountController.m @r7: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys: LSAddAccountController.m @r4: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys: LSAddAccountController.m @r2: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys: LSAddAccountController.m @r1: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:

Here’s the script:

#!/bin/sh
pattern=$1
shift
 
for file in $@; 
do
  svn log -q "$file" 2>/dev/null | perl -ne 'print "$1n" if /^r(d+)/' | 
  while read r 
  do
    match=`svn cat -r $r "$file" | grep "$pattern"`
    result=$?
    if [ $result -eq 0 ]
    then
      /bin/echo -n "$file @r$r: "
      /bin/echo $match;
    elif [ $result -ne 1 ]
    then
      exit 2
    fi
  done
done;

#!/bin/sh pattern=$1 shift for file in $@; do svn log -q "$file" 2>/dev/null | perl -ne 'print "$1n" if /^r(d+)/' | while read r do match=`svn cat -r $r "$file" | grep "$pattern"` result=$? if [ $result -eq 0 ] then /bin/echo -n "$file @r$r: " /bin/echo $match; elif [ $result -ne 1 ] then exit 2 fi done done;

Read More

Using custom DNS servers from the iPhone and over Internet Tethering

For those of us the roam around on network connections, OpenDNS and Google Public DNS provide public DNS servers which offer better security than using arbitrary DNS that’s assigned to us when we connect to a network. This means that rather than trusting the assigned DNS server — which could be a malicious third party that’s attempting a man-in-the-middle attack — we always use a trusted server.

In OS X, normally, one can specify custom DNS servers in Network Preferences, but when using Internet Tethering with the iPhone, no options are available.

It’s possible to set DNS configuration on the command line, though, as mentioned in this MacOSXHints article.

This technique can be used within a shell script to make things easier.

As it happens, if you have a jailbroken iPhone, the trick works there too — just ssh in as root, copy the script over, and run it from the iPhone.

The one caveat is that the DHCP client both on the iPhone and on Mac OS X will routinely reset the servers — I haven’t found a way to combat this yet, other than routinely re-running the script.

We have been using mobile broadband from my iPhone while we’ve been travelling; our current provider seems to go offline almost every evening — a quirk which I’ve just discovered is related to their faulty DNS server.

Using Google’s public DNS servers instead fixes this problem, so I was after a way to configure both the iPhone and OS X to use the servers.

Read More

Links for October 25th through January 23rd

Links for October 25th through January 23rd:

  • GPS Visualizer: Draw a map from a GPS data file Batch map plotter using GPS co-ordinates
  • Map multiple locations by address Very well-implemented free batch geocoder; accepts only address data, no GPS co-ordinates, but still excellent for some applications
  • iPhone: Custom font loading
  • Implementing Your Own Cocoa Bindings « Tom Dalling
Read More

Talkie 1.1 for iPhone

Talkie 1.1Talkie 1.1 is now available on the iPhone App Store, and it’s better than ever.

The new version connects to other Talkies via Bluetooth completely automatically — start Talkie on your iPhone and within seconds you’ll be connected to anyone nearby using Talkie on the same channel.

Also new are WiFi and Bluetooth connection indicators, and an audio meter for when you’re transmitting or receiving.

For a limited time only, Talkie is available for $1.99. Grab it on the app store.

— And don’t forget, Talkie for Mac is absolutely, 100% free for use with Talkie for iPhone.

Read More

Flickrpress 1.0

Flickrpress sampleI’ve just finished a new release of my Flickr plugin for WordPress, Flickrpress.

The new version features AJAX-based navigation between pages of images, and improved support for insertion within pages and posts as a shortcode.

Flickrpress 1.0 can be downloaded from the WordPress plugin repository

See it an action over on my personal blog.

Read More

Upload Janitor WordPress Plugin

This plugin allows you to reclaim disk space and clean up your uploads folder by deleting old uploads you are no longer linking to.

It will identify unused files within your uploads folder, and give you the option of archiving then deleting some or all of these files.

Before any action is taken, Upload Janitor will automatically make a ‘tar’ archive of all files to be erased, including their original paths, so you can restore if necessary.

Read More

Hidden Tags WordPress Plugin

This plugin allows you to specify a list of tags or categories to keep hidden: These will no longer appear anywhere on the site, such as in the tag cloud or on the list of post tags. This is useful when using tags to control behaviour of your blog with other software, or when you wish to maintain groupings of posts out of the public eye.

Read More

Error -12986 and you

A customer recently got in touch with me with an odd problem — Talkie for iPhone was going silent on him. After a little diagnosis, it turned out the audio system was throwing up an undocumented error — -12986 — while starting up on his iPod Touch.

Some googling turned up this thread on Stack Overflow, which presented a solution for the AVAudioSession framework: It turns out, on recent SDKs (somewhere equal to or above 3.0), the audio system will refuse to start up if the session is set to a recording mode, with no input device available, spitting out this error. Alas, the error isn’t listed anywhere that I could find.

So, the way to fix it is to check whether there’s an input device available, then choose an audio category accordingly:

OSStatus status;
 
UInt32 inputAvailable=0;
UInt32 size = sizeof(inputAvailable);
AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, 
                        &size, 
                        &inputAvailable);
UInt32 sessionCategory;
if ( inputAvailable ) {
    // Set the audio session category for simultaneous play and record
    sessionCategory = kAudioSessionCategory_PlayAndRecord;
} else {
    // Just playback
    sessionCategory = kAudioSessionCategory_MediaPlayback;
}
 
status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
                                  sizeof (sessionCategory),
                                  &sessionCategory);    
checkStatus(status);

OSStatus status; UInt32 inputAvailable=0; UInt32 size = sizeof(inputAvailable); AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &size, &inputAvailable); UInt32 sessionCategory; if ( inputAvailable ) { // Set the audio session category for simultaneous play and record sessionCategory = kAudioSessionCategory_PlayAndRecord; } else { // Just playback sessionCategory = kAudioSessionCategory_MediaPlayback; } status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), &sessionCategory); checkStatus(status);

It’s probably a good idea to respond when input becomes available or goes away, so add a property listener too:

void inputAvailablePropertyListener (void                      *inClientData,
                                     AudioSessionPropertyID    inID,
                                     UInt32                    inDataSize,
                                     const void                *inData) {
    if ( inID = kAudioSessionProperty_AudioInputAvailable ) {
        UInt32 *inputAvailable = (UInt32*)inData;
        UInt32 sessionCategory;
        if ( *inputAvailable ) {
            // Set the audio session category for simultaneous play and record
            sessionCategory = kAudioSessionCategory_PlayAndRecord;
        } else {
            // Just playback
            sessionCategory = kAudioSessionCategory_MediaPlayback;
        }
 
        OSStatus status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
                                                   sizeof (sessionCategory),
                                                   &sessionCategory);    
        checkStatus(status);
    }
}

void inputAvailablePropertyListener (void *inClientData, AudioSessionPropertyID inID, UInt32 inDataSize, const void *inData) { if ( inID = kAudioSessionProperty_AudioInputAvailable ) { UInt32 *inputAvailable = (UInt32*)inData; UInt32 sessionCategory; if ( *inputAvailable ) { // Set the audio session category for simultaneous play and record sessionCategory = kAudioSessionCategory_PlayAndRecord; } else { // Just playback sessionCategory = kAudioSessionCategory_MediaPlayback; } OSStatus status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), &sessionCategory); checkStatus(status); } }

then:

// Listen for audio input availability
status = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioInputAvailable,
                                         inputAvailablePropertyListener, 
                                         NULL);

// Listen for audio input availability status = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioInputAvailable, inputAvailablePropertyListener, NULL);

Read More

Hi! I'm Michael Tyson, and I run A Tasty Pixel from our home in the hills of Melbourne, Australia. I occasionally write on a variety of technology and software development topics. I've also spent 3.5-years travelling around Europe in a motorhome.

I make Loopy, the live-looper for iOS, Audiobus, the app-to-app audio platform, and Samplebot, a sampler and sequencer app for iOS.

Follow me on Twitter.

Posts pagination

« 1 … 21 22 23 … 36 »
© 2021 A Tasty Pixel.