teleren/devto huggingface dataset:
Leaving Windows
Tags: ubuntu, development
Published: 2020-01-02 06:56:19

---
title: Leaving Windows
published: true
date: 2019-12-07 00:00:00 UTC
tags: ubuntu, development
canonical_url: http://jamessessford.com/blog/leaving-windows
---

Before I look at the reasons that got me to leave Windows, I must first state that I write this article from a position of extreme privilege.

I have a steady job that doesn't always require me to work extra hours so I have free time to play with different OSes and fortunate to have two laptops in the house that I could tinker with.

My girlfriend and I both had Windows machines, hers for college work and email, mine for web development. Both laptops are around five years old.

**Hers:**

```
- Toshiba Satelite
- AMD Dual Core
- 4gb RAM
- Windows 8
- 500gb hard drive
```

**Mine**

```
- Lenovo Thinkpad
- Intel Celeron
- 4gb RAM
- Windows 10
- 1tb hard drive
```

The Toshiba laptop had sat abandoned until college started and with not being updated regularly, it was impossible to get it back to a usable standard to work on. This caused it to be reabandoned and we shared one laptop for a couple of months.

Let's go back a week or two.

Whilst [developing on Windows](http://jamessessford.com/blog/leaving-windows), my average response time to serve a page was \> 20 seconds and the memory footprint for each page served was around 15mb (reported by Laravel Debugbar).

I was trying out Inertia.js and was heavily under the impression that I must have some disastorous config setup on my machine, either in the project or the way I'd set up PHP itself. I went through a lot of posts/articles online for fine tuning PHP and Laravel performance on Windows and tried several different ways to serve the application, all with little reduction in response time or memory cost.

The best experience I had with web development on Windows came using Laragon but I still felt it wasn't running smoothly enough that I was being productive.

I decided to flash one of the Raspberry Pi's and put the project on there and see if I could tweak it to run a little better. Debugbar reported a memory drop of ~12mb and the response time was down to milliseconds. It appeared the bottleneck was my laptop.

Let's jump back to the present.

Attempts to get both my machine to a state I was happy developing in and the Toshiba laptop just to be usable had burned out. I pitched the idea of a swap.

My laptop was decent enough for college work and I was willing to take a chance that I could put linux on the Toshiba and it be a comparable, if not better, experience to the Windows machine I was currently using. My expectations were completely blown away.

While not achieving the bar set by the Raspberry Pi, which didn't have VSCode or any of the other background services required to run the Windows laptop, the Toshiba reported \< 1s response time and ~5mb memory consumption for initial page load and then ~750ms response time there after.

The next little while will be spent rebuilding my development environment on an Ubuntu machine :)
Unable To Locate Package dotnet sdk 3.1
Tags: aspnetcore, dotnetcore, ubuntu, apt
Published: 2020-01-25 22:42:35

---
title: Unable To Locate Package dotnet sdk 3.1
published: true
date: 2019-12-07 00:00:00 UTC
tags: aspnetcore,dotnetcore,Ubuntu,apt 
canonical_url: https://solrevdev.com/2019/12/07/unable-to-locate-package-dotnet-sdk-3.1.html
---

## Unable to locate package dotnet-sdk-3.1

