Skip to content

Instantly share code, notes, and snippets.

View tjunghans's full-sized avatar
💭
Open for business

Thomas Junghans tjunghans

💭
Open for business
View GitHub Profile
@tjunghans
tjunghans / Frontend Developer Guidelines.md
Last active February 22, 2021 10:28
Frontend Developer Guidelines

Frontend Developer Guidelines

Pull Requests and Code Reviews

Creating Pull Requests

  • One commit per pull request. Squash commits before merging.
  • Strive for one feature or bugfix per pull request.
  • Link the pull request to a jira using the git branch name.
  • The branch name of the pull request has the following convention: feature|bugfix/MTB-####-short-description-of-change
@tjunghans
tjunghans / increase-ulimit-on-systemd-service.md
Last active January 11, 2022 03:36
Increase ulimit on a systemd service

Increase ulimit on a systemd service

Locate the service under /etc/systemd/system and edit it with vim. Add the following to the [Service] section of the file:

LimitNOFILE=65536

This is the equivalent of ulimit -n.

@tjunghans
tjunghans / octave.md
Last active March 18, 2018 18:29
Octave Commands - Standford Machine Learning

Octave

This is a summary of the Octave Tutorial of the Coursera Machine Learning course by Andrew Ng.

Basic Operations

>> 5 + 6
ans = 11
@tjunghans
tjunghans / template.html
Created June 30, 2017 10:00
HTML Template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="author" content="Thomas Junghans">
@tjunghans
tjunghans / recursive-promises.md
Created May 22, 2017 13:39
Recursive Promises

Recursive Promises

You have a function authenticate which returns a resolved promise on success or reject on failure. If the authentication failed the process should be repeated. This can be a achieved with a recursive promise.

Example

let counter = 0;
@tjunghans
tjunghans / promises-in-sequence.md
Last active May 16, 2017 12:12
Promises in sequence

Promises in Sequence

If you have multiple promises, an array of promises, and you want to perform an action after they all have resolved you can use Promise.resolve(). However if you'd like the same result, whilst having the promises called in order you will need to come up with a custom solution because there is no api for that.

Let's create a promise factory to generate our promises that we want to execute in sequence:

function createP(id) {
@tjunghans
tjunghans / checking_type_api_response.md
Last active March 1, 2024 07:09
Checking the Type of an API Response in TypeScript

Checking the Type of an API Response in TypeScript

TODO: Look at Typescript User defined Type Guards

Although the title contains "TypeScript" what I'm about to show is not TypeScript specific and can and should also be done with JavaScript. The reason I am writing in the context of TypeScript is because we rely on TypeScript for type checking in most cases. An exception is when we get data from an API response such as HTTP GET and expect the data to be a certain type.

The advantage of TypeScript is that it can check variable, property, argument and function/method return types during compilation, catching errors that would possibly be thrown during run time. TypeScript cannot anticipate the shape of an API response, hence we cannot rely on TypeScripts type checking and need to do this manually.

interface Car {
@tjunghans
tjunghans / error_handling_promise.md
Last active May 9, 2017 12:58
Promise Error Handling

Promise Error Handling

  • Errors can be handled in a synchronouse fashion
  • You can throw an exception in a Promise
  • You can reject a promise with an exception
  • You can catch an exception with Promise catch

Throwing and Rejecting Errors

Example 1: Throwing an Error

@tjunghans
tjunghans / debug-log.js
Created January 27, 2017 10:32
Debug Logging
function log(value, label = "-") {
console.log(" ");
console.log(" ");
console.log(label, JSON.stringify(value, null, " "));
}
@tjunghans
tjunghans / Google-Chrome-User-Agent.sh
Last active January 17, 2017 10:13
Start Google Chrome with different useragent
# Run Chrome as IE11
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-agent="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; Ypkch32; rv:11.0) like Gecko"