Navigation | Projectsomewhere

April 29th, 2008

above the clouds



above the clouds, originally uploaded by michi.p.

sweet shot eh?

Filed by Popeye at April 29th, 2008 under Photography
No comments on this post yet

January 21st, 2008

Joining a list to make a long string

I’ve been having some performance issues with what should be an amazingly easy problem. I want to output a string with 8000 1 or 0 values space separated. I want to do this for a few thousand rows. The data is very sparse. I originally used numpy.zeros() thinking this would give me a big list of 0’s really quickly, which it does. My issue came about after I had populated the list with the appropriate 1’s, I was using along the lines of ” “.join([str(x) for x in row]). This conversion bit was terribly slow (that is, terribly slow when multiplied over thousands of rows and columns). My script was taking around 18 minutes to output all the data.

After trying some different methods I tried one of the simpler ones hoping it would work

r = “0″ * 8000
r[5] = 1

TypeError: ’str’ object does not support item assignment

Damn, next, lets try converting that string to a list, then assign. Works beautifully.

Now that we have a list of strings (we need to make sure that we’re assigning strings “1″ instead of integers now), we can just do ” “.join(r).

Total time for my script to run now? 16 seconds… don’t you hate it when it’s something so incredibly simple.

I should also put a note in here for those trying to use the python interface to FANN and running into issues with too much memory being used while training your neural network. Use the raw C interface instead, for some reason it’s so incredibly much more memory efficient.

Buy OEM Software

portland construction prices test

Filed by Popeye at January 21st, 2008 under Nerdy, Python
No comments on this post yet

January 14th, 2008

My market predictions for 2008

A lot of other bloggers who are much more qualified than I am have been writing about their predictions for the markets in 2008. I’m going to as well, mostly so that at the end of the year I can look back and see if I was right or wrong. As I’m not as qualified as other bloggers, my list will be shorter :)

  1. Oil is going UP… this has been my view for a long time now, and don’t see it stopping until there is a viable alternative fuel for cars.
  2. Soaring oil prices will increase the demand for alternative energy, expect some fairly major developments. Though nothing to suddenly fix the worlds problems.
  3. The US is going to have more hard times this year, subprime was just the trigger (and it is far from over yet) that will see more pain for the whole US economy.
  4. With the US going down Gold is going UP.
  5. US interest rates will keep falling.
  6. Commodities in general will continue going up.
  7. My bravest prediction is that the AUDUSD is going to get to parity with the USD.
  8. Expect strength in the EUR, JPY, CAD.
  9. Expect weakness in the GBP (particularly against the EUR), whether the EUR can maintain the strength for the whole year will be interesting.
  10. I see less political conflict for the year ahead. In the US elections the Americans will finally fix the mistake they made 4 years ago and the republicans will get their asses handed to them. Which will be a good thing for America and the world.

Sadly, the longer we go with exploiting natural resources the deeper the hole we’re digging, and the harder it is to climb out of it in 10, 20 or 50 years time.

It will be interesting to see how my predictions go, no doubt some of them will be incorrect, though hopefully some relatively safe options in there as well.

I hope you all have an enjoyable, prosperous and fun filled year.

Filed by Popeye at January 14th, 2008 under Finance, FOREX, Trading
No comments on this post yet

January 9th, 2008

Flash VideoError: 1005 Solution

I encountered this problem today with the FLVPlayback component in my Sailing Videos.org project and couldn’t find any helpful answers by searching.

The error that you get is along the lines of:

VideoError: 1005: Invalid xml: URL: "..." No root node found; if url is for an flv it must have .flv extension and take no parameters

The cause of the problem is with the SMIL functionality built into FLVPlayback, they have something along the lines of:

if (extension == ".flv"){
    // play video
}else{
    // it must be a SMIL file
}

So, the trick to getting video files to play that don’t have a .flv extension (eg. youtube videos) is to create a SMIL file that references the actual video, then you load the SMIL file which will load the video file…

A quick SMIL file that worked for me is below:
<smil>
<head>
<layout>
<root-layout width="240" height="180" />
</layout>
</head>
<body>
<video src="HTTP://WWW.EXAMPLE.COM/MYVIDEO?query=1" />
</body>
</smil>

It seems like a really stupid/lazy bit of coding on Adobe’s part… why can’t you check the mime type instead of relying on just the file extension??

Oh, while I’m posting about this, if you’re working in FlexBuilder on an Actionscript project and you want to get access to the fl.* classes then you’ll need to have Flash CS3 installed, then add the SWC’s (take a peek under “Drive/Program Files/Adobe/Adobe Flash CS3/en/Configuration/Components”) to your library path. Using FLVPlaybackAS3.swc with FlexBuilder Linux Alpha works well, I haven’t tried other swc’s.

Filed by Popeye at January 9th, 2008 under Flash, Actionscript 3
1 person have commented this post

Australia at the top of 49ers again

Nath and Ben have won the 49er worlds that have just finished in Melbourne (OK technically Sorrento), first time an Aussie has won the 49er worlds since Nicho won the last of his 3 worlds about 9 years ago.

