Sunday, December 4, 2016

Blogger: Host "SyntaxHighlighter" on GitHub-Pages

Objective


I would like to host my "SyntaxHighlighter" on Github-Pages to make it easy to format my source-code on my blog on Blogger. This is needed, because the original hosting service of Google-Drive is not working anymore..

Motivation


In a comment, a reader of my blog made me aware, that the syntax highlighting for source-code stopped working a while ago. So I investigated into the issue and found out that unfortunately Google stopped web-hosting of pages via Google-Drive.

Google deprecated web-hosting support in Google-Drive as of 31. August 2015 (Reference: https://gsuiteupdates.googleblog.com/2015/08/deprecating-web-hosting-support-in.html).
However, the web-hosting via Google-Drive stopped working only a year later as of 31. August 2016.

I did neither want to move on to Google Domains nor to the Google Cloud Platform,because both services are not free, so I decided to give Github-Pages a try.

Prerequisites



Setup your Hosting of SyntaxHighlighter on Github-Pages


Prepare your local repository


Follow the instructions in to get the sources for SyntaxHighlighter.

Create a directory for your new repository named e.g. syntaxhighlighter-pages/docs:
$> mkdir -p syntaxhighlighter-pages/docs
$> cd syntaxhighlighter-pages
$> git init

Initialized empty Git repository in /home/cschmidt/syntaxhighlighter-pages/.git/

Assuming your SyntaxHighlighter files are at the some location as your syntaxhighlighter-pages folder, copy all the source files your need to be hosted into your docs folder:

$> cd docs
$> cp -r ../../syntaxhighlighter_3.0.83/scripts .
$> cp -r ../../syntaxhighlighter_3.0.83/styles .
$> git add *
$> git commit -m "hosted syntaxhighlighter files"

[master (root-commit) 3556ca1] hosted syntaxhighlighter files
45 files changed, 5483 insertions(+)
create mode 100644 docs/scripts/shAutoloader.js
create mode 100644 docs/scripts/shBrushAS3.js
create mode 100644 docs/scripts/shBrushAppleScript.js
create mode 100644 docs/scripts/shBrushBash.js
...
create mode 100644 docs/styles/shThemeEmacs.css
create mode 100644 docs/styles/shThemeFadeToGrey.css
create mode 100755 docs/styles/shThemeMDUltra.css
create mode 100644 docs/styles/shThemeMidnight.css
create mode 100644 docs/styles/shThemeRDark.css

Finally push your local repository to your github:

$> cd ..
$> git remote add origin https://github.com/cwschmidt/syntaxhighlighter-pages.git
$> git push -u origin master

Counting objects: 50, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (50/50), 47.03 KiB | 0 bytes/s, done.
Total 50 (delta 24), reused 0 (delta 0)
remote: Resolving deltas: 100% (24/24), done.
To https://github.com/cwschmidt/syntaxhighlighter-pages_.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.


Prepare your github repository


Now log into your github account and create a new repository named "syntaxhighlighter-pages". Herefore click on the "+" on the upper-right corner of the Github webpage.



Fill in the name of the repository and make it "public" as shown below (didn't test, whether publiching pages also works with "private" ones):



Select the actual created repository and go to the settings tab shown below.
Scroll down until you reach the section "Github Pages". From the combo-box where "None" is selected right now, select "master branch /docs folder".



Click "Save" and after some seconds, your pages are successfully published:




Prepare your template to support code formatting


Go to your Blogger's blog online editor and choose "Template" from the menu at the left.




Click on "Edit HTML".

Within the code search for the closing head-tag

</b:template-skin>
    <b:include data='blog' name='google-analytics'/>
  </head>

  <body expr:class='&quot;loading&quot; + data:blog.mobileClass'>
  <b:section class='navbar' id='navbar' maxwidgets='1' name='Navbar' showaddelement='no'>

And copy the following code (only the links to the files you prepared for hosting) right before the end head-tag

<!-- Begin SyntaxHighlighter-->
    <link href='https://<username>.github.io/syntaxhighlighter-pages/styles/shCore.css' rel='stylesheet' type='text/css'/> 
    <link href='https://<username>.github.io/syntaxhighlighter-pages/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shCore.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCpp.js' type='text/javascript'/> 
    <!--script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCpp.js' type='text/javascript'/--> 
    <!--script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCSharp.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCss.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/shBrushJava.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushJScript.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushPhp.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushPython.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushRuby.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushSql.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushVb.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushXml.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushPerl.js' type='text/javascript'/--> 
    <script type='text/javascript'>
    window.setTimeout(function() {
        SyntaxHighlighter.config.bloggerMode = true;
        SyntaxHighlighter.all();
    }, 20);
    </script>
<!-- End SyntaxHighlighter-->
</head>

Exchange the "<username>" within the URL with your own username on Github.


Test it


For Testing go back to my blog post Blogger: Setup "SyntaxHighlighter" for your blog - Test it

References:

  1. http://alexgorbatchev.com/SyntaxHighlighter/
  2. Github-Pages
  3. Blogger: Setup "SyntaxHighlighter" for your blog

Friday, August 12, 2016

MacOS X: Problem with accessing SMB-Shares on your Synology with "El Capitan"

Objective


I wanted to access my smb shares on my Synology from my MacBook Air that I recently updated to "El Capitan".

Motivation


As I my Synology DS209+II as my central data store where I never had problem so share files via the smb protocol with my MacBook Air as a client, I recently recognized that I can't establish a connection to the shares on my Synology after updating my MacBook Air to "El Capitan".


Prerequisites


  • DS209+II
  • MacBook Air (or any other Mac) with "El Capitan"

Solution


Explanation


Apparently Apple change it's security policy regarding smb-shares in "El Capitan". Those changes can lead to significant speed reduction with smb connection and even prevent you to mount a share at all. Ususally a login via the Finder menu "Go to server" is not successful whereas in the previous version of MacOS X "Mavericks" there where no problem and nothing has changed meanwhile on the server.

Solution


You can quickly fix the problem without downgrading to MacOS 10.11.4.

Open a Terminal an execute the following command:

sudo sh -c 'echo "[default]\nsigning_required=no" > /etc/nsmb.conf'

Now, restart your MacBook and you should be able to mount a shared drive from you Synology as ususal.

References:

  1. http://www.heise.de/mac-and-i/meldung/OS-X-10-11-5-Abhilfe-fuer-SMB-Probleme-3222725.html (German)

Sunday, April 17, 2016

Manage your local scripts via git on a shared directory of your NAS

Objective


I want to store all my scripts in a central place on my Synology NAS. I want to be able to easily add or alter any script on any computer within may local network. I want to be able to synchronize all my computer to have always the most recent version of any of my scripts installed. I don't want to use a public repository like GitHub or BitBucket for privacy reasons.

Motivation


At the moment, I use several computers to develop software. Those include a MacBookAir, a Linux workstation with several Virtual-Machines on it and a Laptop. On all those machines, virtual or physical I have a separate homeaccount with a bin folder where my scripts for daily work are located. I have a Synology NAS in my network where I backup all those scripts manually in a so called reference folder. I also synchronize my scripts manually, which is time consuming and kind a painful, because sometimes I even don't remember which of my local machines has the most recent version of a script stored at a certain point of time.

Prerequisites


  • Linux Mint 17.3 Rose
  • Synology DS209+II
  • git v1.9.1
  • nfs-shared directory on NAS

Solution


Create a new bare git repository


On my client machine (laptop with Linux Mint) I changed to the mounted directory (automount) from my NAS wher I want to create the bare git repository:

$> cd /mnt/DiskStation/data/home/cschmidt/

At the moment I have my reference directory containing all my scripts already in the bin folder there.

$> ls -la

drwxr-xr-x 3 cschmidt users 4096 Apr 16 22:54 .
drwxr-xr-x 3 cschmidt users 4096 Apr 16 22:54 ..
drwxrwxrwx 2 cschmidt users 4096 Apr 16 22:54 bin

Now I create the bare git repository named bin.git

$> git init --bare bin.git

Initialized empty Git repository in /mnt/DiskStation/data/home/cschmidt/bin.git/

Create a non-bare git repository in the folder where the reference scripts are actually stored.


Now I change back to the folder where my scripts are currently stored

$> cd bin
$> ls -la

drwxrwxrwx 2 cschmidt users 4096 Apr 16 22:54 .
drwxr-xr-x 4 cschmidt users 4096 Apr 17 2016 ..
-rwxrwxrwx 1 cschmidt users 82 Jul 20 2008 listfoldersize.sh
-rwxr-xr-x 1 cschmidt users 2193 Apr 16 18:20 mkscript.sh
-rwxr--r-- 1 cschmidt users 886 Sep 5 2015 renfiles.rb
-rwxrwxrwx 1 cschmidt users 671 Dez 3 2009 synapticsOnOff.sh
-rwxr--r-- 1 cschmidt users 1626 Jul 12 2015 wav2mp3.sh

Here I create a non-bare repository

$> git init

Initialized empty Git repository in /mnt/DiskStation/data/home/cschmidt/bin/.git/

Now I add all the scripts I already have, to the working copy and commit them all.

$> git add .
$> git status

On branch master

Initial commit

Changes to be committed:
(use "git rm --cached ..." to unstage)

new file: listfoldersize.sh
new file: mkscript.sh
new file: renfiles.rb
new file: synapticsOnOff.sh
new file: wav2mp3.sh

$> git commit -m "initial bunch of scripts"

[master (root-commit) 17879d2] initial bunch of scripts
5 files changed, 805 insertions(+)
create mode 100755 listfoldersize.sh
create mode 100755 mkscript.sh
create mode 100755 renfiles.rb
create mode 100755 synapticsOnOff.sh
create mode 100755 wav2mp3.sh

Push the commited scripts into the bare repository


So, now I tried to push the committed scripts into my bare host repository

$> git push

fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

git remote add

and then push using the remote name

git push

Ok, I admit ... I forgot to add the remote repository to push into, so do so now

$> git remote add origin /mnt/DiskStation/data/home/cschmidt/bin.git

and again

$> git push

oops ...


fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master

Ok, I see I could name the repository every time I want to push something into or I'll add it as a upstream.
Let's do the latter ...

$> git push --set-upstream origin master

Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 32.23 KiB | 0 bytes/s, done.
Total 7 (delta 2), reused 0 (delta 0)
To /mnt/DiskStation/data/home/cschmidt/bin.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.

Synchronize your script repository with your client


So, I want to have my recently commited scripts synchronized to my client

I go to my home account on my laptop and clone the remote repository into my bin.
(If you have already a bin folder in your home account, delete it first.)

$> cd ~
$> git clone /mnt/DiskStation/data/home/cschmidt/bin.git bin

Cloning into 'bin'...
done.

$> cd bin
$> ls -la

drwxrwxrwx 2 cschmidt users 4096 Apr 16 22:54 .
drwxr-xr-x 4 cschmidt users 4096 Apr 17 2016 ..
-rwxrwxrwx 1 cschmidt users 82 Jul 20 2008 listfoldersize.sh
-rwxr-xr-x 1 cschmidt users 2193 Apr 16 18:20 mkscript.sh
-rwxr--r-- 1 cschmidt users 886 Sep 5 2015 renfiles.rb
-rwxrwxrwx 1 cschmidt users 671 Dez 3 2009 synapticsOnOff.sh
-rwxr--r-- 1 cschmidt users 1626 Jul 12 2015 wav2mp3.sh

Yeah, everything worked fine!