Posts

Showing posts from July, 2018

Bayesian Analyis with Python Chapter 4, Understanding and Predicting Data with Linear Regression Models

Image
Simple Linear Regression Continuous variable - a variable using real numbers or floats (dependent, predicted, outcome) Independent variable - can be continous or categorical (predictor, input) We can can model this relationship with linear regression.  With multiple independent variables, we will use multiple regression models. The machine learning connection Machine learning (ml) is the umbrella term for a collection of methods to automatically learn patterns in data.  Regression is a supervised learning problem because we know the x and y values.  The question is how to generalize these observations to any future observation. The core of linear regression models Beta is the slope of the line, changer per unit change in x. Alpha is the value of y when x = 0. When we try to solve this problem we use the least squares model.  We can also use a Bayesian framework. This has several advantages: we can obtain the best values of alpha and beta capture u...

The Research Magnificent Chapter the First: The boy grows up

1. Benham's father was a school headmaster, who never had much success.  2. Benham's mother is introduced.  Benham sees her a few times a year when they have tea.  The Lady Marayne makes conversation and then sends him on his way.  3. Benham's step-mother loved hims as her own son.  But her spirits were weighed down by the belief that Porphory, Benham's father, did not love her  and that marriage to divorced people was a sin.  Only later in his life was Benham able to see how she loved him.  4. Benham's mother dreams of big things for her son.  She also informs him that money will be nothing to him.  He will have thousands a year. 5. Benham's mother frets over his friends.  How can anyone from a good family with William go by Billy?  She also frets over the boy's and their being "socialists". 6.  In which we learn oft he origins of Billy's and Benham's friendship.  We also learn more about Billy and his uncon...

The Research Magnificent Prelude

The Prelude: On Fear and Aristocracy 1. In Chapter one, we are introduced to our protagonist, Mr. William Porphyry Benham and his goals.  He has a quite odd goal of being noble or Aristocratic.  Hence the title, the Research Magnificent.  Mr. Benham has been taking notes his whole life with this goal in mind. 2. Mr. White, who was lately a friend of the Mr. Benham, ponders the impossibility of turning the manuscript into a book.  Benham throughout his life has alterated the title, of the book, and presumably even the research he started out with. 3. "He did not percieve there was any difference between the fool who says a thing in his heart and one who says it in the dormitory" In this chapter H.G. Wells starts at the beginning of the Benham's life in boarding school.  We learn that he was very much a troublemaker in his youth.  So much so that he proclaimed, not to be a believer in God, just to mess with teacher and another boy. 4.  S...

Getting Started With Laravel 4, Chapter 7: Architecting Ambitious Applications

Moving from simple routing to powerful controllers You can take the business logic out of your routes, and place them in controllers.  Create your route, and place the following in it: array("uses" => controller@function) . Favoring explicit routing You can use implicit routing in Laravel, much like was done in both Codeingniter and early versions of Ruby on Rails. Explicit routes are better.  You can define the name and expected pattern of each argument. Straightforward REST routing Instead of specifying all the routes, you can just create one route, and a controller with all the appropriate action verbs. Supercharging your models We used simple models earlier, but Eloquent allows for more complex queries that we will examine in the next few sections. Simple performance tricks ORM's are great for simplifying database work.  But they can cause issues if you don't know what is going on behind the scenes. Eager loading records When you've got mod...

Getting Started With Laravel 4, Chapter 6: A Command-line Companion Called Artisan

Keeping up with the latest changes Run composer update to pull the latest changes into your local environment.  Running php artisan changes will show the latest changes.  This is a good way to see new features without having to be constantly checking git, blogs and the like to see new things.  This did not work on my 5.xxx Laravel install.  I fear it is deprecated now.  You can also check which version of Laravel you are using with --version .  Inspecting and interacting with your application Using the routes options with show all the routes your application will respond to.  This is a great way to start familiarizing yourself with a new application that someone else has written. Fiddling with the internals php artisan tinker This will start an interactive shell called Read-Eval-Print Loop (REPL).  This works much like the regular php shell.  Turning the engine off -down command will turn off your app, in case you need to som...

Getting Started With Laravel 4, Chapter 5: Testing - It's Easier Than You Think

Testing in PHP is hard.  PHP is hard.  PHP apps are tightly coupled and that makes them hard to test.  They can also be heavily reliant on databases and other outside dependencies.  This is really outside the scope of unit testing, and really is called integration testing.  Laravel was built from the ground up to make testing easier Links: https://stackoverflow.com/questions/2741832/unit-tests-vs-functional-tests https://www.softwaretestinghelp.com/the-difference-between-unit-integration-and-functional-testing/  https://codeutopia.net/blog/2015/04/11/what-are-unit-testing-integration-testing-and-functional-testing/ The benefits of testing Testing has many benefits, as projects grow in size and shape, tests can insure everything keeps working, and we know that nothing is broken.  A failing test should allow you to quickly know what the problem is, and where the problem is.  This will allow considerable less downtime when deploying new app...

