teleren/devto huggingface dataset:
Quick steps to import and debug angular GitHub repository in StackBlitz
Tags: angular, webdev, debug, github
Published: 2020-02-11 17:41:33

Originally published at http://efficientuser.com on August 14, 2019.

StackBlitz is an online IDE where you can create Angular & React projects that are immediately online & shareable via the link.

It provides an option to open any public repo into it and debug immediately.

You can run any public repo on GitHub by providing the username + repo name like so:
> stackblitz.com/github/{GH_USERNAME}/{REPO_NAME}

And you can also optionally specify a branch, tag, or commit:
> …/github/{GH_USERNAME}/{REPO_NAME}/tree/{TAG|BRANCH|COMMIT}

Automatically stays in sync with your repo
Whenever you push commits to Github, the corresponding StackBlitz project automatically updates with the latest changes — ensuring Github remains your code’s source of truth.

For example,

If we have angular repo like below
https://github.com/PandiyanCool/thirukural

This can be framed as the following URL
https://stackblitz.com/github/PandiyanCool/thirukural

Happy Coding :heart:
JavaScript Promise and its states?
Tags: javascript, react, node, codenewbie
Published: 2020-02-11 17:30:18

---
canonical_url: https://bonsaiilabs.com/promise-and-states
---

This post covers what are `Promise` in JavaScript and a bit about the different states of `Promise`.

The code is available at https://bonsaiilabs.com/promise-and-states/

{% youtube CE2EjJRmTWM %}


Subscribe for more videos on JavaScript with Visualization: https://www.youtube.com/channel/UC0yZBnRsD9JRqLXBkfGym0Q?sub_confirmation=1
Overbitty, too modular?!
Tags: react, javascript
Published: 2020-02-11 17:20:12

I have adopted an entire React UI project at work all for me to get grips with before I hand that knowledge on to the team 🤯, I have been here a month now too, not bad if I do say so myself. I have realized that this should be (and probably is) the project of my dreams, it's very well put together. It's also very bitty, components are similar to atomic design principles.

I am not complaining at all, this is what I have longed for, for years, pitty the team who made it have long since dispanded to pastures new.

I feel like if I change anything I will be haunted by the ghosts of said team somehow. Truth is, I have to own it, understand it, compromise with it like my child. When I see some imperfection, I must remind myself, it's probably there because there is a jolly good reason. I cannot attempt to replace something I don't like it's not that easy.

So yeah, I am currently tracing path after path of component and prop after prop of functions and data, this isn't actually a mark of poor architecture, it's a mark of scale, the project is big. I almost wish it was all a bit flatter with more comments at file headers but at the same time I know I would eat my words and hate that, why do I always want the opposite of what I have.

Do you believe there is a perfect level of modularity?
What is a best / simplest way to serialize / deserialize JavaScript objects?
Tags: discuss, javascript
Published: 2020-02-11 17:17:08

Also, it is best to use minimal libraries. Prefer built-ins, rather than NPM.

I tried to use `JSON.stringify` with `replacer`; and `JSON.parse` with `reviver`, but it isn't as easy and intuitive as it seems.

This doesn't work, BTW.

```ts
function serialize (obj: any) {
  return JSON.stringify(
    obj,
    (_, v) => v instanceof Date ? { __date__: +v } : v
  )
}

function deserialize (s: string) {
  return JSON.parse(
    s,
    (k, v) => k === '__date__' ? new Date(v) : v
}
```

## Solution

```ts
function serialize (obj: any) {
  return JSON.stringify(
    obj,
    function (k, v) {
      if (this[k] instanceof Date) {
        return ['__date__', +this[k]]
      }
      return v
    }
  )
}

function deserialize (s: string) {
  return JSON.parse(
    s,
    (_, v) => (Array.isArray(v) && v[0] === '__date__') ? new Date(v[1]) : v
  )
}
```

Functions should work as well, with `Function.toString()` and `eval(Function)`.

## Questions

