Home
Slick Date and Time picker
- Details
I need a nice looking and easy to use date and time selector. I didn't want to use a drop down for the time because it just feels kludgy and old. I opted for a clock shape analog with hours. Once you select your hour it changes the hours to 5 minute intervals. The am/pm select is in the middle. The standard JQuery datepicker is used to select the date but in a static way. All this opens in a dialog. Please not this does multiples of 5 for minutes (0, 5, 10, 15, etc.). This opens in a dialog and needs JQuery to work. Another piece of functionality I added was to have the dialog set 2 form elements; 1 textbox with a nice formatted date and 1 hidden with a MySQL date.
For the file go to https://github.com/mrosandich/slickDTP
Quick Example: https://www.ourace.com/code_examples/slickDTP/index.html
So you want to put an above ground pool in Austin?
- Details
So you want to put an above ground pool in Austin?
First thing to remember is that you will need to stay at least 10 feet away from the back fence and 5 feet away from the side fences. This is pretty much true for any type of structure you plan to put in your yard.
Now if you pool is going to less than 5000 gallons there isn’t much else to do with the exceptions of the 10’ x 5’ rule aforementioned. For safety make sure there are no power lines above or below your pool.
Over 5000 gallons you will need a permit which cost me $365.88 at the time I wrote this article (6/12/2015).
Before you go to the planning office you will need a few things.
3 copies of your plot plan with your pool drawn on it to scale use the 1”=20’ scale and make 3 prints on 11x17 papers. This is what is should look like. sample home
Fill out the calcuation_aid.doc which basically will tell the person looking at your plan what type of impact it will have with drainage and impervious cover. calcuation_aid.doc
You will need to fill out the pool deck application as well. pool and deck.pdf
Going to the planning office:
Now march yourself down to the city and go by Austin Energy first, they will need to stamp your plan and they will have a form you will need to fill out and return with your application. They are on the first floor (721 Barton Springs Rd Austin, TX 78704) to the right when you first walk in.
Once you’ve done that take the elevator up to the 2nd floor and go right to the window. They will record you being thee and someone will come out and get you and review the papers to make sure you have everything. If all goes well they will send you to the first floor to pay for it.
Now go home and wait. They will call you and email you. If all goes well then you will be permitted to put in your pool.
Note:
Above ground pools do not affect the impervious cover numbers. So if your pool was 12’x24’ or 288 sq. ft. it would not add 288 sq. ft. to your impervious cover. It has zero affect.
Amazon echo (alexa) with PHP Hello World
- Details
This is my Helloworld for interacting with the amazon echo.
I packed it into one file. i'm not a big fan of samples being weighed down by includes (unless it calls for it).
In this example. Say your phrase: Alexa start Count Example
The echo will respond by saying the phrase "Welcome to the Our Ace count example say next item" and sending you a card in your echo app
The echo light will stay on and wait for you to say "next item" or "next"
When you say next it will count up by 1 using the session attributes in the json. You pass it json attributes and it passes them back
say next item until it hits five then it will quit. The light will go off on your echo.
Please note: you have to access you developer portal and set up your URL web service and SSL settings. Also, make sure your echo is using your developer email. If not setup another user on your echo and switch profiles to your developer account.
your dev setup area is here dev aw
Intent Schema:
{ "intents": [ { "intent": "quit", "slots": [] }, { "intent": "next", "slots": [] } ] }
Sample Utterances
next item
Below is the PHP code.
$EchoJArray = json_decode(file_get_contents('php://input')); $RequestType = $EchoJArray->request->type; $JsonOut = GetJsonMessageResponse($RequestType,$EchoJArray); $size = strlen($JsonOut); header('Content-Type: application/json'); header("Content-length: $size"); echo $JsonOut; //-----------------------------------------------------------------------------------------// // Some functions //-----------------------------------------------------------------------------------------// //This function returns a json blob for output function GetJsonMessageResponse($RequestMessageType,$EchoJArray){ $RequestId = $EchoJArray->request->requestId; $ReturnValue = ""; if( $RequestMessageType == "LaunchRequest" ){ $ReturnValue= ' { "version": "1.0", "sessionAttributes": { "countActionList": { "read": true, "category": true, "currentTask": "none", "currentStep": 0 } }, "response": { "outputSpeech": { "type": "PlainText", "text": "Welcome to the, Our, Ace, count example" }, "card": { "type": "Simple", "title": "Our Ace count example", "content": "I can count to five." }, "reprompt": { "outputSpeech": { "type": "PlainText", "text": "Can I help you with anything else?" } }, "shouldEndSession": false } }'; } if( $RequestMessageType == "SessionEndedRequest" ) { $ReturnValue = '{ "type": "SessionEndedRequest", "requestId": "$RequestId", "timestamp": "' . date("c") . '", "reason": "USER_INITIATED " } '; } if( $RequestMessageType == "IntentRequest" ){ $NextNumber = 0; $EndSession = "false"; $SpeakPhrase = "The next number is "; if( $EchoJArray->request->intent->name == "next" ) { $NextNumber = $EchoJArray->session->attributes->countActionList->currentStep + 1; $SpeakPhrase = "The next number is $NextNumber"; if( $EchoJArray->session->attributes->countActionList->currentStep == 3 ) { $EndSession = "true"; $SpeakPhrase = "Thank you for counting and good bye"; } } $ReturnValue= ' { "version": "1.0", "sessionAttributes": { "countActionList": { "read": true, "category": true, "currentTask": "none", "currentStep": '.$NextNumber.' } }, "response": { "outputSpeech": { "type": "PlainText", "text": "' . $SpeakPhrase . '" }, "card": { "type": "Simple", "title": "Our Ace count example", "content": "' . $SpeakPhrase . '" }, "reprompt": { "outputSpeech": { "type": "PlainText", "text": "Say next item to continue." } }, "shouldEndSession": ' . $EndSession . ' } }'; } return $ReturnValue; }// end function GetJsonMessageResponse
If you want Alexa to repeat phrases back to you try this:
Intent: { "intents": [ { "intent": "repeat", "slots": [ { "name": "Words", "type": "LITERAL" } ] } ] } Utterances: repeat words {any|Words} repeat words {any|Words} {any|Words} repeat words {any|Words} {any|Words} {any|Words} repeat words {any|Words} {any|Words} {any|Words} {any|Words} repeat words {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} repeat words {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} repeat words {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} repeat words {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words}
each repeat Words line allows for inputs. the first line would grab only 1 word. if there are 3 words after the phrase "repeat words" it would match the 3rd utterance down. If you wanted to catch a lot of words you would need to extend how many utterances are listed and keep adding an extra {any|Words} for each line.
To get the words into PHP it would look like this
$TempWords = $EchoJArray->request->intent->slots->Words->value; //based off the above code.
PHP and MongoDB
- Details
I get the question how to interact with MongoDB at least once a month. So here is the simple version.
You will need to have the Mongo Functions installed on your web server see the installation guide (http://php.net/manual/en/mongo.installation.php)
Connecting to the database:
Just like any other database you need to specify an IP, port, database, username, and password.
$connect_mongo = "mongodb://localhost:27017/mytestdatabasename";
$o_mongo_connection= new Mongo($connect_mongo,array('username'=>'YourUsername','password'=>'YourPassword'));
You will need to assign that database to a var so you can reference it easily.
$o_database = $o_mongo_connection->selectDB('yourdb');
Now thinking in the terms of normal database like MySQL or MS SQL you generally write a select statement against a table. In the case of MongoDB we are going to make a reference to the collection (sorta of like a table).
$o_collection = $o_database->collection; //grabs the default collection
$o_collection = $o_database->selectCollection('collection'); //grabs a specific collection. Recommended
If you wanted to make a new collection you can do this:
$o_recipes = $o_database->recipes;
You now have a collection called recipes
To add a recipe:
$a_ingredients = array('Item' => '1 pound flour','Item' => '1 pound butter', 'Item' => '1 pound sugar');
$a_recipe = array(
'title' => 'Pound Cake',
'description' => 'They called it pound cake becuase it literally used a pound of butter, pound of sugar, and a pound of flour',
'ingredients' => $a_ingredients,
'create_date' => new MongoDate()
);
$o_recipes->insert($a_recipe);
Yes, you can simply pass it an array and that is your new document.
Please note that $recipe now has a new key called '_id' which was created for you and which you can now use to find the item in the database.
Reading and Finding
So to pull out the record you just made you could (wouldn't really need to do this since $recipes is already loaded into memory):
$id = $recipe['_id'];
$results = $o_recipes::findOne(array('_id' => $id));
To find all recipes that use 1 pound of flour:
$a_query = array('Item' => '1 pound flour');
// for a like use this: $a_query = array('Item' =>array('$regex' => '1 pound')); //there are various ways to do a like some are more optimal than others
$a_results = $o_recipes::find($a_query);
To iterate the array:
foreach ($a_results as $doc) {
print_r($doc);
}
To Update
To update a recipe you pass back the recipe you found. the _id is the key here.
if your record has an _id then it is an update. if no _id then it is new.
if you pass in new array keys they will be added.
To Delete:
to remove a single document you will want to use the _id for the most part
$id = $recipe['_id']; //or you got it from a POST or GET
$o_recipes::remove(array('_id' => $id));
or
$o_recipes::remove(array('_id' => 777), array("justOne" => true));
References:
http://php.net/manual/en/mongo.core.php
Page 7 of 40