teleren/devto huggingface dataset:
How std::cin works in C++?
Tags: cpp
Published: 2021-04-09 20:06:34

   **std::cin** is used to get user input from external source.

When the user enters input, that data is put in a buffer inside of std::cin. The buffer is used to hold user input while it’s waiting to be extracted to variables.

**std::cin extraction steps:**
- If there is data already in the input buffer, that data is used for extraction.

- If the input buffer contains no data, the user is asked to input data for extraction. When the user hits enter, a ‘\n’ character will be placed in the input buffer.

- operator>> extracts as much data from the input buffer as it can into the variable (ignoring any leading whitespace characters, such as spaces, tabs, or ‘\n’).

- Any data that can not be extracted is left in the input buffer for the next extraction.

Extraction succeeds if at least one character is extracted from the input buffer. Any unextracted input is left in the input buffer for future extractions. For example:
```
int x {0};
std::cin >> x;
```
If the user enters: "22m", the variable x is filled with "22" leaving the "m" alone in the buffer.
Extraction fails if the input data does not match the type of the variable being extracted. 
For example, if the user enters "m" extraction would fail because "m" can not be extracted to an integer variable. But then what would be the value of x?
**Before c++ 11:a failed extraction would not modify the variable being extracted to.
However, as of C++11, a failed extraction due to invalid input will cause the variable to be zero-initialized.**

Look at this code

```
// uint16_t is a typedef for unsigned short
std::uint16_t x {0}; // max is UINT16_MAX (65535)
std::cin >> x;
```

when a user enters 65537, std::cin goes immediately into failure mode, but also assigns the closest in-range value to the variable. Consequently, x is left with the assigned value of 65535. Additional inputs are skipped.

**Before C++11, a failed extraction would not modify the variable being extracted. 
However, as of C++11, an out-of-range failed extraction will cause the variable to be set to the closest in-range value.**

Also note that when std::cin goes to failure mode, it will skip any other extractions, so you should put it back to the normal mode:
```
if (std::cin.fail())
{
    std::cin.clear();
}
```
Avoid Costly Rails Logging
Tags: ruby, logging, rails, performance
Published: 2021-04-09 20:04:40

---
title: Avoid Costly Rails Logging
published: true
description: efficiency gains with Rails.logger block syntax
tags: ruby, logging, rails, performance
//cover_image: https://direct_url_to_image.jpg
---

Let's be clear: This post is *not* targeting logger lines like this, with short/quick strings:
```ruby
Rails.logger.debug 'Rare Event!'
```

## Some Logs Can Be Costly

But every now and then you might stumble upon a more-intense logger line. Maybe you are serializing objects for debugging in your logs, or doing IO to load DB rows for debugging purposes. To simulate this, I will go to an extreme and just use `sleep`:

```ruby
Rails.logger.level = :info # simulating production

Benchmark.measure do
  Rails.logger.debug "Log: #{sleep 1}"
end.real

# 1 second passes...
=> 1.0011528139948496
```

This log does not print because it is `.debug` and our `logger.level` is `:info`. But we still had to endure the string-building logic.

## Possible Solution: Use Block Syntax

This syntax passes a block, which is only called if the logging actually runs.

```ruby
Rails.logger.level = :info # simulating production

Benchmark.measure do
  Rails.logger.debug { "Log: #{sleep 1}" }
end.real

# instantly returns a way smaller value
=> 1.4374993043020368e-05
```

If your logging level is `:debug` (usually in development), you will see the time go back up because the logging is actually happening:
```ruby
Rails.logger.level = :debug # simulating development

Benchmark.measure do
  Rails.logger.debug { "Log: #{sleep 1}" }
end.real

# back up to 1s, we are in debug and want our log
=> 1.0006488429935416
```

## Code Coverage Concern

One downside to this path is code-coverage, especially if you suppress `:debug`-level logging in your build environment. Unless your block is executed on a real case, you might not know for sure that it works. Maybe you have a typo or `nil.method` error in your log line and you will only find it in whatever special environment wants to actually log your string.

In my head you can make that more visible by making sure to add a newline on your block, so that automated code coverage tools will call you out. This way, the line will be red unless your build pipeline actually built you a string successfully:
```ruby
Rails.logger.debug do
  "Log: #{sleep 1}"
end
```
Flex boxes
Tags: beginners, css
Published: 2021-03-31 17:58:00

Flex boxes;
CSS flexboxes are modern CSS layout that help us to order elements vertical and horizontal.
It's easier to make responsive our website with flex box. Flex supported by all browser today.

