Unix Command Line 'Touch' command in Windows Command Prompt

Sun May 29 04:44:17 2011

I was asked the other day how to do the "touch" command in the command prompt on a Win machine to create a new file.

Anyone who uses the command line of Unix based environments will have most likely used the following command to create a new file.

touch fileName.fileExtenstion

Creating the file 'test.txt' is just a simple matter of touch test.txt.

OK, nothing new there. So how do we do this in Windows? The answer is simple. Open the Command Prompt, navigate to a folder in which you wish to create a file (cd to the Desktop for example) and type the following command.

copy nul test.txt
and press enter.

That's it.

There are a bunch of extra arguments you could add in place of the nul, like con which will let you enter content directly from cmd. Anyway, I'll let you look for those... and that's how you do it.

Node.js - better than sliced bread!

Fri Mar 25 03:23:58 2011

For those who haven't heard about Joyent and Node.js, you should definitely take a look. This has got to be one of the best things to happen to the Internet in while!

Also, just wanted to post a quick link to the blog post that got me up and running: Building a socket server with Node.js and Flash CS4

I did the tutorial linked above without Flash and here's the AS3 code I threw together just to test it out. It literally took 5 mins to write so no complaints if you don't like my rushed code, thank you.

Want to say a big thanks to my friend Dan for introducing this stuff to me. It made my day, I can tell ya!

Using Dropbox as a remote for git

Thu Mar 24 04:36:51 2011

dropbox-n-gitSetting up a git remote on Dropbox is great for backing up and sharing projects with other people. Here's how to get started.

Getting a local repository started

First off open a Terminal window and create a project folder. I'm going to make one in my ~/Sites folder of my mac using the command mkdir (make directory) and cd (change directory) inside.

cd ~/Sites/
mkdir project
cd project

Next create a git repository inside the folder project

git init

When you want to add files that are saved in the projects folder to the repository, use the add and commit commands. For example, say you have the file index.html in your project folder, use git add * where * means everything/all, but can be a specific file name such as index.html. Using the command git status will show you if any changes have been made or/and if there are any untracked files that exist in the directory. Right now, no files have been commited to the repository, so the 'index.html' should be displayed. Run the following to commit to the repository:

git commit -a -m "Initial commit"

The -m followed by a message in between " " will be the message that is display in the log/history of changes. After commiting changes, run git log to view the git history.

Creating and "Pushing" to a Remote (i.e. Dropbox)

Now, in the same way we created a directory for the project, we have to also make a directory for the remote branch. I will make one called "Repository" in the root of Dropbox and then make another folder inside that called project.git, for sake of ease.

cd ~/Dropbox
mkdir Repository
cd Repository
mkdir project.git
cd project.git

Now that we're inside project.git, let's create a bare repository

git init --bare

Now, all that's left is to add our Dropbox remote to the repository of our project and push to it. (We'll have to cd back into the local project folder for that)

cd ~/Sites/project
git remote add origin ~/Dropbox/Repository/project.git
git push origin master

Now, if everything went OK, you should be able to run git log from inside ~/Dropbox/Repository/project.git and view the same log as ~/Sites/project.

Pulling from the Dropbox Remote

Let's say that you are now on a different computer with access to Dropbox. It's really easy to clone and pull files from the remote and code anywhere!

cd ~/Sites
git clone -o Dropbox file://$HOME/Dropbox/Repository/project.git

You should now see the new project folder on inside your ~/Sites folder as it was when you left if on your other computer!

Just rememeber to push any changes made here to the Dropbox remote and then git pull origin master will pick things up again on any other computers that have cloned the repository. Cool eh? Saves room in my pockets where a USB drive used to be :)

Build Apps for Android using AS3 without a device

Tue Jan 25 07:20:53 2011

Here's a post I've been meaning to write for a while but never got round to it. Let's get right to it.

1. Getting Set Up

First, go here and get yourself the Android SDK. Make sure it's the right one for your OS. I'm currently using 2.2.

Next, if you haven't got it already, scoot over to Adobe and grab the Flex SDK. I'm current using Hero as it gives support for Air 2.5 (a must have).

I placed both SDKs inside /Developer/SDKs/. I'll refer to this folder as DEV/ from now on. After unzipping the SDKs, I renamed the Flex SDK to 'flex_sdk_4.5' and the android-sdk to 'android-sdk'. I refer to them by these names.

Also, I added the paths to my terminal. If you don't know how to do that, you could just cd (change directory) into the folders your files are in or you could use a search engine to look into how to actual add the path, which I recommend. I'm not going to write about it here.

Finally, download the zip file I put together here : HelloAndroid.zip. This file contains all of the files talked about in this tutorial. For those who wish to do it all from scratch, I would advise at least taking a glimpse at the files contained to see what you will be making before hand (in which case you will have to create your own HelloWorld.as and application.xml files as the code for that is not shown on this page).

2. Creating a 'Hello World' to test

First off, a quick hello world in AS3. Inside the zip that can be downloaded above, there is a file called Main.as. This is a simple hello world program. To compile that file, just type DEV/flex_sdk_4.5/bin/amxmlc file-path/Main.as in your terminal window. Note that 'file-path' needs to be the location of the Main.as file containing your hello world code, which is also the location of the output. If you wish to change the location and name of the swf that is output, please refer to the available compiler options here. If all goes well, you should end up with a file call Main.swf

Now, open up terminal if not already open and type DEV/android-sdk/tools/android. In a few moments, the Android SDK and AVD Manager should pop up. This is where we will create a virual device to test hello world on. If you have a real android device, please use Google to look up how to install your hello world on your device. I will not cover it here.

3. Creating your AVD (Android Virtual Device)

