Web Tooling and Automatisation using gulp 4

Now working with Gulp you will discover that you run into a couple of minor problems. Especially in sequencing the different types of tasks. Let’s take a simple clean task, it should run before all of the other tasks. However, Gulp will run all tasks in parallel.

The team that is working on Gulp has been working on a solution for this problem and in Gulp 4.0 we will get gulp.series() and gulp.parallel(); to distinguish between these two types of operations.

Sadly it looks like that currently the release of Gulp 4.0 is delayed. However, you can use the current Alpha version prior to its release.

Installing Gulp 4

You can simply install the next version of Gulp with NPM (A git client is required, as the package is not in the npm repository and will be cloned from Github) npm install gulpjs/gulp#4.0

Updating the gulpfile.js

The syntax for tasks has changed, so we need to rewrite parts of the file: Our existing Gulp 3 taskgulp.task("default", ["html", "scripts", "styles", "images"]); Needs to be rewritten with gulp parallel as such: gulp.task("default", gulp.parallel(html, scripts, styles, images)); However, we should not stop there and improve upon this task, by running the clean task before all of the other tasks. To ensure that it runs before the other tasks we use gulp.series().

gulp.task("default",
    gulp.series(cleanDist, gulp.parallel(html, scripts, styles, images))
);

Improving on the production flag

With gulp.series() we now can stop using the –production flag. We simply define a production task.

As first operation we pass in a function that simply sets the production boolean to true: gulp.task('production', gulp.series((done) => { production = true; done(); }, 'default')); The function uses “done” to signal gulp that the function has completed.

Hiding Tasks

Another improvement of Gulp 4.0 is that you can pass functions, as well as tasks to gulp.series and gulp.parallel.

This, in turn, lets you write normal functions that are hidden from the command line, ensuring that everybody on the project runs the default build task instead of only the HTML task.

Here is now our improved Gulpfile.js:

//Gulp Packages
const gulp = require('gulp');
const gulpIf = require('gulp-if');
const browserSync = require('browser-sync').create();
const clean = require('gulp-clean');

const pug = require("gulp-pug");

const imagemin = require('gulp-imagemin');

const sass = require("gulp-sass");
const autoprefixer = require("gulp-autoprefixer");

const ts = require("gulp-typescript");
const tslint = require("gulp-tslint");
const uglify = require('gulp-uglify');

const jasmine = require("gulp-jasmine-phantom")

//Global Variables
var production = false;

//Path Definitions
const paths = {
    html: {
        src: "src/views/**/*.pug",
        dest: "dist"
    },
    styles: {
        src: "src/styles/**/*.scss",
        dest: "dist/styles"
    },
    scripts: {
        src: "src/scripts/**/*.ts",
        dest: "dist/scripts"
    },
    images: {
        src: "src/img/*",
        dest: "dist/img"
    }
}

//Internal Tasks
function cleanDist() {
    return gulp.src('dist')
        .pipe(clean())
}

function html() {
    return gulp.src(paths.html.src)
        .pipe(pug())
        .pipe(gulp.dest(paths.html.dest))
}

function scripts () {
    return gulp.src(paths.scripts.src)
        .pipe(ts({
            out: "output.js"
        }))
        .pipe(tslint({
            formatter: "verbose"
        }))
        .pipe(tslint.report())
        .pipe(gulpIf(production, uglify()))
        .pipe(gulp.dest(paths.scripts.dest));
}

function styles() {
    let sassOptions = {};
    if (production) {
        sassOptions = {
            outputStyle: 'compressed'
        }
    }
    return gulp.src(paths.styles.src)
        .pipe(sass(sassOptions).on('error', sass.logError))
        .pipe(autoprefixer({
            browsers: ['last 2 versions']
        }))
        .pipe(gulp.dest(paths.styles.dest))
        .pipe(browserSync.stream())
}

