selectize.js combobox example

Selectize.js ComboBox: Cloning and Destroying

Selectize.js is a javascript library that allows you to offer more complex HTML select boxes, such as combining a select and an input box, commonly known as an autocomplete combobox. Most importantly, they have a built-in stylesheet for Bootstrap 3. However, I discovered a problem when you are trying to add another form field dynamically, specifically using jQuery’s .clone() function.

However, selectize() does not clone well… it breaks horribly. The key you must .destroy() the selectize() prior to cloning. Of course, another problem occurs then: The select element, upon selectize.destroy(), will reset the value to the last option. Solution? Store the value, destroy(), then set the value.

// When add button is clicked
$('#add').on('click',function(){
   $('.combobox').each(function(){ // do this for every select with the 'combobox' class
      if ($(this)[0].selectize) { // requires [0] to select the proper object
         var value = $(this).val(); // store the current value of the select/input
         $(this)[0].selectize.destroy(); // destroys selectize()
         $(this).val(value);  // set back the value of the select/input
      }
   });
   $('#monsters .form-group:first')
      .clone() // copy
      .insertAfter('#monsters .form-group:last'); // where
      selectizeme(); // reinitialize selectize on all .combobox
});

Here’s a working demo of the functionality.

Pokemon Go for Business cover

Pokémon Go for Business: A Guide to Capturing New Customers (Kindle)

“Pokémon Go for Business” is a new ebook dedicated to helping every consumer facing business attract new customers. Well researched and full of specific, qualified ideas, the book helps explain the mobile game obsession to those who may never have heard of Pokémon before. Most importantly, it breaks down marketing ideas based on specific criteria, such as: Lure Modules, Gyms, and five distinct business types (e.g. Active Shopper, such as a retail store).

Available now on Amazon sites worldwide.

Included with this book are free Pokéstop icon templates (external download) and an employee handout (external download); the resources you need to get started DOING, not just thinking. The first layer of the table of contents is listed below for your convenience:

  • Introduction to Pokémon Go
  • Lure Modules: Who, When, and How Often
  • Marketing Toward Pokémon Go Players Without Lure Modules
  • Category Specific Marketing
  • Promotional/Guerrilla Marketing
  • Future Pokémon Go Features
  • Pokémon Go Quick Player Guide

PHP Alternatives for Nested IF Statements

We’ve all done it. It starts as a single IF statement:

if (empty($var)){ // does it exist?
   $error = 'No username entered';
   return $error;
}
// everything is OK

Then we decide, we need to check something else, so we just add in one more IF statement:

if (empty($var)){ // does it exist?
   $error = 'No username entered';
   return $error;
   if (strlen($var) > 20){ // Is it too long?
      return 'Invalid username';
   }
}
// everything is OK

Continue reading

debian 8 "jessie" LAMP

Install Apache, MySQL, PHP5, and PHPMyAdmin on Debian “Jessie”

This is a quick guide to getting an Amazon EC2 server up and running with LAMP and PHPMyAdmin based on the LTS (Long Term Support) Debian version 8.5 “Jessie”. This guide was written using the Community AMI image debian-jessie-amd64-hvm-2016-04-03-ebs for Debian “Jessie” and assumes you are able to launch the server and connect via SSH.

Amazon assumes an EBS volume of 8GB (t2.nano) or 10GB (t2.micro), but if the server will be storing very little, the real minimum size of the EBS can be calculated safely as:
1.5GB + (RAM x 2)
That is roughly 3GB EBS for t2.nano, and 4GB EBS for t2.micro.

Continue reading

Thinking Statue

Change the Legal Name of Your S-Corporation in 5 Steps | USA, Colorado

After recently selling all of the assets of Dice Candies, it was time to change the name of my umbrella S-corporation from Dice Candies Inc to Slowpreneur Inc. These steps are here to help ensure you don’t miss a step.

One quick note: While many of the links are specific to the state of Colorado, the steps are the same anywhere in the United States.

1) Articles of Amendment

The Articles of Amendment are an official document submitted to the Secretary of State’s office, where the corporation is registered, declaring the name change. Usually there is a small fee involved ($25 for Colorado). This first step is critical because the document is later used as proof for all other agencies and companies.
Continue reading

Picky Mat Example

Picky Mat – Make Your Own Cat Food Dish Liner

While I’m sad that the Kickstarter project failed for Picky Mat, I know the product works and I know it solves a real problem: cats who complain when they eat their dry food and suddenly see the bottom of the dish and consider their dish empty. Picky Mat solves this by removing the discouragement and in some cases retrains the cat to eat more of their food even after the mat is removed. All that being said, I didn’t want that work to go to waste, so here is a quick tutorial in making your own DIY Picky Mat.
Continue reading

WebM Converter Batch File

Encode WebM Video Files on Windows for HTML5 with FFmpeg

If you want to put video on the web, you’ll probably just going to upload it to YouTube and use their embed code. However, if you want to embed video on your own site without YouTube you want to make use of HTML5’s video element. To do that, you’ll want to make two encodings of your videos: WebM (Google backed) and H.264 (current standard). H.264 is easy because it’s been a standard for a long time (I personally use HandBrake), but WebM is quite a bit more difficult. There hasn’t be a defacto winner when it comes to encoding, though Miro Converter has come close.

However, the core of Miro and many others is the open encoder FFmpeg so we’re just going to setup an easy way to use that in this tutorial. Here are our goals:

  1. Install FFmpeg on Windows
  2. Create a Batch file (.bat) that we can drag-and-drop video files on to create WebM video
  3. Write the HTML5 code to allow for maximum speed and compatibility

Continue reading