Sublime Text 3

Legacy

So I managed to fuck up my Sublime Text 3 install, and this is the reinstall. I haven’t installed Sublime since 2014, so as I go on this journey, I will post my findings here, hopefully making it possible for me to actually remember what was what the next time I need to install Sublime…

Obviously start with the key that is saved in Google Keep. Thinking about it, save this to KeePass as well.

Going for the portable version, might make backup easier…

First off, to even get any packages installed, get Package Control. This will let you install more packages easily from within Sublime.
https://packagecontrol.io/installation

Settings, will update as I find them…

 

Alignment
If you have OCDC like me…
https://packagecontrol.io/packages/AlignTab
https://packagecontrol.io/packages/Alignment

Bracket​Highlighter
Basically easily see where a tag starts and stops.
https://packagecontrol.io/packages/BracketHighlighter

ApacheConf.tmLanguage
For .htaccess and .conf files, but mostly for .htaccess.
https://packagecontrol.io/packages/ApacheConf.tmLanguage

Side​Bar​Enhancements
Not really sure why I’m installing this, I rarely ever use the sidebar…
https://packagecontrol.io/packages/SideBarEnhancements

Autoprefixer
Might need this for when CSS doesn’t work in some browsers.
https://packagecontrol.io/packages/Autoprefixer

Themes and Stuff
https://packagecontrol.io/packages/Colorsublime
https://packagecontrol.io/packages/Themes%20Menu%20Switcher
https://packagecontrol.io/packages/Base16%20Color%20Schemes
https://packagecontrol.io/packages/Boxy%20Theme

BufferScroll
Scroll back to wherever you were in a file when you reopen it!
https://packagecontrol.io/packages/BufferScroll

Open URL
Quickly open any URL in a file.
https://packagecontrol.io/packages/Open%20URL

All Autocomplete
Autocomplete anything from any file open.
https://packagecontrol.io/packages/All%20Autocomplete

INI
Syntax Highlighting for INI files.
https://packagecontrol.io/packages/INI

Various for Easier Coding…
https://packagecontrol.io/packages/jQuery
https://packagecontrol.io/packages/DocBlockr
https://packagecontrol.io/packages/SublimeLinter

Backup to Google Drive

Legacy

This will be my attempt at documenting what I did when configuring automatic backup of websites and databases to Google Drive. Note that this is in past tense, ergo I have already completed this project and will now try to backtrack what I actually did…

First of all, this requires a shell account where your website is hosted.

I started with how to upload to Google Drive. Previously Lemon had setup this for me on the old VPS-installation, but since I believe the only way to learn is to do it yourself (or fuck it up yourself), I’ve since reinstalled the VPS. I did use some of his code, which is something I could have written myself, but I’m lazy so I copy+pasted. Anyway, I have no idea what he used to connect to Google Drive, so I started fresh.

https://github.com/prasmussen/gdrive
After 100+ tabs in Chrome I decided upon gdrive. It offers way too much more than I need, but seeing as it’s coded by a fellow Norwegian, I’m guessing it reeks of quality… Either way, it was the simpler choice.

I used wget to copy the file (which is hosted at Google Docs for some reason). Now, this is not my forte, but eventually I realized that for it to work as I had planned, I had to copy it to /usr/local/bin, though looking back this might not have been the case. Either way. That’s where it is now. Also, when I downloaded the file via wget, it got a terrible name, so I renamed it to gdrive. Though, I did this via WinSCP… Running gdrive the first time you have to enter “gdrive about”, this will prompt you with a link you need to open, which is where you select which Google Account to authorize access to. In return you get a key which you paste into gdrive (specifically asks for it). Voila, you now have ultimate unlimited power…

Now for the fun part… gdrive made no sense at all to me, making it impossible for me to use folders I had made in Google Drive. gdrive uses IDs. Which makes sense since Google Drive allows you to have the same name for files and folders in the same folder. So I made a folder. And then I made a folder inside that folder. Because I need structure. When you make a folder or upload a file (or anything) gdrive gives it an ID. If you want to meddle with any files or folders, you need to use that ID. And now, I have an ID for the sub-folder where I intend to store my backup.

