Archive for February, 2013

Well, I was working on my phonegap + native application for stuttering therapy for some time now. And it was really a mess. nothing worked smoothly and every step took lots of time. CSS is a real bitch for me and I don’t like it one bit. I miss the days I was creating web apps with macromedia flash and everything was visual and easy. The gui was a piece of cake and writing code was brief and very debuggable.

Before I started to build my mobile app I created a very similar app using Silverlight. This was also very nice. Using Expression blend for the GUI and C# for the code is sooooo sweeeeet.

I’m going to convert both my apps (the silverlight and phonegap + java) to Adobe Flash Air. I really hope the API adobe provides is compatible and I will write this app only once for all platforms.

going to start with this video series on youtube. 

Sample Application using Flex and AIR for Android

Tutorial: Flex for Android in 90 Minutes

key feature in my app is sound recording in real time, found it on stackoverflow

How can I record audio in a Air Mobile App?

basics:

Create an Android application in Flash Builder

PHP – MySQL – Flex 3 Client-Server Application

very nice example with audio & microphone:

“VoiceNotes for Android”: Sample App using Flex, AIR, and the Microphone API

also found this awsome ebook on flex for android:

http://www.wefdc.com/wp-content/uploads/2011/10/Developing_Android_Applications_with_Flex_4.5.pdf

Advertisements

When I tried to export my android project I saw this error alert message

“Conversion to Dalvik format failed with error 1”

found this post and got this answer working for me just fine.

Confirmed the problem is caused by ProGuard command line in the file
[Android SDK Installation Directory]\tools\proguard\bin\proguard.bat

Edit the following line will solve the problem:

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*

to

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

 

disable the “Build Automatically” option. Build the project manually.

Perl script for batch whois

Posted: February 14, 2013 in Perl, snippets

I created a perl script that reads a file with domains to check and output the valid ones.It can also go through domain name combinations.

#!/usr/bin/perl

