teleren/devto huggingface dataset:
A data breach on a site exposed your password
Tags: help, node, javascript
Published: 2020-07-15 06:16:20

I have added authentication to my website and it shows a message as shown in the picture when I login or signup. And also I have an option called <strong>"Add Comment"</strong>, which opens only if the user is logged in or else it redirects to the login page. But here when I login and click on the "Add Comment" button it still redirects to the login pageant it doesn't show me the Add Comment page.

Authentication routes:
```javascript
app.get("/register", function(req, res){
	res.render("register");
})

app.post("/register", function(req, res){
	User.register(new User({username: req.body.username}), req.body.password, function(err, user){
		if(err){
			console.log(err);
			return res.render("register");
		}
		else{
			passport.authenticate("local")(req, res, function(){
				res.redirect("/campgrounds");
			})
		}
	})
})

app.get("/login", function(req, res){
	res.render("login");
})

app.post("/login", passport.authenticate("local", {
	successRedirect: "/campgrounds",
	failureRedirect: "/login"
}), function(req, res){
})

app.get("/logout", function(req, res){
	req.logout();
	res.redirect("/")
})

function isLoggedIn(req, res, next){
	if(req.isAuthenticated()){
		return next();
	}
	res.redirect("/login");
}
```
Comment Route:
```javascript
app.get("/campgrounds/:id/comments/new", isLoggedIn, function(req, res){
	Campground.findById(req.params.id, function(err, campground){
		if(err){
			console.log(err);
		}
		else{
			res.render("comments/new", {campground: campground});
		}
	})
})

app.post("/campgrounds/:id/comments", isLoggedIn, function(req, res){
	Campground.findById(req.params.id, function(err, campground){
		if(err){
			console.log(err);
			res.redirect("/campgrounds");
		}
		else{
			Comment.create(req.body.comment, function(err, comment){
				if(err){
					console.log(err);
				}
				else{
					campground.comments.push(comment);
					campground.save();
					res.redirect("/campgrounds/" + campground._id);
				}
			})
		}
	})
})

```
Top 8 Challenges for Machine Learning Practitioners
Tags: machinelearning, beginners, datascience
Published: 2020-07-15 05:16:44

When I started implementing machine learning in realtime, I faced a lot of issues since in some tutorials or courses people start explaining the machine learning models but the reality is different. Bringing a use case to reality became a huge thing.

To all those who want to enter the jargon world of machine learning, there will be some obstacles you need to encounter to develop a stable application. Check out my article to get more insights into it.

https://towardsdatascience.com/top-8-challenges-for-machine-learning-practitioners-c4c0130701a1?source=friends_link&sk=b15317d9f8ff1de6f4a194ca6385f1cb
DevOps RoadMap — How to Get Started!
Tags: devops, career, beginners
Published: 2020-07-15 05:07:19

When I first started learning #DevOps I honestly had no idea about it, a lot of questions hovered in my mind all the time. A lot of people find it difficult to get started. It was a hell lot of confusion, so I am here to clear your confusion now that my confusion is no more confusion. To Understand DevOps in simple terms, check out my article below. 

https://medium.com/towards-artificial-intelligence/devops-roadmap-how-to-get-started-39ce861e15c0?source=friends_link&sk=787383bbad4c98bd6c2d1630949d82f2
How to connect mobile to android studio without USB
Tags: android, androidstudio, developer, appdevelopment
Published: 2020-07-15 05:07:06




It isn't hectic to carry a USB cable, every time when you want to test or debug your android app,

 definitely, this is very irritating.

So you want to see your table neat and clean having a laptop only on the table, no cable at all to debug the app.

Time to dispose of conveying USB cable for Android Developer to install, run, and debug your applications while creating. Android wifi ADB causes you and becomes generally helpful for Next-age Android Developer.


IntelliJ and Android Studio created a plugin to rapidly connect your Android device over WiFi to install, run, and test your applications without a USB associated. Simply press one button and disregard your USB cable. 

Follow this very helpful article to avoid usb.

https://www.javaoneworld.com/2020/06/how-to-connect-mobile-to-android-studio-without-usb.html
Long time reader, first time poster.
Tags: beginners, codenewbie, webdev
Published: 2020-07-15 04:56:13

###**Litle Introduction**
Currently I am working on multiple personal projects to really broaden and challenge my expertise while at the same time expand my learnings, but ultimately, my drive is to solve one of several problems. Thats the whole point right? find a problem, find a pain point & and then build to solve. 

