Wednesday, December 29, 2010

iPhone SDK: Application failed codesign verification

Check the following:

1. We are using release | device - during compilation, if you cannot select release then chances are configuration for arvm6 was not selected (we need to use standard)

2. check that the codesign has distribution selected and not any other certs

3. the release shoudl be at: Release-iphoneos

4. if there is no popup that asks for permissions to do codesign, then chances are the setup is wrong some where.. for example the active executable is towards that of the iOS simulator and not for release.

Aaron

Sunday, December 26, 2010

Get today's date mysql

"SELECT * FROM netl_hiscores WHERE DATE(scoreDateTime) = DATE(NOW())";

Tuesday, December 14, 2010

Weird floating DIVs

If you run into problems with div floating on the side of another div despite having clear seperators, then you need to inform the browser to 'stop' floating.. using the following command.

<div style="clear: both;"> </div>

Monday, October 25, 2010

Haversine Formula Calculation between two points

seems like safari does not support torad() function of javascript.

function getDistance(lat1, lon1, lat2, lon2) {

var R = 6371; // km
var dLat = (lat2-lat1) * Math.PI / 180;
var dLon = (lon2-lon1) * Math.PI / 180;
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;

return d.toFixed(2);
}

Friday, October 1, 2010

mysqldump and restore

mysqldump -u [uname] -p [dbname] > bak.sql

mysql -u [uname] -p [dbname] < [bak.sql]

Friday, September 17, 2010

format base strip sscanf php

function stripCurrency($input) {

$input = str_replace(",","",$input);
$input = str_replace("$","",$input);

return $input;
}

function stripRoadTax($input) {

$input = str_replace(",","",$input);
$input = str_replace("$","",$input);
list($val) = sscanf($input, "%d per year");

return $val;
}

function stripMileage($input) {

$input = str_replace(",","",$input);
list($val) = sscanf($input, "%d km");

return $val;
}

mysql php installation errors server 2008 zlib.dll

When IIS is complaining about a missing DLL file either a zlib.dll or oci.dll, chances are soemthing is wrong with the msi file, disable some of the extensions and try to install again, as long as php-cgi.exe runs properly, the program should work.

after ensuring that php works, follow the insturctions to edit the php.ini file to point to the correct fastcgi settings.
http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-7/

I installed PHP on C:\PHP and not within program files directory mainly because of the space.

lastly, take note of the appliaction pool, the manage pipeline mode should be integrated and the "enable 32 bit applications" setting should be set to true.

Wednesday, September 8, 2010

Performance xpath->query vs dom->getElementsByTagName

xpath works much faster, with speed of over 3 times faster compared to that of doing normal traversal using DOM.

// dom method
$xpath = new DOMXPath($dom);
$nodes = $dom->getElementsByTagName('td');
foreach($nodes as $node) {

if($node->nodeName == 'td'){

$inodes = $node->childNodes;

if ($node->getAttribute('class') == 'usedcar_InfoName usedcar_InfoName_padding') {
echo $node->nodeValue . "
";
}

if ($node->getAttribute('class') == 'usedcar_InfoContent usedcar_InfoContent_padding') {
echo @mb_convert_encoding(htmlspecialchars($node->nodeValue), 'utf-8') . "
";
}

foreach($inodes as $inode){

if($inode->nodeName == 'a' && $inode->getAttribute('class') == 'breadcrumb_link') {
echo $inode->nodeValue . "
";
}

if($inode->nodeName == 'td' && $inode->getAttribute('class') == 'usedcar_InfoName usedcar_InfoName_padding') {
echo $inode->nodeValue . "
";

}
}
}
}

// xpath method
$xpath = new DOMXPath($dom);
$title = $xpath->query("/html/title");
$elements = $xpath->query("//*[@class='usedcar_InfoName usedcar_InfoName_padding']"); // header
$elements2 = $xpath->query("//*[@class='usedcar_InfoContent usedcar_InfoContent_padding']"); // content

// dump all the header tag into an array
$headers = array();
if (!is_null($elements)) {
foreach ($elements as $element) {
$nodes = $element->childNodes;
foreach ($nodes as $node) {
array_push($headers, $node->nodeValue);
}
}
}

