Sunday, December 4, 2016

My Favorite Kodi Setup

Home Theaters.... Who doesn't love to go to the theater, eat some popcorn while the trivia slides, new trailers, and the turn-off-your-cell-phone clip runs?  That whole cinema experience is something I'd been wanting to recreate in my home for those times when staying in is the plan.  I looked at a few media center setups, but most of them worked only (or had the best features) on windows, cost money to buy, or required a subscription or additional expensive hardware.  I won't tell you which ones I tried, because I'm really stoked about a tried and true free option.  You've probably heard about it: KODI.  It's free, very stable, and fast.  It's one of the best open source media centers available and you can get it on Windows, MAC OSX, Linux, Android, iOS, and Raspberry Pi (which is really just a linux version).  Since I love the raspberry pi, this walk-though will use that.

I didn't want to be wasting my electric bill on a PC running solely to stream my ripped movies that I own, so I looked into a light weight, energy efficient, fast media center that I could have complete control over... Enter stage Raspberry Pi 3.  It wasn't until the raspberry pi 3 came out that the pi really had enough speed to perform similarly to the windows version on KODI,  So I went all in.  I'll be updating this blog with my changes as I perform them periodically, but let's get right to the setup:

My Hardware:

The Software:

WARNING: Your USB Stick / SDcard will be erased by this procedure as it installs OpenELEC onto it. Please ensure you know the correct drive letter for your USB Stick / SDcard.

Writing *.IMG to SDCard:
  1. Extract the OpenELEC image using 7zip.
  2. Insert your USB Stick / SDcard into your system/card reader. It should appear as a new drive letter (make very sure you know which drive letter it is, since Win32DiskImager WILL wipe that drive - if it happens to be your Windows drive... too bad).
  3. Run Win32DiskImager
  4. Select the image (*.img) file and verify the destination drive letter is correct, then click write.
  5. When it is finished you can safely remove the USB stick / SDcard by right clicking on the drive in windows explorer and selecting eject.
Get Kodi Setup for the First Time:
  1. If you have a case for the raspberry pi, please put it all together so you don't inadvertently short out any circuits.
  2. Plug the newly written SD card into the SD card slot in the raspberry pi.
  3. Connect the usb keyboard.
  4. Connect the HDMI cable from the raspberry pi to a motitor or TV.
  5. Power on the raspberry pi by plugging it into a wall outlet.
  6. Follow the first time setup guide in order to add a media source for Kodi to be aware of your video/tv locations: http://wiki.openelec.tv/index.php/Guide_to_first_use
  7. I happen to use the AEON MQ6 skin (seems to look and feel great), you can add it from here: http://kodi.wiki/view/Add-on:Aeon_MQ_6
Creating the True Home Theater Experience (MY FAVORITE PART AND THE REASON I WENT WITH KODI):
I happen to love the full movie experience once in a while without the cost.  I have found that the Cinema Experience add-on for Kodi to be the most comprehensive experience of them all.  It's pretty simple to setup, and amazingly powerful for customization.  What I love about it, is that you can add your own pre-roll videos, trivia slides, and any amount of other pre-roll stuff, including scripts to control lights in the room, and have it download and play trailers from the internet that are the same or lower ratings as the movie you are playing.  Here's how to get it setup from the main menu:
  1. Settings
  2. Add-ons
  3. Install from repository (v15/v16) / Get add-ons (v14)
  4. Kodi add-on repository
  5. Program Add-ons
  6. Cinema Experience
  7. Install
You do need to spend a bit of time reading how to setup the cinema experience add-on in order to show the correct videos/trivia/intros/outtros/etc and when, but it's not hard, just go into the configuration of cinema experience (CE) and look at each item and compare it with what you want to show and when.  You will need to specify file locations for the different types of videos and trivia and have downloaded those things into those folders.  But the trailers can be set to download from internet sources, so you can always be seeing up coming trailers without any extra work.  Here is a list of things you can possible add around the feature film (this comes directly from the section 3.2 Sequence Overview from the CE wiki):

