Hide wordpress password protected pages

A lot of the time it is not desirable to have a password protected post show up on your WordPress home page or recent posts list however it is the default behaviour.

This code is almost straight out of the manual, however it may help someone looking for a complete example with the plugin header/comment that is required for the file to be recognised as a plugin by WordPress.

<?php
/**
 * @package hpp
 * @version 1.0
 */
/*
Plugin Name: HidePasswordProtected
Plugin URI: http://hotchipsnsource.com/
Description: As per name
Author: hot chips n source
Version: 1.6
Author URI: http://hotchipsnsource.com/
*/
// Filter to hide protected posts
function exclude_protected($where) {
	global $wpdb;
	return $where .= " AND {$wpdb->posts}.post_password = '' ";
}

// Decide where to display them
function exclude_protected_action($query) {
	if( !is_single() && !is_page() && !is_admin() ) {
		add_filter( 'posts_where', 'exclude_protected' );
	}
}

// Action to queue the filter at the right time
add_action('pre_get_posts', 'exclude_protected_action');

?>

Save the code in a file named HidePasswordProtected.php and save it to your wp-content/plugins directory. Then just activate it from within the WordPress Plugins administration page.

There is one flaw with this, while viewing a single post if the next or previous post made was a hidden post the next and previous buttons will expose a link to a hidden page. I have not had time to dig into this as yet and as the posts are not actually accessible it’s not presently a priority. If you know the solution please leave a comment below.

Alternatively there are plugins available on the WordPress Plugins Directory, the ones I tried also suffered from the next and previous issue.

Resurrection

I’ve bought back this site after a long break, piecing together old posts from information I could find in the internet archives. Not everything made it, some of the older information has broken links and some posts needed tweaking. Despite any issues, I’m happy to once again have a place to share and save some of the things I get up to.

Arduino controlled – spooky Halloween themed birthday cake stand

A friends birthday promise to make a memorable cake resulted in a fun filled couple of days building an Arduino controlled cake stand and baking a cake 🙂

I had been tinkering with Arduino it in the past and after the commitment  thought it would bring something special to the task at hand.

board_arduino_uno

Arduino is an open source electronics board with a number inputs that can be used for reading various sensors among other things and a number of outputs that can be used to control or power other things.

Cake stand features:
  • circling shark in pond (motor with reduction)
  • proximity sensor controlled coffin that opened if someone reached over it. (Added a Jaycar proximity sensor to trigger the input of the Arduino).
  • flapping bats (servo moving thin wire and black paper for the bats)
  • twinkling stars (random pattern)
  • button controlled flying witch across the moon in an arc with a message behind(servo controlled with long thin wire arm)
Cake features:
  • Cake
  • coloured icing

Modular Building Designer / Estimator Tool

Here are a couple of modular building design / estimating program prototypes I came up with. There is a Web App & Windows Version, the premise was to design and prebuild house as modules from substructure through to roof and sell them through an app, construction would be just placing the modules onsite and bolting them together hopefully reducing construction time onsite to a few weeks.

boxbuilder
Windows Version

 

Luhn Formula, Mod 10, Modulus 10, Credit card & BPay Number Validation

Hans Peter Luhn the creator and original patent holder for the Modulus 10 Formula left us all a legacy. Just about every time you enter your credit card details online you will be subjected to the Luhn check. If you’re not, the website you are visiting is likely to be a little on the dodgy side.

Mod 10 as it’s commonly known is not the only check that a payment number goes through before validation of a payment occurs, it is only really usefull to check for typing errors and kids who think they might like to try random numbers. The real work of checking a payment number is going to be done by the bank or credit card gateway that is used by the merchant. When a check with mod 10 is done prior to sending a request to the final checker, it cuts down on millions of electronic requests to the many various payment providers and thus goes a long way to providing a smoother overall experience to users.

So now to the reason why I’m bothering to write about the Luhn Algorithm. The reason is not so much to do with the algorithm but with implimentation for bPay. bPay is a non-instant payment system popular in Australia where I live. With bPay you never have to give the store or service any payment details, they give you a unique payment number for either each user/account or for each unique transaction made for their business. A combination of both user and unique transaction is also possible. bPay numbers can become large due to the large amount of users who utilise the service and the amount of tracking the business decides to use. It’s common for CRN’s (Customer Reference Number) lengths of well over 20 digits. This is a rather large number and when considering doing calculations on it a few consideratons have to be made to ensure you get results. Your common off the shelf mod 10 program/script may not be able to cope with such large numbers due to the limitations of the data type programming language, or lack of forethough when it was written. So the reason as to why I have written this post is now ready to be revealed, I tried to use an off the shelf script in PHP for bPay validation and it failed…sometimes..

The script I initially utilised was written for credit card verification (16 digits in length), somewhat smaller than the 20+ digits I wanted to work with. After integrating the script and adding all the required functionality to the website shopping cart I was working on, everything seemed fine. CRN’s and check digits were getting produced during the checkout process and I was able to verify the CRN’s with some third party mod10 programs. It was only after producing the required 20 CRN’s during the bPay application process that any Issue was raised. The bank kindly sent an email in reply stating that some of the numbers didn’t check out. Admittidly it took a while to work out the issue, In my defence it was only every now and again the script would produce an incorrect check digit number. I rewrote the script a couple of times before it even occured to me to break the number up into chunks. Sure enough by processing the number in chunks it didn’t produce randomly incorrect numbers anymore. Further investigation showed that when dealing with larger numbers instead of producing an error message PHP would still provide an answer but the accuracy could be questionable. After a Google I found the PHP Integers page and the following

The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that’s 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5.

