teleren/devto huggingface dataset:
Lists 
Tags: dlang, csharp, java
Published: 2020-03-10 02:57:44

In this article I will be using list as the concept of sequence of items and not a specific implementation.

If we take C# as an starting point, specific implementations would be:

* List
* Array
* ArrayList
* LinkedList

The general list concept in C# is [IEnumerable](https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerable?view=netframework-4.8). Objects implementing this can be used where processing a list is needed.

Note that not all code examples are valid, this will help me focus. Use the linked documentation to get correct implementation. 

```csharp
// C#
public class MyList : IEnumerable {
    IEnumerator IEnumerable.GetEnumerator() {
        return new MyListEnumerator(...);
    }
} 

public class MyListEnumerator : IEnumerator {
    public bool MoveNext()
    {
       ... 
    }

    public void Reset()
    {
       ... 
    }

    object IEnumerator.Current
    {
      ... 
    } 
} 
```

The actual iteration is handled by a IEnumerator which needs to be given what to iterate. 

Java calls their's [Iterable](https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html) 

```java
public class MyList : Iterable {
    Iterator iterator() {
        return new MyListEnumerator(...);
    } 
} 

public class MyListEnumerator : Iterator {
    public boolean hasNext()
    {
       ... 
    }

    Object next() 
    {
      ... 
    } 
} 
```

Similar

* identify if there are elements 
* obtain an element 

Difference

* advancement either happens while getting the item or while determining if iteration should stop

In D it is called a [range]()

```dlang
public struct MyList Enumerator {
    bool empty() {...} 
    Object front() {...} 
    void popFront() {...} 
} 
```

Similar

* identify if there are elements 
* obtain an element 

Difference

* advancement is separate and not part of the other operations

Now I can tell you from experience that being able to obtain the current element can require having a temporary storage due to the underlying container or heavy computation. 

It may also appear that D is cheating, in both Java and C# have two classes defined, a container and then the iterator. D does have the concept of a container, however `foreach` does not operate at that level, it is expected that to slice the container to get its range. This reduces overhead to chaining ranges while enumerable needs to contain and then enumerate.
Lesson19Stuff
Tags: becomingacoder
Published: 2020-03-10 02:32:48

Lesson 19 Discussion 

Please create a blog on dev.to with the following information: 

1.Explain in your own words the lesson. 

2.Include the following questions: 
Why should you consider using an enum over using a String or an Int to identify options? 

Today’s lesson was Enumerations and Switches. How to use them and how to shorten code or using a shortcut for conditionals. An enumeration defines a common type for a group of related values. It lets you manipulate the values safely within the code. The values in an Enum are called cases and called with the “case” keyword. You can also match values in an Enum with a Switch statement. Switch statements can replace conditionals and allows for faster and less typing.  

You should use enums instead of strings or Ints to identify values that are related. This allows you to manipulate the values with less code and prevents coders from having to write a conditional statement for each value.
[Video] Build a MacOS installer for your desktop app.
Tags: nwjs, tutorial
Published: 2020-03-10 02:28:06

Hello, 

I recently started recording again videos for my playlist about creating a desktop app using NW.js and Vue[tify].

This in particular is a video where we create a MacOS installer, which we accomplish in less than 10 minutes.

Enjoy!

{% youtube LJ3f_iifVS4 %}

