teleren/devto huggingface dataset:
Better Conditional Rendering with Is.js
Tags: react
Published: 2020-09-10 04:27:38

---
title: Better Conditional Rendering with Is.js
published: true
description: 
date: 20200806T10:00Z
tags: react
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/sbs7bbexvna7pexkaez4.jpg
---


## What is Conditional Rendering
`Conditional rendering` as a term describes the ability to render different UI markup based on certain conditions. In React-speak, it is a way to render different elements or components based on a condition. This concept is applied often in the following scenarios:
- Rendering external data from an API
- Showing/hiding elements
- Toggling application functionality
- Implementing permission levels
- Authentication and Authorization

## Problems With Readability
Take the `UserInfo` component as an example. The user object must be populated with data before the `h1` can be rendered. To achieve this, a Logical `&&` is used to block the right hand side of the expression from being rendered if the left hand side is fails to meet a condition. This is also known as Short Circuit Evaluation.
```jsx
function UserInfo({user}) {
  return (
    (user !== {}) && <h1>{user.name}</h1>
  )
}
```
While this format gets the job done, it can lead developers astray when trying to quickly infer the 'meaning' of a component. The problem is especially evident when rendering is dependent on array length.
```jsx
function UsersList({users}) {
    return (
        (users && users.length > 0) &&
            users.map(user => <UserInfo user={user} />)
    )
}
```
This is objectively ugly and the nested `&&` operators are just as bad as nested ternaries.

## A Convenient Solution