Getting Started With Laravel 4, Chapter 4: Authentication and Security

Image
Authenticating users PHP doesn't have any way to authenticate users.  This leads to many problems,  and many different solutions in pure PHP.  Laravel provides the tools to make this happen. Creating the user model Laravel provides default inside auth.php and an existing user model that we can take advantage of.  For this app, we will simplify it a little bit. Creating the users database schema The author introduces a foreign key constraint.  And we will use a seeder function to add data to our new user table.  We are also introduced to the Hash::make helper.  Laravel expects all passwords to be hashed with this function.  You should not store passwords in clear text, and you should not hash them with some of the weaker algorithms (md5 or sha1). Authentication routes and views We make a few changes to our master view to accommodate users, allowing them to login and logout.  We pass in our username and password to the Auth::attempt...

Getting Started With Laravel 4, Chapter 3: Your First Application

Sketching out the application Our first app will be a browsable cat database.  We will leave authentication until next chapter. Entities, relationships and attributes The first thing to decide where we start a new application is our objects and their attributes. (i.e., our tables, columns and any relationships between them) The map of our application You should write out all the routes you need for your app.  You can then translate these into controllers.  Standard HTTP requests do not support the verbs, Laravel uses a method field on the the form to emulate these verbs. Starting the application In this section, we start building our new cats application.  Instructions are well written, and things just worked on my mac.  I did run into some issues, I was running Laravel 5, and a lot of things changed.  I would recommend getting a newer book, but this one was free, and the data is still good to learn Laravel. Using the builtin development server...

Getting Started With Laravel 4, Chapter 2: Composer All Over

Working with the command line This section goes over how to open a terminal window, and introduces the cd command.  It also gives the shortcut of typing cd in a terminal window, and then dragging the folder you want into the terminal window as a way of navigating to the correct folder. How does Composer work? Composer is a command line tool that uses a json file to download and install packages. Installation Unix (MacOS, Linux) This might have been the easiest tutorial I have ever found.  It just worked.  The biggest caveat is to make sure you have PHP installed and added to your Path variable. Windows These instructions seem easy to follow.  I don't have a Windows pc to test on, so I can't say for certain.  I think the hardest part, is making sure you have PHP installed. Creating a new Laravel application Creating a new Laravel project is easy.  Just use the command listed, and everything should work.  It worked just fine for me. F...

Getting Started With Laravel 4, Chapter 1: Meeting Laravel

The need for frameworks Out of the box PHP is easy to use, but it is prone to allow mistakes by beginners.  It doesn't lend itself to separation of concerns.  If you have ever worked on an old PHP project, you've probably spent more time screaming and yelling at the developer than you did writing code.  This is why frameworks are useful and needed. The limitations of homemade tools If you have done any significant projects in PHP.  You probably have amassed a pile of files and functions that you carry over from one project to the next.  This is another reason why we need frameworks.  Frameworks allow other developers to be able to jump in immediately and start helping write code. Laravel to the rescue This is where Laravel comes to the rescue.  It is an MVC (model-view-controller) paradigm. A new approach to developing PHP applications PHP is better than Ruby and Python for Web development.  Both of those languages have had ...

Mastering Docker, Chapter 6: Docker Machine

Installation Use the curl command to download and install Docker Machine. You will need to change the permission to execute Using Docker Machine We will learn how to use Docker Machine to deploy docker hosts on various machines. Local Machine Use create --drive switch to install a docker host on either Virtualbox or VmWareFusion. Cloud environment The author explains how to deploy Docker on AWS (Amazon Web Services). Docker Machine commands active: shows the current active Docker host config: shows the config of the active host env: shows the environment variables inspect: shows a lot of information on the current host ip: shows the ip address  kill: stops the machine ls: show all running hosts you have created with Docker Machine restart: restarts the machine rm: removes a machine scp: copies files from your local machine to a Docker host ssh: allows you to login to your Docker host start: starts a Docker host stop: stops a Docker host upgrad...

Mastering Docker, Chapter 5: Docker Security

Side note:  This is another chapter that either should have been only a couple of pages long, or really should have been split into multiple smaller chapters.  There is just not very much good information here.  The gist is download and run Docker Bench from github, and fix everything that says warning.  While I agree that this is not a book on server security, there could have been a lot more discussion on common problems and how to actually fix them. The not so bad Anyone who as access to the docker daemon can do whatever they want to you docker container.  Run them, modify them, delete them.  Practice good server security management What to look out for Docker containers can contain malicious code.  You should only use docker images from trusted sources. The Docker Commands We will focus on docker run and docker diff to what is happening inside our machine. docker run With the --read-only switch we can control where our container can ...