function images () {
    return gulp.src(paths.images.src)
        .pipe(gulpIf(production, imagemin()))
        .pipe(gulp.dest(paths.images.dest));
}

//External Tasks

gulp.task("tests", () => {
    return gulp.src("src/tests/test.js")
        .pipe(jasmine({
            integration: true,
            vendor: '_build/**/*.js'
        }));
})

gulp.task("default",
    gulp.series(cleanDist, gulp.parallel(html, scripts, styles, images))
);

gulp.task('production', gulp.series((done) => { production = true; done(); }, 'default'));

gulp.task("serve", gulp.series('default', () => {
    browserSync.init({
        server: "./dist"
    });
    gulp.watch(paths.styles.src, gulp.series(styles));
    gulp.watch(paths.scripts.src,  gulp.series(scripts));
    gulp.watch(paths.images.src, gulp.series(images));
    gulp.watch(paths.html.src, gulp.series(html)).on('change', browserSync.reload);
}));

Package.json

{
  "name": "gulp4-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "^2.18.7",
    "eslint": "^3.15.0",
    "gulp": "github:gulpjs/gulp#4.0",
    "gulp-autoprefixer": "^3.1.1",
    "gulp-clean": "^0.3.2",
    "gulp-eslint": "^3.0.1",
    "gulp-if": "^2.0.2",
    "gulp-imagemin": "^3.1.1",
    "gulp-jasmine-phantom": "^3.0.0",
    "gulp-pug": "^3.2.0",
    "gulp-sass": "^3.1.0",
    "gulp-tslint": "^7.1.0",
    "gulp-typescript": "^3.1.4",
    "gulp-uglify": "^2.1.2",
    "phantomjs": "^2.1.7",
    "tslint": "^4.4.2",
    "typescript": "^2.1.6",
    "typescript-eslint-parser": "^1.0.3"
  }
}

JSP: Passing Variable Data to JavaScript

When you try to marry old JSP Technology with the modern wonders of Typescript/ES6. You will want to expose some data provided by the backend into the JavaScript. If you have the possibility you would use a fetch()call to receive JSON. Sometimes, it is not possible to do a big rewrite of the JSP to fix a minor bug. Here is a very dirty way to pass data from the JSP into the JS code. This code will utilize the HTML5 data-attribute. Learn more about it here

JSP File:

<fmt:message var="someText" key="core.someText" />

<div id="jsVariables"
     data-someText="${self.someText}"
    >
</div>

JavaScript:

let dataContainer = document.getElementById('jsVariables');
let someText = dataContainer.dataset.someText;

JQuery:

let someText = $('#jsVariables').data('someText')

This is a very elegant solution (for well I guess using JSPs), now you can run ESLint on your Javascript Code and will not have any unresolved variables.

Udacity – Web Tooling and Automatisation

I recently took a look at the course materials for Web Tooling and Automatisation.

Overall the course is very well structured and introduces Gulp and a couple of common packages used in web development. Besides their main topic, they cover topics on good engineering practices, like linting and testing to ensure code quality.

While working on the project I ran into several little smaller things that were quite annoying. Thankfully the gulp community is quite big, so somebody already solved some of the issues I was facing.

Passing an “–production” flag

When developing, you will probably create a version of your software that is suited for easily finding bugs and errors and an optimized version that is minified and optimized for optimal performance for the end user.

You would define two different tasks in gulp, one “default” and one “production” task. This, however, would, in turn, cause you to have to duplicate your code – with optimization and without.

I found the package “gulp-if” that allows you to control if a function like compression is active during the task. The remaining issue was to actually set the parameter before the tasks run. (All tasks in gulp run in parallel).

To get a flag from the command line, you can use the process.argv Array. However, you must add “–” before your flag name. If not gulp will assume it is another task name that should run.

In the end, you would use something like this:

//Enable Production Flag
var production = (process.argv.indexOf("--production") !== -1);

//Use in task

