teleren/devto huggingface dataset:
Creating an AWS lambda that acts as a proxy service
Tags: node, webdev, tutorial, codenewbie
Published: 2020-01-31 10:48:55


## The below code is limited to POST, but can be easily extended to any HTTP Method

```js
const https = require('https');

const destinationHostname = 'someurl.io'
const destinationPath = '/somepath/dev/v1/hola'

exports.handler = async (event) => {
    event.headers = event.headers || {}
    console.log("event", event)
    let postData = event.body
    let body
    let statusCode
    let headers
    await new Promise((resolve, reject) => {
        let options = {
            hostname: destinationHostname,
            port: 443,
            path: destinationPath,
            method: 'POST',
            headers: event.headers,
            rejectUnauthorized: false
        }
        
        // add additional headers if required, in my case I am setting/resetting Auth header
        options.headers['Authorization'] = 'Basic XXXX'
        // most do:
        options.header["X-Forwarded-Host"] = options.header.Host
        delete options.header.Host // also delete the host before forwarding the request

        var req = https.request(options, (res) => {
            statusCode = res.statusCode 
            headers = res.headers 
            console.log('statusCode:', res.statusCode);
            console.log('headers:', res.headers);
            
            let chunks = [];
            res.on("data", function (chunk) {
                chunks.push(chunk);
            });
            res.on("end", function () {
                body = Buffer.concat(chunks).toString();
                console.log("RES BODY: ", body) // body.toString());
                resolve();
            });
        })
        req.on('error', (e) => {
            console.error(e);
        });
        req.write(postData)
        req.end()
    })    

    return {
        statusCode: statusCode || 200,
        headers: headers || {'content-type': 'application/json'},
        body: body
    };
};
```
Programmatically determine OS is up to date or outdated on windows or mac osx .
Tags: csharp, swift
Published: 2020-01-31 10:38:19

Recently I have developed Software for Windows and Mac osx.
Here I needed to determine my os is up to date or outdated programmatically.

For windows version, programming language is C# and for mac osx version, swift is used.

I could implement the function in C# because there are C# code snippet related my purpose over internet.

But unfortunately, no luck for Mac osx and swift.
There are too much articles to get Mac osx or iOS version.
They was not my concerns.

Below is C# implementation for windows version.
```c#
bool CheckIsOSUpdated()
{
    IUpdateSession updateSession = new UpdateSession();
    IUpdateSearcher searcher;
    searcher = updateSession.CreateUpdateSearcher();
    ISearchResult updates = searcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0");
    //ISearchResult updates = searcher.Search("IsInstalled=0");
    if (updates.Updates.Count == 0)
        return true;
    else
        return false;
}
```

Then the implementation in swift for Mac osx version is

```swift
import SwiftShell

func getIsOSXUpdate() -> Bool {
    // softwareupdate --list|tee
    // let command = runAsync("softwareupdate", "--list").stdout.runAsync("tee")
    let command = runAsync("softwareupdate", "--list")
    do {
        try command.finish()
    } catch {
        NSLog("could not collect available updates.")
        return false
    }
    
    _ = command.stdout.read()
    let error = command.stderror.read()
    
    if error.contains("No new software available") {
        return true
    }
    
    return false
}
```

You may wonder why stderror is used rather than stdout.
When you run softwareupdate --list on terminal, you will see the result like below if your Mac os is up to date.
```
JSGURUs-Mac:~ jsguru$ softwareupdate --list
Software Update Tool

Finding available software
No new software available.
JSGURUs-Mac:~ jsguru$ 
```

Strangely, **stdout** returns `"Software Update Tool\n\nFinding available software\n"` and **stderror** returns `"No new software available.\n"`.
That's why **stderror** is used.

I hope these code snippets help you.
Want to learn.
Published: 2020-01-31 10:35:14

I am jotting down some things that I would like to learn.
This is probably more effective to be a public note, I will be updating this every so often.

### Java
- Using Tomcat Java as Rest Server
- Java in general 

### JavaScript
- Lowdash - what does it offer over native prototypes
- Backbone - because legacy 
- Redux
- Advanced React, because I seem to be okay with React via transferable

### Other
- Golang
- GLSL
GATE CSE QUESTIONS
Tags: tutorial, computerscience, beginners
Published: 2020-01-31 10:28:43

