teleren/devto huggingface dataset:
VSCode: Transform text to lowercase/uppercase/titlecase
Tags: beginners, tutorial, vscode, shorty
Published: 2019-10-29 07:17:00

---
title: "VSCode: Transform text to lowercase/uppercase/titlecase"
description: "VSCode: Transform text to lowercase/uppercase/titlecase"
published: true
tags: ["Beginners", "Tutorial", "VSCode", "Shorty"]
series: Shorties
---

VSCode has an built-in function to lowercase, uppercase and titlecase selected text.

![VSCode transform](https://thepracticaldev.s3.amazonaws.com/i/3blytg74r05966rsbzr0.gif)

1. Select the text to transform. Use `Ctrl + L` to selected the whole line
1. Open `Show all commands`. Linux and Windows: `Ctrl + Shift + P`, Mac: `⇧⌘P`
1. Type in the command, e.g. `lower`, `upper`, `title`
1. Wait for auto-complete (like in the animation)
1. Hit `Enter`
Write cleaner function's optional parameters
Tags: typescript, codequality, todayilearned
Published: 2019-10-29 06:08:41

*Clean all the codes!*

-----

Update: 
1. Code typo fixed.
2. Adding default value to optional to make it easier to destructure.

-----

Normally, we can put the optionals last in our function declaration. This way we can simply omit it from our calls when we don't need it.

```
// Declaration
const myFunction = (param1: string, param2: number, param3?: string, param4?: number) { }

// Call
myFunction("Call me maybe", 12345);

```

But, there's a time where we need to assign `param4` without `param3`.

```
myFunction("Call me maybe", 12345, undefined, 67890);
```

I think that's messy, because we are forced to write `undefined` first. This is getting incrementally annoying if there're more than 1 `undefined` in-between. (especially if you are a bit OCD like me)

So, I then remember how the flutter team handles optional parameters, and I think it makes my typescript code much cleaner.

```
// Declaration
const myFunction = (param1: string, param2: number, 
  optionals: { param3?: string, param4?: number } = { }) { }

// Call 1
myFunction("Call me maybe", 12345, { param4: 67890 });

// Call 2
myFunction("Call me maybe", 12345);
```

And to make things better, we can destructure our optionals first, instead of prefixing everything with `optionals.`.

```
const myFunction = (param1: string, param2: number, 
  optionals: { param3?: string, param4?: number } = { }) { 
  const { param3, param4 } = optionals;

  // Write any code here
};
```

*__UPDATE:__ I changed the optionals declaration from `optionals?: {}` to `optionals: {} = {}`. This way, you can safely destructure `optionals` even if it's undefined, because it will be replaced with empty object. Please note that the destructured values can still be undefined.*

I think this will look cleaner no matter how many optional parameters we have. We can even still omit the `optionals` completely like before. 


```
myFunction("Call me maybe", 12345);
```

Win-win for me! 

-----

So, what do you think? Maybe you have a better way to write optionals? Let us know!
Building a digital citizen portal using Vue.JS, MongoDB and Node
Tags: vue, javascript, node, mongodb
Published: 2019-10-29 05:56:54

Technology has enabled an extremely convenient way of life, governments, however, have often remained behind in the digital space, lacking any innovation.

You're in the lucky few if your government is even using a legacy digital system, where most governments will have virtually no digitized core government services.

I decided to build a new government on the grounds that a government must be technologically innovative.

I set out to build a digital government called [Promatia](https://promatia.com)

The government's central digital foundation would be myPro, which is Promatia's online accounts system, where anyone, not limited to citizens would be able to signup. This account would serve as the central hub for the digital government.

Citizens would be able to use this account to register businesses, apply for citizenship, and do other various citizen tasks.

The government portal would serve as a central location for all government services.

![Main App](https://thepracticaldev.s3.amazonaws.com/i/khhs7mbnspdrrazlxqwq.png)

All government services would use a single account, that would be used across all government services using SSO (Single sign-on)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/e8qgdfvckvwjiw6nxnqn.png)

Citizens would be able to apply for citizenship
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/tx2gel913tv42oa9ysq7.png)

The front-end is using Vue, and Node.js in the backend. Creating this site has prompted me to create an entire CMS using:

- Vue (for frontend)
- MongoDB (for database)
- GraphQL (for API)
- Node (for server)
- Koa (for routing)

We'll be posting regular news updates about Promatia's website on our government-run news website [Proma Times](https://promatimes.com)

Currently, the website is not online, and will be offline until further development
Please don't come Bank IT if you are good programmer. 
Tags: productivity, java, android
Published: 2019-10-29 05:56:34

I am a software programmer. I have tried a lots of time to being a good software engineer. I was working in a reputed software company in my country. The sad part of mine is , When i was in software company i had lots of time to learn and implement. But with the influence of my colligue i was applied on Bank software development department. I thought it will be the same environment as my company. But reality is very different , here in Banking Software development envionment of wroking is very bad. I can not getting comfortable with this environment. 

I want to get back my own kingdom. But at the same time most of the software company is vounarable. Now what i need to do . Please help me.
Advantages and Disadvantages of 5G Technology
Published: 2019-10-29 05:46:09

      Advantages    
 a. High accuracy and large bidirectional bandwidth configuration  
    
 b. Technology to collect all the networks on a single platform.  
    
 c. Effective & efficient.  
  
 d. Technology o to facilitate common supervision tools for rapid action.  
      
 e. It was most likely; it will provide huge (Gigabit) radio data .it will Supported more than connections.  f. Can be easy to control with the previous generations.  
    
 g. Technological voice to support heterogeneous services (including the private network).  
  
h. Enabled to provide unified uninterrupted and consistent connectivity world.


 Disadvantages  
  
a. The technology under research, research on its applicability is on-going.  
  
b. The(fast) speed at which this technology appears to be difficult to achieve(in the coming future, perhaps) due to inefficient coverage and traffic disruption because of the different transport forces of technology support in most parts of the world.  
  
c. Infrastructure development needs high cost.  
  
d. The issue of security and privacy  that has not    yet been resolved
What is a <div> in HTML5 with Corgis?
Tags: codenewbie, html, beginners, computerscience
Published: 2019-10-29 05:29:49

`<div>` element explained with Corgis

Hello 👋💻🌎 Tech World,




![HTML5](https://miro.medium.com/max/6670/1*bomvZMwLXYyiDKArU1vMwQ.gif)



![Code with Corgis](https://miro.medium.com/max/2446/1*prXGj63P6y-DfhTlncUXBg.gif)

Example:
```<div> Corgis Content </div>```


![Panel1](https://miro.medium.com/max/4332/1*3idkoSENfDeDwBzPMTSLnw.gif)

![Result](https://miro.medium.com/max/2160/1*v8UVRUUtSTRfbxxkvS04rA.gif)

#Result
```Corgis Content```
![Result Corgi Content](https://miro.medium.com/max/4332/1*u8NKD-maipMFwEIxhuVG5A.gif)



Usage Notes 📝
Only use a `<div>` element when no other semantic element (such as `<article>`, `<aside>`, `<blockquote>`, `<footer>`, `<main>`, `<nav>`, or `<section>` ) is appropriate.
You can learn about these semantic elements in the Resources below or Stay tuned for comic strips explained by corgis

Resources 📚
MDN web docs — https://developer.mozilla.org/

Thank you for reading ❤,
Kody The Coding Corgi & Bits The A.I.


P.S. If this comic strip was able to help you in any way, DM us on Instagram or tweet us on Twitter. Please share this with your coding friends, corgis friends, and coding corgis friends so we can make more comics in the future with your support. Thank You!




{% medium https://medium.com/codewithcorgis/what-is-a-div-in-html5-with-corgis-dc8142d032a0 %}
React-Native Ecommerce app with React Hook
Tags: reactnative, react
Published: 2019-10-29 05:12:58

Hi, i would like to ask some React questions.

-How should i architect a React-Native Ecommerce App if im going to rebuild a magento 2 site from scratch using React Hook?

-What stack/framework is most suitable for ecommerce app?

-What third party libraries i should use to prevent reinventing the wheel?

-Where can i find high quality tutorials that apply React Hook to build Ecommerce app?
NestedModel in Google Firestore - FireO
Tags: firestore, fireo, orm
Published: 2019-10-29 04:18:26

FireO allow you to create `NestedModel` Model inside another model.

### Usage Example:

```python
class User(Model):
    name = TextField()


class Student(Model):
    address = TextField()
    user = NestedModel(User)


u = User(name='Nested_Model')

s = Student(address="Student_address")
s.user = u
s.save()
```

Read More [NestedModel](https://octabyte.io/FireO/fields/nested-model/)

Give some good feedback to [FireO](https://github.com/octabytes/FireO)
Ruby on Rails 6 with React and Webpacker
Tags: rails6, react, webpacker, railsreactwebpack
Published: 2019-10-29 03:36:06

---
title: Ruby on Rails 6 with React and Webpacker
published: true
description: 
tags: #rails6 #react #webpacker #railsreactwebpack
---
Do you want to learn how to use webpacker and react with rails 6. If so this video is for you.

{% youtube oDmSOmO88v0 %}
Binary Search in JavaScript
Tags: javascript, algorithms, coding, computerscience
Published: 2019-10-29 03:02:45

Binary Search is one of the most basic algorithm that is studied by CS students. Questions about Binary Search are also very popular during coding interviews.

Binary Search is used when you need to efficiently locate a value in a sorted list of values. Rather than checking all the values one by one in a linear fashion, you can make use of the fact that the list is sorted and first check if the value you're looking for is in the middle of the list.

If not, then determine which half of the list may contain the value and start over again checking the middle of that sub-list.

```
var ar = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];

var position = findNumber(90, ar);
println(position);
```

You are probably familiar with this algorithm if you played the "find the number game" in which one person picks a random number and you have to find it guided only by the hints the other player tells about the numbers you are trying.

In this short article, I will present you two simple implementations of Binary Search in JavaScript. 

#Solution 1: Recursive approach

```
// Find number n in sorted array ar
// Returns array index if found or -1 if not found
function findNumber(n, ar)
{
    return _findNumber(n, ar, 0, ar.length - 1);
}

// Find number n in sorted array ar in between indexes i1 and i2
// using recursive approach
function _findNumber(n, ar, i1, i2)
{
    if (i2 < i1)
        return -1;

    println("Checking interval: [" + i1 + ", " + i2 + "]");
    
    var mid = i1 + Math.floor((i2 - i1) / 2);
    
    if (n === ar[mid])
        return mid;
        
    if (n < ar[mid])
        return _findNumber(n, ar, i1, mid - 1);
        
    return _findNumber(n, ar, mid + 1, i2);
}
```

As you can see the recursive approach is very easy to implement. However, sometime an iterative approach is more efficient and therefore preferred over a recursive one.

#Solution 2: Iterative approach

```
// Find number n in sorted array ar using iterative approach
// Returns array index if found or -1 if not found
function findNumber2(n, ar)
{
    var i1 = 0;
    var i2 = ar.length - 1;
    
    while(i1 <= i2)
    {
        println("Checking interval: [" + i1 + ", " + i2 + "]");
        
        var mid = i1 + Math.floor((i2 - i1) / 2);
        
        if (n === ar[mid])
            return mid;

        if (n < ar[mid])
        {
            i2 = mid - 1;
        }
        else
        {
            i1 = mid + 1;
        }
    }
    
    return -1;
}

```

You can find the full source code of this article in the playground from [codeguppy.com](https://codeguppy.com)

Direct link: [https://codeguppy.com/code.html?Y5RZ5qiu1nVUiamySIz4](https://codeguppy.com/code.html?Y5RZ5qiu1nVUiamySIz4)
An Online Multiplayer Game Example
Published: 2019-10-29 02:43:43

Hey everyone!  It's been a little while, but here I am with a new project: a simple game server made entirely with Node.

Source code and docs [here](https://github.com/RevelMind/game-server).

Let's go over the server script:

> ./server.js
```javascript
// HTTP Server

var express = require("express"); // Load the express package
var app = express(); // Create an app with express
var up = true; // Unused value... I'll remove it in the future.
var data = { // The cube's data.
    x: 0, // "X" position of the cube.
    y: 0 // "Y" position of the cube.
};

app.get("/updatePos", (req, res) => { // Create a listener for /updatePos
    res.json(data); // Return the cube's data.
});

app.get("/setPos/:x/:y", (req, res) =>  { // ^
    data.x = parseInt(req.params.x); // Sets the "X" position
    data.y = parseInt(req.params.y); // Sets the "Y" position
    res.status(200); // Sets the result status as a success
    res.json({data: "Hello, world!"}); // Just so it returns something.
});

app.listen(8080, () => { // Start listening.
    console.log("Hosted server at localhost:8080"); // Let the user know the server started
});
```

I explained each line of code briefly with comments so you can understand it a bit better.  Also, don't forget to read the [readme.md](https://github.com/RevelMind/game-server#readme) file so you know it's dependencies.

Have a nice day! :D
[React] Component Render Call & Update Events Order
Tags: react, javascript
Published: 2019-10-29 02:43:31

#### When it comes to do something before, during, after the rendering and updating react components, we need to know what functions are available for us and what is the order of being called.

Before rendering happens, 
`componentWillMount()` function is called at first. 

Then, `render()` funciton is called, 

and lastly `componentDidMount()` is called.


You can update the state of React by using

```javascript
setState({ state_name: new_value })
```
> **Note:** Without calling **setState()** function, render update functions will not be called.


When the state is changed updating functions will be called in order below. 

| Order | Function |
| ------ | ------ |
| 1st | `componentWillReceiveProps()` |
| 2nd | `shouldComponentUpdate()` |
| 3rd | `componentWillUpdate()` |
| 4th | `render()` |
| 5th | `componentDidUpdate()` |
28.10.19 - In which many wheels were spun
Tags: machinelearning, datascience, devjournal, selftaught
Published: 2019-10-29 02:26:15

<h1>And little forward momentum occurred...</h1
<i>My weekly accountability report for my self-study approach to learning data science.</i>

<ul>Things that I worked on this week.
<li> I reviewed some high-level documentation of Scikit-learn, in order to have some level of preparedness for the WiMLDS sklearn open-source sprint this coming weekend. I've never been involved in open source or a sprint, so I'm excited about that. But I definitely need to do a bit more studying/review in that arena.
<li> I did some more fastai. I returned to week three because I wanted to understand better what I was doing. I worked on protein multilabel classification and got more CUDA errors, but was able to figure out a scaling system that seemed to work and I avoided more crashes, by swapping out to resnet34, using smaller images sizes and incrementally increasing them while shrinking the batch sizes. My resulting f-score beat the top public scores, proof that I have no clue what I'm doing. I was at the point where I was reading the forums to understand people's various approaches when the opportunity came to do some freelance work. So I haven't been back to fastai, and I'm not sure exactly when that will happen as the next few weeks are filling up between sklearn, work, and family constraints.
<li> Something I wish I understood - why does my VM on GCP sometimes quit? Usually not long after a first launch it? Very mysterious...
<li> I did manage to study polynomial regression and pull together several hundred flashcards in machine learning, coding, and statistics. I like being able to review a little at a time in a very methodical way. I don't feel like it's necessary for a job, but I do think it will be helpful for interviews.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/29fes64h5ptljkfy1sao.png)
<li>There are many things about python that tripped me up when I first started learning it. Like list comprehensions and how iterators work in for loops but once I write them of my own volition I feel like I attain the next level of pythonicness. This weekend I had the opportunity to say "you know what would be good here, a generator" and then I wrote it and I'm honestly wondering why I was scratching my head for so long. Honestly, it's probably because I still have to remind myself that functions are objects.
<li>I feel like I should have gotten more stuff done this week, but damn if work & study - life balance isn't hard. Life has a way of demanding my attention, which I don't mind. It's just hard to say no to. I think I will try to make sure I set my alarm every morning and see if I can't get some consistency around that.
JOB TEST TIPS
Tags: career
Published: 2019-10-29 01:38:42

A famous proverb says that an idle mind is a devils workshop and that is seen in our society these days. The rate of laxity on the side of youth is on the rise and many people attribute it to lack of employment and vocational engagements. 

One thing that stands out and tries to hold the test of time in all these is that Opportunity always meets preparation. This is seen in so many situations like impromptu examinations, tests or job interviews. This also does not mean that those that didn’t prepare aren’t intelligent it just means that they didn’t plan well.

Job tests are one of those cases where we need to be prepared so as to match our opportunistic moment. They are so many ways we can prepare for a job interview.

JOB TEST TIPS
There are so many ways that people prepare for a job test, here are few of them:
1) Practice Aptitude test online
2) Get all the needed tools
3) Preparation is the key
4) Do your research
5) Get comfortable taking a test
6) Use the assessor’ resources
7) Take tests on your own
8) Carefully read the instructions during the test.
 
Also for the personality assessment test, we can also use the tips below:
There are good and bad personality tests.
Ask for the results and show a desire to learn from it.
Practice ahead of time.
Be honest and open.
Take the test in the context of who you are at work, not necessarily who you are at home.
One of the most used tools for job test is the GMAT module and it helps you to prepare for any job test. It can be downloaded in the link below. http://unbouncepages.com/stanuchenna-2853/
Let's make a link!
Tags: javascript, beginners, html
Published: 2019-10-29 01:28:49

Hello!
Have you ever made a link? Yes, maybe the answer is yes. Unless your website is a single page application, a link would be there.
Well, how do you make a link?
The answer is, use an anchor tag like

<body>
<script>
<a>Link</a>
</script>
</body>

Another question is here. Have you ever imagined the whole background is a link?
JavaScript can make it real.
More generally, JavaScript can make a link anywhere you want!
The magic word is "onclick." If you write it inside the body element, you can make the whole background a link. The code which realises it is for example (onclick="link()"):

<body onclick="link()">
<script>
    function link(){
       location.href = "url or path";
    }
</script>
</body>

body, div, button, even anchor, anywhere can be made a link!
Sure that you are getting closer to your beautiful imaginations.
Safe journey!

I almost forgot. There is one more thing.
For you, I have created a JavaScript website. Many things JavaScript can draw are there.
New to Django (again)
Tags: django
Published: 2019-10-29 01:18:29

Greetings,

Yesterday I built, for the third or fourth time, a godforsaken polls app.

Today, I feel, for maybe the first time, that maybe it kind of makes sense.  I sort of...get it.  A bit, at least.

I'm glad I fought through it.  (Again)

Still not sure what I'll do with it.  My brain says...build a website.  Think of a domain name.  Do that.  Sell crap.  Make money.

Maybe I'll find something useful to put my hobbying towards.  Maybe something that isn't cheap and awful.

Or I'll just wander aimlessly, from rabbithole to rabbithole...

Onward,
-Brandon
My Docker note
Tags: docker
Published: 2019-10-29 01:00:09

---
title: My Docker note
tags: docker
series: note
published: true
cover_image: 
canonical_url:
---

{% link n350071/login-to-mysql-on-docker-and-run-a-sql-file-2bk7 %}

```sh
# show cpu usages
docker stats
```
I blew up my life
Tags: webdev, career, education, beginners
Published: 2019-10-29 00:29:26

“I’m an imposter, a goddamn liar!” 

At least, that’s what my internal monologue was screaming as I changed the title on my LinkedIn profile to “Front-End Developer”.  You see, last month I basically blew up my life and walked away from my job of over 8 years and a career in advertising and marketing I had spent considerably longer building.   I know, smart right?

It was absolutely fucking terrifying.

So why had I walked away from my career and sole source of income?  Had I won the lottery?  Received a surprise inheritance from a long-lost rich relative?  Nope.  I walked away because the first time I wrote “Hello World!” in my text editor, I was hooked.  When I signed up for my first HTML & CSS workshop on a whim, little did I know I would fall down the rabbit hole into the world of web development.  But one afternoon workshop lead to an 8-week part-time web development introductory course, which lead to 24-weeks of part-time HTML, CSS and JavaScript courses.    

It was safe to say this was now more than a hobby for me.

I was excited to go to class even after working all day, I wanted to work on my projects all the time, I was thinking about my code when I should have been focusing on other things.  This was a problem.  Why?  Because the more exited I got about web development the harder it became to ignore the fact that I was miserable in my job.  

Truthfully, I couldn’t recall a time where I had been as passionate about work as I had become about coding.  Over my career it had become common place to work in environments where most people were frustrated and burnt out on a daily basis.  That’s some pretty depressing shit isn’t it?  I’m not gonna lie.  It was rough.

However, the more web development courses I took, the more alumni from HackerYou & Juno College I met.  Most of them had no previous experience in coding, the only thing most of them had in common was the fact they had taken the Web Development Immersive Bootcamp.  From there, they were able to launch a new career, forge a new path.  The other weird thing?  They were all pretty fucking happy.  Ok, well maybe I was the only one who found that weird.  They also all universally raved about their experience in the Bootcamp.  Now, at this point I had started to suspect this may in fact be some sort of cult.  How could so many people have the same positive experience without some sort of brainwashing going on?  Despite that, it was the only cult I had ever been interested in joining.  

The idea of building a career where I would continuously be learning, growing and challenging myself was now starting to feel more like a possibility than a pipe dream.  I decided to take a chance and apply to the Bootcamp.  I was accepted to Cohort 24 and am now a Juno College student.

There’s no turning back now.  Bring on the Kool-Aid!