Sometimes we just want to display the website if all the images are loaded.
Or do something when a few images are loaded and viewable in the browser.
This script makes it very easy for you!
(continue reading…)
Sometimes we just want to display the website if all the images are loaded.
Or do something when a few images are loaded and viewable in the browser.
This script makes it very easy for you!
(continue reading…)
Scenario:
Sometimes u have an image tag in youre html file that is VERY big, and u want to read the height, width or something else in youre javascript.
You create a nice onload function that triggers when the dom is loaded.
You didnt set the width and height attribute in the image tag because u want it to be just as big as it is.
This specific prototype function tries to read the height: “$(‘someimage’).getHeight()” but what the f… :
height is 0, nothing or undefined????
(continue reading…)
Since the introduction of PHP 5 and it’s better OO capabilities it is possible to use method chaining. In most modern frameworks, like Zend Framework‘s Zend_Mail for example, it’s widely used.
An example of method chaining from the Zend Framework documentation for the Zend_Mail component looks like this:
$mail = new Zend_Mail();
$mail->setBodyText('This is the content of the mail.')
->setFrom('somebody@example.com', 'Some Sender')
->addTo('somebody_else@example.com', 'Some Recipient')
->setSubject('My own subject')
->send();
The code above can also be written like below, without method chaining:
$mail = new Zend_Mail();
$mail->setBodyText('This is the content of the mail.');
$mail->setFrom('somebody@example.com', 'Some Sender');
$mail->addTo('somebody_else@example.com', 'Some Recipient');
$mail->setSubject('My own subject');
$mail->send();
It depends on your likings of which method you want to use, but you can extend your methods with the chaining way without harming the traditional way so in the end the programmer can decide the method he desires. If you want to make the methods ready for it the method simply needs to return the object itself, like so:
public function foo() {
// ... do something here ...
return $this;
}
I’ve highlighted line 3 where the magic applies. If you had foo(), bar(), baz() and bat() methods you could then do this:
$myClass->foo()->bar()->baz()->bat();
You may not want or need to do this in any of your code, but the possibility is there if you or any colleague wants to.
Well.. kohana’s auth module is fine, but it does not work for me…
We programmers just want something we fully understand and most of the time we just write something ourselfs instead of using things that other programmers made.
That’s why i made my own auth module ( used lot of kohana’s auth module ), and i think that everyone could use this one..
The use is very simple, and the code is very easy to understand and extentable.
DOWNLOAD
includes:
-auth module
-sql script
The code works just fine… and when u take a look at the code you will see alot of different kind of databases handling. That is one of the learning curves here for you guys.
Take a look at the database (mysql workbench screenshot):
(continue reading…)
And again i searched the internet for some “easy” script to grab/download youtube movies to my own server.
I failed! So wrote my own.
Let me explain the steps or jump over to the VERY short working code:
First step we need to do 3 things:
*1: make a request to youtube for getting the required data
*2: make a second request to really get the .FLV file
*3: save the data to a file
*1: make a request to the url, in this case it is:
(just grabbed a url dont look at the content of it
)
(continue reading…)
*EDIT: check this post for an easy auth module i made myself
I searched the internet for a “GOOD” documentation about the auth module in kohana.
Couldnt find one… (not even on the official website….). [official documentation]
The example they include in the download of kohana isnt working at all (misses classes and so on….)
So i made an simple example.
Let’s start:
I assume that u have the auth tables allready correct inserted into youre database.
(if not go to modules/auth/views/auth/install.php query should be in the php source…)
Create a file login_test.php
place it in: application/controllers
CTR-C and CTRL-V the code in that file.
Goto: youredomain.nl/login_test
(continue reading…)