teleren/devto huggingface dataset:
Spread Operator(...) in JavaScript.
Tags: javascript, beginners, tutorial, functional
Published: 2019-04-07 06:45:12

Hello again, Just a quick reminder, This is the third part of the series **Strange JS** so if you haven't checked out yet go and read previous two posts. 


So without further wasting time let's get started. Today we are gonna talk about **Spread Operator** but I call them **Super Dots** because I like it. 🙃


Now the biggest question is What the hack is **Spread Operator**??

In simplest words **Spread Operator** convert a list into an array and an array into a list. Sounds confusing?

Let's understand with some examples. Assume that you created a function which takes 2 or 3 arguments and you just called that function but you have an array and function needs a list. for example.
```javascript
function sum(a, b, c) {
    console.log(a + b + c)
}

let array = [1, 2, 3]
sum(...array)

// 6
```
This was the one scenario, but it can be used for a variety of cases like array manipulation.

You can concat two arrays.
```javascript
const num = [1,2,3,4]
const words = ['Hey', 'Hellow']

console.log([...num, ...words])

//[1, 2, 3, 4, "Hey", "Hellow"]
```

These are only two examples but it can be lots of use cases so get your hands dirty with **Spread Operator**.

I'll be back with something new and strange until then **Good bye**.
![Bye](https://media.giphy.com/media/7DzlajZNY5D0I/giphy.gif)
HTTP Network Requests on Android Pie
Tags: android
Published: 2019-10-14 06:45:20

---
title: HTTP Network Requests on Android Pie
published: true
tags: android
canonical_url: https://varunbarad.com/android/2019/04/07/http-network-requests-on-android-pie.html
---

Recently when I started work on a new app for my company I noticed that all of my requests were being rejected before even reaching the server. This was a problem I was facing only on the emulator and not on the Nexus 5 I had for physical testing. I searched on the Internet a bit and found out that Android Pie has disabled cleartext network traffic by default.

I found 2 solutions for this. You can either enable cleartext traffic from your app for specific domains or you can set it for all the domains.

## Enabling cleartext traffic for all domains (discouraged due to being less secure)

Add this attribute to the `<application>` tag in your `AndroidManifest.xml`

```xml
android:usesCleartextTraffic="true"
```

This will enable app-wide cleartext traffic for any and all domains to which your app makes a request.

This is discouraged as you don’t specifically allow only the domains that require cleartext.

## Enabling HTTP requests for specific domains (go for this one if you can)

You first need to create a file named `network_security_config.xml` file inside your `res/xml` directory. The file contents should be as below

```xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">example-domain.com</domain>
    </domain-config>
</network-security-config>
```

You need to replace `example-domain.com` with the domain for which you want to enable http traffic. If you want to enable http for more than one domains then add relevant `<domain>` tags for each.

Then you need to specify this file in your `AndroidManifest.xml` as below:

```xml
...
<application
    ...
    android:networkSecurityConfig="@xml/network_security_config">
...
```

## That’s all folks

I faced this issue at work and now I am writing about it so others (and also me) can benefit from it in future. If you have more such ideas/examples or any other suggestions under the sky, [contact me](https://varunbarad.com/contact) or tweet to me [@varun\_barad](https://twitter.com/varun_barad).
Why wrapping a web project and making it deploy able to any server seems so hard with Docker?
Tags: discuss
Published: 2019-04-07 04:47:44

---
title: Why wrapping a web project and making it deploy able to any server seems so hard with Docker?
published: true
tags: discuss
---

I've been working on an open source project of mine that recently got featured on Laravel News https://laravel-news.com/unified-transform-open-source-school-management-platform .

The common problem I faced in **Issues** is to make this web app seamlessly deploy able to any platform due to different PHP and composer versions of users. So I wanted to implement a Container solution like **Docker**. But Docker seems pretty hard to me to work with.

It'll be great if anybody can suggest me a simple working steps to work with Docker. Thanks.
AWS Pro-Tip: Manage CLI User Identities with Profiles
Tags: aws, cli, profiles
Published: 2019-08-03 22:02:50

---
title: AWS Pro-Tip: Manage CLI User Identities with Profiles
published: true
tags: AWS, CLI, profiles
canonical_url: https://yiddish.ninja/aws-pro-tip-manage-cli-user-identities-with-profiles/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/42arh9hv5q1encvkag7j.png
---

If you’re doing a lot with AWS, you’ll find yourself using two things… multiple IAM users and the AWS CLI. One of the things I kept seeing the instructors in a certification training course (3rd party) doing was reconfiguring the CLI with new credentials every time they created a new user for a demo.

That’s nice and all, but you can only view your credentials once and then you have to generate new ones if you haven’t stored them somewhere. Storing them in the CLI config is good… until you clobber them with the credentials for another IAM user you created.

But the AWS CLI has user management features with the `profile` argument.

The easiest way to add a new profile is to simply add a `profile` argument when you issue a `configure` command.

```
aws configure --profile myUserName
```

You can substitute whatever name you gave to the IAM user for myUserName and a profile will be created with that user name, storing both the user’s credentials and preferred region. Then, to issue a command in the CLI as that user, like creating an S3 bucket…

```
aws s3 mb s3://bucket-name --profile myUserName
```

**But what if I don’t want to specify the profile on every single command?**

First, if you don’t specify a profile argument during configuration, AWS CLI will store the credentials and region under a user named “default.” So, the user you configure without a name will be the one used whenever you don’t specify a name… unless…

The AWS CLI looks for an environment variable called `AWS_DEFAULT_PROFILE`. If it’s not set, the default profile is “default,” but if you set it, the CLI will use whichever profile name it specifies.

So, let’s say you just created a mySysOp user who will be your default user for all your CI/CD commands related to CodeBuild and CodeDeploy. You open a terminal window (or DOS prompt, or PowerShell), and you can run one of the following commands to set the user for that shell session…

**Windows:** `set AWS_DEFAULT_PROFILE mySysOp`  
**Linux/Mac** `export AWS_DEFAULT_PROFILE=mySysOp`

To make it more permanent (all subsequent terminals opened, but not any _other_ ones that are currently open), you’d use `setx` in Windows, or add the value to your `.profile` file for your Bash shell user.

I’d literally considered spinning up VMs via Docker and remoting into them for each IAM user to avoid CLI clobberification, so I was really glad I did some investigating and found out about profiles. For the full skinny on profiles, visit the [AWS docs page about profiles](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html).
Understand cloud security
Tags: azure, security
Published: 2019-04-07 01:21:45

---
title: Understand cloud security
published: true
description: Implement platform protection
tags: #Azure, #Security
---

**Introduction to the shared responsibility model**
- Challenges faced by organizations:
    - Securing their datacenters
    - Recruiting and retaining security experts
    - Using many security tools
    - Keeping pace with the volume and complexity of threats
- Benefits of shifting responsibilities to Azure:
    - Provides organizations with enhanced security coverage
    - Enables organizations to move security resources and budget allocations to other business priorities
![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/8qxwoowc8aw0czo0jxwg.png)
![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/rj846i0d5lgna6pcmz8q.png)
![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/7v7huqe5kl708vlo5dx1.png)

**Overview of elasticity and scalability**
- DevOps has completely changed the way applications are developed and maintained 
- Cloud applications typically encounter variable workloads and peaks in activity 
- You can use Azure Monitor to understand how your applications are performing 
- Azure Monitor Autoscale helps to enable the elastic scale feature of the cloud
 ![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/901a7l4a5huk4jwby19q.png)

**Understand virtualization, containers, and serverless computing**
- Virtualization creates a simulated, or virtual, computing environment, as opposed to a physical environment
- Each virtual machine can then interact independently and run different operating systems or applications
- There are four main categories of virtualization:
    - Desktop virtualization
    - Network virtualization
    - Software virtualization
    - Storage virtualization
- Azure Virtual Machines lets you create and use virtual machines in the cloud for scenarios such as:
    - Testing and development
    - Running applications in the cloud
    - Extending your datacenter to the cloud
    - Disaster recovery
- A container is a modified runtime environment that prevents a program from accessing protected resources
- A container interacts directly with the host operating system (OS) and augments the containment functions
- A container does not use virtualization 
- For container management, Microsoft released Azure Container Instances in April of 2018
- You can move existing applications to container(s) and run them within Azure Kubernetes Service (AKS)
- Serverless computing is the abstraction of servers, infrastructure, and operating systems
- When you build serverless apps, you don’t need to provision and manage any servers
- Azure Functions is a serverless application platform
- Azure Logic Apps allows developers to add workflows to support their Azure functions
- Serverless computing generally encompasses three things: 
    - Abstraction of servers
    - Event-driven scale
    - Microbilling
Book Review: Academic Slide Design by Ann E. Fandrey
Tags: bookreview, ladyconferencespea, speaking
Published: 2019-04-07 02:49:12

---
title: Book Review: Academic Slide Design by Ann E. Fandrey
published: true
tags: Book review,Lady Conference Spea,Speaking,book review
canonical_url: http://heidiwaterhouse.com/2019/04/06/book-review-academic-slide-design-by-ann-e-fandrey/
---

![Book cover in teal, says “Academic Slide Design”, author Ann Fandrey](http://heidiwaterhouse.com/wp-content/uploads/2019/04/img_0533.jpg)

This book says “Academic”, but it’s also an excellent resource for the person writing technical/software presentations. We often face the problem of trying to convey really important concepts in a way that serves people who are primarily listening to us as well as people who are reading the slides, either because they don’t speak the same language, or because that’s how they absorb information best.

This book is full of actionable, clear, and research-based suggestions for how to design your slides for both clarity and impact. I highly recommend it to other people trying to design a talk deck or webinar materials.

> The more quickly students can apprehend the meaning of the slide, the more quickly they can return their attention to you.

Read if: You want something a bit more scientific than “This is what my TED talk looked like”.

Skip if: You feel like you already have a good grasp of visual information design and you don’t like learning new things.
iOS App rejection: Info.plist file should contain a NSLocationAlwaysUsageDescription
Tags: reactnative, ios
Published: 2020-04-21 17:36:39

---
title: iOS App rejection: Info.plist file should contain a NSLocationAlwaysUsageDescription
published: true
date: 2019-04-07 00:00:00 UTC
tags: ReactNative,iOS
canonical_url: https://www.jskap.com/blog/Info.plist-file-should-contain-a-NSLocationAlwaysUsageDescription/
---

We received a message from iOS App Team about adding `NSLocationAlwaysUsageDescription` key in `Info.plist` file. Our last build was rejected for this specific reason.

Being clueless about what went wrong here. I googled up and found some interesting things.

`NSLocationAlwaysUsageDescription` key needs to be added to your `Info.plist` file if your app using user's location data. You need to add a custom message about why you need user's location data as well.Quite surpised by this, we were not using geolocation service or tracking user's location. Our app didn't need this specific functionality. So why we do we need to tell the user that we are tracking the user location while we are not ?

Turns out React Native has a `GeoLocation` service which gets included by default into your build. Even if you do not use the `GeoLocation API` in your codebase , it is still in your app build. This triggers code bots about possible usage of Geolocation.

## How do you solve this ?[<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#How-do-you-solve-this-)

Referring to this github issue - [https://github.com/facebook/react-native/issues/20879](https://github.com/facebook/react-native/issues/20879). There are three possible ways. I tried the first and easy one and that worked fine for me. I deleted `RCTGeolocation.xcodeproj` from `libraries` folder in XCode and rebuilt the app. You can see on the left Libraries in current app in below screenshot. This solved the `NSLocationAlwaysUsageDescription` issue.

![Xcode Libraries](https://kapilgorve.s3.ap-south-1.amazonaws.com/blog/all/xcode-libraries.png)

Update- I am told that this issue will be fixed around React Native version 60.

  

This post was originally published at https://www.jskap.com/blog/Info.plist-file-should-contain-a-NSLocationAlwaysUsageDescription/

  

👋 Hi! I’m Kapil. I am always chatty about building things, sharing my learnings, freelancing. Come say hi to me at [https://twitter.com/kapilgorve](https://twitter.com/kapilgorve)
Bash Functions & Git - How to wipe out changes made to a specific file
Published: 2019-04-08 01:17:15

---
title: Bash Functions & Git - How to wipe out changes made to a specific file
published: true
tags: 
canonical_url: https://www.stephencharlesweiss.com//2019-04-07/bash-functions/
---

I find myself writing the following command multiple times daily.

```
git stash push pacakage-lock.json
git stash drop 0
```

I had been reading a little about bash functions and wanted to see if I couldn’t automate the process.

There are two files in particular that I was running these commands for due to our build process: `pacakge.json` and `package-lock.json`.

My first solution was a hard coded version called `cpkg`. I saved the function my `~/.zshrc` for easy access.

```
#cpkg = "clear changes to pacakge"
cpkg() {
  git stash push package-lock.json;
  git stash drop 0;
  git stash push package.json;
  git stash drop 0;
}
```

This function achieves my goal. It wipes out changes to the `package.json` and `package-lock.json`.

Still, I wanted to challenge myself to see if I could add some dynamism. Maybe I wouldn’t want to clear my package, but drop changes from a different file.

This required a function that accepted arguments.

# Parameters And Bash Functions

The first place I looked, of course, was [Stackoverflow](https://stackoverflow.com/questions/6212219/passing-parameters-to-a-bash-function). This conversation was a good introduction of how functions pass parameters.

In my case, I only needed to handle a single parameter - so order wasn’t important and I could use the `$1` without any type checking.

What I came up with was:

```
#gsdf = "git stash drop file"
gsdf() {
  git stash push $1;
  git stash drop 0;
}
```

It’s simple, but it does work as expected.

If I run `gsdf package.json` the file will be added to the stash (if there have been changes) and then dropped - letting me move on in peace.

This works by assigning `package.json` to the `$1` parameter during execution.

The next steps would be to handle _multiple_ arguments, so I could pass multiple files at once.

# Caveats

This will _not_ affect untracked or ignored files. It will only wipe out changes to files that have been previously tracked or committed.

The reason is that `git stash` does not stash untracked or ignored files by default.

For more on this, see a different conversation on [Stackoverflow](https://stackoverflow.com/questions/835501/how-do-you-stash-an-untracked-file).

# Final Thoughts

Is this the _best_ way to achieve my goal? Probably not, but it’s been w working for me and I understand it. If you can point me to a more common pattern with git for this, I’m all ears.

I'd also be very interested if someone knows a good way of handling an unknown number of arguments to create a loop of repeating this process for each file passed into the `gsdf` function. 

# Resources

- [Advanced Bash Scripting - Complex Functions](http://tldp.org/LDP/abs/html/complexfunct.html)
Testing Axios Requests With Jest
Tags: jest, react, axios, testing
Published: 2019-04-06 23:49:43

---
title: Testing Axios Requests With Jest
published: true
description: Testing asynchronous requests in my React App was really tricky when I first started unit testing JS/TS code. Here's a quick explainer how I handle Axios calls in my unit tests.
tags: jest, reactjs, axios, testing
---
Let's say we have a simple async function that calls some remote data. We pass in our query and configuration object. To see an example of what can be passed through this request config see [the Axios docs](https://github.com/axios/axios#request-config "Axios request config"). My query in this case is just the `url` key in the config for example `/user` which could be an API end point. This function simply returns the data from axios (the actual response body from your endpoint). If we fail to get a response from our endpoint, the function is going to catch and we'll throw a console error.

request.js
```javascript
export const fetchData = async (query, config
) => {
  try {
    const { data } = await axios.request({
      method: 'get',
      url: encodeURI(query),
      ...config
    });

    return data;
  } catch (e) {
    console.error('Could not fetchData', e);
  }
};
```

Now let's create a new file `request.spec.js` we want to add two imports
```javascript
import mockAxios from 'axios';
import { fetchData } from '../request';
```
In order to test this we need to use a mocked version of Axios which is conveniently imported from the core library. We're now ready to write our test
```javascript
  it('should call a fetchData function', done => {
    fetchData('/test', {}).then(response => {
      expect(response).toEqual({
        data: {},
      });
    });
    expect(mockAxios.request).toHaveBeenCalledWith({
      method: 'get',
      url: '/test'
    });
    expect(mockAxios.request).toHaveBeenCalledTimes(1);
    expect(consoleErrorSpy).not.toHaveBeenCalled();
    done();
  });
```
First we call then function with a test query and an empty config to ensure then test that our response is correct. Now we are testing `mockAxios.request` that it was called with the arguments we expected, that it was called only one time, and that our function did not throw an error. Finally we call the `done()` callback which let's just know our asynchronous operations are complete.
My First Three Weeks at Lambda School as a PT Student
Tags: webdev, beginners, career, css
Published: 2019-04-06 20:36:26

---
title: My First Three Weeks at Lambda School as a PT Student
published: true
description: I talk about what I have learned in the PT Web Dev cohort at Lambda School
tags: webdev, beginners, careers, css
---
This week I completed my first three weeks in Lambda School's part-time Full-Stack Web Engineering and Computer Science bootcamp. As the program is 18 months long, I have quite the way to go.

I wanted to take the time to write about what the part-time program is like for anyone considering enrolling in a PT cohort. I hope my insight will give you an idea of what to expect upon enrolling.

##Why I decided to attend Lambda School

Five months ago I had no idea what web development was. At the time I was searching for a more robust career trajectory and came across the world of software engineering and web development. After teaching myself HTML5/CSS3 on [codecademy](https://www.codecademy.com/) I decided in early January that I wanted to make this my new career path.

My intention was to use as many free resources and [Udemy](https://www.udemy.com/the-web-developer-bootcamp/) to further my education, build as many projects as possible and apply for a job within 9 months. It was all planned + going quite well until in late January I came across JavaScript and hit a mental roadblock. I realized that I needed a more structured learning path to assist me in my learning, and decided to apply to a bootcamp to accelerate && support my progress. Enter: [Lambda School](https://lambdaschool.com/).

##The First Three Weeks
My cohort started on March 18th and I am honestly amazed at what I've been able to accomplish in the past three weeks as a part time student. For the first portion of the curriculum we focus on web development fundamentals. In 3 short weeks I have solidified my knowledge in semantic html5, CSS3, responsive web design and accessibility. 

During the first week I learned about Git and the command line and I must say that I am starting to get quite comfortable with using these essential web developer tools. I have created pull requests, cloned repositories, create branches in existing repos and have started to create really amazing relationships with students in my cohort. I also created my first portfolio website! How exciting!

##The Next Three Weeks
In the next three weeks I will have a solid understanding of pre-processing and start learning more about fundamental Javascript concepts. I will continue to do more advanced projects and continue to build relationships with the amazing students I am learning with.

If you would like to see what I have done so far, see my Github repos [here](https://github.com/LadyKerr?tab=repositories). 

Until next time, thanks for reading! :)