Move An Existing Git Repository Into Bitbucket In 3 Steps

Thanks to my good friend Simon I've been a happy git user for a few months now. I installed my own git server on Amazon EC2 using Ubuntu, git and gitolite and just fired it up once or twice a day to push and pull. This worked out fine but with more and more easy to use git hosting services springing up I gave Atlassian's bitbucket a try since it offers unlimited private repositories which is a bonus.

It took me a little while to figure out how to move my existing repository into bitbucket, especially since it was already tracking the existing remote repo on my server. What follows are a few easy steps that describe the process - but note that you follow along at your own risk.

› Read Full Article


Easily Monitor Log File Output in OSX Terminal (tail -F)

Here's a quick tip that is a real time saver in some situations. As a developer you often come across programs, tools or servers that produce output in form of a log file. Or maybe - and this includes myself - you use logs for debugging purposes.

In ColdFusion for example I regularly find myself adding cflog tags to my code in order to get a view into what my code is doing. Having to open and close log files constantly can be tedious at best, but luckily there is a really simple way of displaying a live view of the most recent entries using the standard Unix tail -F command.

Whereas tail on its own simply displays the last part of a file, the -F option will not stop when the end of the file is reached but will keep monitoring the file for new lines and displaying them, thereby giving you effectively a live console view into the file.

Taking ColdFusion logs as an example, here's how you'd monitor a particular log file (mine are typically named according to the site or application I am working on):

view plain
1cd /Applications/ColdFusion9/logs/
2tail -F playingornot.log
3"Information","jrpp-4","02/21/12","17:40:30","PLAYINGORNOT","/index.cfm"
4"Information","jrpp-5","02/21/12","17:40:33","PLAYINGORNOT","/index.cfm"
5"Information","jrpp-5","02/21/12","17:40:35","PLAYINGORNOT","/cfc/Auth.cfc"
6"Information","jrpp-5","02/21/12","17:40:35","PLAYINGORNOT","/cfc/Players.cfc"
7"Information","jrpp-5","02/21/12","17:40:36","PLAYINGORNOT","/cfc/PlayTimes.cfc"
8"Information","jrpp-1","02/28/12","09:37:37","PLAYINGORNOT","/index.cfm"
9"Information","jrpp-1","02/28/12","09:37:40","PLAYINGORNOT","/cfc/Auth.cfc"
10"Information","jrpp-1","02/28/12","09:37:41","PLAYINGORNOT","/cfc/Players.cfc"
11"Information","jrpp-1","02/28/12","09:37:42","PLAYINGORNOT","/cfc/PlayTimes.cfc"
12"Information","jrpp-2","02/28/12","09:40:30","PLAYINGORNOT","/cfc/PlayTimes.cfc"

As my application runs I can see new entries being displayed in real time in my log file - very handy. This particular log is produced by adding

view plain
1<cflog file="#this.name#" type="information" text="#arguments.targetPage#">
to my Application.cfc's OnRequestStart handler.

This technique works for any kind of text based log file on operating systems that have the tail command or similar available.


Installing git and gitolite on Ubuntu 11.10

Don't ask me how I did it (ok, you can ask, in fact I'm going to tell you...), but somehow I now have a remote git server and gitolite for repo and user administration installed and running on Ubuntu 11.10 using an Amazon EC2 Micro instance.

I've spent all morning on this, tested it on 3 different instances (I love it how you can just throw away an EC2 instance and start again with a new one in a matter of minutes) and have kept a log of the steps which got me there. Please note that there may be errors or illogical jumps in this summary, but maybe it will be helpful nonetheless - or it may even work outright, who knows.