Every time there is a new release of [dotnetcore](https://dotnet.microsoft.com/download) I need to get it updated on the three environments where I develop and deploy code.

I develop and deploy on macOS, Windows and Linux (Ubuntu) and macOS’s homebrew and Windows’s chocolatey will update the version of dotnetcore for me, sometimes there is a delay but they will update them.

However, on my Ubuntu machine each release of dotnetcore I always have to manually intervene and install it manually.

If you follow the instructions over at [https://docs.microsoft.com/en-gb/dotnet/core/install/linux-package-manager-ubuntu-1904](https://docs.microsoft.com/en-gb/dotnet/core/install/linux-package-manager-ubuntu-1904%5D) you will get the following error message:

_Unable to locate package dotnet-sdk-3.1_

The issue is that page targets 19.04 and I am running 19.10

So, If you are me from the future wanting to know how to get the latest version installed and not want the waffle here is what you need to do

```powershell
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo apt-add-repository https://packages.microsoft.com/ubuntu/19.10/prod
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1
```

Success 🎉
Make node list into an array
Tags: javascript
Published: 2019-12-15 04:57:40

---
title: Make node list into an array
published: true
date: 2019-12-07 00:00:00 UTC
tags: JavaScript
canonical_url: https://coltborg.com/make-node-list-into-an-array/
---

Most of the time when I'm coding with [node lists](https://developer.mozilla.org/en-US/docs/Web/API/NodeList), I want to iterate through each of them and preform some action. My first thought is, "Node lists are \_like\_ arrays, I should be able to use the array methods like `.map()` or `.filter()` right?" 🤔

But every time it backfires because Node lists are actually objects.

```javascript
const nodeArray = document.querySelectorAll('p');

nodeArray.map(node =\> console.log(node); // ❗️TypeError: nodeArray.map is not a function
```
To quickly fix this, I could either use the `.forEach()` method instead of `.map()`.
```javascript
const nodeArray = document.querySelectorAll('p');

nodeArray.forEach(node =\> console.log(node); // ✅ That works!
```
Or I could quickly turn the node list into an array using the `spread operator`.
```javascript
const nodeArray = document.querySelectorAll('p');
const realArray = [...nodeArray];

realArray.map(node =\> console.log(node);
// ✅ That works!
```
KotlinConf 2019
Published: 2019-12-30 15:16:20

---
title: KotlinConf 2019
published: true
date: 2019-12-07 00:00:00 UTC
tags: 
canonical_url: https://www.geekytidbits.com/kotlinconf-2019/
---

This week I had the opportunity to attend [KotlinConf 2019 in Copenhagen, Denmark](https://kotlinconf.com/) with 4 other fellow colleagues at YNAB. It was a great time of learning new things, meeting new people, seeing the city of Copenhagen, and spending time with my fellow coworkers and friends.

Kotlin is not a language I use (yet) but at YNAB we are evaluating using its [multiplatform capability](https://kotlinlang.org/docs/reference/multiplatform.html) to enable writing code in Kotlin that can be compiled down to JVM (for Andriod), Native (for iOS), and JavaScript (for Web). The prospect of us being able to share code in this way is compelling so we want to learn more.

I walked away admiring the Kotlin language, impressed with its community, and hopeful for the future in regards to multiplatform support and features.

## Sessions I Attended

### Day 1

- Go multiplatform with Kotlin Workshop - Salomon BRYS

### Day 2

- Building Progressive Web Apps in Kotlin - Erik Hellman
- MPP in 1.3.X and beyond - Dmitry Savvinov & Liliia Abdulina
- What the F(p) is Kotlin? Shelby Cohen & Katie Levy
- Bridge the physical world: Kotlin/Native on Raspberry Pi - Qian Jin
- Your Multiplatform Kaptain has Arrived - Ahmed El-Helw
- Shipping a Mobile Multiplatform Project on iOS & Android - Ben Asher & Alec Strong
- Kotlin Native Concurrency Explained - Kevin Galligan

### Day 3

- Asynchronous Data Streams with Kotlin Flow - Roman Elizarov
- Kotlin Uncovered - Chet Haase & Romain Guy
- What’s new in Java 19: The end of Kotlin? - Jake Wharton
- Kotlin in Space - Maxim Mazin
- Do it in code (not YAML)! Unlock power of Kotlin DSL for Kubernetes - Fedor Korotkov
- Kotlin puzzlers, vol 3 - Anton Keks
Day 48 : The Point
Tags: hiphop, code, coding, lifelongdev
Published: 2019-12-06 23:44:55

_liner notes_:
- Professional : Spent the day working on my Prize Wheel App and Ninjas vs Pirates App. Fixing some small things. Also looked into something called OpenComponents. It's used to create micro-frontends. It's pretty cool. Also hung out with some team mates on a video call to talk about other things than work. haha.

- Personal : Did my laundry. It's been a lot cooler outside so I didn't need to mow the lawn. Had a guest on the last radio show so we didn't play as many tracks as normal so those will roll over into this week. Still got a little more pre-show work to do. Going to see if I can work on the Google Pixel Slate and see what else I can get done with it. I want to be able to edit some videos from the GoPro Max, but for some reason, although the GoPro app installs and loads, it crashes when I try to edit a 360 video. I'll see what I can work out. I want to get to the point where I can completely replace some laptops with the Slate.

![mountains of Hoher Kasten, Appenzell Alps, Switzerland under a cloudy sky](https://thepracticaldev.s3.amazonaws.com/i/xia6nsqyn1aig5wntpkg.jpg)

Got a full weekend ahead. I'll also be looking to ordering things for my new van. Pretty excited to pick it up next week!

Have a great night and weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube dGeksyMppi4 %}
⚡️ Lightning-fast EventSourcing projections
Published: 2019-12-06 22:58:43

Simplified summary of how projections are built when reading events.

Each single projection will now be able to scan and project **5M events per hour**. Really happy ❤️

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2hf3snmt7jh7a7d81gc8.png)

Cheers! 😊
Advent of Code 2019 solutions repository
Tags: adventofcode, contributorswanted
Published: 2019-12-06 22:43:06

A few friends and I made [a repository to share our 
AdventOfCode solutions](https://github.com/jkoenig134/AdventOfCode-2019/tree/develop) with the world and we're happy about any contribution!

So far we've got solutions implemented in:
- Clojure
- Go
- Haskell
- JavaScript (Node)
- Scala
- Java
- Kotlin

You may contribute new languages, add missing solutions or make alternative solutions for existing languages.

Happy coding!
Auto-Compiling markdown for a live preview
Tags: vim, linux
Published: 2019-12-06 22:38:48

Now, I really like markdown, but there can be some annoyances when it comes to viewing you'r finished product. In a lot of cases it is nice to see you'r result as you type, so we want:

* Auto compilation on save
* Refresh our PDF reader

# How I *thought* this would work

Initialy I thought I’d be using the amazing tool entr. entr is great because it monitors a files changes on disk. So the plan was compile with pandoc (as standard for markdown) through a shortcut in [n]vim, be watching for the file change with entr and then send a `-HUP` signal to my pdf reader (`mupdf` in this case) with `pkill`.

# How it actually worked

Both fortunately and unfortunately there is no need for entr in this scenario. After a bit of scrolling through :help in nvim I had gathered this info:

* Bash commands could be ran through the use of !
* `autocmd` runs ‘automatically when reading or writing a file’ (from `:h autocmd`)
* `BufWritePost` executes something 'After writing the whole buffer to a file’ (again from `:h autocmd`)
* `%` are the name of the file
* Using `*.md` after `BufWritePost` specifies file type
From this we can start to piece together what we need to put in out `.vimrc` (or `init.vim` in my case) This is what I came up with:

```
autocmd BufWritePost *.md !pandoc % -o %:r.pdf --pdf-engine=wkhtmltopdf && pkill -HUP mupdf
```

# Lets decompose that line:

* `autocmd BufWritePost` - Run after ! once the entire buffer has been writen to a file
* `*.md` - Only do this for markdown files
* `!pandoc % -o %:r.pdf --pdf-engine=wkhtmltopdf` - Use pandoc to compile the current file (`%`) to current filename without extention (`%:r.pdf`) using the `wkhtmltopdf` PDF engine
* `pkill -HUP mupdf` - Send mupdf a HUP signal ([source](https://t.umblr.com/redirect?z=https%3A%2F%2Funix.stackexchange.com%2Fquestions%2F425907%2Fhow-to-make-mupdf-automatically-refresh-a-document&t=MTA5MDM0OTFmNzZjMTdmOWQ1NWQyMzI0M2RkMzEzYjQ3NjYxZTg5MyxpMk9JYWJqaQ%3D%3D&b=t%3AeCQNsGnbqK13UGG5X5tNLA&p=https%3A%2F%2Fmanfromth3m0on.tumblr.com%2Fpost%2F189371861374%2Fauto-compiling-markdown-for-a-live-preview-now&m=1))

Well that was easy

Yes and no, it took me a while to actually come up with that but its actually a very simple and elegant solution. If it isn't working for you make sure you have `wkhtmltopdf` (or whatever PDF engine you use) and `mupdf` installed. Also make sure you’ve put it in the correct file (`.vimrc` for vim, `init.vim` for nvim) and reopened any [n]vim instance to make the changes

Thank you all for reading and happy writing, 
~ M
getSnapshotBeforeUpdate property not existent
Tags: react
Published: 2019-12-06 22:14:38

I'm attempting to use the method getSnapshotBeforeUpdate and I'm importing react in my file but I'm getting 'property doesn't exist' errors when using the code from React's documentation for maintaining DOM properties between component refreshes.

listRef = React.createRef();

    getSnapshotBeforeUpdate(prevProps, prevState) {
        const { current } = this.listRef;
        const isScrolledToBottom = current.scrollTop + current.offsetHeight >= current.scrollHeight;
        return { isScrolledToBottom };
    }

    componentDidUpdate(prevProps, prevState, snapshot) {
        const { isScrolledToBottom } = snapshot;
        if (isScrolledToBottom) {
            this.listRef.current.scrollTop = this.listRef.current.scrollHeight;
        }
    }

My problem is the .scrollTop and .offsetHeight are non existent properties of an unknown type. I was using this documentations: https://reactjs.org/docs/react-component.html#getsnapshotbeforeupdate

Any assistance to get these properties to exist is greatly appreciated :)
NaN (javascript) 
Tags: javascript, design, devops, devlive
Published: 2019-12-06 22:09:35

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/75flrz6di7vl246opb80.jpg)

NaN ====> Not_To_Number

Syntax
------
var val = Number.NaN;

Example 
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/pha02zenxbkqp9lehgyu.png)

Example from MDN:
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/hrwu1jgt3j211un88zou.png)

_Testing against NaN_
---------------------
perform a self-comparison:
NaN and another NaN, will compare unequal to itself. 
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/p0nh3cjjg4x1exlf22sg.png)


Using parseInt, parseFloat
It is also NaN when using parseInt, parseFloat.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ja9fu3nanmf75b2tau3p.png)
React Devs, Why don't you use React Native for Web?
Tags: react, reactnative, discuss, javascript
Published: 2019-12-06 20:51:48

