teleren/devto huggingface dataset:
First look at the new UIColorPickerViewController in iOS 14
Tags: ios, ios14, swift
Published: 2020-06-23 13:57:18

With iOS 14 we can use the new `UIColorPickerViewController` to let user select color. In this post let's briefly check how to use it. You of course need the new Xcode 12 to be able to try this example.

### Showing the color picker

The new `UIColorPickerViewController` works basically in the same way like other pickers and pre-made controllers. We create an instance, set ourselves as a `delegate` and `present` the picker like so:

```swift
let picker = UIColorPickerViewController()
picker.delegate = self
present(picker, animated: true, completion: nil)
```

Note that you should not wrap the picker in `UINavigationController` I tried it and got very strange behaviour with missing background. Also since the picker has its own navbar I think that is the indication it should not be used with  `UINavigationController`.

Once you present the controller, you get UI like this:

![UIColorPickerViewController screenshots](https://nemecek.be/media/images/UIColorPickerViewController.png)

There are three ways how to pick a color with the option to also select opacity. This can be customized with the `supportsAlpha` property. If set to `false` you cannot change opacity and cannot select color with alpha component. So far that is the only customization we have.

### Implementing the delegate

To get notified about user's color selection we need to implement the `UIColorPickerViewControllerDelegate`. These are two methods. One informs us about new color selection and the other about user closing the picker.

The basic implementation could look like this:

```swift
func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
        dismiss(animated: true, completion: nil)
}
    
func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
        let color = viewController.selectedColor

}
```

And that is our first look at `UIColorPickerViewController`.



[![Scan it - wide banner](https://nemecek.be/media/images/scanItWideBanner.png)](https://apps.apple.com/app/scan-it-scan-and-export-pdf/id1509634112)
Variables in Declarative Programming
Tags: declarative, programming, logic, javascript
Published: 2020-06-23 13:34:16

Variables carry value or reference to object, but what they 
represent in imperative (procedural) and declarative programming is different. Before diving into details, the one of main differences of two programming styles: declarative programming is strict to provide logical integrity, often in formal logic, but imperative programming doesn’t have to be because its control flow is managed by its programmers.

Let’s start with a simple example:

```javascript
x = 1;
y = x + 1;
```

JavaScript engine creates a value in memory and links to variables, but when `x` is changed like `x = 2`, value of `y` stays as is because only memory location of `x` has changed. So, **logical integrity** is broken. However, if we apply the same example in declarative programming:

```javascript
> x = 1
> y = x + 1
> x = 2
> y
3
```

So `y` has changed along with the `x`. When `y = x + 1` is defined, declarative runtime is now responsible for providing logical integrity, means correcting `y`.

> **Declarative runtime** doesn’t care technical representation (In this case, memory location) rather interested in logical meaning.

The same concept is applicable to object and its properties:

```javascript
class User {}
user1 = new User()
user1.domain = "domain.com"
user1.username = "first-user"
user1.email = user1.username + "@" + user1.domain
```

`user1.email` is initialized as `"first-user@domain.com"`, but changing `user1.username` doesn’t affect `user1.email` same as above because it is pointed to different memory block.

In declarative programming, it is not the case, in fact, the declaration can be initialized at the beginning, even before defining properties.

```javascript
> class User {}
> user1 = new User()
> user1.email = user1.username + "@" + user1.domain
> user1.domain = "domain.com"
> user1.username = "first-user"
```

> `user1.email` stays `undefined` until all properties are defined.

## DECLARATIVE RUNTIME = RUNTIME + DATABASE

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

While the declarative runtime provides `logical integrity`, it stores each statement as received so it doesn’t require external `database`.

---

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

Nucleoid is open source (Apache 2.0), a runtime environment that allows declarative programming written in ES6 (JavaScript) syntax. Since statements are declarative, the runtime provides logical integrity and persistency as hiding technical details.

Join project at [gitlab.com/nucleoid/nucleoid](https://gitlab.com/nucleoid/nucleoid)
Regex search and replace with VS Code
Tags: productivity, vscode
Published: 2020-06-23 13:25:00

I wanted to upgrade `ag-grid` across a number of apps. Standard search and replace did not work due to variations in package names and versions. So do I have to update each manually? Thankfully the answer is no! Regex search and replace to the rescue.

## Too many variations 

For example each of the apps below have different versions and package names. How do we upgrade all `ag-grid` packages to the latest release of `23.2.0`? We cannot do a search and replace, unless we go one at a time...

```json
 App 1
"@ag-grid-enterprise/all-modules": "22.1.4",
"@ag-grid-community/angular": "22.1.5",

App 2
"@ag-grid-community/all-modules": "22.1.3",
"@ag-grid-community/angular": "22.1.4",

App 3
...
```

## Regex match to the rescue

VS Code lets you search with regexes. Select the third option in the search bar and write your regex.

![Enable Regex Search](https://dev-to-uploads.s3.amazonaws.com/i/wiw5umjyn85ivtdsa9t1.png)

This is the regex that I used to find all the packages starting with `@ag-grid-`.

```
(@ag-grid-.*:).*,
```

You can see this regex in action on [Regex 101](https://regex101.com/r/qT7NP0/3) to try it out for yourself.

### Capture Groups

Now comes the amazing part! The part of the regex in the `()` is called a capture group and you can reference it the replace box. This means that you can say, whatever matched this capture group, leave that the same when you make the replacement. 

In our case this is whatever `ag-grid` package name we already have. 

```json
Capture Groups for $1

App 1
@ag-grid-enterprise/all-modules":
@ag-grid-community/angular":

App 2
@ag-grid-community/all-modules":
@ag-grid-community/angular":
```

We refer to the capture group with the syntax `$1`.

> If you have multiple capture groups then you would use `$1`, `$2`, `$3` and so on to refer to the capture groups in the order they are defined.

So we can then write our search and replace as follows.

```
Find: (@ag-grid-.*:).*,

Replace: $1 "23.2.0",
```

Here is the replacement preview, showing the versions updated for different packages at the same time thanks to our regex.

![Replace Preview](https://dev-to-uploads.s3.amazonaws.com/i/mbifdq9sas226jzw48mn.png)

This is so powerful, as we can do a single regex search and replace and update all `ag-grid` packages at once saving heaps of time and ensuring we don't accidentally miss any! 

Find more examples of regex search and replace see this [Stack Overflow](https://stackoverflow.com/questions/34618383/vscode-regex-find-replace-submatch-math) question or check out my other [post](https://dev.to/scooperdev/powerful-refactoring-with-regexes-3237) which shows another example of refactoring code using Regex Search and Replace. 

Hope this saves you as much time as it did for me!

---

Follow me on Twitter [@ScooperDev](https://twitter.com/SCooperDev) or [Tweet](https://twitter.com/intent/tweet?text=%22Regex%20search%20and%20replace%20with%20VS%20Code%22%20by%20%40SCooperDev%20%23DEVCommunity%20https%3A%2F%2Fdev.to%2Fscooperdev%2Fregex-search-and-replace-with-vs-code-4911) about this post.
Redux or Recoil?
Tags: discuss, react, redux, recoil
Published: 2020-06-23 12:57:56

I'm a new developer working on a React project that has grown from its original scope. I started out just using local state and passing props, but as it has grown it is time to refactor and implement state management. The application involves multiple components with many fetches to external APIs, and displaying the data in various ways across routes. 

I have used Redux in the past (but not with React hooks), but I am also considering trying out Recoil.

**Should I stick with what I already know (Redux), or take this opportunity to explore a new library (Recoil)?**

**In your opinion, what are the pros and cons of each?**

Thank you in advance for any thoughts or recommended resources!
Redis Streams available in redis-rs
Tags: redis, rust, news, data
Published: 2020-06-23 12:44:45

---
title: Redis Streams available in redis-rs
published: true
description: MERGED! 
tags: redis, rust, news, data
---

Woohoo! We now have high-level support for Streams commands in redis-rs:

https://github.com/mitsuhiko/redis-rs/issues/162

This is the conclusion of work described in a previous post:

https://dev.to/terkwood/adding-redis-streams-to-rust-464j

Hope someone out there finds it enjoyable! I have a couple of outstanding work items that I'm going to revisit now that there's a pleasant way to interact with this portion of the Redis API. 🦀 💾
Export/Import Excel documents to MS Project in C#/.NET using Aspose.Tasks
Tags: msproject, mpp, msexcel, xlsx
Published: 2020-06-23 12:44:22

# Export MS Project data to XLSX
Sometimes there may be requirements to work with your project data in Microsoft Excel.
In simple scenarios, you can export project data using Aspose.Tasks with two lines of code (default settings will be used):
{% gist https://gist.github.com/aspose-com-gists/da7049762cbffc404c0451742f0dade8 file=BasicExportToXLSX.cs %}

The resulting spreadsheet will contain three sheets (for Task, Resource, and Assignments) with default columns.
If you need a specific set of columns the resulting spreadsheet can be customized in the following way:
{% gist https://gist.github.com/aspose-com-gists/da7049762cbffc404c0451742f0dade8 file=AdvancedExportToXLSX.cs %}
The resulting spreadsheet when opened in Microsoft Excel:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jlsfy1w0csb6rcozao1z.jpg)
# Import project data from XLSX
There is no API for importing XLSX to project data at the moment, but you can use OpenXml to implement an importing routine specific to your data. Here is a simplified example of how it can be done (requires ‘DocumentFormat.OpenXml‘ NuGet package ):
{% gist https://gist.github.com/aspose-com-gists/da7049762cbffc404c0451742f0dade8 file=ImportFromXLSX.cs %}
Timeout with a third party library or another server - How to handle?
Tags: help, architecture, server, python
Published: 2020-06-23 12:35:06

---
title: Timeout with a third party library or another server - How to handle?
published: true
description: How do we handle timeouts between different servers and the data integrity
tags: help, architecture, server, python
//cover_image: https://direct_url_to_image.jpg
---

This example I am stating obviously a rare scenario, but I would like to understand how this would be handled? (or they should be totally avoided?)

Consider there's two application server (AS1 and AS2) having their own databases(DB1 and DB2). An HTTP call to one AS1 will internally make HTTP call to AS2. Once AS2 validated the payload from AS1, it will write to DB2 and returns an hash, which AS1 will store in DB1. 

Looks very simple to construct, but how can we handle this following scenario. Say, AS1's internal HTTP call to AS2 has a specific timeout (let's assume 15seconds). In that time period, AS2 writes to DB2 but didn't return before the timeout, so AS1 don't have the hash and now it cannot make a duplicate call to do AS2 again.

How should this be handled? I know the scenario looks vague for few of you. But let's pop up some discussion further if needed. Thanks.
QlikSense Free Live Webinar 
Tags: qliksense, qlikview, qlik
Published: 2020-06-23 12:34:39

📣 Join our Upcoming - Free Live #Webinar on #Qliksense - 🚀 One of the Best #DataVisualization tool
👉Qliksense is one of the emerging ☁cloud-based #BusinessIntelligence service. To help enterprises with their data to create & share effective #visualizations for #businessgrowth.

👨‍🎓 #Learn how to Create, Visualize, and share #Enterprise #data to get better #business insights

👩‍⚖️ In this webinar, you'll learn

1. Importance of Business Intelligence?
2. What is Qliksense?
3. Qliksense Growth, Trends, and Market share
4. Why Qliksense is so popular?
5. Why use Qliksene? And its key Features
6. Components of Qliksense
7. Architecture & Building Blocks
8. Getting started with Qilksense
& more.

👉For Free Registration visit Here:https://bit.ly/3d697IY
Getting Error .replace is not a Function
Tags: node, javascript, webdev, help
Published: 2020-06-23 09:23:09

I am facing .replace() is not a function. Following is the code. 
****Code****
//Server
const http=require('http');
const fs=require('fs');
const url=require('url');


const replaceTemplate=(temp,product)=>{
    let output=temp.replace(/{%PRODUCTNAME%}/g,product.ProductName);
    output=output.replace(/{%IMAGE%}/g,product.image);
    output=output.replace(/{%PRICE%}/g,product.price);
    output=output.replace(/{%FROM%}/g,product.from);
    output=output.replace(/{%QUANTITY %}/g,product.quantity);
    output=output.replace(/{%DESCRIPTION%}/g,product.description);
    output=output.replace(/{%NUTRIENTS%}/g,product.nutrients);
    output=output.replace(/{%ID%}/g,product.id);

    if(!product.organic)output=output.replace(/{%NOT ORGANICR%}/g,'not organic');
        return output;
}


const tempOverview=fs.readFileSync('./templates/overview.html');
const tempCard=fs.readFileSync('./templates/template-cart.html');
const tempProduct=fs.readFileSync('./templates/product.html');

const data=fs.readFileSync('./dev-data/data.json');
const dataObj=JSON.parse(data);


const server= http.createServer((req,res) => {

const pathName=req.url;
if(pathName==='/' || pathName=='/overview'){
    //Overview Page
    res.writeHead(200, {'Content-Type':'text/html'});
    const cardHtml =dataObj.map(el =>replaceTemplate(tempCard,el));
    console.log(cardHtml);

    res.end(tempOverview);
}
//Product Page
else if(pathName=='/product'){
    
    res.end('This Is Product Path');
}
   //API Page
else if(pathName=='/api'){
 
fs.readFile('./dev-data/data.json',(err,data)=>{
    if(err){
        console.log('Error Occured')
    }
            //Not Found Page
    else{

        const productData=JSON.parse(data)
        res.end(data);
    }
})

}




else{
  res.writeHead(404,{
      'Content-Type':'text/html',

  });
  res.end('<h1>Page Not Found</h1>');
}




   

})
server.listen(8000,'127.0.0.1',()=>{
    console.log('Server Is Started');
})

*****
CashRegister with barcode logon and 5 buttongroups with each 39 + 1 programmable productbuttons  in Python and Pyqt5
Published: 2020-06-23 12:05:37

# Register with logon from barcode.
Link to download: https://github.com/DirkJanJansen/Sales/

Link to Installation: https://github.com/DirkJanJansen/Sales/blob/master/Installation/install.txt

Link to Linux Installation: https://github.com/DirkJanJansen/Sales/blob/master/Installation/LINUX_install.txt

Link to documentation: https://github.com/DirkJanJansen/Sales/blob/master/Documentation-Sales_CashRegister.pdf

Link to changelog: https://github.com/DirkJanJansen/Sales/blob/master/Installation/Changelog.txt

Barcode testlabels for employees for logon included

40 programmable buttons for unpackaged products

3 Entrance security levels 

Equipped with inventory management system
It’s about the why, not the what
Tags: webdev, career, productivity, beginners
Published: 2020-06-23 12:02:05

One of the things my wife and I most like to do together is play board games. Oftentimes, we'll invite other people to play as well.

But we've learned something interesting-most people don't like learning new games.

This had perplexed me for awhile, because everyone loves <i>playing</i> games, but people struggle <i>learning</i> games. And then, last night, it hit me like a ton of bricks.

It's because when we play games we focus on the "what" (or the execution) and not the "why" (the actual problem). Let me tell you what I mean by that.

How many times have you been learning a board game and people try and teach you it...but they only focus on the what? "On your turn you do this" or "When you get this card, you do that" and so on. That's frustrating! Sitting there not knowing what to do and being told what to do...it oftentimes leaves us not even wanting to play anymore!

And so you have to focus on, and tie <i>everything</i> back to the "why", and then people can have more fun!

"But Adam", you ask, "This is a development blog...why are you talking about board games?" And I imagine you can deduce the reason...because this completely ties back to development.

Why do so many software businesses fail? Why do teams sometimes "miss the mark" when it comes to projects? Because they're focusing on the "what." They're focusing on what they're doing for their customer: "these are all the products and features in our product" or, even worse "this is our tech stack! It's super cool and we're very proud of it!" When businesses focus on that, they fail. Businesses should focus on the "why." "We're solving this problem for the customer." "Implementing this solves that problem for the customer." And so on and so on. It's a subtle change, but it works wonders.

Focusing on the "why" is how I'm trying to build my product right now, called: <a href="https://upvid.app/d/2/2/" title="Go to Upvid" target="_blank" rel="noopener">Upvid.app</a>. 

So what is my "why"? Well it's: "being able to upload a video and easily share it is too cumbersome, there is definitely an easier way." 

The "what" is easy (and sometimes more fun) to focus on: "I'm building a JAMStack app" or "It's going to be able to be searchable, sortable, and be able to give you several different embed codes for your video." But again, when you focus on the what, you will lose sight of what you are hoping to do, which is to solve a problem for your customer.
Daily Developer Jokes - Tuesday, Jun 23, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-06-23 12:00:05

---
title: "Daily Developer Jokes - Tuesday, Jun 23, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Tuesday%2C%20Jun%2023%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259b4a4ae9.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ Why do developers mixup Terminals and Polygraphs?

___A:___ Because they both can see a lie (CLI)
 -->
So excited about Scribble in iOSPad 14
Tags: wwdc20, iospad, apple, digitalart
Published: 2020-06-23 11:59:25

Just what the title says, but at the time I was skeptical as the person demoing had really neat handwriting as opposed to my Jekyll & Hyde writing... really neat (artist side of me) but can flip to be messy (coder/techie side of me).

Then I watched the State of the Union later and Scribble recognised the engineer's scribbles! 🙌

I'm getting into digital painting because I finally got around to do the [21Draw's How to draw a cartoon character workshop](https://www.21-draw.com/course/draw-cartoon-character/). I was one of the kickstarter backers, and it's totes worth it. They've KS'ed another one to bring more courses that are beginner-friendly, so really looking forward to that.

BTW, [the article about Scribble from CreativeBloq](https://www.creativebloq.com/news/wwdc-ipad-scribble) got me thinking and that's why I wanted to write this post. 😊

##### References
👉 https://developer.apple.com/wwdc20/
👉 https://www.apple.com/newsroom/2020/06/ipados-14-introduces-new-features-designed-specifically-for-ipad/
Css styling
Published: 2020-06-23 11:46:09

CSS styles are applied in the order they are linked in your HTML code.

So if you had two stylesheets e.g. styles1.css and styles2.css which both target the same element e.g.

styles1.css

body {
background-color: red;
}
styles2.css

body {
background-color: blue;
}

If inside the head section if your HTML, you list your links as this:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/e1c8bnf4nji4kbwz281h.jpg)
<link rel="stylesheet" href="styles1.css">
<link rel="stylesheet" href="styles2.css">

Can you guess how the resulting page will be? 
The resulting page will be blue.

But if you listed your links like this:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7mcmj0tj1sb2tpbi8fe2.jpg)
<link rel="stylesheet" href="styles2.css">
<link rel="stylesheet" href="styles1.css">

The resulting page will be red.

Essentially both styles are being applied, but the one that's visible at the end is the one applied last.
How about a "transferrable" coding interview question?
Tags: codenewbie, inthirtyseconds, interview
Published: 2020-06-23 11:44:20

Thinking about coding interview questions or take home assignments. We all come up with our own that we use to evaluate all our candidates. And it's a great tool for figuring out a candidate's capability to deliver working software.

Then I came across my friend's Tweet:

{% twitter 1275014930182180864 %}

I know of many job seekers who hunker down over weekends to do multiple coding assignments with fixed deadlines. Perhaps we are expecting too much or going overboard with our interview questions.

## Culture Fit Interviews

Other than take home assignments, we also do live coding interviews to further evaluate a candidate's culture fit - how do they handle stressful situations, how do they troubleshoot a problem, can the candidate communicate well or articulate the technical decisions they make. These are good for gauging whether a candidate could be a suitable co-worker. So the culture aspect is quite specific to your company culture and what you look out for in a suitable candidate. 

What i'm curious to know is if there can be a set of coding assignments that candidates can use to show that they know their shit. Not as formal as a certification, but more of a do you have a baseline competency for the role we are looking for.

## How about online coding puzzle sites?

Sure, we can use HackerRank or something similar for this as a shared reference point for the candidate's capabilities. But those coding problems tend to incentivise a certain kind of behaviour. Coding for performance in a coding puzzle is not the same as writing well designed & maintainable code.

## Make it transferrable?

Perhaps we should let candidates who don't make our cut to just bring their coding assessment to show the next company? I mean, you can say its your company's intellectual property... and it might encourage plagiarism... or give future candidates an unfair advantage if they know your coding test.

However, the flip side is this might actually accelerate the interview process. If the candidate is good, they wouldn't just copy pasta, they would do something properly (depending on the type of company you are in, copy pasta may or may not be a good thing).

## No dramas...

Also, this may also ease the stress level of newbie coders who are bogged down with so many coding interview assignments from the companies they interview at.

What do you think?