// dump all content tag into an array
$contents = array();
if (!is_null($elements2)) {
foreach ($elements2 as $element) {
$nodes = $element->childNodes;
$count =0;
foreach ($nodes as $node) {
if ($count == 0)
array_push($contents, $node->nodeValue);
$count++;
}
}
}

for($count=0; $count < sizeof($headers); $count++)
echo $headers[$count] . ": " . $contents[$count] . "
";

Monday, August 23, 2010

Android Screen Cast

http://code.google.com/p/androidscreencast/

Saturday, August 21, 2010

asp.net session extension

<script type="text/javascript">
$(document).ready(function () {
setHeartbeat();
});

function setHeartbeat() {

setTimeout("heartbeat()", 300000); // every 5 min
}

function heartbeat() {

$.get(
"/SessionExtender.ashx",
null,
function (data) {
setHeartbeat();
},
"json"
);
}
</script>

Wednesday, August 11, 2010

Confucius

quote from Confucius' book Genuine Living says, "Developing in accordance with one's own nature is called "the way of self-realization." Proper pursuit of the way of self-realization is called "maturation"." In this quote, I believe Confucius proposes education for a but subject matter and form for that education would vary according to one's own nature. C.T.M.A.T.M. 78 At Confucius' own school, he would not teach "duflards", and would "only teach those who were bursting with eagerness for enlightenment." However he would not turn someone away because they had no money.
http://www.qddx.gov.cn/n435777/n435782/n435826/n436845/n436862/5307.html

Monday, August 9, 2010

Pressing enter in textbox asp.net

<INPUT type="text" style="VISIBILITY: hidden;POSITION: absolute">


Start debugging again. You cannot see the second textbox, and everything looks like before. Try again to write something in first textbox. If you press enter now, form will submit, and your code for button's click event will now be executed. This is extremely different behavior, and you did nothing except you placed one invisible textbox on web form. :)

Sunday, August 1, 2010

Compiling mobile apps

Blackberry
1. Clean project
2. Project -> Blackberry -> Package All
3. *the program should automatically launch code signer
4. Inside Blackberry Manager, locate the ALX file and have it uploaded

iPhone
1. Download the latest version
2. Double click and launch the xcode project file
3. debug first and run on simulator (this is important)
4. if it works, connect the iphone
5. Select release (it will show base sdk is missing)
6. Select device
7. BUILD!

Thursday, July 29, 2010

linux directory search

find -type d -iname "*$mydir*"

Thursday, July 22, 2010

Android Camera Picture Errors

Its important to createnewfile(), because it creates the file. also it is important that during testing, the sdcard is unmount, there will be an exception about the parent directory being unreachable.

This can be potentially useful:
http://stackoverflow.com/questions/1431042/problem-in-creating-temporary-file-in-android

File photo = new File(Environment.getExternalStorageDirectory(),"modcloth/placeholder.jpg");

try {

photo.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream(photo.getPath());

BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 5; // sets image quality

Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length,options);

BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);

myImage.compress(CompressFormat.JPEG, quality, bos);

bos.flush();
bos.close();

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

Saturday, July 3, 2010

Placing Div above flash

place: "wmode", "transparent"

inside the following areas:
AC_FL_RunContent
<param name="wmode" value="transparent" />

Tuesday, June 22, 2010

Blackberry spacer whitespace generator

I thought android was bad, but Blackberry is 10 times worst. I spent an entire day doing a simple UI. Its not even easy considering the useless API documents. Anyhow I came up with a whitespace method (in place of padding)

private BitmapField whitespace(final int width, final int height) {

Bitmap img = Bitmap.getBitmapResource("transparent.png");
return new BitmapField(img) {
public int getPreferredWidth() {
return width;
}
public int getPreferredHeight() {
return height;
}
protected void layout(int arg0, int height) {
super.layout(getPreferredWidth(), getPreferredHeight());
setExtent(getPreferredWidth(), getPreferredHeight());
}
};
}

Sunday, June 20, 2010

validation javascript