Cinema Experience gives you the ability to enable or disable any introduction videos, or the trivia slideshow. You have the power to customize your cinema experience. The following is an example of the complete script flow:

  1. Trivia Intro Video(s)
  2. Trivia Slides with Optional Music Playlist
  3. Trivia Outro Video(s)
  4. Movie Theater Intro Video(s)
  5. Coming Attractions Intro Video(s)
  6. Trailer(s)
  7. Coming Attractions Outro Video(s)
  8. 3D Intro Video(s) - if upcoming Movie is in 3D format
  9. 3D Trailers( from folder as I haven't found a site that has them really available) - if upcoming Movie is in 3D format
  10. Countdown Video
  11. Feature Presentation Intro Video(s)
  12. Rating Video (MPAA, BBFC and FSK ratings are currently supported)
  13. Audio Format Video
  14. FEATURE PRESENTATION
  15. Intermission Video(s) (note)
  16. Rating Video
  17. Audio Format Video
  18. FEATURE PRESENTATION 2
  19. Intermission Video(s) (note)
  20. Rating Video
  21. Audio Format Video
  22. FEATURE PRESENTATION 3
  23. Intermission Video(s) (note)
  24. Rating Video
  25. Audio Format Video
  26. FEATURE PRESENTATION 4
  27. Intermission Video(s) (note)
  28. Rating Video
  29. Audio Format Video
  30. FEATURE PRESENTATION 5 (end note)
  31. Feature Presentation Outro Video(s)
  32. 3D Outro Video(s) - if upcoming Movie is in 3D format
  33. Movie Theater Outro Video(s)

Available in 3D if upcoming movie is 3D and settings enabled.
(note) At this point in the script, if multiple features have been queued and the skin uses home menu integration, multiple rating videos, audio format videos, features, and intermission videos will take the place of a single feature. A total of 5 features can be queued. This option can be even larger if you use one of the starting methods suggested in the Script Starting methods section.

You setup the folders first (they can be networked locations or local), then go into the cinema experience configuration and select what you want turned on to show during the flow and where that file source is.

For the home automation stuff see the integration section.  This is for things like dimming the lights, etc.  Of course, you'll need to do a bit more research on this, as I've not setup home automation yet with CE, but I will be, and when I do, I'll post it most likely right here.

In order to play a movie using the cinema experience, you need to select the movie and show the movie details. One of the items in the list of actions along with the standard "Play" button will be "cinema experience" button.  Choose that one and you'll be on your way.  The default button, "Play", will just play the video without any of the cinema experience.   I really like that I've setup the time of the trivia to display for 10 minutes (this can be changed in the CE config).  This allows me to go make popcorn and tell everyone that the movie will start at a certain time, and just show up right before that time and it starts into the intro videos and trailers.  It's really, really, really cool.  Did I mention it was really cool?
Using your phone or tablet to control Kodi
I Installed the android app Kore on my phone to control KODI over the network.  It works great, but you also need to make sure that you set Kodi to allow to accept network remote controls:
  1. Go to System->Settings->Services->Webserver and enable the setting Allow control of XBMC via HTTP;
  2. Take note of the Port number that is selected, the Username and the Password (if any). You’ll need to input this in Kore;
  3. Go to System->Settings->Services->Remote control and enable the settings Allow programs on this system to control XBMC and Allow programs on other systems to control XBMC.


Thursday, February 18, 2016

Android Programming for Beginners - Especially Useful

Android Programming for Beginners - This book, though for beginner programmers that may not be familiar with Java, can be used as a refresher for job interviews or for a personal refresh.  I was surprised at how the author took some complex topics and made them understandable to someone who might not know anything about programming.  You get to building apps right away.  The environment is typical Windows and Android Studio, but if all you have is a Mac you should be fine too if you are intuitive about installing things.  If you are really wanting to be a programmer, you're going to have to learn to figure out problems all the time, so following this on a Mac should not be any issue.  But if you've really never programmed, then I'd recommend sticking with Windows and following along exactly.

You get to build quite a few apps from the basic setup all the way to publishing the app and marketing it.  The meat of the book is really about understanding the Android environment with a programmers mind.  Don't worry, it goes over Java language as well with some great analagies that I see would help even the newbie of noobs.  But we were all noobs at some point, and this book is a great start at it.  I wish I had this book when I started programming native Android.  Highly recommended.

Mastering RStudio - Develop, Communicate, and Collaborate with R - Pretty Sweet with a Slice of Awesome

Mastering RStudio - Develop, Communicate, and Collaborate with R - Tons of information and in-depth walk-throughs on how to create and present calculated data sets using all sorts of statistical analysis. I love that it helps me generate interactive websites and reports that look good. What's an analysis worth if you don't know how to present your findings? Don't get me wrong; this book is not all about how to present your findings. There are heaps of analysis tools to use which are powerful, but having the ability to generate more than just an in-application graph is a valuable asset.  Plus once they are generated, you can simply copy-paste them into your own environment.

I really like the way this book presents the data, principles, and solutions.  Good work!!!

Thursday, February 4, 2016

Custom Kendo UI Map Tips - A General Walk Through

QGIS

Find maps

First thing you need to do is find the maps you want to use.  There are many places where you can find shape file maps, but the main resource I ended up using is http://www.naturalearthdata.com/downloads/50m-cultural-vectors/.  The data comes in various scale.  For our purpose I used the 1:50m (medium scale) maps.  There are 3 type of data, Cultural, Physical, and Raster.  You want Cultural data.  I picked the Admin 0 – Countries in order to get a world map of the countries.  I then needed to merge the countries by deleting the USA and replacing it with the USA Counties.  So for the US Counties map, I went to https://www.census.gov/geo/maps-data/data/cbf/cbf_counties.html.

Download QGIS

The merge of the 2 files is best performed in a program called QGIS LTR (long term release) available for free here: http://www.qgis.org/en/site/forusers/download.html
Note I tried to use the merge function in the non LTR version, which was newer, but it seemed broken.  So I used the LTR version and the merge worked fine.

Load Layers into QGIS

Open QGIS Desktop, which ever version you have.
Unzip the map files you downloaded as well.  The files will contain many files, but you are looking for the files with the extension .shp and .dbf.
For QGIS, you don’t need the dbf file, but just be aware of its existence for further instructions.
You can now just drag the .shp files you want into the layers section of QGIS.  You’ll want to add all the files you have into the layer browser.
You should now have something like this:

Edit the layers

Now you need to edit the layers, by removing the overlapping shapes.  Play around with the “x” next to the layers to hide and show the layer you want to edit.  What we need to do is delete the USA from the admin map.  So we’ll hide the counties map by unselecting the x next to the counties layer.  Click on the admin layer to highlight it.  Then press the “edit” button to allow editing of the shapes:
Once edit is turned on you can now use the selection tool to click and highlight the USA.  It should turn a different color, in my case it was yellow:
Notice that you don’t have to highlight Alaska and Hawaii separately when you clicked on the USA.  Those get highlighted as well.  However, Puerto Rico does not get highlighted, which the county map contains the counties for as well, so we need to highlight that shape as well by holding the CTRL key and clicking on Puerto Rico shape:
Now that you have all the shapes selected where the two layers generally overlap, you can now delete the yellow highlighted shapes by pressing the DELETE key on your keyboard.  You should be left with the following:
If you want to pan around the map, press the hand button to switch to panning.  You may now turn off the editing button for this layer by pressing the editing button again: .  You want to save the changes.  Note that the admin (countries) file you loaded is now changed.
Now turn back on the counties layer and you’ll end up with the following:
We are now done editing the files and are ready to merge them into one file for use with Kendo UI Maps.

Merge Layers Into a single file

I never found an easy way to merge the visible layers from QGIS into a single file, but rather there is a processing tool you use to do the merge and then it’s loaded back into the layers as a third layer for you the check.
Open the file merge tool by going to: Vector >> Data Management Tools >> Merge Shapefiles to One…
Now select the checkbox indicated and select the 2 .shp files as input.  I had to move the shape files into the same folder so I could select both files by holding the CTRL key.
NOTE: on the export of the file, you must select the encoding as UTF-8.  This is critical in order for the Kendo UI Maps to read the file properly.
You should end up with this (once the merge is done, you can press cancel on the merge tool):
Now you want to right click on the new layer and select “Save As…”.
Make sure you select Format as GeoJSON, and Encoding as UTF-8.  It’s up to you if you want the saved file added to the map or not.  Once you have saved that, you now can take that GeoJSON file into mapshaper.org and simplify it.

MapShaper.org

Load the Map

Notice that the saved GeoJSON file is way too big to using in the website:
>
We need to shrink the file.  We do this with mapshaper.org.
Open http://mapshaper.org/  website and select the GeoJSON file you just saved.  Note if you are working with .shp files, you’ll need to load the corresponding .dbf file as well.  Just drag the GeoJSON file onto the website.
Press the simplify button: .  Then make sure that “prevent shape removal” is selected as well.  This will help from removing the small shapes, but if you simplify it too much it will anyway.
I’ve had good luck with simplifying it down to about 0.41%.  This makes the counties not too distorted, but it makes the file size a ton smaller.  When you’ve played with the simplify feature to your liking, then press the Export button.
You may need to enter “encryption=utf8” in the command line options if you are importing a non utf-8 file (say like a shape file you got from the internet somewhere that does not have utf-8 encoding already).
Select GeoJSON and there you have it, a smaller merged file:

Kendo UI Maps

The Code

I’m going to gloss over this part as there are tons of resources on how to setup and implement Kendo UI Maps.  Just google that term for the API (http://lmgtfy.com/?q=kendo+ui+maps).  You’ll need to workout your own event logic for the map, but here is my createMap function (it’s in angularJS) that creates the layers and sets up the callbacks to the appropriate event methods:
 $scope.createMap = function () {  
 // insert the markers into the $scope.kendoMapMarkers object  
 $scope.insertMapMarkers(null);  
 var colors = ["#104E8B", "#1874CD", "#1C86EE", "#2385E6", "#509EEA", "#60AAF3", "#86BCF1", "#9CC8F3", "#A4CEF8", "#B9DCFF"];  
 // create the map with the markers  
 $("#kendoMap").kendoMap({  
      center: [30.268107, -97.744821],  
      zoom: 3,  
      controls: {  
           attribution: false,  
           navigator: false  
      },  
      wraparound: false,  
      layers: [  
      //{  
      //  type: "tile",  
      //  urlTemplate: "http://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png",  
      //  subdomains: ["a", "b", "c"],  
      //  attribution: "© OpenStreetMap contributors"  
      //},  
      {  
           type: "shape",  
           dataSource: {  
                type: "geojson",  
                transport: {  
                     read: "/Resources/kendoui/GeoJSON/countries_and_counties_3.json"  
                }  
           }  
      },  
      {  
           type: "shape",  
           //autoBind: false,  
           dataSource: {  
                type: "geojson",  
                transport: {  
                     read: "/Resources/kendoui/GeoJSON/world_countries_and_states_provinces_lakes.json"  
                }  
           }  
      },  
      {  
           type: "marker",  
           dataSource: {  
                data: $scope.kendoMapMarkers  
           },  
           locationField: "latlng",  
           titleField: "name"  
      }],  
      shapeCreated: function (e) {  
           e.shape.fill("#104E8B");          
      },  
      markerCreated: function (e) {  
           // Draw a shape (circle) instead of a marker  
           e.preventDefault();  
      },  
      click: onClick,  
      reset: onReset,  
      pan: onPan,  
      panEnd: onPanEnd,  
      shapeClick: onShapeClick,  
      shapeMouseEnter: onShapeMouseEnter,  
      shapeMouseLeave: onShapeMouseLeave,  
      zoomStart: onZoomStart,  
      zoomEnd: onZoomEnd,  
      shapeClick: shapeClick  
 });  
Notice that in the “shapeCreated” and “markerCreated” functions I’m running them in-line while all the other functions refer to a reference to their respective methods.  You don’t need to do that and make them all reference calls.  It’s just a convenience thing.

Friday, January 29, 2016

Udemy video course - Web Visualization with HTML5, CSS3, and JavaScript Review

Web Visualization with HTML5, CSS3, and JavaScript: First of all, css is awesome.  This course does not dive into setting up your environment, but rather focuses on aesthetics in design - and how to implement those design features using HTML5, CSS3, and JavaScript. The content is applicable and relevant.  Easy to follow and understand.  He could have been a bit more prepared with the colors he wanted in lecture 4 with the gradients, but he recovered nicely.  5 stars for this one because he covers some advanced topics effortlessly.  With CSS it's not always necessary to dive into the technical why, which he balances very well.  The manner in which he teaches new methods are very clear and easy to remember.  Good job!  I've learned a lot of new tips.

Wednesday, January 27, 2016

Cocos2d-x Cookbook - Helpful

Cocos2d-x Cookbook - Pretty great resource if you don't know much about Cocos2d-x. But if you already have knowledge in Cocos2d-x, like how to load sprites, physics, audio, and 3D models then only a part of this book may be useful. There is not much in the way of 3D, other than how to load a 3D model, which seems to have a spelling error in the first section it is described (using "3D modal" instead of "3D model"). Grammatically it needs a bit of work, but I understood everything that was being said.

You can definitely use this as a reference or a getting started set of snippets, but all recipes would need to be modified to be implemented in a use-able game/app. That being said, you'll find the networking part very helpful. There does not seem to be enough clarity on the web on how to frame web service calls and process the data. This book helps with that. This is a critical part of securing external logins and other security items. It is a great book and I recommend it, but I cannot say its the most explanatory book on the subject, though it does cover all the relevant topics.

Don't get me wrong, this book will help you go in the right direction and implement certain important standards, but you'll need to do your own leg work to figure out how to put all the pieces together.

Monday, January 18, 2016

DevOps Automation Cookbook - These ARE the servers you're looking for...

DevOps Automation Cookbook is chocked full of good information and recipes.  You'll gain 100 points in your geek level just by reading this book.  If you implement what you've read, well then, you are eligible to become a Geek Master...  You might as well pick up D&D while you're at it, because that's the only thing you'll be lacking after reading this book.
Seriously, even developers should read this book, since DevOps is all about bridging the Agile gap between developer, manager, IT, end user.  Remeber, this is a cookbook, so you may not have the exact requirement, but you'll be able to easily modify the recipe to meet your needs.
The author does not attempt to force you down a particular path and states that very clearly.  So use what you've got, and purge the principles in this book to apply to your own environment.  You go girl!