The code below is a shell script (based on Lemon’s script). Basically we start with pre-defining domain-name, database-name, folder-location and ID of the previously created folder in Google Drive. It also sets time and date so that backup-files have the necessary information of when the backup is from. First off we dump the database. I created a user called dump, this way I can configure his privileges (grants) in hopes of added security. I’ve also created a file to store the password in, so that I don’t have to keep the password in neither shell script nor crontab. No idea if this secure, but according to some of the 100+ tabs I had open, this was the right way to do it.

Moving on after the dump, we tar the files in the folder together with the database-dump. Having been born unto Windows, tar is new for me, but it’s just zip for Linux… The tar is named after the domain we are backing up and the time it was backed up. If you ever need to restore to a certain time, this is highly valuable information. After that we run gdrive with a simple upload to specific folder and delete after upload. I prefer to delete it after upload. I’ll be taking a backup at least once per week, and the more sites you have, the higher the gigabytes rack up. Also, if the VPS is hacked, explodes or whatnot, that is not where I need a backup. Keeping a backup in the same location as where the original files are is not a backup. It’s just duplicates and waste of space. I also delete the database-dump. Since this specific file is not uploaded directly by gdrive (it is inside the tar), gdrive is not deleting it.

Now I have the script that backups website files and database, names, tars, uploads and deletes. Tested and tried, it works as intended. So here I venture into crontab so that I can schedule this update. Logging in and running the script manually is stupid… For some reason crontab always opens in whatever the fuck it is, so I tend to start off with code below to get it in nano. I prefer nano, but to each their own. And then just enter the line below. Crontab will then run the script every 3rd day of the week (Wednesday) at 01:00. When adding more sites I will delay each script with 5-10 minutes to make sure it does not conflict with each other.

Advanced Automatic Updates

Legacy

https://wordpress.org/plugins/automatic-updater/

Advanced Automatic Updates adds extra options to WordPress’ built-in Automatic Updates feature. On top of security updates, it also supports installing major releases, plugins, themes, or even regular SVN checkouts!

While this will be useful for the vast majority of sites, please exercise caution, particularly if you have any custom themes or plugins running on your site.

Getting hacked cause I forgot to update WordPress, themes, and or plugins, is simply idiotic. Now it may happen from time to time that a WordPress site gets hacked and keeping it updated wouldn’t have made a difference, but for that one time where it could have prevented getting hacked, it’s rather stupid that the only reason it happened was because you forgot to log in and run an update. If you have many sites to manage like me, you may forget about some sites, you may not have time, or the hack happens just as the vulnerability is fixed and made public…

This is where Advanced Automatic Updates comes in. Why bother with updating websites manually when they can do it automatically? Now, something really important to note here is that this plugin only updates. Your site may break due to changes in plugins, themes or WordPress. The question is, would you rather have downtime due to an update you can reverse, or due to a hack? If you have made custom core changes to your theme, a theme that is available via the WordPress repository (this also goes for plugins), they will of course be overwritten as the updated version is downloaded and installed.

If you make changes to core files in themes or plugins, a simple way to avoid having them erased by an automatic update is to change the version number in the main PHP-file(plugin) or CSS-file(theme). Very often version numbers are pretty low, so if you set it to 1337 or something very, very high, it is unlikely that the plugin will be updated and your changes overwritten. You can also solve this problem via plugins that “lock” other plugins from getting updated, deleted, deactivated and so and so forth. But more on that plugin later.

As you see in the picture, you can via the settings page set whether you wish to update major/minor version of WordPress, plugins, and or themes. You can also setup so that you get an email for each update that has occurred. This really helps if the site breaks. Getting an email about an update, you might be inclined to check the site and see that everything still works. Or disable email notifications completely. Really depends on the site you are running.

Change name of menu item in Theme Options Framework

Legacy

 

Display Google Captcha on key input

Legacy

High contrast (WCAG)

Legacy

 

Remove unnecessary body classes generated by WordPress

Legacy

 

Get parent page ID in WordPress

Legacy