If you don’t know about homestead, its a vagrant box that automatically configures a great development environment for laravel. http://laravel.com/docs/homestead
The box should always be suspended before shutting down your machine to prevent loss of data. This is not always possible and you may lose data. This may include data stored in database, new applications installed, custom configurations etc.
You will likely notice the loss of data when you try to run
on your box.
The steps detailed below are for Ubuntu 14.04, Virtualization provided by Oracle’s Virtual Box
Open terminal and run
VBoxManage list vms
This will give you a list of existing instances. That look something like this
It is very likely one of them is the box you lost. In my case it was the second last one.
Take note of the id (The value in the brackets)
Navigate to the base of your homestead box, ie that is where you normally start your box from.
From there you need to edit the id file ie
Replace the value in the id file with a value of one of the previous instances and save.
This steps helped me recover a lost instance.
All the best 🙂
If you have been programming for more than 2 secs. You are probably already familiar with loops.
In PHP (which is the language we will be talking about in this post) there are three common methods to run a loop.
Even seasoned programmers make generous use of this constructs. While they still have their use, I am here to tell you that their more functional equivalents
are far much better.
To demonstrate this point here is a gist showing a snapshot of a short demo. The full demo can be found here https://github.com/prodeveloper/array_compares This code capitalizes first name of each string.
Here is a the snapshot
Just from the code above you see the following benefits:
- Functional constructs are are far more concise: From our example above there we’re 2 more lines in the loop constructs than in functional ones. This may seem trivial but a typically project has thousands of lines of code. You do the math.
- Functional construct enforces single logic for a function: It may not seem like it at first glance but loop constructs are in fact executing two pieces of logic in that one function. The first one to loop through an array the second to actually deliver the payload to the string.
- Less variables in functional constructs: You note we needed to create a variable to hold the value that the pointer is currently pointing to. Its usually best to reduce variables where it makes sense. If nothing else to save ourselves the hustle of coming up with names
- Readability is compromised in loop constructs: To understand what is happening we must understand both the function being called and how the looping works. Case in point did you notice the name variable was passed by reference?
Well I am sure there are far more benefits to the functionals. If you have something to add, would love to hear from you.