teleren/devto huggingface dataset:
Solution: UnSupported Protocol scheme golang issue
Tags: go, http, vasubabu
Published: 2019-12-05 06:03:55

Recently I had faced an issue while using `net/http` to get the resource from an URL:

Here is my program:

```
package main

import (
	"fmt"
	"log"
	"net/http"
)

type WebScrapper interface {
	PullContent(url string)
}

type webScrapper struct {
}

func (w *webScrapper) PullContent(url string) {
	resp, err := http.Get(url)

	if err != nil {
		panic(err)
	}

	defer (func() {
		if r := recover(); r != nil {
			fmt.Printf("Recovered from panic %s", r)
		}
	})()

	log.Printf("Got response for %s and status is %s", url, resp.Status)
}

func main() {
	w := webScrapper{}
	urls := []string{
		"www.google.com",
		"www.facebook.com",
		"www.gmail.com",
	}

	for i := 0; i < len(urls); i++ {
		w.PullContent(urls[i])
	}

}

```
yes its a lot of code, but don't worry about code having interfaces and structs and defer. The code is breaking mainly at getting resource from URL.


Error: 

```
 Get www.google.com: unsupported protocol scheme ""

```

Solution:

To fix `unsupported protocol scheme` prepend `http://` before every URL.


```
urls := []string{
		"http://www.google.com",
		"http://www.facebook.com",
		"http://www.gmail.com",
	}
```

That's it!!!
I can help not not too much
Published: 2019-12-05 05:29:30

My opinion is ts can help but can't help a lot, you should be clearly know what you are doing not just depend on ts enhancements. js is very easy to read but ts is not, and js is more sufficient when you know exactly what you are doing. Most type issues I encounter are running issues, static type checking won't help. I love js as a small and easy-readable language, so I won't choose ts, though ts is not bad at all.
CLI for Efficiency #1
Tags: linux, ubuntu, productivity
Published: 2019-11-19 14:41:02

I tried KDE Plasma on my Ubuntu machine last weekend. After using it for a while, I decided that it is too complicated for me and I'd like to remove them from my machine.


To remove installed packages in Ubuntu is simple. 

`$ sudo apt remove package-name-1 package-name-2`


But, there are a lot of packages installed automatically when you install KDE Plasma. Removing them one by one is definitely, well, inefficient. So, the challenge here is to get a list of installed KDE packages in proper format, so you can feed them into the command above.


Here's how I solve it in an efficient way.


`apt` as the interface for the package management system in Ubuntu provides a way for you to list installed packages. Here's one way to list installed packages which name contains `kde`.


```
$ apt list --installed | grep kde

.
.
debconf-kde-helper/disco 1.0.3-1 amd64 [installed,automatic]
kde-style-breeze/disco 4:5.15.4.1-0ubuntu1 [installed,automatic]
.
.
```


The output is not something we can feed into `apt remove` command directly, so we need to sanitize it quite a bit.


It's obvious that the package name is anything before `/`. We can use the `cut` command to do just that.


```
$ apt list --installed | grep kde | cut -d "/" -f 1

.
.
debconf-kde-helper
kde-style-breeze
.
.
```


Next, since each packages are listed in a new line, we still can't pass this output directly to the `apt remove` command. Let's replace the new line with space using `tr` command. 


```
$ apt list --installed | grep kde | cut -d "/" -f 1 | tr '\n' ' '

.
.
debconf-kde-helper kde-style-breeze
.
.
```


Now, the output of installed KDE packages are now in proper format. We can now feed the output directly to `apt remove` command using `xargs`.

 
`$ apt list --installed | grep kde | cut -d "/" -f 1 | tr '\n' ' ' | xargs sudo apt remove`


It's amazing how these four simple tools: `grep`, `cut`, `tr`, and `xargs`, can help you automate and achieve your goal; saving you from the manual and repetitive labor. 


How might you do it differently?
Angular 8 Install Font-awesome icons example
Published: 2019-12-05 11:08:40

---
title: Angular 8 Install Font-awesome icons example
published: true
date: 2019-12-05 03:57:36 UTC
tags: 
canonical_url: https://www.itsolutionstuff.com/post/angular-font-awesome-how-to-install-font-awesome-in-angular-8example.html
---

