teleren/devto huggingface dataset:
DRAGnet Reducer
Published: 2019-12-30 03:21:59

<h3><center>Rails + React + Redux - Pt 11</center></h3>
*********************************************************

The queens_reducer.js was the first reducer I wrote for DRAGnet. It was a natural choice as the simplest. 

*********************************************************
<h1><center> Let's get started! </center></h1>
*********************************************************

For UPDATE_QUEEN I defined idx as the id for the queen being updated by the user. In the case of UPDATE_QUEEN, the return is the data for the updated queen spliced from the complete array of drag_queens. 

{% gist https://gist.github.com/JaredHarbison/64fbb22b88e66e635e13cb3ee1f4e338 %}


*********************************************************
<h1><center> That's all folks! </center></h1>
Regular Expressions in D
Tags: regex, dlang, tutorial
Published: 2019-12-30 03:07:00

# Meta

In a previous post about string parsing, I noted that regular expressions were available, but did no dive into an example. 

{% link https://dev.to/jessekphillips/parsing-a-string-in-d-15pk %}

# Intro 

Regular Expressions (regex) is a way of defining a search pattern. It is a very common operation in programming and comes with an age old joke.

>> I had a problem which I solved with regular expressions

> Now you have two programs 

[What does that mean](https://softwareengineering.stackexchange.com/questions/223634/what-is-meant-by-now-you-have-two-problems)

For learning how and what regular expressions look like I suggest this help site [regularexpressions.info](https://regular-expressions.mobi/index.html). But you can keep reading to learn about them and how to take advantage of them using D.

# Format Phone Number

I wanted to start with something simple, but too simple seemed not useful. In this example I decided to show changing from one US phone format to another. 

```dlang 
import std.regex;
void main()
{
    auto data = "555.876.9846";
    
    auto re = regex(r"(\d{3})\.(\d{3})\.(\d{4})");
    
    auto ans = replaceAll(data, re, "($1) $2-$3");

    assert(ans == "(555) 876-9846");
}
```

There are a number of things in this along with the regular expression.

* Regex
  * groupings 
  * digits
  * repeat
  * escape
* regex string literal
* [replacement of all matches] (https://dlang.org/phobos/std_regex.html#replaceAll) 
* match group referencing

## String Literal

[string literal](https://dlang.org/spec/lex.html#string_literals) 

One thing that can be problematic is that the programming language provides special codes string literals can use to represent unprintables. D provides the regex string literal `r""` otherwise the above would look like

` "(\\d{3})\\.(\\d{3})\\.(\\d{4})"`
`r"(\d{3})\.(\d{3})\.(\d{4})"`

This string is still problematic if you need to use quotes. D also has a wysiwyg literal with back ticks, which is problematic for if that is needed. And D provides... Alright that is enough you can follow the link above.

## Regex

[std.regex](https://dlang.org/phobos/std_regex.html) 

### Digits

`\d`

The backslash enters into a special "code" in this case `d` which stands for digit. 

Other common codes 

* w - word character (alphanumeric) 
* s - whitespace 

### Repeat

`\d{3}`

Here I'm using an explicit number of instances. It will only match if three digits are written in a row. Other common repeat codes:

* \d* - zero or more 
* \d+ - one or more 

### Grouping

Regular Expressions allows matched content to be stored in groupings. This is done with the parentheses.

`r"(\d{3})"`

This creates a match group 1. This is used in the replacement string as `$1`.

### Escape Sequence 

`\.`

In regular expressions the dot `.` has a special meaning, match any character. I wanted to match on the literal character. Thus I escape the special processing using backslash, just like when I escape into into special meaning with `\d`.
Learning the REST API Web Service Testing uses SOAP UI
Published: 2019-12-30 02:51:20

## Learning the REST API Web-Service Testing uses SOAP UI

### REST API Testing using SOAP UI + Industry standard REST API WebService connected to mysql DB for learning and practice 

Welcome to REST API Web-Service Testing using SOAP UI tutorial.

Currently API is a booming technology it exists everywhere like Social media, Mobile platform, cloud computing etc,.
Now its a good opportunity to make promising career in API testing.

**This course below topics and more:**
* What are the API & Webservices
* How to Test the Webservices using Soap UI
* What is Rest API
* JSON
* Request-Response
* Soap UI tool
* Path parameter
* Query Paramter
* HTTP status codes

**This comprehensive course cover:**         
* REST API web-service testing using popular soap ui tool
* The SPECIAL thing about this course is, you will get 1 industry standard downloadable REST API web-service connected to Mysql database which can be executed on your own system without need of internet. You will know how API web-service interacts with back-end database.
* You don't need to depend on free online API Web services available on internet for learning purpose.
* This course is for someone who want make good career in API testing.

You don't need to have previous knowledge on WebService as course cover from basics. 

**By the end of this course:** 
* You will know how to test REST API web-service
* You will be having REST API web-service knowledge equivalent to industry standard experienced tester.

**What you'll learn:**
* REST API WebService Concepts
* REST API Testing methodology
* Soap UI Tool
* JSON

Happy Learning

{% youtube YxPwLTyIx0U %}
Day27:surf: async HTTP client - 100DayOfRust
Tags: rust
Published: 2019-12-30 02:27:36

In [previous post](https://dev.to/0xbf/day14-call-web-api-100dayofrust-177b) I wrote on how to call web API with the `reqwest` crate, we can do the same thing with `surf`.

In `Cargo.toml`:
```
[dependencies]
async-std = "1.4.0"
surf = "1.0.3"
serde_json = "1.0.42"
```

In `main.rs`:
```rust
use async_std::task;
use serde_json::{Value};
use surf; 


fn main() {
    let url = "https://blockchain.info/ticker";
    println!("Send request to: {}", url);

    task::block_on(async {
        // first way, auto parse returned string as json
        let val:Value = surf::get(url).recv_json().await.unwrap();
        println!("Bitcoin Price: ${}", val["USD"]["last"]);

        // second way, use returned string
        let valstr = surf::get(url).recv_string().await.unwrap();
        let val:Value = serde_json::from_str(&valstr).unwrap();
        println!("Bitcoin Price: ${}", val["USD"]["last"]);
    }); 
}
```

Run code `cargo run`:

```
Send request to: https://blockchain.info/ticker
Bitcoin Price: $7346.23
Bitcoin Price: $7346.23
```

### Reference:
1. https://docs.rs/surf/1.0.3/surf/
2. https://github.com/http-rs/surf
Make your cards pop on hover with CSS
Tags: tutorial, css
Published: 2019-12-30 02:25:29

If you've ever wanted to change the color or opacity of something when you hover the mouse over it then this short tutorial is for you!


First let's create a div and a card.

```
  <div class="container">
     <div class="card"> 
       <h1>I'm a card!</h1>
      </div>
   </div>
```

Next let's style the card. We will give it a border and change the sizing as well as centering the text.

```
 .card {
    border: 3px solid black;
    background-color: green;
    width: 400px;
    height: 200px;
    opacity: 80%;
 }


 .card h1 {
    text-align: center;
 }

```

Now we can add changes on hover let's make the border thicker and change the opacity to 100% when the mouse hovers over the card. We can do this using :hover. Make sure you don't add a space between :hover and the class name. If you add a space it wont work properly.


```
 .card:hover{
    border: 8px solid black;
    background-color: green;
    opacity: 100%;
 }
```

Now when we hover over the card it changes!
How to add words inside a border in CSS
Published: 2019-12-30 01:59:05

I recently figured out how to put words into a border and thought I'd make a short tutorial on how to do it.

First you'll need to create a border. Let's create a Div to add a border to.

```
<div class="border"><h1 class="words">Look at this div</h1></div>
```

Now let's give it a border using CSS. We will also add some margin spacing and change the width and height of the div.


```
 .border {
     border: 2px solid black;
     margin: 100px 100px 100px 100px;
     width: 600px;
     height: 400px;
    
 }
```


Next we will want to style the h1, we will give it a negative top margin so it will be within the border line, we will also give it a background color of white so the line behind it disappears. We set the left margin to 10px so the words aren't completely on the left side of the div, and finally we set the width to 220px so the entire top border line doesn't disappear.

```
 .words {
     margin-top: -17px;
     margin-left: 10px;
     background: white;
     width: 220px;
 }
```

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/vih1d374flazjrh8nd5h.jpg)
Why I hate refactoring
Tags: refactoring, todo, lazy
Published: 2019-12-30 01:54:09

---
title: Why I hate refactoring
published: true
description: Refactoring sucks?
tags: refactoring, TODO, lazy
cover_image: https://vitalflux.com/wp-content/uploads/2014/01/refactoring.jpg
---

Okay, I admit it. This was a clickbait title. So sue me. I don't actually hate refactoring. What I really hate, and what will be the topic of this post, is being lazy (particularly when it applies to refactoring).

How does this phenomenon arise? Well, it's pretty simple. We as developers get lazy. For example, suppose someone points out in a code review that we could DRY some code and thereby remove duplicated effort. You respond by saying there's no time for that now and that we'll add it to the technical debt in our backlog. Or say that you settle for a few TODO comments instead of actually doing the due diligence to write clean code. It will get done eventually after all.

Wrong! These things rarely get done in practice once they've been relegated to the purgatory known as, "to be done later." There's always more important work to be done than humble ol' refactoring. I've worked for 2 different employers since graduating college and I honestly cannot think of a single instance where cleaning up technical debt and refactoring code actually got prioritized in a sprint.

And to be fair, I'm not arguing that refactoring is always more important than writing new features. I'm not even arguing that it's more important most of the time. At best you could say that, occasionally, the benefits probably outweigh the costs for some specific instance. Which, as the clever reader that you are will surmise, is hardly a standing ovation for refactoring. So what is the point I'm trying to make?

Stop being lazy! Stop procrastinating! The correct answer to the first hypothetical scenario from above should have been, "I'll DRY the code in my upcoming code review," and the correct way to handle the second scenario is to not leave TODOs littered in your code unless absolutely necessary.

Legacy TODOs are so obnoxious. No one on the team knows what they mean anymore and are therefore afraid to remove it in case it could be useful. So what you end up with is just training developers to ignore TODOs. Which is not a good habit to ingrain.

Similarly, technical debt cleanup in the backlog is always relegated to being a second class citizen. It's very hard to justify "improving code quality" over "delivering features that earn money."

Fortunately there's a simple, albeit effortful, solution to all this. Take pride in writing clean code. Do your due diligence to ensure you follow the [~~boy~~ person scout rule](https://medium.com/@biratkirat/step-8-the-boy-scout-rule-robert-c-martin-uncle-bob-9ac839778385). Taking an extra hour in the sprint to refactor code to be maintainable could mean you won't have to spend 15 hours a year from now to refactor the bigger mess that your procrastination induced. Or perhaps, as is more likely, you never get around to refactoring it and any work involving that gross, legacy part of the codebase just becomes more and more difficult as time goes on.
It's About Time | Hello 👋🏾
Tags: hello
Published: 2019-12-30 01:53:41

This is my hello post. I'm having some really interesting experiences in my tech life and I would like to have someplace nice to share them. 

![kid, as in goat, running up to say, 'hi'](
https://media.giphy.com/media/3PAL5bChWnak0WJ32x/giphy-downsized.gif)

From Twitter, I get the idea that this is the place to be so I'm here now. I'm looking forward to sharing more with the community soon.

Thanks for having me!
Use `mkfifo` to create named pipe - Linux Tips
Tags: mkfifo, bash, linux
Published: 2019-12-30 01:50:38

We can use `mkfifo` or `mknod` command to create a named pipe. A pipe is a structure which one end can send message and the other can consume it.

To create a named pipe, we can use `mkfifo` or `mknod`:

```bash
$ mkfifo pipe1

# we can see the file type is "named pipe" using `file` command
$ file pipe1
pipe1: fifo (named pipe)

$ ls -al pipe1
prw-r--r-- 1 userx userx  0 Dec 29 20:35 pipe1

# or we can use mknod, "p" indicate this "node" is a pipe
$ mknod pipe2 p
$ file pipe2
pipe2: fifo (named pipe)
```

Now let's send/consume messages with this pipe. Open a terminal window:
```bash
$ tail -f pipe1
```

Open another terminal window, write a message to this pipe:
```bash
$ echo "hello" >> pipe1
```

Now in the first window you can see the "hello" printed out:
```bash
$ tail -f pipe1
hello

```

Because it is a pipe and message has been consumed, if we check the file size, you can see it is still 0:

```
$ ls -al pipe1
prw-r--r-- 1 userx userx 0 Dec 29 20:35 pipe1
```
Python is so flexible that I use it as development glue
Tags: python
Published: 2019-12-30 01:05:12

I can think of no better example of "Python as glue" than this here commit on one of my game projects, in which I took locale files from one game (LaserTank) and converted them for use in a remake of said game (LaserTank Improved). This is such a common development task, and one highly suitable for automation, that using Python seemed too logical to NOT do... [here is the commit in question](https://github.com/PuttySoftware/laser-tank-improved/commit/6a77aad51b9324537ab52120ce6e9120b2449a5d).
Minhas boas leituras de 2019 (e as bem ruins também)!
Tags: paideia
Published: 2020-01-06 13:15:59

---
title: Minhas boas leituras de 2019 (e as bem ruins também)!
published: true
date: 2019-12-30 01:02:06 UTC
tags: paideia
canonical_url: https://www.itexto.com.br/devkico/?p=2928
---

Aquele post que agora é tradicional: quais as leituras que mais me impactaram em 2019 e quais os planos para 2020, que é um ano que promete bastante!

Leia mais em https://www.itexto.com.br/devkico/?p=2928
My new blog
Tags: showdev, discuss
Published: 2019-12-30 01:00:44

I have decided to write less on dev.to. Which seems like a ridiculous statement given how good of a platform it is. Here is my reasoning.

I have a new day job that does not involve coding, like at all. Most of what I do outside of work is build my company [flawk.to](https://flawk.to), which involves some coding but nothing of immense value yet. But I still want to write. So I created a new blog called [Attempts.](https://attempts.space/). There I will be posting about my life as a father, my business development and current day job goings on - which will be very interesting in the coming months.

I wrote my first post https://attempts.space/the-beginning/, I would love it if y'all could take a look and give me some feedback! The blog is open source and based heavily on [Dan Abramov's](https://twitter.com/dan_abramov) [overreacted.io](https://overreacted.io). It is hosted on [Zeit's now](https://now.sh) feel free to ask me anything about building it.

Also, do you think it is a good idea to post less on dev.to even if my content is less development related?
Getting the user signature with Xamarin Forms
Tags: xamarin, nugetpackage, signature
Published: 2020-01-01 21:59:48

---
title: Getting the user signature with Xamarin Forms
published: true
date: 2019-12-30 00:49:47 UTC
tags: Xamarin,nuget package,signature
canonical_url: https://blog.torib.io/2019/12/29/getting-the-user-signature/
---

This is a common feature requested for many applications in the corporate world or if you are working on some sort of payment processing application or a delivery app. You may need the user signature to confirm they have received a package, an order has been delivered or many other scenarios.

With the SignaturePad Xamarin forms control you can get the user sigature in no time for both Android, UWP and iOS.

### Getting it to work

Include the nuget package: [Xamarin.Controls.SignaturePad.Forms](https://github.com/xamarin/SignaturePad) to all target projects.

![](https://blog.torib.io/wp-content/uploads/2019/12/Screen-Shot-2019-12-29-at-7.54.53-PM-1024x689.png)<figcaption>Adding the Xamarin.Controls.SignaturePad.Forms nuget package</figcaption>

Add the control to your page:

<script src="https://gist.github.com/eatskolnikov/a29de6997654464345d5650996509fb1.js"></script>

And now the control is ready for use

![](https://blog.torib.io/wp-content/uploads/2019/12/signature.gif)

Notice how In the example gist I’m making sure to [set the Safe areas for iOS](https://blog.torib.io/2019/04/24/layout-safe-areas-for-ios-in-xamarin-forms/), otherwise the you could get some overlaps like in the image bellow

![](https://blog.torib.io/wp-content/uploads/2019/12/Screen-Shot-2019-12-29-at-8.07.42-PM-469x1024.png)<figcaption>The “sign above the line” text is being crossed because we didn’t set the safe area</figcaption>

The control interface includes a line and instructions to sign above it. It also includes a reset button and a prompt text that you can set to, for instance, the name of the client. All these texts can be set with their respective properties and you can also set the stroke width, stroke color and background color.

![](https://blog.torib.io/wp-content/uploads/2019/12/Screen-Shot-2019-12-29-at-8.37.16-PM.png)

You can access the generated signature image in two ways. One is an Image Stream and the other is as an array of Points (I prefer this one since you can then serialize it a a JSON and save it to a database with much ease)

To get the image stream you call the GetImageStreamAsync method from the instance of the control

```
Stream bitmap = await signatureView.GetImageStreamAsync (SignatureImageFormat.Png);
```

To get the points array you reference the Strokes property from the instance of the control

```
var strokes = signatureView.Strokes;
```

You can then use the same strokes to load the image back

```
signatureView.Strokes = newStrokes;
```

And that’s about it. I hope you enjoyed it and if you did share it with Karen from work she’ll appreciate it, trust me. Have a good day.

The post [Getting the user signature](https://blog.torib.io/2019/12/29/getting-the-user-signature/) appeared first on [Enmanuel Toribio](https://blog.torib.io).
Combined powers of Flask and Falcon
Tags: python, falcon, flask, api
Published: 2019-12-30 00:48:22

Hola, people!

Quite some time ago, I started learning Flask. Boy, it really got me engaged and addicted to creating web apps the "easy" way.

But, it wasn't long when it got real mundane typing `from flask import whatever` for every little project I wanted out to try. In fact, I really started to ask, "Am I learning something, or just importing flask every now and then?".

Next thing you know my history is flooded with searches as in "Flask alternatives", or "Python web frameworks -flask" (`-flask` is a Google dork, meaning `MINUS/SKIP "flask"`) and so on, and I was overwhelmed with the number of frameworks out there.

Out of all those numbers, one thing that got my tick was Falcon. I quickly navigated to it's docs, followed the tutorial, and yes - there was an app serving within minutes I read the documentation.

Now, due to some random state of my mind, I decided to start a project using Falcon. I made a couple "test apps" to acquaint myself with the framework, but yeah, they didn't suffice the skillset required to create scalable apps yet.

I started figuring things out, and decided to re-create a Flask project I made back in the days, using Falcon to serve as an API.

It was (is) an open-source blogging site, where you can (at least) upload blogs, and share your posts' URL for people to read.

I now plan (and am working on) to introduce some more advanced features like following people, getting suggestions from people regarding possible enhancements in posts (much like GitHub PR Reviews), and, maybe some more.

I've hosted the app here - https://blogstate.pythonanywhere.com
running on the source - https://github.com/roshnet/blogstate-refactor
based on the API - https://github.com/roshnet/blogstate-api
which is deployed somewhere top-secret ;>


If (by the slightest chance) you might wanna suggest anything or help me out in code, please open a PR on the linked repositories, or [submit an issue](https://github.com/roshnet/blogstate-refactor/issues/new).


Thanks for your time!
Inset grouped List in SwiftUI
Tags: swiftui, ios, swift, uikit
Published: 2020-02-02 04:20:47

---
title: Inset grouped List in SwiftUI
published: true
date: 2019-12-30 00:00:00 UTC
tags: SwiftUI, iOS, Swift, UIKit
canonical_url: https://sarunw.com/tips/inset-grouped-in-swiftui/
---

In iOS 13, Apple brought a new style to the Tables, inset grouped.

``` swift
let tableView = UITableView(frame: .zero, style: .insetGrouped)
```

The code above would result in a table view with rounded corners and are inset from the edges of the parent view.

![Inset grouped table view style](https://sarunw.com/images/insetgrouped-example.png)<figcaption>Inset grouped table view style</figcaption>

SwiftUI has a List view to represent rows or data, just like UITableView. Too bad it doesn't have inset grouped style. You has only two styles (for iOS) `PlainListStyle` and `GroupedListStyle` which you can apply to list view like this:

``` swift
List {
    Text("Item 1")
    Text("Item 2")
    Text("Item 3")
}.listStyle(GroupedListStyle())
```

## iOS 13.2 #

In iOS 13.2, this is no longer a case. A grouped list will use an inset grouped style when it is presented under the _horizontal size class_ environment.

You can make your grouped lists style present as an inset grouped style by overriding your list view with regular horizontal size class (`.environment(\.horizontalSizeClass, .regular)`).

``` swift
List {
    Text("Item 1")
    Text("Item 2")
    Text("Item 3")
}.listStyle(GroupedListStyle())
.environment(\.horizontalSizeClass, .regular)
```

<aside>
<p>I can't find any reference for this change in official release notes, but in my test, this was introduced in iOS 13.2.</p>
</aside>

Apple choose not to introduce a new style like `InsetGroupedListStyle`, but adapt `GroupedListStyle` based on size class. I think the reason might lie in their [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/ios/views/tables/), here is some part of _Inset grouped_'s definition.

> The inset grouped style works best in a regular width environment. Because there's less space in a compact environment, an inset grouped table can cause text wrapping, especially when content is localized.  
> – Apple's Human Interface Guidelines

As you can see, the explanation is well aligned with the implementation detail.

---
*Originally published at [https://sarunw.com](https://sarunw.com/tips/inset-grouped-in-swiftui/).
Find out my latest article and more at https://sarunw.com I post articles weekly there.*

[![Subscribe](https://thepracticaldev.s3.amazonaws.com/i/rmrsj3km5j19r1ba8tm8.jpg)](https://sarunw.us1.list-manage.com/subscribe/post?u=da8ac0f3b786879a00c413a46&amp;id=43463b63ef&SIGNUP=Devto)


## Related Resources #

- You can check out my compiled cheat sheet at [fuckingswiftui.com](https://fuckingswiftui.com/) or [goshdarnswiftui.com](https://goshdarnswiftui.com/) if you want more work-friendly url.
- [Human Interface Guidelines – Tables](https://developer.apple.com/design/human-interface-guidelines/ios/views/tables/)