Make Gadgets Work

A friend of mine today had an issue. He had created a template for some really complex calculations and to ensure he does not mess up with the forumlae by mistake he had password protected sheets and cells. He had done this back in 2012 and now he wanted change something in there but he had forgotten the password so he asked me if I can help. Now I do not know much about how it could be done on windows or on excel but I knew a small trick on LibreOffice so I asked him to send me that excel file by email. I then took following steps: Opened the excel file Locked.xls in LibreCalc. Saved it as an Locked.ods file. From file browser, right click on newly saved Locked.ods file -> Open With -> Archive Manager as shown below. Now open the content.xml Find table:protected="true" and Replace All with table:protected="false" Save the xml file. Now open the Locked.ods in LibreCalc and save it as Unlocked.xlsx This should do the trick and unlock all password protected sheets and cells to be freely modified.

Unprotect Sheets in Libre Calc, Excel

A friend of mine today had an issue. He had created a template for some really complex calculations and to ensure he does not mess up with the forumlae by mistake he had password protected sheets and cells. He had done this back in 2012 and now he wanted change
Right then, the Ghost V1.0 was out a while back and they made Ghost 0.11.x an LTS so I was not in any rush to upgrade too. I have not had much time to sort this out for a while and two days back when I finally came around to check how to upgrade, my first moment of concern was that officially supported stack is for NGINX. I have moved my blog to the Apache Stack on DigitalOcean and while on my sandbox environment I still have NGINX, that is not a place I want to host my blog from. Anyhoo, I realised soon enough that while not officially supported it s easy to bypass the restrictions so I went ahead. The upgrade itself couldn't have been simpler considering the major version bump. The answer to the question "Was it worth it?" is something we will have to wait and see although I am liking what I see except for the initial hiccups. EDITED AFTER THE POST Boy oh boy - just after I finished this post I saw the latest version of Ghost V1.12 is out and it was such a painless process compared to past. Just a simple command 'ghost update' and job done. That itself makes this whole pain kind of worth it. OK so the steps I took are as below: Backup Download and Install Setup Wizard Configure Apache Restore Tweak Backup We will take the back-up from front end for all the posts and we will also backup on the server the entire directory where old instance of the blog is residing. To take backup of all the content and download it in a json file, open your ghost site on a browser, navidate to "Settings" and then click on "Export". Next for the backup of folder on the server itself. To do this issue the following commands on the terminal. #Updateand upgrade the OS repo sudo apt-get update sudo apt-get upgrade #Stop the ghost server pm2 stop Ghost "assuming Ghost is the pm2 id for the site" # Change directory to web-server root cd /var/www/html/"path to your ghost directory say 'ghost' " # Create a new directory for backup sudo mkdir old_ghost_bkp sudo mv ghost old_ghost_bkp # Recreate the ghost directory sudo mkdir ghost cd ghost # Give right privileges to the new directory sudo chown -R <your username>:www-data . Download and Install As we are already in the right directory lets get on with installing the latest version of Ghost using npm. sudo npm install -g ghost-cli #Make sure you are in the directory where new ghost is to be installed. #If you have followed all commands so far, you will already be in #required the directory ghost install It is at this point that you will have to deviate from official guide if you have Apache instead of NGINX. You will be prompted by the installer that it could not find NGINX and do you still want to continue. Default is "No" so make sure you enter "Y" and then press enter. For me rest of the install went smoothly. Setup Wizard Immediately after the install is complete, you will be presented with following questions: Please note that if you have configured SSL using LetsEncrypt as explained in previous posts on this blog then even if you are using https, the answer to blog url must be the with http and not https. For example: I gave http://mgw.dumatics.com and not https://mgw.dumatics.com Enter your blog url: http://your.blog.url Enter your MySQL Hostname: localhost Enter your MySQL Username: root Enter your MySQL Password: "your mysql root password" Enter your Ghost database Name: "a relevant name - for security reasons you may want to keep it different from your blog name" Do you wish to set up Nginx: no Do you wish to set uo Ghost MySQL User: yes Do you wish to set up Systemd: yes Do you want to start Ghost: yes Please do note that the response on line 6 above to "Setup Nginx" must be "no" After the questions are complete you will get a notification You can access you blog at http://your.blog.url. At this point, it is best to see which port is configured by ghost CLI for this installation. you can do so by checking the configuration file like so: nano config.production.json You can change the port if you like but if it is different than the port you originally had for old version of ghost you can either change it here or you need to change Apache conf file in next step. If you do decide to change the port here, then there should be no need to carry out the next step - Configure Apache. Configure Apache Assuming that the port in Ghost config file was 1234, there will be some changes that you will need to make in Apache conf files like so: cd /etc/apache2/sites-available/ sudo nano ghost.conf Now change the port on ProxyPass and ProxyPassReverse to be same as what is in the config.production.json file and save it by pressing Ctrl+x and y.- so for this example it will be changed to 1234 and change will look as below: ProxyRequests off ProxyPass / http://localhost:1234/ ProxyPassReverse / http:/localhost:1234/ Now open the ssl config file for the site using commands below and make the same changes as above. sudo nano ghost-le-ssl.conf TIP: If done using LetsEncrypt, it will be named something like `ghost-le-ssl.conf`. Once the changes are saved, disable and enable the configurations using following commands: sudo a2dissite ghost.conf sudo a2dissite ghost-le-ssl.conf sudo a2ensite ghost.conf sudo a2ensite ghost-le-ssl #Restart the server sudo service apache2 restart Now if you enter you blog url in a browser, you should be presented with vanilla Ghost site. If not, something in server set-up has not worked and you will need to troubleshoot it and fix - luckily for me all worked like a charm. Restore Right, so you are now on the browser looking at the Vanilla Ghost install. First thing you need to do now is create the user with same credentials you had on your old version of ghost. To do this you will first need to enter the admin url for ghost and follow the steps to create your user. Once you are into the admin interface, navigate to "Settings" -> "Labs" and click on "Choose File" button, select the json backup that was exported from your old version of the blog and then click on "Import" button. Now to restore the images from your old blog on the server issue following commands: cd /var/www/html/ghost/content sudo rm images sudo cp /var/www/html/old_ghost_bkp/ghost/content/images /var/www/html/ghost/content/ ### Make the new image directory is writable or image uploads will fail sudo chown -R ghost:ghost images/ ### Restart Ghost cd .. ghost restart 1. The ghost CLI commands like stop, start and restart will require you to be in the directory where ghost is installed. 2. While start and stop commands of ghost specifically ask for sudo credentials, restart command just keeps rotating and hence it is better to issue a command with sudo before you issue `ghost restart`. This is it. Your old blog is now fully restored. Tweak This section is a bit of a pain because there are quite a few things that break with this version. So if you have heavily used html, you will painstakingly need to go through posts and add a new line between markdown and html content for it to be parsed properly or else it will display quite wiered outputs on your blog. If you have used code blocks with syntax highlighting, another change is with older version you would have given three backticks followed by language-sql but now you just need to give three backticks followed by sql. If you have used line numbering using prism.js, it just wont work and you will need to apply changes to your theme the way I did. Without going too much in detail on that, you can get the copy of prism.js, prism-custom-line-number.js, prism.css, prism-line-number.css using the github links for my theme and place them in assets directory of your theme. Then make sure you include them in relevant files where your theme calls the javascripts. Once done, issue the command ghost restart and things should look pretty again. Happy Migrating !!!