`Is.js` is a micro-library that, [at only 4kb when gzipped](https://bundlephobia.com/result?p=is_js@0.9.0), solves this readability issue without adding much to an application's total package size. It comes packed with plenty of features, but I'll only be focusing on the parts that lend themselves to making conditional rendering more declarative and easy to read.

To get started, install is.js in your app:
```bash
npm install is_js
```

Now you can include `is_js` in any file.
```javascript
// src/app.js
import React from "react"
import is from "is_js"
...
```

## Examples
### Check for Emptiness
```jsx
function UserInfo({user}) {
    return (
        is.not.empty(user) &&
            <h1>{user.name}</h1>
    )
}
```
```jsx
function UsersList({users}) {
    return (
        is.not.empty(users) &&
            users.map(user => <UserInfo user={user} />)
    )
}
```
The intentions of this code are much more apparent because they are immediately readable by a developer. No interpretation required.
#DeveloperMom #MomWhocodes #IMSHE
Published: 2020-09-10 04:14:54

Hello Developers, how u all the doing?
I am Meenakshi from India, New to the DEV. I believe, every single day is a new learning, and i am ready to learn... I a mom for two beautifully handsome boys. I think its the high time to start doing what I always wanted to do.... I m sort of a #newbie .... so will be looking for some guidance from u all....

thanks in Advance.
#happycoding
How does one go to bed?
Tags: productivity, codenewbie, webdev, devops
Published: 2020-09-10 03:48:03

I have recently started coding frequently and I can't tell how many times the clock struck midnight and my eyelids are wide open, my eyes are dry and red, and all I can think about is "how much I don't want to sleep because I want to code, but I have to." How do people deal with this? 
I imagine most people just go coding away through dawn, but I actually NEED to have healthy habits by this time in my life. I guess good old discipline has been flown out the window and I'm gonna have to go downstairs and pick it back up.
Anyone have a better suggestion for this lazy begginer?
Avoid Wake locks in Android apps
Tags: android, energy, battery, apps
Published: 2020-09-10 03:35:22

Apps users hate if the app drains the battery of their mobile phones. With some careful coding this situation can be avoided.

Wake locks are evil and is the main cause for energy bugs in android apps. Here is a nice blog on avoiding energy bugs. 

https://www.blog.finotes.com/post/how-to-avoid-energy-bugs-caused-by-wake-lock-in-android-apps
Availability in Distributed Systems
Tags: softwaredevelopment, programming, softwaredesign, softwareengineering
Published: 2020-09-10 10:17:23

---
title: Availability in Distributed Systems
published: true
date: 2020-09-10 02:48:16 UTC
tags: softwaredevelopment,programming,softwaredesign,softwareengineering
canonical_url: https://towardsdatascience.com/availability-in-distributed-systems-adb43df78b9a
---

[![](https://cdn-images-1.medium.com/max/2600/1*0kwLo9ta1krEP8C8bEl-9g.jpeg)](https://towardsdatascience.com/availability-in-distributed-systems-adb43df78b9a?source=rss-577e2119c7f2------2)

##What are Nines in Availability?
If a system has availability of 99%, it is called two nines availability as the number nine appears two times. Even a 99% available system gives almost four days of downtime a year, which is unacceptable for services like Facebook, google.

For 99.9% availability is known as three nines and 99.99% as four nines availability. Five nines availability (99.999%) gives a 6 minutes downtime in a year, which you can say is the gold standard of high availability.
High availability (HA) is a characteristic of a system that aims to ensure an agreed level of operational performance, usually uptime, for a higher than normal period.
Having high availability comes with trade-offs like higher latency or lower throughput. When you are a system designer, it’s your job to think about these trade-offs and decide how high available systems you need. Maybe a part of your system needs to be highly available, not the whole system.


[Continue reading on Towards Data Science »](https://towardsdatascience.com/availability-in-distributed-systems-adb43df78b9a?source=rss-577e2119c7f2------2)
** If you don't have a medium account you may use [this link](https://towardsdatascience.com/availability-in-distributed-systems-adb43df78b9a?source=friends_link&sk=773392e4be39c667162ba9a757cf8fd1)
Join the virtual LondonCSS event on Sept. 10
Tags: webdev, css, events
Published: 2020-09-10 02:19:08

I'm pleased to share I'll be speaking at LondonCSS about the story of [StyleStage](https://stylestage.dev) and sharing tips on how to create your submission including a few new resources.

Join myself and fellow speakers Adam Argyle and Cassie Evans at LondonCSS, a _free_ virtual meetup!

{% twitter 1301914903905796096 %}

Register to make sure you have the access info, and to check the even time for your timezone.

**[Event Registration >](https://live.remo.co/e/london-css-endless-summer/register)**

Hope to "see" you there! 😊 I'll be sharing my slides and other resources [on Twitter](https://twitter.com/5t3ph) after the event.
TDD approach 
Tags: testing, beginners, tdd
Published: 2020-09-10 02:16:58

> Thanks to my wife, this blog post is because of our morning tea discussion. She asked me to convert the discussion into a blog :)
 

* You start with a test for a smallest unit of code you want to deliver (At this point in time it doesn’t exist yet)


```

describe 'Arithmetic::Sum' do
  describe '#add' do
   it 'is expected to take 2 and 3 and return 5' do
     expect(subject.add(2,3)).to eq(5)
   end
  end
end

```

* Ensure test fails with an error that `Unit of code` you are testing doesn’t exist yet.

```
 Arithmetic::Sum not found error

```
* Coding time...., write just minimum code necessary to make the test fail for the reason you expect.

 * Create Arithmetic module
 * Add class inside that module
 * Add method `add` (for now its empty)

 ```
   Code errors out saying nil and 5 are not equal.
 ```

* Coding time..., Now write the minimum code necessary to make the test pass.

 ```
  def add(a, b)
    return 5
  end
 ``` 

* Test should turn green at this point.
* Add few more test expectations to deliberately make the test fail, and ensure that the failure messages are meaningful.
 
```
 describe 'Arithmetic::Sum' do
  describe '#add' do
   it 'is expected to take 2 and 3 and return 5' do
     expect(subject.add(2,3)).to eq(5)
   end

   it 'is expected to take 4 and 6 and return 10' do
     expect(subject.add(4,6)).to eq(10)
   end

   it 'is expected to take 100 and 100 and return 200' do
     expect(subject.add(100,100)).to eq(200)
   end
  end
 end

```

* As Uncle bob says, `As the Tests get more Specific, the Code gets more Generic`. Enhance add method to be more generic which could handle all the test cases mentioned above.

```
 module Arithmetic
   class Sum
     def add(a, b)
      return a + b
     end
   end 
 end

```

* Run the tests again and see all of them turn green.
* Commit the code :)

Example given in this blog follows TDD approach i generally follow when writing ruby programs. Just curious how Java or Go community approach TDD as there is a compilation phase before running a program. I will research and if possible add another blog in continuation to this based on how their dev community approaches TDD.

Thanks to Uncle Bob and his [clean coder videos](https://cleancoders.com/library/all) :)
E-attendance v1.0 (Google Play)
Tags: smallgcok, android, googleplay, eattendance
Published: 2020-09-10 00:59:07

💬💬 Since classes are all online now 🌐, when you want to take the attendance, it will be recorded in a file 📄, after then you still have to send the file to the 📧 school administration, sometimes you forget to send it 🙄. Now use "E-attendance" you can instantly share student attendance with the school administration ✔️ …

🔎 E-attendance ver 1.0
1. Add registration function (Administrator)
2. Add login function (administrator and user)
3. Add create new users function
4. Add attendance function
5. Add report function

📲 Google Play (App link):
https://play.google.com/store/apps/details?id=com.smallgcok.eattendance

🎥 YouTube (Demonstration video):
https://youtu.be/cW80bubQk_E

---------------------------------------------------------------------

📌 *Share with your friends~~~

📌 Group (BUG Report/Function Discussion)：
https://www.facebook.com/groups/SmallGCOk.Programmer

📌 More SmallGCOk App：
https://www.smallgcok.com/p/appshare-android-google-playpowered-by.html

📄 *繁中、简中、Español、English

⏩ e點名 >>> 還在使用 Excel 點名後再傳送檔案嗎？"e點名" 可即時共享點名結果…
⏩ e点名 >>> 还在使用 Excel 点名后再传送档案吗？"e点名" 可实时共享点名结果…
⏩ E-attendance >>> Still using Excel take attendance before sending it? "E-attendance" is cloud App
⏩ E-asistencia >>> ¿Usa Excel para asistencia luego enviarlo? "E-asistencia" es una App en la nube

#⃣ #SmallGCOk #Android #GooglePlay #smallgcok #android #googleplay #e點名 #e点名 #E_attendance #E_asistencia #e_attendance #e_asistencia

© com.smallgcok.eattendance
Get Satisfaction or You Are Doing It Wrong
Tags: motivation
Published: 2020-09-09 20:53:01

I have been very consumed with the things that I have been working on lately. Even now there are 10,000 ideas floating around in my mind about the various details of my current project. I am a software developer, it's what I do, but it's also what I love to do. My grandfather who rest his sole, passed away offered up this bit of wisdom after over 35 years of service in the FAA:

The most important factor is to enter a field that has a great attraction for you. To be happy in your work, do what you want to do. If you work just to make money, your work will be drudgery.

After you are in the job, try to increase your competence to perform that job in every way possible.

Work hard. Do the very best that you possibly can in performing the job, even if it means working overtime without an expectation of extra pay or rewards.

Have integrity. In other words, "when in doubt, do the right thing". At times, this is difficult, because it may seem that taking the "right" course of action is not in your best interests. In the final analysis, however, being a person of integrity will be recognized by other people, both on and off the job, and will pay off in both material and non-material ways.
Presto community broadcast episode 1
Tags: database, podcast, livecasts, presto
Published: 2020-09-10 00:20:46

Hey all!

Tune in to the inaugural episode of the #Presto Community Broadcast on https://www.twitch.tv/prestosql at 5pm GMT that Manfred Moser and myself will be hosting.

If you can't make it, we will eventually be hosting the recordings on YouTube, Podcast, and possibly other formats as needed.

In tomorrow's show, we will be interviewing Karol Sobczak and Raunaq Morarka over the https://github.com/prestosql/presto/pull/1072 pull request which added dynamic partition pruning. As well we will be covering some foundational knowledge of presto and introducing folks who aren't as well acquainted with getting started with presto.

Here's a little teaser I put together, hope to see you there!

https://www.youtube.com/watch?v=WYeh_Z_wVdU
How to Remove Dashes in UUID
Tags: python, utils, uuid
Published: 2020-11-18 13:02:40

---
title: How to Remove Dashes in UUID
published: true
date: 2020-09-10 00:00:00 UTC
tags: python, utils, uuid
canonical_url: https://tech.serhatteker.com/post/2020-09/how-to-remove-dashes-in-uuid/
---

**UUID**s are just 128 bit pieces of data, that is displayed as (128/4) = 32 hexadecimal digits, like this :

- UUID v1 : c1b33c74-0006-11eb-9894-c83dd482e3ef
- UUID v4 : 8791f25b-d4ca-4f10-8f60-407a507edefe

Python has built-in `uuid` library to generate **UUID** easily:

```bash
$ python3
Python 3.8.1 (default, Feb 12 2020, 16:30:11)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import uuid
>>> print(uuid.uuid4())
8791f25b-d4ca-4f10-8f60-407a507edefe
```

OK, how can we turn __8791f25b-d4ca-4f10-8f60-407a507edefe__ to __8791f25bd4ca4f108f60407a507edefe__ ?

There are `regex` solutions for this problem but I like to use __python__ to solve this.

```python
# utils.py
from uuid import UUID

def uuid_to_hex(uuid):
    """Turn uuid4 with dashes to hex

    From : 8791f25b-d4ca-4f10-8f60-407a507edefe
    To   : 8791f25bd4ca4f108f60407a507edefe

    :param uuid: uuid string with dashes
    :type uuid: str

    :returns: str - hex of uuid
    """

    return UUID(uuid).hex
```

Example usage of this function:

```bash
$ python3
Python 3.8.1 (default, Feb 12 2020, 16:30:11)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from utils import uuid_to_hex
>>> _uuid = "8791f25b-d4ca-4f10-8f60-407a507edefe"
>>> print(uuid_to_hex(_uuid))
8791f25bd4ca4f108f60407a507edefe
```

And yes, I like _docs_ very much:

```bash
>>> uuid_to_hex.__doc__
'Turn uuid4 with dashes to hex\n\n    From : 8791f25b-d4ca-4f10-8f60-407a507edefe\n    To   : 8791f25bd4ca4f108f60407a507edefe\n\n    :param uuid: uuid string with dashes\n    :type uuid: str\n\n    :returns: str - hex of uuid\n    '
```

We can write this funtion also with __Type Hints__ which introduced in [PEP 484] in order to make it more readable(?). __Type Hints__ requires `Pythhon >= 3.5`.

```python
# utils.py
from uuid import UUID

def uuid_to_hex(uuid: str) -> str:
    """Turn uuid4 with dashes to hex

    From : 8791f25b-d4ca-4f10-8f60-407a507edefe
    To   : 8791f25bd4ca4f108f60407a507edefe

    :param uuid: uuid string with dashes
    :type uuid: str

    :returns: str - hex of uuid
    """

    return UUID(uuid).hex
```

All done!




[PEP 484]: https://www.python.org/dev/peps/pep-0484/
Announcing Keynote Speaker for PyCon India 2020 - S Anand
Tags: python, datascience, pyconindia
Published: 2020-09-10 11:39:48

---
title: Announcing Keynote Speaker for PyCon India 2020 - S Anand
published: true
date: 10/09/2020
tags: python,datascience,pyconindia
canonical_url: 
---

We are happy to announce **S Anand** as a Keynote speaker for PyCon India 2020!

Anand is the co-founder of Gramener, a data science company. He is recognized as one of India's top 10 data scientists. He leads a team that automates insights from data and narrates these as visual data stories.

You can find him on Twitter: [@sanand0](https://twitter.com/sanand0)

![S Anand](https://in.pycon.org/2020/assets/images/sanand.jpg)
How to refresh a website using JavaScript?
Tags: javascript
Published: 2020-09-10 00:00:00

---
  title: How to refresh a website using JavaScript?
  published: true
  tags: JavaScript
  date: Thu Sep 10 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/programatically-refresh-website-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-356676cd1b882de5372d26a11d94487e.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/programatically-refresh-website-javascript)
  
To programmatically refresh a webpage, you can use the `reload()` method in the global `window.location` object using JavaScript.

```javascript
// refresh a webpage
location.reload();
```

### Feel free to share if you found this useful 😃.

---
ReScript: The Module or File Can't Be Found, Unabridged
Tags: rescript, reason, bucklescript
Published: 2020-09-11 13:19:28

---
title: ReScript: The Module or File Can't Be Found, Unabridged
published: true
date: 2020-09-10 00:00:00 UTC
tags: ["rescript", "reasonml", "bucklescript"]
canonical_url: https://webbureaucrat.gitlab.io/posts/rescript-the-module-or-file-cant-be-found/
---

If you work with BuckleScript, now ReScript, you'll likely come across the common build error message, "The module or file $name can't be found" followed by a few helpful suggestions for how to properly install a ReScript module.It's a good error message, but I've found it underestimates me in my ability to get things wrong, especially if I'm the one who wrote the missing module to begin with. I'm going to write a guide while one of these problems is still fresh in my mind so that I have a checklist to go through the next time I get frustrated.

I'm going to start with the supply side of the module. If you're referencing someone else's third party and can assume that their code works on a basic level, feel free to skip ahead to "Consuming your ReScript package."

## If you wrote the ReScript module you're having trouble adding

### Check the `name` property in _package.json_

Make sure your package is what you expected it to be in npm.

### Check the `namespace` property in _bsconfig.json_

The naming convention for BuckleScript is to begin the package name with `bs-`, and the emerging naming convention for ReScript is to begin the package name with `res-`. Meanwhile, the naming convention for modules is to drop the prefix. (E. g., `bs-service-worker` and then `open ServiceWorker;`.) However,when scaffolding the `namespace` attribute of _bsconfig.json_ often defaults to `true`, which strips special characters like "-" and Pascal-cases the name, but otherwise leaves the prefix attached.

The solution is to set the namespace explicitly. Instead of `true`, use the module name that fits the module, like `"ServiceWorker"` for`bs-service-worker`.

### Make sure you've run `npm publish` recently.

Consider setting up CI/CD on `git push`.

## Consuming your ReScript package

### Make sure your package is properly installed, both places.

Make sure the package is installed by npm into your _node\_modules_, and make sure the package is listed in your bsconfig.json as a dependency.

### Check the namespace of your package

Your package's namespace is determined by the `namespace` attribute of the _bsconfig.json_ (as described above). You need to know it to open it.

### Make sure you haven't already opened the package at the top of the file

Yes, this is also something I have done.

This closes out the list of possible causes I'm aware of so far, but I believe that if I work hard and believe in myself I'm bound to find more ways into this compiler error, and when I do, I'll revisit this post.
My first post
Tags: memories
Published: 2020-09-09 22:42:34

---
title: My first post
published: true
description: Hi community! My name is Christian Alvarado and this is my first English post. Never I do this (write in English) but I want practice.
tags: memories
cover_image: https://dummyimage.com/1600x1200/ffffff/fa66ff.png&text=My%20first%20english%20post
---

# My first English post

Hi community! My name is Christian Alvarado and this is my first English post. Never I do this (write in English) but I want practice (I accept feedback). I work in beauty company in Nevada like a engineer software in this moment (I am live in Mexico, but, remote work... he he). 

I beginning to program when I was nineteen years old. I programmed in Java and PHP (university languages) but in that times, I was interested in know program languages more efficient (in certain mode). I began to learn python and I was fascinated. 

well, I'll follow writing in next times. 

greetings community and thanks if this haven't non sense!
I've been working through Udemy courses with Python
Tags: python, database, datascience, github
Published: 2020-09-09 22:36:32

I stumbled across this site today, and was reading the article on MongoDB, and why one SHOULD NOT use it.  The reason I ended up on this site is that I have fallen down the "IT rabbit hole" that was formerly known as "curiousity killed the cat".  Like many on Udemy I've bought many courses, with realistically little time to complete them.  Currently I'm working through a Python-centered course where you end up with some "projects" completed at the end.  At the moment the instructor Ardit is talking about databases.  In his course he mostly talks about SQL-centered databases, namely PostgreSQL, SQLite and MySQL.  Yet in other courses I have participated in, the instructor hypes things like MongoDB.  My question is this:  I'm mostly interested in SQL-centered databases, I do not work as a developer, and I'm mostly interested in making little apps that will improve my life or maybe help me in making 2D-based games.  Which databases do you recommend?  One thing that turns me off is the idea of SQL-centered databases that require a "server" running.  I would prefer to have my databases in the same folder my source code is in. 

EDIT 0: I would like to be able to use SQL on a database that doesn't require a "service" or "server" running.  At the moment it appears that Sqlite is already supported by Python3 as a native module, and that I can use a Sqlite-centered gui to create and 'view' the layout of my scheme.  

Edit 1: I'm not really qualified on the topic to converse with anyone who might comment on my post, and I admit to being a little socially awkward.  Just know that I do appreciate any feedback, and I feel I would most benefit by reading conversation between YOU guys.  :-)