Sunday 31 May 2015

A PHP Programmers Greeting of a New Month - June 2015



Good Mid-Night Elders, Colleagues and Juniors.. 😊
I new you would think that the greetings gonna be kinda very tushed to programming.. All i just got for you is the screenshot of my code as at the time it clocks..

Want to Inform you its clock a New Month of Great Achievements...
.
..
...
....
.....
...... Happy New Month - You've Dreamt. Imagine and make that Wish 💭 ......

😎 - Michael Akanji

PHP Image Resizer Class to resize images on the Fly

 

PHP Image Resizer Class - File


PHP Class to resize images on the fly mostly while coding in HTML

This Image Resizer class is a part of my project on www.dpedit.tk I tot to share this, thinking it would be useful, doh its just a simple version of the actual one i use in my picture editor project but simple enough to do the work, and for the brave developers out there you can use this script to resize images as it is uploaded to a particular size you require of your users, also can be used to create thumbnail images..

This idea is something facebook as implemented... example is a situation where by you would have to click on view full size while checking your friends profile picture before you can actually see that her/his phone's camera is superb..

Advantages

  • You would make your website load faster
  • You wont have to type <img width="...px", to resize and image actually knowing it still has original its file size and width the same therefore only a good html interpreter(browser) can try to minimize the image file size
  • You can use it to generate image thumbnails(more like cache-ing)
  • You can use it to compress images to have smaller size with desired width by only manioulating the quality value i.e no need to learn/open up your photo editing software
  • and many advantages you could imagine....

Usages

 To use this tools/file/tech/idea in your project.. is as simple as you code your html..
It resizes images of format JPG and PNG only but resizes to JPG

URL Parameters

  • img -- this is the path to the image you want to resize e.g image/bg-img.jpg
  • width -- the width at which you want your image to be.. e.g 50.. (note: its in pixel)
  • quality -- optional: this is the quality you want the image to have, it ranges from 1 - 100, the default value is 80. e.g the images of linux shooting windows i screenshot above are resize using this tools and on the right are those i set to have a 20% quality..

Example Usage

<img src=path/to/this-file.php?img=path/to/image.jpg&width=300&quality=50 />
<img src="image.php?img=image.jpg&width=250&quality=10" />

FAQs

 I was ask if this does open a site to any kind of vulnurability..
The answer is actually noo.. simple reasons been that - its just there in a directory, it does not connect to a database so its SQLI free, it does not take file input so you are shell scripting free, even if someone tries to manipulate the url - it would rather generate and error saying image can not be displayed or corrupt image..

Take a step to using it and i am sure you pretty much like it..

Thursday 28 May 2015

HTTPS Everywhere - Secure yourself while Browsing

HTTPS Everywhere is a Firefox, Chrome, and Opera extension that encrypts your communications with many major websites, making your browsing more secure. Encrypt the web: Install HTTPS Everywhere today.

HTTPS EveryWhere for Mozilla Firefox
HTTPS EveryWhere for Mozilla Firefox on Android
HTTPS EveryWhere for Google Chrome
HTTPS EveryWhere for Opera Browser

Note: In summary why you need HTTPS Everywhere. - Without HTTPS an Attacker can sniff to get your personal data, passwords, credit card(master card and co) info, conversations etc...

HTTPS Everywhere is produced as a collaboration between The Tor Project and the Electronic Frontier Foundation. Many sites on the web offer some limited support for encryption over HTTPS, but make it difficult to use. For instance, they may default to unencrypted HTTP, or fill encrypted pages with links that go back to the unencrypted site. The HTTPS Everywhere extension fixes these problems by using clever technology to rewrite requests to these sites to HTTPS.

Friday 22 May 2015

PHP Sucks on the file_exist() Function

I wonder why Father Rasmus Lerdorf(Cap Off) and team Zend would make file_exist() to check for both if dir or file exist without even passwing a second argument to force it to check for files only and return false once file does not exist..
I expect there should be file_exist() and dir_exist()

The alternative is_file() function is for a diff scenerio, dont wanna talk about that..


If you think i dont use the doc.... you can name the function that can do the ish please...


Why Programmers Write Lot of Lines of Codes

Thinking Security when Coding makes Me write lot of Lines of Code to prevent the Bad Guys...

Why on Earth do the Bad Guys Exist.. they make it take more time to finish a Function of an App...

How cool would it have been to just consider logining someone in without thinking they myt wanna do some SQLI, CSRF and so on..


#VeryShortAPost....

Tuesday 19 May 2015

Learning Python Programming the Easy Way.