---
title: React Devs, Why don't you use React Native for Web?
published: true
description: As a React dev, I use ReactDOM everyday and RN is fun but I've never considered React Native for Web
tags: react,reactnative,discuss,javascript
---

I use React in my job on a daily basis and that often bleeds into side-projects. I've even dabbled with React Native but I've _never_ considered React Native for Web... until I saw this tweet.

{% twitter 1202888933434122240 %}

I've been catching up on the [React Day Berlin 2019 livestream](https://www.youtube.com/watch?v=Mti0zaws1nI), and the talk by [Evan Bacon](https://dev.to/evanbacon) was **awesome**.

![Mind blown animated clip](https://media.giphy.com/media/xT0xeJpnrWC4XWblEk/giphy.gif)

I thought the [react-native-web project](https://github.com/necolas/react-native-web) was an oddity but after the presentation/live demo and looking into it more, React Native is really powerful and the being able to write code which is shareable on native platforms and the web is amazing. I had a preconceived idea of what RN and Expo could do but they are now shattered.

Evan asked the crowd the following question, I want to know your answer:
# Are you a React developer and why don't you use React Native for Web?
Linux on a Macbook Pro
Tags: linux
Published: 2019-12-06 20:24:43

So after some worries and horror stories, I install a dual boot Pop OS 19.10 (Ubuntu basically) on my Macbook Pro.   

If anyone is interested:

Pre-install steps:

1. I wrote the PopOS image to a thumb drive using [Etcher](https://www.balena.io/etcher/)
2. Under Disk Utility in OS X, I resized the apple partition down from 240GB to 170GB
3. It wrote for like 12 hours then it hung.  I checked the fdisk and it seemed fine so I killed the disk utility. 

Install:

1. I shutdown the computer and inserted the usb from step 1.
2. I reboot holding the Option key, and selected the EFI
3. It booted from the USB stick  
4. I selected manage partitions (*not* Completely remove and install fresh PopOS)
5. I created an EFI partition at the **end** of the disk of 500 MiB (type: Fat32)
   1. OS X had an EFI partition but it was only 200 MiB which is not large enough for PopOS
6. I created a Swap partition of 8GB (8192 MiB): type linux swap
7. I created a root partition of the remaining (~69GB): type ext4

Post Install

1. It rebooted to PopOS and I created my account and poof Linux on a macbook
2. You sometimes have to boot with the "option key" pressed cause OSX and boot loaders don't play well together.
Full Doctrine configuration via url
Tags: php, symfony, doctrine
Published: 2019-12-06 20:18:11

---
title: Full Doctrine configuration via url
published: true
description: the well hidden secret treasure (feature) of the query parameters in the url setting of doctrine.
tags: #php, #symfony, #doctrine
cover_image: https://thepracticaldev.s3.amazonaws.com/i/xsggmdwaj8hwzl1l1732.jpg
---
most of the time you need to set the following variables:
```
doctrine:
    dbal:
        dbname:               database
        host:                 localhost
        port:                 1234
        user:                 user
        password:             secret
        driver:               pdo_mysql
        server_version:       '5.6'
        charset:              UTF8
        url:                  mysql://db_user:db_password@127.0.0.1:3306/db_name
```
https://symfony.com/doc/current/reference/configuration/doctrine.html

there are quite a lot settings to configure doctrine in symfony. if you want to be flexible, your .env file or your 
environment variables get increased by many variables.


the main problem is that if you want to use sqlite for tests and mysql for dev & prod you need to define the `charset` and 
the `server_version`. where sqlite needs `UTF8` and mysql `UTF8MB4`. also mysql needs the `server_version`

an important info is, that url overwrites all other settings. so if your url starts with `mysql:` you don't need to set 
the `driver`

> A URL with connection information; any parameter value parsed from this string will override explicitly set parameters

info from `Configuration.php` of doctrine-bundle


a thing which is well hidden, is that doctrine supports query parameters, so you can reduce the config to this:

.env
```
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.sqlite?charset=UTF8
#DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name?charset=UTF8MB4&server_version=5.6
```

with this dotenv setting you also set the charset and the server version


so the other settings from above are reduced to this:

doctrine.yaml
```
doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'
```

links:

- cover image by MasterTux https://pixabay.com/photos/adventure-treasure-map-old-world-map-2528477/
What's new in Neoload 7.1?
Tags: performance, testing, loadtesting, neoload
Published: 2019-12-06 20:04:39

I am not sure how many of you using commercial tool for your performance testing needs. You can check it out Neoload whether it suit your needs.

Couple weeks ago, Neotys has released its next iteration of Neoload 7.1. I am going to throw you an overview of Neoload 7.1 features and other stuffs.

![What's new?](https://media.giphy.com/media/ftdke2OxN2IXe3iol3/giphy.gif)

# New Features

* Citrix Support
* Web tests
* Reservations
* More percentiles
* CI improvements
* Predefined Functions
* Summary Panel
* XML support for projects
* Bulk Delete/Duplicate in Populations
* ECMA 6 support in JavaScript engine

For more insights, please visit my [blog](https://qainsights.com/whats-new-in-neoload-7-1/).
Closures in Javascript
Tags: javascript, webdev, beginners
Published: 2019-12-06 19:39:05

Closure is basically an inner function which has access to variable of outer function.

Lets see an example:

```js
function outer() {
  var a = 123;

  function inner() { // this function act as closure
    console.log(a);
  }

  inner();
}

outer(); // it will print '123'
```

**The amazing thing is, even if the outer function returns the inner function then also inner function will have access to outer function variables**, in other programming languages if a function returns then it becomes ready for garbage collection or is completely removed from the heap, but in **Javascript** if there is closure then the parent function variables remain in the heap.

So the following code is also correct...


```js
function outer1() {
  var a = 123;
  return function() { // this function act as closure
    console.log(a);
  }
}

var func  = outer1();

func() // this will also print '123'
```

####Advantages of closures:

1. Callbacks implementation in javascript is heavily dependent on how closures work
2. Mostly used in Encapsulation of the code
3. Also used in creating API calling wrapper methods

####Disadvantages of closures:

1. Variables used by closure will not be garbage collected
2. Memory snapshot of the application will be increased if closures are not used properly

**Lets solve a famous interview problem based on closures**

When you are performing an async operation inside a loop in javascript make sure each iteration has its own respective value passed to the operation.
Lets see this question.

#####What will be the output of the following?
```js
const arr = [10, 12, 15, 21];
for (var i = 0; i < arr.length; i++) {
  setTimeout(function() {
    console.log('Index: ' + i + ', element: ' + arr[i]);
  }, 3000);
}
```
Surprisingly the output will be `Index: 4, element: undefined(printed 4 times)`

This happens because until the loop is executed completely the function inside `setTimeout` will not be called since it is async function, after the loop is executed functions stacked inside `setTimeout` will start invoking and will try to print the value of `i` which will be 4 by then, so how to print the correct value of `i` with out removing `setTimeout`

```js
const arr = [10, 12, 15, 21];
for (var i = 0; i < arr.length; i++) {
 (function(i) {
  setTimeout(function() {
    console.log('Index: ' + i + ', element: ' + arr[i]);
  }, 3000);
})(i)
}
```
**There are lot of problems solved by closures and some are created by closures, make sure to use closures wisely**

*Feel free to add you thoughts in the comments*

**Follow me** for more such content