Things I tend to forget


Writer's Block

Every once in a while we all get it. I’m not talking about writing novels or articles, rather about writing code. You feel the code dancing around in your head but for some reason you cannot get it out on the keyboard! It’s a frustrating feeling, but it’ll pass…

Similar Posts:

    None Found




Huston, We have a House!

Yeah yeah, we do!
It’s in Zouk Mosbeh, Jesus The King inside road. It’s a nice and cosy little place (120+m2) with a small balcony facing the sea. I think I can get a google map for the place …
Umm, will post more info and pics hopefully later

Similar Posts:

    None Found




jqModal Fix

The thing I didn't like in AJAX related stuff was that first I don't know much Javascript, and second that there was no real way to debug the whole thing. Well, with some practice I think I'll get to understand JS, especially with jQuery. As for debugging, enter Venkman! You'll have to get used to it, but it doesn't take that long to get it working for you.
I needed Venkman last night as I was trying to get the tabs and the jqModal plugins to play nice together. The code is beautiful, maintainable, and small! However, I wasn't getting what I wanted and it got frustrating since no one seemed to be able to help.
So, after quite a bit of debugging and following the code around jQuery and jqModal (the tabs plugin is simply perfect, for what I need at least!) here was the solution:

/*
 * jqModal - Minimalist Modaling with jQuery
 *
 * Copyright (c) 2007 Brice Burgess , http://www.iceburg.net
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * $Version: 2007.02.14 +r6
 * slightly modified by Abdallah Deeb 
 */