Mastering Docker, Chapter 4: Managing Containers

The Docker commands The author wants to spend the next section going over the command line tools that can be used to help troubleshoot containers.   docker attach Using this command will connect to the running machine's standard input (STDIN). docker diff Shows the changes made to a container.  Similar to git's diff command   docker exec Allows us to run commands against a container with connecting to it (via ssh). -i: runs the commands and shows us the output thereof -d: runs the command as a daemon, and doesn't show the output docker history The history command gives us a detailed list of all the commands that have been on a container.  docker inspect Shows the following information: When the container was created whether the container is using any volumes network settings established architecture used operating system running on the container docker logs Shows has been happening since the container was started.  The -f op...

Mastering Docker

Mastering Docker is really a terrible book.  I got through Chapter 6 and realized that this book has no real purpose.  I learned a little bit, but it was just enough so that I know where to start asking questions.  I feel like entire sections were nothing but filler pages.  I do not recommend purchasing this book.  If you want to pick up a copy, wait until it shows up as a Free Book of the Day on Packt's website .  There is a second edition of the book, but I don't have the time to read it right now.  Chapter 1: Docker Review Chapter 2: Up and Running Chapter 3: Container Image Storage Chapter 4: Managing Containers Chapter 5: Docker Security Chapter 6: Docker Machine Chapter 7: Docker Compose Chapter 8: Docker Swarm Chapter 9: Docker in Production Chapter 10: Shipyard Chapter 11: Panamax Chapter 12: Tutum Chapter 13: Advanced Docker  

Mastering Docker, Chapter 3: Container Image Storage

This entire chapter of the book seemed very much like filler.  The big takeaway is that if you can use a computer you can use Docker Hub to set up automated builds.  I would skip this chapter completely. Docker Hub This section is full of details that are subject to change.  Dashboard There are a couple of sections here about using the Docker Hub website.  I'm assuming if you are reading a book on using Docker, you probably know how to use a website.  So I'm not going to cover them.  This blog is mostly for making sure I get the key takeaways from books as I read them, and there was nothing helpful here. Automated Builds This section sounded great.  It ended up not being.  You can kick off automated builds from either github or bitbucket . Use the website, set up your account, pick your repo, push to it, and you get automated builds.  Setting up Docker Hub Putting all the pieces together Creating your own registry Maybe I am ...

Mastering Docker, Chapter 2: Up and Running

Dockerfile The goal of this section will be structure dcokerfile in most practical and efficient manner best practises allow us to read dockerfiles A short review of dockerfile from: image to be used maintainer: the person who maintains the file run: fetch and install packages and other commands add: add files or folders to your docker image expose: exposes ports to the outside world cmd: executes the command and keeps the container alive Reviewing dockerfile in depth Label : used to add information to the file Add or Copy : add will download a file from an url and unpack/untar it.  Copy will add files, but it   won't download from an url or unpack/untar it Entrypoint : is similar to the CMD instruction, but doesn't keep the command alive User : allows you to specify the user to run the command Workdir : sets the working directory Onbuild : lets you stash commands for when the image is used as a base image Dockerfile - Best Practices ...

Beginning Android Programming For Beginners -- Chapter 6

Image
The Life and Times of an Android App Introduction to the Android Lifecycle I've read several Android books in the past couple of years, and this is the first one that does a good job of explaining what the @override and the super.oncreate lines of code do. I don't think it matters that you understand, but I appreciate the author doesn't just let it all be "magic". A simplified explanation of the Android Lifecycle You can do a lot of things on a smartphone, and all of these things involve some part of the app life cycle.  The author goes through a real life scenario that you might actually do. Lifecycle phases - Whate we need to know There are 7 phases in the app lifecycle. Being Created Starting Running Pausing Stopping Being Destroyed Lifecycle Phases - What we need to do While there is a lot of information in the lifecycle phases, we don't necessarily have to implement them all.  There are various methods we will use when the lifecycle ...

Mastering Docker, Chapter 1: Docker Review

Understanding Docker Difference Between Docker and Typical Vm's Docker is a linux container (LXC) management system.  Like other virtualizion strategies, it allows you to create a self contained sandbox that just works on a server, since theoretically everthing else is the same.  Unlike virtual machines, Docker containers do not need an entire operating system to run.  This makes them smaller and easier to use ship. Dockerfile The Dockerfile contains all the instructions to be performed when an image is built Docker Networking/Linking Docker containers are linked together through bridged network adapters.  Communications are through these bridged adapters, so you don't have to expose ports for different containers to talk to each other.  This can be a safer method of using docker containers, than using vm's. Docker Installers/Installation There are four different environments you can install Dock in: Apple OSX Microsoft Windows Linux (all flavor...