teleren/devto huggingface dataset:
Advent of Code 2019 Solution Megathread - Day 23: Category Six
Tags: adventofcode, challenge, adventofcode2019, spoilers
Published: 2019-12-23 06:59:16

---
title: Advent of Code 2019 Solution Megathread - Day 23: Category Six
published: True
description: Nothing is more satisfying than proper cable management.
tags: adventofcode,challenge, adventofcode2019, spoilers
series: Advent of Code 2019 Solutions
cover_image: https://i.imgur.com/gWd3pyL.png
---

Looks like our worst fears have been realized: we've got to debug our network traffic.

### [Day 23 - The Problem](https://adventofcode.com/2019/day/23)

After perfecting our ridiculous shuffling algorithm (but know that [every day we're shuffling](https://www.youtube.com/watch?v=VJNBfBr-OGU)) we check in with our repair droids. They report that repairs are going well, but the damage is going to require us to diagnose the health of the network traffic.

So, lets boot up 50 of our best IntCode computers and hook them up to our rudimentary network setup and Part 1 has us trying to see who sends anything to network address 255.

Part 2 adds a NAT that checks to see if the network is idle.  If the network _is_ idle, then the NAT needs to send the last thing it saw sent to 255 to address 0. Our answer is the first repeated send.

### Ongoing Meta

#### Dev.to List of Leaderboards

* `120635-5c140b9a` - provided by [Linda Thompson](https://dev.to/lindakatcodes) 

 If you were part of [Ryan Palo](https://dev.to/rpalo)'s leaderboard last year, you're still a member of that! 

If you want me to add your leaderboard code to this page, reply to one of these posts and/or send me a DM containing your  code and any theming or notes you’d like me to add. (You can find your private leaderboard code on your "[Private Leaderboard](https://adventofcode.com/2019/leaderboard/private)" page.)

I'll edit in any leaderboards that people want to post, along with any description for the kinds of people you want to have on it. (My leaderboard is being used as my office's leaderboard.) And if I get something wrong, please call me out or message me and I’ll fix it ASAP.

There's no limit to the number of leaderboards you can join, so there's no problem belonging to a "Beginner" *and* a language specific one if you want.
Basic structure of SwiftUI project
Tags: swift, swiftui, ios, xcode
Published: 2019-12-23 06:57:22

Apple introduced [SwiftUI](https://developer.apple.com/xcode/swiftui/) in WWDC 2019 that enabled a new way to create user-interface of your iOS app.

Whenever you create your single view app using SwiftUI, You will get the following basic template of your app.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/9fqyrmhzy3rigq7q65ld.png)
<figcaption>SwiftUI default project structure</figcaption>

Let's discuss more about this all files,

**AppDelegate.swift**
After SwiftUI introduced, Appdelegate is only responsible for setting up external dependency and managing application data(ex. coredata).

**SceneDelegate.swift**
This is something new you can see in a project that is created using SwiftUI. SeceneDelegate is responsible for managing the way your app is shown. This contains the app transition methods that handle the app enter in the foreground, enter in the background, etc.

**ContentView.swift**
This is an initial view of your application. In this file, you can create your app interface using a declarative way. This is equivalent to ViewController that is being generated in the project that is created without using SwiftUI.

**Assets.assets**
As usual as previous, Assets contain all the images and colors that are used in our project.

**LaunchScree.storyboard**
This screen is displayed as a launch screen(splash screen) of your app. Nothing changes the way we setting up the launch screen previously.

**Info.plist**
This is a property list file that states all the system related settings like app name, app version, build number, etc.

**Preview Contain**
This folder includes one another asset catalog that is used at preview time in canvas.


Thanks for reading, Happy Holidays 🎅🎄
Side Project release! 🎉
Tags: showdev, android, kotlin, sideprojects
Published: 2019-12-23 06:47:37

### TL;DR; 
1. I did release music player 1.0.0 (first side project) - [link](https://play.google.com/store/apps/details?id=kr.heepie.musicplayer)
2. Please give me feedback.
3. Thank you guys, I want to improve my skill

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

### Hello! I’m heepie. 😀
I'm a junior android developer. And I’m getting a lot of info here. :)

I’m trying to improve my dev skills. So I did start a side project.
And I released 1.0.0! So I’m happy and I would like to receive the feedback.

#### Project Name
- Music Player - [link](https://play.google.com/store/apps/details?id=kr.heepie.musicplayer)

#### Pros
- Video background playback 
- Change play order in real-time 

#### Known issue
- Inappropriate video ratio: some video ratio is not appropriate

### Next 🙋‍♂️
I’ll post my dev log (planning, dev, design, fixBug etc).
Cloud Storage that ignores node_modules with a filter file
Tags: node, npm, cloudstorage
Published: 2019-12-23 06:45:04

---
title: Cloud Storage that ignores node_modules with a filter file
published: true
description: Ignore node_modules with a filter file using Tresorit cloud storage.
tags: #node, #npm, #cloudstorage
---

I have been using dropbox for a long time and even though I remain on the free plan I have never filled up the space. Important things live on there - and my laptop ever died somehow, I'd be okay.

But one frustration I have had is that there is no way to *not* sync certain folders - and this is a bigger problem with node_modules. Syncing thousands of files is ridiculously slow.

*Note: you can selective sync with a paid dropbox account. I'm not paying for that.*

This issue continued to perplex me. I did find pnpm which reduces amount of files used, but that didn't really solve the problem.

So I went searching for another cloud provider. Hopefully it would give me a folder that I could use - like `.syncignore` similar to how `.gitignore` files work.

### Trail and Error
I did try sync.com which offers a free package, is decent, and allows you to selectively sync via the UI. This is *okay*. But it's not ideal either.

Along the way I ran into another service from Switzerland that has a great feature set from [https://tresorit.com](tresorit.com)

During my first attempt using Tresorit I felt it was slow. But I tried again, and it was just fine. So I jumped in further, because I found out that Tresorit allows you to create a filter for syncing - kind of like a `.gitignore` file.

### Setting it up

**Step 1**: set up an account, install the desktop software, etc. 

**Step 2**: In the software, make a new Tresor (let's try ~/projects).

**Step 3**: Make a rule to filter all node_modules in every sub folder in ~/projects

*You can read through [this documentation](https://support.tresorit.com/hc/en-us/articles/217103697-Exclude-specific-file-types-from-sync-advanced-) which is buried a little bit on their site.*

```
cd ~/projects
mkdir -p .tresorit/Filters
echo "[Ignore] //node_modules" > .tresorit/Filters/local.filter
```

This will add an ignore rule for *all* sub-directories named `node_modules`. They won't be synced. Brilliant.

**Step 4**: Make a test project and see how it works.

```
cd ~/projects
mkdir test-project && cd test-project
npm init -y
npm install [some package]
ls
```

(you will see your node_modules folder here)

Now check in the Tresorit desktop app and see what was synced - you will not see your node_modules folder. You should see `package.json` and `package-lock.json`


---

Summary: Now you have one file with one rule in your ~/projects that filters all sub-directories name node_modules. Nifty.

Happy npm-ing!
Cryptocurrency Regulations: A Need or Necessity
Tags: cryptocurrency, blockchain
Published: 2019-12-23 06:41:31

Cryptocurrency space has come a long way from its early days of heavy scrutiny and being seen as an internet bubble. When Bitcoin was launched back in 2009, it remained nearly value less for almost an entire year, before seeing some price movement. The progress of Bitcoin, and the core software being open source led to the creation of several other cryptocurrencies in the following years. Most of these cryptocurrencies remained unknown from the broader public glare and only became popular after the bull run in Dec 2017.

Read Out More 👉 https://www.cryptoknowmics.com/news/cryptocurrency-regulations-a-need-or-necessity
Deploy 3scale on OKD3.11 all in one cluster
Tags: 3scale, okd
Published: 2019-12-23 06:35:07

There are multiple approaches to setup 3scale APIcast on Openshift origin. The one with yaml file is the common approach to setup 3scale account. Another approach is the easiest one where you need to pull 3scale image on local docker repository, then create new application in OKD from docker image by passing required parameters. I have used this approach to setup 3scale APIcast on my all in one OKD cluster on AWS.

- Pull the 3scale image to your local docker repository.

docker pull registry.access.redhat.com/3scale-amp20/apicast-gateway:1.0

In all cases, in order to setup 3scale you need to have 3scale account. Steps to create and configure 3scale account are given here (https://github.com/tnscorcoran/rhsso-3scale).

- Once configured 3scale account, you need 'ACCESS_TOKEN' along with your 3scale account URL which is called `ADMIN_PORTAL_DOMAIN`, to create secret which in turn used by your application for authentication. Create secret as discussed in the above approach.

oc create secret generic apicast-configuration-url-secret --from-literal=password=https://2040edXXXXXXXXX80d6@XXXXX-admin.3scale.net --type=kubernetes.io/basic-auth

Using 'ACCESS_TOKEN' and 'ADMIN_PORTAL_DOMAIN', you can configure another environment variable 'THREESCALE_PORTAL_ENDPOINT'.

THREESCALE_PORTAL_ENDPOINT=https://ACCESS_TOKEN@ADMIN_PORTAL_DOMAIN

- In order to create application using local 3scale docker image, you need to pass environment variables

oc new-app --docker-image=registry.access.redhat.com/3scale-amp20/apicast-gateway:1.0  --param CONFIGURATION_URL_SECRET=apicast-configuration-url-secret -e THREESCALE_PORTAL_ENDPOINT=https://2040edXXXXXXXXX80d6@XXXXX-admin.3scale.net

This should setup 3scale APIcast on your all in one OKD cluster.
The Formula for Software Estimation
Tags: productivity, management
Published: 2019-12-23 06:33:36

As an undergraduate student, I was amazed to know that there are software estimation formulas like COCOMO. I studied them, solved the problems in class but did not understand their impact on real-life projects or how to apply them in my projects.

When I join the industry I didn't know how to estimate my tasks. Formulas were of no help. This problem was most pressing:

a) When my superior (many times not adept in programming) asked me about the estimates for a software feature. I gave heroic answers which I regret later.

b) When I want to compare my productivity to other developers. I worked alone for a few years and I want to benchmark myself with the outside world and wanted to know if I work at the same pace as others.

So I laser-focused myself to learn about software estimation and read almost all top books on software estimation.

Reflecting on my experience with multiple projects and running a few experiments I know better than before (I wanted to write ‘I crack the code’ but let me be modest).

One key finding of the software estimation was refreshed when reading recently about the estimation method in SCRUM. The phrase: “story point estimates have no value outside the current team” catch my attention and motivated me therefore I am writing this email.

The basic unit of work in SCRUM is a story and team members collectively decide the estimate for the story on a scale. This estimate is called story points. This estimate is **relative** to that team. Another team might choose different story points for the same story. Because every team has a different skill level.

This is unique to software estimation and it is the critical mindset when working with software estimates. It is relative. There is no formula like Newton’s equation where you put in some parameters and it spits out the result.

Estimation is one of the areas where software engineering differentiates from other fields. The GANTT chart approach does not help here :).

So, are software estimation formulas useless? I use them after the completion of a project and measure the deviation. I have tuned them for my team (again 'relative') to get tolerably close estimates.
Cancel navigation on route change.
Tags: react
Published: 2019-12-23 06:18:42

I have a component which requires confirmation before navigating to another component. There is a Prompt component in `react router` which enables to ask confirmation before navigating to another component but I can't find any similar solution in `reach-router`. Is there any way I can ask the user for confirmation before they navigate to another route and cancel the navigation if the user responds no?
unexpected char: 0xFFFF
Tags: jenkins, pipeline, groovy
Published: 2019-12-23 06:15:56

---
title: unexpected char: 0xFFFF
published: true
description: Explaining why you get "unexpected char: 0xFFFF" from your Jenkinsfile.
tags: Jenkins, pipeline, groovy
---

Since I didn't find anything useful Googling, I decided write this short note.

When you get "unexpected char: 0xFFFF" from your [Jenkinsfile](https://jenkins.io/doc/book/pipeline/jenkinsfile/) (or any [Groovy](http://groovy-lang.org/) script), it basically means "Parse Error: Unexpected End of File". This is because Groovy's parser is implemented with [Antlr](https://www.antlr.org/) that uses Unicode noncharacter U+0FFFF ([link](http://www.unicode.org/charts/PDF/UFFF0.pdf) to pdf) to signal end of file.

In my case the problem was that I hadn't quoted a string. In retrospect the issue is obvious. When specifying environment variables, the values has to follow Groovy syntax i.e. strings need quotation marks unlike in shell.
12 Youtube channels to watch Javascript conference videos
Tags: javascript, techtalks, node
Published: 2019-12-23 04:52:39

## JSConf
JSConf is a series of JavaScript conferences from around the world and here we release the conference talk videos for free as fast as we can after every event.
Link: https://www.youtube.com/user/jsconfeu

## JSNation
The largest and longest-running JavaScript community in Benelux, running annual conference and meetups.
Link: https://www.youtube.com/channel/UCQM428Hwrvxla8DCgjGONSQ

## Google Chrome Developers
Making the web more awesome. Talk on Chrome Dev Summit, HTTP203, and state of the web.
Link: https://www.youtube.com/user/ChromeDevelopers/featured

## JAMstackConf
JAMstack conf around the world.
Link: https://www.youtube.com/channel/UC8bRyfU7ycLXnEBfvdorpUg/featured

## GOTO Conferences
Created for developers, by developers, GOTO Conferences is a series of software development conferences focused on gathering the best minds in the software community to bring the most interesting topics to light. This channel features video interviews and presentations from GOTO Conferences and GOTO Nights.
Link: https://www.youtube.com/user/GotoConferences/featured

## You Gotta Love Frontend
The largest international frontend conference in the Middle East and East Europe
Link: https://www.youtube.com/channel/UCU-fOxx_kT5OARG0KiksiCA/featured

## ng-conf
The world’s original Angular conference, with talks from the Angular Team and top experts from around the world.
Link: https://www.youtube.com/user/ngconfvideos/featured

## Pusher
Pusher talk on Javascript, Nodejs, React, etc.
Link: https://www.youtube.com/user/pusherapp/featured

## Cascadia JS
CascadiaJS is a two-day conference on the cutting edge of JavaScript. Browser, server,etc.
Link: https://www.youtube.com/user/cascadiajs/featured

## Dotconferences
Tech Conferences, re-invented. Talk on dotJS, dotGo, dotSwift, dotCSS, dotScale.
Link: https://www.youtube.com/user/dotconferences/featured

## Frontend United
Frontend United is a non-profit, developer-first, community-focused conference. Our aim is to connect frontend developers and designers from all kinds of backgrounds closer together to share knowledge, experiences, and ideas.
Link: https://www.youtube.com/channel/UC6Q3-JjgMpb4Uy6YgHdJSMw/featured

## JScamp
International single-track and two-day conference covering all about JavaScript and modern web technologies.
Link: https://www.youtube.com/channel/UCVLlWT1NZZEJs4A67XgObnQ/featured
Git Messages need Rebase 
Tags: git
Published: 2019-12-23 04:31:49

I feel like I get myself stuck in a circular argument in explaining the value of rebase interactive. It goes something like

You'll want to squash, reword, split these apart. Why? To get clearer messages about what is changing. Why? Because it helps you track your changes and makes it easier to rebase. 

It is not so much this is the argument I articulate. But as I help people work through a rebase I notice a pattern that people don't really know what is in their commits. Which makes sense, it is a lot of work for me to put changes together with intent.

When performing a rebase, commits which aren't targeted create a hectic conflict resolution. Many times changes are an experiment to see an outcome from a hypothesis. This is all important stuff and may need referenced in the experimentation. But when all is said and done it can be hard to see what happened and why.

The source code is in a working state, why spend so much time optimizing how to get there? Why communicate through commits when code review provides review of the end result and I can explain why we want this end state?

Personally I understand my changes better. When I try a first experiment often the commit message I wrote is wrong and misleading. If I am rebasing then a conflict on these commits could result in unnecessary work on something I didn't understand at the time and don't understand now.

Before I end it is important to note that understanding a change in this context does not mean understand why the changes worked.
It's Just Pretentious Enough - An Update to My Parallax
Tags: html, css
Published: 2019-12-23 04:25:42

<h1><center>My Portfolio Site - Pt 4</center></h1>
********************************************************

I tend to gravitate to my portfolio site of all my side projects at the moment. I would like to make sure a viewer sees something different and unique to me before I hop into some of the functional features I have planned. With most of the more complicated visual features behind me, I can whip up some better styling for the content, push it, and move on. I've been eager to get back into DRAGnet! 

{% youtube knlLPN0Zpbw%}

*********************************************************
<h1><center> Take a look at some code! </center></h1>
*********************************************************

{% gist https://gist.github.com/JaredHarbison/9948fbddcae665a2360735bb50568e50 %}

I hope to publish the updated version of the site this week! 

*********************************************************
<h1><center> That's All Folks! </center></h1>
*********************************************************
Checks calling echo with no htmlspecialchars when using pure PHP as template with PHPStan
Tags: php, showdev
Published: 2019-12-23 02:25:43

---
title: Checks calling echo with no htmlspecialchars when using pure PHP as template with PHPStan
published: true
description: I coded a tool that Checks calling echo with no htmlspecialchars when using pure PHP as template with PHPStan.
tags: php,showdev
---

The only and greatest benefit of using a template engine library with PHP is that it runs htmlspecialchars without omission.

https://github.com/phpstan/phpstan/issues/351#issuecomment-381421561

As commented in this issue, I partially agree with using standard PHP classes for type checking.
Partial means that I want to write a mixed HTML and PHP template as shown below.

```php
<?php

namespace App;

class ProductDto
{
    /** @var int */
    public $product_id;
    /** @var string */
    public $name;
    /** @var ?string */
    public $description;
}
```

```php
<?php
namespace App;
class ProductHtml {
    public function view(ProductDto $product): void {
?>

<div>
  <div>
    <?= $product->product_id ?>
  </div>
  <div>
    <?= $product->name ?>
  </div>
  <div>
    <?= $product->description ?>
  </div>
</div>

<?php
    }
}
```

PHPStan (or rather PHP-Parser) correctly parses PHP with mixed HTML.
The only complaint about this way is that it cannot check htmlspecialchars exhaustively.
For example, `<? = $ Product-> description?>` May cause XSS.
PHPStan has a plugin mechanism, so we decided to add a htmlspecialchars check as a trial.

{% github nishimura/phpstan-echo-html-rule %}

Adding this extension will report an error similar to the following:

```
 3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ---------------------------------------------------- 
  Line   ProductHtml.php                                     
 ------ ---------------------------------------------------- 
  16     Parameter #1 (string) is not safehtml-string.       
  19     Parameter #1 (string|null) is not safehtml-string.  
 ------ ---------------------------------------------------- 

                                                                                
 [ERROR] Found 2 errors
```

`htmlspecialchars` needs return `safehtml-string` because the extension added a virtual type `safehtml-string`.

```php
<?php

/**
 * @param int|string|null $input
 * @return safehtml-string
 */
function h($input)
{
    return htmlspecialchars((string)$input);
}

/**
 * @param int|string|null $input
 * @return safehtml-string
 */
function raw($input)
{
    return (string)$input;
}
```

Then, correct the part that caused the error.

```php
<?php
namespace App;
class ProductHtml {
    public function view(ProductDto $product): void {
?>

<div>
  <div>
    <?= $product->product_id ?>
  </div>
  <div>
    <?= h($product->name) ?>
  </div>
  <div>
    <?= h($product->description) ?>
  </div>
</div>

<?php
    }
}
```

All other echo calls that do not use htmlspecialchars are now reported as errors too.
Simplifying UI Logic using Finite State Machines - an old pattern for the modern web!
Tags: webdev, patterns
Published: 2019-12-23 00:41:45

Sometimes it good to revisit older design patterns and see how they apply to a more modern web development world.  

That's exactly what I do in [this post about using Finite State Machines for managing UI state.](https://terodox.tech/ui-state-machines/)
I'm a professional React developer, and here's how I set up Sequelize with MySQL inside of Docker Compose for Microservices. #2
Tags: react, node, webdev, javascript
Published: 2019-12-23 00:30:49

**Update:** [Part 3 is out!](https://dev.to/bettercodingacademy/i-m-a-professional-node-js-developer-and-here-s-how-i-create-graphql-powered-microservices-using-node-js-and-sequelize-1a5n)

**About Me:** I've been a professional web developer for just over 10 years now. I'm currently the lead web development instructor at [Better Coding Academy](https://codebetter.com.au), and as part of what I do, I post videos on our YouTube channel at [https://www.youtube.com/c/BetterCodingAcademy](https://www.youtube.com/c/BetterCodingAcademy).

_(Subscribe for awesome web development content!)_

This is part 2 in a full tutorial on how to set up a React/Node.js app with a microservices architecture. ([Here's part 1!](https://dev.to/bettercodingacademy/i-m-a-professional-react-developer-and-here-s-how-i-set-up-react-node-js-microservices-using-docker-and-graphql-20gk))

In this video I set up two MySQL containers using [Docker Compose](https://docs.docker.com/compose/), and then use [Sequelize](https://sequelize.org/) to run database migrations on the databases within both containers.

I hope you enjoy!

{% youtube 6Yfm5gHQjaQ %}

Happy coding!

Full source code: [https://github.com/parkroolucas/microservices-demo](https://github.com/parkroolucas/microservices-demo)