Ghost V1.0 Upgrade on Apache stack, related quirks and fixes

Right then, the Ghost V1.0 was out a while back and they made Ghost 0.11.x an LTS so I was not in any rush to upgrade too. I have not had much time to sort this out for a while and two days back when I finally
Install R using following commands: sudo apt-get install r-base libapparmor1 gdebi-core # Check that R is installed R #quit R q() Install Rstudio IDE server cd Downloads/ wget https://download2.rstudio.org/rstudio-server-1.0.136-amd64.deb sudo gdebi rstudio-server-1.0.136-amd64.deb At this point if all goes well you can check the status of rstudio server by issuing the command: sudo systemctl status rstudio-server.service The server is started automatically at port 8787 and can be accessed using <ip_address:8787> in browser of your choice, provided all firewall settings have been taken care of. However, when you open the Rstudio server you will be presented with a logon screen and while you can access this using the users for the machine it is hosted on, it will be prudent to create a lower privilege user as explained in next section. Add User to access the RStudio sudo adduser rstudio Set up SSL and reverse proxy for R-Studio Server Now important thing to note is that community version of Rstudio server does not come with SSL enabled but just to run it on a secure socket layer you don't necessarily need the pro version. By following the steps below, your communication with the server will be on SSL. However to achieve the objective we need to accomplish following steps: Enable modules on Apache to help set up proxy Configure a proxy to control access to RStudio Server Use LetsEncrypt to enable SSL Restrict access to Rstudio server only through proxy Restart both Rstudio and Apache servers Step 1: Enable modules on Apache to help set up proxy There is guidance on how to do this on Rstudio Support. However, there was a bit of hair pulling and head scratching involved to get all the steps above work together so stick with me but keep that link in back pocket for variations or when you are stuck. With head scratching and hair pulling I mean that I encountered errors such as these - AH01102 error reading status line from remote server, Rstudio Proxy redirect changing the URL to localhost and many others which can be avoided by following steps as explained below. Anyway so we need to enable mod_proxy and mod_proxy_wstunnel modules. As Apache is already installed and mod_proxy already enabled I did not have to install the module itself, but if it needs to be done the commands are: sudo apt-get install libapache2-mod-proxy-html sudo apt-get install libxml2-dev Issuing the following commands should enable the relevant modules: sudo a2enmod proxy sudo a2enmod proxy_http sudo a2enmod proxy_wstunnel Step 2: Configure a proxy to control access to RStudio Server # Change directory to sites-available cd /etc/apache2/sites-available # create a rstudio conf file sudo nano rstudio.conf Paste the following in the conf file but make sure to change details relevant to your set-up for each entry (line numbers 2, 3, 4, 15 and 16 below): <VirtualHost *:80> ServerAdmin user@yoursite.com ServerName yoursite.com ServerAlias whatever.yoursite.com #Specify path for Logs ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined RewriteEngine on #Rewrite the url supplied to ensure https is applied RewriteCond %{SERVER_NAME} =yoursite.com [OR] RewriteCond %{SERVER_NAME} =whatever.yoursite.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] # Following lines should open rstudio directly from the url RewriteCond %{HTTP:Upgrade} =websocket RewriteRule /(.*) ws://localhost:8787/$1 [P,L] RewriteCond %{HTTP:Upgrade} !=websocket RewriteRule /(.*) http://localhost:8787/$1 [P,L] ProxyPass / http://localhost:8787/ ProxyPassReverse / http://localhost:8787/ </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet Press Ctrl+x and save the file. TIP: If you just want reverse proxy and no SSL, you can just comment out line 15, 16 and 17 in above conf file and you are all set. If you do want to enable SSL, enabling the site with commands below won't probably work just yet and subsequent steps will need to be completed. Anything else Now enable the new site by issuing the commands: sudo a2ensite rstudio.conf sudo service apache2 restart Step 3: Use LetsEncrypt to enable SSL Follow the instructions here for specific usecase but one way or the other using Certbot you will be able to obtain the LetsEncrypt SSL certificate and enable it on your server. Once certbot has completed doing it's thing you would find an additional conf file in /etc/apache2/sites-available named rstudio-le-ssl.conf. It will be pretty much same content as in rstudio.conf with very minor changes. The first line will be listening on 443 instead of 80 and the ssl certificates will be included. Normally you would not need to tweak anything in the resultant file but just for reference the contenst of this file will look as below: <IfModule mod_ssl.c> <VirtualHost *:443> ServerAdmin user@yoursite.com ServerName yoursite.com ServerAlias whatever.yoursite.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined RewriteEngine on # Following lines should open rstudio directly from the url RewriteCond %{HTTP:Upgrade} =websocket RewriteRule /(.*) ws://localhost:8787/$1 [P,L] RewriteCond %{HTTP:Upgrade} !=websocket RewriteRule /(.*) http://localhost:8787/$1 [P,L] ProxyPass / http://localhost:8787/ ProxyPassReverse / http://localhost:8787/ SSLCertificateFile /etc/letsencrypt/live/whatever.yoursite.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/whatever.yoursite.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet </IfModule> Restrict access to Rstudio server only through proxy Finally, we want to ensure that access to the Rstudio server is only through the proxy we configured and to do that we just need to specify this in the rstudio server configuration the attribute that tells it to only serve requests from localhost. sudo nano /etc/rstudio/rserver.conf Now on the opened file type www-address=127.0.0.1 and press Ctrl+x and save the file. Restart both Rstudio and Apache servers Finally issue the following commands to restart both the servers: sudo systemctl restart rstudio-server.service sudo service apache2 restart This is it. Now your new Rstudio server is ready to be used through secure socket layer.

