Friday, December 14, 2012

Bubble Sort Algorithm with PHP


Today I happened to have stumbled on "how algorithms shape our world" by Kevin Slavin. Kevin draws inspiration from real life scenes,Wall street ,  Amazon, Netflix to show how algorithms shape our world in all forms.

I was looking at the bubble sort algorithm , thought that I've never implemented it in php (I used usort before) and found how elegant  she is in Wikipedia.
From the books "The bubble sort is generally considered to be the simplest sorting algorithm.
Because of its simplicity and ease of visualization, it is often taught in introductory computer science courses. Because of its abysmal O(n2) performance, it is not used often for large (or even medium-sized) datasets.". We have this:


function bubbleSort( array &$array )
{
 do
 {
  $swapped = false;
  for( $i = 0, $c = count( $array ) - 1; $i < $c; $i++ )
  {
   if( $array[$i] > $array[$i + 1] )
   {
    list( $array[$i + 1], $array[$i] ) =
      array( $array[$i], $array[$i + 1] );
    $swapped = true;
   }
  }
 }
 while( $swapped );
}
"The bubble sort works by passing sequentially over a list, 
comparing each value to the one immediately after it. 
If the first value is greater than the second, 
their positions are switched.
Over a number of passes, at most equal to the number 
of elements in the list,all of the values drift into 
their correct positions(large values "bubble" rapidly
toward the end, pushing others down around them)." 
 
It's use basically is to sort arrays. 
So, I decided to write it in php.
Simply, we shall pass through the array in question 
using 2 for loops. For each of the value,
we shall compare the lower value with the upper value and
switch positions only if the lower value is less than 
the upper value. Hence we keep pushing bigger values 
behind:" they bubble up".
 
$array = array(1, 3, 4, 8, 9, 57, 11, 34, 78,90);

echo "Array before sorting";

print_r($array);

$array_count = count($array);

for($i=0; $i<=$array_count; $i++):

    for($j=0;$j<=$array_count; $j++):

        if( @$array[$i] < @$array[$j])

            {

              $tmp = @$array[$i];

              $array[$i] = $array[$j];

              $array[$j] = $tmp;

            }

    endfor;

endfor;

echo "<br/> After sorting: ";

print_r($array);

You could chose to do a better swapping using list, list($a,$b) = array($b,$a).

Hope you enjoyed the sort :)

Tuesday, November 27, 2012

Vision

Great people are attracted to great people and great visions; Bored people quit.


Sunday, November 18, 2012

Measure progress: Startup

...however, these tools for product improvement do not work the
same way for startups. If you are building the wrong thing,
optimizing the product or its marketing will not yield significant
results. A startup has to measure progress against a high bar:
evidence that a sustainable business can be built around its products
or services. That’s a standard that can be assessed only if a Startup
has made clear, tangible predictions ahead of time... -  Lean Startup

Wednesday, August 29, 2012

Monday, July 9, 2012

We Fell To Earth - The Double

Lyrics:
i don't care what u said so long ago
the double and the same one
it don't move what the .. save anyone
..
i can't tell if the thoughts mean anything
u don't ever say why
no offense ..
the double and the same one..
same sign.. same sign.. same sign.. same sign..

i don't care what u did so long ago
the double and the same one
it don't move when the thought fell anyone
it shook and it can't stay right
you never look what u say and u mean
u only look and u see what's in the mirror
u never look at what u see in a mirror
u wanna look at what u see under a mirror
same sign.. same sign.. same sign.. same sign..

I fell in Love with the song. I mean I think it's music!

Thursday, July 5, 2012

UNIVERSAL PRAYER



Lord, I believe in you: increase my faith.

I trust in you: strengthen my trust.

I love you let me love you more and more.

I am sorry for my sins deepen my sorrow.

 

I worship you as my first beginning,

I long for you as my last end,

I praise you as my constant helper,

I call on you as my loving protector.

 

Guide me by your wisdom,

Correct me with your justice,

Comfort me with your mercy,

Protect me with your power.

 

I offer you, Lord, my thoughts: to be fixed on you;

My words to have you as their theme;

My action to reflect my love for you;

My sufferings: to be endured for your greater Glory.

 

I want to do what you ask of me:

In the way you ask,

 For as long as you ask,

Because you ask it.

 

Lord enlighten my understanding,

Strengthen my will,

Purify my heart.

And make me holy.

 

Help me to repent of my past sins

And resist temptation in the future.

Help me to rise above my human weaknesses