sub whois
{
#print “doing whois for “.$_[0].”: “;
my $domain = $_[0];
$domain =~ s/www\.//g;
open(WHOIS_CMD, “whois -h whois.isoc.org.il \”$domain\”|”) or die “Can’t run ‘$whois_cmd $domain’\n$!\n”;
$i=0;
while(<WHOIS_CMD>)
{ # each line of output is put into $_
if ($_ =~ /No data was found to match the request criteria|No match|A C C E S S D E N I E D/i)
{
#print $_;
return 0;
}
}
return 1;
}
if ($#ARGV>(-1))
{
print $ARGV[0];

my $file = $ARGV[0];
open my $domains, $file or die “Could not open $file: $!”;

while( my $domain = <$domains>)
{
chomp($domain);
if (whois($domain)==1)
{
print “$domain : ok\n”;
}
else
{
print “$domain : fail\n”;
}
}

close $domains;
}

print “\n\n”;

 

$.mobile.changePage(“#page2”);

(from this post)

ok. this isn’t working. I’m getting the following error:

02-14 18:20:12.093: E/Web Console(17689): Uncaught TypeError: Cannot call method ‘changePage’ of undefined at file:///android_asset/www/goals.html:112

bad bad bad

need to find something else. so i tried this

$.mobile.back();

still not working i’m getting this error

02-14 18:23:16.082: E/Web Console(17915): Uncaught TypeError: Cannot call method ‘back’ of undefined at file:///android_asset/www/goals.html:112

i’ll try something else… following this site i’m trying

$.mobile.loadPage( pageUrl, { showLoadMsg: false } );

shit. nothing seems to work. now i’m getting this error

02-14 18:27:24.265: E/Web Console(18181): Uncaught TypeError: Cannot call method ‘loadPage’ of undefined at file:///android_asset/www/goals.html:112

tried this:

$.mobile.changePage(“index.html”, null, true, true);

and got

02-14 18:30:33.429: E/Web Console(18465): Uncaught TypeError: Cannot call method ‘changePage’ of undefined at file:///android_asset/www/goals.html:112

it seems like $.mobile is not recognized…. 😦 what to do what to do?

i tried also to change the calling of this code not from deviceReady event of phonegap but with this:

$(document).bind(“pagecreate”, function(){

found it on this link. also not working… not even triggering…damn

also tried to change the calling to this

$(‘#goals-page’).live(“pageinit”, function() {

and failed. I’m getting this error

02-14 18:39:05.158: E/Web Console(19354): Uncaught TypeError: Object [object Object] has no method ‘live’ at file:///android_asset/www/goals.html:103

i’m strating to get pissed off.

OK. FOUND THE ANSWER HERE. I used this:

window.location.href = “index.html”;

I already created a semaphore in my java native activity. I needed it to add voice samples to a buffer from one thread and read and empty this buffer on other thread. Started to get data aborts so I investigated and found the semaphore isn’t working as I expected.

The code I use is this:

declare the semaphore:

static public final Semaphore SEMAPHORE = new Semaphore(1);

and than do

SEMAPHORE.acquire();

and

SEMAPHORE.release();

and it isn’t working… 😦

So I find this code which creates a class and looks and sleeps until lock is acquired, but I don’t like it. Can’t believe this is the solution and it looks kinda old (2004 old).

I tried to implement the code from this post, looks decent. The synchronized architecture looks very logic.

WOW this is a great improvement in performance too!!!! I guess the “old semaphore” didn’t work as well as I thought it would. The new code involves this:

public Class MyClass {
  private static Object lock = new Object();
  public void myMethod() {
    // Stuff that multiple threads can execute simultaneously.
    synchronized(MyClass.lock) {
      // Stuff that only one thread may execute at a time.
    }
  }
}

(taken from the very same post)

So just encapsulates all sync’d code in “synchronized(MyClass.lock) {}” and it does the semaphoring for you.
happy happy

I want to show the users progress over time with some charts. So here I am searching google again for some answers.

Found this link:

Create Quick and Easy Progress Bar Charts with HTML5 and CSS3

p1

This isn’t exactly what I was looking for but an easy progress bar can be quite handy. Its worth testing…

Fuck, this article has no demo. This is NOT COOL. But it was easy creating out of the code presented on the page. So I guess I will try.

Ok, got it. Here is the result:

p2

and the code is:

<html>
<body>
<style>
/* Firefox – value portion of progress bar */
progress#bar::-moz-progress-bar {
background-color: red;
-moz-box-shadow: 1px 1px 1px #333333;
}

/* Chrome, Safari – value portion of progress bar */
progress#bar::-webkit-progress-value {
background-color: red;
-webkit-box-shadow: 1px 1px 1px #333333;
}

/* All other attributes */
progress#bar {
background-color: #F0F0F0;
border: solid #808080 2px;
border-radius: 5px;
-moz-box-shadow: 3px 3px 3px #C0C0C0;
-webkit-box-shadow: 3px 3px 3px #C0C0C0;
box-shadow: 3px 3px 3px #C0C0C0;
padding: 3px;
width: 250px;
height: 20px;
}
</style>

<strong>Project Completion Status</strong><br />
<br />
Project #1<br />
<progress id=”bar” value=”6″ max=”9″>
<em>6 of 9 stages completed</em></progress>
<br />
Project #2<br />
<progress id=”bar” value=”20″ max=”100″>
<em>20% complete</em></progress>
<br />
Project #3<br />
<progress id=”bar” value=”12″ max=”20″>
<em>12/20 components completed</em></progress>
<br />
Project #4<br />
<progress id=”bar” value=”4″ max=”8″>
<em>50% complete</em></progress>
<br />
Project #5<br />
<progress id=”bar” value=”9″ max=”10″>
<em>9 out of 10 stages completed</em></progress>
</body>
</html>

This will be handy someday 🙂

The next google search result looks very good. Its specifically about jquery-mobile charting. Exactly what I need.

jQuery Mobile Charts

+ the source code on github

If this will be the result on my end, I will be a happy man indeed. Lets give it a try.

The example works just fine. Now I will try to embed this to my phonegap app. lets see how it goes…

ok. it took me 10 minutes to integrate the sample code to my html5 code. (just the sample, no functionallity yet).

I had one problem with the addition, at first it didn’t work and than I tried to add this code:

<script src=”JQMCharts/scripts/jquery.jqplot.min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/jqplot.pieRenderer.min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/jqplot.barRenderer.min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/jqplot.categoryAxisRenderer.min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/underscore-min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/hideAddressBar.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/app.js” type=”text/javascript”></script>

to the end of the file instead of the beginning.

this what fixed my problem.

I have no idea why…

anyways i don’t like this code so much. not very scalable…

So I gonna try this library:

http://www.jqplot.com/

ok so i downloaded jquery.jqplot.1.0.5r1122 and I’m following the basic installation instructions from the jqueryPlot website I hope it will be easy as it looks.

I added two files to my project and added the following lines

<!– jqueryplot –>
<script language=”javascript” type=”text/javascript” src=”jqueryplot/jquery.jqplot.min.js”></script>
<link rel=”stylesheet” type=”text/css” href=”jqueryplot/jquery.jqplot.css” />

I added a chart container:

<div id="chartdiv" style="height:400px;width:300px; "></div>

. and added the graph creation code

$.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]);

not worknig 😦

I will try to add

<script language=”javascript” type=”text/javascript” src=”jqueryplot/jquery.min.js”></script>

as well.

Still nothing.. the chart isn’t showing…

GOT IT!! The problem was as usual that my code aims for phonegap so the $.jqplot(‘chartdiv’,  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]); code wasn’t triggered because it was in the deviceReady event function. When I created a window.onLoad function instead – everything worked on Chrome.

 

Now I need to create a vertical bar chart. So I found this link.

Also succeeded to create a BarRender chart with it. and found this pretty awsume link to how add dynamic data to a jqplot chart.

I almost finished my phonegap + native java code for my mobile application.

I decided to take another background task to design it. I guess it will take some time and i’ll iterate over several designs so it about the right time to get started.

I found an interesting post on adobe website, and it links to a video on adobe-tv.

i’m familiar with photoshop, dreamweaver and phonegap so it shouldn’t be too hard on me 🙂