Posts

What is Base, Local & Remote in Git merge

Image
When you use a merge tool for Git and you have conflicts you often see these three versions of a file. This is called the three-way-merge. BASE LOCAL REMOTE So what are these files exactly? Imagine you have a branch. While you're working on the code, someone else has already changed the code in the main branch. Now you'll have a conflict if you merge your code into the main branch. The picture above emphasizes the points that are involved into the merge. GREEN : The common anchestor of the change. This is the BASE. RED : Your changes to the code. This is the REMOTE. ORANGE : The code change of someone else. This is the LOCAL. BLUE : The end result file after the merge. Here a more detailed illustration: Sometimes you will fallback to a two-way merge e.g. in cases where you or the other part deleted a file. Some tools refer them as "ours" or "theirs" ours => LOCAL theirs => REMOTE CONFISUNG NAMES? I personally find the naming confusing because why the h...

Asynchronous Nunjucks with Filters and Extensions

Image
The Problem Nunjucks was developed synchronous. The architecture behind is synchronous. So if you use nunjucks everything is fine until you hit an asynchronous problem. One easy example is: You want to have a method to download a data as json from a server That is easy to solve, normally. You download the data before creating the nunjucks context and pass the data to nunjucks after download. The problem arises when you don't know the source of the data in front. An example: {% set dataSource = userSelection %} {% set data = loadData('https://mydomain/sources/' + dataSource + '.json') %} The userSelection is e.g. a value from a dropdown on an html page. This can have multiple values. Now you have to download the data while rendering the nunjucks template, because you don't know the value of the "dataSource" variable upfront. Nunjucks Filters Nunjucks Filters are making the language more flexibel. Filters are nothing else then a function. In Nunju...

Basic React Hooks explained

Image
What are React Hooks? The preferred way to create components in React nowadays are functional components. React Component often have an inner state. They show an image or a text or other UI elements depending on user actions. User actions like clicking a button can change the inner state of a component. In the early days using "evil" 🙃 class components it was easy to hold the state within the component. You had a "state" class property and a "setState" class method to change the state. import React,{Component} from 'react'; class App extends Component { constructor(){ super() // Here I set sth. in my state this.state={ text : 'Welcome to Barbarian Developer' } } private sayGoodbye(){ // here I modify my component state this.setState({ text:'Bye Bye Earthling' }) } render() { return ( <div> <h1>{this.state.text}</h1> ...