- Somehow, [NeDB](https://github.com/louischatriot/nedb)'s internal uses `{ $$date: +new Date() }` with great success. I don't know how that works.
- Even if I manage to get `JSON.parse` and `JSON.stringify` to work with `Date`, I cannot be really sure if it is more performant than third party solutions, but at least it is better than [js-yaml](https://github.com/nodeca/js-yaml)...
- `JSON.stringify` / `JSON.parse` is also known to not preserve key orders. I don't know if this will be problematic in the future.
python for the web
Tags: python, beginners, webdev
Published: 2020-02-11 17:06:34

You can use the Python programming language to build web apps. These web apps then run server-side and the user is presented with the traditional web app (HTML, JavaScript, <a href="https://angular.io/">Angular</a>, <a href="https://vuejs.org/">Vue</a>).

Python doesn't have a built-in web framework, so you have to pick one. A web framework starts a server, does templates, deals with architecture (often <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">model-view-controller</a>) and so on. It saves you a lot of development time. Web frameworks can be installed with pip

```bash
pip install <framework>
```


## Web Frameworks

A popular micro-framework is <a href="https://palletsprojects.com/p/flask/">Flask</a> (<a href="https://pythonbasics.org/flask-tutorial-hello-world/">hello world example</a>). This does the bare minimum, run the server, <a href="https://pythonbasics.org/flask-tutorial-routes/">routing</a>, parse <a href="https://pythonbasics.org/flask-tutorial-templates/">templates</a>, pass variables etc.

If you want to have many features available in the framework, like an ORM (Object Relational Manager) you could go for <a href="https://www.djangoproject.com/">Django</a> (<a href="https://dfpp.readthedocs.io/en/latest/chapter_01.html">django tutorial</a>). Downside of Django is the learning curve and it has many features you may not need.

<a href="https://www.tornadoweb.org/en/stable/">Tornado</a> is another option you could pick. It is a Python web framework and asynchronous networking library. Tornado apps are scale-able, it can scale to tens of thousands of open connections. 
You can install tornado with pip

```bash
pip install tornado
```

It's very straightforward to create a hello world app:

```python
import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

def make_app():
    return tornado.web.Application([
        (r"/", MainHandler),
    ])

if __name__ == "__main__":
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()
```

It opens the server at port 8888, then waits for input. It creates one web route (/) which is linked to MainHandler. This returns the text "Hello, World".

## Hosting

To get your app online, you have to host it on a server. You could open your home server to the web, but this is generally not a good idea.

An easy way to do hosting is to use <a href="https://www.pythonanywhere.com/">PythonAnywhere</a>. This lets you host, run and code in the cloud.

If you want to do everything yourself, you could use <a href="https://www.vultr.com/">Vultr</a> or <a href="https://www.digitalocean.com/">Digital Ocean</a> instead.
How to Keep Writing Code and Building Products at Age 70
Tags: career, discuss, inclusion, beginners
Published: 2020-02-11 17:00:38

[If I get enough experienced developers responding, I hope to interview some about their stories and synthesize useful information for beginners!]

I want to talk about career longevity in the software industry. There are so many new developers entering the industry and that is awesome. But I also see people with years of experience leaving the industry. My sense is that when people with so much experience leave development (for other industries or for other roles), we as an industry loose **wisdom** and forward progress.

If your goal is to write code and build products for the rest of your career (as a job or as an entrepreneur or using it as a tool to solve problems) and beyond retirement, how will you make that happen?

Yes there are certainty challenges - there are new tools and technologies to learn frequently, and this industry is still working on improving the -ism (including ageism).

There are certainty opportunities too - the sense of achieving mastery, for using software as a powerful tool to yield outcomes, for understanding history and recognizing patterns, for bringing others (apprentice) along the path you've traveled.   

Are there dev.to readers who've been in the industry for more than 15 to 20 years. What practices did you use to build a career of that length? Can you see yourself staying the industry for the next 15 to 20 years (or until retirement age)? What challenges do you see, what opportunities do you look forward to? 

And I hope this thread is useful for beginners. Because when you're on a journey sometimes it helps to see the path ahead not just a few steps but a several miles ahead.
Getting Started with Cloudflare Workers
Tags: cloudflare, cloud
Published: 2020-02-11 23:39:50

---
title: Getting Started with Cloudflare Workers
published: true
date: 2020-02-11 17:00:00 UTC
tags: Cloudflare,Cloud
canonical_url: https://homelab.blog/blog/devops/cloudflare-workers/
---

I have recently had the need to redirect a few subdomains to another domain, due to old links still being used by public individuals.

I wanted a solution that would not require running another web server, so I started looking into a few different options.

## Cloudflare Page Rules

While Page Rules do want I want, they were either not flexible enough (could only target a single subdomain), and would be relatively expensive for the number I would need.

## Cloudflare Workers

Cloudflare Workers are pretty cool. They allow you to run JS code at the Cloudflare edge. They are basically functions-as-a-service, which are super fast and customizable.

I was able to set up a function in less than 5 minutes that allows me to redirect any subdomain to another domain.

The function I am using looks like this:

```
async function handleRequest(request) {
  return Response.redirect(someURLToRedirectTo, code)
}
addEventListener('fetch', async event => {
  event.respondWith(handleRequest(event.request))
})
/**
 * Example Input
 * @param {Request} url where to redirect the response
 * @param {number?=301|302} type permanent or temporary redirect
 */
const someURLToRedirectTo = 'https://homelab.blog'
const code = 302 // Temporary Redirect

```

Basically, it handles requests by sending a 302 Temporary Redirect to my current blog page.

Additionally, the function is super fast. It seems significantly faster than if I were to run a webserver to handle the redirect myself.

It is also using the [routes](https://developers.cloudflare.com/workers/about/routes/) function. You still have to define a DNS name for the URLs you want to redirect, and I currently just CNAME them to the workers.dev hostname of the worker.

This is just a start of what workers/functions are able to do, and I am excited to see where else I can use them to make my life easier.
Easy Authentication in Elixir & Phoenix with the pow & pow_assent libraries
Tags: elixir, phoenix, authentication, webdev
Published: 2020-02-11 16:57:45

{% youtube hnD0Z0LGMIk %}

### Setting up authentication in new Phoenix web apps

I always enjoy starting new web projects, its a nice clean slate and an opportunity for you to create a solution that's hopefully better designed and engineered than the other projects I've worked on... and there are all sorts of interesting things to think about and research, and there's no technical debt to deal with (yet), and there are no pending deadlines, and so on.

But here's the thing, as soon as I start setting up the new [Elixir](https://elixir-lang.org/) / [Phoenix](https://www.phoenixframework.org/) project, my excitement fades pretty quickly, because, in my mind, project setup should take a matter of minutes, but in reality project setups takes much longer than I expect, because... well, it's not something I do every day, so I always have to shake off the dust, do a bit of research to see if there are any new "best practices", or new libraries I should look at and so on.

### So what?

Ok, so why am I talking about this?

Well, because sometimes we make these initial setups harder than they have to be, and I want to look at one particular aspect of setting up a new project, that I suspect many of us do the hard way, I know I have.

The thing I want to look at is handling authentication in a new phoenix project... And I want to consider the question: "how should I handle authentication? roll my own or use a library"

Check out the above [screencast](#body) to see my take on handling authentication in Elixir / Phoenix web applications.

### Spoiler alert

Do you want to know the gist of the screencast?

Even thought it's "easy", you probably shouldn't write your own authentication system, you should just use the excellent [**pow**](https://github.com/danschultzer/pow) and [**pow_assent**](https://github.com/pow-auth/pow_assent) libraries. I make the case for using these libraries and show you how in just a matter of minutes you can:

1. Create a new Phoenix project
2. Setup authentication
3. Add simple route based authorization
4. Setup password resets
5. Setup social logins (ie login with Twitter, Facebook, Github, etc)

If you like pow & pow_assent, please reach out to the primary author, [Dan Schultzer](http://twitter.com/danschultzer) and thank him for all his hard work.

Additionally, if you can, please consider [sponsoring](https://github.com/sponsors/danschultzer) Dan's open source-work, either personally or through your employer. I believe open source authors are truly under-appreciated, but we can change that if we all chip in just a little bit.

### Want to learn more about Elixir & Phoenix?

Checkout my new course: [**Elixir & Phoenix for Beginners**](https://knowthen.com/elixir-and-phoenix-for-beginners)
Different types of function – JavaScript Series – Part 18
Tags: javascript, beginners, codenewbie, tutorial
Published: 2020-02-11 16:49:13

In last two part we declare the function in a same style, but there is a another way declare a variable. We are going to learn it today.

Up until now we wrote the functions declaration. Now we are going to learn about function expression.

Here we don’t have a name for the function. So it also called anonymous function.

Let’s write one to understand more about it.
```

function() {
  console.log('How you doin ?')
}
```
this will be function and we’ll store it on a variable and then we’ll call the function using variable()

Example –

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0n65r0lb6yn9putdhghn.png)

This exactly does the same thing as our old function. This pattern is widely use in js, so it is better to know both.

Let’s have a look on the both type

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7yna09i1e4mrs4ha353n.png)

Result –

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7hd6jrlz5tsirc29mure.png)

You can see the graphical version here
{% instagram B8bObQxgWe- %}

Source Codes - { Check commits }
{% github nerdjfpb/javaScript-Series %}

Originally it published on [nerdjfpbblog](https://blog.nerdjfpb.com/javascript-part-18/). You can connect with me in [twitter](https://twitter.com/nerdjfpb) or [linkedin](https://www.linkedin.com/in/nerdjfpb/)!
golang break for loop
Tags: go, beginners
Published: 2020-02-11 16:30:06

In <a href="https://golang.org">Go</a> you can use a <a href="https://golangr.com/for/">for loop</a> to repeat code. The for loop exists in many programming languages. But how do you stop a for loop?

By default, it stops if a condition is true. In Go, this repeats while i is smaller than 5. If its greater it stops.

```go
for i := 0; i < 5; i++ {
```

This works well, but what if conditions are not right? Like this:

```go
for i := 0; i > -1; i++ {
```

Then it keeps repeating over and over.

## Infinite loop

An infinite loop is a loop the stays in the loop indefinitely. In Golang you can create this type of loop:

```go
for {
```

So when would this for loop end?

```go
package main

import "fmt"

func main() {
    i := 0
    for {
        fmt.Println("i is:", i)
        i++;
    }
    fmt.Println("Statement after for loop.")
}
```

It doesn't end by default, this creates an infinite loop in Go. So this outputs..

```
...
i is: 59641
i is: 59642
i is: 59643
i is: 59644
i is: 59645
...
```

ad infinitum. 

## Break keyword

To get out of the loop, you can use the **break** keyword. The break exits the infinite loop, but it has to do so <a href="https://golangr.com/if/">conditionally</a>.

```go
if i >= 10 { break }
```

So that would give you the code:

```go
package main

import "fmt"

func main() {
    i := 0
    for {
        if i >= 10 { break }
        fmt.Println("i is:", i)
        i++;
    }
    fmt.Println("Statement after for loop.")
}
```

**Related links:**
* <a href="https://play.golang.org/">Go playground</a>
* <a href="https://golangr.com/">Learn Go</a>
Remove Linux GRUB from UEFI boot list and keep Windows BCD
Tags: undefined, bcd, boot, bootlist
Published: 2020-02-17 15:35:37

---
title: Remove Linux GRUB from UEFI boot list and keep Windows BCD
published: true
date: 2020-02-11 16:17:02 UTC
tags: Undefined, bcd, boot, boot list
canonical_url: https://esabook.wordpress.com/2020/02/11/remove-linux-grub-from-uefi-boot-list-and-keep-windows-bcd/
cover_image: https://esabook.files.wordpress.com/2020/02/20200209_121051.jpg
---

 **UEFI:** [https://en.wikipedia.org/](https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface)  
**ESP:** [https://en.wikipedia.org/](https://en.wikipedia.org/wiki/EFI_system_partition#Windows)  
**GRUB:** [https://www.gnu.org/software/grub/](https://www.gnu.org/software/grub/)  
**BCD:** [https://en.wikipedia.org/](https://en.wikipedia.org/wiki/Windows_NT_6_startup_process)

* * *

1. Boot to Windows **terminal** mode, by typing this at `command prompt` 
   `shutdown.exe /r /o`
   other guide [https://www.minitool.com/](https://www.minitool.com/news/advanced-options-windows-10-009.html)

  
2. **Rebuild** `BCD` (swapping `GRUB` to `BCD`)
   `bootrec /rebuildbcd`
   `bootsect /nt60 sys`
   `bootrec /fixmbr`
   if all of that command is not successful, jump to [step 3](#assign-volume-letter), then back again here to rename old BCD, and retry.
   `cd /d Z :/EFI/Microsoft/Boot`
   `ren BCD BCD.old`
![20200209_113255](https://esabook.files.wordpress.com/2020/02/20200209_113255.jpg)<figcaption>Windows 10 at terminal mode</figcaption>
####  
3. Make​ ​`ESP` accessible
  `diskpart`
  type `list disk` if any other disk attached, else​ ​`select disk 0`  
  type `list volume` to find ​`ESP` volume number  
select volume **number** (e.g **`4`** ) and assign a **letter** (e.g **`Z`** ) as `ESP` volume alias.
  `select volume 4`
  `assign letter= Z`
  `exit`
![20200209_121646](https://esabook.files.wordpress.com/2020/02/20200209_121646.jpg)<figcaption>Diskpart.exe</figcaption>
4. **Remove** `Kali GRUB` from `ESP`
   `cd /d **Z** :/efi`
   `rmdir /r /s **kali**`
5. **Done**

* * *

**Bonus**  
Merging unused (old linux system) to single (nearest) partition.

![](https://esabook.files.wordpress.com/2020/02/20200209_113720.jpg?w=300)<figcaption>Highlight of unused partition</figcaption>![](https://esabook.files.wordpress.com/2020/02/20200209_113853.jpg?w=300)<figcaption>Extend partition volume with diskmgmt.exe</figcaption>![](https://esabook.files.wordpress.com/2020/02/20200209_114012.jpg?w=300)<figcaption>Result of merged partition</figcaption>
Push to a forked pull request branch on GitHub—Am I doing this right?
Tags: git, github, help
Published: 2020-02-11 16:05:15

I want to ask about something I know _how_ to do, but I'm not sure if there's a more straightforward way to do it.

Let's say I want to collaborate on a pull request with @andy, this would be my flow...

First I add Andy's repo...

```bash
git remote add andy https://github.com/Zhao-Andy/dev.to
```

Then I push to their repo like this...

```bash
git push andy my-branch-name:his-branch-name
```

It's kind of straightforward but requires me to add his repo, copy and paste his branch name, and just doesn't seem elegant.

Are there other ways to do this or is this just how you do it?
Can volatile make a non-atomic operation to atomic?
Tags: java, tutorial
Published: 2020-02-11 16:02:57

This question is also not easy to answer because volatile is not about atomicity, but there are cases where you can use a volatile variable to make the operation atomic.

One example is having a long field in your class. If you know that a long field is accessed by more than one thread e.g. a counter, a price field or anything, you better make it volatile.

Why? because reading to a long variable is not atomic in Java and done in two steps, If one thread is writing or updating long value, it’s possible for another thread to see half value (fist 32-bit). While reading/writing a volatile long or double (64 bit) is atomic.
F*ck-That Money
Tags: career, startup, business, motivation
Published: 2020-02-11 15:22:08

---
title: F*ck-That Money
published: true
description: It's time to throw out the Silicon Valley bullshit that perpetuates the idea of "F*ck-You Money."
tags: career, startup, business, motivation
canonical_url: https://www.honeybadger.io/blog/f-ck-that-money/
---

**I've met some hugely successful people. Some of them are happy.** Some of them... aren't. I've noticed some things about the ones who aren't:

- They're obsessed with their careers
- They spend a lot of time at work
- They aren't fulfilled by the work they do
- They aren't content with what they have

In many circles, these people are way more successful than most of us. They probably have better networks. They might have fancier job titles. They certainly make more money.

The Silicon Valley meme goes, "start a company and sell it for so much money that you can say 'f*ck you' to anyone in the world." Or maybe an alternate career path is to climb the corporate ladder at Google until you've banked that privilege.

**So much toxic bullshit stems from that line of thinking.**

I'd rather have f\*ck-that money—e.g., a moderate amount of money that empowers you to live a meaningful life. F\*ck-that money isn't about being a pretentious asshole; it's about keeping your priorities straight. For example:

- Miss your kid's soccer practice to catch up on emails? F*ck that!
- Power through lunch? F*ck that!
- Skip the gym? F*ck that!
- Work over the weekend? F*ck that!
- Save that side project for when you have more free time? F*ck that!
- You get the idea...

At Honeybadger, this mindset has led us to turn down acquisition offers and investors—to stay small and grow naturally. We're not in this business to be rich; we're in it to be free.

Regret the best years of our lives?

**Fuck that.**

---
Btw, we're currently [hiring a developer](https://www.honeybadger.io/blog/hiring-a-software-developer/) to join us.