(GATE CSE Questions](https://academyera.com/gate-cse-questions)

[Digital Logic Design GATE CSE Questions](https://academyera.com/digital-logic-design-subject-wise)  
[Database Management System GATE CSE Questions](https://academyera.com/database-management-system-psu-subject-wise-solved-questions) 
[Computer Organization GATE CSE Questions](https://academyera.com/computer-organization-subject-wise) 
[Computer Networks GATE CSE Questions](https://academyera.com/computer-networks-subject-wise) 
[Engineering Mathematics GATE CSE Questions](https://academyera.com/engineering-mathematics-psu-subject-wise-solved-questions) 
[Algorithms GATE CSE Questions](http://academyera.com/algorithms) 
[Data Structures GATE CSE Questions](https://academyera.com/data-structures-psu-subject-wise-solved-questions) 
[Theory of Computations GATE CSE Questions](https://academyera.com/theory-of-computation-subject-wise) 
[Compiler Design GATE CSE Questions](https://academyera.com/compiler-design-subject-wise) 
[Operating Systems GATE CSE Questions](http://academyera.com/operating-systems-subject-wise-gate-cs-questions) 
[Gate CSE Questions From Other Branches](https://academyera.com/computer-engineering-subject-wise)

Refer : [GATE CSE QUESTIONS](https://academyera.com/gate-cse-questions)
Best Websites to Learn Coding for the Beginners
Tags: wordpress, webdesigner, codenewbie
Published: 2020-01-31 10:25:16

If you don't know how to code create computer software apps or websites , there are a tons of great resources on the web that will  teach you the skills you needed . To get started many of this free and some them are paid.I am giving you a few of them these are really helpful for the beginner.





1.Freecodecamp

https://www.freecodecamp.org/


2.Udemy

https://www.udemy.com/

3.The Odin Project
https://www.theodinproject.com/

4.Edx

https://www.edx.org/

5.Tutorials point

https://www.tutorialspoint.com/

6.W3school

https://www.w3schools.com/

7.Mdn web docs

https://developer.mozilla.org/

8.Code Academy

https://www.codecademy.com/

9.SkillShare

https://www.skillshare.com/

10.Lynda.com

https://www.lynda.com/
Good resources to learn Kotlin for Android?
Tags: kotlin, discuss, help, android
Published: 2020-01-31 10:09:45

In my dealings with React Native, I have found certain plugins disappointing, so I am considering writing my own plugin in Kotlin. Obviously, that requires knowledge of Kotlin and how to develop for Android. I know the barest basics of Kotlin, but I know of a few resources to improve my knowledge of the language.

What I'd like to ask from you guys is if you know of any good tutorial, book, playground or other such things to learn Kotlin specifically to develop Android apps.

Bonus points if you can also point me to somewhere that explains how to develop plugins for React Native.

Thanks a lot!
Bpython: Python REPL on steroids.
Tags: python, beginners, shell, productivity
Published: 2020-01-31 10:08:09

## Table of Contents
- [Introduction to Python REPL](#introduction)
- [Introduction to bpython](#bpython)
    - [Installing bpython](#install-bpython)
    - [Python intepreter vs bpython](#vs)
    - [Rewind function to undo last line](#rewind)
    - [Open python file in interactive shell](#shell)

## Introduction to Python REPL <a id="introduction"></a>
Python comes with a simple but really helpful interactive shell also know as REPL `read–eval–print loop`. REPL allows us to quckly validate some ideas without the need to fire up the `IDE` or Text Editor.

To start the python `REPL` you can run `python` command on your terminal.

```bash
➜ python
Python 2.7.17 (default, Nov  7 2019, 10:07:09)
[GCC 9.2.1 20191008] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

```

*I am running ubuntu and it comes with Python 2, to run Python 3 I have to run python3*

You can run normal statements or even create `Class` or `Function` inside `REPL`.

But the problem with `REPL` is that it doesn't come with color highlighting nor code completion. So, here comes [bpython](https://bpython-interpreter.org/).

<hr>

## bython <a id="bpython"></a>
bpython is simply a python intepreter on steorid. It comes with great features like:
- Syntax highlighting
- Autocompletion and auto indentation
- Rewind function to undo last line
- Support for Docstring

### Installing bpython <a id="install-bpython"></a>
Easiest method to install bpython is using `pip`.

You can install bpython using the command
```
pip install bpython
```
>*If your computer also has python2 and you want to install bpython for python3 use `pip3` instead of `pip`*

That's it, now you should be able to use bpython just by typing `bpython` in your terminal.

```bash

bpython
bpython version 0.18 on top of Python 3.7.5 /usr/bin/python3
>>>

```

### Python intepreter vs bpython <a id="vs"></a>
Now we can see auto complete in action, someone said picture speaks 1000 words right? Let's see if that's true;

![bpython vs python intepreter autocomplete](https://dev-to-uploads.s3.amazonaws.com/i/83nmho7vsxwvlmqp99a0.png)
![bpython vs python intepreter docstring](https://dev-to-uploads.s3.amazonaws.com/i/vjqdndotz04670bhjlkh.png)

<a id="rewind"></a>
You can undo the last line simply by pressing `Ctrl`+`R`.


<a id="shell"></a>
You can also open and run a python file in bpython intepreter using the command.
```
bpython -i file_name.py
```

I found bpython to be really helpful, I hope it's for you too.

Please let me know if I have missed some features of bython that you love.

**See you in the next one.**<br>
<br>
*In the mean time you can follow me on [twitter](https://twitter.com/PaurakhSharma)*
Learn Python basics - Chapter #1
Tags: python, automatetheboringstuffs, programming, learn
Published: 2020-01-31 09:55:59

*Python is one of the best programming languages for beginners. Before moving on to some advanced topics, one should give more importance to the basics of the Python programming language.*

Today we will look at the basics of Python programming language and get started with it.

You can use any sort of editor for practice purpose, I mostly prefer 
[VS Code](https://code.visualstudio.com/insiders/) but you can choose whichever text editor or IDE you love.

You can also use IDLE, a Python [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) 
 
Open the IDLE and run the below code

### Example 1: Adding two numbers
<pre>
  >>> 2 + 2
  4
  >>>
</pre>

In the above example, 2 + 2 is an *expression*, where 2 is a value and + is an *operator*.

As a programmer, it is useful to understand the programming constructs thoroughly.

*Happy learning !!*
Do you consider learning Elm?
Tags: discuss, elm, javascript
Published: 2020-01-31 09:02:11

Hi devs, want to ask you to take a moment and vote in the poll if you consider learning Elm. Is the Elm the thing still? I am also very interested in your opinion why yes, why not, so waiting for comments. Please click the link to the poll below:

{% twitter 1223169359125909507 %}
Launched iHateregex.io in Producthunt
Tags: productivity, regex, javascript
Published: 2020-01-31 09:00:16

I just launched iHateRegex on product hunt:
👉👉
https://www.producthunt.com/posts/i-hate-regex
❤
Thanks to everyone in this community who motivated me to do this

See my previous post about the tool: https://dev.to/geongeorge/i-hated-regex-so-much-that-i-made-ihateregex-io-1ih4
Anatomy of a Border: a Saul Bass Demo
Tags: codepen, saulbass, clippingpath, css
Published: 2020-01-31 08:58:30

{% codepen https://codepen.io/onebrightlight/pen/mdyYgjN %}

I’m in the process of redesigning my website and I was about to do yet another layout using geometric fonts and rounded edges when a friend of mine said that I’m a person that loves modern aesthetics but also enjoy objects with personality and attitude. He suggested that I look at Saul Bass’s work, most notably the artwork for Anatomy of a Murder. The edges of the boxes had a wonderfully geometric yet “broken” quality that I wanted to see if I could emulate with CSS clipping paths.

The challenge at first for me was that creating the clipping paths required percentages in order to have the path scale. At first I thought the only way to get around this would be to create an SVG file and reference it in the CSS, but quickly realized I could just use the `calc()` function to subtract a defined unit of measurement from the edge of the right and bottom edges of the div.

Now that I have my proof of concept, my next step is creating a Sketch file to start planning my *actual* website in this style!

![Poster Art by Saul Bass for the film “Anatomy of a Murder.”](https://dev-to-uploads.s3.amazonaws.com/i/g4fytm0lt9k2p5p7h28h.jpg)
Marketing automation software
Published: 2020-01-31 08:53:20

With the assistance of advertising computerization apparatuses India, it is effectively noticeable that India is similarly associated with <b><a href="https://www.salezshark.com/marketing-automation">marketing automation software</a></b> database business. To pick up benefits and increment business, you have to remain dynamic all the time in light of the fact that there are bunches of contenders who work day and night to vanquish you. We at Dataguru, give India <b><a href="https://www.dataguru.in/">business directory</a></b> catalog with the goal that it turns out to be simple for their customers to make a reasonable picture of the present business advertise situation and to comprehend item request.
my experience so far with remote working
Published: 2020-01-31 08:37:23

having to work remote from the office and keep working with co-workers as a software engineer might sound unusually and to some it might sound imposible

so how is it like to work remotely as a developer 

at first, i thought that communication was going to be the main issues for remote working with the team i have been working with, but turns out it was not bad at all 
remote working has some cons and pros that i found on my own perspective as i had a 2 weeks experience so far 

some of the cons are that, you waste most of your time trying to comfort yourself with this new way of working 
second cons is that for some people with poor communication skills, this might become super hard for them to get used to
third cons is slowing down the working progress and productivity cause of all the destruction you get when you are not at your working space

there is some pros that you get to enjoy as you work remote that i have encountered on my own prospective 
first is that you get a lot of free time as you work on your own schedule but for procrastinators like me this might make you less productive 
the second advantage is saving expenses like transport and more that you spend when working at the office 

for some of you starting this new journey of working remote i would advise to read more on this working remote guide from [skillCrush](https://skillcrush.com/2016/10/10/working-remotely-tips/) which will inform you more on how you can productively work remotely 

and as you start this new journey of working remotely you have to learn to use the essential tools used in remote working as it all listed on [creative boom blog] (https://www.creativeboom.com/resources/10-of-the-best-tools-for-remote-working/), make sure you learn how to use them cause they will become your new way of working with your teammates and coworkers
Reading Snippets [40 => CSS ] 🎨
Tags: css, beginners, html, codenewbie
Published: 2020-01-31 08:00:46

Display is considered to be the most important property in CSS. All elements have default display values. 

The default display value for an element is dependent on the type of element. Most elements have display values of block or inline. 

A block element is usually called a block-level element. An inline element is always just called an inline element. 

Setting <code>display</code> to <code>none</code> is different from visibility. It renders the page as though the element does not exist. 

Setting <code>visibility</code> to <code>hidden</code> results in the element being hidden but still taking up space that it would if it was fully visible. 


<kbd><small>Source:<a href="http://learnlayout.com/display.html">Learn Layout
</a></small></kbd>
On.NET Episode: Getting started with cloud deployments with Pulumi and .NET
Tags: dotnet, cloud, devops, pulumi
Published: 2020-01-31 07:51:25

In this episode, Matt and Luke sit with Scott Hunter to show how Pulumi enables .NET developers to define and deployment their cloud infrastructure as code.


{% youtube sig68daTG-0 %}

If you liked this video and would like to see some more of our .NET content, please subscribe to our [.NET Developers YouTube Channel](https://www.youtube.com/channel/UCvtT19MZW8dq5Wwfu6B0oxw).


## Useful Links
* [Getting started with Pulumi](https://www.pulumi.com/docs/get-started/azure/)

* [Azure for .NET Developers](https://docs.microsoft.com/dotnet/azure/?WT.mc_id=dotnet-c9-cephilli)

* [Building Modern Cloud Applications using Pulumi and .NET Core](https://devblogs.microsoft.com/dotnet/building-modern-cloud-applications-using-pulumi-and-net-core?WT.mc_id=dotnet-c9-cephilli)

* [.NET Core support in Pulumi](https://www.pulumi.com/docs/intro/languages/dotnet/)
Online Tutor
Published: 2020-01-31 07:44:58

I am an Online Tutor who have 2 years of teaching experience in C, C++, Java, JavaScript and Python. I teach 1:1 ratio, where I personally teach a single student for a period of 1-2 months. Course fees is exceptionally low and you get study materials & Certificate if you intend to take.
Languages : C,C++,Java, JavaScript & Python .
Genre: Web Development using HTML,CSS,JS,jQuery,Bootstrap,Node.js & MongoDB.
I am also a blogger. Visit : <a href="https://learnnodeonline.blogspot.com/">Click Here</a>
If you are interested to learn from me, mail me : devjeetroy.dr@gmail.com
Long Data Vs. Wide Data
Tags: todayilearned
Published: 2020-01-14 16:35:58


So, lately I have had my hands on some raw unclean data for an assignment for school. Originally I thought that messy data was about cleaning up blank values, formatting text, numbers, and strings in the right form, etc. But as I proceed to analyze my data in R I found out that it could not be handled. There was a key concept that I was missing when it comes to setting up data the right way: Wide and Long Data

**What is Wide Data?**

In the wide data (also known as unstacked) is when each variable attribute for a subject is in a separate column.

|Person   | Age  | Weight  
|---|---|---|---|---|
|Buttercup|  24 |110|   
|Bubbles| 24  |105|   
|Blossom| 24  |107|   



**What is Long Data?**

Narrow (stacked) data is presented with one column containing all the values and another column listing the context of the value

|Person|Variable|Value|  
|---|---|---|
|Buttercup|  Age |24   |   
|Buttercup| Weight | 110  |   
|Bubbles|Age   | 24  |   |   
|Bubbles| Weight  | 105  |   
|Blossom | Age  | 24  |    
|Blossom | Weight|   107|     


It is easier for r to do analysis in the Long data form. This concept might seem weird at first. We are use to seeing and analyzing data in Wide data form but with practice it gets easier over time. R has an awesome package called reshape2 to convert your data from wide to long.

First install the r package and load the library.

`install.packages("reshape2")
library(reshape2)`

Using the wide table above we will split our variables into two groups **identifiers** and **measured** variables.

Identifier variable:Person
Measured variable: Age, weight

In order to transform this wide data into long data we will have to use the melt method. You “melt” data so that each row is a unique id-variable combination.

```
df
 Person Age Weight
1 Buttercup 24 110
2 Bubbles 24 105
3 Blossom 24 107
 
ppg <-melt(df,id=c("Person"),measured=c("Age","Weight"))
 ppg
 Person variable value
1 Buttercup Age 24
2 Bubbles Age 24
3 Blossom Age 24
4 Buttercup Weight 110
5 Bubbles Weight 105
6 Blossom Weight 107
```

## Resources
For official documentation about the [reshape library](http://had.co.nz/reshape/introduction.pdf) from its creator Hadley Wickham. 

More about Wide vs. Long data check out [The Analysis Factor](http://www.theanalysisfactor.com/wide-and-long-data/)

More information about cleaning and shaping data from messy data to tidy data check out [Hadley Wickham’s paper Tidy Data](http://vita.had.co.nz/papers/tidy-data.pdf)
Optional Chaining in JavaScript
Tags: webdev, javascript, tutorial, beginners
Published: 2020-01-31 07:15:03

---
title: "Optional Chaining in JavaScript"
date: "2020-01-31T07:15:03.284Z"
tags: webdev, javascript, tutorial, beginners
canonical_url: "http://ryanlanciaux.com/blog/2020/01/31/optional-chaining-in-javascript/"
---

{% youtube u90I9BuOcmE %}

In this article, we're going to take a quick look at the new, Optional Chaining operator in JavaScript. This language feature is valid JavaScript as of ES 2020 (the official definition of the language).

To take a look at why I think this feature is compelling, let's assume we have an object that represents a menu for a conference meal plan. Each object represents a different day for the conference and each day can have `breakfast`, `lunch`, and `dinner`.

```
const monday = {
  menuItems: {
    breakfast: {
      items: ['Eggs', 'Oatmeal', 'Cereal']
    },
    lunch: {
      items: ['Sandwich']
    },
    dinner: {
      items: ['Cheeseburger', 'Salads', 'Tempeh Sandwich']
    }
  }
};

const tuesday = {
  menuItems: {
    breakfast: {
      items: ['Cereal', 'Bagel']
    },
    dinner: {
      items: ['Tacos']
    }
  }
};
```

For our example, we'd like to `console.log` the first element of the lunch object. We'll display "No lunch on this day" for any day where lunch is not specified (and therefore not provided). We'll start with the following code.

```
function logLunch(day) {
  const lunchItem = day.menuItems.lunch.items[0];

  console.log(lunchItem || "No lunch on this day");
}


logLunch(monday);
logLunch(tuesday);
```

This function works well for Monday, but fails for the Tuesday object since it only specifies a `breakfast` and `dinner.` Typically we could solve that by ensuring our properties exist before interacting with them. In this case, our expression could look something like this:

```
const lunchItem = day && day.menuItems && day.menuItems.lunch && day.menuItems.lunch.items && day.menuItems.lunch.items[0]
```

It's not very pleasant to guard each property like this!

## Optional Chaining

Thankfully, we can rewrite this line with Optional Chaining to the following:

```
const lunchItem = day?.menuItems?.lunch?.items[0];
```

We're using the `?.` instead of a `.` between properties. This `?.` is the `optional chaining` operator. This entire expression will be evaluated as undefined if any of the properties are null or undefined. Instead of checking these properties, we can express the desired intent much more cleanly with this new operator.

[Check out the example for this article on Codepen](https://codepen.io/ryanlanciaux/pen/KKwLBYp?editors=0012).

I'd love to know of any thoughts you have. You can [find me on Twitter here](https://twitter.com/ryanlanciaux)!