function validate(form) {

var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

if (document.getElementById("txtName").value == "") {
alert("Please input a valid name.");
return false;
}

if(reg.test(document.getElementById("txtEmail").value) == false) {
alert("Please input a valid email.");
return false;
}

if (!document.getElementById("chkAgree").checked) {
alert("You have not agreed to the terms and conditions.");
return false;
}

return true;
}

<form method="post" action="" onsubmit="return validate(this)">

5 Reasons why GoThere.sg is overrated

So Aditya and I was talking over lunch about mapping services and how Singaporeans (in general) do not use Google Maps. Rather, they (Singaporeans) are appalled by Street View when they first see it. Aditya went on and said, oh Singaporeans uses GoThere.sg but not Google Maps. I was like. Why? This does not makes sense. Aditya say, "its better". In what ways? I asked. Aditya said, it is "localized, e.g. you can search for chicken rice on it and they have their own maps which don't resemble Google maps." That phrase basically sparked a 30 minute intensive research by myself and the results in this post as follows:

So here are five reasons why it is overated:

1. Its buggy?
On first entry and just doing nothing but essentially "dragging".. I got an instant error "stack overflow". Most likely something is wrong with their Arrays.


2. It is a variation of Google Maps
Yes on first glance it looks different. But you can't trick the expert (look at what I found, the street view is completely the same). I digged a little deeper and found that creating gothere.sg is relatively simple. its basically KML. You can find out a little more about KML here: http://code.google.com/apis/kml/documentation/whatiskml.html



3. It does not find directions
I tried and tried and tried.. many combinations ranging from SMU to Boon Lay and Orchard road. I may have been typing the wrong keywords, but hey if the system can't even give proper instructions on how to find directions, how are you going to expect people to use it? Google is simple on this, two text boxes at the start of the page and you are all set.



4. I can't get directions to Johor
I love going into Johor, in fact most if not all Singaporeans drive/get driven there at some point in their life. Why limit their market to Singapore? I know, bowling pin strategy. But if you are already ripping the maps off Google, why don't you just rip the rest off?


5. Lacks contextual information
I must say, Google maps on the PC is still rather bad on this, but its moving in strongly in this area with the mobile phones. So for instance, an example of a missing contextual information is "time". When it calculates ERP, does it take into factor the time of the day and give you the cheapest route base on price? When it estimates time of arrival, does it takes into account weather and traffic? I may be better off sticking to my radio if they don't have such things.


-----------------------------------------------
All in all i felt that GoThere.sg has got some potential (not a lot). Why?

1. Low barriers to entry, from my experience. I am sure I can replicate this in less than a month with a team of four programmers.
2. It is hard to scale and replicate this 'success' overseas. Face it, try coming to the USA and you will be swarmed with Google Maps. Almost certain a flop if it comes to the US of A.
3. Crowded space, Google is moving strongly in this area. So is Microsoft and Apple. So the golden question is, will it be a take over target of Google or any of the Giants in future? My answer is - no. The Singapore market is too small for any of the giants to bother. Also, most importantly, there is nothing truly novel about their approach. Everything they have done was already done in Google Maps (transit fare calculation etc).
4. In fact the very nature of their existence is due to the existence of Google. So if Google (one day) decides that all companies that uses Google Maps will have to pay for it. They are going to be in trouble.

BUT..