Rstudio Server Setup with SSL behind Apache proxy server

Install R using following commands: sudo apt-get install r-base libapparmor1 gdebi-core # Check that R is installed R #quit R q() Install Rstudio IDE server cd Downloads/ wget https://download2.rstudio.org/rstudio-server-1.0.136-amd64.deb sudo gdebi rstudio-server-1.0.136-amd64.deb At this point if all goes well you can
For a fairly long time, I have been looking for a simple markdown type of solution to be able to quickly draw Gantt charts but never came across what one would call a quick option. It has always been an involved process. To my simplistic mind, a simple solution would just be an option where I can type the action, a start date and an end date for the action line after line and it get's displayed in the Gantt chart. The latest edition of Linux Format (Issue 221, Page 52) had mermaid as one of the hotpicks and highlighted the availability of Gantt charts which piqued my interest, I tried the solution and it is indeed what I was looking for. There are a few rough edges but it is a working solution and in normal circumstances will save considerable time and hence will become my tool of choice. There are few ways of using it and because it has been made to work with MarkDown syntax, it can work on a number of tools too. I found CuteMarkEd to be the easiest one to use but the various ways to use it are listed below and their usage explained in following sections: CuteMarkEd Install Mermaid CLI Install Markdown Plus Mermaid Live Editor Install CuteMarkEd CuteMarkEd is not available in debian repositories nor does it have a binary for debian. Although it does have an rpm binary. As I have been playing with Debian / Ubuntu based Elementary OS lately, instead of my regular Fedora install, I figured might as well compile from source code. Steps are as below and are also available on the github page for CuteMarkEd: #Prepare the environment for building from source code. sudo apt-get install build-essential checkinstall git #Get the code from github git clone --recursive https://github.com/cloose/CuteMarkEd.git #Install dependencies for CuteMarkEd sudo apt-get install libqt5webkit5-dev qttools5-dev-tools qt5-default discount libmarkdown2-dev libhunspell-dev #Compile and install CuteMarkEd qmake CuteMarkEd.pro cd CuteMarkEd/ qmake CuteMarkEd.pro make echo "A Qt-based Markdown editor with live HTML preview and syntax highlighting of markdown document." > description-pak sudo checkinstall --requires "libqt5webkit5, libmarkdown2, libhunspell-1.3-0, discount" sudo ln -s /usr/lib/x86_64-linux-gnu/qt5/bin/cutemarked /usr/local/bin/ sudo mkdir -p /usr/local/share/icons sudo cp app/icons/scalable/cutemarked.svg /usr/local/share/icons/cutemarked.svg sudo apt-get install fcitx-libs-qt5 Now there is a bug in the tool which makes the Gantt charts appear as monochrome but fear not for there is a workaround for it.Once installed, open CuteMarkEd and add a snippet in the tool to ensure Gantt charts display properly. Steps below: Enable diagram support by clicking Extras->Options->Diagram Support Add the snippet for quick creation by clicking Extras->Options->Snippets->Add Then type \~\~\~gantt and in description something to the effect of Adds the codeblock for mermaid with the necessary javascript Now in the snippet box add the following code. To invoke the snippet simply type in editor \~\~\~gantt followed by pressing the Ctrl+Space keys. \~\~\~mermaid gantt dateFormat YYYY-MM-DD title <Name of the project> %% <Name of Activity> : crit if critical else empty,done, active or empty, reference name or empty, Start Date or dependency, End Date or Duration section Phase 1 Name Activity 1 : done, des1, 2017-01-06, 2017-01-08 Activity 2 : active, des2, 2017-01-09, 2017-01-12 Activity 3 : des3, 2017-01-12, 5d Activity 4 : des4, after des3, 5d section Phase 2 Name Activity 5 : crit, done, 2017-01-06, 24h Activity 6 : crit, done, after des1, 2d Activity 7 : crit, active, 3d Activity 8 : crit, 5d Activity 9 : 2d Activity 10 : 1d section Phase 3 Name Activity 11 : active, a1, after des1, 3d Activity 12 : after a1 , 20h Activity 13 : doc1, after a1 , 48h section Phase 4 Name Activity 12 : after doc1, 3d Activity 15 : 20h Activity 16 : 48h ~~~ <script> mermaid.ganttConfig = { titleTopMargin:25, barHeight:20, barGap:4, topPadding:50, sidePadding:100, gridLineStartPadding:35, fontSize:11, numberSectionStyles:3, axisFormatter: [ // Within a day ["%I:%M", function (d) { return d.getHours(); }], // Monday a week ["w. %U", function (d) { return d.getDay() == 1; }], // Day within a week (not monday) ["%a %d", function (d) { return d.getDay() && d.getDate() != 1; }], // within a month ["%b %d", function (d) { return d.getDate() != 1; }], // Month ["%m-%y", function (d) { return d.getMonth(); }] ] }; </script> This will then show in the preview pane following Gantt Chart and we can edit, add and modify the data as per the requirements: TIP: You can make as many snippets as you want and for the simple solution that I mentioned right at the top, I made one snippet called dategantt replacing the code between line 3 to line 29 of the snippet above dateFormat DD/MM/YY title Project Name Section Pre-condition Activity 1 :21/12/16, 22/12/16 Activity 2 :21/12/16, 22/12/16 Activity 3 :16/01/17, 02/02/17 Activity 4 :01/02/17, 02/02/17 Section Kick-off Activity 5 :01/02/17, 03/02/17 Activity 6 :01/02/17, 03/02/17 Project Initiated :01/02/17, 03/02/17 Section Tech Design Technical Design :crit, active, T1, 06/02/17, 21/03/17 Section Delivery Activity 7 :06/02/17, 10/02/17 Activity 8 :10/02/17, 14/02/17 Order :15/02/17, 14/03/17 Deployment :crit, 15/03/17, 21/03/17 Activity 9 :crit,T2, after T1, 23/03/17 Project Close-Down :after T2, 24/03/17 Once done, just type dategantt followed by ctrl+space and you will have the framework to enter activities, start dates and end dates. Gantt Chart will be ready just like the one as cover image of this post right at the top !!! Install Mermaid CLI One of the drawbacks of the CuteMarkEd is that the pdf export there just does not work and you will need to rely on a screenshot. Now if the Gantt chart is really huge a screen shot wont cut it and mermaid does offer the ability to generate svg file for your effort. It is ofcourse a command line tool but is actually fairly easy to use once installed. #check if nodejs is installed. If command below results in nothing then you need to install nodejs nodejs -v # Instal nodejs sudo apt install nodejs #On Ubuntu there is some link issue where node is #referenced as nodejs which results in issues #while installing npm modules. This can be avoided #by creating a symlink using following command. sudo ln -s /usr/bin/nodejs /usr/bin/node #Install npm sudo apt install npm #In order to install npm modules without sudo, #As explained in one of [my previous posts](http://mgw.dumatics.com/ghost-on-fedora-24/#step3installnpmmodules), #it requires fixing the permissions using following steps. #This needs to be done only once so if you have #done this in past, then there is no need to repeat. mkdir ~/.npm-global npm config set prefix '~/.npm-global' nano ~/.profile source ~/.profile #Install Mermaid and phantomjs on which mermaid depends. npm install -g phantomjs npm install -g mermaid #Check if mermaid is installed by issuing the command mermaid --h #Generate a png using following command mermaid -p path/to/markdown file with .md or .mmd extension. Install Markdown-plus MarkdownPlus is a good markdown editor and can be used on their hosted solution or for offline use it can be installed as a local copy and accessed from the browser by pointing the browser to the index.html. The bug from CuteMarkEd is not present here. To access offline, you can clone it from github using following command. git clone --recursive https://github.com/tylingsoft/markdown-plus.git Then open the folder markdown-plus and right click on the index.html file and open it using your browser of choice. Alternatively, in the browser enter file:///home/path/to/markdown-plus//index.html. Mermaid Live Editor While Markdown Plus is quite a versatile browser based editor, I did not like the fact that there is no easy way to save the file you have created and all I could work out was that you will have to copy paste your text and save it using another text editor. I felt, for this reason that the Mermaid Live editor was better compared to this option and the live editor is quite basic to be honest and can't be used offline.

Markdown and Gantt Charts

For a fairly long time, I have been looking for a simple markdown type of solution to be able to quickly draw Gantt charts but never came across what one would call a quick option. It has always been an involved process. To my simplistic mind, a simple solution would
Apply Unlocked stock firmware download all the three files from... Follow these steps: 1. Connect the power supply to the TP-Link router and switch it on. 2. Connect the ethernet cable in one of the yellow LAN slots of the router. ...

DD-WRT firmware on TP-LINK TL-WR841N v11

Apply Unlocked stock firmware download all the three files from... Follow these steps: 1. Connect the power supply to the TP-Link router and switch it on. 2. Connect the ethernet cable in one of the yellow LAN slots of the router. ...