Congrats to Nath, Ben and coach Emmett!

Top 10 are:

  1. AUS
  2. GBR
  3. UKR
  4. ITA
  5. USA
  6. ESP
  7. GER
  8. DEN
  9. GBR
  10. AUT

Hopefully this great performance carries through to Beijing!

Other aussies did quite well as well, Will and Jon did well finishing 18th, while Dave and Gooby won the silver fleet. Sadly Clynton and Joe had a bit of an ordinary regatta :( they finished in 50th.

My claim to fame (yeh it’s a rather piss poor one and it was some years back), the last aussie to beat Nath and Ben in the Aussie Nationals ;)

Filed by Popeye at January 9th, 2008 under Sailing
No comments on this post yet

January 8th, 2008

Top Gear prank

I’m a big fan of Top Gear (maybe the title is a little misleading(?) as it has very little to do with Top Gear), and saw this on BBC News, pretty funny if you ask me :) At least he took it well.

TV presenter Jeremy Clarkson has lost money after publishing his bank details in his newspaper column.

The Top Gear host revealed his account numbers after rubbishing the furore over the loss of 25 million people’s personal details on two computer discs.

He wanted to prove the story was a fuss about nothing.

But Clarkson admitted he was “wrong” after he discovered a reader had used the details to create a £500 direct debit to the charity Diabetes UK.

Clarkson published details of his Barclays account in the Sun newspaper, including his account number and sort code. He even told people how to find out his address.

“All you’ll be able to do with them is put money into my account. Not take it out. Honestly, I’ve never known such a palaver about nothing,” he told readers.

Read the rest…

Filed by Popeye at January 8th, 2008 under Nerdy
No comments on this post yet

January 7th, 2008

Leaving it to the last minute

The 29er and 49er worlds are currently on in Melb (ok, technically Sorrento thoguh close enough). Without a boat I’m not there, and well even if I had a boat, I’m not sure that I would’ve been there anyway, sailing around in emerald fleet just doesn’t excite me very much.

So I’ve been checking the results very often to see how everyone is going, Nath and Ben appear to be doing very nicely (winning qualification and at present leading gold fleet), Clynton and Joe are normally pretty reliable when it comes to sailing in breeze, though they tend to struggle in the lighter stuff, which unfortunately they had for the first couple of days.

Late saturday arvo I was sitting in Borders reading what actually seems to be a pretty good book The Clean Tech Revolution when I got a call asking me if I’d like to sail an 18 on sunday. I’ve had a really sore shoulder/back for a few days (you know the one you get from the computer?) so I was a little hesitant, until
I found out that there was absolutely no crew and they needed to just get the boat on the water. So with the offer of the tiller and not much work for me I figured that my shoulders should be ok. Next problem, finding crew, my brother was an easy find and was keen for the bow, I had hoped for Matteo (who has been crewing for me on the 49er) though he wasn’t due back from Coffs until later sunday arvo… a couple of others didn’t pan out and it looked like we might be trying to find someone in the boat park before sailing.

Then suddenly Jonathan (who normally sails the boat though is in Melb for the 29er worlds) rings to let me know that he has found me a great guy for the main. Excellent, now I just hope that I don’t f**k things up for my first go at driving an 18.

We turned up quite early, hoping that we could get the boat right near the ramp… 18’s weigh a ton and need to be carried on your shoulders into the water, so obviously being closer to the ramp would be a GREAT idea. Sadly a heap of boats beat us to it and we were stuck with a few boats between us and the ramp. After a bit of messing about rigging and trying to get the mast straightish (I’m talking about the track being straight) out of the mast we managed to get it looking ok, despite arriving terribly early we were still last boat off the beach, oh well at least there wasn’t much blocking us getting to the ramp ;)

We went out and had a quick test set, gybe and drop then it was time for a start. Our aim for the day was really just to get across the start line, and try to keep the boat in one piece, fortunately with about 12-15 knot nor-easter it wasn’t going to be the most challenging conditions. We racked up right behind Seven at the starboard end of the the line (yes, wrong end for a nor-easter, but it was going to be pretty clean there). We had to tack away fairly shortly after the start, when we came back we were actually doing ok… not up with the front guys, though we were mixing it fairly well with plenty of boats in the B bunch. first reach we played it well and picked up a few boats. Lost some on the work and run before doing ok on the next work and reaches to finish (considering it was my first time driving, my brothers first time on an 18 and the boat was meant to be a full back marker) pretty well. Luckily Kurt was very good on the boat and really helped keep it going quick, and mostly in the right direction.

In the end we finished 16th over the line and 5th on handicap, so we were pretty happy :)

It was suggested to put my name down for a boat for next season, I’ll give it some thought, though to be honest there must be good reasons why other people are so reluctant… it was great fun though logistically… for starters the little Peugeot won’t pull an 18… even if it had a towbar!

Filed by Popeye at January 7th, 2008 under Sailing
No comments on this post yet

January 3rd, 2008

Automated Trading Championships 2007

