teleren/devto huggingface dataset:
The Mysterious Double Tilde (~~) Operation
Tags: javascript, webdev
Published: 2019-12-06 08:18:50

---
title: The Mysterious Double Tilde (~~) Operation
published: true
description: Have you ever used tilde (~) in your JavaScript code?
tags: javascript,webdev
---

Long ago, I was optimizing a *hot-path* in some game physics code which involved lots of `Math.floor()` and `parseInt()` operations. I came across a micro-optimization to cast `float` or `string` to `int`. 


## ~~ operation

```js
console.log(~~1.6); // 1
```

## What's happening?
A single `~` is a unary operator that converts the given number `N` to `-(N+1)`. For example:

```js
console.log(~2);  // -3
console.log(~1);  // -2
console.log(~0);  // -1
```

This operation is a bit too specific to be useful to many. But when you apply this operation twice, it's equivalent to `Math.floor` or `parseInt`. Examples:

```js
console.log(~~-1);    // -1
console.log(~~0);     // 0
console.log(~~1);     // 1
console.log(~~"-1");  // -1
console.log(~~"0");   // 0
console.log(~~2.4);  // 2
console.log(~~3.9);  // 3
console.log(~~"1");   // 1
console.log(~~true);  // 1
console.log(~~false); // 0
```

## Should I use it in my code?

*It depends*. As I said, it's a micro-optimization and the performance gains are only significant if you are doing this operation *a lot* in your code. Do not use it if you care about readability of your code as it might confuse other developers in your team.


## Performance comparison

