all blog posts

AVA Tutorial

24 Apr 2019

avajs/ava : 🚀 Testing can be a drag. AVA helps you get it done.


A concurrent test runner from the Andromeda galaxy. If I was to stray from Jasmine then it could only be for a project Sindre Sorhus is working on :) The screenshots on the project site promised extensive assertion failure output with clean stack traces and built-in Promise, async/await, Observable and React component support. So I tried it out and yup, AVA delivered.

Get Started

# Install
npm init ava

# Run tests
npx ava --watch --verbose
testing tutorial

.NET Regex Tutorial

19 Apr 2019

Not nearly as confusing as it is in JavaScript.

using System.Text.RegularExpressions;

bool mach = Regex.IsMatch("input", @"\w+", RegexOptions.None);
Match match = Regex.Match("input", @"\w+");
IReadOnlyList<Match> matches = Regex.Matches("input", @"\w+");
string result = Regex.Replace("input", @"(\w+)", "$1");
cheat-sheet regex

Vue.js Tutorial

19 Apr 2019

vuejs/vue : Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

Why Vue

  • 100k+ ⭐: So many people can’t be wrong
  • Declarative rendering with a cool, terse syntax
  • Low learning curve
  • Reactive and composable view components
  • Optional official vue-router and vuex (statemanagement)
  • @vue/cli: Scaffold project with optional support for TypeScript, PWA, CSS Pre-processors, Linters, Tests, …
  • Automatic dependency tracking
  • Virtual DOM
  • Supports IE9+
tutorial

Moment.js Tutorial

19 Apr 2019

Moment.js is a mutable wrapper with a fluent interface for the native JavaScript date object (property _d). Use .toDate() to convert back to a JavaScript date.

Dates are interpreted as local time. Unless instantiated with moment.utc().

const now = moment(); // current local time
const a = moment('2016-01-05');
const b = a.clone().add(1, 'week');
b.format('YYYY-MM-DD HH:mm:ss');

moment/moment : Parse, validate, manipulate, and display dates in javascript.

cheat-sheet tutorial

Git Hooks with Husky

13 Apr 2019

Avoid pushing changes that break the build with githooks and Husky.

typicode/husky : 🐺 Git hooks made easy

git

Exotic Git Snippets

5 Apr 2019

Some git commands and scripts that come in handy from time to time.

git


JavaScript RegExp Tutorial

5 Mar 2019

A cheat sheet for the regex syntax in JavaScript.

MDN RegExp Guide

TL&DR

''.test(/^$/);
'ok'.replace(/(.)(.)/g, '$2$1'); // $$, $&, $`, $'

const matchG = 'aaa'.match(/a/g);
matchG == ['a', 'a', 'a'];

const matchNoG = 'str'.match(/(st)r/);
matchNoG == Object.assign(['str', 'st'], {groups: undefined, index: 0, input: 'str'});
matchNoG == /(st)r/.exec('str');
cheat-sheet regex