Two billion eh! that’s 2,000,000,000 in the short scale of things. At the command line on my test server

[brendon@hotchipsnsource]# php -r 'echo PHP_INT_MAX;'

produced exactly “2,147,483,647″.

That is not even enough to hold the 16 digit credit cards that the script was created for, so what is going on?

~to be continued.

Wivenhoe Fishing Map

Wivenhoe is about an hour from home and a nice spot for camping and fishing, I think I will be visiting a lot more often now, so have taken to collecting as much fishing information I can find and have started putting it all together onto a map of the area. As I learn more I will continue to update it and hopefully it will become a usefull resource.

IF YOU HAVE ANY LOCATIONS THAT I CAN ADD LEAVE THEM IN THE COMMENTS!

Bas
Bass
Catfish
Catfish
Mary River Cod
Mary River Cod
Redfin
Redfin
Saratoga
Saratoga
Yellowbelly
Yellowbelly

View Capitan Morgans – Wivenhoe Fishing Map in a larger map or add to your own Google account and update as you like. Just be sure to tell me about the good additions you make!

To use on a mobile phone web browser with GPS like the iPhone or Android use this shortened URL http://goo.gl/QIBpE

Another alternative that I have found better on the go is to save the map to your own Google “My Maps” and add it to Google Earth for iPhone or Android. Just make sure you browse to all the places you want to visit before you leave home so it caches the maps for quicker and less costly use, also incase you do not get reception.

How to work out a Hip or Valley length (Part 2)

Alright so in the last post we went through the reasons why the multiplying factor is not the same for a Hip or Valley as it is for the roof or for that matter a section of barge, this time you get what you were after, the actual formula.
..

To view the formula, or to save and edit this file go to: https://spreadsheets.google.com/ccc?key=0Am6p57KakXPVdFVLR3BGUGNqbnVQMGgxVjU0U1Vjdmc&hl=en select “File” -> “Download as” -> and then select “Excel” or “Openoffice”. If you have any issues just let me know in the comments.

Deleting Images within a range in Excel

I couldn’t find a way to delete images within a range of selected cells in Excel’s interface so put together the following code and set it to run with Ctrl+Shift+I.
Sub delimg()
Dim sh As Shape
With Excel.Application.ActiveSheet
For Each sh In .Shapes
On Error Resume Next
If Not Application.Intersect(sh.TopLeftCell, Selection) Is Nothing Then
sh.Delete
End If
Next sh
End With
End Sub

Note: If you need to delete all images and objects you can use F5 select “Special” and click “Objects” and that will do the trick too.

How to work out a Hip or Valley raking length.

This is a two part series on how to work out a Hip or Valley raking length for Estimating purposes.

Having done a bit of estimating for large residential builders now, I have come to learn that many estimators do not know how to work out a Hip or Valley length. The matter has recently come up again so in order to get the word out about how to correctly work it out I thought it best to put up a post and an excel spreadsheet demonstrating a method of correctly working them out.

But firstly, and it may seem obvious, why do estimators need to know the Hip and or Valley lengths? Could they not get their Fascia and Gutter supplier or Roofing supplier(Tile or Sheet Metal) to supply them with a quote with the measurements? Of course they could but how would you know they are quoting to you correctly, if you have more then one quote and both match for quantities your probably safe, but what if they differ? You could be building 500 homes a year and they could be supplying you with quotes saying you have an extra 2m of Hip capping on each job. If each lineal meter of hip capping was $15.00, just the roof tile supplier could be getting an extra $15,000 from you each and every year(Are you a builder that has been operating for more then 10yrs?). That is just the start, you also have to pay for your valley irons and valley trimming and some builders pay their carpenters for the lineal meterage of hips as an extra. Those who calculate these simple things the wrong way or rely on a quote for the measurements could be paying more then they need to. It is a fact that I more often then not see these things over allowed rather then correctly allowed, it is primarly the estimator not understainding how to do the calculation correctly to begin with and then adding a little extra “fat” and then also rounding up as well, just to be sure.

So lets get into it shall we. Both a hip or valley length is calculated the same way, this is so because they basically form a corner for a roof and the distance from fascia to apex/ridge does not change be it a Valley(generally an internal corner) or a Hip(generally an external corner).

If you have tried to work it out for yourself before and your thinking to your self the only angle you need to work with Is the roof pitch (in degrees) form the plans, you would be mistaken. This is the common mistake I come across over and over, so don’t feel bad about it you’re not alone. I have found a lot of estimators use the roof pitch factor based off just the main roof pitch to work out the length of their hips and valleys and this leads to over estimating as it is not the right way to work it out.

Consider the following to understand why the pitch of your hip or valley is different to your roof pitch; Your hips and valleys if measured in plan view are longer then your standard truss to the ridge line, this is because they are at 45 degrees to the normal trusses and the distance therefore is further. If your hip or valley was rising at the same pitch as the truss and as we worked out before they are indeed longer, the top of the hip or valley would be higher then the top of the truss. Obviously because your ridge line should be horizontal having your hip higher is going to be an issue.

A common mistake made by estimators is thinking that hips rise at the same degree as normal trusses.

There are three(3) triangles to consider when working out the length.

25 Degree Example Roof

The first triangle would represent half of a normal truss in elevation (side) view.

25 Degree Example Roof

The second triangle would represent the 45 degree angle to the hip or valley in plan view.

25 Degree Example Roof

The third would represent the hip or valley itself in elevation.

25 Degree Example Roof

We now have knowledge of the basic building blocks we require to write the formula to work out the raking length, in the next installment we will go through the math and I will present you with a excel spreadsheet which you can use yourself.