5. It is the first company (other than streetdirectory) to create such things, created perfectly in time to fill that void that the company left. It uses a different map (but actually it is just google's map) and mashed everything up together. Honestly, it does save you time e.g. you don't have to find parking information elsewhere. But the question is this: "what is your value proposition?" Any body can just come in and create a mashup in no time, how much time can you save?

To summarize it all: Mr Lesmana, i am not still not sold by gothere.sg, i can also search for chicken rice on Google maps (you pretty much get the exact same results) also they are USING google maps, not their own map.

Saturday, June 12, 2010

Flex Mouse Cursor on Non Buttons

<mx:Image source="image1.jpg" useHandCursor="true" buttonMode="true" />

Tuesday, May 4, 2010

Phonegap Eclipse

1. create directory C:\xampp\htdocs\omniproxrewards
and place icon.png, index.html master.js and phonegap.js into it

2. remove any existing directory in the workspace (i.e. omniproxrewards) if any

3. C:\Program Files (x86)\phonegap\android>ruby build.rb oward com.omniprox C:/xamp
p/htdocs/omniproxrewards C:\Users\Aaron\workspace\omniproxrewards

4. phonegap.jar has to existin in framework directory it can be found online or genearted internally.

5. rename the auto generated project into omniproxrewards2

6. inside eclipse. select to create a new android project NOT from existing source

7. after creating, go back and copy everything in omniproxrewards2 folder into omniproxrewards

8. back in eclipse add phonegar.jar as build path
(right click -> build path -> add to build path)

Monday, May 3, 2010

The Entrepreneur with a Bond

“If you like being an entrepreneur so much, why did you take up a scholarship?”

That was the question many had, when they heard I am actually on a bond with the Infocomm Development Authority of Singapore. I will always answer them: “Because of the doors it will open”.

By being bonded, I exchanged a few years of my prime for an opportunity to learn the best practices of huge companies – allowing me to learn the ropes for further expansion of my company in future. It gives me instant credibility as a person who ‘knows my stuff’. The bond also pays for my education overseas and allowed me to reinvest more of my money back into the company. Most importantly, it gave me contacts with some of the brightest future leaders of tomorrow in the industry – Something that an entrepreneur should never be short of.

No one can be sure if I made the right decision to take the scholarship four years ago. Not even me. If I didn’t take the scholarship, I would not have studied in CMU, I would not have been exposed to world class research. I would not have met so many professors that shaped my thoughts and skills. I would not have co-founded another company in the United States.

Is the four years of bond worth all these things? I asked myself.

I don’t know.

If there was one thing I learnt as an entrepreneur. That would be, never be afraid to be different.

Taking on a scholarship is similar to that of starting a business. We don’t know for sure what awaits us at the end of the tunnel but we are forced to invest time and money in it. It could be the best decision I made or the worst. We never know.

But life is too short for “If only I had”. That’s why I took the plunge and did what I did.

Taking a scholarship does not stop me from being an entrepreneur. Nope, not at all. You do not need to be an entrepreneur to be an entrepreneur. You can be working for somebody and still be an entrepreneur. You can be an entrepreneur anywhere. An entrepreneur looks at problems in the eye, and says he can fix that. An entrepreneur is motivated and driven. An entrepreneur works in a team, sets achievable goals and eventually reaches them. Being an entrepreneur is really not about being one physically, it is the spirit of being one.

I don’t know if the scholarship was a good decision but I do know that the scholarship does not mark the end of my life as an entrepreneur. I will be an entrepreneur wherever I go.

Thursday, April 29, 2010

PHP scrapping for .net

/************************************************
* ASP.NET web site scraping script;
* Developed by MishaInTheCloud.com
* Copyright 2009 MishaInTheCloud.com. All rights reserved.
* The use of this script is governed by the CodeProject Open License
* See the following link for full details on use and restrictions.
* http://www.codeproject.com/info/cpol10.aspx
*
* The above copyright notice must be included in any reproductions of this script.
************************************************/

/************************************************
* values used throughout the script
************************************************/
// urls to call - the login page and the secured page
$urlLogin = "http://www.portauthority.org/atisdnn/default.aspx";
$urlSecuredPage = "http://www.portauthority.org/atisdnn/default.aspx";

// POST names and values to support login
//$nameUsername='txtusername'; // the name of the username textbox on the login form
//$namePassword='txtpassword'; // the name of the password textbox on the login form
//$nameLoginBtn='btnlogin'; // the name of the login button (submit) on the login form
//$valUsername ='myUsername'; // the value to submit for the username
//$valPassword ='myPassword'; // the value to submit for the password
//$valLoginBtn ='Login'; // the text value of the login button itself

$valuePair = array(
'txtDeparture' => '4628 Henry Street',
'radDeparture' => 'I',
'txtArrival' => 'Airport Pittsburgh International',
'radArrival' => 'I',
'ddlArrDep' => 'D',
'ddlHours' => '7',
'ddlMinutes' => '55',
'ddlAmPm' => 'PM',
'Calendar1_txtCalendar' => '4/29/2010',
'ddlTripPreference' => 'I',
'lblWalkDist' => '.25',
'ddlNumItins' => '1',
'hdnTripDate' => '4/29/2010',
'lblHiddenSearchType' => '',
'lblHiddenSearch' => '',
'txtHiddenLocationIndex' => '',
'txtHiddenArrivalIndex' => '',
'txtHiddenDepartureIndex' => '',
'btnSubmit' => 'Submit',
'__EVENTTARGET' => '',
'__EVENTARGUMENT' => '',
);

// the path to a file we can read/write; this will
// store cookies we need for accessing secured pages
$cookies = 'someReadableWritableFileLocation\cookie.txt';

// regular expressions to parse out the special ASP.NET
// values for __VIEWSTATE and __EVENTVALIDATION
$regexViewstate = '/__VIEWSTATE\" value=\"(.*)\"/i';
$regexEventVal = '/__EVENTVALIDATION\" value=\"(.*)\"/i';


/************************************************
* utility function: regexExtract
* use the given regular expression to extract
* a value from the given text; $regs will
* be set to an array of all group values
* (assuming a match) and the nthValue item
* from the array is returned as a string
************************************************/
function regexExtract($text, $regex, $regs, $nthValue)
{
if (preg_match($regex, $text, $regs)) {
$result = $regs[$nthValue];
}
else {
$result = "";
}
return $result;
}



/************************************************
* initialize a curl handle; we'll use this
* handle throughout the script
************************************************/
$ch = curl_init();


/************************************************
* first, issue a GET call to the ASP.NET login
* page. This is necessary to retrieve the
* __VIEWSTATE and __EVENTVALIDATION values
* that the server issues
************************************************/
curl_setopt($ch, CURLOPT_URL, $urlLogin);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$data=curl_exec($ch);

// from the returned html, parse out the __VIEWSTATE and
// __EVENTVALIDATION values
$viewstate = regexExtract($data,$regexViewstate,$regs,1);
$eventval = regexExtract($data, $regexEventVal,$regs,1);


/************************************************
* now issue a second call to the Login page;
* this time, it will be a POST; we'll send back
* as post data the __VIEWSTATE and __EVENTVALIDATION
* values the server previously sent us, as well as the
* username/password. We'll also set up a cookie
* jar to retrieve the authentication cookie that
* the server will generate and send us upon login.
************************************************/
$postData = '__VIEWSTATE='.rawurlencode($viewstate)
.'&__EVENTVALIDATION='.rawurlencode($eventval);

foreach ($valuePair as $key => $value) {
$postData = $postData . '&'. $key.'='.$value;
}

//.'&'.$nameUsername.'='.$valUsername
//.'&'.$namePassword.'='.$valPassword
//.'&'.$nameLoginBtn.'='.$valLoginBtn
;

curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_URL, $urlLogin);
//curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);