gulp.task("default", ()=>{
  gulp.src(path.src);
.pipe(gulpif(production, foo())
.pipe(gulp.dest(path.dest));
});</pre>
**Note:** In Gulp 4, you can use a sequencer and would not need to pass in the flag by command-line, but you would define a task that will run before all the other tasks.

# Dealing with Asset sources and destinations
When using gulp.src() and gulp.dest(), typically people use strings to define the locations. However, this is quite annoying if you want to get a quick overview which locations are used. For a better maintainability, you should create a small variable block that defines these strings. In the long run, it lets you be more flexible where your files are etc.
<pre class="lang:js decode:true ">//Path Definitions
const htmlPaths = {
    src: "src/views/**/*.pug",
    dest: "dist"
}

gulp.task("html", () => {
    gulp.src(htmlPaths.src)
        .pipe(pug())
        .pipe(gulp.dest(htmlPaths.dest))
});

End Result

At the end of the course, I ended up with this gulpfile.js. It adds support for Typescript, Pug(Jade), google-closure-compiler.

The common gulp tasks to run are:

  • gulp serve: Uses browser-sync with CSS injection for live-editing
  • gulp --production: Creates an optimized build

Next steps: Depending on your web server, you would want to add a gulp deploy task.

gulpfile.js

//Gulp Packages
const gulp = require('gulp');
const gulpif = require('gulp-if');
const browserSync = require('browser-sync').create();

const pug = require("gulp-pug");

const imagemin = require('gulp-imagemin');

const sass = require("gulp-sass");
const autoprefixer = require("gulp-autoprefixer");

const ts = require("gulp-typescript");
const eslint = require("gulp-eslint");
const closureCompiler = require('google-closure-compiler').gulp();

const jasmine = require("gulp-jasmine-phantom")

//Flag Definitions
var production = (process.argv.indexOf("--production") !== -1);


//Path Definitions
const htmlPaths = {
    src: "src/views/**/*.pug",
    dest: "dist"
}

const stylesPaths = {
    src: "src/styles/**/*.scss",
    dest: "dist/styles"
}

const scriptsPaths = {
    src: "src/scripts/**/*.ts",
    dest: "dist/scripts"
}

const imgPaths = {
    src: "src/img/*",
    dest: "dist/img"  
}

//Task Definitions
gulp.task("default", ["html", "scripts", "styles", "images"]);

gulp.task("serve", ["default"], () => {
    browserSync.init({
        server: "./dist"
    });
    gulp.watch(srcStyles, ["styles"]);
    gulp.watch(srcScripts, ["scripts"]);
    gulp.watch(srcImages, ["images"]);
    gulp.watch(srcHTML, ["html"]).on('change', browserSync.reload);
})

gulp.task("html", () => {
    gulp.src(htmlPaths.src)
        .pipe(pug())
        .pipe(gulp.dest(htmlPaths.dest))
});

gulp.task("scripts", () => {
    gulp.src(scriptsPaths.src)
        .pipe(ts({
            out: "output.js"
        }))
        .pipe(eslint({
            parser: "typescript-eslint-parser"
        }))
        .pipe(eslint.format())
        .pipe(gulpif(production, closureCompiler({
            compilation_level: 'SIMPLE',
            warning_level: 'VERBOSE',
            language_in: 'ECMASCRIPT6_STRICT',
            language_out: 'ECMASCRIPT5_STRICT',
            output_wrapper: '(function(){\n%output%\n}).call(this)',
            js_output_file: 'output.min.js'
        })))
        .pipe(gulp.dest(scriptsPaths.dest));
});

gulp.task("styles", () => {
    let sassOptions = {};
    if (production) {
        sassOptions = {
            outputStyle: 'compressed'
        }
    }
    gulp.src(stylesPaths.src)
        .pipe(sass(sassOptions).on('error', sass.logError))
        .pipe(autoprefixer({
            browsers: ['last 2 versions']
        }))
        .pipe(gulp.dest(stylesPaths.dest))
        .pipe(browserSync.stream())
});

gulp.task("tests", () => {
    gulp.src("src/tests/test.js")
        .pipe(jasmine({
            integration: true,
            vendor: '_build/**/*.js'
        }))
})


gulp.task("images", () => {
    gulp.src(imgPaths.src)
        .pipe(imagemin())
        .pipe(gulp.dest(imgPaths.dest));
})

Package.json

{
  "name": "udacity-webtooling",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "^2.18.7",
    "eslint": "^3.15.0",
    "eslint-config-google": "^0.7.1",
    "google-closure-compiler": "^20170124.0.0",
    "gulp": "^3.9.1",
    "gulp-autoprefixer": "^3.1.1",
    "gulp-eslint": "^3.0.1",
    "gulp-if": "^2.0.2",
    "gulp-imagemin": "^3.1.1",
    "gulp-jasmine-phantom": "^3.0.0",
    "gulp-pug": "^3.2.0",
    "gulp-sass": "^3.1.0",
    "gulp-tslint": "^7.1.0",
    "gulp-typescript": "^3.1.4",
    "phantomjs": "^2.1.7",
    "tslint": "^4.4.2",
    "typescript": "^2.1.6",
    "typescript-eslint-parser": "^1.0.3"
  }
}

