Tuesday, 26 January 2016

CSS3: Using vw and vh units

VW simply means viewport width while VH is viewport height.

So, you've heard about px, pt, em, and the fancy new rem. Let's look at a couple more: vw and vh.
Often times, there are certain elements within our design that we'd like to ensure can fit into the viewport in their entirety. Normally, we'd have to use JavaScript to do this. Check the size of the viewport and then resize any elements on the page accordingly. If the user resizes the browser then the script runs again to resize the elements on the page.

With vw/vh, we can size elements to be relative to the size of the viewport. The vw/vh units are interesting in that 1 unit reflects 1/100th the width of the viewport. To make an element the full width of the viewport, for example, you'd set it to width:100vw.

Putting it to good use

Lightboxes seem like a great candidate for using vw and vh units, since the lightbox is normally positioned in relation to the viewport. For elements positioned in relation to the viewport, however, I find using fixed positioning with top, bottom, left, and right values to be an easier approach—completely forgoing the need to specify height and width at all.
A good use case for these new units would be for content that sits within a normal document flow. For example, scrolling this page, I could include a number of screenshots. For those screenshots, I don't want them to exceed the height of the viewport. In this case, I can set a maximum height on my images.
img { max-height:95vh; }
In this case, I set the height to 95 to give the element a little bit of breathing room while on the page.

Browser Support

This feature is supported by all major browsers including internet explorer 9.


Follow me on twitter: http://www.twitter.com/_josiah_king Join me on Google+: https://www.plus.google.com/u/0/113541005774136102412/posts/p/pub?cfem=1

Monday, 18 January 2016

Developing a web base fingerprint/biometric software using PHP and Javascript

Hello, i got some request few days ago on how to use fingerprint with php. Here are some useful links to check out if you are considering developing a web base fingerprint app.

http://jayakody2000lk.blogspot.com.ng/2009/07/phphd-server-side-hardware-port-access.html
https://github.com/Valve/fingerprintjs2
https://www.npmjs.com/browse/keyword/fingerprint
http://www.bayometric.com/web-based-biometrics/

And yes, it is possible with todays technologies, but not directly. I am yet to develop a fingerprint software of any platform, so i have not test any of the above solutions.

Follow me on twitter: http://www.twitter.com/_josiah_king Join me on Google+: https://www.plus.google.com/u/0/113541005774136102412/posts/p/pub?cfem=1

Thursday, 14 January 2016

Detect if file is not empty before upload in PHP

I was working with a script developed by something else and i got hooked because i could not post content due to some logical issue with the programming of the script.
The script was design to upload file whether empty or not and this was causing problem for me because i am not attaching a file to the post.
Here is the code to here detect if the file upload is not empty:
if(!$_FILES["file"]['error'] == 4){ //process upload }

That solves the issue, i could now post without upload a file.


Follow me on twitter: http://www.twitter.com/_josiah_king Join me on Google+: https://www.plus.google.com/u/0/113541005774136102412/posts/p/pub?cfem=1

Monday, 11 January 2016

Search and replace string in PHP

Search and replace string in php.
Search and replacing string is not difficult using the function str_replace();
I have to search a string (actually an html content which i extracted from a file using file_get_content()), string to was src=" and replace with src="http://path/to/the/image/folder/ and i acheived this by simply str_replace('src="','src="http://path/to/the/image/folder/',$str);

Follow me on twitter: http://www.twitter.com/_josiah_king Join me on Google+: https://www.plus.google.com/u/0/113541005774136102412/posts/p/pub?cfem=1

Friday, 8 January 2016

Working with PHP ZipArchieve Class


This happened today, it was my first time working with zip file.
The issue came up when i opened the file like this:

$zFile = $zip->open($filePath,  \ZipArchive::OVERWRITE);
$zip->extractTo($bookDir);

After opening the file i was trying to extract to another directory, this returns true but no extracted data was found.
The is a really troublesome bug, but thank God for the internet.
After sometime i debugged and removed the \ZipArchive::OVERWRITE and it worked.

$zFile = $zip->open($filePath);
$zip->extractTo($bookDir);





Follow me on twitter: http://www.twitter.com/_josiah_king Join me on Google+: https://www.plus.google.com/u/0/113541005774136102412/posts/p/pub?cfem=1