Thursday, December 3, 2015

Code Generating Code

When database grows!

Today I was quite frustrated with the size of database I created yesterday. It took a whole of the day to design database terms. Then it took another whole day to create the necessary fields and tables. When I saw it today morning, looking at the code, I had to do all the copying and pasting of the common database methods in the php classes. (Classes are the means to create objects of same properties. Each object has its own collection of variables.) Looking at the whole 3 page list of tables, I really was considering an intensive task for the avalanche I created today.

Ideas happen to the lazy guys

There is a saying "Why we progressed in the society today is because we are getting more and more lazy." Maybe it is not a good thing to live a healthy life but believe me or not; we are always trying to find comfort in our lifestyle --- finding a way to live a lazy life. Well, the world behaves in a different way. For a person thinking to live a lazy life, another wise lazy guy helps him to trade the progression. For example, I may spend a whole 10 years to develop a wooden car that runs out of solar power and if another guy is spending his 10 years to develop an automatic plowing machine --able to do weeding as well as loosening the soil then after our feats, our results will bring a trigger of 20 years to life of people in just 5 years.

Speaking of the part

Well, enough of the nonsense and lets take code. I collected common methods in a separate file. Then I inquired the database system to give me list of table and ask each table the description of variables it held in its definition. Then the principle was simple. I just had to use arrays to load tables and use each item to load arrays of fields. It then was easy running the combined effort in generating class files in php. (Take each variable instance and loop it to create new file each time it encountered a table item). Now I can easily do a CRUD method using the classes I created. Well, it did saved me a time to cross consider whether I was right about the design I used. But also now with the code developed I can easily manage more database classes by using it.

Look at the code

Maybe you are wondering what I was really talking about! Well, you may want to grasp the idea. And here it is:

$file1 = fopen("includes/class/myclass.php","w");
$file2 = fopen("includes/class/data.txt", "r");
$code = fread($file2,filesize("includes". DS. "class". DS. "data.txt")) ;
fclose($file2);
// echo getcwd();
// echo filesize("includes". DS. "class". DS. "data.txt");

function find_by_sql($sql="") {
    global $database;
    $result_set = $database->query($sql);
    $object_array = array();
    while ($row = $database->fetch_array($result_set)) {
      $object_array[] = $row[0];
    }
    return $object_array;
  }

$myarray = find_by_sql('show tables');
print_r($myarray);

foreach ($myarray as $myclass) {
$file1 = fopen("includes/class/".  $myclass . ".php","w");
$clas = "class ". $myclass ."{";
// echo $myclass ."
";
// print_r( find_by_sql("desc ".$myclass));
// echo "
";
$var = '';
unset($w1);
$w1 = find_by_sql("desc ".$myclass);
foreach ($w1 as $key => $value) {
$var .= "
public $".$value .";";
}
// echo $var . "
";
$tb = "protected static db_fields = array('". join("', '", array_values($w1)) . "');";
// echo "
";
$output = "
$clas . "
" . $tb . "
" . $var . "
".
$code .
"} \n" .
" ?>" ;
fwrite($file1, $output);
fclose($file1);
}

Tuesday, September 8, 2015

Writing tips for making a good motivation letter

I am writing this tip for me. I collected these ideas from my brother's motivation letter. I don't know if he was truly aware of the content he has put into it, but I really loved the presentation of ideas in there.

First Motivation Heading:

Background

  1. Domestic Scenario
  2. International Scenario to compare for investment
  3. The investors (criteria where they want to invest and what field of interest does it catch)
  4. The factors of growth affecting the tension on your field of study.

Roles and Inclinations

  1. Challenges (How you overcame the challenges during your bachelor studies and what motivated you much)
  2. Motives (How the motives developed to pursue further career)
  3. Contribution (How you can contribute towards
    • time
    • money
    • energy
  • )

Professional Career:

  1. Why I pursue?
  2. What chances I got?
  3. What steps I walked over?
  4. What can I aid to?
  5. Why I need this course?
    • Growing Market
      • Where to start
      • When to start
      • What to fill up the gap

Relevance of Course for Employing Organization

Organization development

  • What the organization is about?
  • What program?
  • My TOR activities!
  • How I did my work with colleagues?
    1. How I felt about the work in progress of the institution?
    2. Why the progress is hindered?
    3. What skills are important for this job. emotions!!

Wednesday, January 13, 2010

POKHARA


My Grandparents use to tell me a story, in which, an angel flying on the sky saw a beautiful flower on the earth. Then, she tried to land on the earth. She slowly came down. Being more nearer, she found the flower more beautiful. So, she changed her mind and wanted to land on the petals of the flower. But she could not do it because flowers are weak and can not resist her load. So she later transformed herself as a bee so that the flower could resist her landing on the petals. But again, when she was about to land, she felt the fragrance of the flower. The fragrance of the flower forced her to change her plan once again. She thought if she would land and take out the nectar from the flower, then, other who visits the earth will not get such opportunity to smell it. So she left the flower on its own condition and with its own fragrance. She then transformed herself back to her original form and returned back and told her friends about the the beautiful thing she experienced. Pokhara is such a Flower in EARTH.Just imagine the flower as Pokhara and yourself as Angel. What would you do if you get such flower? I can not explain its beauty because it is something to be felt. You should visit Pokhara to find it out.

There is a carefree attitude here, as most visitors are about to start or have just finished a trek into the mountains.

Pokhara is Nepal’s holiday resort town. At around 6 to 8 hours from Kathmandu, Pokhara is located deep inside the Himalayas and sits on the edge of Lake Phewa Tal away from the main part of town. Lakeside, this part of town is full with lots of tourist and offers every thing that a visitor may need – barbers, massages, convenience stores, general supplies, outdoor clothing and off course your souvenir stores etc. The area near that lake has numerous hotels and guesthouses, and new ones are springing up all the time. The price starts from 200 rupees per night. There are also many restaurants and they tend to be very reasonably priced.Pokhara has some of the most amazing views of the Himalayan Mountains. Mt. Annapurna was breathtaking, especially if you are able to get a good view. The Nepalese are the nicest people I have ever encountered. Its been less than a year since I visited and I am already saving money for my next trip. This is the kind of place you'd want to retire in! It’s so amazing, the view of Annapurna range is awesome and pepole are really friendly.Food is goodBest time to travel--feb--marchAwesome sunriseLovely boating facilityGood trip for honeymooners