And to grow stronger as a Christian.

 

Let me love you, my lord and my God,

And see myself as really am:

 A pilgrim in this world,

A Christian called to respect and love

All whose lives I touch,

Those under my authority,

My friends and enermies.

 

Help me to conquer anger with gentleness,*

Greed by generosity,

 Apathy by favour.

Help me to forget myself

And reach out toward others.

 

Make me prudent in planning,*

 Courageous in taking risk.

Make me patient in suffering,

Unassuming in prosperity.

 

Keep me Lord, attentive at prayer,*

Temperate in food and drink,

Diligent in my work,

Firm in my good intentions.

 

Let my conscience be clear,

My conduct without fault,

My speech blameless,*

My life well-ordered.*

Put me on guard against my human weaknesses.

Let me cherish your love for me,

Keep your law,

And come at last to your salvation.

 

Teach me to realize that this world is passing,

That my true future is the happiness of heaven,

And life to come is eternal.

 

Help me to prepare for death

With a proper fear of judgment,

But a greater trust in your goodness.

Lead me safely through death

To the endless joy of heaven.

Grant this through Christ our Lord. Amen.

 

thanks lizzy...you'll always have that special part in my heart  ;)

Saturday, June 23, 2012

My notes on Paul Graham's essay on wealth

Lately, I had a discussion with my friend  Bill Zimmerman who introduced me to Graham. I've found his essays and will be studying them one at a time.
This is the first of the essay I've taken : Paul Graham essay on wealth.
While I read, I take down notes. The notes include my own points and important lines drawn from the essay.
In Graham's words
"Startups usually involve technology, so much so that the phrase "high-tech startup" is almost redundant. A startup is a small company that takes on a hard technical problem."

The Proposition

"Economically, you can think of a Startup as a way to compress your whole working life into a few years. Instead of working at a low intensity for forty years, you work as hard as you possibly can for four. This pays especially well in technology, where you earn a premium for working fast"

Money and wealth
Money is not wealth.
Wealth is the fundamental thing, wealth is stuff we want, food, clothes, houses, cars, gadges, travel to interesting places, so on.
But wealth has money value. Money is no Garantee to wealth [my cousin raymond saying ]
Money is the medium to transport wealth.

About technology and leverage
Write once, run everywhere. Ditto for Wal-Mart.
Use difficulty as a guide not just in selecting the overall aim of your company, but also at decision points along the way. At Viaweb one of our rules of thumb was run upstairs. Suppose you are a little, nimble guy being chased by a big, fat, bully. You open a door and find yourself in a staircase. Do you go up or down? I say up. The bully can probably run downstairs as fast as you can. Going upstairs his bulk will be more of a disadvantage. Running upstairs is hard for you but even harder for him.

Deliberately sought hard problems...." If there were two features we could add to our software, both equally valuable in proportion to their difficulty, we'd always take the harder one. Not just because it was more valuable, but because it was harder. We delighted in forcing bigger, slower competitors to follow us over difficult ground. Like guerillas, startups prefer the difficult terrain of the mountains, where the troops of the central government can't follow. I can remember times when we were just exhausted after wrestling all day with some horrible technical problem. And I'd be delighted, because something that was hard for us would be impossible for our competitors.

This is not just a good way to run a startup. It's what a startup is." 


Getting Users
In a Startup, you're not just trying to solve problems. You're trying to solve problems that users care about.

Wealth and Power
Making wealth is not the only way to get rich.
Remember what a Startup is, economically: a way of saying, I want to work faster. Instead of accumulating money slowly by being paid a regular wage for fifty years, I want to get it over with as soon as possible. 

I look forward reading all the essays.
 

Sunday, June 17, 2012

Live fully with your heart

http://leelouzworld.files.wordpress.com/2011/07/happiness-heart.jpg
Everything is cheap. Except things not bought with money.
They are the best things in Life, which are free. Like Air and the Heart.
Don't live cheap, live fully with your heart.
I've come to believe these things revolve around the decision of true happiness.

Friday, June 15, 2012

How my typical weekend may look like - ( when I want to have space)