There are 2 main item in flexbox. First Container,
 second Items.

Display property:
Using display:flex we make our container flexible.

Flex direction:
used to determine how items arranged in layout(horizontal or vertical) and applied to the container element.
*row (default): standard layout from left to right
*row-reverse: reverse layout from right to left
*column: From top to bottom layout
*column-reverse: From bottom to top layout

Flex-wrap:
Flex-wrap mostly used for creating responsive layouts. The flex-wrap property is specified as a single keyword chosen from the list of values below.

*nowrap (default): All elements are in 1 row.This is the default value.
*wrap: The flex items break into multiple lines.
*wrap-reverse: Behaves the same as wrap but it have reverse order.

flex-flow:
           is for setting both the flex-direction and flex-wrap properties in one command.

Justify-content:
                It defines the alignment along the main axis.

Align-items:
            It help us alignment of items in y-axis.
means

The order Property:
The order property specifies the order of the flex items.it means we can change the order of flex item according to our needs.

The flex-grow Property:
The flex-grow property specifies how much a flex item will grow relative to the rest of the flex items.
The value must be a number, default value is 0.

The flex-shrink Property:
The flex-shrink property specifies how much a flex item will shrink relative to the rest of the flex items. The value must be a number, default value is 1.

The flex-basis Property:
The flex-basis property specifies the initial length of a flex item.

The flex Property:
The flex property is a shorthand property for the flex-grow, flex-shrink, and flex-basis properties.

That's all for now I'll share more in my upcoming posts.
Thank for reading:)
Monolith vs Micro
Tags: architecture, devops, containers
Published: 2021-04-09 19:27:10

What exactly is a monolith and what is a Microservice? They're not exactly tangible and the definition seems a bit obscure at a glance so lets take some time to define both of them.

###What is a Monolith?
It's a type of architecture where everything is self-contained in a singular pipeline. Think of your major CMS' like Drupal or WordPress. These are large applications/services that attempt to cover a large breadth of tasks and workload. It's both versatile but also very heavy.

###What is a microservice?
Think opposite. These attempt to do a singular task or very specific task in a very small lightweight solution. Often times they are working in tandem with other microservices to achieve a larger task at hand. They are additionally usually paired with APIs so that they can properly communicate with other microservices.

###Why is this important?
We as developers need to understand the mechanics behind this so that we can further refine our own understanding of web development, not just at a face value but the technologies that drive our workflow. The current trend is to rely on microservice technologies instead of monolith types. This is because code deployment is taxing and resource heavy when attempting to do deployments or fixes on Monolith type services. In a microservice type system we can deploy hundreds of times a day and fix small parts of the system that need work or make changes without having to fear of damaging the overall system.

Some industry leaders such as Uber, Netflix, and Amazon have realized this a long time ago and have shifted over to the microservice model.