BEfore we get started, here are some links that helped me (but note I had to pick some steps from some links, and other steps from others...). In particular I did not clone gitolite to my local machine (as this post suggests but ended up using

view plain
1sudo apt-get install git

Links I used:
git + gitolite + git-daemon + gitweb setup on Ubuntu 11.10 server
How to setup git server using gitolite in Ubuntu 11.10 Oneiric
Install Gitolite To Manage Your Git Repositories

First of all, get yourself an instance of Ubuntu (you may swap this for your preferred Linux distro). If you are in love with EC2 then head over to alestic.com and click the selection at the top of the page (I'm using the us-east region), and then pick your preferred image.

The neat thing is that if you already have an Amazon Web Services account you can launch your instance with virtually one click, very neat. I picked the Ubuntu 11.10 Oneiric EBS boot image, 64 bit.

Once booted, SSH into your instance (consult other blogs for details on this if you need help).

› Read Full Article


Uploading Files To Amazon S3 With ColdFusion

Since version 9.0.1 (if I am not mistaken) ColdFusion supports Amazon's S3 file storage pretty much out of the box. The complexities of access control to your bucket is abstracted away and you can use S3 almost like a local file system. You can read more about it in the CF docs and on Ray Camden's blog.

My task at hand was to accept user submitted file uploads and store them in S3. According to the CF documentation the full set of cffile operations is supported, however I could not get it to work.
The following failed for me with a 'destination invalid' error:

view plain
1<cfset mydir = "s3://media.mysite.com/logos">
2<cffile action="upload" filefield="logo" destination="#mydir#" nameconflict="makeunique" charset="utf-8" />

Please note that in order for the s3:// syntax to resolve to your bucket you need to follow some setup steps which I won't cover here. Also watch out for a bug related to setting metadata.

› Read Full Article


Shorthand For Sorting ArrayCollections In ActionScript & Flex

Here is a tip containing a quicker way to sort an ArrayCollection in ActionScript by using the underlying Array sortOn method. By quick I mean less code - I make no statement about performance.

Normally to sort an ArrayCollection you would need to create instances of both the Sort and SortField classes to arrive at something like this (untested code to give you an idea):

view plain
1var sort:Sort = new Sort();
2var sortField:SortField = new SortField();
3sortField.name = "myFieldName";
4sortField.numeric = true;
5sortField.descending = true;
6
7myCollection.sort = sort;
8myCollection.refresh();

However since the source property of the ArrayCollection class points to the Array that acts as the source of the Arraycollection's data you can mess with it if you like (it's a bit naughty as you are not meant to do this and your mileage may vary).

So therefore to sort the above example 'myCollection' numerically by 'myFieldName' you could to this:

view plain
1myCollection.source.sortOn('myFieldName', Array.DESCENDING | Array.NUMERIC );
2myCollection.refresh();

I'm sure someone will tell me off for this but here you go. This worked for me for my purposes and it seems a lot simpler. And I like simple things.


Converting And Editing AVCHD (.mts) Files On OSX

A quick note about this article: I chose a slightly misleading title in order to help people find it more easily as most would not know that a search for 'rewrapping .mts files' is what they may be after.

This post is about rewrapping .mts files to make them compatible with QuickTime; it is not about re-encoding or editing .mts files (but rewrapping will make them editable using most common video editing tools).

Many common camcorders and digital cameras - in particular Panasonic and Sony models - produce video files in AVCHD format, with file extension .mts, .m2ts or .m2t. These files often do not play back natively unless you install a third party video player such as VLC.

I was getting a bit annoyed at the fact that quick preview in Finder would not work with .mts files and that the format is generally a bit of a nuisance (iMovie for example won't find any compatible files if you tell it to look in a folder that only contains .mts files). Moreover I was looking to stitch some clips together which in turn was made more difficult by the .mts format.

› Read Full Article


Enable Ping ICMP Replies For Amazon EC2 Windows Instances

Here's a quick tip on how to configure a Windows Amazon instance to successfully respond to ping requests.

By default an EC2 security group does not allow ICMP ping requests, and in some cases the internal Windows firewall will also block it. You therefore should check both settings if you want to be able to ping your EC2 Windows instance.

Step 1: Check Windows Firewall Settings
To enable the Windows firewall to allow ping request check that under 'Inbound Rules' the setting 'File and Printer Sharing (Echo Request - ICMPv4-In)' is enabled. The icon should turn green if the rule is enabled.
Alternatively you can use the commandline option:

view plain
1netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow

This should take care of the Windows firewall.

› Read Full Article


Adding event sounds to the Chat Component (by Gani)

In this tutorial we will be explaining how to add a sound in the chat component so that when a message is received or sent it will be played.

First of all, open up your application and in the first frame create the code for the sound object that will be played.

You are going to need a sound to play, so go ahead and bring a sound into your library that you would like to be played when you send and/or receive a message . Once you have the sound file imported, right click on it in the library and choose linkage. Enter a name for your sound and press ok.


In this example the name of our sound is 'chimes'

Now we need to create the sound object.

chatSound = new Sound();
chatSound.attachSound("chimes");

The next thing we need to do is make the function that will play the sound.

function playSound(){
   chatSound.start();
}


Click an instance of the chat component onto the stage, rightClick on it, select 'edit in place' and find the layer called actions. Select the first frame to reveal its code in the actionscript editor.

You have to find the following two functions
FCChatClass.prototype.receiveMessage = function( mesg ) and
FCChatClass.prototype.sendMessage = function(mesg)

You need to add the following line of code to the sendMessage function:
   _root.playSound();

You should also place the following piece of code inside the receiveMessage function. This will check to make sure that the sound does not play when the message is coming from yourself but only when it comes for another user.
if(mesg.slice(25,this.username.length+25)!=this.username){
   _root.playSound();
}


The completed code should look like this:
FCChatClass.prototype.receiveMessage = function( mesg ) {
   this.history_txt.htmlText += mesg;
   this.history_txt.scroll = this.history_txt.maxscroll;
   if(mesg.slice(25,this.username.length+25)!=this.username){
      _root.playSound();
   }
}

FCChatClass.prototype.sendMessage = function(mesg) {
   this.nc.call( "FCChat." + this.name + ".sendMessage", null,    this.message_txt.text );
   this.message_txt.text = "";
   _root.playSound();
};

You're done. (and keep the sounds subtle or we won't visit your app ;-)


Running Flashcom Server alongside IIS

If you are running your own webserver and maybe have bought a Flashcom license alongside it then you might be tempted to run both your webserver and flashcom apps on the same box. And why not, after all we don't all have multiple machines at our disposal.

The following configuration is one that I have set up several times. I am running IIS (Microsoft's Internet Information Server) and FCS (Flash Communication Server 1.5.2) on the same server which uses Windows 2000 Server as its OS.
It's possible to use other webservers like Apache for this but in this tutorial I will focus on IIS and FCS on Windows so keep that in mind if your setup is different.

The principles behind it are the same on any server: we want FCS to use other ports than the standard 1935 because we want to use http tunneling. As you might know tunneling uses port 80 (usually used for 'normal' http website traffic) or port 443 which is common for SSL traffic. Both ports are often open on firewalls hence the tunneling there ;-)

The problem is that no two services on one IP address (read: our machine) can use the same port - we would end up having FCS and IIS competing for port 80, and one service would win. Should FCS start up before IIS then it might grab port 80 and not allow any website (IIS) traffic through it, effectively making any website unavailable. that's when you would get the alert in IIS saying 'address is already in use'. Let that be your warning sign.

The whole problem is easily solved in a few steps.

Step 1 - Assign a second IP address to your server
If your server is hosted remotely simply ask your hosting provider for a second IP. Sometimes they charge for this but it's usually a $10 one off fee, that's all. Your host might ask you why you want the secondary IP, tell them you want to run 2 services on port 80.
If you are running your own server then assign a secondary IP yourself, how this is done is beyond the scope of this article. You'll find this information on the net.

Step 2 - Stop IIS grabbing all available IPs
By default IIs will bind to all IP addresses it can find. To prevent this from happening you need to disable socket pooling in IIS. This is quite easily done and you can see a full description in this article.

Addition: since this tutorial was released I have also installed FCS on Windows 2003 Server and the process of stopping IIS grabbing all IPs is different to Windows 2000. You need to use a utility called httpcfg.exe, read about it here.
The following steps apply to Windows 2000 as well as Windows 2003.

Step 3 - Bind IIS to one IP address
For example say your host has assigned the following two IP addresses to your server: 123.123.123.1 and 123.123.123.2. We decide we want to bind 123.123.123.1 to IIS.
To do this open Internet Information Services Manager (start > control panel > Administrative Tools > Internet Information Services). Right-click on the first website listed and select 'Properties'. The following panel (or similar) should pop up:


In the dropdown next to 'IP Address' you can now select one of all IP addresses available on this machine. You should select the one of the two you have available. Also add any host headers if necessary and repeat this process for every site on your server, always making sure that no site has (All Unassigned) selected. Each site should bind to the same IP address, we will later bind FCS to the other.
For information on host headers consult the Microsoft website. You should know how these work if you run your own webserver.

Step 4 - Bind FCS to the other IP address
We are almost done. IP addresses in FCS are configured via a file called Adaptor.xml. You can bind FCS to any IP or all IPs available. By default FCS tries to bind to all IPs available so we need to edit the Adaptor.xml file to change this. Adaptor.xml is inside the conf\_defaultRoot_directory. Open it for edit.
Find the <HostPort>:1935</HostPort> tag. In this case FCS binds to port 1935 on any IP address. In our example we want it to bind to 123.123.123.2 on port 1935, 80 and 443.

Therefore our host tag should look like this:
<HostPort>123.123.123.2:1935,80,443</HostPort>

Save the file, restart FCS, restart IIS and you are done. You can now run websites and FCS on the same machine with http tunneling fully functional.

I *think* that the admin port 1111 for FCS will still bind to both IPs but this won't affect IIS in any way. Also I you do not want to use tunneling then IIS and FCS live happily alongside on a single IP.


Configuring Flashcom Server with multiple vhosts

Time for a new tutorial and this time I will try and explain how you set up and configure your Flashcom Server with multiple vhosts. It should be noted that only the Professional Edition supports vhosts so if you run the Developer or Personal Edition then you will not be able to add additional vhosts. Dev and Personal Edition will only run apps under the _defaultVhost_

The following steps apply to the Windows version of Flashcom Server but apart from Windows style filepaths you can take a lot away from this tutorial for Linux installations, too.

Flashcom Server uses XML files for configuration and these work in several levels starting at the server level (Server.xml) down to adapter (Adapter.xml) and vhost level (Vhost.xml) The last level is Application.xml which as the name says is responsible for configurations on an Application level.
The XML files are well commented and essentially pretty easy to maintain. To set up a working vhost you will normally need to edit 3 files:
- Server.xml, Vhost.xml and Application.xml

Server.xml can be found in the root of the /conf directory; Adapter.xml can be found inside the _defaultRoot_ directory and both Application.xml and Vhost.xml can be found under _defaultVHost_

This is how your file structure would look like after a standard Flashcom installation in Windows (only _defaultVHost_ is available)


Server.xml
Strictly speaking you do not have to edit server.xml to add a vhost. This is because the vhost entry in server.xml is only needed so that you can later add vhost administrators via the admin console. Adding a vhost to server.xml does NOT actually add the vhost to the server config. This might be a bit confusing but it's actually the process of creating the necessary folders under your adapter level which creates the vhost.

Having said that I would always recommend you add your vhost to server.xml to keep things organised. This will also allow you later to modify the vhost admins via the admin console. So here's how you add the entry to Server.xml. you need to copy the entire <VirtualHost....>...</Virtualhost> entry, basically the whole chunk that you see in the pic below.

Next you need to give your new vhost a name. This is important and you should always name it after the domain (or subdomain) the you use to later access it. Say for example your main domain is myflashcomhost.com then why not call this vhost vhost1.myflashcomhost.com. It is important to understand that this new subdomain must resolve to your Flashcomserver IP address. If it doesn't then you'll never be able to connect!

So for this example I will call my vhost vhost1.myflashcomhost.com and this is how the entry in server.xml should look like:

Adding the vhost folder
This next step is important as it will actually create your vhost. You have to create a new folder under your adapter level (in our example under ...\conf\_defaultRoot_), on the same level as _defaultVHost_. I sometimes just copy the entire _defaultVHost_ and then rename it. Warning: The name of this folder needs to correspond to your domain that you will use to access this vhost, in our example vhost1.myflashcomhost.com.

Your folder structure under /conf/_defaultRoot_ should now look like this:

This has in effect created the new vhost on your server.

But in order to be able to actually use the vhost you need to configure the <ScriptLibPath> in Application.xml and also the <AppsDir> in Vhost.xml. If you have created your new folder by copying _defaultVHost_ then those 2 files already exist inside your new vhost folder. If they don't then you need to copy them over from an existing vhost. You should also create a folder called 'admin' inside vhost1.myflashcomhost.com if you want this vhost to be able to accept admin connections. Have a look inside _defaultVHost_ for an example.

Adding the corresponding applications folder for your vhost
The Flashcom Server configuration is usually split up in 2 parts: the admin files under /conf to which only the server admin has access to and the vhost folders themselves (yet to be created) which will host your actual serverside scripts such as main.asc. The vhost folders can be made available via FTP for example to allow access for vhost admins. It is also a good idea to add a dedicated scriptlib to each running vhost.

In a nutshell what you have to do is create another folder to which you map your appsdir and scriptlib. This folder should not reside under /conf and it should not be accessible from the web, only via FTP. This applications folder is not the place from which you serve your swf files!
If you are planning on running a webserver on the same machine as your Flashcom Server then I recommend you read my tutorial on IIS and Flashcom, it gives some tips in regards to IP addresses and ports.

In my example the applications folder lives under C:\Inetpub\flashcom\applications (note that it is not under wwwroot and therefore not accessible from the web) but you can basically map it to wherever you see fit.
I call my new folder 'vhost1' and create 2 more folders inside it called 'apps' and 'scriptlib'. I then copy my scriptlib files from abother vhost into the scriptlib folder. My folder structure now looks like this:

Now we need to map appsdir to C:\Inetpub\flashcom\applications\vhost1\apps and map scriptlibdir to C:\Inetpub\flashcom\applications\vhost1\scriptlib

The correct XML entry therefore look like this for Application.xml

and like this for Vhost.xml


And that is pretty much all there is to it. It sounds a lot more complicated than it really is and I recommend you just try it out. I always restart my server just for good measure although I have been told that this is not strictly necessary.

a coomon problem oftne is that the new vhost domain (in our example vhost1.myflashcomhost.com) doesn't actually resolve correctly to the FCS IP and in that case you will never successfully connect. I therefore always open my admin console and check if my connection attempt actually hits the server - and I keep a particular close eye on the fact that the connection attempt does not connect to _defaultVHost_. If it does connect to _defaultVHost_ instead of your new vhost then you might have a config problem.

If your connection does not hit the server at all then the problem is likely DNS related.

If your connection does hit the Flashcom box but fails in some other way then nine times out of ten the admin console will give you some clues as to what is going wrong.

If you are still stuck after that then I recommend reading the Flashcom Server docs at http://www.macromedia.com/support/flashcom/documentation.html and in particular the first 2 PDF's called Installing Flash Communication Server and Managing Flash Communication Server.

There are also some interesting Live Docs available at http://www.macromedia.com/livedocs/flashcom/mx2004/index.html


More Entries