I usually have days like any other human.
At the end of the previous day or the start of the new day,  I do a program to guide my day, this is what I have today, this is an open diary ;)
I wish to have space. [start by stating what I wish. it's usually how I feel than thought.]

  • Finish client work:  7-10am
  • Attend project planing meeting: 10am
  • Return home to do Laundry and cleaning up...12-3:00pm visit book store 4pm-5pm.
  • Drink Milk shake / cappuccino [alone]
    Return home... Read...7pm-9:30pm
  • Go for prophetic night  9:30pm-6am.
  • -sleep()

Monday, May 28, 2012

The Proof of Your Love


"The Proof Of Your Love" - Lyrics


If  I sing but don't have love
I waste my breath with every song
I bring an empty voice, a hollow noise
If I speak with a silver tongue
Convince a crowd but don't have love
I leave a bitter taste with every word I say

So let my life be the proof,
The proof of Your love
Let my love look like You and what You're made of
How You lived, how You died
Love is sacrifice
So let my life be the proof,
The proof of Your love

If I give
To a needy soul but don't have love then who is poor?
It seems all the poverty is found in me

So let my life be the proof,
The proof of Your love
Let my love look like You and what You're made of
How You lived, how You died
Love is sacrifice
Oh, let my life be the proof,
The proof of Your love

When it's all said and done
When we sing our final song
Only love remains
Only love remains

Let my life be the proof,
The proof of Your love
Let my love look like You and what You're made of
How You lived, how You died
Love is sacrifice
So let my life be the proof,
The proof of Your love.
Something is right about the song. The lyrics, the music, may be everything
For King and Country - album crave.

Saturday, May 12, 2012

Don't give up Hope

From time to time while in the pursuit of our dreams, we are faced with circumstances. 
Some of them may deter  us and propel despair so bad that you fall into the "state" of  forgetting your original purpose.
 Sometimes someone will slap you out of it. Most times you'll survive because you can slap yourself out: don't give up hope!
A proper depiction of what I'm trying to say from my new all time favorite anime -- Code Geass :)

Sunday, April 22, 2012

Nothingness

I don't know which of the pics depicts how I feel. But I feel nothing. Empty, Apathy may be.
Apathy is worst than Hate or Love I learnt.
This song may have sent me into the mode. I still have it playing with headphones as I write. [Cigarettes seriously damages health but why do u keep smoking ?]

Simplify

                 When in doubt, simplify.

Thursday, March 8, 2012

Certain things are just Compatible in Life

I first listen to this music about 2 days ago and I instantly fell in love with it. The song had been cropped from the Roomate by Absalom Shu. It was anoying that  a nice song plays and finishes prematurely. So, we set out yesterday to find the song and behold, 15mins later we got it.
The song is featuring in my all times favorite. It's new each time I listen.
It's strange for it to enter into my all time favorite. I noticed in Life certain things are just compatible. It reminds me of the things that happen beyond our 5 senses. I'm compatible to this song, I mean all of it :).
Repeat, repeat, repeat....



~Lyrics~

The end begins just as it starts,
And leaves me wondering what we left behind.
Told me not to talk but please explain
My thoughts that float around my mind

So take a step back will you
Be alright, feel alright?

And now...

All this time when we walk we won't feel,
Put some time in a box it won't steal you

(Oooohhh)

Up ahead I see it I can find it, but I feel alive.
Followed me inside of a place
I felt like things would still be alright

And now...

All this time when we walk we won't feel
Put some time in a box it can steal you
All this time when I talk its not real, its not real, not real, not real, its not real

(Oooohhh)

All this time when we walk we won't feel
Put some time in a box it wont steal you
All this time when I walk, I wont feel, I wont feel
All this time when I talk its not real, its not real, not real, not real, its not real...

All this time when I talk its not real, its not real, its not real.

Great Northern - Houses and ME are compatible.

Sunday, February 12, 2012

Death should be our teacher - Teach us how to Live

The news of  Whitney Houston's dead this morning is a reminder of a blog post I was suppose to to publish.
In all my life I dodged from looking at corpses or even try to think while I went to or was brought near some one who is lying waiting  to be buried.
Well this fear had old founding, basically because:
  1. as I child I was told when you see a corpse you shall see the dead person while you sleep and walk at night.-- these were all childhood fears.
  2. The fear of dead, no matter how hard I try to pretend. 

Then last December, someone died whom I knew so I said to my self, this is the time for me to get close to the dead; as if I had a choice.
While at the mortuary, I experienced first hand dead bodies. While people where standing, passing here and there, doing this and that. I stood still only thinking: "how did this people live and now they are dead just like that". Seeing how the body was motionless, how the skin has deteriorated, how the person who had breathe could breathe no more.
This is not a new question for me but because I came close to dead bodies the question became part of me, part of my thinking as a whole.
Naturally every living being should be afraid to die.
My experience in coming close to the dead only reminded me of the life lessons, of how useless you become and lose form once you die.
Of how precious you  should treat life and Live.
The greatest love of all: “To love others you must first love yourself.”
Then I recall my Love and Life teacher: Leo Buscalgia - 1924-1998.