$data = curl_exec($ch);


/************************************************
* with the authentication cookie in the jar,
* we'll now issue a GET to the secured page;
* we set curl's COOKIEFILE option to the same
* file we used for the jar before to ensure the
* authentication cookie is sent back to the
* server
************************************************/
//curl_setOpt($ch, CURLOPT_POST, FALSE);
//curl_setopt($ch, CURLOPT_URL, $urlSecuredPage);
//curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);

//$data = curl_exec($ch);

// at this point the secured page may be parsed for
// values, or additional POSTS made to submit parameters
// and retrieve data. For this sample, we'll just
// echo the results.
echo $data;



/************************************************
* that's it! Close the curl handle
************************************************/
curl_close($ch);


?>

Thursday, April 22, 2010

QuertyString and Includes PHP




instead of


The main reason being $navi will be an instance variable of header.inc.php file

Thursday, April 15, 2010

Flex Combobox

xmlSalons = XML(this.loadSalons.lastResult);
var xSalons:XMLList = xmlSalons.salon;

// add default for nothing
salons.push({data:"-1",label:"I will select a salon later."});

for each (var xSalon:XML in xSalons)
{
salons.push({data:xSalon.salonId,label:xSalon.name});
// for future usage to push salon object (for management) i.e. create/delete
//salons.push(new Salon(xSalon.salonId, xSalon.userId, xSalon.type, xSalon.name, xSalon.description));
}