(function($) {
$.fn.jqm=function(o,x,y){
var _o = {
zIndex: 3000,
overlay: 50,
overlayClass: 'jqmOverlay',
wrapClass: 'jqmWrap',
closeClass: 'jqmClose',
trigger: '.jqModal',
ajax: false,
target: false,
autofire: false,
focus: false
};
$.jqm.serial++; s = $.jqm.serial;
hash[s] = {c:$.extend(_o, o),active:false,w:this,o:false,u:$('input,select,button',this)[0]||this[0],cb:[($.isFunction(x))?x:false,($.isFunction(y))?y:false]};
$(_o.trigger).bind("click",{'s':s},function(e) {
	return (!hash[e.data.s]['active'])?$.jqm.open(hash[e.data.s],this):false;});
if(_o.autofire) $(_o.trigger).click();
return this;
}
$.fn.jqmClose=function(){var p=this.parent();
	this.hide().insertBefore(p); p.remove(); return this;}
$.jqm = {
open:function(h,trig){
	var h.t=trig;
	var c=h.c; h.cc='.'+c.closeClass;
	var z=c.zIndex; if (c.focus) z+=10; if (c.overlay == 0) z-=5;
	if(!$.isFunction(h.q)) h.q=function(){return $.jqm.close(h)};
	h['active']=true;

	var f=$('').css({'z-index':z-2,opacity:0});
	var o=$('
').css({'z-index':z-1,opacity:c.overlay/100}).addClass(c.overlayClass); $([f[0],o[0]]).css({height:$.jqm.pageHeight(),width:'100%',position:'absolute',left:0,top:0}); if (c.focus) { if($.jqm.x.length == 0) $.jqm.ffunc('bind'); $.jqm.x.push(s); o=f.add(o[0]).css('cursor','wait');} else if (c.overlay > 0){o.bind('click', h.q); o=($.jqm.ie6)?f.add(o[0]):o;} else o=($.jqm.ie6)?f.css('height','100%').prependTo(h.w):false; if (o) h.o=o.appendTo('body'); h.w.wrap('
'); if (c.ajax) { var r=c.target; r=(r)?(typeof r == 'string')?$(r,h.w):$(r):h.w; var url=c.ajax; url=(url.substr(0,1) == '@')?$(trig).attr(url.substring(1)):url; r.load(url, function() {$(h.cc,h.w).bind('click',h.q);}); } else h.w.find(h.cc).bind('click',h.q); (h.cb[0])?h.cb[0](h):h.w.show(); h.u.focus(); return false; }, close:function(h){var h['active'] = false; $(h.cc,h.w[0]).unbind('click',h.q); var x=$.jqm.x; if(x.length != 0) { x.pop(); if (x.length == 0) $.jqm.ffunc('unbind'); } (h.cb[1])?h.cb[1](h):h.w.jqmClose(); if(h.o) h.o.remove(); return false; }, pageHeight:function(){var d=document.documentElement; return Math.max(document.body.scrollHeight,d.offsetHeight,d.clientHeight || 0,window.innerHeight || 0); }, hash: {}, serial: 0, x: [], f:function(e) { var s=$.jqm.x[$.jqm.x.length-1]; if($(e.target).parents('#jqmID'+s).length == 0) { hash[s].u.focus(); return false;} return true; }, ffunc:function(t) {$()[t]("keypress",$.jqm.f)[t]("keydown",$.jqm.f)[t]("mousedown",$.jqm.f);}, ie6:$.browser.msie && typeof XMLHttpRequest == 'function' }; var hash=$.jqm.hash; })(jQuery);

Similar Posts:

    None Found




More jQuery

I’ve already written about JavaScript the easy way, but this is ridiculous. jQuery simply puts every other tool there is out there to shame. There are too many useful things in there, especially using the plugins, that one cannot start adding the features to the site/web-app.
I’ve been re-writing the web application for the MRP in the factory I work for, and things are getting there faster than I thought. Honestly, what’s holding me back are the logic that’s shifting day by day as we refine our processing, and the layout (CSS and stuff), but I have GE for that!
So, what am I using:

$("#element-id").corner("top"); // you can use many combinations for the rounded corners
$('#container').tabs({remote = true}); // loads stuff using AJAXially
$('#myForm').ajaxForm(options);
$('#myForm').ajaxSubmit(options);

Similar Posts:

    None Found




Weekend Blues, and Greens, and other colors…

Umm, Weekends are swishing by just like that.
This Friday was weee…
Then on Saturday, afternoon, we had a quick Bayd-b’Awarma. Then went for a walk with the parents in Burj Hammoud. It was, well, too long! I’m getting old, I can’t even walk for 4 hours straight anymore
But, we topped it with a wonderful dinner with Mat 😀 Guess where?! Yep, none else than the Pasta di Casa, italian resto.
We had: Gnocchi Pesto (Paypouy), Carbonara Ham (Mat), Caneloni (Me).
And it went on till about 12+
On Sunday, we were invited to the Aboud’s place. Nice family, coming from Liberia, Africa. So we had a very nice African meal: Chicken with Peanut Butter. It was a nice afternoon. And after some “rest”, I went with Barkoosh to find Paypouy again and went for a nice dinner at Bread & Brown in Jounieh.
Paypouy’s been on my case about the difference between Jounieh, Zouk and Kaslik. As it turns out, these are actually different areas in Keserwan, go figure. Oh, and there are 2 Zouks (as it turns out, they are 3 in fact!) I won’t go into it any more… Paypouy will soon, with Graphics and Maps from Google (Heh, Yeah Right!) 😛

Similar Posts:

    None Found




Appliances [Round One]

We spent the day yesterday (Lebanese official holiday Mar Maroun) in large stores, looking for appliances.
It seems that everyone has the same brands give or take 1 or 2 that are either their own brand, or something totally unheard of.
The largest choice I found was at Abed Tahan & Sons. I could be wrong of course!
The range of refrigerators starts at 560USD and goes up to 1500USD for normal models. Of course, you can find larger ones for 3K and 5K, but I’m not going to buy one of those, not now anyway 😉
We didn’t exactly know what washing machine to look for. So, we ended up looking at everything from small ones with the 5Kg load to the large 8+Kg load. Again, it’s 300USD to 650USD. Some models where even priced in Eur, go figure!
As for the stove, 300 to 800USD is the range. Some of these are quite nice. I especially like the ones that look heavy duty, with large black metal cookers. They give the impression you’re meaning business while in the kitchen 😀
Ah, and last but by far not least: the TV. You can get a TV for 50USD these days. Heh, yeah right! A Sony 32″ goes for about a 1000USD, a similarly sized “lesser” quality TV goes for, well less! But simply looking at them side by side tells you why… Anyway, we’re still looking into it, Paypouy might have to buy that one herself 😛
Oh, that leaves out the Microwave (120USD Max), the “hoover” (60-100USD), the iron (20-50USD), etc… but we figured we’d get these as we go.

All in all, it’s a dirty job, but someone’s got to buy all this stuff. Hope you’re taking notes, might come in handy some day. Of course, if you know something I don’t, please send me a comment.

Similar Posts:

    None Found




CRUD PHP

It’s not crude, it’s CRUD (Create, Read, Update, and Delete).
This stuff should be easy to do. However, sticking to the SQL basics is not going to cut it when doing this much record handling. It simply gets too tedious after a while.
Looking for a good solution took me to RoR and its ActiveRecord. However, I’m back in PHP with CakePHP and its own paradigms. While it’s nice and dandy, I had spent a lot of time working with my own code that I am hating the move to CakePHP. So, I went back to search for something that will do the work while keeping me in charge. And below are my results:

Similar Posts:

    None Found




HOWTO: Build a house

We’re getting married soon*, and I do like to document everything. So starting today, I’m going to disclose some of the things I’m doing/learning, in the hope that it would help someone somewhere!

First and foremost, find a house. When you do, get/make the floor plans so that you could use them when you buy stuff for the house. Attached to this entry is a sketch of one house we saw.

After that, you need to go shopping. Here’s my list (created while discussing the subject with Paypouy).

  1. 3afesh
    1. Bedroom
    2. Living Room
    3. Salon
    4. Kitchen
  2. Utilities & Appliances
    1. Kitchen ware
    2. Berrad, Ghessaleh, Furn Gaz
    3. TV

The above list is by no means complete. Soon, I’ll have it fixed with a good translation (non-Lebanese), and perhaps price ranges for the specific items at the time of the writing.

Any comments are welcome.


* exactly how soon is debatable

Similar Posts:

    None Found




Javascript the easy way

I have mentioned before that I don't like Javascript. I'll be honest about the reasons. Some may say it's not safe or that the code is too permissive… whatever! I say I'm too lazy to learn it the way I like to learn a normal language, and I feel I have too many bits and bytes that I have to search for in an endless chaos to find the right docs.
Anyway, I finally found the easy way out. I had previously thought I did, when I found the prototype library. It was a nice one, and still is. However, it's lacking a good documentation. But now, I found an even better solution: the jQuery library. You might take a look at their site, it's quite loaded with features and docs, even plugins that help a lazy old programmer do new tricks.
One thing I made using jQuery is the following

';
// snippet
while ( $row = mysql_fetch_assoc($res) ) { 
		if ( $row_num % 2 == 0 ) { 
			$table .= '';
		} else { 
			$table .= '';
		}
		$table .= ''.$row['ID'].'';
		$table .= '';
		$table .= '...';
		$table .= '';
		$table .= '';
		$table .= ''; 
		$table .= 'more information ...';
		$table .= '';
		
		$row_num += 1;
	}
/* snippet */
.more { 
	display: none;
}

Similar Posts:

    None Found