r3dux.org

A number-pimping side project from the valleys in *NEW* upside-down flavour.

  • Home
  • ABOUT
  • OLD SITE
  • SEARCH
  • FEEDBACK

Perfect Form

r3dux | May 18, 2010

Perfect Form

Comments
No Comments »
Categories
Imagery
Tags
Couch, Dive, TV
Comments rss Comments rss
Trackback Trackback

Bananas and Monkeys

r3dux | May 17, 2010

Found this when I hit StumbleUpon the other day and it made me grin, so I thought I’d share.. (original source unknown btw, even by the place I found it!):

Start with a cage containing five monkeys.

Inside the cage, hang a banana on a string and place a set of stairs under it. Before long, a monkey will go to the stairs and start to climb towards the banana. As soon as he touches the stairs, spray all of the other monkeys with cold water.

After a while, another monkey makes an attempt with the same result – all the other monkeys are sprayed with cold water. Pretty soon, when another monkey tries to climb the stairs, the other monkeys will try to prevent it.

Now, put away the cold water. Remove one monkey from the cage and replace it with a new one. The new monkey sees the banana and wants to climb the stairs. To his surprise and horror, all of the other monkeys attack him.

After another attempt and attack, he knows that if he tries to climb the stairs, he will be assaulted.

Next, remove another of the original five monkeys and replace it with a new one. The newcomer goes to the stairs and is attacked. The previous newcomer takes part in the punishment with enthusiasm! Likewise, replace a third original monkey with a new one, then a fourth, then the fifth. Every time the newest monkey takes to the stairs, he is attacked.

Most of the monkeys that are beating him have no idea why they were not permitted to climb the stairs or why they are participating in the beating of the newest monkey.

After replacing all the original monkeys, none of the remaining monkeys have ever been sprayed with cold water. Nevertheless, no monkey ever again approaches the stairs to try for the banana. Why not? Because as far as they know that’s the way it’s always been done round here.

And that, my friends, is how company policies are made.

I think there’s more than a grain of truth in that…

Comments
No Comments »
Categories
Humour, Life
Tags
Bananas, Company Policy, Monkeys
Comments rss Comments rss
Trackback Trackback

How-To: Install or Build a Working Version of Handbrake for Ubuntu

r3dux | May 16, 2010

Update: To install a working version of Handbrake in Ubuntu 10.10 or 11.04, you’ll need to install from the PPA, and you’re probably best off doing so like this…

First, you’ll need to add the Handbrake PPA (personal package archive) to your Ubuntu system. Open up a Terminal window and use this command:
For the official builds:

sudo add-apt-repository ppa:stebbins/handbrake-releases

Or for the nightly builds:

sudo add-apt-repository ppa:stebbins/handbrake-snapshots

After the repository has been added, update your system’s listing of its repositories with this command:

sudo apt-get update

Once the repository listings have been updated, you can then install the graphical version of Handbrake with this command:

sudo apt-get install handbrake-gtk

You can also install the command line version of Handbrake with this command:

sudo apt-get install handbrake-cli

Props to Jonathon Moeller for his write up on this 10.10 technique.


If You’re Still Want to Build Your Own Copy However…

The currently available pre-packaged version of Handbrake (the Video/DVD transcoder/ripper) at the time of writing is 0.9.4 (actual filename for the 64-bit version: HandBrake-0.9.4-Ubuntu_GUI_x86_64.deb) – and it’s about as much use as a chocolate teapot on Ubuntu 10.04… You simply can’t endcode/transcode with it because it’s broken, with the Add to Queue and Start buttons permanently greyed out because the functionality behind them is mashed.

So let’s build a fresh version that works!

Step 1.) Get the Necessary Libraries

A quick trip to the command line will get everything you need (where everything you already have in this list is simply ignored):

sudo apt-get install subversion yasm build-essential autoconf libtool zlib1g-dev libbz2-dev intltool libglib2.0-dev libdbus-glib-1-dev libgtk2.0-dev libgudev-1.0-dev libwebkit-dev libnotify-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