How a deployment works with Docker:
[Youtube](https://youtu.be/xwpUeBna4QE)
20 Types of Input in HTML & HTML5 | What are the All HTML Input Types | HTML Input Types All
Tags: html, css, webdev, javascript
Published: 2021-04-09 18:54:41

Hi, Welcome, in this video tutorial we are going to learn the following 20 types of inputs in html with a complete practical guide: input types drop down, html input file accept multiple types, a list of html input types, html input type boolean, html input type checkbox, html input type color, html input types currency, html input type checkbox checked, html input type calendar, html input type date, html input type date format, html input type datetime, html input event types, html form element types, html form element input types, html form input types file, input types in html, input types in html css, html5 new input types, input control types in html, javascript html input types, html input types list, html input type link, html input multiple types, html input accept multiple types, html form types of input, html input type range show value, html input types size

###20 HTML Input Types###

{% youtube K00ZmtHYo9M %}


------------------------------------------------------------------
- Please have a look at my website for more details!
         https://hmawebdesign.com
- Place an order for any Web Development work!
         https://www.fiverr.com/haaddison1?up_rollout=true
------------------------------------------------------------------

Suggested Videos:

10 Input Types in HTML Every Web Developer Must Know in 2021 | HTML5 Input Types Tutorials
https://youtu.be/8qBPKXRUOnk

How to  Design a Responsive HTML Email Template from Scratch 2021 | Create HTML Newsletter
https://youtu.be/c8GwsCZcBIc

How to Send Email to Client Using PHP Mail Function | Sending Email in PHP 2021 Tutorial
https://youtu.be/DeqOVJ-aXkg

$_POST | What is the Post Variable in PHP | How to Use Post Variables in PHP 2021
https://youtu.be/HO-TrXY4a1A

How to Define Variables in PHP | How to Create PHP Variables | (PHP tutorial-3) - 2021
https://youtu.be/bfqAa0Gm3YY

How to Start First PHP Web Project on Local Server/Localhost PHP Tutorial-2
https://youtu.be/18I7U4-nJb0

How to Start Web Project with Microsoft Visual Studio 2021 | Visual Studio Project
https://youtu.be/MLzuQ_pH9Ew

How to Get Start PHP Hello World Page on Live Web Server  |  PHP Tutorial - 1
https://youtu.be/Uc7uLD7Ur6M
------------------------------------------------------------------
Contact me through social media for web development work:

- Fiverr             https://www.fiverr.com/haaddison1?up_rollout=true
-  witter:          https://twitter.com/HmaWebdesign
- Facebook:    https://web.facebook.com/HmaWebdesign
- LinkedIn:      https://www.linkedin.com/in/engrmianayub/
- Instagram     https://www.instagram.com/hmawebdesign/
My 5 favorite HTML/CSS shortcuts in VSCode
Tags: vscode, html, css
Published: 2021-04-09 18:50:07

Tired of typing in `<div>` only to be forced to scroll back and type in the class elements?  Exhausted by nesting div into div to make your beautiful grid layout in what was supposed to be a flash, but turned into leaning on your left arrow key until your hand went numb?  If you said yes to any of that, you need to meet my buddy Emmet.  Emmet helps devs by allowing you to type in snippets within VSCode, and have beautiful HTML come out the other end. 

# 5. Quick siblings
 Good ol' addition symbols (+) will get you sibling elements.  Lets say you have a div with an image, h3, and paragraph.  With your cursor in the body of the div, just type `img+h3+p` and emmet will give you the beautiful html :
```
      <div>
          <img src="" alt="">
          <h3></h3>
          <p></p>
      </div>
```
And your cursor will be ready to insert the src for your image.
# 4. Nested elements
What if you need nested elements?  Just change out the + for a >!  `body>main>div>h1` will give you 
```
      <body>
          <main>
              <div>
                  <h1></h1>
              </div>
          </main>
      </body>
```
# 3. Multiple elements
Making a table can be time consuming, unless you're using emmet to its full potential.  Using the same technique, parentheses will let you multiply the number of nested children.  `div>(p*5)` turns into:
```
      <div>
          <p></p>
          <p></p>
          <p></p>
          <p></p>
          <p></p>
      </div>
```
# 2. fast ids
If you want to put some divs in with ids already attached, you can use css-style syntax.  `#article` becomes `<div id="article"></div>`.  But you can combine other techniques with this, for instance `div>#hello>p` becomes
```
       <div>
          <div id="hello">
              <p></p>
          </div>
      </div>
```
# 1. Divs, but with class!
If you paid attention during the last tip you'll probably already understand how to use classes.  Just add a dot.  `.bold` becomes `<div class="bold"></div>`.  You can also chain them together to add more (.bold.bigtitle.nav-bar-header) or combine any previous methods to get these going.  Try `div>#art1.article>#art2.article>#art3.article` and you'll see how many things we've just covered can be combined.

Let me know what your favorite shortcuts are!
Git Bisect > Encontrando o Commit Bugado
Tags: git, brazilliandev
Published: 2021-04-09 18:41:41

---
title: Git Bisect > Encontrando o Commit Bugado
published: true
description: 
tags: #git #brazilliandev
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jzpnvwxy5sq9ya7xzuei.png
---

Então você roda a sua aplicação e descobre um bug! 
Você olha o histórico de alterações do projeto e não consegue identificar quando o bug foi introduzido.
O jeito é fazer o checkout de cada revision e testar... um por um! Se for apenas 3 commits, ok! Mas se for 10, 15, 30... vai levar horas!

Aí que entra o `git bisect`!

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


O `git bisect` utiliza um algoritmo de pesquisa binária no histórico de alterações do seu projeto para descobrir qual commit introduziu o bug. Mas ele não faz tudo sozinho. Precisamos interagir bastante nesse processo mas ainda assim é bem mais fácil do que fazer tudo sozinho.

Para iniciarmos o processo, precisamos informar um commit "bad" (ruim) e um commit "good" (bom). Então o primeiro passo é descobrir um commit onde você tenha certeza de que a sua aplicação estava funcionando. Com esse commit na mão podemos começar.

```
$ git bisect start
$ git bisect bad            # A versão atual está ruim
$ git bisect good bf21fee   # bf21fee é uma versão boa
```

Então o `git bisect` vai fazer uma análise e irá te responder algo assim:

```
Bisecting: 84 revisões deixadas para testar depois disso (aproximadamente 7 passos)
```

A partir daí, ele vai selecionar um commit entre esses dois pontos, vai fazer o checkout e vai te perguntar se esse commit é "bom" ou "ruim". Então cabe a você decidir... ou melhor, testar! Faça o teste e verifique se o bug está lá.

Se o bug ainda estiver lá, basta digitar:

```
$ git bisect bad
```

Mas, se a versão estiver funcionando corretamente:

```
$ git bisect good
```

Após isso, ele irá responder:

```
Bisecting: 42 revisões deixadas para testar depois disso (aproximadamente 6 passos)
```

Em seguida, ele irá escolher um outro commit, fará o checkout e te perguntará novamente se o commit é bom ou ruim. Agora é só ir repetindo esse processo até acabarem os commits. Então o `git bisect` irá te informar qual é o primeiro commit ruim.

Pronto! Agora é com você! Hora de corrigir esse bug!
Progress Report - April 9th
Tags: beginners
Published: 2021-04-09 18:18:34

It's been about two weeks since the last post so it seemed like a good idea to make another one. Progress has been meandering but in the right direction. 

The first course, DataViz (React & D3) was completed. It took longer than I thought to get through 17 hours and it really slowed down towards the end. Still, the capstone project, Global Covid Deaths, was completed and deployed on GitPages. 

[We shipped the dataviz capstone]  (https://padosensei.github.io/CovidVoronoi/)  

You also broke ground on your own DataViz project, BJJViz, which required getting back into Python and coming up with a basic Beautiful Soup script that collects Win/Loss stats for visualisation later. 

We attended two online meetups, ticking boxes for JAMstack and API exploration.  It also highlighted the importance of getting active in making open source contributions. 
This last point was echoed in our chat with Padraig O'B. "Project work is just scratching your own ass."

We also put a Git course on our LinkedIn, which can't hurt. 

So not bad, not bad at all. 
Going into next week, 
- We're starting our Node/Express course with Coding Addict 
- while pushing forward with the BjjViz project
- We have a Blockchain meetup on Wed
- Tighten up your workflow. The [TomatoTimer](https://tomato-timer.com/) is a great way to track and push. If your attention / energy is flagging, switch! Let's really try to have 6 - 8 slots a day. 
- And keep up on your [ThisCodeWorks](https://www.thiscodeworks.com)
Install 350++ Tools Hacking
Published: 2021-04-09 18:16:02

Hallo, dikesempatan kali ini saya akan membagikan sebuah tools yang akan langsung menginstall 350++ tools termux untuk hacking. Jadi nantinya kalian tidak perlu menginstall tools lagi karna didalam tools ini sudah terdapat semua, tinggal kalian memilihnya.

Untuk penginstallan tools ini sangatlah mudah, tools ini merupakan tools library hacking, kenapa disebut seperti itu ? Karna didalamnya sudah terdapat 350++ tools untuk melakukan hacking.

Baiklah kita akan masuk ke menu pembahasan, yaitu cara untuk menginstall tools library hacking. Nama dari tools ini adalah Onex.

Cara penginstallan.
Langkah pertama silahkan kalian buka dahulu termux kalian, dan lakukan update && upgrade.

$ pkg update && upgrade
$ pkg install bash
$ pkg install git
$ git clone https://github.com/Rajkumrdusad/onex
Tunggulah beberapa saat sampai tools berhasil terinstall.
$ cd onex
$ chmod +x install
Berikan “install” permission dengan mengetikan chmod +x
$ ./install
Setelah semua terinstall, kalian bisa menggunakan command onex -h untuk option lebih lanjut.
Sekian artikel saya ini, jika ingin info lebih lanjut tentang termux dan info tips hacking lainnya silahkan kunjungi https://www.sangkelana.org
Day~4 of #100DaysOfCode
Published: 2021-04-09 18:15:54

*Hello Everyone,*

*Today is day three of my 100daysofcode challenge, I did nothing much, learned about signals in Django, and implemented post_save signals and receiver, I wasn't able to grab 100% of its concept but I was able to use it in my custom user profile. I also created a new app in the project for all the notes in this notes app I have created two models one for tags and the other for notes. I also rendered a template from Django.*

*This is how the template looks*
![Screenshot_2021-04-09 Keep Notes 📕(2).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1617991651115/3nZX4GgXC.png)


![Screenshot_2021-04-09 Keep Notes 📕(3).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1617991677388/K-lSCyRMN.png)


*This is how the user's profile Looks*

![Screenshot_2021-04-09 Keep Notes 📕(1).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1617991698169/HdTswWf3k.png)
Live Zoom programming Sunday with Gábor Szabó
Tags: perl, meetup, mojolicious, pairprogramming
Published: 2021-04-09 18:14:27

---
title: Live Zoom programming Sunday with Gábor Szabó
published: true
date: 2021-04-09 18:10:29 UTC
tags: Perl,meetup,Mojolicious,pairprogramming
canonical_url: https://phoenixtrap.com/2021/04/09/live-zoom-programming-sunday-with-gabor-szabo/?utm_source=rss&utm_medium=rss&utm_campaign=live-zoom-programming-sunday-with-gabor-szabo
series: Live-coding a web app in Perl and Mojolicious
---

We’re doing part 2 of pair programming a course management app in Perl and Mojolicious this **Sunday at 10 AM** Central US time. [Get more details and register here.](https://perlmaven.com/course-management-app-in-mojolicious)
The strongest hearts of Rwandans
Tags: react, reason, devjournal, showdev
Published: 2021-04-09 18:10:11

__2 decades and 7 years__ are gone after __Tutsi Genocide__ happened in __Rwanda__. The very horrible tragedy!  

We Rwandans were never held back by our history!
We moved on!
``We remember, unite and renew!
``  

## We see the light after the darkness!  
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c3r60gzcznsu20qxu2or.jpg)    
  

This Friday, I had a session about __resilience and stress management__.  

But let me talk about resilience!  

__Resilience__ is the ability to withstand adversity and bounce back from difficult life events.  

Good definition, isn’t it? It’s about keeping your head up in hardship.  

Frankly, we all face hardship but few of us withstand.
Being resilient doesn’t mean that a person won’t experience difficulties, it simply means that a person stays strong and calm in situation.  

Those people who are resilient are _adaptable, optimistic and pragmatic_.  

You can become a resilient too by _building your connection (relationship), fostering your wellness, finding your purpose and seeking for help_.  

You can be resilient in stressful situations and other hardships.
It’s not that is, is it? But it helps of course, it makes you move on and continue living your life instead of being held back by your past.  

>Losing your husband/wife, children, brothers, sisters, parents, entire family and still can be able to forgive the person who took them from you is not easy thing to manage.
``Saying that that person is  resilient isn’t enough, He/She is a hero, no maybe other term.
``  

It wasn’t imaginable that people will live as they live today in Rwanda after what happened.  

But with their strongest hearts, they moved on.
They forgave their neighbors who slaughtered their families and accepted to live with them again in peace.
It’s not resilience science they studied, __it’s just humanity__!  

What other example could be better than those people?
You can overcome any hardship as Rwandans did!  

``Twibuke twiyubaka!
``
Toast Notification in Laravel Livewire Tutorial
Tags: laravel, livewire, php, javascript
Published: 2021-04-09 18:07:36

What is Livewire?

Livewire is a full-stack framework for Laravel that makes building dynamic interfaces simple, without leaving the comfort of Laravel. Livewire relies solely on AJAX requests to do all its server communications. Livewire completely sends Ajax requests to do all its server-side communication without writing any line of Ajax script.

What is Toast Notification?

A toast notification is a message object that presents timely information, including confirmation of actions, alerts, and errors.

In most projects, We are use sweetalert2 for toast notifications. Sweetalert2 is very easy to use and implements in any frontend frameworks like Vue.js, React.js and etc.

We have already a project of Laravel Livewire Crud Example. so in this blog, we don't need to create a project for this example. Let's start with some basic steps.

https://techvblogs.com/blog/toast-notification-livewire-laravel
Anyone know what's up with these "fake" github accounts forking/starring random repositories?
Tags: github, git, repository, account
Published: 2021-04-09 17:44:43

Hey!

I've been doing many POC projects and sharing them on Github. Most of the time these are just tutorials I've completed. Nothing interesting or valuable really. And time to time I notice that someone starred my repo. I checked these account's activity and it seemed like they are just starring and forking random (random to me) repositories. Does anyone have an idea why?