Learning python programming language as been a headache for alot of people which at the end they will end up saying learning python programming the hard way is the only option... Ooh oh, here i am to tell you that learning python programming language would be more fun attending this class which will start in less than 13 days... videos and course material are totally free.. it can be downloaded for latter watch also.. have a nice time learning. see you soon at https://www.coursera.org/course/pythonlearn .. actually i am not gonna see you. :-D

Saturday 9 May 2015

Nigerian 36 States, Capital & Local Government Areas PHP Class

I got the inspiration of updating and sharing this PHP Class after a good Don Jajo of mine did.... I thought i should at least spare some time as he did to FORK the repo via https://github.com/donjajo/NGStatesLGA so i can contribute to the PHP Class as someone wished if the methods can be at least Chain-able. And now, its not only Chain-able but i added and modify some methods...


User Guide

Do not mind as the code samples may look like as i am not so good in blogging

-- require "nsl.php";
-- $nsl = new NSL('nsl_data') ; // pass as argument path/to/nsl_data file without extention, only json format supported for now

 Getting Results

To get raw result as it is fetched from the nsl_data file to do your manipulation yourself, use
-- $result = $nsl->get();

To get all the states
-- $result = $nsl->state()->get(); // returns array of states

To get states and their capital 
-- $result = $nsl->stateAndCapital()->get();

To get local gov under a state
-- $result = $nsl->stateLga('state_name')->get();

check in the code to see comment on every method for the function they perform

Counting Results

To count the number of result, chain the countResult() before the get() method, do like below
-- $result_num = $nsl->stateLga('state_name')->countResult()->get();

Formatting Output

Output can be formatted in JSON and CSV(comma seperated values) . the standard output format is ARRAY.. ARRAY Object will be added in the update to come
example formatting;
-- $result = $nsl->stateLga('state_name')->stdout('json')->get();

NB:  only normal array and one level up associate array result can be output via the csv stdout format e.g array('mike', 'gattel'); and array(array('mike' => 'gattel'), array())



Get NSL on GitHub



I would like to hear your feed back.....

Friday 8 May 2015

Reading BootStrap 3.3.4 Documentation - Tutorial Offline

   Download BootStrap_doc-3.3.4.zip
---- OR
   Here Bootstrap-3.3.4.zip

    It took me a while to be able to compile the bootstrap documentation.
while i am using Windows i couldn't achieve this simply because there are lot of dependencies attached to setting an environment to compile the bootstrap document and distribution from its source package, reason being that most dependencies are not meant for windows OS e.g Jekyll etc. unless you tweak your way to installing the dependencies but on migrating to Linux OS(Ubuntu Distro) i could achieve this even doh it took a hell lot of stress as well but it yield unlike while using Windows OS...

    With this documantation, you could study bootstrap at your convienience, data econimicity(:-D) and speed of loding time.. you can run it on your phone as well probably best using UC Browser...

I look forward to seeing your comment and or request below...

Tuesday 5 May 2015

USBKill — Code That Kills Computers Before They Examine USBs for Secrets



USBkill — A new program that once activated, will instantly disable the laptop or computer if there is any activity on USB port.
Hey Wait, don’t compare USBkill with the USB Killer stick that destroy sensitive components of a computer when plugged-in.
"USBKill" is a new weapon that could be a boon for whistleblowers, journalists, activists, and even cyber criminals who want to keep their information away from police and cyber thieves.
It is like, if you are caught, kill yourself. In the same fashion as terrorists do.

Here I am not talking about to kill yourself, but to kill the data from your laptop if the law enforcement has caught your laptop.

USBkill does exactly this by turning a thumb drive into a kill switch that if unplugged, forces systems to shut down.
Hephaestos (@h3phaestos), the author of USBkill, reports that the tool will help prevent users from becoming the next Ross Ulbricht, founder of the infamous underground drug marketplace Silk Road, who was arrested in a 2013 FBI raid in which his laptop was seized by law enforcement agencies.
"USBKill waits for a change on your USB ports, then immediately kills your computer," a Github document states.

Completely Wipe up any pieces of evidence before Feds caught you:

Generally, the kind of activities on USB port include the police installing a mouse jiggler – a tool that prevents computer systems from going to sleep, and any USB drive being removed from the computer.
"If this happens you would like your computer to shut down immediately," Hephaestos says. Simply, tie a flash USB key to your ankle, and instantly start USBkill when the police or any other law enforcement official caught you with a laptop.
In case, they steal or take your laptop or computer with them, they would definitely remove the USB drive that will immediately shut down your laptop.
The author of USBkill states that the program could be very effective when running on a virtual machine, which would vanish when you reboot.
The author says that USBKill will be added to additional commands and functions. However, it does work correctly and efficiently in its current state as well.

Courtesy: - The Hackers News