Step 2.) Get the Source Code

Create a folder for it, move to it, then grab the latest source code via subversion like this:

mkdir handbrake
cd handbrake
svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk

Step 3.) Build It!

Once we’re in the right place, this configure line with the given switch will configure and make Handbrake in one fell swoop:

cd hb-trunk
./configure --launch

Step 4.) Test It!

After a successful build, you’ll see the executable HandBrake-CLI in the build folder – but you’re probably after the GUI version, which is tucked away in build/gtk/src and called ghb – just go to the right folder, launch it and give it a try out – should be absolutely mint.

There are a stack of different options for the encoding process which can slow down the encode/transcode process and increase the quality – I went with these final settings to get high encoding quality without the encode process taking all week:

ref=2:bframes=2:subme=6:trellis=2:b-pyramid=1:b-adapt=2:direct=auto:no-fast-pskip=1
HandBrake - Working

HandBrake - Now Working! Woo-Hoo!

Cheers!

Comments
11 Comments »
Categories
How-To, Linux
Tags
10.04, build, DVD, Encode, HandBrake, Source, Subversion, SVN, Transcode, Ubuntu
Comments rss Comments rss
Trackback Trackback

ActionScript 3: How to use Event Listeners to Call Functions with Parameters

r3dux | May 15, 2010

By default, you can’t. But there’s a way around it so you can by creating a custom event class! In this case, I’m going to deal with extending the Timer class to create a custom timer class with additional properties that we can use to pass data to functions.

The Problem

To demonstrate the problem, consider the following simple timer code:

var greetTimer:Timer = new Timer(3000, 1);
greetTimer.addEventListener(TimerEvent.TIMER, greet);
greetTimer.start();
 
function greet(e:TimerEvent):void
{
	trace("Hello!");
}

This will work just fine – it’ll call the greet function once to output “Hello!” three seconds after the timer was started. But what if I wanted to say “Hello, SOME_NAME_STRING”, like “Hello, Bob!”, well you might think you could just do something like this:

var name:String = "Bob";
 
var greetTimer:Timer = new Timer(3000);
greetTimer.addEventListener(TimerEvent.TIMER, greet(name));
greetTimer.start();
 
function greet(e:TimerEvent, theName:String):void
{
	trace("Hello, " + theName + "!");
}

But you CAN’T! ActionScript 3 doesn’t allow you to pass parameters other than the TIMER event (i.e. the timer going off) to functions which are bound to a timer. And even changing the order of the parameters, or using a line such as the one below simply won’t work:

greetTimer.addEventListener(TimerEvent.TIMER, greet, name);

The Solution

Now, there are things you can do like use intermediate functions which might call a second function, or using anonymous in-line functions (there’s a good forum thread on it here if you want to investigate that route) – but there’s a better way of doing it: We can just create our own custom Timer class!

For this simple text example we could use something like this:

Custom Timer Class (String version) Code:

package
{
	// Import required libraries
	import flash.utils.Timer;
 
	public class cTimer extends Timer
	{
		// Create a property for our cTimer class which can be used to store a String
		public var firstName:String;
 
		// Constructor function
		public function cTimer(theDelay:Number, theRepeatCount:int, theFirstName:String):void
		{
			// Create a normal timer using the Timer class' constructor
			super(theDelay, theRepeatCount);
 
			// Set our firstName property to what was passed to our cTimer constructor
			this.firstName = theFirstName;
 
		} // End of constructor
 
	} // End of class
 
} // End of package

And then we could use our custom timer like this:

Flash File Code:

// Import our custom timer class for use
import cTimer;
 
var greetTimer:Timer = new cTimer(3000, 1, "Bob");
greetTimer.addEventListener(TimerEvent.TIMER, greet);
greetTimer.start();
 
