Generating directory structure ASCII art on Windows

Don’t feel left out Windows users, you have a tree command too! Tree documentation is here. I found I couldn’t use it from Git bash, but I could use from the usual Windows command prompt.

Usually you will have to edit the output a bit to make it appropriate for a blog post. It may give too much or too little information. You can see how I used the output in my migrating imakewebsites.ca to Hexo post.

Here’s a raw sample of tree /f from an old Laravel project folder:

C:\WWW\WEEKEND-WARRIORS
│   .gitignore
│   .htaccess
│   changelog.md
│   index.php
│   license.txt
│   php.ini
│   Readme.md
│
├───application
│   │   composers.php
│   │   filters.php
│   │   routes.php
│   │
│   ├───config
│   │   │   .gitignore
│   │   │   application.php
│   │   │   auth.php
│   │   │   cache.php
│   │   │   container.php
│   │   │   database.php
│   │   │   error.php
│   │   │   session.php
│   │   │
│   │   └───adam
│   │           application.php
│   │           error.php
│   │           session.php
│   │
│   ├───controllers
│   │       home.php
│   │
│   ├───language
│   │   └───en
│   │           common.php
│   │           enter.php
│   │           entries.php
│   │           pagination.php
│   │           validation.php
│   │
│   ├───libraries
│   │   │   .gitignore
│   │   │   base_facebook.php
│   │   │   facebook.php
│   │   │   fb_ca_chain_bundle.crt
│   │   │   jsredirect.php
│   │   │   mail.php
│   │   │   maxuploadsize.php
│   │   │   qqfileuploader.php
│   │   │   votebutton.php
│   │   │
│   │   └───phpmailer
│   │           class.phpmailer.php
│   │           class.smtp.php
│   │
│   ├───models
│   │       .gitignore
│   │       contestperiod.php
│   │       contestperioddetail.php
│   │       entry.php
│   │       error.php
│   │       fb.php
│   │       report.php
│   │       user.php
│   │       vote.php
│   │
│   ├───routes
│   │       error.php
│   │       info.php
│   │       submit.php
│   │
│   ├───storage
│   │   └───database
│   │           .gitignore
│   │
│   └───views
│       │   contest-over-page.php
│       │   default.php
│       │   entries.php
│       │   entry.php
│       │   info-page.php
│       │   rules.php
│       │   tab-liked.php
│       │   tab-unliked.php
│       │   thanks.php
│       │   upload-form.php
│       │
│       ├───common
│       │       footer.php
│       │       footerjs.php
│       │       header.php
│       │       nav.php
│       │       share-video.php
│       │       sponsor-likes.php
│       │       sportselect.php
│       │       vimeo-player.php
│       │
│       ├───entries
│       │       entry-details.php
│       │       register-vote.php
│       │       share-button.php
│       │       vote-button.php
│       │       vote-js.php
│       │       voted-already.php
│       │
│       ├───error
│       │       404.php
│       │       500.php
│       │
│       ├───home
│       │       index.php
│       │
│       └───info
│               vote-report-row.php
│               vote-report.php
│
├───laravel
│   │   arr.php
│   │   asset.php
│   │   auth.php
│   │   autoloader.php
│   │   benchmark.php
│   │   blade.php
│   │   config.php
│   │   cookie.php
│   │   core.php
│   │   crypter.php
│   │   facades.php
│   │   file.php
│   │   form.php
│   │   hash.php
│   │   helpers.php
│   │   html.php
│   │   inflector.php
│   │   input.php
│   │   ioc.php
│   │   lang.php
│   │   laravel.php
│   │   memcached.php
│   │   messages.php
│   │   paginator.php
│   │   redirect.php
│   │   redis.php
│   │   request.php
│   │   response.php
│   │   section.php
│   │   str.php
│   │   uri.php
│   │   url.php
│   │   validator.php
│   │   view.php
│   │
│   ├───cache
│   │   │   manager.php
│   │   │
│   │   └───drivers
│   │           apc.php
│   │           driver.php
│   │           file.php
│   │           memcached.php
│   │           redis.php
│   │
│   ├───config
│   │       ascii.php
│   │       mimes.php
│   │
│   ├───database
│   │   │   connection.php
│   │   │   expression.php
│   │   │   manager.php
│   │   │   query.php
│   │   │
│   │   ├───connectors
│   │   │       connector.php
│   │   │       mysql.php
│   │   │       postgres.php
│   │   │       sqlite.php
│   │   │
│   │   ├───eloquent
│   │   │       hydrator.php
│   │   │       model.php
│   │   │
│   │   └───grammars
│   │           grammar.php
│   │           mysql.php
│   │
│   ├───routing
│   │       controller.php
│   │       filter.php
│   │       loader.php
│   │       route.php
│   │       router.php
│   │
│   └───session
│       │   payload.php
│       │
│       └───drivers
│               apc.php
│               cookie.php
│               database.php
│               driver.php
│               factory.php
│               file.php
│               memcached.php
│               redis.php
│               sweeper.php
│
└───public
    │   .htaccess
    │   index.php
    │
    ├───css
    │       .gitignore
    │       fileuploader.css
    │       global.css
    │       tab.css
    │       thanks.css
    │
    ├───img
    │       .gitignore
    │       header.png
    │       loader.gif
    │       prizes-collage.jpg
    │       sponsors-signs.jpg
    │       square-logo.png
    │
    └───js
            .gitignore
            fileuploader.js
            global.js
            submit-entry.js
            vote.js

