I have been playing with Flex a bit, to write an Flash application for my masters degree (I find the flex environment much better for programming than flash), and like most people working with flash I have come up against the cross domain issue (where the player won‘t pull data from a domain which doesn’t have a cross domain policy allowing them to do so). This is a problem for the application I am working with, because I want to pull RSS feeds.

The obvious answer, a php proxy. In a way that makes it sound grander than it is because all it really is is a script to pull data from a remote source to get around the cross domain issue.

here is the script (simplified):

`

<?php
    header("Content-Type: application/xml; charset=UTF-8");
    $url = $_GET['url'];
    readfile($url);
?>

`

Now the code pulls back the feed as expected, but prepends this:

67c0

immediately before the content. Where does that come from, any ideas? Wherever it comes from it obviously means the feed won't parse!

In the end, I used curl like this (simplified):

`

<?php
    header("Content-Type: application/xml; charset=UTF-8");

    // note that this will not follow redirects

    $url = $_GET['url'];

    // create a new curl resource
    $ch = curl_init();

    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);

    // grab URL and pass it to the browser
    curl_exec($ch);

    // close curl resource, and free up system resources
    curl_close($ch);
?>

`

Technorati Tags:
developing, php, web development, rss, flash

As a web developer, I love the fact that my work machine can run apache, mysql and php. It makes my working life so much easier than all that ftp'ing then testing. It becomes even more important when you are working with Subversion; I think it good practice to work on a particular bit of a project until it is basically working, before those changes are committed. So my set up is that my SVN working copies become my apache docroots.

So, I usually have Apache 2 set up (along with MySQL, and PHP), via MacPorts, and using 'dynamically configured mass virtual hosting'.

This basically means that any calls to my local apache server will look in my sites folder for a directory with the same name as the requested domain name. In order to get the domains working under Mac OS X Tiger, I would just edit /etc/hosts pointing each domain to 127.0.0.1, then restart lookupd, and the whole system would work.

Great … except when Apple developed Leopard, they removed lookupd and thus, my means of pointing my local domains to my local server. Read on for the answer …

Technorati Tags:
developing, how to, Mac, osx, software, tips, tutorials, leopard

After a bit of searching, I found an answer; dnsmasq. Here is a quick run down of what I did to get it working under Leopard. NB: This is pretty MacPorts centric because that's how I did it, and thus assumes you are doing the same! This also requires a bit of terminal work.

  1. Install dnsmasq

sudo port install dnsmasq

  1. Create a copy of the sample dnsmasq config

sudo cp /opt/local/etc/dnsmasq.conf.sample /opt/local/etc/dnsmasq.conf

  1. Edit the conf file:

Find line 58 (#address=/doubleclick.net/127.0.0.1):
I added the following at line 59:

address=/.localsites/127.0.0.1

This points anything.localsites to 127.0.0.1 (obviously change this to whatever you want)

Then I enabled the ‘no-hosts’ directive at line 92:
Change:

#no-hosts

to:

no-hosts

  1. Now we need to make dnsmasq run all the time and in the backgorund. I used a launchd script:

sudo nano /Library/LaunchDaemonscom.steamshift.dnsmasq

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.steamshift.dnsmasq</string>
        <key>ProgramArguments</key>
        <array>
                <string>/opt/local/sbin/dnsmasq</string>
                <string>-d</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
</dict>
</plist>

and save.

  1. Now run that file:

sudo launchctl load /Library/LaunchDaemons/com.steamshift.dnsmasq.plist

  1. Finally, in System Preferences > Network > Advanced… > DNS add 127.0.0.1 to the list of DNS servers.

Hopefully, if I haven't left out any steps, you should now be able to visit (for example, as set up above): mysite.localsites and be directed to your local apache server.

Please comment with your experiences with this!

SteamSHIFT out.

Update

After posting this, I received a helpful email from ‘Damian Bourne’ who pointed out the following:

Just read your blog entry on lookupd and dnsmasq.

I'm NOT saying anything bad about dnsmasq.. I use it lots of places.

I just wanted to let you know that lookupd was replaced with dscacheutil (as far as the command line is concerned), and that /etc/hosts still works.

I found that I didn't even need to flush the dns cache anymore for this to work, even when flip-flopping things around.

All the best,

Damian

Cool - another way, always useful. I think I will continue to use DNSMasq because of the wild card stuff, however, I have found one minor annoyance … which may force me back to /etc/hosts - if you don‘t have an internet connection, you can’t seem to point to a DNS server; Also when I am logged in via VPN to my uni network, I can't add my DNS server to the VPN network access. Hmm - any thoughts - please leave comments!

If like mine (until this morning) has been exibiting the behaviour of shutting itself down (with no prior warning) after 15 or so minutes running on battery power (but is fine when plugged into the mains); it could well be a battery problem. I took my (6 months out of warranty) machine into my local Apple Store this morning, was given a replacement battery and am now happily running on battery once more.

SteamSHIFT out.

bcf2000_1.2

It has taken some time, but I am pleased to present an update to our Virtual BCF2000 Application (original release post). The key features of this release are the removal of the requirement to use MidiPipe, and various bug fixes.

We have new customisable ‘Pro’ versions in the works - watch this space!

As before, enjoy (and if you use it let us know how we can make it better). SteamSHIFT out.

Technorati Tags:
VJ, quartz composer, midi, mac, osx, bcf2000, cocoa

A while back, I was doing some work with Arduino, passing serial data to the mac to a small application written with Processing which converted the serial data into MIDI data and pushed it out into other apps. Now Processing is a Java thing; and the standalone applications it creates are Java applications.

All fine, but a mere few days before an assessment, I couldn't get the Serial to Midi application to work; I recalled an article on createdigitalmotion.com which I admit, I didn't read fully, which said the following:

On the music side, Apple dumped its com.apple.audio.midi java package with 10.4.8. Result: not only do you lose all the features that make the Mac great for MIDI, like the IAC bus for inter-application MIDI routing, but your external devices also spontaneously disappear. Nice.

Now at this point, I put 2 + 2 together and got 5 … Apple have broken my app… Ahh what to do - revert my entire computer to 10.4.7?

So, I sat down and over the next few days and with much help, I managed to build (read: hack together) a serial to midi converter in Objective-C and Cocoa. Works perfectly (now!).

So, no more problem. Indeed. And not 1 day later, I remembered that I had bought an Java extension from Mandolane, which was needed for my original app. I reinstalled that and bingo, that worked too. Doh. Doh. Doh.

Oh well; I wanted to start learning Cocoa etc!

SteamSHIFT out.

Technorati Tags:
midi, mac, osx, art, experiments, developing, cocoa

DOH DOH DOH

How did I never notice the Add User / Edit User / Permissions in CocoaMySQL????

I was trying to hide it away; hit command-m and there the permissions box was! Now aside from the fact that command-m is a stoopid shortcut key to use (normally is for minimise), this is a great find; apparently it‘s only been there since Beta 0.7b5 … so upgrade if you’re not using that version.

SteamSHIFT out.

Technorati Tags:
mac, osx

Copyright © 2013 - Brothers Bennettw - Powered by Hexo
- Ported theme GreyShade -