I wrote a little [perf-test script](https://jsperf.com/doubletildeperf) to compare.

On Desktop Chrome, `Math.floor()` is almost as fast as `~~`:
![](https://thepracticaldev.s3.amazonaws.com/i/gyfpppxdtfhx5tivo4d7.png)

On Desktop Safari, `~~` is way faster than both `Math.floor()` and `parseInt()`:
![](https://thepracticaldev.s3.amazonaws.com/i/k8n6dz7wji3dwl5wqw68.png)

On iPhone XS, `~~` is also way faster than the others:
![](https://thepracticaldev.s3.amazonaws.com/i/j7yzxvogscrvmf7q5i5s.jpeg)

Happy Coding!
Day 6 of the Visual Studio Tips Advent Calendar is now live
Tags: visualstudio
Published: 2019-12-06 07:58:45

Day 6 of the Visual Studio Tips Advent Calendar is now live. Enjoy! 

What will it be today I wonder?

https://visualstudiotips.co.uk/calendar/

#VisualStudio #DevDecember #VsTipsAdvent #Advent
How to use Repository Templates in GitHub?
Tags: github, codequality, productivity
Published: 2019-12-06 07:26:44

This is a fairly new to GitHub feature released in 2019. In the post i am going to speak about this new feature and how to used it. 

<h3>Benefits of using repository template</h3>

<ul>
<li>Spend less time repeating code </l1>
<li>Focus on building new things </li>
<li>Less manual configuration</li>
<li>Sharing boilerplate code across codebase</li>
</ul>

<h3>Features of repository template</h3>
<ul>
<li>Copy the entire repository files to a brand new repository </li>
<li>Every template has a new url endpoint called <b>/generate</b></li>
<li>Share repository template through your organization or other github users </li>

<hr>

<h2>How to use this awesome feature</h2>

<ol>
<li>On github, navigate to the main page of the repository</li>
<li>Under the repository name click settings <br>
<img src="https://github-images.s3.amazonaws.com/enterprise/2.15/assets/images/help/repository/repo-actions-settings.png">
</li>
<li>Select template repository<br>
<img src="https://help.github.com/assets/images/help/repository/template-repository-checkbox.png">
</li>
</ol>

<h2>How to create a repository from a template</h2>

<ol>
<li>On, navigate to the github main page of the repository </li>
<li>Above the file list click <b>Use this template</b><br>
<img src="https://help.github.com/assets/images/help/repository/use-this-template-button.png">
</li>
<li>Use the owner drop down menu and select the account you want to own the repository<br>
<img src="https://help.github.com/assets/images/help/repository/create-repository-owner.png"/>
 </li>
<li>Type the name for your repository, and select the account you want to own the repository<br>
<img src="https://help.github.com/assets/images/help/repository/create-repository-name.png">
</li>
<li>Choose to make the repository either public or private. Public repositories are visible to the public, while private repositories are only accessible to you, and people you share them with.<br>
<img src="https://help.github.com/assets/images/help/repository/create-repository-public-private.png">
</li>
<li>Optionally, if the personal account or organization in which you're creating uses any GitHub Apps from GitHub Marketplace, select any apps you'd like to use in the repository.<br>
<img src="https://help.github.com/assets/images/help/repository/create-repository-choose-marketplace-apps.png">
</li>
<li>Click <b>Create repository from template</b></li>
Build a Simple Contact List with SwiftUI
Tags: swift, ios, swiftui, xcode
Published: 2019-12-06 06:50:02

In WWDC 2019 Apple introduced SwiftUI, which is an innovative and simple way to build user interfaces across all Apple platforms.

SwiftUI is powered by Swift language and allows you to use the same tools and APIs for developing applications for macOS, iOS, iPadOS, tvOS and watchOS.

SwiftUI uses a declarative syntax so you can simply state what your user interface should do. Before the introduction of SwiftUI, developers used imperative UI which was prone to errors because it required developers to track the state of the code. For example two states of Boolean, like on or off.

In order to use SwiftUI with all the features it offers, you need to run macOS X 15 or newer and Xcode 11 or newer. Xcode 11 includes new design tools, drag & drop of controls and previews which allow you to instantly see the changes as you type your code which is a huge time saver.

If you’ve developed for iOS platform before SwiftUI, you are probably familiar with Interface Builder and storyboards.

Even though this helps to visualize the code a lot, they have one huge problem. Interface Builder doesn’t know about the Swift code and vice versa. That’s why it was pretty easy before SwiftUI to delete the action in Interface Builder, and since Interface Builder didn’t care about the code, the code would still compile.

Simply put, Interface Builder and Swift were always totally separate tools, but SwiftUI changes this a big way. As a Swift-only framework, SwiftUI solves many old problems with Swift and Interface Builder.

Here are two of the most important:

*   you no longer have to worry about calling non-existent functions, because the user interface is checked by the compiler
*   you no longer have to argue about programmatic or storyboard design, you get both at the same time

I’ve created a rather short class to show you exactly how to use SwiftUI by creating a simple contact list. This app won’t earn you and design award, but it will demonstrate the power and ease of use SwiftUI offers over the old approach.


Here's the link: [https://skl.sh/2XInPhG](https://skl.sh/2XInPhG)

With SwiftUI, Apple wrote a whole new and pretty exciting chapter to its iOS and macOS development book. I hope you’ll like using SwiftUI as much as I do! 🙂
Angular — CORE Concepts list
Tags: angular7, angular
Published: 2020-07-15 09:33:52

---
title: Angular — CORE Concepts list
published: true
date: 2019-12-06 06:38:20 UTC
tags: angular7,angular
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/800/1*yjgLGn-pbGD4kj3Gpa0wRQ.jpeg)

### Angular — CORE Concepts

Hello everyone,

Angular is evolving as a de facto standard for developing the Single Page Applications. As part of this blog post, we would like to provide you the CORE concepts of Angular. Once the developer is familiar with the below-mentioned concepts he/she can start the journey with Angular.

**What is Angular?**

> _Angular is superheroic framework to build the Single Page Applications._

> _Google_

I would elaborate the each and every concept in a very detailed way that we listed below in subsequent posts.

**TypeScript Basics**

Learning TypeScript is fun. Having basic familiarity with TypeScript helps to build the angular applications in a more performant way

- What is TypeScript?
- Differences between TypeScript vs JavaScript
- Datatypes in TypeScript
- Type Inference
- Type Assertion
- Var vs let vs const
- Functions
- Interfaces
- Classes
- Generics
- Modules

**Angular Fundamentals**  **Overview**

- [Architecture](https://medium.com/techmonks/angular-architecture-a80e94e92c23)
- CLI
- Modules
- Components
- Directives
- Services
- Pipes
- Dependency Injection

**Components, Data Handling and, Events Handling**

- Data binding in components
- Template Variables
- Communication between components
- Parent and Child
- Independent components
- View Encapsulation
- Content Projection
- View Child and View Children
- Content Child and Content Children
- Life cycle of a component

**Directives and Pipes**

- Directives Overview
- Built-in Directives
- Custom Directives
- Pipes
- Custom Pipes

**Angular Forms Module**

- Angular Forms
- Reactive Forms
- Form Validations
- Custom Validators

**Angular Routing and Services**

- Routing
- Router outlet
- Configuring Routes
- Activated Route
- Router parameters
- Optional and Query string Parameters
- Routing Guards
- Service

**Thank you for Reading 🙂**

![](https://cdn-images-1.medium.com/max/72/0*i_D6k1EfJOCPU5w-.png)

_Originally published at_ [_http://www.techmonks.org_](http://www.techmonks.org/angular-core-concepts/) _on December 6, 2019._

* * *
Advent of Code 2019 Solution Megathread - Day 6: Universal Orbit Map
Tags: adventofcode, challenge, adventofcode2019, spoilers
Published: 2019-12-06 05:47:15

---
title: Advent of Code 2019 Solution Megathread - Day 6: Universal Orbit Map
published: True
description: Time to find the shortest path after we see all the possible paths.
tags: adventofcode,challenge, adventofcode2019, spoilers
series: Advent of Code 2019 Solutions
cover_image: https://i.imgur.com/8EtgDZv.png
---

Ah, BFS my old friend. I must resist booting up a gremlin database to solve this one.

### [Day 6 - The Problem](https://adventofcode.com/2019/day/6)
Cool as cucumbers we descend upon the map station on Mercury. For once, nothing is wrong, and we just need to verify the data and then plot an efficient course.

Part 1 is fairly straightforward, but slow if you're not careful. We've returned to the land of generous examples and explanations on this one.

Part 2 is a perfect place to try out your favorite way to do a modified breadth first search.

It seems like we're alternating between challenging and straightforward prompts. Oh well, at least I think we'll see some creative optimizations in the answers!

### 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.

#### Neat Statistics

I'm planning on adding some statistics, but other than "what languages did we see yesterday" does anyone have any ideas?

**Languages Seen On Day 05**

* JavaScript x 4
* Python x 3
* c
* Kotlin
* PHP
* Racket
* Rust
* Swift
Dec. 6, 2019: What did you learn this week?
Tags: weeklylearn, discuss, weeklyretro
Published: 2019-12-06 05:10:04

Photo by [Road Trip with Raj](https://unsplash.com/@roadtripwithraj?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/learning?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)

It's that time of the week again. So wonderful devs, what did you learn this week? It could be programming tips, career advice etc.

![Image of the brain](https://media.giphy.com/media/ojmB7lOn3VUU8/giphy.gif)

Feel free to comment with what you learnt and/or reference your TIL post to give it some more exposure.

{%tag todayilearned %}

And remember, if something you learnt was a big win for you, then you know where to drop it as well.👇👇🏻👇🏼👇🏽👇🏾👇🏿

{% link https://dev.to/jess/what-was-your-win-this-week-2l4g %}

![Winning!](https://media.giphy.com/media/3ohryhNgUwwZyxgktq/giphy.gif)
Improving Test Failure Messages
Tags: testing
Published: 2019-12-06 04:57:37

---
title: Improving Test Failure Messages
published: true
description: 
tags: testing
---

Having good failure messages does not sound very important. In many ways I agree, in D without an extra library or a custom message a failure message boils down to a file and line number. A quick printout of the result and rerun of the test has generally been sufficient. 

My day job entails writing tests and working with others writing tests. These are visible to the developers as we run them in a CI pipeline. In this case a file and line number is not sufficient. 

I've been working on our messages (expected 1 actual 0) because they didn't help guide the reader to the right course of action. In this case xUnit is being used and it does not allow custom messages on any assert except Assert.True()

For this reason it is important that all assertion happen with true, this allows a message like "expected to get the value 0 when expecting the result to be 1" this provides a lot more on what is the value and which is the result.

Seriously I want to talk about lists, checking optional equally with order. The contains function can find that an element exists but not the order in the list. Jumping to the correct list location and checking equality provides the expected and actual but doesn't give context on the expected or actual position.

This has led me to dynamically build an expected list (this really is only beneficial for short lists). By using the actual results to fill in expectations the message printed states the actual results as expected.

```dlang
auto result = [1, 2, 3, 5];
[1, null, null, 4].fill(result) 
== [1,2,3,4];
```

Now the error from a friendly assert will provide the two lists and standard collection asserts don't need special training for optional values. 

—--------

Consider that I am not saying you should spend a lot of time on the errors messages. I have found that it is important to my situation. 

I will also say that the process of making more information available created a common set of code for data retrieval, reducing code duplication and surfaced more of the action steps in the test function.
Social Media Accessibility
Tags: a11y, socialmedia
Published: 2019-12-06 04:44:24

---
title: Social Media Accessibility
published: true
description: What are the existing settings and methods we can use to make social media more accessible?
tags: accessibility, a11y, social media
---

I was link-surfing when I came across an accessibility feature in Twitter I'd never heard of before, adding an image alt attribute!

{% twitter 1202799248770662400 %}

What the whaaaat? This prompted me to check if Instagram had something similar and...

{% twitter 1202803936232497152 %}

..BAM! The two social media channels I use the most often both have accessibility features I hadn't realized I could be using!

Apparently, even Tumblr has taken a stab at [making their site more accessible](https://unwrapping.tumblr.com/post/182100543757/were-making-tumblr-more-accessible).

But, they don't have the ability to add an img alt attribute.

{% youtube nwKAcgHFrzs %}

What accessibility-related things have you run into on various social media platforms?
Q&A Développement Waves Blockchain bi-mensuel!
Tags: blockchain, wavesplatform, ride, smartcontract
Published: 2019-12-06 04:38:14

Posez vos questions ! Réponse sur telegram et en vidéo bi-mensuelles pour les plus pertinentes. #blockchain #ride #smartContract #développeurs


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

Premier Wébinaire le 17 décembre à 17h

Enregistrez vous!!
Meetup: https://www.meetup.com/Paris-Waves-Bl...

A bientôt!!!

Suivez nous sur:
Telegram : https://t.me/wavesdappsFR
Twitter : https://twitter.com/WavesDevFr
Facebook : https://www.facebook.com/wavesfr
Dev.to : https://dev.to/gegesures
Day20:Compute MD5 of String - 100DayOfRust
Tags: rust
Published: 2019-12-06 03:39:29

### Cargo.toml

```
[dependencies]
md5 = "0.7.0"
```

### Code

```rust
use std::fs;

fn main() {
    let content = fs::read_to_string("main.rs").unwrap();
    let hash = md5::compute(content);
    println!("md5: {:?}", hash);
}
```

### Run

Use `cargo run` get result:

```
md5: f6c1bbeb1f3a85a44bc550a03f02398e
```

To verify our code works correctly, we use `md5sum` shell command to calculate the md5 value:

```bash
$ md5sum main.rs
f6c1bbeb1f3a85a44bc550a03f02398e  main.rs
```

You can see the value is the same as we computed.
Seeking: UI Software Developers for Wealth Management company in Brookfield
Tags: career, microservices, csharp, javascript
Published: 2019-12-06 03:34:48

TSG has a client looking for Developers in Brookfield WI. Join a team of innovators and be part of the next revolution in wealth management applications! The Software Engineer team builds scalable, responsive and complex web UI. The best person for the position will possess strong UI/MicroServices JavaScript, HTML, CSS, AJAX, and C#.


ABOUT THE POSITION:
• Experience with delivering large-scale dashboards containing complex 
  data visualization.
• Research, architect and implement responsive, reusable, customizable 
  next-generation web and mobile components and interfaces.
• Develop new ways of visualizing data and communicating information to 
  end-users.
• Educate, support team on UI issues and promote good UI practices 
  amongst developers.

Skill & Qualifications:
· Expert level of knowledge with JavaScript, HTML, CSS, AJAX and/or C#.
· Familiar with the Microsoft development stack s in C#/ASP.NET, and/or 
  .NET Core
· Experience with implementing web/mobile user interface using one or 
  more UI frameworks such as React, Vue.js, AngularJS or others.
· Experience implementing web-based dashboards utilizing one or more 
  data visualization libraries (SVG or WebGL) such as D3.js, deck.gl, 
  JointJS, Cytoscape.js or others.
· Experience with serverside implementations using JSP, Spring, 
  Hibernate or Node.js.
· Experience with developing cross-platform (Android/IOS) UI for mobile 
  platforms.
· Experience with web services development: C#, NodeJs
· Experience with TypeScript, JavaScript
· CI/CD, Automated testing and other
· Experience developing solutions with AWS native components a plus
· Prior background in Financial Markets development a plus
· Good understanding of MicroServices architectures
· Understanding of event-based and message-driven distributed systems
· Working knowledge of distributed, multi-tier systems
· Strong problem solving, algorithmic thinking and coding skills
· Experience with performance tuning and optimization
· Ability to work in a highly agile team environment
· Self-driven, goal-oriented team player with good communication skills


HOW TO APPLY:
Please use the link to schedule an immediate phone screening for further consideration. Please note: This opportunity is in Brookfield, WI and is an on-site position, no Remote work at this moment.

https://calendly.com/techsourcer/screening


_Please feel free to leave questions in the comments section._
Getting comfortable using Google.
Tags: javascript, help, codenewbie
Published: 2019-12-06 03:24:49

When I say get comfortable with using Google, I do not mean actually knowing how to use it. I am hoping you already have gotten that far. What I am thinking of more is using it to find your solutions. 

I am currently in the [Vets Who Code](https://vetswhocode.io/) program. And to share a little history. I dropped out of High School, spent ten years in the Army doing one of the most non-techy jobs out there (unless you consider the art of running a floor buffer), and then working jobs all the way from pulling cable, electrician, tower climber, to sales. 

Now, on the other hand, I am a geek at heart. I am comfortable at the hardware level. If you have read any of my other posts you would know I am really comfortable with operating systems also. 

I even can grasp HTML and CSS pretty well now. 

But JavaScript and the computer science double whammy kicks my behind. I really do have some difficulty picking it up. Once I get a concept I'm good. But getting it can take time. 

In class, I can be given a problem to solve and I will just go blank. I can't even think of where to start. What do I have to do? I google it. Then I read it, most likely implement the version I found, test it, then try to make it my own. 

I repeat this process quite a bit. Slowly it starts to sink in and I may not need to look that particular thing up again. Or maybe I get half the solution but need to look up the rest. I'm still making progress. 

My hurdle was overcoming the fact that I felt like a cheat. A downright plagiarist! What I bum I was, copying code I found. Poser!

But what I am discovering is the process of finding what I need, making use of it, and then learning what it's doing as I test it and make it my own is teaching me. The very act of copying code is making me better at the craft. As time goes on I am convinced and starting to see that I need to copy less and less for more common tasks. They are sinking in. 

I guess the point I want to make is don't feel guilty for having to look stuff up and even use it for a solution. With enough of it and much more practice, it sinks in, honest. I have to thank the staff and mentors at Vets Who Code for not letting me beat myself up and teaching me that it's part of the process. I believe if someone didn't tell me it's normal, even OK, I would have quit from guilt. 

My last suggestion, don't copy and paste directly. Even if you're using somthing you found, type it in yourself. Test it as you go to help you figure out what's going on. 

Finally, enjoy the ride. You'll get there. 

** Note, there can be malicious stuff out there for you to copy. Be cautious and try to use trusted sites to get your info. If completly in doubt, maybe keep looking.