Cdeveloper's Posts
Nairaland Forum › Cdeveloper's Profile › Cdeveloper's Posts
Hello WMasters what do you make of a Forum for Nigerian Students Community where problems relating to them can be addressed? i thought about it for a while and my friend and i decided to put up something using smf. Review www.youbanize.com and give your candid feedback, will appreciate it a lot |
What does the house make of a Nigerian Students Forum? Well i thought about it and decided to come up with something.Please check it out at www.youbanize.com and give your feedback will appreciate it. Besides ALL ABU students in the house find your Registration Guideline for 2009/2010 Academic Session at the site thanks |
I one of my project i was wondering how to build an auto grow textarea box. What i mean is a textarea control that automarically grows when you are typing in it much like what you have on FB, so i googled for a jQuery plugin and found one written by John (the author of JQuery) and one of his friend, so i thought since he is the author of the framework why won't the plugin work. Well to my surprise it was not efficient and kind of like freezes the browser intermittently. So i googled around further looking for a better option,when i was getting no positive result. i decided to think it through and implement it. What is the logic? simple, when the textarea in question gets a focus create a div element that has Exactly the same style as the textarea and insert it immediately after the textarea. When characters are typed into the textarea replicate it in the div you created and watch the height of the div. Whenever the div height changes it is time to change the height of the textarea by whatever amount the div's height changed.This could be a shrink or an expansion. Armed with this knowledge i set out to implement it. First i want the to target the onfocus event of the textarea and i want the code not to recreate the div whenever the textarea loses and regains focus, so i will need an object that instantiates itself whenever the textarea gets focus but checks if the div already exists or not. Secondly i want the code to be decoupled so that i can reuse it as many times i want and on as many textarea a can be found on the page. Since all the textarea i am using a style by a single class and they each have an id and a name. i create an instance of the autogrow object with the id of each textarea, Lastly i want to control the maximum number of characters that can be typed and i want it to be dynamic. With this requirements in mind below is the implementation:
That completes the code and it work with jQuery library in addition to the code you need to define a css class named"autogrow" and set the height propertity to auto; this will enable the clone div to automatically expand or shrink in addition to the css class of the textarea Also use css class to define the height and width of the textarea, Don't use rows and cols for eample if i want to use this code for a textarea that has the following rules: CSS: .test { width:300px; height:25px; overflow-y:hidden; font-size:12px; font-weight:normal; color:#333; } .autogrow { height:auto; } i will attach the code like this <textarea id='growthis' name='growthis' class='test' onfocus="(new CDeveloperGrow(this)).setFocus('test',300)"></textarea> This is just about the mystery of auto grow and you can test it, tweak it, use it for you next stunning project and enjoy it. if you have an issue hala back NOTE: jquery library must be loaded in other for this to work or better still you can re-factor the code and remove the jQuery thing |
This is intended for all the Nigerian Javascript Developers that are using or want to start using the jQuery Javascript Framework. This Thread focuses on speeding up the usage or understanding of the Framework. Post your puzzles and find solutions from other jQuery veterans. |
Thanks alot people for the comments, what i mean by porting to other browsers is not in a sense recoding the entire site again to display as it should on them what i mean is this. I do the site layout in the Fox and style it in such a away that both the beloved IE8 and Fox family renders almost the same and every other styling is done at the same time. When i am done with that, I just make i copy of the master css and then delete every thing else but the layout css, those are the one i tweek to get he same layout other browsers. Its is painless for me. Again i am wating for that moment when the cafes will upgrade their systems for people to enjoy their the browsing.It is the Nigerian bug i should say Make money at the expense of others. I remember a cafe i went to with my laptop to upload some files i, i spent 20 minutes just waiting to read my company mail, i got frustrated and left that place even though i paid for an hour. That is an experiences, Perhaps there should be regulations or some kind of standard that cafe operators must maintain in other to run a cafe. |
I am afraid you can not run away from it cos its the default browser for our cafe guys who want to maximize profit and minimize expenses by putting up what i call mono-chrome computers for people to browsing with. This is actual a test of how good you a developer or designer you are, the ability to port your design to all the major browsers both grade A and older browsers. I build with the Fox browser and when i am done with the entire design i port to wired IE6 and IE7, cos both Fox and IE8 renders almost the same. My method is to create stylesheets from the master stylesheet,stripeout what is common in both and only tweak those elements that are having problem rendering well in IE6 and IE7 The browser war is a cold war that we developers can not avoid. |
Questions i suppose require answers |
When i started out with programming my mentor an Indian once told me that in learning programming you do not just learn the syntax and semantic and then relax and feel like a programmer rather you strive to learn the philosophy ,the weakness and the strength the language cos at a point in your coding life you learn to apply the strengths of a language while keeping its weakness at a minimum. My friend above posted a request wanting to know more about MVC pattern , perhaps it has captured his attention and all i could see was a reference to a wiki where he will find nothing but theories about MVC. Some say that MVC is not applicable in some areas i agree but if you ask me , the best pattern i have seen applicable to web developement is the same pattern we are talking about here MVC Just like the name sound MVC,Model---View---Controller if our notion of this pattern is simply the separation of app into three parts namely the Model(database etc), View(interface,html etc) and Controller(some serverside scripts etc) then we will not understand the true meaning of the pattern and when we do not understand that, then we can not use what we have limited know about. I must let the people here know that MVC is applicable not only in the serverside but also in the clientside with pure Javascript. The birth of object oriented programming spawned the idea of patterns, when developers keep getting the feeling "dejavour" (but i have done this before). Patterns, if i may paraphrase it, is a set of solutions for dealing with a known problem. It is an OOP way of dealing with problems and there are a lot of them. The basic of an MVC app is simply objects that talk to each other through a well defined means with some rules applying to them this rules are simply that: 1. A view object does talk directly to the Model object 2. A Model object does not talk directly to the View object 3. A controller object is the bridge between the View object and the Model object 4. if a view object needs data it makes request to the model object through the Controller object 5 If the Model object needs to send data to the View object it sends it through the Controller object To put it in another way MVC is IOC(Inter-Object-Communication) The Model The model is like an end point from which you get a resource, this resource is not only a database, it could be a flat file, a web service, just about anything that has a form of storage capability can pass as a model.Meaning i could have a controller that is talking to a Flickr photo model etc. The Controller This is like a king whose duty is to issue commands or pass on messages from other objects. It could be a serverside script or even a Js function delegated to the task of contacting a serverside script via ajax. The Views The views are what there name imply but the are more than that. they are objects delegated with the task of constructing the actual interface that is render to a browser or a window GUI. They wait for response from the Controller and have there own logic for determining what to render and what not to render.In JS the are called event subscribers cos they are usually attached to a controller who will pass on the message from the model to them on completion.To put it in another, they are sometimes called template parsers. for those who no the Backbase framework and who have looked at the FB app developement markup language, this are the templates that are usually parsed by the View object so if i say <fb:iframe width='400' height='400'> etc ,i am only creating a template that will be parsed by the View object which will examing the custom tag <fb:iframe> and replace it with real iframe tag or translate it to some like this <iframe with='400' height='400'></iframe> I have only explained what MVC means in ordinary sense of it but this pattern can be very simply or very complex depending on how you choose to implement it. A prime example implementation of the MVC pattern are the Zend Framework and the Symphony Framework. they did a great job with the MVC pattern. Perhaps i might someday use real codes in both JS and serverside code to illustrate the MVC pattern in all its glory. |
Imaging a world where everyone look very much alike and where everyone do the same thing everyday and the same way. Well for me it would be a great bore and an uninteresting place to live. Likewise programming, if all programing languages where one language, what a great sadness it would be for many would not give programming a second thought. For me i always say that programming languages are like tools you find around and the way you use it depends on your knowledge of it. To come here and start the endless flame of which programming language is the best is a waste of time and a rocking chair that takes you no where. I am a web developer as well as a desktop developer i do not use the tools i use for the web for desktop app and i do not use the tools i use for web for desktop app , each has its own strength and weakness and the best choice in a given situation is the tool that best suites the need. |
Programming is madness a form of trying to control an object ,sorry i am already spitting the language of the field. It's something that scares people who are not into it and it is something that holds on to people who are into it like 'Aradite' once you are into it you can not walk away from it. When you sleep, you think it, when you walk the street you think it, when you are discussing with friends you are still thinking it even when you are eating. I have found that it is a form of mental activity that takes you to places in your imaginative world you could not naturally get to. Back in school in the field of Computer Science you are taught what the call the basic of programming and you think that is the end of it. It was unexciting but when you start off on your own exploring the driving forces behind a computer system, you get to find out that programmers are more like small gods with the power to think through the entire event that would happen throughout the life time of a program. You give your program some form of human ability and people marvel at how the stuff is responding to them. Has someone ever tried out a command on a Nix box several times, what was the response you get? |
There are coder capable of building Social Site only that they are busy right now |
They job of a programmer is to see the beauty in everything he or she does and his or her task is to make other see it and appreciate it. |
It is been a while i saw the post on Framework here and Framework there but i am yet to see a url either on Google Open source project hosting or sourceForge code hosting for the work to be reviewed if not by the veteran programmers at large, at least by fellow programmers in Nigeria. However, one thing i look out for in a Framework is the extensibility of such Framework through plugins. Its am open source Framework i suppose meaning it is not written in an abstract language. Best of luck man. |
It was never my object to get someone disappointed with my last post. What i did in there was to create an instance object Person so that i can illustrate the point i was trying to make. If i got you guys lost in that last post then i guess i have to digress a little and talk about Anonymous Functions ,perhaps it could help clarify alot of what is going on in that post. An Anonymous function is a function that is nameless and runs instantly the page containing it is fully loaded on the Browser. To define an anonymous function you simply do something like this (function(){//code goes in here})(); So if i want to create a function that i want to execute immediately a page containing it is loaded i could do something like this (function(){ for(i=0;i<20;i++ ) { alert(i);} })(); if this code in included in a page and that page is loaded in a browser before the page finishes loading the function will be executed. You do not need to call it for it to be executed at all .What is happening here is that when the JS Engine encounters the parenthesis surrounding the function it immediately executes its content which is a function without name. However if you do not want the function to go out of scope after executing, you can assign it to a variable for later reference. That is what i did in the Person Object that i used in my previous post. Please note that you can pass a variable to this function by specifying then in the outer parenthesis i.e (function(){})(var1,var2,var3,, ); To make use of this variable within the function you have to pick them up as you specified then i.e ( function(v1,v2,v3,, ){// the code goes in here } )(var1,var2,var3); You guys may not see the use of using this thing called anonymous function but if you have worked with JS Libraries like YUI from yahoo, and you need to use say the Dom component of the library you will have to type something like this YAHOO.Util.something.something.Dom; That is how they chose to develop there own name space, to have just one global Namespace called YAHOO and have every other component build from there. If you are developing you own object that uses the YUI Library, you certainly get tired of typing those lengthy Namespace stuff, this is where the anonymous function comes in to play suppose that Person object i used for ilustration above uses the Yahoo Library objects Dom, i would save myself the lengthy typing by doing something like this using an anonymous function var Person=(function(dom){ //The parameter dom is a reference to the YAHOO.Util.Dom object // between dom and YAHOO.Util.Dom which will you prefer to use? well for me the shorter dom is ok for me })(YAHOO.Util.Dom); When the JS engine encounters this code it will immediately execute it and assign the output of the execution to a variable called Person,so with this variable at my disposal i can further call its public interfaces or methods that where created when the code is executed. This is to those who feel that the ideas in here are rather difficult. The Beginning title of this Post is Advanced JavaScript Stunts. I stated upfront what will be coming from the beginning.So if somehow it is not getting any more interesting then it is time for you not to exit this Forum but to become more practical. Copy the codes, create a simple index.html on your system, run the code and see things for you self, break ,tweek and alter the code. That way you beginning to put your mind to learning. For they say that the best way to learn programming is through enduring practice and determination. I must confess, there are still stuff that i myself do not even understand in JS. IsStudied JS from the JS codes powering wikipedia site. Yes! i printed out the entire code and studied it as you would study a course in school and till today i still have those printouts with me for reference purpose. when you interact with the Masters like those working for Mozilla Project or study their articles you tend to become like them.Have you ever wondered what is powering the Firefox Web Browser,well i have until i looked under the hood. it is Pure JS,XML, better known as XUL ,google for this for see what it would turn up for you I am writing this not to discourage those who would want to learn JS but to give then the impetus. You will need the knowledge someday in you project. I will save the next How To Article for another day. |
That was quite a lengthy code you have in there, if you ask me what method you are using i tell you what, just like they say that all roads lead to Rome, so i tell you that JavaScript is a mythical dynamic language that you can bend anyhow you want to achieve your goal. You are mixing alot in there. You have a mixture of Option 1 and Option 2 in you code and i see Global variables here and there. Thanks for the lengthy code man , i would appreciate if you have the understand that we are here to share what we know will help others in there work and not to test other's skill or understanding of JS. If i where to do that then the aim of having a general forum is defeated. Today i will be looking at Creating Private Properties and Methods in Javascript Just like in the mature languages we have the concept of private, protected,public,final,abstract properties so also we can implement some of these concept in JS too. The dynamism of JS gives us the power to mimic this concept and implement it in JavaScript. The implementation of Private and public properties and method in JS is brought to you through a concept known as Closure I recalled i hinted on this when i was talking about implementation of classes in JS. so i will look in to that further here.To start with what do you guys think will happen when this function is ran function genericFacotry() { var timestamp=new Date().getTime(); return function() { return timestamp; } } If i run the function above say var instance=genericFactory(); What do you guys think instance will hold, a function or a timestamp variable? Well if you guess right it will hold a reference to the inner function and when i do something like this alert(instance()) you are going to see the timestamp we defined inside the function genericFactory(); this may look too simple but the magic start happening when you look back at how JavaScript work. JavaScript is an Interpreted language meaning that as soon as the functions are encountered, the are executed immediately and there after, the go out of scope; but here strange things are happening. I defined a function genericFactory() and after i ran it it was suppose to go out of scope , and the variable timestamp that i defined right within the context of that function is still accessible even after the function genericFactory() has gone out of scope.This is what is called Closure, the ability to define a function within the context of another function and have the defined function have access the to variables defined within the context of the containing function . This idea forms the building block of Creating Private and Public properties in JavaScript By Private properties i mean those properties that are only accessible within the context of the containing function and by public properties i mean those ones that can be accessed public or have a public interface. To illustrate what i mean consider the code below function saveName(n) { var name2Uppercase=n.toUpperCase(); var nameLength=n.length; return { capitalize:function(){return name2Uppercase;}, size:function(){nameLength;} }; } var nameObj=saveName("javascript is a voodoo language" ;alert(nameObj.capitalize()); you will get the capitalized sentence"JAVASCRIPT IS A VOODOO LANGUAGE"; and if you do something like alert(nameObj.size()) it will return the number of characters in the sentence, which is 31 characters This may look rather simple but the point i intend making is that ,the variables nameLength and name2Uppercase are private properties that can not be accessed outside the context of the function saveName() but can be accessed within the public interfaces capitalize() and size() defined within the function. This is how private and public properties can be implimented in JS. To illustrate with concreate example consider this var Person=function() { var name="cdeveloper"; var name2Uppercase=null; function toUpper() { name2Uppercase=name.toUpperCase(); } return{ getName:function() { return name; }, setName:function(newName) { name=newName }, getSize:function() { return name.length; } }; }(); Now look at what is happening alert(Person.name) returns undefined; alert(Person.getName()) return cdeveloper; alert(Person.getSize()) returns 10 Person.setName("Ama" ;alert(Person.getName()) returns Ama; alert(Person.getSize()) returns 3 This is how to implement Private properties and methods in JavaScript, if you look closely you will see the parenthesis added at the end of the function defination, this is called anonymous function that runs immediately the page containing this script is run. it instantly create the Person object and i can access its properties anytime |
I am not sure i can grade my own skills either,all i do is to figure how to implements stuff and i do. It is not for me to do the grading. Anyway , Today i will be talking about How to create classes in JavaScript The question is can classes be created in JavaScript? and the blunt answer is BIG NO!!! This is because JS does not have the features that full blown languages have to implement classes.However there are features in JS that developers can use to mimic classes like in other languages. One of such feature is what is the understanding that Everything inn JS is an Object, String,Date,Function etc are pure object in JS and if the building blocks are object then we can create class like object with then, another important property of the language is what is call Closure which in its simplest definition is the definition of a function right inside another function and having access to the inner function even when the outer function has gone out of scope. I will be discussing Closures when i get to building object with private and public properties in JS. A class is simply a blueprint from which objects can be manufactured. to build a qiuck javascript object the old fashion way ,i will do something like this: var myObj=new Object(); //assign first property to this object myObj.property1="Data1"; or myObj["property1"]="Data1"; //assign property 2 myObj.property2="Data2" etc This is an old fashion way of building an object in JS .Imagine you are working on a large project with lots of JS files and you end up creating global variables like we have done above, you will end up overwriting the global variables that you will spend perhaps ages to debug. I do not like the sound of that. Creating object the new gives you some control and elegance if you are the type that like things to standout on their own. this are the various way to build object in JS 1. Using the {} or curly braces symbol var objBase={}; //define properties objBase={ property1:null, property2:"data1", property3:true, //define some methods initClass:function() { //TODO: }, doSomething:function(param1,param2) { } }; 2. Using a base Function function objBase() { this.property1="data1"; this.property2="data2"; } // add some method to this object using the prototype property objBase.prototype.method1=function() { //TODO: } objBase.prototype.method2=function() { //TODO: } 3. Using a base Function with the new keyword var objBase=new Function() { //add properties this.property1=''data1"; this.property2="data2"; //add some methods this.method1=function() { //TODO: }; this.method2=function(param1,param2) { //TODO: }; } I have listed three basic way of creating defining a class in JS from which objects can be created. Among these three methods i preferred option 1 because it gives me control over my object and it tends to look like or it is in fact a Singleton Pattern Implementation for there can only exactly on instance of the object at any time (t). Option 1 and to are similar because in much the same way. to use this class in any place in a page the includes the file within which you defined the class or within any function that is not defined in the class simple reference it by its name then a dot notation and then any method name or property can be accessed like this objBase.method1(),objBase.property1; etc. The second option works diffrently, you have to instanciate the class before you can use it like this var obj= new objBase(); and then obj.method1();obj.method2() etc. Because option 1 is a lot easier to work with i can go elegant with it by going as far as building a namespace for myself much like the YUI library. That ensures that if i am using a third party script in my project it does not interfere with my own classes. Using option 1 i can define any length of namespaces for myself. to illustrate i am going to show how to define two JAVA classes namely[b] Date and ArrayList [/b] classes which are contained in the namespaces[b] java.util.Date and java.util.ArrayList[/b] in pure javascript define the base class java var java={}; //define the util namespace java.util={}; //define the Data class java.util.Date={}; //define the ArrayList class java.util.ArrayList={}; this is just how to implement namespace in JavaScript, to define namespaces using option 2 we do something like this java=function(){}; java.util=function(){}; java.util.Data=function(){}; java.util.ArrayList=function(){}; that is just it.So if you are wondering how to implement classes in JS , CLASSES CAN BE IMPLEMENTED IN JS USING THE LANGUAGE'S FEATURES THAT LENDS THEM THEMSELVES TO THE ELEMENTS OF A TYPICAL CLASS DEFINITION ANY IN LANGUAGE |
Checked out your work , great stuff you have in there, but why have you not posted it here for others to look at it. Well you seem to have forgotten that i have seven How Tos to answer here. And whether you have implemented before or not, post it right here others look at it ,that is why i am going to shear my own ideas about them. I thought you would want to critices my code that is why i posted it right here. Anyway i still will post more on these. Saw you codes on Upload stuff, was wondering whether what you loaded in the hidden Iframe is simple html page that sends dat to the callback function or you are loading the response in the hidden iframe and then reading the content of the loaded document in the iframe. That is not the way i see such man. Stay tuned man, you will see my own implementation on this and perhaps see that there are different ways of solving problem. |
Wondering what the heck this chap is up to, well i am JS Freak and i want to look at some stunts that can be done in JS. I will list then here and gradually fill them in.So if you know some stunts yourself, this the time to show it off. 1. How do I perform Cross Domain Request with JavaScript 2. How do i Create an Auto Grow Textarea Box 3. How do I preload Images before showing them in a Page 4. How do i Store data on the clientside with JavaScript 5. How do i upload files to a server without page refresh with JavaScript 6. How do i implement a class in JavaScript(is that possible?) 7. how do i implement private and public properties and methods in JavaScript Seven Interesting "How Do I's": 1 . How do i perform cross domain request with javascript Well for the first one anyone who has worked with Ajax will agree that it is not possible to contact a different domain from which your js scripts was served from the clientside.This Internet GUys call it "Same Origin Policies" that is implemented in the browser for security reasons, but clever dudes have come up with a way to do that. This is the genesis of what is today called MashUps, Google MashUps,Yahoo MashUps blah blah blah. The idea is that you can serve scripts from www.mydomain.com and still be able to load up data from www.yourdomain.com from the clientside. This is normally done on the serverside via server-to-server communication. But This days the forgotten language(JavaScript) has hit the limelight again with the advent of Ajax technigues,JSON( JavaScript Object Notation) a kind of data interchange format. to illustrate this concept look at the codes below: <head> <script type='text/javascript'> function loadData(url,params) { var params=params || {}; var html=[]; if(params.length>0) { for(var k in params) { html.push(k+"="+params[k]); } url=url+"?"+html.join("&" ;url=url+"&callback=processResponse"; } var script=document.createElement("script" ;script.type='text/javascript'; script.src=url; document.getElementsByTagName("head" [0].appendChild(script);} function processResponse(data) { if(data.name){alert("the server returned "+data.name+"" ;}} </script> </head> and that is the technique for cross domain request. the returned data is in JSON format. The url sent to this server conatins parameters and a callback function that the server will pass the data to. Once the server passes the data to the callback function it will be executed on the clientside by the callback function "processResponse": the server script might look like this in PHP <?php $param1=$_GET["param1"]; $callback=$_GET["callback"]; //do some processing that will return data as an array //convert it to json and call the callback function $data=array("name"=>"Ama" ;$jsonData=json_encode($data); echo $callback."(".jsonData." ";exit ?> this will send the json encoded data to processResponse, and it will handle json data. Note that you need to ensure that the json_encode function is enabled in the server configuration. This is the idea that is used by sites like Flickr etc to sent data across domains and you can communicate with these server from your clientside with pure JavaScript. JSON has revolutionized the way data is exchanged on the web this days and that comes security problems as well |
Let the dude do his thing guys if what he is talking about is rather too simple for you fine and good but let other who do not have the experience learn. it is rather not a programmers attitude to look down on other peoples code just because he or she can make a meaning out of it. If you think it is rather simple why don't improve on it and let others see the improvement. it amazes me how some people are just out to to discourage the effort of others. If you think it is easy to put up a tutorial and post it for the public to see, well why don't u just try one and see if it is that easy to post something you can not defend yourself. My guy keep up the good work man i am solidly behind you and if i see anything that need to be improved on i will look into it. Scripting in Javascript has gone beyond pop windows and launching a new window. it is the backbone of every web 2.0 and it is time we start looking at Javascript not from the eyes of document.write("blahblah") but as a bridge between the server and the client. |
I like this post and i think i have started something on this line before. Well I created a blog on www.youbanize.com recently because i wanted to create a place online to share programming experiences. I am a PHP programmer, a veteran in JavaScript and CSS. I have posted some of my codes in there;if you would like to share real experiences or learn from the experiences of others , you are welcome. |
I want to believe that forums are places you can come with questions you want to find answers to and not to be questioned back. Well it amazes me that someone wanted to know what API is and ends up be made to look like a dump who knows nothing. i think it is a bad idea. Well to my best knowledge API stands for Application Programming Interface, depending on what programming language you are dealing with i means different things, in the world of desktop application development, it is a collection of dlls or function or method or classes that you call from your own defined function or classes to do certain stuff you can not do on your own. For instance there system services you would want to access from your own codes, you do not gain access to such services directly rather they have a well defined interface through which you can access them, pass parameters to them and get feedback from them. In this context ,the word Interface means the only available point through which you can gain access to the underlying collection of codes. In the world of web development, API means a set of classes or methods or functions you have defined or some else has defined and are sure the always work as expected and can handle errors in away that is clearly defined. This set of classes or methods or functions could be stored away in a server so that others can access this methods in a standard way to get some stuff done. This can either commercialized or open to the public. a good working example of what APIs means and can do ,can be found in the google code room at www.code.google.com, there are various APIs there. browse it and find out for yourself what APIs are perhaps you can be inspired from them |
You will probably have to go the way of Apache Mod-Rewrite. Depending on the server you are using. if you are working on an Apache server then you can easily identify visitors based on IP and redirect then to the right page that you want then to view or even block them from visiting your site. |
ATTENTION! ATTENTION!! PLEASE NOTE THAT WHAT YOU WILL READ IS NOT INTENDED TO SPARK OFF ANY FORM OF SENTIMENTS IN THIS SITE BUT FOR THE PURPOSE OF PROGRAMMER'S AMUSEMENT Have you ever wondered what would happen if Programming Languages where Religion? Well someone did the job of compiling what would happen if that was to happen and here is the summary. you can find the link to the original post at the end C would be Judaism - it's old and restrictive, but most of the world is familiar with its laws and respects them. The catch is, you can't convert into it - you're either into it from the start, or you will think that it's insanity. Also, when things go wrong, many people are willing to blame the problems of the world on it. Java would be Fundamentalist Christianity - it's theoretically based on C, but it voids so many of the old laws that it doesn't feel like the original at all. Instead, it adds its own set of rigid rules, which its followers believe to be far superior to the original. Not only are they certain that it's the best language in the world, but they're willing to burn those who disagree at the stake. PHP would be Cafeteria Christianity - Fights with Java for the web market. It draws a few concepts from C and Java, but only those that it really likes. Maybe it's not as coherent as other languages, but at least it leaves you with much more freedom and ostensibly keeps the core idea of the whole thing. Also, the whole concept of "goto hell" was abandoned. C++ would be Islam - It takes C and not only keeps all its laws, but adds a very complex new set of laws on top of it. It's so versatile that it can be used to be the foundation of anything, from great atrocities to beautiful works of art. Its followers are convinced that it is the ultimate universal language, and may be angered by those who disagree. Also, if you insult it or its founder, you'll probably be threatened with death by more radical followers. C# would be Mormonism - At first glance, it's the same as Java, but at a closer look you realize that it's controlled by a single corporation (which many Java followers believe to be evil), and that many theological concepts are quite different. You suspect that it'd probably be nice, if only all the followers of Java wouldn't discriminate so much against you for following it. Lisp would be Zen Buddhism - There is no syntax, there is no centralization of dogma, there are no deities to worship. The entire universe is there at your reach - if only you are enlightened enough to grasp it. Some say that it's not a language at all; others say that it's the only language that makes sense. Haskell would be Taoism - It is so different from other languages that many people don't understand how can anyone use it to produce anything useful. Its followers believe that it's the true path to wisdom, but that wisdom is beyond the grasp of most mortals. Erlang would be Hinduism - It's another strange language that doesn't look like it could be used for anything, but unlike most other modern languages, it's built around the concept of multiple simultaneous deities. Perl would be Voodoo - An incomprehensible series of arcane incantations that involve the blood of goats and permanently corrupt your soul. Often used when your boss requires you to do an urgent task at 21:00 on friday night. Lua would be Wicca - A pantheistic language that can easily be adapted for different cultures and locations. Its code is very liberal, and allows for the use of techniques that might be described as magical by those used to more traditional languages. It has a strong connection to the moon. Ruby would be Neo-Paganism - A mixture of different languages and ideas that was beaten together into something that might be identified as a language. Its adherents are growing fast, and although most people look at them suspiciously, they are mostly well-meaning people with no intention of harming anyone. Python would be Humanism: It's simple, unrestrictive, and all you need to follow it is common sense. Many of the followers claim to feel relieved from all the burden imposed by other languages, and that they have rediscovered the joy of programming. There are some who say that it is a form of pseudo-code. COBOL would be Ancient Paganism - There was once a time when it ruled over a vast region and was important, but nowadays it's almost dead, for the good of us all. Although many were scarred by the rituals demanded by its deities, there are some who insist on keeping it alive even today. APL would be Scientology - There are many people who claim to follow it, but you've always suspected that it's a huge and elaborate prank that got out of control. LOLCODE would be Pastafarianism - An esoteric, Internet-born belief that nobody really takes seriously, despite all the efforts to develop and spread it. Visual Basic would be Satanism - Except that you don't REALLY need to sell your soul to be a Satanist, The original post can be found here http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html |
I am kind of like interested in this Ajax discussion. Did come across this post after i have posted on a thread on Client-side Caching using jQuery perhaps my Ajax pioneers will have to look at my implementation and give their own assessment of it it is bit too long anyway this is the link https://www.nairaland.com/nigeria/topic-255439.0.html i will entertain question on it. |
You are right dhtml, yet i do not see anything wrong in showing those who are interested some of the articles i have written about jQuery. I think it is one of the principles of programming DRY ( Do not Repeat Yourself) So Today i will be looking out something very important that i have always thought is only done on the serverside,yet it could be done on the clientside i use to write serverside caching systems and it did work fine until lately i started looking at sites like google Map. I realize that both Gmail and Google Map and not just mere application but are also very intelligent applications too. One aspect i took time to look at is the way GMap cache on the client side giving you that feeling that you are using a desktop App. Well google map uses a mixture of Predictive and Passive Cache Pattern to get the job done. Passive Cache is a method caching in which your previous request are cached on the clientside so that when you request the same information again that data is not polled from the server but from the cache. This form of cache only changes whenever there is a change in the data itself.While Predictive Cache is a method that simply predict what you might do next based on previous requests. For instance if you are reading an article that spans multiple pages and you are current viewing page 1 the Predictive Cache figures that since you are reading page1 there is a 50 05 chance of reading Page 2 so it downloads it at the background using a AJAX and cache it so that when you eventual clicks on Page 2 it just loads as though you are working on a Desktop App. Well those are the ways Caching on the clientside are done i am going to show an implementation of clientside cache that can work for both method of caching, since all we need is a data store on the clientside with ability to update, delete, insert and do periodic update on the data. So How do we Implement A Clientside Cache Using jQuery? The implementation of a clientside cache using jQuery is simple, first we need to define the structure of our cache, for this i will use a simple Javascript Object for that them i will define methods for Adding ,Deleting,Garbarge Collecting and Updating data on the cache Object. So lets start by defining the cache Data Structure. I will be usoing OOP design here so that i can pack both Data and methods that work on the data into the same JavaScript Class( Did i say class in JS impossible there is no class structure in JS some of you will say but people have learned to implement concept in OOP language also in JavaScript) will show how to in the process of building this object What does a simple class look like in JavaScript?
That is what a class look like in JavaScript even though it does not yet have properties and methods. There are other ways on implement classes in JS using prototype property of javascript object i will be using the one the template above So a Cache object will need methods like Update,Add,Remove,GC(Garbage Collector) and of course the init Method and a data store Cache class will look like this
I suppose the class is beginning to make sense with those methods studs and the cache data store added i have called the data store cache and it is an object literal,you will see why it have to be an object literal. Now we need one more stuff here. We need away to tell the GC that a piece of data has expired, so we need to set an expiry date for each data item in the cache so that the gc can use that to determine which data item needs to be cleared. So we will add a second property call livetime to the class so our evolving class will look like this
I have initialize the livetime property to 60 seconds(1 minute),by the way a seconds is 1000 micro-seconds in JS so 60000 ms = 60 s. We will define the add method which adds data to the cache store. Now the cache is an object literal because it needs to store data in the form of Key/Value pair so that we can access specific data item using the key. The value itself is an Object as well because for each value stored we need to store the time that data item is stored so that the gc can check it at interval to determine if the data value is still valid or not. Enough theory the code below
And that is what the add method looks like if the key already exists it is updated , else it is added to the cache.Also not the timestamp property added to the data object this will be compared to the livetime to determine the validity of that data. the method getTime() returns the current timestamp in microseconds Next i will implement the update method
Next i will implement the remove method which simply delete a given item from the data store based on a given key
Very easy to delete record from the cache using javascript in-built delete command. Next i will implement the most intricate part of the system which is the gc method for garbage collection. If you have worked with OOP language you must have come across GC then. Our GC job is to go through all the data item in store , check the timestamp against the global livetime. if the are expired clear them. How we are goint to do this is to use the compare the current timestamp with the timestamp store for each data item. The implemantation is as shown
That was it, using jQuery array iterating method jQuery.each(index,callback), i have looped through all the data items in the cache and removed all tose that are already expired. you will notice that i computed the time difference between the timestamp stored during adding the data item and the current timestamp as at the time the gc method is running. One problem remaining is to make the gc run indefinitely at a specific interval as long as the page has not refreshed yet. This we will implement in the init method of the cache class
So there is the trigger; i have set it to run at an interval of 2 seconds , that is the gc method get called after every 2 seconds to do its Garbage Collection job. I think i am missing something. We have defined how to get data into the cache, update it , and remove it but i have not yet defined how to get back data from the cache so i will define that
So the getItem simply checks if the data item requests exists in the cache. if does exists it is returned else for now it will return null but in a prodcutive environment, this is the place to use Ajax to fetch the data from the server, put it in the cache and then return the data to the caller method. So far i have developed Cache simple cache system that can still be improved on.For instance we can make the gc method to refresh all outdated data item from the server without page refresh and the user not beeing aware of what is happening at the background.One more thing still remains, which is initiate the action of periodic update of the cache. Here i will show how how to do that on page load using jQuery
And that is your cache system running , the gc method gets called every 2 seconds and the cache is purged every 2 seconds |
What will be your reaction if tommorrow you find out that a new Social Networking site,built from scratch( ground up) for Nigerians by Nigerians with features found on leading social sites has gone live? Criticise it, Contribute to it technically, Support it ,Write it off or be proud of what Nigerians are capable of building. I have often wondered what i would do myself and i have always thought it impossible to build but lately i figured that it is not entirely difficult only requires experience and some hard thinking to build. |
If comparing PHP and Python is purely based in terms of web development and popularity then i give PHP the lead but when compared in terms of power and capabilities php is not in any where comparable to Python. Just like the name implies, Python is a powerful reptile and the language itself is subtly powerful. Python has always enjoyed a lot of advanced usage beyond simple web page design and it has shown great strength in munching text,glueing other programming languages as well as excel in performing system administration. have you ever wondered what sites like Google,Slasdot, are using? Well Python has been described as a language for prototyping application because of it easy to port to any programming language you can think. In all i think the quest to find out what language is better off is a futile one rather one should consentrate on learning the strength and weakness of each of then and find out how to better utilize then. |
jQuery is perhaps one of the most popular ,powerful ,light-weight and easy to use javascript framework or library that i have found on the internet and not only can you use the library, you can also extend the library yourself by writing what is call a plugin. A lot of developers have written powerful plugins for this library and i must commend them a lot for their free contribution to the development of the library. I was a bit reluctant initially when i started out with the library because i could not make sense of what it was and besides I DID NOT WANT ANY NEW LIBRARY THAT WOULD MAKE ME FORGET WHAT I ALREADY KNOW ABOUT JAVASCRIPT. Alot of you perhaps are feeling this way now but i must say that getting to know about the library has revolutionized my JS coding and today i have used the knowledge extensively on the ABU Administrative Online Portal Backend. Some of this i have shared on my blog http://www.youbanize.com. I am not going to bore you with theories but i will start off on a practical way,since they say that the best way to learn programming is by example; also i will reference other sites for more advanced usage of this simple but powerful library. The jQuery magic starts with this: $(document).ready(function(){The dollar sign ($) is a shorthand notation for the jQuery object and they can be used interchangeably. How to i get started with jQuery Library? The first thing you will do is to get the latest version of the library from google code site www.code.google.com; it is now been hosted their include it on a simple page as you would any javascript file and then in the header section of your page include this script
The above code will output the dimensions of your current browser when the page has fully loaded. I will continue the exploring of jQuery and what it has in store for developers who wish to take advantage of the power of jQuery. Just to wet your appetite, did you no that you can create those effect you see on Facebook with jQuery? Well i have done it and perhaps you will get to see it some day. For those who want get the hands on it just post your questions here so that others can benefit too or post it on my blog www.youbanize.com. i am christian an Open Source Developer. |
Are you a veteran in programming, are you a baby programmer still struggling to understand the whole nuts and bolts of programming, do you believe that the easiest way to learn programming is by asking questions and snooping around other peoples codes, do you want a real live sharing of ideas and an avenue to meet with experienced programmers you can interact with, then i welcome you to the code poets experiences sharing site. www.youbanize.com You will only stay away from that site for two reasons You are not sure of your skills and are afraid of other's criticism You have never written any code on your own but have always copied and claimed ownership of another coder's work Welcome to the programmers haven where your poetic codes are subjected to the scrutiny of veterans who are all out not to make you feel bad about yourself but make you a better coder. |
You know guy i have thought of this idea before and i did not just stop at thinking about it ; but went ahead to implement knowledge sharing blog about it. I think the western world are far more better when it comes to building standard codes that can pass the test of time not necessarily becuase they are exceptionally good , but because they understood the concept of sharing experiences and that way each one learn faster than they could have done when studying alone. I was wondering where our veteran programmers;Human knowledge belongs to the world, we need to teach they younger chaps interested in programming and make the learning curve a lot easier for them,by sharing our own experiences I implemented a knowledge sharing site, you can find it at www.youbanize.com ;it is place to ask questions ,get answers, share experiences, learn from the experiences of others. I built for one sole purpose,sharing experiences and learning from others. so if you think you are an expert in your programming skill ,get in there and let others criticize you implementation. I have made a couple of contributions there ,go there and criticize my implementation with good reasons. I will be making more contribution when i am done working on the university of Jos student result processing and transcript module. I will be sharing the codes i used in the implementation. |
I always believe that human knowledge belong to the world, and taking advantage of others to enrich your pocket is an indication of your selfishness and to such persons knowledge always come to those who will freely give it out first before it comes to you. I am not referring to anyone in particular but those of us that think we can take advantage of other peoples ignorance; i am afraid you won't get any far. If i have to integrate interswitch on my site and i pay you N15000 for that and still you collect 5-6% interest on any transaction that transpired on my site. Common guys, do not think i will be that stupid to fall for this bloated offer, when i can get to interswitch guys and initiate this transaction at VI. Stick with me and i will be explaining the products interswitch offer and the cut they collect from you. Hey if you have any question regarding connecting interstwich,etranzact payment gateway, feel free to post it on my blog www.youbanize.com and i will attend to your question. I am a developer based in Lagos and part of my job is to connect any application my company develop with these payment gateways. So i am well acquainted with the processes involved and i can offer to help anyone who is prepared to connect to these payment gateway. I have a couple of question for you and i would want you to answer them 1. What product of interswitch or etranzact payment engine are you charging N15000 for ? 2. How much interest do they(Interswitch or etranzact charge per transaction) 3. When has these payment gateway start dishing out apis to third parties Friends,comrades and fellow developers, i have worked with these guys and i must say that the fact that they did not explicitly explain their transactions does not mean that it is very difficult. Interswitch has three payment solutions namely WebPAY payment engine PayDirect payment engine AutoPay payment engine Majority of merchant go for either WebPAY or PayDirect payment engine WebPAY payment engine is the cheapest of them and it is not very difficult to setup.A one time setup fee of N150,000 is required to get your merchant ID and for every transaction you make they charge you N50, while PAYDirect payment engine (majorly used by universities and colleges) is about N1.5M and for every transaction you make depending on the transaction amount, they will charge you either N300 if your transaction amount is less that N20,000 and 1.5% if your transaction is more that N20,000. I will be discussing more of these payment gateway in my blog.Please do not let people who are out to capitalize on your ignorance swindle you off you hard earn money. Cdeveloper www.youbanize.com |
Building a forum is not an easy task but if you really have to build one , you must have other guys that would help you. You need to have something you are passionate about and your friends are too. That way guys can set up one for yourself and start off with the most important thing- contents. You will need quality content to start attracting people. I run a personal blog about what i love most doing, programming you can check it out at www.youbanize.com. Note , they often say that content is the king. Ama. |
;