I'll be posting some of those learnings, thoughts and take aways over the next few days and weeks on specific topics and/or projects. Like "The benefits of using SASS and BEM with a 7 to 1 folder structure". No doubt, I will also have some questions and you good dev people will help out.

###**My Latest Project**
I have finished my latest project. It was for an NGO animal shelter in Lebanon, called Mashala Shelter. The economic crisis coupled with the corona pandemic really affected how and to what extent these initiatives could operate. I reached out to them over instagram and offered my dev services and here we are. It is by far not a one off project, I will keep it updated and constantly build on its features and components and improve its code base as I learn new things (like introducing SASS, reorganising the folder structure and optimising the images for faster loading).
 
Anyway here is the link to the [Mashala Shelter](http://mashalashelter.org). Check it out. Tell me what you think.

cheers everyone
Top 5 must-have features of Grofers clone app

Tags: grofersclone, groferscloneapp, grofersappdevelopment, grofersclonescript
Published: 2020-07-15 04:46:12

The grocery delivery app is a fast-growing sector with newcomers venturing now and then to satisfy the customer’s demand. Retail stores are adapting to the click and collect grocery model to increase their customer base and profits. According to this model, customers can place the orders in the app, then the respective supermarket takes care of the packaging, and delivery executives pick up and drop off the orders in assigned locations. As per Progressive grocer reports, 43% of people prefer to order groceries through grocery delivery apps. So the time is ripe to invest in Grofers clone.

Advanced features of Grocery delivery applications:
Features are the factors that attract the customers to the grocery delivery apps, so make sure the Grofers clone app has the following features.

Quick shopping list: Customers can save the product for future purchases. They can segregate the products into various categories using this feature, such as favorite list, scanned barcode list, the reminder list, and so on.

Delivery scheduler: Customers can schedule the order in advance as per their convenience. They can choose the delivery slot and cart ready with products. 

Quick reorder: It allows customers to place orders with a single click from the existing orders. This feature makes the ordering process quicker and easier.

Recommend products: This feature is part of popular e-commerce apps, wherein customers get recommended products based on their previous orders and search history. This is often present at the bottom of the page.

Shopping remainders: Customers can set shopping remainders with the list of products to buy and the date to place the order. Users can also choose the means of getting remainders, such as push notifications or SMS.

Appdupe offers Grofers clone script with all the salient features. Entrepreneurs can use this golden opportunity and get a ready-made clone app from us and initiate their profitable business venture.

visit us @https://www.appdupe.com/grofers-clone
GitHub Actions — Makes ‘One Click To Deploy’ Feasible For ML CI/CD Pipeline
Tags: github, machinelearning, devops, python
Published: 2020-07-15 04:42:49

What if I told you “You can automate the process of building, testing, delivering, or deploying your Machine Learning models into production using GitHub Actions”? Do read the article to know how to set up your own workflow!

https://towardsdatascience.com/github-actions-makes-one-click-to-deploy-feasible-for-ml-ci-cd-pipeline-61470ed3edbc?source=friends_link&sk=a90e087d2e25ce614973f1b1075a4439
JS Array
Tags: javascript, node, deno
Published: 2020-07-15 04:42:45

Recently read an article on medium about JS Arrays which said as follows:

In Js, an array internally is also an object only

for a regular array like this
['a','b','c'] its equivalent object is { 0: 'a', 1: 'b', 2:'c', length: 3}
This is by definition a dense array

In JS, there is also the concept of sparse array
['a', , 'c'] its equivalent object is { 0: 'a', 2:'c', length: 3}

The empty hole we refer to is called an Elision

So in order to replicate holes/Elision , you just need not set the index values in the object but set the length property,

[,] equivalent is {length: 1}

but if you try
a = [,]; b = [undefined];
a[0] === b[0], it will return true though a[0] is an elision
because technically, elision is treated as an undefined value

but when u represent a = [,], the browser sees the length property of the object a and finds 1

But if it accesses the index 0, it hasn't been set also doesn't have a value and hence its undefined, but its represented as a hole/elision (as [empty] in chrome v8)

So basically in Js a hole/elision is created when there is a mismatch between index assignment and length property of an object (of type array)
Hello World: What I wish I knew at the beginning of my programming journey. 
Published: 2020-07-15 04:10:26

#Hello World: 
#### Where do the bootcampers get a drink after a full day of coding? You guessed it, foo bar!

On a more serious note, I began my programming journey a measly four months ago. Other than learning the very basics about programming on sites like [codecademy](https://www.codecademy.com/) and [Khan Academy](https://www.khanacademy.org/) I knew little to nothing about the culture. 

I attended a programming bootcamp and learned a lot throughout the process but here are a few things I wish I knew when I started the bootcamp: 

1. **You are not limited to the resources the bootcamp has to offer.** This seems like a given, right? It might be, and I'm sure my instructors probably told us this; however, I probably could've heard that a few more times. It took me twelve weeks to realize some of the best introductions to a new technology are simply the official documentation for the technology, scouring [GitHub](https://github.com/) for any juicy documentation, or just going to the handy dandy youtube. 

2. **Star [sindresorhus/awesome](https://github.com/sindresorhus/awesome) on GitHub**. Don't forget to thank him for all the effort he put into this repository. Before I start learning any new technology I go the above mentioned repository and drink all the information from the firehose. There is not much more to say here, but this was something I wish I learned about before I started programming. 

3. **Take breaks, and take them often.** When I first started programming, I would catch myself typing away till two in the morning. I would get stuck with error message after error message searching [Stack Overflow] (https://stackoverflow.com/) for answers I'd never find. Eventually I would tire out, not solving the issue at hand, wake up in the morning look at the code for 5 minutes or less and solve the issue. This happened countless times, and admittedly still does, but I am starting to understand the importance of taking breaks. 

4. **Attend Meetups.** Dive into the community, learn to embrace the uncomfortable, and make friends while you do it. When you first start programming there is a lot to take in and it may be hard to jump into meetups not sure of what to say or what is going on. I wish I would've known that it's perfectly fine to show up to a meeting, listen, and not be sure of what is going on. Eventually you'll be participating and making connections that may lead to future job opportunities. 

5. **Make an effort to help others to solidify your knowledge.** Moving information from short term memory to long term memory can be achieved by teaching a recently acquired skill to someone else after learning it. I wish I would've known how effective this can be when starting to program. Talking your code out like you eventually will in an interview will give anyone a leg up. 

During my process of becoming a software engineer there are many other things I wish I would've known but these 5 tips would have had the greatest impact on my learning experience.
Qual a diferença do WhatsApp GB para o WhatsApp Plus?
Tags: whatsappgb, gbwhatsapp, whatsappplus
Published: 2020-07-15 04:08:33

Ambos os aplicativos são versões modificadas do WhatsApp. Contudo, se você tem dúvidas sobre qual a diferença do WhatsApp GB para o WhatsApp Plus, veja a seguir o que diferencia entre esses apps:

-Adesivos ilimitados disponíveis no WhatsApp GB;

-Bloqueio de chamadas para contatos ou grupos específicos no GBWhatsApp;

-Possibilidade de copiar o status de contatos;

-Dispensa a necessidade de acesso a root, no caso do WhatsApp GB.

Essas são basicamente as principais diferenças entre os dois apps, mas podemos notar que não há tanta variação.

Ambos oferecem recursos muito parecidos para os usuários, sendo que o WhatsApp GB é mais similar ao aplicativo original, enquanto que o WhatsApp Plus oferece mais privacidade e personalização.

Fonte: https://biva.digital/gbwhatsapp/
LeetCode: Clone Binary Tree With Random Pointer
Tags: leetcode, algorithms
Published: 2020-10-19 15:34:09

---
title: LeetCode: Clone Binary Tree With Random Pointer
published: true
date: 2020-07-15 03:49:00 UTC
tags: LeetCode,Algorithms
canonical_url: https://coderscat.com/leetcode-clone-binary-tree-with-random-pointer
---

![CAPTURE-2020_07_15_clone-binary-tree-with-random-pointer.org_20200715_113620.png](https://coderscat.com/wp-content/uploads/CAPTURE-2020_07_15_clone-binary-tree-with-random-pointer.org_20200715_113620.png)

## Deep copy

Deep copy is a process in which the copying process occurs recursively. We need to clone all the elements of a tree.

## Solution

The overall algorithm is recursive, but we need to find the previous cloned elements. So use a `hashmap` will help us to store the pair relationship of the elements of source tree and the new cloned elements.

```cpp
class Solution {
public:
    map<Node*, NodeCopy*> node_map;

    NodeCopy* copyRandomBinaryTree(Node* root) {
        if(root == NULL) return NULL;
        return dfs(root);
    }

    NodeCopy* dfs(Node* cur) {
        if(cur == NULL) return NULL;
        if(node_map.count(cur))
            return node_map[cur];
        NodeCopy* node = new NodeCopy(cur->val);
        node_map[cur] = node;
        node->left = dfs(cur->left);
        node->right = dfs(cur->right);
        node->random = dfs(cur->random);
        return node;
    }
};

```

The post [LeetCode: Clone Binary Tree With Random Pointer](https://coderscat.com/leetcode-clone-binary-tree-with-random-pointer) appeared first on [Coder's Cat](https://coderscat.com).
JavaScript: While Loop
Tags: javascript, beginners, codenewbie, 100daysofcode
Published: 2020-07-15 03:40:53


Loops allow us to repeat the same action multiple times. Every loop has three key items:

1. Loop start
2. Loop end
3. Loop increment/decrement/counter

For example, we might want to log numbers from 1 to 10. Here, the start is 1, the end is 10, and the counter increments by 1 every time.

```javascript
let i = 1; // start
while (i <= 10) { // end
  console.log(i); // 1 2 3 4 5 6 7 8 9 10
  i++; // increment/counter
}
```

🚨If we did not have the increment or counter, the loop will go on forever and log `1` infinite times.

The expression that is evaluated for the end of the loop need not be a comparison. Any falsy expression or variable will end the loop.

```javascript
let i = 10; // start
while (i) { // end
  console.log(i); // 10 9 8 7 6 5 4 3 2 1
  i--; // decrement/counter
}
```

When `i` reaches 0, it is falsy, and the loop will end.

The example above could also be turned into a one-line while loop. We can also omit braces when it is a one-liner loop.

```javascript
let i = 10;
while (i) console.log(i--);
```
Deployment Pipeline Best Practices Summarized
Tags: continuousdelivery, cd, devops, deployment
Published: 2020-07-15 03:28:38

---
title: Deployment Pipeline Best Practices Summarized
published: true
description: Deployment pipeline best practices for continuous delivery
tags: continuousdelivery, cd, devops, deployment
//cover_image: https://direct_url_to_image.jpg
---

Deployment pipeline as defined in the [Continuous Delivery](https://www.goodreads.com/book/show/8686650-continuous-delivery), is a process of converting commits into certified releasable artifact. 

As a developer, who loves types, I would rephrase the definition for conciseness as

```DeploymentPipeline :: List<Commit> -> Try<ReleaseableArtifact>```

While working as a consultant, when it comes to deployment pipelines, I have seen same mistakes being repeated across teams. So it is worth reiterating the deployment pipelines guidelines as mentioned in the [Continuous Delivery](https://www.goodreads.com/book/show/8686650-continuous-delivery).

- Build your binaries only once
- Binaries should not be environment specific
- Deploy same way to every environment
- Smoke test your deployments
- Deploy into copy of production
- Each change should propagate through the pipeline instantly
- If any part of the pipeline fails stop the pipeline

I highly recommend [Continuous Delivery](https://www.goodreads.com/book/show/8686650-continuous-delivery) book that further elaborates on each of these points.
A zoo of casts
Tags: syntax, compilers
Published: 2020-07-14 20:35:52

I recently made a post on Reddit to ask about various types of cast syntax. For posterity's sake I'm recording them here.

Note that I'm ignoring the behaviour of the cast. Some languages have different syntax for upcasts, downcasts, bitcasts etc. I'm not concerned with that here. This is merely a list of variants of visual syntax. Consequently I list `:>` even though that's only a special form of cast for F#, and only one of the many `keyword<type>(x)` casts for C++, even though there are many variants.

Also I apologize in advance if the attribution is incorrect somewhere. I don't know all the languages I list here.

(The list of languages for each is also incomplete – it's just a sample)

    cast(x, int)        MATLAB
    int(x)              Pascal
    <int>x              Typescript
    (int)x              C/C++/Java/Beef/C#
    static_cast<int>    C++
    x as int            C#/Swift/Rust
    x as! int           Swift
    cast(x as int)      SQL
    cast(int)x          D, Jai
    @as(int, x)         Zig
    [int]x              Pike
    (int)(x)            Go
    x :>                F#
    cast[int](x)        Nim
    x.as(int)           Crystal/Ecstasy
    x->(int)            Frost
    (x: int)            Flow
    cast<int>(x)        C2
    x.asInstanceOf(int) Scala
    x.(int)             Go
    x $ int             ChucK
    int'(x)             Verilog
    
For fun, here are other permutations of the cast syntax that may or may not be useful:

    (x as int)       
    (x, int)
    x<int>
    x::int
    (int : x)
    (int x)
    int::x
    (x :: int)
    cast(x -> int)
    x to int
    x#int
    int:x
    x.as[int]
    x[int]
    x.int
    (int >> x)

C3 is currently using `cast(x, int)` but that might change.

When evaluating syntax, readability is important and it is always nice if the precedence is crystal clear.

As an example: `x as Foo[4]` – would that be `x as (Foo[4])` or `(x as Foo)[4]`? Precedence rules will obviously decide, but if we compare with `cast<Foo[4]>(x)` the latter is much clearer because there is no need to know the precedence. 

But length also matters: `x = int(y) + int(z)` is succinct while `x = cast(y, int) + cast(z, int)` feels quite a bit more wordy.

Picking a good cast syntax for a language is clearly one of difficult trade-offs.
Custom directory for Webpacker in Rails apps
Tags: rails, webpacker
Published: 2020-07-18 12:25:45

---
title: Custom directory for Webpacker in Rails apps
published: true
date: 2020-07-15 03:19:11 UTC
tags: rails,webpacker
canonical_url: https://prathamesh.tech/2020/07/15/custom-directory-for-webpacker-in-rails-apps/
---

Starting from Rails 6, Webpacker is the [default JavaScript compiler](https://dev.to/prathamesh/understanding-webpacker-in-rails-6-l4i) for Rails apps.

By default, Rails recommends adding the Webpacker related JavaScript code in `app/javascript` directory. A lot of people wanted to place the JavaScript code in custom directory instead of `app/javascript`. It is now possible to customize it.

You just need to set the `source_path` in the `config/webpacker.yml` to the directory relative to the `app` folder where you want to place the Webpacker JavaScript code.

<!--kg-card-begin: code-->
```yml
# config/webpacker.yml

default: &default
  source_path: app/frontend

```
<!--kg-card-end: code-->

This change is available in Webpacker gem from version 4.1.0 onwards and in Rails from Rails 6.0.1 onwards.

With this change, we can place our JavaScript code in any of the custom directory of our choice under the `app` directory, configure it via the `source_path` setting in the `webpacker.yml` and that's it.

Once we have configured this directory, then the subsequent Webpacker commands use this directory as reference.

<!--kg-card-begin: code-->
```sh
✗ bundle exec rails webpacker:install:react
Copying babel.config.js to app root directory
       force babel.config.js
Copying react example entry file to /Users/prathamesh/Projects/fun/frontend_rails_app/app/frontend/packs
      create app/frontend/packs/hello_react.jsx
Updating webpack paths to include .jsx file extension
      insert config/webpacker.yml
```


Want to know more about Webpacker and Rails, check out my [other blog posts](https://prathamesh.tech/webpacker-on-rails/) on this topic or subscribe to my [newsletter](https://prathamesh.tech/mailing-list).
Generate SSH Key on windows
Published: 2020-07-15 03:01:37

1. To generate SSH key on your windows PC, Open command prompt (cmd) and type the following command
`ssh-keygen`

2. To save the key to the default location, press enter. Otherwise enter your desired location

3. Enter a para-phase you can remember or press enter to leave it blank

4. Re-enter your preferred para-phrase 

5. The system generates your key pair and also displays a randomart image

6.Navigate to the location you had initially accepted, e.g C:\Users\user_name\.ssh

7.Two files are available in the folder id_rsa is a private kay.
The public key is id_rsa.pub.This is the SSH key pair.
Do you know its power? 🚀
Tags: serverless, aws, javascript
Published: 2020-07-15 02:57:07

**Tech Stack!** 🚀

 A decade ago, Languages use to trend and now variable tech stacks are trending whether it be MERN Stack, MEAN Stack, JAM Stack, or other stacks available out there.

Several stacks I've worked on are MERN, MEAN, LAMP, JAM, and recently Serverless Stack. (AWS Lamda, Serverless Framework, API Gateway)

So developers and my fellow pals on Dev.to, what do you think is the **Potential**, **Power**, and **Scalability** of the Serverless stack in the modern Web architecture?

**Abbreviations**
- JAM (Javascript, API, Markup)
- MERN (MongoDB, Express.js, React.js, Node.js)
- MEAN (MongoDB, Express.js, Angular.js, Node.js)
- LAMP (Linux, Apache, MySQL, PHP)
get diff from arrays in JavaScript
Tags: javascript
Published: 2020-07-15 01:45:25

```javascript
// getDiff
const hoge = [1,2,3,4,5]
const fuga = [3,4,5,6,7]
[
    ...hoge.filter(v=>!fuga.includes(v)),
    ...fuga.filter(v=>!hoge.includes(v))
]
// [1,2,6,7]
```