teleren/devto huggingface dataset:
Converting CSV string to a 2D array of objects in ES6
Tags: javascript
Published: 2020-03-01 16:53:01


## Converting CSV string to a 2D array of objects in ES6

In this article I will explain how to convert a comma-separated values (CSV) string to a 2D array of object using Javascript.

![](https://cdn-images-1.medium.com/max/3300/1*78xdOOxeMwV-_8s-kVPH4w.jpeg)

Let’s say you have a CSV list of users ordered in three columns: id, name and email and you want to convert it to JSON to send it over an API for example.

First we’ll set up a function that takes in two parameters: a string and the delimiter by which we need to divide the rows by. Then we grab the title by slicing the first row and splitting it by our delimiter. If our delimiter is not set, we’ll set it to a comma by default.

{% gist https://gist.github.com/sanderdebr/b7988a6c3cc6d68aac152244fbd9b7d5 %}

Now we have the titles in an array, let’s get the rows inside an array. We do this by mapping over our rows array and splitting each row by our delimiter.

{% gist https://gist.github.com/sanderdebr/c6d119407ea6a8a85f0edb88aa61f2f6 %}

Now comes the exciting part. Inside our map loop we will convert the current row to an object by running the reduce() function on our titles array. This way we can set the correct value for each title. Then we’ll return our created object back and repeat the process for every row.

{% gist https://gist.github.com/sanderdebr/012d9d1b7c734d60feb79c31de796f81 %}

Great! Let’s refractor our code and make it shorter. Also we can test it with a different delimiter.

{% gist https://gist.github.com/sanderdebr/66b72fccf320a037425cdec9f54d0a34 %}

That’s it! Hope you’ve learned something from this short article.
Revealing module pattern in Javascript
Tags: javascript
Published: 2020-03-01 16:49:39


## Revealing module pattern in Javascript

![](https://cdn-images-1.medium.com/max/12000/1*ewT3zoPntM1edKtNUUp1Jw.jpeg)

Design patterns are crucial for writing maintainable, readable and reusable code. There is a diverse list of design patterns we can use with Javascript. In this article I will provide an intro to the the revealing module pattern, which is useful in many cases.

Although ES6 modules have replaced this technique and have been implemented in today’s major browsers, it is still useful if you are not using a transpiler.
>  A design pattern is a term used in software engineering for a general, reusable solution to a commonly occurring problem in software design.

First we wrap out function inside an IIFE (immediately invoked function expression) to create a local scope for our functions and variables.

const myWidget = (function() { ... })();

With this function we can return an object referring to methods that we want to expose publicly. These public methods are the only ones who have access to our private methods and variables inside our myWidget function.

{% gist https://gist.github.com/sanderdebr/daa038902b4bea367822b8d1abe697ea %}

In this example, we are getting the likes of Jenny and also adding a like called ‘travel’. Outside our module, we are only allowed to call the myWidget.getLikes() method, we do not have access to the data object or the addLike method which are private.

## Advantages
It allows us to write more consistent code and also makes clear which variables and functions are accessed publicly.

## Disadvantages
When you have a private function that refers to a public function, you can not override that public function when you want to change or update your module. This is why modules created with the Revealing Module pattern may be more fragile than modules from the original module pattern.

##ES6+
With the introduction of the **let **and **const** keywords we are able to create block scoped pieces of code to make sure our variables are private. Before this was only possible inside a function or IIFE (immediately invoked function expression). Also we can use the import and export declarations to divide our code up into modules and declare local variables. Make sure to use a transpiler because to support all browser, e.g. Babel. Or use a bundler that already has a compiler included, e.g. webpack or pacel.
Windows update error 0xC1900101 - 0x30017
Tags: software
Published: 2020-03-07 19:24:43

---
title: Windows update error 0xC1900101 - 0x30017
published: true
date: 2020-03-01 16:41:49 UTC
tags: software
canonical_url: https://siderite.dev/blog/windows-update-error-0xc1900101-0x30017/
---

  I had tried to install the latest version of Windows 10 (at this time 1909, the September 2019 version), but it had failed with a blue screen. I kind of ignored it, because I thought they will probably fix it or maybe it's because my laptop is new and so on. But recently I got this warning in Settings Windows Update: "_You’re currently running a version of Windows that’s nearing the end of service. We recommend you update to the most recent version of Windows 10 to get the latest features and security improvements_".

  So I tried to install it again. Same thing: a blue screen with a creepy smiley telling me it has failed to boot, with a stop code of "MEMORY MANAGEMENT" at FIRST\_BOOT when BOOTing. Well, no shit, Sherlock! I tried to install it using the Media Creation Tool (which I recommend when you have Windows Update issues because you can download the update and save it into an ISO, so you can try it again and again without redownloading everything) and I got a more specific error: " **0xC1900101 - 0x30017**". What does it mean? No one knows, but it led me down a rabbit hole of people having a lot of different issues.

  This post will not discuss every single problem out there, you can search for yourself, I only wrote this because in some obscure corner of a forum I saw one person saying he solved by uninstalling Diskcryptor, a software that I had also installed, but never used. Once I uninstalled it, the update went without a hitch.

  So, summary:

- if you have Diskcryptor, uninstall it. You can re-install it later.
- download the [Media Creation Tool](https://www.microsoft.com/en-us/software-download/windows10 "The Update Assistant can help you update to the latest version of Windows 10. ") for your service pack
- tell it to download in an ISO file
- mount the ISO and install from there
- check what error you get
- Google for it until you find someone having had the same specific problem
Musicians! I made a random scale picker: Box of Scales
Tags: showdev, offtopic, watercooler
Published: 2020-03-01 15:57:59

**Website:**&nbsp;&nbsp;&nbsp;&nbsp;[https://boxofscales.com](https://boxofscales.com)
**Twitter:**&nbsp;&nbsp;&nbsp;&nbsp;[@boxofscales](https://twitter.com/boxofscales)

Made this initially for my own personal use for practising scales for exams. Figured it might be useful to others so I've unleashed it upon the internet so you too can improve your daily scale practice (that you definitely do, oh yes, every day...).

Just select what you want included and it will shuffle all combinations.

The only mildly interesting technical part is the example of the scale is dynamically generated each time rather than being a static image.

I will at some point open source it, but as is usually the case with unplanned projects it could do with a tidy up first.

If anyone uses it and finds an issue please do [Tweet/DM](https://twitter.com/thatonejakeb) or message me here and let me know. Equally, if it is of use and you've any feature requests let me know!
PHPの include と require の違いについて
Tags: php, japanese
Published: 2020-03-01 15:33:11

---
description: "PHPで外部モジュールの読み込みに利用する include と require の違いを解説します。"
---

PHPで外部モジュールを読み込む際に利用する `include`, `require` の違いです。

## include と require の使い分けまとめ

指定したモジュールが存在しない場合の挙動が異なります。

- `include` の場合、Warning になりスルーされる。
- `require` の場合、Fatal error となり処理が終了する。

外部モジュールを読み込んだ後の処理が、外部モジュールに依存しているかどうかによって使い分けましょう。

依存していない場合は `include`、依存している場合は `require` です。
基本的には`require`でいいかと思います。

## include と require の実際の挙動を検証してみる

以下のコードを実行して、実際の挙動を確認してみます。

```php
<?php

include('foo');
require('bar');
echo 'Hello';
```

```shell
$ php index.php
Warning: include(foo): failed to open stream: No such file or directory in /Users/shootacean/github.com/shootacean/sandbox/php/include-require/index.php on line 3

Warning: include(): Failed opening 'foo' for inclusion (include_path='.:') in /Users/shootacean/github.com/shootacean/sandbox/php/include-require/index.php on line 3

Warning: require(bar): failed to open stream: No such file or directory in /Users/shootacean/github.com/shootacean/sandbox/php/include-require/index.php on line 5

Fatal error: require(): Failed opening required 'bar' (include_path='.:') in /Users/shootacean/github.com/shootacean/sandbox/php/include-require/index.php on line 5
```

- `include`では、Warning となりますが、次の処理へ進むので`require`が実行されます。
- `require`では、Fatal error となり処理が終了するので、`echo 'Hello';`は実行されません。

ビジネスロジックのコアな部分の外部モジュールを利用する際などには、  
`require`を利用することでモジュール読み込み時点で致命的なエラーに気づくことができます。

ビュー層などの致命的な問題にならない箇所では `include` でいいかと思います。

以上、PHPの `include` と `require` の挙動の違いについてでした。
Python continue statement
Tags: python, beginners
Published: 2020-03-01 15:47:50

In <a href="https://python.org">Python</a> code you can repeat code using loops, the most common being a for loop and a while loop.

Python continue keyword is used to jump out of this cycle, and the <a href="https://dev.to/libertycodervice/python-break-statement-4ki5">break</a> keyword out of the cycle.

The `continue` statement is used to tell Python to skip the remaining statements in the current cycle, and then proceed with the next cycle.

The continue statement may be used in a <a href="https://pythonprogramminglanguage.com/while-loop/">while loop</a> and <a href="https://pythonprogramminglanguage.com/for-loops/">for loop</a>.

Python language continue statement syntax is as follows:

```       
    continue
```

## Flow chart:

The control flow graph (flow chart) below shows the continue use:

![python continue statement](https://dev-to-uploads.s3.amazonaws.com/i/knks3huh9rrxwv5r2m7b.jpg)

## Continue Example

The example below uses continue to break out of the cycle, in both the for and while loop.

```python
#!/usr/bin/python

for letter in 'Python': # first instance
   if letter == 'h':
      continue
   print('current letter:', letter)

var = 10 # second instance
while var> 0:
   var = var -1
   if var == 5:
      continue
   print('current variable values:', var)
print("Good bye!")

```

The results of the above examples:

```
current letter: P
current letter: y
current letter: t
current letter: o
current letter: n
current variable values: 9
current variable values: 8
current variable values: 7
current variable values: 6
current variable values: 4
current variable values: 3
current variable values: 2
current variable values: 1
current variable values: 0
Good bye!
```

**Another example**

Python continue statement can be used to skip certain cycle, only the odd-numbered print between 0-10:

```python
#!/usr/bin/python

n = 0
while n <10:
    n = n + 1
    if n% 2 == 0: # If n is even, execute the continue statement
        continue
    print (n)
```
The program outputs:
```
1
3
5
7
9
```

**Related links:**
* <a href="https://gumroad.com/l/dcsp">Python book and course</a>
* <a href="https://pythonbasics.org/">Python tutorial</a>
Evolution of MERN Stack 
Tags: react, mongodb, express, node
Published: 2020-03-01 15:41:27

# MERN Stack

The MERN Stack is the javascript that is increasing more faster than any stack ever. This stack has a group of technologies that one takes its role and they are very important in their tasks.

## Technologies

There are 4 Different technologies in the stack which are MongoDB, Express, React and Node.


React is a front-end Javascript library that is moving fast to the end line of developer's hearts, It was developed by Facebook. It came to existence in 2011 by a software engineer called Jordan Walke. At that time, The React crew and Facebook decided to make it an opensource in May 2013 at the JSConf US.

In 2015 at the JSConf, They announced the React Native that helps to develop mobile apps on different Operating Systems such as Android and IOS.

MongoDB is a NoSQL database that is fast in performance and it is also bringing more applications to life, and it very reliable.

Express is also a library that works on the Backend and it is also becoming more popular.

Nodejs is the technology that holds the Backend and it works well with Express.

In my opinion, I would advise everyone who wants to go far with javascript, they could go with the MERN Stack because it is awesome.

                                        -- Happy Coding --
Record Output Audio via Terminal
Tags: linux, audiovideo
Published: 2023-01-06 01:37:54

---
title: Record Output Audio via Terminal
published: true
date: 2020-03-01 15:38:06 UTC
tags: Linux,AudioVideo
canonical_url: https://brandonrozek.com/blog/recordoutputaudio/
---

This post is specific to `PulseAudio` on Linux.

I know of GUI based solutions like [PulseAudio Volume Control](https://freedesktop.org/software/pulseaudio/pavucontrol/) that lets you set up monitor devices. But, what if you want to do this through the terminal?

Luckily, [b-ak](https://askubuntu.com/a/850174) on AskUbuntu gave an elegant answer to this question!

First make sure you have `pulseaudio-utils` installed,

```
sudo apt install pulseaudio-utils

```

Next we need to search for the speaker we wish to monitor

```
pacmd list-sinks | grep -e 'name:' \
                        -e 'index' \
                        -e 'Speakers'

```

It will output something similar to this:

```
  * index: 0
        name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
                analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)

```

From here note the name in `<>` of the speaker you wish to monitor. For example for my output above, I wish to monitor `alsa_output.pci-0000_00_1b.0.analog-stereo`.

Next we will use the `parec` command to record the raw audio stream from the PulseAudio server.

```
parec --device alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | encoder_command

```

Notice the addition of `.monitor` at the end of the device.

## `lame`

For the `encoder_command`, b-ak used `lame`.

```
lame -r -V0 - out.mp3

```

This command takes in a raw pcm `-r` and enables variable bit rates for the highest quality `-V0`. From there it encodes it and puts it in `out.mp3`.

Now `lame` actually makes a couple assumptions about your raw pcm if you didn’t specify additional arguments:

- The Raw PCM is formatted in signed 16-bit little endian samples
- The Raw PCM has 2 channels

If you’re assumptions don’t meet the above, then you will need to add additional arguments.

## `ffmpeg`

We can replace `lame` with the more featureful `ffmpeg` if we take note of the same assumptions above.

```
ffmpeg -f s16le \
       -ac 2 \
       -i pipe:0 \
       -b:a 0 \
       out.mp3

```

Where we can replace the `.mp3` with whatever file extension `ffmpeg` supports.

Now to show the entire command

```
parec --device alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | \
  ffmpeg -f s16le \
         -ac 2 \
         -i pipe:0 \
         -b:a 0 \
         out.mp3

```
Python break statement
Tags: python, beginners
Published: 2020-03-01 15:31:33

The <a href="https://python.org">Python</a> break statement, like in C or the C++ programming language, breaks or closes a <a href="https://pythonprogramminglanguage.com/for-loops/">for loop</a> or a <a href="https://pythonprogramminglanguage.com/while-loop/">while loop</a>.

The `break` statement can be used to terminate a loop statement, i.e., False condition or loop condition has not yet been completed, will stop the execution loop.

The break statement can be used in a while and for loop.

If you are using nested loops, break statement to stop the execution of code gets very confusion, it stops the innermost loop.

**Python language break statement syntax:**
The syntax for the break statement is: (*drum rolls*)
```python   
    break
```
**flow chart:**

![break statement](https://dev-to-uploads.s3.amazonaws.com/i/jrq6oij9bpc383annjgl.jpg)

**Example:**

The example below creates two loops, both which are stopped using the break statement. In the first example we use <a href="https://pythonbasics.org/strings/">strings</a>, in the second example a plain variable counter var.

```python
#!/usr/bin/python
 
for letter in 'Python': # first instance
   if letter == 'h':
      break
   print('current letter:', letter)
  
var = 10 # second instance
while var> 0:
   print('current variable values:', var)
   var = var -1
   if var == 5: # var is equal to 5 when the variable loop exits
      break
 
print("Good bye!")
```
The results of the above examples:
```    
current letter: P
current letter: y
current letter: t
current variable values: 10
current variable values: 9
current variable values: 8
current variable values: 7
current variable values: 6
Good bye!
```
Learn How to Display Recent Posts from a Specific Category Without Editing the WordPress Theme files
Tags: latestposts, php, wordpress
Published: 2020-03-01 15:35:03

---
title: Learn How to Display Recent Posts from a Specific Category Without Editing the WordPress Theme files
published: true
date: 2020-03-01 15:19:45 UTC
tags: Latest Posts,PHP,WordPress,php
canonical_url: https://robdoylecreative.com/learn-how-to-display-recent-posts-from-a-specific-category-without-editing-the-wordpress-theme-files/
---

When building your WordPress websites have you ever wanted to display recent posts from a specific category without going under the hood and editing the theme files? Diving into the code isn’t for everyone especially if you only want to implement this on a small area of the website such as a widget area. In […]

The post [Learn How to Display Recent Posts from a Specific Category Without Editing the WordPress Theme files](https://robdoylecreative.com/learn-how-to-display-recent-posts-from-a-specific-category-without-editing-the-wordpress-theme-files/) appeared first on [Rob Doyle Creative](https://robdoylecreative.com).
Opinions on which to pick C++ or Java for GUI project?
Tags: discuss, java, cpp, help
Published: 2020-03-01 15:11:45

Hey fellow Devs!

So here the thing I'm currently enrolled in ComputerScience degree in University. 

Basically this semester I will have to make a project with this limitations : 
 - Must have a GUI.
 - Implement at least one of the `Search` and `Sort` algorithms.
 - Must be written in one of the following : `C#`, `C++` or `Java`.

after some search here and there I found this answer {% stackoverflow 3361568 %}

this answer is quite old and the release of `DotNet Core` made possible to create cross-platform apps using `C#`, but I'm dropping C# because I feel like C++ is more powerful somehow and I have basic understanding of it(I rate myself as above beginner in C++) I feel a bit comfortable with it, also I'm considering Java even that I will have to learn it first, because most of the internet says it's the best choice for enterprise-level apps (I'm not sure what Enterprise-level means :D) but if I learned it will be more helpful in the future right? 


One last thing, If I'm gonna use C++, I will learn and be using the Qt framework, I tried my luck with other ones but mostly fail not sure because that I run on windows or the lack of information on how to use 'em .
Python is string?
Tags: python, beginners
Published: 2020-03-01 15:11:00

In the <a href="https://python.org">Python</a> programming language, everything is an <a href="https://pythonbasics.org/class/">object</a> including strings. (Yes, everything!)

Python text objects (<a href="https://pythonbasics.org/strings/">strings</a>) are created using the `Class String`. So how can you determine if an object is created from the String class?

You can think of using the method **type()**, which returns the type of object.

```python
      >>> def isExactlyAString(obj):
          return type(obj) is type( '')
      
      >>> isExactlyAString(1)
      False
      >>> isExactlyAString('1')
      True
      >>>
```
and also
```python
      >>> def isAString (obj):
      try: obj + ''
      except: return False
      else: return True
           
      >>> isAString(1)
      False
     >>> isAString('1')
      True
      >>> isAString({1})
      False
      >>> isAString(['1'])
      False
      >>>
```
Although there are no problems with the ideas and methods we can use, there is a better way: **isinstance (obj, str)**
```python
Python 3.7.5 (default, Nov 20 2019, 09:21:52) 
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def isAString(obj):
...     return isinstance(obj,str)
... 
>>> isAString(1)
False
>>> isAString('1')
True
>>> 
```
SuperPyOS- intro
Tags: python, linux
Published: 2020-03-01 15:08:05

# intro ....

---

Not one for introductions, here goes.



6 months ago, i had begun to make what hadn't been made before. SuperPyOS- the 'OS written in python'.

Then when I revived it a few weeks ago. I got another person on glitch.com to help, and at that moment we began to turn it into a fully fledged linux distro. Or something like that.


------

How did we do it?- simple things like boolean logic and input are essential to this project. We split the project into parts:

1. Them pythonic scripts that act as the bootloader
2. The main script that houses our terminal
3. The programs- languages, configuration etc.

-----

I hope this series will help you build a simple OS in no time!

Source!: https://glitch.com/~python-os
About confidence, code, and tests
Tags: tdd, testing
Published: 2020-03-01 15:05:54

Whether you're reading a classic like "Test-driven Development by Example" by Kent Beck or a yet another article on medium. When it's about testing, there's always some talk about confidence. That made me think.

> Can you be confident about your code when you don't have tests?

The question seems ridiculous. Of course, you can. Millions of developers out there are. At least I was. Well, I still am. But something has changed.

Although I'm a big advocate of TDD, I wasn't born like that. Actually, I came pretty late to the party. I've started coding as a kid about 30 years ago and have been working for the past 20 years as a professional. But it wasn't until 10 years ago that I got into automated testing. Given that, I wrote a lot of code without any tests and for sure felt confident in doing so.

Precisely because I wrote a lot of code, I was able to build confidence. With every year, with every project and with every mistake I grew experience and with it came confidence. But still, nowadays I rarely write anything that's not test-driven. When I do, it's usually a one-off job or prototype. And while some people claim that they have a hard time coming up with a test first (or at all), I get anxious when I don't.

Tests have taught me one thing: Even though I feel confident that I won't break anything, I will. It might not happen often, but when it does, the red bar will hit me unexpectedly. It's a funny little feeling when it happens that is hard to describe. But I'll try it anyway:

Imagine having deployed a new release to production. Your phone rings just a few minutes later. It's your client yelling about something that's broken. Adrenaline kicks in. While they are still explaining the issue you know exactly _what_ is broken, and _why_ it's broken, and you hate yourself because it's such an obvious thing. Well, maybe that's overly dramatic, but you get the idea.

Now take away all the bad elements and you're left with a harmless little "gotcha". The instant you see the red bar, you probably still know what's broken and why but it doesn't do any harm. You fix it and move on.

Let's get back to the original question. Can you be confident without tests? Of course, you can. But maybe you shouldn't. Reading about the percentage that automated tests may drop your defect rate is nice, but seeing that it actually does was a game-changer for me. There's a chance that I'm just a lousy programmer who is overly confident, but with TDD, I found something that works for me. Maybe you should give it a try, too.