I’m a little late on the blog posting, though the Automated Trading Championships for 2007 finished just before christmas, I ended up 35th, which I’m actually fairly happy with, my main goal was to be profitable (which I was), and next year maybe I can work on a better EA.

I had a guy ask me if I’d share my EA and I thought what the hell why not, I sent it to him and thought some of you might be interested in it (it’s really not rocket science and my interview outlined everything in it).

Read the next little bit and then you can download it.

For the championship it was on a daily USD/CAD chart, though it will probably work ok on any currency pair that shows reasonable trending characteristics.

A major word of warning, this EA has risk set at stupid levels (I think you need to in order to have a chance of winning a competition like the ATC). So don’t even consider using it with real money unless you do a
few things:

  1. have extremely low leverage.
  2. significantly reduce the amount risked.
  3. there is hardly any code, make sure you understand it fully.
  4. modify it so that it will only enter on the first breakout (this is more to reduce an initial losing position, over the long term it shouldn’t matter).

When you do those things it should be profitable in the long term (months), though absolutely no guarantees :)

I should also mention, that if you do the above and have this online 24/7 you’ll lose more money in electricity (not to mention doing more than your fair share to make the world a hotter place) than you will make unless you have a significant amount of money.

If you’ve got questions, comments or just want to say thanks feel free to add a comment.

Feel free to modify and redistribute, some credit would be nice :)

pikkumql4.zip (unzip this into your metatrader experts directory).

Filed by Popeye at January 3rd, 2008 under FOREX, Trading
No comments on this post yet

Actionscript 3 dispatch a custom Event

Don’t you hate it when you’re searching for something that should be really easy to find and implement though for the life of you you can’t find a good example?

I’ve just spent a fair amount of time trying to find a good example of dispatching a custom event in actionscript 3… mostly without any luck, at long last after a lot of searching I found a link in a comment on assertTrue which pointed me towards the Flex documentation… after which I was able to find something that helped.

So, to help those of you that might possibly be searching, and also no doubt to remind me when I next forget how to do it… below is how to dispatch a custom event class in Actionscript 3.

Firstly lets create the custom event class that will be dispatched, in my case what I wanted to do was to create a custom data loading status event. I probably could have instead used existing event classes to achieve the same thing, though it’s about time that I really nailed dispatching custom event classes.

package projectsomewhere.events

{

 import flash.events.Event;

 public class DataEvent extends Event{

 	public static var LOADED:String = "loaded";

 	public static var LOADING:String = "loading";

 	public function DataEvent(type:String):void{

 		super(type, true); // remove true if you don't want your event to bubble

 	}

 	override public function clone():Event {

 		return new DataEvent(type);

 	}

 }

}

Now to actually dispatch this event… it’s rather simple!

When the program starts loading the data I run the following piece of code:

this.dispatchEvent(new DataEvent(DataEvent.LOADING));

When the data has loaded I execute this bit of code:

this.dispatchEvent(new DataEvent(DataEvent.LOADED));

Now to listen for these events is simple, just add along the lines of the following:

this.loaderobject.addEventListener(DataEvent.LOADING, itsLoading);

this.loaderobject.addEventListener(DataEvent.LOADED, itsLoaded);

What you can do with your new custom event class is that you can then add custom properties and methods to it which are then available within your event handler. As an example, I could set a data property which I populate with the data prior to dispatching, then my event handlers can get easy access to the data that has been loaded.

When we are listening for and dispatching our events we could just as easily use “loading” instead of DataEvent.LOADING, this wouldn’t be a great idea though as the compiler will pick up on a typo for the latter… not for the former (bug heaven). As the docs say:

These constants provide an easy way to refer to specific event types. You should use these constants instead of the strings they represent. If you misspell a constant name in your code, the compiler will catch the mistake, but if you instead use strings, a typographical error may not manifest at compile time and could lead to unexpected behavior that could be difficult to debug. For example, when adding an event listener, use the following code:
myDisplayObject.addEventListener(MouseEvent.CLICK, clickHandler);
rather than:
myDisplayObject.addEventListener("click", clickHandler);

Filed by Popeye at January 3rd, 2008 under Flash, Flex, Actionscript 3
No comments on this post yet

December 19th, 2007

Flash Development on Linux

I’ve known about Eclipse for a LONG time and I even downloaded it once or twice and fiddled with it, though I couldn’t ever get myself to use it as other editors (my favourites are jEdit and Eric) were slimmer and did what I needed, recently I’ve been playing with Actionscript 3 (Flash development) and have come to quite like FlexBuilder 2 which is basically Adobe’s editor built on top of Eclipse and so I’ve been trialiing Eclipse again for my other development (predominantly Python and HTML, actually I haven’t yet looked deeply into eclipse HTML plugins). I’m quite happy with it. Today I finally got around to downloading the Adobe alpha Linux FlexBuilder plugin for Eclipse and have to say I’m rather happy, all my development can now happen within the one IDE and I don’t need to use Windows for the Flash development.

Filed by Popeye at December 19th, 2007 under Nerdy, Linux, Flash, Flex, Actionscript 3
No comments on this post yet