Migrating imakewebsites.ca to Hexo

Today I migrated http://imakewebsites.ca from a home-made PHP and MySQL CMS to the Hexo static blogging engine. Moving content over was easy, but it took some time to rebuild my theme and figure out a few quirks when using Hexo for a site without a blog component.

Why migrate?

I rarely update imakewebsites.ca, so moving it to static hosting makes life easier and takes a microscopic amount of load off the web server. I also want to learn what working with Hexo is like.

Pages

Like WordPress, Hexo supports pages, which are like blog posts but without chronological order and their own template. Hiding the blog related functionality by removing links the template engine was easy, but I discovered you must have at least 1 blog post in a site, otherwise the site’s homepage (index.html) will not render. I had to keep a dummy blog post in the site which is an orphaned page (no links to it)

Preserving URLs from my custom site was easy. I ended up with a directory structure like this:


public │ .htaccess │ favicon.ico │ index.html │ ├───2015 | (hidden dummy blog posts) │ ├───404 │ index.html │ ├───archives │ (hidden dummy blog posts) │ ├───contact │ (contact specific images) │ index.html │ ├───css │ style.css | ├───free-zen-cart-templates │ (template specific images and files) │ index.html │ ├───img │ (images used all over the site) │ ├───making-downloadable-products | (tutorial specific images and files) │ index.html │ ├───portfolio │ (portfolio specific images used on the homepage) │ └───zen-cart-layouts (tutorial specific images) index.html

I moved my page specific images out of a general /images folder and into the folder associated with each page. The content of each page is in each index.html, but browsers won’t need to show that in the URL. The folder names match the names of my old pages from the CMS.

It would be nice to disable the archive and blog page generation entirely, but their overhead is tiny so it isn’t a big problem.

Rendering HTML

Hexo encourages you to write content in Markdown. However, I already wrote content for the site in HTML. If you supply blog posts and page content with a .html extension, Hexo will use it and not run it through any sort of generator. Your raw HTML gets integrated into the site smoothly.

Moving the theme

I took the included Landscape theme and overwrote its HTML with content from my own site. I removed code for some blogging features. EJS Package for Sublime Text came in very handy for editing the theme’s files.

Deployment Process

hexo-deploy-ftpsync looks like is being smart and only uploading files that have changed, but I haven’t confirmed that yet. I wish I didn’t have to save my FTP name and password inside _config.yml to use it.

The fun part is when I make changes to the site, I can generate the new /public directory of the project and deploy with one terminal command:

hexo generate && hexo deploy

I like that!

Compile nginx with RTMP support on Raspbian

Here’s a bash script. Put this into a new file, ~/install-nginx-rtmp.sh:

 #!/bin/bash
sudo apt-get update
sudo apt-get install nginx -y
sudo apt-get remove nginx -y
sudo apt-get clean nginx -y
sudo apt-get install -y curl build-essential libpcre3-dev libpcre++-dev zlib1g-dev libcurl4-openssl-dev libssl-dev
mkdir nginx-build
cd nginx-build
wget http://nginx.org/download/nginx-1.7.5.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
tar -zxvf nginx-1.7.5.tar.gz
unzip master.zip
cd nginx-1.7.5
./configure --prefix=/var/www --sbin-path=/usr/sbin/nginx  --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_ssl_module --without-http_proxy_module --add-module=/home/pi/nginx-build/nginx-rtmp-module-master

make
sudo make install
echo "made it to the end"

execute it like this:

sh install.sh

Notice it install nginx from the package manager, and then removes it. This will leave some useful files behind for running nginx as a service.

This script is made of commands I learned from these posts, which explain what’s going on line-by-line.