Sources:

ImageDesigned by Freepik

Continuous Integration (CI) for Gitbook using Gitlab and Gulp

Gitbook is a static site generator, that converts a collection of Markdown files into an HTML Site. Alternatively, it can also convert the markdown files into a PDF or ebook. If you are not writing a book, it is also a great tool to create a quick documentation for a project you are working on. # Initial set up We will need gitbook. Gitbook does not automatically generate a SUMMARY.md file, however, there is an existing gitbook-summary tool to take care of that. Gulp will be our task runner. I will deploy to my server via FTP. Since you are only serving HTML Files, there is usually no need for server restart etc. To integrate it into Gulp I will be using vinyl-ftp.

npm init

Install Gitbook Tools

npm install --save-dev gitbook gitbook-cli gitbook-summary

Install Gulp with Tools

npm install --save-dev gulp gulp-gitbook

Install FTP with needed Gulp Tools`

npm install –save-dev vinyl-ftp gulp-util

Gulp Create a file called `gulpfile.js` and define your gulp tasks. You should test especially the “deploy” task locally if everything is working correctly.

let gulp = require("gulp");
let gitbook = require("gulp-gitbook");
let ftp = require("vinyl-ftp");
let gutil = require("gulp-util");
var summary = require("gitbook-summary/lib/summary");

gulp.task("default", \["build"\]);

//Generates the Summary.md file
gulp.task('summary', ()=> {
    let options = {
        root: "."
    }
    return summary(options);
});

//Generates the Website
gulp.task('build', \["summary"\], (cb) => {
  gitbook('.', cb);
});


//Deploys the output onto your server
gulp.task('deploy', \["build"\], () => {
    var conn = ftp.create( {
        host:     '<url>',
        user:     '<username>',
        password: '<password>',
        parallel: 10,
        log:      gutil.log
    } );
 
    var globs = \[
        '_book/**'
    \];

    return gulp.src( globs, { buffer: false } )
        .pipe( conn.newer( '.' ) ) // only upload newer files 
        .pipe( conn.dest( '<server directory>/' ) ); // Depending on your server you may have to prefix something like /home/www/
});

Gitlab CI Integration

You need to create a YAML File called .gitlab-ci.yml. Gitlab will recognize the file and run the commands in it.

image: node:latest

cache:
  paths:
   - node_modules/

before_script:
  - npm install
  - npm install -g gulp

deploy:
  only:
   - master
  script:
   - gulp deploy

That’s it. If you push something into the master branch, it will automatically run the commands in the yaml file and deploy your static website to your server. When the build completes, you will receive an email, telling you if everything went as planned.

Elementary OS: Things to do after installing Elementary OS 0.4 (Loki)

When you start out with elementary OS there are a couple of useful things that you should do to have a better experience working with your system.

General

“Software & Updates” for Additional Drivers

The easiest way to install the proprietary nVidia Drivers (in Ubuntu) is to go to System Settings > Additional Drivers and then simply select the driver.

This option is not available in Elementary. However, by installing the package software-properties-gtk you can get the program.

sudo apt install -y software-properties-gtk

Now by clicking on Applications on the top right, and then type “Software & Updates” you can access the Settings.

Easy way to add PPA

With the command line tool add-apt-repository you have a quick way to add additional PPA’s. To get this tool you need to install the package

sudo apt-get install software-properties-common

Add a Minimize Button to Windows

Some of the Elementary Windows do not have an easy way to minimize the window.  With Elementary Tweaks you can add a button to the windows.

Officially the elementary team does not encourage users to use the tweaking tool, since it also exposes switches to functionality that could mess up your system, so use the tool with caution.

sudo add-apt-repository ppa:philip.scott/elementary-tweaks
sudo apt install elementary-tweaks

Microsoft Font Compatability

sudo apt-get install ttf-mscorefonts-installer

Replace Screenshot tool

sudo apt remove screenshot-tool
sudo add-apt-repository ppa:shutter/ppa
sudo apt-get update && sudo apt-get install -y shutter

Chrome

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable

Skype

wget https://go.skype.com/skypeforlinux-64-alpha.deb
sudo dpkg -i skypeforlinux-64-alpha.deb

Office

sudo apt install libreoffice

Graphic Editors

sudo apt install gimp inkscape shutter

Video

Video Lan

sudo apt install -y vlc

Codecs

sudo apt-get install ubuntu-restricted-extras ffmpeg

Other

Redshift

A simple program to prevent Eye Strain

sudo apt install redshift gtk-redshift

Laptop Battery Saver

sudo apt install tlp tlp-rdw

Last Steps

Remove Programs

sudo apt remove pantheon-mail -y
sudo apt remove maya-calendar -y
sudo apt remove epiphany-browser -y
sudo apt remove audience -y

Update your system

sudo apt-get update && sudo apt-get dist-upgrade

Some content has been disabled in this document

Elementary OS: Windows Apps with Play on Linux

One of the major issues when using Linux is that you would like to use Software that was written for Windows. Thankfully more and more new Software is cross-platform compatible. However especially older Software and most newer Games will not support Linux.

If you are dependent on using Windows Software then you have several options available. Dual-Boot Windows and Linux, use a Virtual Machine (like VirtualBox or try  WineHQ

Wine essentially translates the Windows Commands to Linux Commands at run-time. Eliminating the penalty of using a virtual machine. The downside of Wine is, that not all new programs run properly. However, it seems games that were written for Windows XP work better with Wine than with Windows 10.

The last time I was playing with Linux I found it very difficult to configure and find packages. You need wine, wine-tricks, then install some other windows package into wine etc.  This time I found another project Play on Linux that provides an easy to use GUI with quick Installers for many different programs.

The other thing which makes “Play on Linux” great, is that it can create multiple virtual drives, for your various programs. So you can use different versions of Wine, or configure the different drives to emulate a different version of Windows, use different components etc.

Install Play on Linux

wget -q "http://deb.playonlinux.com/public.gpg" -O- | sudo apt-key add -
sudo wget http://deb.playonlinux.com/playonlinux_trusty.list -O /etc/apt/sources.list.d/playonlinux.list
sudo apt-get update
sudo apt-get install playonlinux

Battle.net games

Play on Linux shines the most when it already provides an installer that automatically configures Wine correctly to install all components that the program simply runs without any additional work.

You just locate Hearthstone, Diablo or Starcraft from the list and press install and the program will work without any issues.

Windows Steam Games

Step 1#

Install Windows Steam. Play on Linux provides easy installers for Steam, simply search for steam in the installer menu and press install.

Step 2

You will have to look up in the Wine AppDB if your game is supported by Wine.

If it is supported you then can log into steam and install games from your library just like in windows.

Step 3

Usually, you will need to install some sort of additional windows package to get the program running.

In my case, I wanted to install Tron 2.0, in the documentation for the program. Something like needs “winetricks directmusic” was mentioned.

To install “directmusic” you need to select Steam and click on Configure. Then switch to the Install components Tab and then select the component from the list and press install.

In some cases, like with my Tron 2.0 example, this is not enough and you have to google some more to find some helpful [article] (http://www.gamersonlinux.com/forum/threads/tron-2-0-guide.628/) that then tells you to install additional components  and not to use the Windows XP emulation but the Windows 7 emulation.

Custom Installers

Of course, you may have your own Programs, you can simply click on “Install non-listed program” navigate to the installation files and install your program.

Access to Files

Play on Linux installs a handy shortcut into your home directory so that you can easily access the various virtual hard drives of the Play on Linux instances, if you have the need to copy&modify files.

Conclusion

While Wine is not perfect and not everything runs smoothly and out of the box like when using Windows directly. It is worth fiddling around with Wine/Play on Linux to not have to dual boot or get a VM running.

Elementary OS: Loki

Elementary OS is a new Operating System that wants to be an alternative to Window or OSX. The team behind the project puts a high emphasis on Usability and Design.

Over the next couple of days, I will try to actually switch to the system. Elementary is based on Ubuntu, which in turn is based on Debian, so all *.deb packages and programs can be installed without any problems. As with all Linux, Distributions Elementary is free. However, the developers require you to think about it if you would like to support their efforts or not. If not you enter a 0 into the download field.

For my initial setup, I will essentially install all the common programs I use on a day to day basis.

How To install Elementary.io

Step 1 Download the ISO

Go to www.elementary.io and download the current Version. If you have some money to spare you can donate to the project. If not enter a 0 and you can download the iso for free.

Step 2: Prepare a USB Stick

Go to https://rufus.akeo.ie/ and download the Rufus tool, this allows you to easily create a bootable USB stick.

Step 3: Install

Well for the last step you really just have to boot from the stick and follow the instructions.

First Steps

Remove Default Programs

The team focuses a lot on providing a suite of programs that also follow it’s design principles.

I would prefer to use Chrome as my Browser, and VideoLan for videos and I do not need an email client or a dedicated calendar.  I removed them with these commands:

sudo apt remove pantheon-mail -y
sudo apt remove maya-calendar -y
sudo apt remove epiphany-browser -y
sudo apt remove audience -y

(The program “audience” is the default video player)

Install General Programs

Chrome

Since Chrome has some Google stuff in it you first have to add it to apt with this command:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable

VideoLan

To install VideoLan simply enter the following command:

sudo apt-get install vlc -y

###Skype Microsoft has just recently announced that they will create a Skype Client for Linux. For now, there is only the official “Skype for Linux Alpha”. Essentially the program is still barebones and is in very early stages of development. – If you install it do not expect that everything will be working.

wget https://go.skype.com/skypeforlinux-64-alpha.deb
sudo dpkg -i skypeforlinux-64-alpha.deb

Shortcuts

| Shortcut | Command | | ==== | ==== | | ⌘+Space | App Launcher | | Alt+Tab | Window Switcher | | ⇧+Alt+Tab | Switch Windows Backwards| | ⌘+Left/Right | Switch Workspace | | ⌘+S | Workspace Overview | | Ctrl+⌘+Left/Right | Snap Window to Half of Workspace | | ⌘+T | Terminal |

Conclusion

The OS looks awesome, it feels like a system you actually could work with for a longer period of time. In the past, I have always tried Linux for a couple of days and then said, well interesting, but a lot of my programs simply do not work and I would like to go back to Windows.

Let’s see how long this time the experiment is going to last and if Linux has become more user-friendly over time.

How to install Windows 10

Preparation

You will need a USB-Drive with a minimum of 3GB free space.

Installation Files

Unlike previous versions of Windows, Microsoft has released a download tool.

  1. Download the tool from https://www.microsoft.com/en-us/software-download/windows10
  2. Attach the USB-Stick to your computer
  3. Start the tool and select your USB-Drive
  4. The tool will download the installation files and make the USB-Stick bootable.

Install Windows 10

Start your computer and boot from the USB-Drive During Installation you should not use “Express Settings” but instead use “customize settings” and take a close look at the different options. If you are upgrading a Windows 7 installation or Windows 10 has been previously installed on the computer Windows will not ask you for a Product-Key and does not need to be activated again.

Quick Program Setup

By using chocolatey you can quickly install most of the programs you need.

Install Chocolatey

  1. Open a cmd with Administrator Privileges (Windows Key > type “cmd” > Shift + Ctrl + Enter)
  2. Copy and Paste following script:
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin 

Install your programs

  1. Visit the chocolatey site to find packages (http://www.chocolatey.org)
  2. Open a cmd with Administrator Privileges
  3. Create your own script that looks something like this:
  4. choco install -y googlechrome vlc skype 7zip

Optimizations

Remove Preinstalled Apps

If you are running Windows on a Desktop without any touch capabilities, you will probably have no use for certain features, like Cortana or those Apps in the Start menu. Some of these Apps you can remove using the control panel, however, Microsoft apps like “Mail” cannot be removed using the control panel. To remove them you need to using an elevated Powershell (Windows Key > “Powershell” > Ctrl-Shift-Enter)

To remove a package

Step 1

First List all available Packages Get-AppxPackage

Step 2

Use the name of the package, only one package should be selected Get-AppxPackage Microsoft.Windows.Photos

Step 3

Get-AppxPackage Microsoft.Windows.Photos | Remove-AppxPackage Note: It is not recommended to remove the Windows Store. It is rumored that you then cannot install anymore Windows updates after that.

Remove all Packages

As alternative run following command to remove all Apps (excluding the Windows Store). Get-AppxPackage -AllUsers | where-object {$_.name –notlike “\*store\*”} | Remove-AppxPackage

Note: This command may also remove components you actually would like to keep It is better to create a controlled powershell script to remove only the apps you do not want.

Disable UAC (User Account Control)

Assuming you are a power user and you know what you are doing with Windows. You can disable the User Account Control using the elevated Powershell console. With this oneliner, you can disable UAC on your computer.

Set-ItemProperty -Path HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\policies\\system -Name EnableLUA -Value 0

(Restart required)

Getting Started using AngularJS with Yeoman and Visual Studio Code

Typically to get started with a web-project you would start downloading libraries, configuring grunt etc. Yeoman is a project that takes care of all of this in a simple step and goes one step beyond, it also ensures that you will be using current web standards. My editor of choice is Visual Studio Code (Other alternatives would be Atom, Sublime, Brackets etc.). I will be using Windows as my Operating system, all Software is available cross-platform for Mac and Linux. Some commands need to be adjusted for the platform you are using.

Software needed:

Now it may seem odd that python and git are listed here. However, while I was trying to get yeoman to work I discovered that bower requires git to be added to the path and since python was missing from my path, some odd errors occurred while creating the initial project.

Getting Started with Yeoman

Working with Yeoman requires you to work with the terminal. Open Powershell (Powershell is the newer version of the console and emulates more a Linux-like shell) by searching for “Windows Powershell” in the StartMenu

  1. Install a lot of node stuff you need for yeoman npm install -g yo bower grunt-cli gulp
  2. Now you need to install the yeoman generator for angularjs npm install -g generator-angular

Your first Yeoman project

Simply because you are anyway in the console change the directory to your project directory (something like cd c:/projects) You can create a new directory using the mkdir-command like: mkdir angularProject Finally, run yo angular to create your project. You have to answer a couple of questions which (modern) tools&frameworks you would like to use: Sass (with Compass): Yes Bootstrap: Yes Bootstrap Sass Version: Yes More information about the official yeoman generator-angular can be found here. If everything goes smoothly the generator-angular created for you an entire modern web application project that uses angularjs.

The generated Gruntfile

Grunt is a task runner, when properly defined it can automate a lot of tedious work. Yeoman essentially does the work of properly defining the gruntfile. A lot of tasks are to optimize your various files, like CSS, js and image files. It also takes care of running the preprocessors like sass or less. It even runs your javascript tests with karma.js. (and now that grunt takes care of most of your repetitive tasks you maybe even have time to write some tests).

What do you need to know?

There are three commands you can use on the console:

  • “grunt” – simply runs all the tasks and provides a working web app in the “dist” folder
  • “grunt serve” – starts a web server and automatically updates your browser while you are working on the source files
  • “grunt test” – runs all of your tests

Visual Studio Code Setup

Well, there is not much to do. You need to open the folder for your project. And out of the box, you can already run the build and test tasks. To additionally run the “serve” task in Code

  1. Ctrl-Shift-P > Configure Task Runner
  2. In the tasks.json add a new task {"taskName": "serve", "isWatching": true }

To use the Visual Studio Code Debugger you need to adjust the Debug Configuration

  1. Ctrl-Shift-P > Debug: Configure
  2. Change the line “program” : “app.js” into “program”: “app/scripts/app.js”.

Conclusion

The power of this setup is mostly that most of the stuff comes out of the box, and provides you with a great foundation to create a high-quality code project. You can and should extend the gruntfile to suit your specific needs like to push your project onto your webserver.

EdX: Introduction to Linux

I recently completed the course “Introduction to Linux” by the Linux Foundation on the edX platform. Instead of paying 2500USD for the course you now can pay 250USD for a verified certificate, or simply get an honor certificate.

https://www.edx.org/course/linuxfoundationx/linuxfoundationx-lfs101x-introduction-1621#.U-YKjfmSyyY

Course Structure

The course is self-paced, you can take the exam any time and at the end of the month, the certificate is going to be issued.

Course Materials

Unlike other edX courses, most of the materials are short articles covering the core topics. There are short videos, however, they are mostly useless.

Learning Objectives

Sadly the first couple of Lessons are more like Advertisements that Linux is great and that Linux is used everywhere and being able to use Linux is an important skill. The rest of the course covers the basic operations when interacting with a Linux system. The course briefly takes a look at the graphical interfaces of three major Linux distributions Ubuntu, CentOS and openSUSE. As expected most of the course covers how to interact with the Console covers the basic interaction with the console, file operations, security principles, text manipulation and concluding with bash scripting.

Final Exam

The final exam is a 30 question multiple choice test. Sadly some questions are easier to be answered using Google than the actual course material. People with a basic understanding of Linux could just skip the entire course and just take the exam. It’s rather straightforward.

Conclusion

The course is a great introduction to the Linux System. The course is designed for IT-Specialists (Programmers, Web-Developers, and Administrators etc.) that have not worked with Linux and need a quick introduction how to work with the system. Sadly with the emphasis on using the console most users interested in using Linux as an alternative to Windows/OSX will simply say “Oh god, what a hassle, I’ll stick to my current system.” Once again Linux does not realize that GUIs have been invented to solve an issue where most people find it confusing when they do not see what they are doing. Most users interacting with a computer are not aware that it is possible to interact with a computer without GUI, telling those users that sometimes you simply do not have a GUI confuses them. Most of the success of Linux as the core of Android is the GUI and that users have a simple way installing programs and are not able to access any console/text only mode. Once again the core of Linux is great, however, the presentation and usability are that what is lacking.