Need an easy way to allow external network users to access services or websites on your local machine? ngrok allows you to easily create a secure tunnel from ngroks servers to your machine. For a web developer, this is a dream come true, this is a great way to demo a development whilst in the early stages, saves time uploading to a server.
Allows access to your locally hosted web server from a unique domain
Can use your own domains
Works with vHost files
Allows testing of website which require an external accessible point such as payment gateways or oAuth
Can tunnel other services such as PhoneGap allowing users external to your network to test your mobile app
Various API and IoT implementations
Easy / quick private networking, VPN benefits
These are only a short list of what is possible using ngrok. Look at their website for a full list of its powerful features and get started.
Need to easily debug some php code? simple add the following code to your script to enable PHP error reporting and display error messages. This allows you to quickly debug without making configuration changes to servers PHP configuration.
It is good practice to hide error messages for security reasons, error messages could be used by hackers to gather information and vulnerabilities.
PHP
1
2
ini_set(‘error_reporting’,E_ALL& ~E_NOTICE);
ini_set(‘display_errors’,On);
This code is provided as it and may require changes to work for your needs.
There is a range of fancy stuff you can do with HTML and CSS but a lot of developers are not aware of the little tricks you can do with CSS which results in developers using alternatives such as JavaScript or PHP when CSS can achieve the same results, sometimes even better as its less code to be written and downloaded by the client.
Time after time I notice websites which have used JavaScript to achieve something like a menu when most of the time simple CSS selectors such as :hover could have been used resulting in a 100% CSS menu which works the same.
Here is a must read article which outlines some of those hidden CSS selectors which make development a lot easier and faster. Did you know you could use regular expressions in CSS as I didn’t.
Internet Explorer (IE) also known to some as Internet Exploder or the worst browser on the internet causes headaches for a lot of us developers. IE has what I would call a lack of tools or features, IE7 lacks the abilities to show images with a alpha channel which is something we take for granted these days, this is just one of many features used on modern websites which us developers have to combat against due to IE limitations.
The main issue is that people are still using IE7 and IE8 which are very out dated, both of these versions of IE don’t support many of the new technologies meaning us developers have to be careful which normally results in hours of extra time writing code specific for each browser version so that the pages render correctly.
Thank fully people have realized these issues and have written some JavaScript libraries we can use to try and fix / add features to IE to make development a lot easier.
HTML5Shiv
A great library I use often which adds HTML5 support to IE8 and below.
A simple function to easily process a website or file and return an array of all the URLs found. The main purpose I created this was to make it easy to process “Directory Listings Pages” which is a page which shows all the files and folders in a websites directory if there inst a default/index page or the directory listings is enabled.
I have used it to find images on another website (which has directory listings enabled) and display the found URLs / Images on another website. It it up to you how you use it but I am not sure what its limit are in terms of URLs per page.
Comparing two bits of data in PHP is quite simple but there are special occasions when a simple comparison of data needs to be slightly different. One of the common issues is comparing float numbers, a common mistake is comparing two float numbers the same way in which you would compare two integers or two strings.
What does float, double or real number look like?
1.234
1.2e4
7E-10
This is due to how PHP stores float numbers (also known as doubles or real numbers) which gives this type of data a very limited precision resulting in numbers being slightly off, for a more in-depth explanation please read the following article http://php.net/manual/en/language.types.float.php.
This issue only occurs once a calculation is performed on a float number.
The best way of comparing two floats to get an accurate comparison is to convert the value to an alternative data type such as a integer, string or use “bccomp” which allows you to compare 2 float data types together up to the precision you specify (bccomp can also be used to determine which of the two floats is higher or lower).
Eclipse is a brilliant programming interface for many languages but when using a Windows 7 based PC you may have issues when pinning the shortcut to the task bar. As you can see below when I launch eclipse via the shortcut instead of using the pinned icon it creates a new one.
If you right click the active icon you do not get a “Pin this program to taskbar” option like you would with other programs. Eclipse on the left and Microsoft Word on the right.
All we need to do is add 2 simple lines to our Eclipse configuration file so that Java is detected correctly which then enables us to pin the application to the task bar. First we need to go to the directory where we have placed the Eclipse files, in my case this is “C:/Program Files/eclipse” but this will differ between everyone.
If you can’t find the files try right clicking any shortcuts you have and select properties that will tell you where the actual files are.
There is a file called “eclipse.ini” open it in Notepad it should look something like this.
Add the following to the top of the file and save it. The second line needs to point to your Java installation bin directory; this may differ on your computer.
You can normally find all the Java installations in the following location “C:\Program Files\Java\”, if you have a older or new version of java than me or using the JDK version then the name may differ from”jre7”.
PHP
1
2
–vm
C:\Program Files\Java\jre7\bin
You can now start Eclipse and right click the icon on the task bar where you will now see the “Pin this program to taskbar” and when you open Eclipse it will no longer create a new icon.
If you receive the following error when trying to start Eclipse then you have provided a invalid file location for Java. Try the other locations or in my case it was due to me pointing it to the 32bit version instead of the 64bit version (Program Files (x86) instead of Program Files).
Here is a function I have created which is used to generate a sequence of random numbers, letters and symbols. I currently use it on a number of projects including http://passworded.co.uk which is a simple password generator. (more…)