Friday, November 30, 2012

Streaming a FLV video with AS3/Flash/Flex from a URL without a Streaming Server

Here's a code snippet to stream a FLV from a random source without a RTMP streaming server like Red 5/ FMS.

//You'll have to add the necessary imports

private var _video:Video; //Our video object

_video = new Video(640, 480);

private var _netConnection:NetConnection = new NetConnection();
_netConnection.connect(null); //No need of specifying a RTMP server!

private var _ns:NetStream = new NetStream(_netConnection);

_ns.addEventListener(NetStatusEvent.NET_STATUS, handleNetStatusPlay, false, 0, true);

_video.attachNetStream(_ns); //Attach our NetStream to our video object

_ns.client = new NetStreamUserClient(_ns);
var streamPath:String = "";;

//Handle our NetStatusEvent
private function handleNetStatusPlay(e:NetStatusEvent):void

 if ( == "error")
  if ( == "NetStream.Play.StreamNotFound")
   trace("FLV file does not exist!");

Code for NetStreamUserClient
  * ...
  * @author Rajesh Peter Douglas D'Monte
 public class NetStreamUserClient
  public function NetStreamUserClient()
  public function onCuePoint(infoObject:Object):void
   trace("onCuePoint" + infoObject);
  public function onMetaData(infoObject:Object):void
   trace("onMetaData " + infoObject);
  public function onPlayStatus(infoObject:Object):void
   trace("onPlayStatus " + infoObject);
   if (infoObject.code == "NetStream.Play.Complete")
    //FLV finished playing
There are some formatting issues 'cause I haven't figured out how to display code properly on my blog.

Thursday, November 29, 2012

Super user (su) on Ubuntu Linux

This post is going to be very brief. I know a lot of you already know all this and more but I still have many friends who come and ask me how to access the Super User on Ubuntu Linux.

They tell me that it keeps asking them for a password and then the blessed thing doesn't seem to login with their password. This is because they have set a password for themselves but not the root, though sudo would work nicely but some chaps want to be fancy and go all su on Ubuntu.

So why does su not work with the password you set during Ubuntu's gui setup?
This is because the super user password is NOT set. I repeat is NOT set by you during Ubuntu's GUI installation. Is it blank? No! Some random password is set for security purposes.

Alright! So how the devil do you access su without going through some mucky cumbersome process of setting root's password.


Go to the terminal (Ctrl + alt + T) (Default for Ubuntu Linux) and punch this in:

$ sudo su
[The system now prompts you for your user password. Enter it Einstein!]

Et voila! You are now in root in the current terminal session!

Note: This method still doesn't set super user's password.
Disclaimer: I am by no means an expert on Linux or the Unix family of operating systems. 'Nuff said.
Zoit: I am a n00b at Linux.

The 7 Deadly Sins & A Successful Website

I read this a while back from somewhere I can't quite remember but maybe I thought of it on my own. Whichever way you look at it, this is probably insightful for those of you who are looking at starting a successful website or business. Yes this applies to businesses as well.

Q1: When can you say your business is successful?

A1: When it makes the monies.

Q2: How do you get there?
A2: You address a need

Q3: WTF, but them peoples all got food, clothing and shelter (I guess you are targeting the part of the human population that ACTUALLY has the monies to spend) So what need do I need to address?
A3: If you are creative and intelligent you can address a need like the way Edison (God rest his soul) built the light bulb. So go find some part of human life that can be made better and you could get a successful business running mehn!

Q4: Blah, I'm dumb. My middle name is stupid and my last name is sloth what now?
A4: Prey on any of the 7 deadly sins (Sounding as cliche as possible my brotha')

Blah blah blah.. yeah so..

Look at all the successful sites around you, most of them if not all prey on three or more of the 7 deadly sins.
Examples include Facebook, MySpace etc

Facebook is fueled by envy and pride among other deadly sins. I'm not dissing the site, it also has a lot of nice nice merits like keeping people connected and shit like that but hey, most of the *h*** you k*** that use it go on th*** and get h****** on for obvious reasons. (I've censored some of this koohawky 'cause I didn't want to s***d s*****)

Oh and here's a list of the 7 deadly sins for those of us that didn't attend Sunday Catechism class.
Lust, gluttony, pride, envy, greed, sloth and wrath.

Have at it:

So you want to make the monies? Want to get kazillions of hits a day on your all so awesome website? Go prey on your friends worst. Would I do this? Maybe. I don't really know, I don't really go out of my way and ask myself, How can I make my project prey on my friends worst? I just build what I find fun to build.

That's all.


ZOIT: What I told my friend when I wrote this blog post: Mehn, I'm writing useful shit and all man.

Updating an Azure Service Project when Publishing fails

This post is for Windows Azure users who are using Windows Azure PowerShell cmdlets to fool around with your Azure Service's

Tally ho:
In case for some reason Publish-AzureServiceProject returns a bunch of cryptic errors that you don't care to understand. I would strongly recommend using Set-AzureDeployment.

Set-AzureDeployment requires a properly rebuilt cspkg Package. There are various ways that you can google to know how to rebuild the cspkg. I simply issue a Publish-AzureServiceProject command and when it reaches the uploading part, I ctrl-c and that exits the process prematurely without it going through the whole rigmarole and then getting stuck at those aforementioned cryptic errors.

Oh and make sure you use the -Force command when calling Set-AzureDeployment.

And here's a bloody good example (or so I like to think):

PS X:\ProjectsAndShit\MyServiceProjectFolder> set-azuredeployment -Upgrade -ServiceName "MyService" -Mode Auto -Package "X:\ProjectsAndShit\MyServiceProjectFolder\cloud_package.cspkg" -Configuration "X:\ProjectsAndShit\MyServiceProjectFolder\ServiceConfiguration.Cloud.cscfg" -Force

The above command (change paths and project name etc where ever applicable [like D'oh]) will do its mumbo jumbo and then ask you to enter a Slot. You have a choice, Production or Staging and you choose whatever the hell fits your bill. (Red pill/Blue pill sorta thing). Like so...

Slot: Production

That's it. Hope this helps you peoples!