Hi DevToday i wanted to show you how to use font awesome icons in angular 8 i want to give you simple example of angular 8 install font awesome icons using npm command we will install fontawesome library for font awesome iconsIcons is a basic requirement of each project icons indicate more
I made something! Introducing Nightingale, a fast and resource-efficient REST client
Tags: webdev, csharp, testing, productivity
Published: 2019-12-05 03:13:58

REST clients today can use upwards to 1000MB of memory. This leads to a poor experience for people who don't have access to high powered machines, such as junior indie developers who are just jumping in to the world of software development. So I built a REST client that uses ~60MB.

[Introducing Nightingale, a fast and resource efficient REST client for Windows 10.](https://www.microsoft.com/en-us/p/nightingale-rest-api-client/9n2t6f9f5zdn?cid=devto)

Let me know what you think! Looking forward to your feedback 🙏🏽
Apply dark theme to your site using prefers-color-scheme
Tags: javascript, css
Published: 2019-12-05 02:42:17

---
title: Apply dark theme to your site using prefers-color-scheme
published: true
description: Apply dark/light theme to your website based on users os set theme
tags: javascript, css
---

I recently noticed tweet by v8 team that said they have introduced dark theme for v8.dev based on users operating system set theme. I has surprised by it so I did a little digging to see how it works. I did find an awesome css media query called **prefers-color-scheme** which is surprisingly easy to use.

To apply dark theme to your website if your os set to dark you can use the media query

```css
@media (prefers-color-scheme: dark) {
  body {
    background-color: #282828;
    color: #f3f3f3;
  }
}

```

Similarly for light theme you could use the media query

```css
@media (prefers-color-scheme: light) {
  body {
    background-color: #fff;
    color: #282828;
  }
}
```

Here is a sample demo of this https://rafi993.github.io/prefered-color-theme/

try switching your OS dark and light color theme to see this.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/lp5lhqmuqt0avtxxj9t5.PNG)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/cndaa0iuk4j7g7372khq.PNG)
How to build a dev community from scratch?
Tags: help, motivation
Published: 2019-12-05 02:30:05

I don't know how to start building a community. Well, I've always been complaining that there isn't a community in my local city and why I can't find other developers or people who want to learn and grow together. So, my goal for next year is to start a community, I know that if I do this it is _"for the love of art"_, but I like to teach and work with people who want to form something bigger than oneself. I really appreciate the help in the comments, thanks.
Docker in Terms You Know 
Tags: docker
Published: 2019-12-05 01:19:28

This discussion was started and I think it is a good segway into a docker article. 