function greet(e:TimerEvent):void
{
	trace("Hello, " + e.currentTarget.firstName + "!");
}

This will print out “Hello, Bob!” just fine using the additional property in our custom timer class! :)

Now that’s all well and good, but most people want to modify some manner of DisplayObject (Sprite, MovieClip etc.) when the timer fires, so for that we can just modify our custom timer class to expect a DisplayObject like this:

Custom Timer Class (DisplayObject version) Code:

package
{
	// Import required libraries
	import flash.utils.Timer;
	import flash.display.DisplayObject;
 
	public class cTimer extends Timer
	{
		// Create a property for our cTimer class which can be used to store a DisplayObject
		public var timerTarget:DisplayObject;
 
		// Constructor function
		public function cTimer(theDelay:Number, theRepeatCount:int, theTimerTarget:DisplayObject):void
		{
			// Create a normal timer using the Timer class' constructor
			super(theDelay, theRepeatCount);
 
			// Set our timerTarget to what was passed to our cTimer constructor
			this.timerTarget = theTimerTarget;
 
		} // End of constructor
 
	} // End of class
 
} // End of package

Flash File Code:

// Import our custom timer class for use
import cTimer;
 
// Create a simple circle centered on the stage and fully transparent
var circle_mc:Circle = new Circle();
circle_mc.x = 275;
circle_mc.y = 200;
circle_mc.alpha = 0;
addChild(circle_mc);
 
// Create a custom timer which does everything a timer does, but also stores a DisplayObject
var circleFadeInTimer:cTimer = new cTimer(2000, 1, circle_mc);
circleFadeInTimer.addEventListener(TimerEvent.TIMER, fadeIn);
circleFadeInTimer.start();
 
// Function to make the circle visible
function fadeIn(e:TimerEvent):void
{
	// Using our timerTarget property of our custom timer class (cTimer) modify the DisplayObject
	e.currentTarget.timerTarget.alpha = 1;	
}

Note: The above code assumes you’ve created a symbol with the class name “Circle” – to do so just draw a circle on the stage, stab F8 to convert it to a symbol, and check the Export for ActionScript checkbox and enter Circle as the class name before hitting the [OK] button.

Just like our String example, adding the additional property to our custom timer class allows us to bind the timer to a specific object which we can then manipulate from the function called when the timer fires! So in this case, two seconds after the timer starts our fadeIn function will be called and our circle instance will have its alpha property set to 1 (so it’s fully opaque – hence visible!).

Wrap Up

I came up against this problem whilst helping out some of my ActionScript students who are first-time coders, so wanted to code more Procedurally than Object-Oriented. When you use OOP there are better ways of going about things, but this is still a useful trick to know when you’re dealing with Event Listeners and Timers. I hope it helps out anyone who’s been banging their head against this problem! Cheers!

Comments
1 Comment »
Categories
Coding
Tags
ActionScript, addEventListener, Class, Custom, Events, Functions, Parameters, Pass, Passing, Timer, TimerEvent
Comments rss Comments rss
Trackback Trackback

Clever Job Hunting

r3dux | May 14, 2010
YouTube Preview Image

And fair play – I think he really deserves it :)

Comments
No Comments »
Categories
Life, Tech
Tags
AdWords, Clever, Google, Job, Jobs, Marketing
Comments rss Comments rss
Trackback Trackback

« Previous Entries Next Entries »

Translate

Categories

Archives

Tags

3D ActionScript ActionScript 3.0 Adobe AI Ballarat Bash C++ Class Convert CS4 Effect Error Film Flash GLSL Gnome Hack How-To install Jaunty Java Kinect Linkage Linux Mash-Up Microsoft Motion OpenGL Particle Problem PS3 Remix Retro script Slides Sound Systems Texture Ubuntu Video VirtualBox Wii Windows XBox

Gamercard

OpenR3dux

Misc.

Flattr this

RSS Feed

r3dux twitter feed



“Non-sequiturs make me eat lampshades.”

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox