Sunday, January 29, 2012

Dreamweaver 5.5 - viewing android app in emulator

If an app will not load from dreamweaver into the android emulator and the following error show in the build.log

Install file not specified.
'ant install' now requires the build target to be specified as well.
ant debug install
ant release install
ant instrument install
This will build the given package and install it.
Alternatively, you can use
ant installd
ant installr
ant installi
ant installt
to only install an existing package (this will not rebuild the package.)


find the build.xml file, located in the target directory of the app that was being built...
at the end of the file alter the line

<import file="${sdk.dir}/tools/ant/build.xml" />

to

<import file="${sdk.dir}/tools/ant/build.xml" as="imported" />

<!-- Override the target to add the dependency -->
<target name="install"
depends="-set-debug-files,imported.install" />

As explained here , something to do with the the most recent Android SDK has an extra parameter that is not yet supported by the PhoneGap integration kit in Dreamweaver. n.b. Before attempting to build and emulate again, the files in the bin folder of the target directory must be deleted.



Another error can occur if more than one emulator/device is running, so for example if an android phone is plugged in via usb and an emulator also running, the app will not load in either, so just run one at a time.

Friday, January 27, 2012

The Happy Prince

High above the city, on a tall column, stood the statue of the Happy

Prince. He was gilded all over with thin leaves of fine gold,
for eyes he had two bright sapphires, and a large red ruby glowed on
his sword-hilt.

He was very much admired indeed. “He is as beautiful
as a weathercock,” remarked one of the Town Councillors who wished
to gain a reputation for having artistic tastes; “only not quite
so useful,” he added, fearing lest people should think him unpractical,
which he really was not.

“Why can’t you be like the Happy Prince?” asked
a sensible mother of her little boy who was crying for the moon.
“The Happy Prince never dreams of crying for anything.”

“I am glad there is some one in the world who is quite happy,”
muttered a disappointed man as he gazed at the wonderful statue.

“He looks just like an angel,” said the Charity Children
as they came out of the cathedral in their bright scarlet cloaks and
their clean white pinafores.

“How do you know?” said the Mathematical Master, “you
have never seen one.”

“Ah! but we have, in our dreams,” answered the children;
and the Mathematical Master frowned and looked very severe, for he did
not approve of children dreaming.

One night there flew over the city a little Swallow. His friends
had gone away to Egypt six weeks before, but he had stayed behind, for
he was in love with the most beautiful Reed. He had met her early
in the spring as he was flying down the river after a big yellow moth,
and had been so attracted by her slender waist that he had stopped to
talk to her.

“Shall I love you?” said the Swallow, who liked to come
to the point at once, and the Reed made him a low bow. So he flew
round and round her, touching the water with his wings, and making silver
ripples. This was his courtship, and it lasted all through the
summer.

“It is a ridiculous attachment,” twittered the other
Swallows; “she has no money, and far too many relations”;
and indeed the river was quite full of Reeds. Then, when the autumn
came they all flew away.

After they had gone he felt lonely, and began to tire of his lady-love.

“She has no conversation,” he said, “and I am afraid
that she is a coquette, for she is always flirting with the wind.”
And certainly, whenever the wind blew, the Reed made the most graceful
curtseys. “I admit that she is domestic,” he continued,
“but I love travelling, and my wife, consequently, should love
travelling also.”

“Will you come away with me?” he said finally to her;
but the Reed shook her head, she was so attached to her home.

“You have been trifling with me,” he cried. “I
am off to the Pyramids. Good-bye!” and he flew away.

All day long he flew, and at night-time he arrived at the city.
“Where shall I put up?” he said; “I hope the town
has made preparations.”

Then he saw the statue on the tall column.

“I will put up there,” he cried; “it is a fine
position, with plenty of fresh air.” So he alighted just
between the feet of the Happy Prince.

“I have a golden bedroom,” he said softly to himself
as he looked round, and he prepared to go to sleep; but just as he was
putting his head under his wing a large drop of water fell on him.

“What a curious thing!” he cried; “there is not a
single cloud in the sky, the stars are quite clear and bright, and yet
it is raining. The climate in the north of Europe is really dreadful.
The Reed used to like the rain, but that was merely her selfishness.”

Then another drop fell.

“What is the use of a statue if it cannot keep the rain off?”
he said; “I must look for a good chimney-pot,” and he determined
to fly away.

But before he had opened his wings, a third drop fell, and he looked
up, and saw—Ah! what did he see?

The eyes of the Happy Prince were filled with tears, and tears were
running down his golden cheeks. His face was so beautiful in the
moonlight that the little Swallow was filled with pity.

“Who are you?” he said.

“I am the Happy Prince.”

“Why are you weeping then?” asked the Swallow; “you
have quite drenched me.”

“When I was alive and had a human heart,” answered the
statue, “I did not know what tears were, for I lived in the Palace
of Sans-Souci, where sorrow is not allowed to enter. In the daytime
I played with my companions in the garden, and in the evening I led
the dance in the Great Hall. Round the garden ran a very lofty
wall, but I never cared to ask what lay beyond it, everything about
me was so beautiful. My courtiers called me the Happy Prince,
and happy indeed I was, if pleasure be happiness. So I lived,
and so I died. And now that I am dead they have set me up here
so high that I can see all the ugliness and all the misery of my city,
and though my heart is made of lead yet I cannot chose but weep.”

“What! is he not solid gold?” said the Swallow to himself.

He was too polite to make any personal remarks out loud.

“Far away,” continued the statue in a low musical voice,
“far away in a little street there is a poor house. One
of the windows is open, and through it I can see a woman seated at a
table. Her face is thin and worn, and she has coarse, red hands,
all pricked by the needle, for she is a seamstress. She is embroidering
passion-flowers on a satin gown for the loveliest of the Queen’s
maids-of-honour to wear at the next Court-ball. In a bed in the
corner of the room her little boy is lying ill. He has a fever,
and is asking for oranges. His mother has nothing to give him
but river water, so he is crying. Swallow, Swallow, little Swallow,
will you not bring her the ruby out of my sword-hilt? My feet
are fastened to this pedestal and I cannot move.”

“I am waited for in Egypt,” said the Swallow. “My
friends are flying up and down the Nile, and talking to the large lotus-flowers.
Soon they will go to sleep in the tomb of the great King. The
King is there himself in his painted coffin. He is wrapped in
yellow linen, and embalmed with spices. Round his neck is a chain
of pale green jade, and his hands are like withered leaves.”

“Swallow, Swallow, little Swallow,” said the Prince,

“will you not stay with me for one night, and be my messenger?
The boy is so thirsty, and the mother so sad.”

“I don’t think I like boys,” answered the Swallow.
“Last summer, when I was staying on the river, there were two
rude boys, the miller’s sons, who were always throwing stones
at me. They never hit me, of course; we swallows fly far too well
for that, and besides, I come of a family famous for its agility; but
still, it was a mark of disrespect.”

But the Happy Prince looked so sad that the little Swallow was sorry.
“It is very cold here,” he said; “but I will stay
with you for one night, and be your messenger.”

“Thank you, little Swallow,” said the Prince.

So the Swallow picked out the great ruby from the Prince’s
sword, and flew away with it in his beak over the roofs of the town.

He passed by the cathedral tower, where the white marble angels were
sculptured. He passed by the palace and heard the sound of dancing.
A beautiful girl came out on the balcony with her lover. “How
wonderful the stars are,” he said to her, “and how wonderful
is the power of love!”

“I hope my dress will be ready in time for the State-ball,”
she answered; “I have ordered passion-flowers to be embroidered
on it; but the seamstresses are so lazy.”

He passed over the river, and saw the lanterns hanging to the masts
of the ships. He passed over the Ghetto, and saw the old Jews
bargaining with each other, and weighing out money in copper scales.
At last he came to the poor house and looked in. The boy was tossing
feverishly on his bed, and the mother had fallen asleep, she was so
tired. In he hopped, and laid the great ruby on the table beside
the woman’s thimble. Then he flew gently round the bed,
fanning the boy’s forehead with his wings. “How cool
I feel,” said the boy, “I must be getting better”;
and he sank into a delicious slumber.

Then the Swallow flew back to the Happy Prince, and told him what
he had done. “It is curious,” he remarked, “but
I feel quite warm now, although it is so cold.”

“That is because you have done a good action,” said the
Prince. And the little Swallow began to think, and then he fell
asleep. Thinking always made him sleepy.

When day broke he flew down to the river and had a bath. “What
a remarkable phenomenon,” said the Professor of Ornithology as
he was passing over the bridge. “A swallow in winter!”

And he wrote a long letter about it to the local newspaper. Every
one quoted it, it was full of so many words that they could not understand.

“To-night I go to Egypt,” said the Swallow, and he was
in high spirits at the prospect. He visited all the public monuments,
and sat a long time on top of the church steeple. Wherever he
went the Sparrows chirruped, and said to each other, “What a distinguished
stranger!” so he enjoyed himself very much.

When the moon rose he flew back to the Happy Prince. “Have
you any commissions for Egypt?” he cried; “I am just starting.”

“Swallow, Swallow, little Swallow,” said the Prince,
“will you not stay with me one night longer?”

“I am waited for in Egypt,” answered the Swallow.
“To-morrow my friends will fly up to the Second Cataract.
The river-horse couches there among the bulrushes, and on a great granite
throne sits the God Memnon. All night long he watches the stars,
and when the morning star shines he utters one cry of joy, and then
he is silent. At noon the yellow lions come down to the water’s
edge to drink. They have eyes like green beryls, and their roar
is louder than the roar of the cataract.

“Swallow, Swallow, little Swallow,” said the Prince,
“far away across the city I see a young man in a garret.
He is leaning over a desk covered with papers, and in a tumbler by his
side there is a bunch of withered violets. His hair is brown and
crisp, and his lips are red as a pomegranate, and he has large and dreamy
eyes. He is trying to finish a play for the Director of the Theatre,
but he is too cold to write any more. There is no fire in the
grate, and hunger has made him faint.”

“I will wait with you one night longer,” said the Swallow,
who really had a good heart. “Shall I take him another ruby?”

“Alas! I have no ruby now,” said the Prince; “my
eyes are all that I have left. They are made of rare sapphires,
which were brought out of India a thousand years ago. Pluck out
one of them and take it to him. He will sell it to the jeweller,
and buy food and firewood, and finish his play.”

“Dear Prince,” said the Swallow, “I cannot do that”;
and he began to weep.

“Swallow, Swallow, little Swallow,” said the Prince,
“do as I command you.”

So the Swallow plucked out the Prince’s eye, and flew away
to the student’s garret. It was easy enough to get in, as
there was a hole in the roof. Through this he darted, and came
into the room. The young man had his head buried in his hands,
so he did not hear the flutter of the bird’s wings, and when he
looked up he found the beautiful sapphire lying on the withered violets.

“I am beginning to be appreciated,” he cried; “this
is from some great admirer. Now I can finish my play,” and
he looked quite happy.

The next day the Swallow flew down to the harbour. He sat on
the mast of a large vessel and watched the sailors hauling big chests
out of the hold with ropes. “Heave a-hoy!” they shouted
as each chest came up. “I am going to Egypt”! cried
the Swallow, but nobody minded, and when the moon rose he flew back
to the Happy Prince.

“I am come to bid you good-bye,” he cried.

“Swallow, Swallow, little Swallow,” said the Prince,

“will you not stay with me one night longer?”

“It is winter,” answered the Swallow, “and the
chill snow will soon be here. In Egypt the sun is warm on the
green palm-trees, and the crocodiles lie in the mud and look lazily
about them. My companions are building a nest in the Temple of
Baalbec, and the pink and white doves are watching them, and cooing
to each other. Dear Prince, I must leave you, but I will never
forget you, and next spring I will bring you back two beautiful jewels
in place of those you have given away. The ruby shall be redder
than a red rose, and the sapphire shall be as blue as the great sea.”

“In the square below,” said the Happy Prince, “there
stands a little match-girl. She has let her matches fall in the
gutter, and they are all spoiled. Her father will beat her if
she does not bring home some money, and she is crying. She has
no shoes or stockings, and her little head is bare. Pluck out
my other eye, and give it to her, and her father will not beat her.”

“I will stay with you one night longer,” said the Swallow,
“but I cannot pluck out your eye. You would be quite blind
then.”

“Swallow, Swallow, little Swallow,” said the Prince,
“do as I command you.”

So he plucked out the Prince’s other eye, and darted down with
it. He swooped past the match-girl, and slipped the jewel into
the palm of her hand. “What a lovely bit of glass,”
cried the little girl; and she ran home, laughing.

Then the Swallow came back to the Prince. “You are blind
now,” he said, “so I will stay with you always.”

“No, little Swallow,” said the poor Prince, “you
must go away to Egypt.”

“I will stay with you always,” said the Swallow, and
he slept at the Prince’s feet.

All the next day he sat on the Prince’s shoulder, and told
him stories of what he had seen in strange lands. He told him
of the red ibises, who stand in long rows on the banks of the Nile,
and catch gold-fish in their beaks; of the Sphinx, who is as old as
the world itself, and lives in the desert, and knows everything; of
the merchants, who walk slowly by the side of their camels, and carry
amber beads in their hands; of the King of the Mountains of the Moon,
who is as black as ebony, and worships a large crystal; of the great
green snake that sleeps in a palm-tree, and has twenty priests to feed
it with honey-cakes; and of the pygmies who sail over a big lake on
large flat leaves, and are always at war with the butterflies.

“Dear little Swallow,” said the Prince, “you tell
me of marvellous things, but more marvellous than anything is the suffering
of men and of women. There is no Mystery so great as Misery.
Fly over my city, little Swallow, and tell me what you see there.”

So the Swallow flew over the great city, and saw the rich making
merry in their beautiful houses, while the beggars were sitting at the
gates. He flew into dark lanes, and saw the white faces of starving
children looking out listlessly at the black streets. Under the
archway of a bridge two little boys were lying in one another’s
arms to try and keep themselves warm. “How hungry we are!”

they said. “You must not lie here,” shouted the Watchman,
and they wandered out into the rain.

Then he flew back and told the Prince what he had seen.

“I am covered with fine gold,” said the Prince, “you
must take it off, leaf by leaf, and give it to my poor; the living always
think that gold can make them happy.”

Leaf after leaf of the fine gold the Swallow picked off, till the
Happy Prince looked quite dull and grey. Leaf after leaf of the
fine gold he brought to the poor, and the children’s faces grew
rosier, and they laughed and played games in the street. “We
have bread now!” they cried.

Then the snow came, and after the snow came the frost. The
streets looked as if they were made of silver, they were so bright and
glistening; long icicles like crystal daggers hung down from the eaves
of the houses, everybody went about in furs, and the little boys wore
scarlet caps and skated on the ice.

The poor little Swallow grew colder and colder, but he would not
leave the Prince, he loved him too well. He picked up crumbs outside
the baker’s door when the baker was not looking and tried to keep
himself warm by flapping his wings.

But at last he knew that he was going to die. He had just strength
to fly up to the Prince’s shoulder once more. “Good-bye,
dear Prince!” he murmured, “will you let me kiss your hand?”

“I am glad that you are going to Egypt at last, little Swallow,”
said the Prince, “you have stayed too long here; but you must
kiss me on the lips, for I love you.”

“It is not to Egypt that I am going,” said the Swallow.
“I am going to the House of Death. Death is the brother
of Sleep, is he not?”

And he kissed the Happy Prince on the lips, and fell down dead at
his feet.

At that moment a curious crack sounded inside the statue, as if something
had broken. The fact is that the leaden heart had snapped right
in two. It certainly was a dreadfully hard frost.

Early the next morning the Mayor was walking in the square below
in company with the Town Councillors. As they passed the column
he looked up at the statue: “Dear me! how shabby the Happy Prince
looks!” he said.

“How shabby indeed!” cried the Town Councillors, who
always agreed with the Mayor; and they went up to look at it.

“The ruby has fallen out of his sword, his eyes are gone, and
he is golden no longer,” said the Mayor in fact, “he is
litttle beter than a beggar!”

“Little better than a beggar,” said the Town Councillors.

“And here is actually a dead bird at his feet!” continued
the Mayor. “We must really issue a proclamation that birds
are not to be allowed to die here.” And the Town Clerk made
a note of the suggestion.

