teleren/devto huggingface dataset:
Quick post about the SQLite UPSERT and the new RETURNING clause.
Tags: sql, sqlite
Published: 2021-05-28 16:59:49

# The RETURNING clause

You can read the official docs [here](https://sqlite.org/lang_returning.html).

Many times we find ourselves wanting to return some data (probably the id) after inserting records in our database. Since version `3.35.0` (2021-03-12), SQLite supports the `RETURNING` clause, which allows you to **return a result row (or specific columns) for each modified database row by a `DELETE`, `UPDATE` or `INSERT` statement.** 

```sql
INSERT INTO customers (fullName, birthdateTimestamp, address) 
VALUES ('Andrew Mitch', 643911868, '206 Grange Road, Gillingham') 
RETURNING *;
```

The above query, after execution, will return us every value inserted in the database, along with the `id` of each row. This way we can avoid making another `SELECT` query to the database. Pretty neat, eh?

# The UPSERT clause

You can read the official docs [here](https://sqlite.org/lang_upsert.html).

Another nice little feature is the `UPSERT` clause. This was added in version `3.24.0` (2018-06-04) and it causes `INSERT` to behave either like an `UPDATE` or a `no-op`, in case of a `UNIQUE CONSTRAINT` or a `PRIMARY KEY CONSTRAINT` violation. 

To elaborate, let's suppose that you have an `action_records` table which holds all actions fired by users in the `users` table, **for a specific session**. When a new action is fired you want to either insert a new `action_record` with no error, or, if existing **AND has the same session timestamp** (this is handled by the `ON CONFLICT` clause), update the old one. You can also optionally add a `WHERE` statement which will result in a `no-op`, if not met. The query below should do it:

```sql
-- Create users table and assign userID and sessionStartTimestamp as a UNIQUE CONSTRAINT.
DROP TABLE IF EXISTS "action_records";
CREATE TABLE IF NOT EXISTS "action_records" (
	"id" INTEGER NOT NULL,
	"userID" INTEGER NOT NULL,
	"sessionStartTimestamp" INTEGER NOT NULL,
	"errorMsg" TEXT,
	PRIMARY KEY("id" AUTOINCREMENT),
	FOREIGN KEY("userID") REFERENCES "users"("id") ON DELETE CASCADE,
    UNIQUE(userID, sessionStartTimestamp)
);

-- Insert new record or update the old one based on UNIQUE_CONSTRAINT OF userID & session_start_timestamp
INSERT INTO action_records (userID, errorMsg, sessionStartTimestamp) 
VALUES (258, null, 643911868) 
ON CONFLICT(userID, sessionStartTimestamp) -- Conflict when a record for the same user and session exists
DO UPDATE SET errorMsg = 'An error occured'
WHERE errorMsg IS NOT NULL -- This will be a no-op in case there is already an error and you don't want to update it
RETURNING *; -- Optionally adding RETURNING to retrieve any number of columns we want
```

# UPSERT & RETURNING combined

One thing I really liked is the fact that you can combine those clauses by simply adding `RETURNING *` at the end of the query. This way any row (or specified columns), either inserted or updated, will be returned.
How to Unminify
Tags: html, css, javascript
Published: 2021-05-28 16:31:58

you want to view page source, but it turns out the code is minify? Take it easy, you can use the following tools to unminify (unpack, deobfuscate) JavaScript, CSS, HTML, XML and JSON code, making it readable and pretty.

1. https://unminify.com/
2. https://www.unminify2.com/
3. https://www.unminified.com/
4. https://cssminifiers.com/
5. https://www.ipvoid.com/

if you know another tool for unminify, please share it here. And don't forget to visit [Bisabos.com](https://bisabos.com), to get articles about web programming, web design, and others.
HTML : You can distinguish if the form button pressed
Tags: html, tutorial, webdev, codenewbie
Published: 2021-05-28 16:23:55

Most of us are unaware of the fact that we can distinguish if the form button pressed by just giving them a name/value pair as shown below - 

```html
<form action="process" method="post">
     ...
     <input type="submit" name="edit" value="Edit">
     <input type="submit" name="delete" value="Delete">
     <input type="submit" name="vote_up" value="Vote up">
     <input type="submit" name="vote_down" value="Vote down">
</form>
```

In the server side, the actual button pressed can then be obtained by just checking the presence of the request parameter associated with the button name. If it is not null, then the button was pressed.

Above code is just to explain you about this html hidden feature however you can use button tag instead.

<a href="https://www.buymeacoffee.com/rkycom" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

With all that being said, I highly recommend you keep learning!

Thank you for reading this article. Please feel free to connect with me on [LinkedIn](https://www.linkedin.com/in/www-rajeshkumaryadav-com/) and [Twitter](https://twitter.com/rky_com).
Turning User Stories Into Enabling Specifications
Tags: uncategorized, agile, productowner, scrum
Published: 2021-05-28 17:15:14

---
title: Turning User Stories Into Enabling Specifications
published: true
date: 2021-05-28 16:17:13 UTC
tags: Uncategorized,agile,productowner,scrum
canonical_url: https://theagilecouch.com/2021/05/28/turning-user-stories-into-enabling-specifications/
---

I’ve had a contractor re-building my back deck, and adding a screened porch area. I had a little side-project I wanted done in the garage, so we walked in there so I could describe it.

**_I told my contractor a story_** , showing him where my car fits in the garage, where the “extra fridge” sits, how much room there is to walk between my side view mirror and the fridge door handle. How my wife has to walk around my side of the garage to get in the house, and when she’s carrying two arms full of grocery bags, it’s hard to get through.

I told him I don’t know enough about housing construction to know if those 2×6’s were structural supports, whether they could be cut and engineered with a header over the top, and if that would provide enough support for the two stories above. I pointed out where the electrical plug is, and I believe the fridge can plug into the same place, without needing to cut the stud that the plug is on.

When he showed the project to his lead builder he just said _“There’s pipes and several walls meet here (points up). Prop this with a jack stand. Cut these two studs (pointing), move them out, supporting the next two, and cut 2×6’s to create a header spanning them.”_

All of these parts needed to happen. Sometimes the customer needs to tell their story. This activity alone is useful. I’ve seen customers talk to a Product Owner and the outcome was that no work proceeded; the person realized their need was outdated, or they had a solution to the problem already. Helping the customer say “No” is just as valuable as taking an order. Remember the **Agile Principle #10, “the art of maximizing the amount of work not done”**.

A Product Owner’s job is to understand the customer’s needs in both the language of the customer, and the language of the developer. Although we often use the terms “Story” or “User Story” as interchangeable with “card”, “PBI” (Product Backlog Item), “Feature”, or “Enhancement”… a true User Story is really just one method of telling the user’s journey from his current need to his successful resolution.

The role of the Product Owner is to translate that into “Enabling Specifications”, a list of discrete work items that the Development Team can immediately understand and begin work on.   
_Note: “Begin” work. If the Development Team has to ask questions before they can start, the written PBI does not yet allow them to “begin”. This is what’s meant by “Enabling”._

_ **The PBI is the gunshot that sets the runner at the block free to race forward.** _
Schedule chicken
Tags: agile, extremeprogramming, xp, courage
Published: 2021-05-28 16:15:23

Sometimes we are faced with situations in which two or more people are working with a common goal and there is a mutual dependence on delivery: the work of one person cannot be deployed without the other fulfilling the agreed and vice versa. In this scenario, if one of the people delays his or her part, all delivery is compromised. 

Depending on the culture of the company, that person who has been delayed may suffer some kind of punishment. Is going to have to explain in detail what happened, will be going to be under pressure to deliver as soon as possible, and in more extreme situations may not be promoted or even get fired. 

But what happens when all people involved know that the agreed deadline will not be met?

Out of fear (lack of [courage](http://www.extremeprogramming.org/values.html)?), no one wants to be the first to break the ice and then comes a situation of deadlock, known as _Schedule chicken_. All are waiting, in the expectation that another person is the first to say that will not be able to deliver what was agreed, causing the date of delivery of all to be extended, leaving the person who brought the information to be held accountable and eventually penalized for the delay alone.

And this deadlock can continue until the deadline, which worsens the whole situation, since at this time the people involved will be forced to face reality in a situation where they can no longer take any action to get around the problem. The result can only be one: the project will delay and the client will only be informed of this on the same day she expected to receive the delivery. 

If this type of situation is recurrent, a common long-term effect is for the client to lose confidence in the team. The consequences may be the imposition of stricter contracts, micromanagement or other practices that are detrimental to both parties.

## Conclusion

It is very important to always give feedback to the client as soon as possible, controlling their expectations. When we are more transparent and courageous, we can resolve this type of situation described in this article in other ways, the most obvious being to decrease the scope of delivery and reviewing customer priorities. Or, in other words, working in an agile way, adapting to the inevitable changes we encounter throughout the software development process.

## References

* [Planning Extreme Programming](https://www.goodreads.com/book/show/67839.Planning_Extreme_Programming), Kent Beck and Martin Fowler (page 33).
* https://en.wikipedia.org/wiki/Schedule_chicken
DotNetDates
Tags: fsharp, dotnet, dates
Published: 2021-05-28 14:25:47

I made a little diddy I wanted to share with you all. It's nothing too grand or impressive. I just really like how it turned out and even more happy with the cleanliness of the code.

It's a simple form to play around with date formats in .NET. Here's the [GitHub](https://github.com/fischgeek/DotNetDates) and a screenshot.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/10i3ea3bopl660s0x0cu.png)

It was all written with F# (minus the C# Forms project bit). What is neat though is I only laid out the basic locations of where I wanted things to go using FlowLayoutPanels.

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

 Then passed those to my F# to handle the rest.

``` csharp
using System.Windows.Forms;
using DotNetDates.FSharp;

namespace DotNetDates
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            var form = this;
            FormBuilder.Build(form, flpFormatMethods, flpFormatSpecifiers, flpCustomFormats, flpCreateYourOwn, flpCreateYourOwnResult);
        }
    }
}
```
I'm curious to read what you think and thanks for checking it out!
What are your thoughts on search engine optimization (SEO)?
Tags: discuss, writing, webdev, watercooler
Published: 2021-05-28 16:07:53

Hey all,

I'm doing some research on developer experiences and sentiments toward search engine optimization (SEO) and want to hear from you.

**What comes to mind when you hear SEO?**
**Have you ever spent any time on your SEO? Why or why not?**

Thanks in advance!
[Dicas do VIM] Excluindo linha ou caracteres no VIM / NeoVIM
Tags: neovim, vim, delete, braziliandevs
Published: 2021-05-28 16:07:34

Pressionando a **tecla S** (S maiúsculo) toda linha onde está o cursor é apagada e em seguida o VIM entrará no modo inserção.

```
S
```

Também é possível excluir a linha onde está o cursor sem entrar no modo de inserção, basta digitar

```
dd
```

A **tecla X** (X maiúsculo) funciona como a tecla *Backspace* 

```
X
```

E a **tecla x** (x minúsculo) funciona como o *Delete*.

```
x
```
The benefits of serverless for staff-strapped teams
Tags: serverless, devops, video, podcast
Published: 2021-05-28 15:59:22

{% youtube dVaoq5BoaHQ %}

Zachary Randall talks about the benefits of serverless technology, especially for small and understaffed teams. Aside from saving money on the hosting bill, serverless can simplify maintenence. We also discuss what it takes to get started with serverless, and what changes are necessary from a tooling or workflow standpoint.
Create a starter kit that fits your needs. 
Tags: react, architecture, javascript, news
Published: 2021-05-28 15:15:56

I work in a french company called [theTribe](https://thetribe.io/) where our typical projects are 3 to 6 month long, generally web or mobile app.

We usually end up choosing a mix of JS / Python or PHP for our web based project and React Native or Flutter for our mobile projects. 

This means a lot of projects, with different needs but also a lot of common tasks we need to solve each time. (think linting, continuous integration, deployment  and provision automation, DB setup, Test setup, authentication etc) 

### the painpoints

A typical bootstrap takes roughly between 3 to 10 days depending on the specificity of the project.

Historically we had different starter kits, for mobile, php and javascript projects.  Each of them relying on different patterns, and since they were scattered it was difficult to maintain them and/or promote their use.

Therefore we decided to tackle this painpoint by creating a new generator which would aim : 

- to centralize our needs.
- allow the dev to choose between the different main tech we use at theTribe
- allow a better maintenance of the project

 

### the solution

We ended up choosing Yeoman which allow us to provide a CLI experience with prompts where the dev will be asked a few questions to choose the stack he/she wants to use and some variables for the project identity

The current MVP covers the most used technologies which are:

- Front-End Architecture : you can choose between `Create React App` and `NextJs` as a boilerplate app
- Backend-End Architecture : you can choose between `Node` and `Symfony` (Node backend comes with Express and TypeORM)
- Containerization In dev environment with `docker-compose`
- Provision/Deployment automation with `Ansible`
- Instance Management with `Terraform`
- Continuous Integration with `CircleCI`

All this comes with the appropriate file structure and allow each dev to kickstart their project easily

We just have open-sourced it on [https://github.com/thetribeio/generator-project](https://github.com/thetribeio/generator-project) and we would appreciate any feedback,

In parallel we also have uploaded it on a the [Fast Modular Project](https://fast-modular-project.com/starters/thetribe-generator-project) which is a platform which aims to reference different starter kits from different companies and individuals. 

Do not hesitate to pin and like if you appreciated the article ❤️
$18k/m as a self-taught developer
Tags: selftaught, apps, beginners
Published: 2021-07-21 07:58:23

---
title: $18k/m as a self-taught developer
published: true
date: 2021-05-28 15:29:07 UTC
tags: SelfTaught, apps, beginner
canonical_url: https://www.nocsdegree.com/18k-self-taught-developer/
---

 ![$18k/m as a self-taught developer](https://www.nocsdegree.com/content/images/2021/05/iu-25.png)

Here's a podcast interview with Alex, a self-taught dev whose company makes $18k/m. Alex talks learning to code and building businesses in this episode of the podcast. His translation app has 800,000 users which is a great achievement for a young entrepreneur without a college degree.

Alex has previously done a [written interview here on the blog](https://www.nocsdegree.com/alex-left-a-tough-life-in-ukraine-and-taught-himself-to-code-and-make-apps/) but it was great to explore things in more detail in the podcast. I hope you enjoy it!

<!--kg-card-begin: html--><iframe width="100%" height="180" frameborder="no" scrolling="no" seamless src="https://share.transistor.fm/e/a268fbe6/dark"></iframe><!--kg-card-end: html-->
An Easy Admin Panel - Rails 6
Tags: ruby, rails, tutorial
Published: 2021-05-28 15:05:43

Having an admin panel in your Rails application is honestly, to me, the best thing to do when it comes to keeping track of your users and giving them permissions. Finding out how to have an admin panel though, that was tough, mainly because I wasn’t searching for the right thing. The [rails_admin gem](https://github.com/sferik/rails_admin), so simple but can control so much! The installation and usage is very simple depending on what you are trying to use it on. I should probably tell you, I am using [devise](https://github.com/heartcombo/devise) with the user having a boolean attribute called admin.
```
 create_table "users", force: :cascade do |t|
...
    t.boolean "admin", default: false
...
  end
```
#### Installation

The installation all starts with you putting `gem ‘rails_admin’` in your gemfile amd running `bundle` in your terminal. After you bundle, you will need to run the rails admin generator - `rails g rails_admin:install` - doing so will ask you a question, just go ahead and hit enter. Once the generator is done, it will create a new route (“/admin”) and an initializer too.

You basically have it all working now. Just go to http://localhost:3000/admin and you should be brought to the admin panel! You can navigate this as much as you want to get a feel for where everything is. 

We now need to add some authorization to the initializer. If you go to `config/initializers/rails_admin.rb` and add this line of code:
```
   config.authorize_with do
      redirect_to main_app.root_path unless warden.user.admin == true
    end
```

Great! Now the only users that can access your admin panel are the ones that are admins. If you need to make yourself and admin go into the rails console with `rails c` in the terminal and put in these 3 lines:


```
u = User.first
u.admin = true
u.save 
```
Now your user has admin so you can mess around in the admin panel.

#### Navigation to Admin Panel

If you check rails routes you will notice at the very top there is a new route called rails_admin, we will use this to get a navigation button that only the admin can access. Go to where your header or navigation bar is located and add this line of code wherever you want:
```
<%= link_to "Admin Panel", rails_admin_path, class:"btn btn-default mb-2 lg:mr-2 lg:mb-0 block" if admin? %>
```
I have an admin? Helper method so if the user is an admin, they will be able to see the navigation button to the admin panel. In order to do this we will need to go into our helpers in the application_helper.html.erb and add this method:
```
   def admin?
        user_signed_in? && current_user.admin?
    end
```
That’s it! You should now have a perfect admin panel that is easy to setup and easy to use!
Knowledge test
Tags: csharp
Published: 2021-05-28 14:56:13

I did a knowledge test where I received a link with 3 steps, unfortunately, I stayed stucked at second step.

The first step ask for to get te middle char of any word.
If the word has a even length, return 2 middle digits otherwise, the middle digit.

**Solution**

```csharp
public static string GetMiddle(string s)
{
  if(s.Length <= 2) return s;
  
  var isEven = s.Length % 2 == 0;
  
  // I remove 1 digit because de array is 0 index;
  // I always round up for de odd words, even words the division is exact
  // rounding up odd words, i dont need to handle with even/odd on the 1 subtraction
  var middleDigit = (int)Math.Ceiling(s.Length * 1M / 2M) - 1;
  
  return s.Substring(middleDigit, isEven ? 2 : 1);
}
```

At this point, everything is ok.

---

The second step asked to me for count the notes of an ATM dispenser just with notes of values: 100, 50 and 20.

**Withdrawals**
* $260
* $40
* $230
* $250

**Outputs**
* {2, 0, 3}
* {0, 0, 2}
* {1, 1, 4}
* {2, 1, 0}

**Solution**

```csharp
public static int[] Withdraw(int amount)
{
  var result = new int[] { 0,0,0 };

  var note100Result = (int)Math.Floor(amount * 1M / 100M);

  if(note100Result > 0)
  {
    var remainValue = amount - (note100Result * 100);

    if(remainValue % 50 !=0)
      if(remainValue % 20 !=0)
        note100Result--;

    result[0] = note100Result;

    if(note100Result > 0)
      amount -= note100Result * 100;
  }

  var note50Result = (int)Math.Floor(amount * 1M / 50M);

  if(note50Result > 0)
  {
    var remainValue = amount - (note50Result * 50);

    if(remainValue % 20 !=0)
      note50Result--;

    result[1] = note50Result;

    if(note50Result > 0)
      amount -= note50Result * 50;
  }

  var note20Result = (int)Math.Floor(amount * 1M / 20M);

  if(note20Result > 0)
  {
    result[2] = note20Result;
  }

  return result;
}
```

**The logic is:** you just can proceed to another note if the remaining value is fully divisible for *ANY ONE* of the other notes, otherwise,
you need to subtract 1 note of the current note counter.

*Of course, this can be done in other ways, with a loop and Linq as example, but I preferred to do like this to be more explainable.*

---

As I didn't finish the second step, I even couldn't see the third step :(

---

As I said earlier, I stayed stucked at this step. I did this test after a long day of work, so my brain was not okay to do tasks like this.

My tip for this tests:

* Do this in a unstressed moment, after take a snap or a good sleep night (if you can choice this moments obviously)
Javascript's import vs require?
Tags: javascript, programming, todayilearned
Published: 2021-05-28 14:55:31

I was recently creating a script that requested data from a 3rd party API, and I was running this script within the server of a Sapper project. In order to correctly get this data, I went through promise chaining, and I had to use an '.mjs' extension on my script.

Since Node v12, ES modules has been enabled by default. Hence my use of '.mjs' to run my file including a node module.
Another way to resolve this issue is to use import with Node.js, you have to edit the package.json to 'type':'module'. However, using this caused my Sapper server to crash since it wasn't supported, as the rollup file outputs the format to commonjs [Explained in (this GitHub issue](https://github.com/sveltejs/sapper/issues/1459)).

Commonjs uses require and module.exports, while ES6 uses import and export. Import and Export are used to refer to an ES module, and can't be used with other file types. 

Reading a little more up on it, here are some differences I found
- import will be run in the beginning of the file, always, whereas require can be called anytime and anywhere
- import gets sorted to the top of the file
- import can be used to selectively load parts you need, and can save memory
- import can be asynchronous, which apparently perform better, and require is synchronous


Are there any others that I missed?
tl;dr: ES6 -> import, export default, export  vs commonjs -> require, module.exports, export.foo