“It's not enough to have lived. We should be determined to live for something. May I suggest that it be creating joy for others, sharing what we have for the betterment of personkind, bringing hope to the lost and love to the lonely.” --Leo F. Buscaglia
Quotes from Leo .
In one of and the best of his works I've read, he lays emphasis
"Death should be our teacher" - to teach us how to live.
Living to me is:
  • making others happy, 
  • that there should be no tear,
  • no suffering
  • that there should be love. 
But life is difficult;
  • trying to make ends meet, 
  • trying to leave a legacy, trying to live and love not only you but love others as much as you love you; 
  • trying not to be sad,
  • trying not to compete with others but with yourself no matter how they force you,
  • trying to be happy always and make others happy, 
  • trying to achieve a dream even when every one but you see it,  
  • trying not to be afraid
  • trying to focus and not get distracted
  • Trying to avoid pain, hate and hurt, 
  • Surviving is though even if you have all things
  • Trying and trying until you reach a point where you no longer have to try.

And in the end, all this trying to live ends in Death. So that when you have achieved all what you call life, when you have achieved what you were living for, when you have achieved the why of creation and existence, then you should be proud of death as you are to be of rest after a long working day.

Prayer:
Lord teach me how to live in such a manner that I will not fear death, even when I see it.

Whitney Houston in Pictures






I Will Always Love You

I had a premonition yesterday. I told Quincy and some friends I was hanging out with that: "Someone I know or Someone connected to me is about to die". Well, I'm not sure it was about this death, except part of me was actually deep rooted in the singer's songs of which I did pay less attention to this connection till now?!. This morning getting up at 7:00am I learn from It's Quincy and Facebook that the Legendary singer Whitney Houston is dead, today 12th, February, 2012 at 3:00am at 48.

Remember One of my life decisions this year is to take a shock without expressing it in sadness emoticon. I should have made a sadness emoticon blog post for her death.
I will remember you for:
  1. The lives you touched.
  2. The light you put in people even when you were stumbling into darkness.
  3. For the courage you instill in me and as I grew up to understood the greatest love of all.
  4. I learning first from you that there is Greatness in Every being.
  5. For your beautiful and peaceful voice, very great energy.
  6. For the song that touch me more as I grew up as a child, till moment and forever:
  7. For the song I heard more by you played by those around me:

Thank you for the life you lived: I Will Always Love You! R.I.P.


Thursday, January 12, 2012

Who broke the replay button in 2011

I did not listen to music this year as I used to between 2006 -2010.
I compiled a list of the songs I played more this year, not necessarily songs made this year.
I had to do this list before the 1st but has been putting it off. Thanks to the groupI did it today :). 
In any other,  Enjoy!

                           

                            











Someone asked me: "How many hearts Adele has, because she always sings about broken heart" . I could not answer. May be some people are blessed with many hearts :).

People who slightly missed the above list:










Favorite Band I knew this year goes to :
The perishers.
Writing this post and still trying to break the replay button for Augustana :)

My story of MBOA

MBOA in Bakweri dialect means House. I wonder the several meanings in Different Dialects. I found MBOA in Limbe.
My story of  Mboa,






Great story :).

Wednesday, January 4, 2012

untitled

             

              rate, share and tell.

              Find what you Seek.





it means nothing. just made sense as i read our bizness plan :)

New year resolution

I always thought new year's resolutions are clearly pointless.


Simply because I end up losing vision of the resolution somewhere along the line or I get stuck in a thinking because of a certain resolution. After assessing the long list of resolutions for last year, I noticed that I had more than 55% of success. I was shocked.
I was making new year resolutions and this is part of my list . I just uplifted and I hope I can write mine in the Open diary :). Matt Might new year resolutions:

  • Read at least 12 hardback books from Cover to back - including novels.
  • Get closer and comit to God - read my bible often and attend fellowship more.
  • Do exercise often and learn a new sport.
  • Learn a new Computer programming language.
  • Keep to time more. Be a better time manager. Don't be late.
  • Act nicer to people I don't like, act nicer to the people I do like.
  • Watch more movies that make more meaning. Watch more family movies. The movies do not need to be a list movies.
  • Don't write the :( this year :)
populating...