In the Android SDK and AVD Manager ("Android Manager" from now on), under Virtual devices, click the 'New' button on the right. In the 'Name' box, choose a name for your device. I just called mine 'Foo'. Set the target as Android 2.2 (or whichever version you wish to use). After that the default settings should be fine, so just click "Create AVD". That's that done, so you can close the Android Manager now.

4. Create the certificate you'll need for testing

To create a self-signed certificate, type the following into a Terminal window:
DEV/flex_sdk_4.5/bin/adt -certificate -cn yourDigitalID 1024-RSA AndroidSigningCert.p12 yourPassword You could give your own id in place of yourDigitalID. It could be anything now though as this is just a test. You can also change the name of the p12 file to be saved and your password. For simplicity's sake, the zip file that you should have downloaded already contains the AndroidSigningCert.p12 created using this command.

5. The Application XML file

The application xml file can be named anything you like, but the data it contains is consistent and provides important information about you application during the build process. For this hello world app, I've included a file in the zip called 'application.xml'. Feel free to take a look at that in your favourite editor and play around with some of the settings to see what happens. Also note that there are a lot more settings than are actually contained in that file. Please look at Adobe's documentation for more details.

6. Create and APK file from your hello world SWF

Open a Terminal window and type the following making sure you input the correct location of each file DEV/flex_sdk_4.5/bin/adt -package -target apk-emulator -storetype pkcs12 -keystore file-path/AndroidSigningCert.p12 Main.apk file-path/application.xml file-path/Main.swf
The compilation is pretty quick and you should end up with a file called Main.apk.

7. Installing the APK onto the AVD

The installation of applications is simple. On the mac, it seems that the installation requires an extra step though. *First drag your .apk file inside the DEV/android-sdk/tools/ *Next, using Terminal, cd into your DEV/android-sdk/ and open your AVD by typing tools/emulator -avd Foo, where Foo is the name you entered when you created your AVD in the Android Manager. (Note* you could just type DEV/android-sdk/tools/emulator -avd Foo).
To actual install the app open a new Terminal window and type DEV/android-sdk/platform-tools/adb install DEV/android-sdk/tools/Main.apk where Main.apk is the name of your .apk file. In may be worth mentioning that I sometimes ran into a problem where even though my AVD was on and working, it was telling me that the device was offline. Sometimes it takes a while for the the device to get up and running properly so just be patient and keep trying (In terminal, you can toggle through previous commands using the up arrow key).

Once the installation has completed, your app should be visible on the emulator device. But wait, there is just one more thing you have to do before it will run. You have to install the Adobe Air runtime app. You can find that in the DEV/flex_sdk_4.5/runtimes/air/android/emulator/ folder. The file is called Runtime.apk. Just drag it to your DEV/android-sdk/tools/ folder and install it using the same command as before: DEV/android-sdk/platform-tools/adb install DEV/android-sdk/tools/Runtime.apk

Once that is installed you should be good to go. Test your hello world.

I know, I know. It's a lot of work to get it going, but I hear Adobe Burrito will include support for quick install to devices with the click of a button. However, I don't actually think it's all that difficult once you get used to it.

Just a quick word on the uninstalling of apps. At present, there is no feature in the simulator to allow you to update apps you install, as far as I'm aware. So every time you want to try a new build of your app out in the emulator, you have to first uninstall it. To do this, click on 'Settings' (same place as apps). Scroll down to and click on 'Applications', then 'Manage applications'. Then simply click on the app name you wish to uninstall and click the 'Uninstall' button. You should be good to install the new build of your app after that.

Now, all that's left is to find good ideas for some real apps. Should be a cinch... yeah right!

Graphics Optimization for the Adobe iPhone Packager

Fri Dec 24 05:33:13 2010

I have been doing some looking around and to be honest there isn't much that I have found useful in regard to graphics optimization for the iPhone Packager. To be quite frank, I may even be as bold as to say that it appears quite useless compared to a lot of other solutions available. That of course does not go for Adobe's efforts for Android. I'm sure that with the increase in great mobile devices that offer Android OS, the performance will just keep getting better. However, what do we do in the meantime for ActionScript on the iPhone? Well, here's something that may not be very practical but I have found that it boost performance of graphics on the device.

Most will know by now that using cacheAsBitmap = true; and cacheAsBitmapMatrix = new Matrix() along with setting the renderingMode to gpu helps performance considerably and I can vouch for that.

However, I have been hearing a lot of talk about how using Bitmaps also helps performance. This I have found not to be so true, as when I compile an .ipa file using -renderingdiagnostics, every bitmap that I have every tested lights up a bright red (not good). All vector graphics, including FXG graphics display in a nice green. The frame rate is always much higher for vector graphics and FXG too, provided that nothing too strenuous is being done to them.

Now this is what I find interesting about all this. When I create an FXG file containing one of the .png files that display in red under -renderingdiagnostics, and then import said FXG file and use cacheAsBitmap = true; and cacheAsBitmapMatrix = new Matrix() with gpu set as the renderingMode, I get much better performance than just using a Bitmap by itself.

I don't really know why this occurs and I nothing I have read gives any indication of this, but through my own experiments, that is what I found. Please let me know if anyone finds a way to use bitmaps that display in green under -renderingdiagnostics. Or have I got it all wrong, and there is no way to cache an actual Bitmap? If so, then that is just silly!

Come on Adobe, I know you are working hard but throw us a bone!

Most recent posts

  1. Convert Font Suitcase to TTF in 3 Easy Steps
  2. Rain or Shine - Weather Forecast Available Now!
  3. Getting around Apple's silly rules for iOS 10
  4. Localising App Names for iOS and Android
  5. Today - Powerful To-Do App Now Available on iOS & Android

Search site:

Apps by Ubacoda.com

Click the app icons to see more info


Archives

Categories