Upload Files to your Web Server using Git

If you upload files frequently to your web server, you’ll know how much of a pain it can be to upload only the files needed. I had resorted to another method of zipping everything on my computer, upload to the server, then extract from there replacing all my files. Butย as a lazy guy, this was simply unacceptable! And guess what? I found the perfect solution.

git-ftp
git-ftp (GitHub repo)
So, i install git-ftp on my Kubuntu.
You need to have an ftp account created on your web server.
Initially you need to push using this command
git ftp init -u <user> -p - ftp://host.example.com/public_html
Everytime your mates or yourself commit/push to your remote ย git repository, you run these 2 lines and the changes get reflected on your live server in less than 2 mins. ๐Ÿ˜€
git pull origin master
git ftp push --user <user> --passwd <password> ftp://host.example.com/public_html
It uploads only files that has been changed. It’s almost like magic. LOL ๐Ÿ˜›
You can even create a shell script for these 2 lines if you’re like lazy to the extreme. But i just press the up button in my terminal and the codes are already here. ๐Ÿ˜‰

Solar Water Heaters are Magic (even in Curepipe)

Been about a week since we installed a Solar Water Heater on our house. I must say it’s awesome! Government did a really nice initiative to subsidize these equipments.

Solar Water Heater in Curepipe

A Luxury
Once the water gets heated, it stays hot for 3 days. Hadn’t tried it but there was one day there was no sun and yet the water could be used to take a bath at night.

So yeah, it is working at Curepipe in Plaine Wilhems in winter. ๐Ÿ™‚

The Lazier, The More Modular Programmer

Might not be totally true but here’s my hypothesis: “Lazy programmers tend to code in a more modular way and do more automation.”

snapshot407I do like SQL. But don’t like to write it. So, i decided to write a class for adding/deleting/updating from database.

$sets['fname'] = 'John';
$sets['sname'] = 'Smith';
$where['sex'] = 'm';
$where['country'] = 'USA';

$db->update('users',$sets,$where);

equivalent to

UPDATE users SET fname = 'John',sname = 'Smith' WHERE sex = 'm' AND country = 'USA';

Another example of automation is when i want a clean setup of a website i’m working on. I just go on phpMyAdmin. I drop the database. The next time the engine of the website is triggered, it checks if database exists, creates it if not, runs an install script which will recreate the tables.

$db_selected = mysql_select_db($dbsettings['dbname'],$con);
if (!$db_selected) {
___mysql_query("CREATE DATABASE {$dbsettings['dbname']}",$con);
___$db_selected = mysql_select_db($dbsettings['dbname'],$con);
___// If an installer exists, we try to run it.
___if(file_exists(ROOTDIR.'inc/install.php')){
______header('Location: '.ROOTURL.'inc/install.php');
___}
}

This laziness pushed me to write a templating system in PHP for my university Web assignment so as my HTML and PHP codings are separate.

$recipes = $Recipes->get_multiple("ORDER BY timeposted DESC");
$recipelist = "";
foreach($recipes as $recipe)
_eval("\$recipelist .= \"". $templates->simple_get("gallery_recipe") ."\";");
eval("\$contents = \"".$templates->get_page("gallery_page")."\";");
eval("\$headerincludes = \"".$headerincludes."\";");
$templates->output_page($contents);

If i would been a “hard working” guy. I wouldn’t have bothered to do these extra simple things. I would have enough energy to write 100 update queries manually. Have long html codes inside PHP loops and so on..

What do you think?

Wisdom for Idiots

My theory: Wisdom at the hands of an idiot is twice as much as dangerous to a casual idiot.

I’m responsible for what I say, not for what you understand

This is in reference to the “wise quotes” people usually share on Facebook. Do you really think people /teens especially have become more mature with those wise quotes? I don’t think knives can be used as toys for any age group; neither can guns nor nuclear bombs..

// I may be an idiot too but I am afraid when others play with guns.