Skip to content

Instantly share code, notes, and snippets.

View lenrsmith's full-sized avatar

Leonard Smith lenrsmith

View GitHub Profile
@lenrsmith
lenrsmith / booklet_pages.php
Created February 12, 2018 20:22
Rough algorithm to calculate pages for a booklet
function collateBookletPages($totalPages)
{
// See if the page count is odd. If so, add 1 page to make it even
if($totalPages % 2) {
$totalPages++;
}
// $totalSides is a bit misleading, but couldn't think of a better term at the moment.
// We are referring to one side of a sheet of paper (obverso/reverso) upon which
// 2 pages will be printed on the left and right.

Keybase proof

I hereby claim:

  • I am lenrsmith on github.
  • I am lenrsmith (https://keybase.io/lenrsmith) on keybase.
  • I have a public key ASDK0FQY-JHicP-_1vnefRvuCyO8eIR_5lwYrzIKQpjwdwo

To claim this, I am signing this object:

@lenrsmith
lenrsmith / gist:279bf2c5420c4246b579
Created June 22, 2014 16:14
Keep focus on an input box on an HTML form
/*
The following is the only way I could find to solve an annoying problem
I was having on an HTML Form. I needed to add items from an input box to a
multiple select control. I wanted to use the change event instead of a button
to speed up the process. Everytime the entry was loaded into the select, the
select control received focus requiring the user to tab or click back into the
input box. I tried to use the focus event in multiple combinations and the
following finally worked.
#new_item is an input that adds new items to a multiple select box