ddlSalons.dataProvider = salons;
ddlSalons.labelField = "label";
ddlSalons.data = "data";
ddlSalons.selectedIndex = 0;

var obj:Object = ddlSalons.selectedItem;
obj["salon"] = obj["data"];

Wednesday, April 7, 2010

Bluetooth research

1. Problems getting bluetooth drivers to work on Vista.
-> Uninstall drivers and reinstall it, else try manually replacing the drivers. Lookout for the bluetooth icon on the bottom right on the taskbar instead of within control panel.

2. Motorolla offers WIDCOM stack.

Tuesday, March 30, 2010

PHP error on IIS

FastCgiModule
Data1 FASTCGI_RESPONSE_ERROR
Data2 PHP Warning: Unknown: open_basedir restriction in effect. File(C:\inetpub\rewards\index.php) is not within the allowed path(s): (C:\Windows\Temp) in Unknown on line 0
PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0

ErrorCode 5

The way to solve this is to comment the line on open_basedir in php.ini

Flash CS3 Alpha Tweening

In order for alpha to work, we have to set the text to static instead of dyanamic. It should still work as usual for images. if problem persists, close windows and make sure that the file is exported to the right place.

Tuesday, March 23, 2010

PHP File Upload

1. Setup .ini file within the directory to include the following lines:
post_max_size = 10000000
upload_max_filesize = 10000000

2. Make sure that HTML code contains the MAX_UPLOAD_SIZE hidden field

3. Use the following codes:
function uploadPicture() {

$uploaddir = "issuepics";

$pext = getFileExtension($_FILES['txtImgFile']['name']);
$pext = strtolower($pext);

if (($pext != "jpg") && ($pext != "jpeg"))
{
unlink($_FILES['txtImgFile']['tmp_name']);
return "Error: Extensions Unknown, only JPEG is allowed.";
}

// Resize image
$imgsize = getimagesize($_FILES['txtImgFile']['tmp_name']);
$imgfile = $_FILES['txtImgFile']['tmp_name'];

if (($imgsize[0] > 640) || ($imgsize[1] > 480))
{
$tmpimg = tempnam("/tmp", "MKUP");
system("djpeg $imgfile >$tmpimg");
system("pnmscale -xy 640 480 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile");
unlink($tmpimg);
}

// Rename image
global $finalFileName;
$finalFileName = getRandomKey() . "." . $pext;
$newfile = $uploaddir ."/" . $finalFileName;

// copy image into directory
if (is_uploaded_file($imgfile))
{
if (!copy($imgfile,"$newfile"))
{
return "Error: Problem uploading file";
}
}

unlink($imgfile);

return "";

}

function getRandomKey() {
$rand = time() . rand(0,1000);
return $rand;
}

Saturday, March 13, 2010

503 Service Unavailable

This is likely due to the IIS application pool not being started.

Sunday, February 28, 2010

Android Emulator with SD Card

I can't believe how lousy the Android documentation. To run an emulator with an SD Card, we have to do the following:

1. Create an ISO image of our SD card. Can be done with tools like "FREE ISO Creator".

2. After which, store the program somewhere in the drive and go to the SDK/Tools directory via command line. And then run this:
mksdcard 256M C:\Users\Aaron\workspace\tmp.iso

3. Go back to Eclipse, open "AVD manager" (the black phone icon). Then add a new AVD. Select the file option as "C:\Users\Aaron\workspace\tmp.iso

4. When we run the configuration file, remember to target the run AVD manager created in step 3.

Thursday, February 18, 2010

The Drs Show (Speech)

PMS: Please make it stop, Push me Stupid.

Monday, February 8, 2010

(Google Maps/MapQuest) Mapping in ActionScript 2.0