This is part of a larger content playlist where we basically go step by step building the cross-platform desktop app. You can see how the process is "in real life" as I like to refer to it. You can check it out [here](https://www.youtube.com/playlist?list=PLmJs3lfUmCdT9MyG60Oo6HM7xAn79vwZ0).
Pick your preferred monitoring memcached tool
Tags: php, linux, database
Published: 2020-03-10 01:44:27

Whether you don’t want to install any additional package or fancy more detailed statistics, your preferred monitoring tool will vary.

Let’s make a few assumptions first to better understand the context of this post:

Your database server is running Ubuntu/Debian.
You have one or several web nodes and at least one database server (alternatively you could have a primary/replica). memcached is installed on the remote database server.

The database server’s IPv4 address is 203.0.113.12 memcached is listening on its default port (11211) netcat is installed

Using netcat

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

In most Ubuntu-based distributions and Debian, netcat will be available by default. This allows to run commands such as:

$ echo stats | nc 203.0.113.12 11211
STAT pid 71
STAT uptime 6949
STAT time 1486379640
STAT version 1.4.21
STAT libevent 2.0.21-stable
STAT pointer_size 64
(snipped)
END
How to run SPA webapp on Spring Boot 2.x
Tags: java, javascript, spring, spa
Published: 2020-03-10 01:33:41

TL;DR scroll down, get the sources below and taste it.

Most common web server with SPA flavor, All routes will forward to `/index.html`.
Yes. Spring boot also can do this. but it's pretty hard to figure it out until now. let's do this.

How much difficult to resolve this? 
touch `application.properties`? NO.
write `@Configuration`? NOPE.
write `@ControllerAdvice`? NAH.
Why don't think easy peasy lemon squeezy?

just write a class with `@Controller` and implements `ErrorController` interface.
that's all. here's the code!

```java
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class SpaErrorController implements ErrorController {

    @RequestMapping("/error")
    public Object error(HttpServletRequest request, HttpServletResponse response) {
        // place your additional code here (such as error logging...)
        if (request.getMethod().equalsIgnoreCase(HttpMethod.GET.name())) {
            response.setStatus(HttpStatus.OK.value()); // optional.
            return "forward:/index.html"; // forward to static SPA html resource.
        } else {
            return ResponseEntity.notFound().build(); // or your REST 404 blabla...
        }
    }

    @Override
    public String getErrorPath() {
        return "/error";
    }
}
```

Don't think other things, just compile and run.
You'll never see whitelabel error page and ALL routes will foward to `index.html`.
it's SPA style.

I'm using this solution in real world. ye... uhmm.. pretty good.

But remember, splitting front-end and back-end will be better choice; because of REUSABLE, comfortable deploying, other good point that you know.
Little Insights to Survive the Coding Bootcamp
Published: 2020-03-10 01:32:53

It seems like it was just few days ago I got the email from Juno saying that I have been accepted in their Web Development Immersive Bootcamp.  I was so excited that I was going to enrol in the best coding bootcamp in Toronto. But besides the excitement, there was always a part of me who was nervous of starting the journey as “coding bootcamp” was entirely a new experience for me. Previously, I survived earning a Bachelor degree in engineering and an MBA but all of those degrees were from traditional educational system; and almost everyone around me has been in these system. But before starting the bootcamp, I hardly knew someone who has survived the journey and could give me some first hand insights about it. So as a bootcamp survivor I thought of sharing some insights which might be useful for someone who is going to start their journey.

Preparation before Bootcamp:

Coding bootcamps are really intensive. You have to spend eight hours a day, five days a week; and sometimes after school hours and even the weekend for completing the project work due. There are lots of new concepts you come through everyday which you have to absorb  and apply  on your projects shortly. So the pressure of deadline is real and its going to hit you hard. To survive this pressure, I believe the bootcamp students should go over some of the study material at least once before starting the bootcamp. I found the resources available online and also some courses in udemy very helpful in this case. 

Eat Well, Sleep Tight, Meet Friends

During the bootcamp, coding becomes  the core focus of  life. But those weeks when I didn’t prepared my weekly meal I ate junk foods, spent lots of money in restaurants. Those weekends that I spent doing only the homeworks and not meeting my friends and families, made me exhausted afterwards. And the sleepless nights didn’t let me concentrate on my class. So doesn’t matter how busy we are in the bootcamps, we should never forget to eat well, have a good night sleep and spending some time with our loved ones.

Psychological Training

I think  the hardest thing in bootcamp is to train our mind not to compare ourselves with others. Even if I tried to soothe myself telling that everyone’s journey is different and everyone has his or her own learning pace I had hard time training my mind with that philosophy. I am still trying  everyday to teach myself not feeling intimidated seeing other peoples progress but to feel rewarded when we learn a new thing make little progress everyday.
hostname of anchor element throws undefined exception when href attribute has non break space in IE11
Tags: ie11, dom
Published: 2020-03-10 00:42:35


IE11 で以下のコードで未定義のエラーが発生する

```js
var dom = document.createElement('a'); dom.href="http://example.com&nbsp;あああ"
dom.hostname
```

&nbsp;とマルチバイトをもつURLをhrefにいれた状態でhostnameを呼び出すと未定義のエラーが発生した。
Using 🎉Emojis💎 when naming Pull-Requests
Tags: todayilearned, git, github
Published: 2020-03-10 00:18:21

Today, I started my new job at [JStratégia](https://jstrategia.com/) as a mobile developer. For the first 4 hours, I worked on setting up my brand new Lenovo Thinkpad (never had one, they're sweeeeet !), getting my emails set up on both mobile and on the laptop, meeting the team...

And then I was explained for the remaining 2 hours how the neighboring team worked for the past 6 months, and it was a mindblowing experience.

One of the biggest revelations I had out of the many great practices they had within their git workflow, was to use emojis at the beginning of the title of the pull request. This might sound odd at first, but here's some examples :

If it's a feature, name it, for example :
`🎉 Mobile : Responsiveness to sales view`

If it's a bugfix, use this :
`🐛 Apache : Access to root from a regex pasted in url`

For adding tests :
`☑ Setup : Compat. Linux, Mac OS, Windows and Solaris`

In case you're upgrading a library the project depends on or adding new ones :
`📚 NPM : leftpad 2.0.2 to 2.1.4`

When it involves the documentation :
`🗒 Deployment : Extra troubleshooting`

This has multiple advantages :

## 1. It's fun

Well, duh. Emojis are fun. 💩

## 2. It's easier to give a meaningful, but descriptive title.

You can waste a lot of time trying to conjugate your sentences in a coherent manner, but here you'll keep it short and sweet.

## 3. It'll give quick-scan skills to reviewers

You won't feel guilty of writing "Fixed deployment bugs" and fear that any extra details will be glossed over if you add anything more, but reducing on details won't help either. Plus, there is now a clear distinction between category, sub-category and description.

## 4. You can count 'em !

When you'll be making a post-mortem, you'll be able to easily count emojis by making a search for them and counting the results for every time they come up. This means you can count how many times bugs, features, documentation and testing were worked on, and compare with past projects to get a feel of what's been prioritized the most.

So, what do you folks do at work to improve your git workflow ? I'd love to know !
Make Vim Default Editor For Git and OS
Tags: vim, git, vcs, linux
Published: 2020-06-16 16:12:45

---
title: Make Vim Default Editor For Git and OS
published: true
date: 2020-03-10 00:00:00 UTC
tags: vim, git, vcs, linux
canonical_url: https://tech.serhatteker.com/post/2020-03/default-git-editor-vim/
---

I prefer to write my git commit messages in __Vim__ instead of nano or emacs or anything. To set this 'globally', change your __Git__'s [core.editor]:

```bash
$ git config --global core.editor "vim"
```

If you also want to set __Vim__ for other programs as well, set the standardized `VISUAL` and `EDITOR` environment variables in your terminal resource file (`.zshrc`, `.bashrc`, `config.fish` etc.)

```bash
export VISUAL=vim
export EDITOR="$VISUAL"
```

All done!


#### P.S: 
If you wonder why both `VISUAL` and `EDITOR` set, please look at : [VISUAL vs EDITOR]


[core.editor]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#Basic-Client-Configuration
[VISUAL vs EDITOR]: https://unix.stackexchange.com/questions/4859/visual-vs-editor-what-s-the-difference
Wouldn't it be cool if DEV could render LaTeX?
Tags: meta, changelog
Published: 2020-03-09 23:43:01

Oh neat, you can.

{% katex %}
c = \pm\sqrt{a^2 + b^2}
{% endkatex %}

Here's the code to produce that snippet:

```liquid
{% katex %}
c = \pm\sqrt{a^2 + b^2}
{% endkatex %}
```

It's new and there will be kinks that need to be worked out.

Kudos to @maestromac for a really fabulous implementation.

{% github https://github.com/thepracticaldev/dev.to/pull/6237 %}

Happy coding!
Whiteboards as a Shared Resource
Tags: collaboration, learninpublic
Published: 2020-03-09 23:21:28

One of my favorite ways to get ideas out of my head is to start scribbling on a whiteboard. I love to make lists, draw diagrams, and connect things with arrows. It is wonderful for in-person collaboration too.

Whiteboards are great, which is why most offices have a few of them.

Whiteboards are generally a shared resource. And that can quickly become a problem. Now, I'm going to stop myself before I go down the path of some convoluted analogy about resource allocation, pointers, and modifying shared memory. I think many people can think of a time when they sketched a bunch of stuff out on the whiteboard and the next day it was just gone. All those ideas just gone.

Someone erased your hardwork. They probably didn't realize they were doing it. "That looks like the stuff that's been on this board for weeks," they thought to themselves.

Here is the best way I've found to deal with this issue. First, create a channel in your organization's communication tool called something like _whiteboardin'_. Then the next time you need to use a covered whiteboard, snap a quick picture and post it in that channel. The high-resolution photos that everyone's phones can take make it easy to zoom in to every detail. You no longer need to worry about tracking down the person who previously used it to see if they need a saved copy -- just assume they do and post it.

Get your whole organization's buy-in on doing this. Perhaps even post signs next to the whiteboards as reminders, "Before you erase..." Today you'll be saving someone's work, next week someone will be saving your work.

You might be wondering, why not put the impetus on the person who originally used the whiteboard to save their own scribbles if they are so important. I prefer the approach I've outlined because it creates a more cooperative mindset. It encourages empathy and values the work and time of your coworkers.

Save yourself some time, save your coworker's work, and get to whiteboarding before those ideas slip away.
A Plot Proposal for Frozen III
Tags: entertainment, browsers, chrome, firefox
Published: 2020-03-09 23:04:45

---
title: A Plot Proposal for Frozen III
published: true
date: 
tags: entertainment, browsers, Chrome, Firefox
canonical_url: https://macarthur.me/posts/frozen-three-plot-proposal
---

Kristoff, seeking a career more marketable than being an iceman, enrolls in a coding bootcamp in the Southern Isles, where a bitter and vengeful Prince Hans has been forced by his brothers to maintain a legacy Backbone application.

Faking a change of heart, Hans befriends Kristoff, hoping to leverage his connection to Arendelle’s icing industry in order to exact revenge on the kingdom. It works, and Hans convinces Kristoff to hire him to rebuild the ice delivery e-commerce platform.

Hans’ software exploits a performance vulnerability in Chromium browsers (used by the vast majority of the kingdom), causing every machine to get real hot every time a purchase is made.

Soon enough, the kingdom’s climate begins to get dangerously warm, feeding a vicious cycle: ordering more ice causes the kingdom to get warmer, which causes people to order more ice, and so on.

Elsa, Anna, and the gang embark on a mission to convince all of Arendelle to switch to Firefox.

                    (This is an article published at macarthur.me. [Read it online here](https://macarthur.me/posts/frozen-three-plot-proposal).)
If the Democratic Presidential Candidates Were JavaScript Packages
Tags: javascript, politics
Published: 2020-03-09 23:03:33

---
title: If the Democratic Presidential Candidates Were JavaScript Packages
published: true
date: 
tags: javascript, politics
canonical_url: https://macarthur.me/posts/if-democratic-candidates-were-javascript-packages
---

 **BernieSanders.js** - a helper library for making next-generation punch card programs for the browser.

**ElizabethWarren.js** - a probability and statistics library widely used in reservation casinos.

**AmyKlobuchar.js** - a highly opinionated alternative to ESLint, providing harsher, more demanding errors (no warnings).

**JoeBiden.js** - a battle-tested framework for building RPG games for the browser, featuring an API just as approachable to junior devs [as white devs.](https://t.co/ReXr7Njg53?amp=1)

**PeteButtigieg.js** - not really sure what it does or when to use it, but it’s popular up in South Bend.

**AndrewYang.js** - an inline podcast audio player that will literally pay you to use it.

**TulsiGabbard.js** - Russian asset bundler.

**MikeBloomberg.js** - a financial charting library embracing many of the exciting new features available in Netscape Navigator.

Got one I missed? [Make a pull request](https://github.com/alexmacarthur/macarthur-me/blob/master/src/posts/2020-01-19-if-democratic-candidates-were-javascript-packages.md) with your addition followed by “(contributed by Your Name)”, and I might include it.

                    (This is an article published at macarthur.me. [Read it online here](https://macarthur.me/posts/if-democratic-candidates-were-javascript-packages).)
Middleman build error
Published: 2020-03-09 22:45:27

Typing the middleman build command but I keep getting this error I have no idea how to fix it. if anyone can help please let me know.

usr/lib/ruby/vendor_ruby/builder/xchar.rb:111: warning: constant ::Fixnum is deprecated
       error  build/stylesheets/site.css
       error  build/javascripts/site.js
       error  build/index.html
       error  build/images/.keep
There were errors during this build, re-run with `middleman build --verbose` to see the full exception.
Creativity and imagination in programming
Tags: discuss, creativity
Published: 2020-03-09 22:37:38

When i was a kid i often immersed myself into the world of books. Early on it was the comics of Donald Duck, later on the marvelous world of Harry Potter and Lord of the Rings. I carried around the books of Harry Potter and  wanted to know everything about Duckburg.

I always liked the idea of people creating worlds and stories around them. Lego was another thing i immersed myself into. These bricks opened a new world for me to build from my imagination (and later in life build things from Harry Potter with my younger brother) and build things out of my own ideas.

Let me give you an example. A couple of months before my birthday i really wanted a pirate ship but since my birthday was far away i decided to build one with myself with the Lego i had. Even if it looked like any other ship, i remember i was really proud of having built that by my own.

This is why i love programming because you can create purely based on your ideas and imagination. 

It's also a powerful tool for creating solutions to problems (and sometimes to problems that don't yet exists).

I think Albert Einstein sums it up pretty good.

“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.”

― Albert Einstein


When i teach i try to tell my students to be creative problem-solvers and not just focusing on learning the latest JS framework.

I'm curious on how you view programming, please share in the comments!
Nevertheless, Sonja somehow managed to keep showing up
Tags: wecoded, beginners
Published: 2020-03-09 22:32:43

I somehow managed to avoid a tech career for 25 years.  It wasn’t “cool”, I had my sights on other paths, and I felt invisible to my CS instructor (although I loved the class) in college. I wasn’t convinced...

I somehow managed to find myself a close ally with all the IT departments of all the banks in which I worked.  “Can you test this?”, “Will this work the way you need it to?”, “Have I thought of all the scenarios for these bonds?”. I wasn’t moved...

I somehow managed to find errors in hard coded processes that, once reversed, recovered $250k in revenue.  I didn’t make the connection... 

I somehow managed to make a lateral move into technology to manage a service delivery team for a new sub-ledger project after maternity leave. It was amazing...and would have been so much better if I could just dig into the code myself, if I knew how it all worked, if I could help with the testing. But time for another baby...

I somehow managed to come across Codcademy and the future was laid out, shining in front of me!  But we moved. Across the ocean. And all the chaos of transplanting with a four year old and one and a half year old were mine to manage. I couldn’t find the time...

I somehow managed to finally (!) dedicate some quality time to learning: Udemy, Skillcrush and Free Code Camp are wonderful resources. I was on my way to a php conference after arranging child care for three days.  But I had a brain hemorrhage...

I somehow managed to recover 100% and again, found the beacon of a new career, where I can make a difference, work for what I am passionate about, and be a role model for my kids. I graduated from a coding bootcamp! 

This time, I will somehow manage - as I always do - to become a software engineer. I'm looking for my first dev job!