So they pulled down the statue of the Happy Prince. “As
he is no longer beautiful he is no longer useful,” said the Art
Professor at the University.

Then they melted the statue in a furnace, and the Mayor held a meeting
of the Corporation to decide what was to be done with the metal.
“We must have another statue, of course,” he said, “and
it shall be a statue of myself.”

“Of myself,” said each of the Town Councillors, and they
quarrelled. When I last heard of them they were quarrelling still.

“What a strange thing!” said the overseer of the workmen
at the foundry. “This broken lead heart will not melt in
the furnace. We must throw it away.” So they threw
it on a dust-heap where the dead Swallow was also lying.

“Bring me the two most precious things in the city,”

said God to one of His Angels; and the Angel brought Him the leaden
heart and the dead bird.

“You have rightly chosen,” said God, “for in my
garden of Paradise this little bird shall sing for evermore, and in
my city of gold the Happy Prince shall praise me.”


(ebook can be downloaded here)

Friday, January 20, 2012

Twitter rss feed url

To access a twitter rss feed the url is now
http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=xxxxx

where xxxxx is the twitter login name

It took me ages to find as Twitter no longer advertises rss feeds and I will probably forget it later so it is here for posterity and anyone else who may be looking for it.

Saturday, January 07, 2012

Srila Bhaktikumuda Santa Goswami Maharaja

Srila Bhaktikumuda Santa Goswami Maharaja, the last remaining disciple of Srila Bhaktisidhanta Saraswati Thakura Prabhupada left this world today at 1am. The well known founder of the Krishna Consciousness Movement, A.C Bhaktivedanta Swami Prabhupada, was also a disciple of Srila Bhaktisidhanta Saraswati Thakura Prabhupada, one of his God Brothers.

He is one in a line of disciplic succession of Gaudiya Vaishnavas, that will be continued by his own disciples and beyond.

Nityananda Gauranga





Thursday, January 05, 2012

PHP - Parsing a csv file created by Excel

Useful for updating tabular data on a website, without editing any html. Especially if there is no access to a database to upload the info. I found this function at php.net. It returns an array with all the data in the csv file...



function parse_csv($file,$comma=',',$quote='"',$newline="\n") {

$db_quote = $quote . $quote;

// Clean up file
$file = trim($file);
$file = str_replace("\r\n",$newline,$file);

$file = str_replace($db_quote,'"',$file); // replace double quotes with " HTML entities
$file = str_replace(',",',',,',$file); // handle ,"", empty cells correctly

$file .= $comma; // Put a comma on the end, so we parse last cell


$inquotes = false;
$start_point = 0;
$row = 0;

for($i=0; $i<strlen($file); $i++) {

$char = $file[$i];
if ($char == $quote) {
if ($inquotes) {
$inquotes = false;
}
else {
$inquotes = true;
}
}

if (($char == $comma or $char == $newline) and !$inquotes) {
$cell = substr($file,$start_point,$i-$start_point);
$cell = str_replace($quote,'',$cell); // Remove delimiter quotes
$cell = str_replace('"',$quote,$cell); // Add in data quotes
$data[$row][] = $cell;
$start_point = $i + 1;
if ($char == $newline) {
$row ++;
}
}
}
return $data;
}

$filename = "/path/to/file.csv";
$fd = fopen ($filename, "r");
$file = fread ($fd,filesize ($filename));


$new_array=parse_csv($file); // Returns an array of data from the csv file



Then the array can be used the same way a returned mysql result set would be used (see here). The array can be searched (see previous post here) or to simply access elements from the returned array you can simply call individual elements as such...


//line 1 data
echo $new_array[0][0];
echo $new_array[0][1];
echo $new_array[0][2];
//etc
//line 2 data
echo $new_array[1][0];
echo $new_array[1][1];
echo $new_array[1][2];
//etc


To pick out random lines from a csv (eg.with 3 columns year,day,month) and use that data the rand function can be used as follows...



$num=count($new_array);
$num=$num-1;//minus one to cope with 0 in array
$i=rand (0, $num );


$year=$new_array[$i][0];
$day=$new_array[$i][1];
$month=$new_array[$i][2];

echo "The random year is ".$year.". The random day is ".$day.". The random month is ".$month;