Writing a mapping function (to show direction/map) is really not a trivial matter in ActionScript 2.0. The main reason being ActionScript 2.0 does not support the various API/SDKs by GoogleMaps/MapQuest. Hence in other words, you have to rewrite your entire application (which is written in ActionScript 2.0). Not really a huge issue if the application was a switch from PHP 4 to PHP 5. ActionScript 2.0 and ActionScript 3.0 is a hell lot of difference.

One way to overcome this is to do a popup using the getURL command from within flash. Basically the idea is to write them as two separate application and compile them differently using AS 2.0 and AS 3.0 respectively.

Now this sounds simple enough. But for our case, since its a kiosk (which is calling a program), we cannot simply use getURL because it will call up IE/Mozilla by default. Which means we can't do it the normal getURL way. So that leaves us to create our own strip down browser and launch it with a batch file.

Step 1: Create a browser
Can be done with VB.NET with a simple webbrowser dialog. Name it SimpleBrowser.exe

Step 2: Create a batch file
With something like: fscommand("exec", "run.bat");
*now you have to create a folder call fscommand and place run.bat inside.

A batch file can be created with:
   >@echo off
   >start SimpleBrowser.exe %1

But there is a problem with the batch file as it shows the ugly black exe executing. One way around it is to use proxy.exe which was written by northcode. However, I ran into problems passing variables (we need to pass the map's URL) into the batch file. After much trying, I gave up and went the direction of writting the variables to a text file instead.

Step 3: Writing variables to a text file

In ActionScript 2.0 when you write to textfile using LoadVars, it will cause a popup/refresh. So you won't want to do it. Instead I went ahead with FFishScript again and used the following (within Flash):
_root.myURLString = vURLmap;
fscommand("ffish_run", "savetextfile");

Inside (FFscript), i created a script call savetextfile and put the following codes into it:
var myURLString = FlashPlayer.getVariable("myURLString");
var file = new FileStream("C:\\url.txt", "w");
file.writeLine(myURLString);
file.close();

Step 4: Linking Browser with the url output of a textfile
Again, I did it in FFIshScript, after the file.close() command.
Shell.run("C:\\SimpleBrowserC.exe", 1, 100,100);

In VB.NET i did the usual StreamReader and ReadLine and obtain the URL that we got from step 3.

Now everything should just work beautifully. :)

Aaron

Hacking the Print Function (Flash)

Printing in Flash without the dialog box is not a trivial issue. It can mainly be done in the following methods:

1. Having a wrapper around the SWF (by programs such as Zinc and SWFKit)
2. Hacking the Registry in the Operating System
3. Automatic clicking, such as auto-hot-key
4. Javascript clicking

I tried all four methods, and here are the results:

Method 1 works the best, the codes for using method #1 is really just:
FlashPlayer.showPrintDlg = false;
(this is in FFishScript which is SWFKit's language)

Method 2 does not work (at least for vista) which is what the Kiosk OS is on.

Method 3 does not work too. At least for me.

Method 4 works, but I don't actually launch my print function from within the SWF mode. I launch it in projector mode. The codes for Javascript method is:

<script language="JavaScript">
function printit() {
window.print();
}
</script>

Testing

<script language='VBScript'>
Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>

Friday, February 5, 2010

Replace newline in actionscript/flash

desc_txt.text = searchAndReplace(_global.WebHandler.mDesc, "\r\r", "\n");

Sunday, January 31, 2010

Child and Parent FLEX

Accessing the parent functions is not as simple as always, I did try using DisplayObject but it didn't work as i thought. The best way really is to rethink the relationship between the child and parent. Normally, if the function exist with the parent as opposed to residing on the child, the function can be as simple as just:

private function changePot(event:MouseEvent):void {
this.parentApplication.changePot((event.currentTarget as Image).name);
}

Of course the parent application needs to have a function call changePot. Thats it!

Sunday, January 24, 2010

Configuring PHP on Windows

If you are getting 500 errors but everything else in PHP runs normally (in IIS 7), then chances are Session is not working. You can verify this by just having a script that runs session_start().

Two things to fix:
1. session.save_path, session.use_cookes and session.start has to be set too
2. warnings: error_reporting = E_ALL & ~E_NOTICE