{% link https://dev.to/goncalodcorreia/how-would-you-describe-your-perfect-learning-strategy-383p %}

The idea for this article is to make parallels between docker and other programming terminology. 

# Images

Docker operates of the idea of having prepared operating system which can be run on any hardware. This is the same concept as virtual machines which also use the term image, but that one is too easy. 

Object Oriented Programming often provides a concept structure called a class, but a class isn't a thing until it is instantiated. And this is why class makes for a good mental picture.

# Container

Docker needs to have a running instance of its OS, that is where the container comes in. 

Containers are the objects of OOP. They derived from their class(image) 

# Layers 

The layers are the OOP worlds hierarchy where each layer builds on the previous. Each layer is its own class (image). And just like classes a layer can have multiple children. This is where space savings comes in since you only need one copy of the parent for all children. 

Now I must switch analogy to version control. A layer is a state of data for the container. It is a commit of changes on another layer (image), again emphasizing the space savings.

Like git commits these content changes are hashed and the layer or container can be referenced by the hash.

# Registry

Sharing containers is an important part of docker, registry is that repository. Why not call it a repo? I won't tell you. A registry is just there remote upstream. 

And like git the images are immutable. You can remove references to them but it will be a different image.

# Continued

Is there another concept you would like a parallel to? In docker or another subject?
Debugging using VS Code
Published: 2019-12-05 18:52:25

---
title: Debugging using VS Code
published: true
date: 2019-12-05 00:00:00 UTC
tags: 
canonical_url: https://hiltonmeyer.com/articles/vs-code-debugging.html
---

Debugging using VS Code is pretty simple for Node projects. If you run `node --inspect-brk app.js` it will start a debugging session

![Debugging](https://res.cloudinary.com/hiltonmeyer-com/image/upload/v1575104620/debugging-03_zty5zr.jpg)

Then if you use ctl+shirt+P you can toggle the auto attach which will open the session in the Debugger View

![Debugging](https://res.cloudinary.com/hiltonmeyer-com/image/upload/v1575104620/debugging-02_reknek.jpg)

This will then attach to the debugger

![Debugging](https://res.cloudinary.com/hiltonmeyer-com/image/upload/v1575104621/debugging-01_wnt3tp.jpg)

Then just a case of adding breakpoints where you want and start stepping through the code. You don't have to leave VS Code
Advent of Code, day 4 in Zig
Tags: adventofcode, zig, newlanguage
Published: 2019-12-04 23:48:57

For day 4 of Advent of Code I wrote my solution in Zig. In this blog post I want to share a couple of my notes from the process.

[Zig](https://ziglang.org/) was brought to my attention earlier this year as an example of well-designed new programming language. By just looking at examples, it looked for me like "a more correct Rust", which was not very promising, given my problems with writing in Rust in the past. Also, I wanted to give it a shot earlier in Advent of Code, however... I found I don't really know how to read the file in it. The docs are vague and it seems that filesystem support is very rudimentary at the moment. This discouraged me for a while, however, when I saw that today's problem does not need a separate file for the input, I decided to give it a go anyway.

I would describe my experience as relatively pleasant. I had some problems, but all along the way the compile led me nicely with its error messages. The syntax itself is quite intuitive (with some exceptions listed below). Overall, the solution [is not very pretty](https://github.com/katafrakt/advent_of_code_2019/blob/master/04%20%5BZig%5D/solution.zig), but I bet it wouldn't be very beautiful in C either. And Zig targets itself as C replacement.

I found it weird that to populate an array I need to use syntax like this:

```
for (array) |*item| {
    const digit = @mod(value, 10);
    item.* = digit;
    value = @divFloor(value, 10);
}
```

Also, I needed to use weird methods like `@mod` and `@divFloor` instead of regular ones, because apparently Zig make a huge difference between compilation time integers (i.e. given in the code) and runtime ones. There was quite a lot of casting going on in my code. I understand this probably allows having more correct programs and is better for compiler implementation, but I find it a bit awkward.

On the upside, builtin unit tests helped me a lot checking small pieces of my logic for correctness. The pattern itself is not new for me, I really [love it in D](https://tour.dlang.org/tour/en/gems/unittesting), and seing it in Zig made me really happy.

```
fn numToDigits(num: i32) [6]i32 {
    // ...body
    return array;
}

test "numToDigits" {
    const num: i32 = 321456;
    const re = numToDigits(num);
    assert(re[0] == 6);
    assert(re[3] == 1);
}
```

Overall, I think Zig is an interesting language to look at. It still needs some love for less-hardcore compilers fans (my opinion, creators probably have different one). But I see why people give it as an example of a really well designed low-level language. I definitely want to try it out some more.
Track State with React.useState
Tags: react
Published: 2019-12-04 23:45:05

To make state dynamic, we just need a function to update it.

React gives us this function via `React.useState`.

`React.useState` is a function.

```js
React.useState()
```

It returns an array that includes the current value and an updater function.

```js
React.useState()
// => [undefined, function]
```

It takes a default value as an argument.

```js
React.useState("some default value")
// => ["some default value", function]
```

We can use [array destruct assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Array_destructuring) to assign array elements to local variables.

```js
let [value, setValue] = React.useState("default value")
// value => "default value"
// setValue => function
```

Wee use these values in our components.

```jsx
function App() {
  let [index, setIndex] = React.useState(0);

  return (
    <div>
      <button type="button" onClick={() => setIndex(index + 1)}>
        Next
      </button>

      <div>Current Index: 1</div>
    </div>
  );
}
```

## Give it a try

Use `React.useState` to update the Pokemon app in today's assignment sandbox:

{% codesandbox rg7lb %}

**Assignment**
1. Use the React.useState function to wrap our `index` state
1. Use array destructuring assignment to name the first and second elements of the Array React.useState returns
1. Use the `setIndex` function to respond to button clicks and update the index


---

Subscribe on YouTube:
{% youtube 5jI4bNSERlg %}

Follow the 🧵 on Twitter:
{% twitter 1202364792872194049 %}
My code review checklist
Tags: review, test
Published: 2019-12-04 23:39:24

---
title: My code review checklist
published: true
description: The personal checklist I use whenever reviewing commits and pull requests.
tags: review, test
---

I like reviewing code. I often learn new tips or tricks whenever I review. It doesn't matter if it expert or novice code, I learn from each.

Keeping track of everything can be difficult when doing reviews, so here is my personal list of things I check for.

## My reviewing code checklist

- Spelling: Spelling things correctly helps others search the code more effectively when debugging, refactoring, or writing enhancements.
- Transposed text: If it is a content update, I double check the source material.
- Links: Any relative links? Absolute links? SSL? The correct answer depends on the project but I always click through to check that they work.
- Overly complex code: I do not like [code golf](https://en.wikipedia.org/wiki/Code_golf). Writing overly elegant code just makes it more brittle and harder to support. If I can’t understand it at 3am during an incident, I want it refactored or documented thoroughly.
- Does it meet code standards? I like code standards. If everyone knows what the requirements are, the more likely code will be accepted. Also known as, "Argue once over tabs versus spaces, decide as a team, and WRITE IT DOWN."
- Comments: Format and length depends on the team (see code standards). Some teams prefer commit messages or READMEs over comments in code. This step could be renamed, "Is it complex or messy but documented?"
- Security: Is this resource only for admins or editors? How is that checked? Are inputs sanitized?

## Actions

- Run the linter: Sometime people forget.
- Run the tests: Yes, even if there is automated testing.

## Testing

- Run the code: Did the change work?
- Check existing behavior: Does this change affect something else unrelated? I usually check only two or three key paths.

If everything looks good, I approve the pull request.

Reviewing code shouldn't be a chore. It is a great learning opportunity for everyone.
Day 46 : Cold
Tags: hiphop, code, coding, lifelongdev
Published: 2019-12-04 23:29:11

_liner notes_:
- Professional : Sat in on a couple of sessions on how we can submit events and the process involved in deciding which ones we go to. Pretty streamlined. I even added 2 more today. I was able to cut down the number of events in my 2020 roadmap. It's for the first 3 quarters of the year. If I can get a string of them approved, I will be able to visit Europe for about a month. Before that though, I'm scheduled to go to Ohio for a couple of days in January. Worked on getting things set up for that. Also worked on getting my corporate card, but then I some how got my account locked. haha So I sent a message to account support so hopefully that will be unlocked so I can finish up some things in the corporate card process. Finished up the last piece of functionality of the Prize wheel app that I was trying to work out. Now when the winner is selected, a text message is sent to everyone that entered via SMS and let them know if they won or not. Also did some refactoring so things work better. Got pretty much everything done and then Glitch said my site was getting too many hits. haha Also, discovered an issue with my Ninjas vs. Pirates voting app. I think I have a fix, just need to apply it and test it. Oh and I received a package with some wrapped items and a note with a Willie Wonka picture asking not to open until next week during a team meeting. haha What could be in there? 

- Personal : Going to work a little on the front page of a side project. Maybe even get a backend set up to send some data to the frontend. I'd like to also see if I can get some apps installed in Linux on the Google Pixel Slate. Probably will go through some tracks for this week's radio show.

![Sand dunes of the Canary Islands in Spain](https://thepracticaldev.s3.amazonaws.com/i/l8by1btv9kyshqbt4dql.jpg)

Tomorrow, I would like to demo the Prize Wheel app and get feedback on how to improve. Want to fix the Ninjas vs Pirates app and get that up and running. Side note, it's been pretty cold.... in Florida!

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube Cnl5acNeJy8 %}