#incrementalbackup
Explore tagged Tumblr posts
Text
List of Lists Processing with Haskell

Input: lastBackupTime = 461620205
changes = [[461620203, 1], [461620204, 2], [461620205, 6], [461620206, 5], [461620207, 3], [461620207, 5], [461620208, 1]]
Introduction
Haskell is a pure functional programming language with a lot of great features, one of them is the simplicity that offers for handling with list manipulation.
In this example, found at code signal, given a lastBackupTime timestamp and a list of process ( each process is a list where index 0 is the timestamp of the last change to the file, and index 0 is the file id ). The program has to return a list of unique file ids for those who last modification occurs after the lastBackupTime.
Solution
import Data.List
import Data.Ord
incrementalBackups lastBackupTime changes = sort $ nub $ map ( !! 1 ) $ filter (\xs -> xs !! 0 > lastBackupTime) changes
Explanation
This problem can be divided into 4 small problems. First we need to filter those files where lastModification happen after the backup timestime.
Luckly Haskell has exaclty a filter function:
filter :: (a -> Bool) -> [a] -> [a]
The filter signature applies a comparison function to a list and for those elements where the comparison is true are part of the result.
filter (\xs -> xs !! 0 > lastBackupTime) changes
For our problem whe use a lambda function that takes the index 0, timestamp, for each element on the changes list and compares it to the lastBackupTime value.
Our next task is to select only the file 1, this can be done with the map function
map :: ( a -> a ) [a]
map applies a function to each element of a list and return a list of the same size where each element is a transformation of the element after aplying the function.
In Haskell to access elements on a list at specific index whe can use the ( list !! index) operator.
map ( !! 1 ) $ filter (\xs -> xs !! 0 > lastBackupTime) changes
f $ g is equivalent to f ( g ())
Good to notice here is the $ operator what this does is explicit indicates to the Haskell compiler than whe apply the map function after we apply the filter to our changes list.
After applying the map function we need to select only unique file ids,
The Data.List module has a nub function that does this.
After removing duplicates the last thing to do is to sort the file ids.
For this we can use the sort function available at the Data.Ord module.
With only 4 function we were able to solve this code challenge . If you are interested in learn more details about Haskell you can refer to this link.
0 notes
Text
WHY WORDPRESS STAGING IS ESSENTIAL?
WordPress staging site can be viewed as an independent clone of your original website. You can do modification to your staging site and then load changes to your original website later. A staging site is the exact replica of your live site. It helps you to make your live site risk free.
What is the need of staging?
o To examine your site- This is the most important feature of staging sites. There are lots of tasks to be performed while creating a website. Several plugins are used. You also have to specify theme for your website. WP staging allows you to make all the changes you need, in a clone site and test how it will look before publishing them.
o Make changes- You can edit, update and even manipulate it as per your need. You can also test whether your site is functioning properly or not.
o Preview your site- You need to first preview your website before publishing it. This is the reason why you need WordPress staging. Without staging, you might have a risk of crashing the live website.
· How to push staging site to your original production site?
When you have made all the desired changes on the staging site and now you want to push those changes to your live site, you can do this very easily. Just click on push to production (available in the staging drop-down menu) and your staging site will go live. You need to test the staging site vigilantly. If the testing is not done carefully, your production site may not work properly after updating.
· Troubleshooting the staging environment
After installing the staging plugin, there are a sequence of settings that you should configure before proceeding:-
o Make sure your domain is correct: View URL of your admin screen. If it is the sub-domain of your website, the new configuration will be displayed.
o Ensure that the media is successfully placed: Your media should be in a proper place. If it is not placed properly, you have to check whether the ‘uploads’ directory is in the correct place or not.
o Sitemaps option should be disabled: You have to disable xml sitemaps, so that the search engine doesn’t index your staging site.
o Restricted site access: You need to install ‘Restricted site Access’ plugin and update it. By doing this, you can restrict users from visiting your staging site.
o Make sure to update permalinks: ‘Permalink’ is the permanent web address by which your contents are linked. It should never be changed. You have to keep the ‘permalinks’ updated, otherwise errors would generate. You can do this by Settings-> Permalinks.
CONCLUSION
The thought of creating a WordPress staging site for your live site can be very exhausting. But, it would be beneficial for you only. You can update all the changes on your testing site and also preview it offline before publishing the site. So, you should always create a staging site so that you can test the site before pushing the changes on your original live website.
0 notes