teleren/devto huggingface dataset:
Angular: Using custom made SVG icons through Angular Material
Tags: angular, svgicons, material
Published: 2019-10-22 22:44:33

---
title: Angular: Using custom made SVG icons through Angular Material
published: true
description: angular material custom svg icons
tags: Angular, Svg Icons, Material
---

This is a tiny, but useful post that will demonstrate how to create a service that registers custom svg icons in order to use them through the mat-icon component.

Step 1. I place all my icons under `assets/svg/icons`
Step 2. I create an string enum with all the icon names i.e. (you could just have a string array but I like the idea of using an enum)


```typescript
export enum Icons {
    Close = 'close',
    Done = 'done',
    Edit = 'edit'
}
```

Step 3. I create my service. Which simply iterates all values in my string enum and registers them again the `MatIconRegistry`. `bypassSecurityTrustResourceUrl` simply bypass the security checks and trusts the svg file (make sure the svgs are to be trusted).

```typescript
@Injectable({
  providedIn: 'root'
})
export class IconService {

  constructor(
    private matIconRegistry: MatIconRegistry,
    private domSanitizer: DomSanitizer
  ) { }

  public registerIcons(): void {
    this.loadIcons(Object.values(Icons), '../assets/svg/icons');
  }

  private loadIcons(iconKeys: string[], iconUrl: string): void {
    iconKeys.forEach(key => {
      this.matIconRegistry.addSvgIcon(key, this.domSanitizer.bypassSecurityTrustResourceUrl(`${iconUrl}/${key}.svg`));
    });
  }
}

```

Step 4. Then simply on the `app.component.ts` ngOnInit call the `registerIcons` function


```typescript
  constructor(private iconService: IconService) {
  }

  ngOnInit() {
    this.iconService.registerIcons();
  }
```

Step 5. Use them anywhere in the application

```html
    <mat-icon svgIcon="edit"></mat-icon>
```
Seeking Opinions on Wix Code/Corvid
Tags: discuss, wix, corvid, networking
Published: 2019-10-22 22:20:43

First, I'm new to Dev, but I've already seen the strength of this community and am super excited to be a part of it!

Second, I'm doing a deep dive study into Wix and Wix Code/Corvid, which is Wix's app creation platform.  I'd love love to ask folks with experience what they think of Wix and the underlying Corvid platform.  If you are building websites with Wix, Wix Code, and/or are interacting with Corvid, I'd love to hear your opinions about what it does well, and not so well.

Additionally, _for anyone based in NYC_, I'm actually looking to invite a few developers with experience in Corvid over for a nice dinner to chat about everything Wix, Wix Code, and Corvid.  If that sounds interesting, please send me a message on DEV connect (my inbox is open).  

Look forward to hearing from you all!
Can we separate the artist from their art? Should we?
Tags: news, watercooler, discuss
Published: 2019-10-22 21:54:49

(In)famous author and programmer John Sonmez (author of Soft Skills and The Complete Software Developer's Career Guide) has said some patently despicable things on Twitter lately, and faced a rightly-deserved backlash:

{% twitter 1186128959123132416 %}

When events like this happen, whether it's an author, or a musician, or an actor, the conversation often ends up at the idea of separating the artist from their art. __Can we enjoy John Sonmez's books while still thinking he's an awful person who has said some disgusting things?__ Is this cognitive dissonance? If someone else had written the same books, would they be any more useful?

{% twitter 1186734674674102277 %}

Sonmez's publisher has dropped Soft Skills and his courses have been dropped from Pluralsight. I'm completely uncomfortable with financially supporting someone who's hurt people so flippantly, but should we avoid even secondhand (or library copies) of his books?

What do you think?

---

Photo by [Viktoria Goda](https://www.pexels.com/@viktoria-goda-422369?utm_content=attributionCopyText&utm_medium=referral&utm_source=pexels) from [Pexels](https://www.pexels.com/photo/blue-red-and-yellow-chalk-1107495/?utm_content=attributionCopyText&utm_medium=referral&utm_source=pexels)
Abusing pointers is not always fun
Tags: cpp, c
Published: 2019-10-22 21:38:57

Or how to waste one hour(if lucky) in a debugger.

So a couple of days ago I was working on some network protocol stuff. The code looked something like this:

{% gist https://gist.github.com/76716C86/c118cf9a73283063d55c2d0f5513a694 %}


I'll give you 5 minutes to find the bug ... found it? No? Here we go.

All those pointers (ptr_foo_, ptr_bar_, ptr_payload_) are not updated when something new is pushed (given a second thought maybe "append()" would be a better name).

Why would we need to do that, to update those pointers?

Remember that when you call **std::vector<T>::reserve()**, you simply ask the allocator to expand or contract the vector's internal memory block. When the new block is found the contents of the old block might be copied to the new block.

This means that after such a reallocation our pointers will point into some unknown memory region, which might be used by other parts of the program i.e. everytime we change stuff via those pointers we taint someones data.


Now you may ask how can we fix this? It's really simple, we just need to ditch those member pointers and replace them with functions(getters) that ALWAYS compute a pointer using **buffer_** and an offset.

Looking back having those pointers as data members was just a dumb idea, not only causing problems but also increase the memory footprint of a **pdu**.



PS: *I'm aware of my dumb structs not being packed so no need to point that. :)*
Angular 9|8 Promises Example – Manage HTTP Requests
Tags: angular98, angular, http, managehttprequests
Published: 2020-01-31 20:47:55

---
title: Angular 9|8 Promises Example – Manage HTTP Requests
published: true
date: 2019-10-22 21:34:34 UTC
tags: Angular 9|8), Angular, HTTP, Manage HTTP Requests
canonical_url: https://www.positronx.io/angular-promises-example-manage-http-requests/
---

The post [Angular 8/9 Promises Example – Manage HTTP Requests](https://www.positronx.io/angular-promises-example-manage-http-requests/) appeared first on [positronX.io](https://www.positronx.io).

In this **Angular 8/9 Promise tutorial** , we are going to learn how to manage asynchronous HTTP response with JavaScript Promise objects.

Get the full code of this tutorial on the following GitHub repo:



[Click here to read more](https://www.positronx.io/angular-promises-example-manage-http-requests/)
Django and Jupyter notebook app
Tags: django, jupyter, machinelearning, database
Published: 2019-10-22 21:27:44

Hello Guys,

I thought of an idea where I want to create a Django website that has a Jupyter notebook implemented inside Django.

The reason for this is I want to write Data Analytic function that captures data from X year until now and stays current. The data captured gets cleaned and then stored into a database on Django for later use for machine learning.

Problem is, my skills are a bit lacking with Django and I only recently started learning how everything works. 

Question is, is this even possible to do with Django and Jupiter notebook? What kind of server do I need to do this, can it be on a budget or can I use a generic server to do something like this?

Any suggestions and recommendations are welcome.



Kind Regards.
5 Reasons why you should NOT go to a coding bootcamp
Tags: beginners, webdev, codenewbie
Published: 2019-10-22 21:13:27

I went to a coding bootcamp 2 years ago. From my experience and people I met, these are reasons why someone should NOT go to a coding bootcamp.

Please consider subscribing by clicking here if you found this information useful!
[YouTube - Matt Upham](https://www.youtube.com/mattupham?
sub_confirmation=1)

**Check out this video for further detail:**
{% youtube Cygm0EIJXjo %}
[5 Reasons why you should NOT go to a coding bootcamp](https://youtu.be/Cygm0EIJXjo)

**You don’t like software and/or technical thinking**
<ul>
<li>coding is not for everyone, it's really painful to do it if you don’t like it</li>
<li>you probably won’t perform well on the job if you don’t enjoy it</li>
</ul>

**Influences from family & friends**
<ul>
<li>do it for the right reasons (money should be a side effect, not a main purpose)</li>
<li>if your parents pay for it, you’ll most likely fail (internal motivation is needed)</li>
</ul>

**You can’t take time off to devote yourself, build habits, handle stress**
<ul>
<li>it really is 80 hours a week (if you do the 3 month programs)</li>
<li>you need to build a solid routine (if you can’t, you’ll fail)</li>
<li>lots of stress, if you don’t cope effectively you’ll fail</li>
</ul>

**It’s really expensive**
<ul>
<li>~$20k+ is a ton of money (yes, not all bootcamps are this expensive, but many are)</li>
<li>no guarantee for a job</li>
<li>job placement stats are bs (they’re usually manufactured / inflated)</li>
</ul>

**You can learn on your own (Seriously)**
<ul>
<li>you can find most of the material online for $50 or for free</li>
<li>FreeCodeCamp, OdinProject has the same and/or more material than the bootcamp</li>
<li>great inexpensive courses on Udemy, Coursera, Frontend Masters, etc</li>
</ul>


What are your thoughts on coding bootcamps? Yes, they have their flaws, and it’s not for everyone. But the high-quality ones are not completely terrible.

If you enjoyed this article, please consider subscribing to my YouTube Channel! I talk about tech, life in Silicon Valley, and self-improvement!

**Subscribe Here**
[YouTube - Matt Upham](https://www.youtube.com/mattupham?sub_confirmation=1)

Learning to code? Join our growing [Discord](https://discord.gg/9RGdMcF) community!

Thanks for reading!
Problem with a variable
Tags: javascript, html, help, code
Published: 2019-10-22 21:07:56

Hi guys! I have a little problem:
https://pastebin.com/aZLuQkVe
this code would have to find in the textarea a word that I write in the input, and after finding it, the code must highlight the first letter. So I put paragraph.setSelectionRange(indexOfFirst); in this way it would have to highlight the letter corresponding to "indexOfFirst" number, but it doesn't work.
Maybe "indexOfFirst" is not took as number, but I tried to use Number(indexOfFirst) to convert it to number, but nothing changed.
Can you help me?
Sparrow6 plugin to run/wait azure devops builds programmatically
Tags: devops, azuredevops, rakulang, raku
Published: 2019-10-22 20:55:32

---
title: Sparrow6 plugin to run/wait azure devops builds programmatically
published: true
description: How to programmatically manage Azure devops builds
tags: devops, azuredevops, rakulang, Raku, 
---

[Ado-pipeline-build](https://github.com/melezhik/sparrow-plugins/blob/master/ado-pipeline-build/README.md) is a handy [Sparrow6](https://github.com/melezhik/Sparrow6) plugin to manage Azure devops builds programmatically.

# Install

`s6 --install ado-pipeline-build`


# API


```perl

# queue new build
my %state = task_run "run my build", "ado-pipeline-build", %(
  name => "WebApp",
  variables => "foo=1 bar=2"
);

# wait till the my  build finishes
task_run "wait my build", "ado-pipeline-build", %(
  action => "wait",
  build_id => %state<build_id>
);

# list all builds for given build definition and current branch
task_run "last builds", "ado-pipeline-build", %(
  name => "WebApp",
  action => "list"
);
```

# Documentation

[ado-pipeline-build](https://github.com/melezhik/sparrow-plugins/blob/master/ado-pipeline-build/README.md)
Understanding JavaScript Array Series XVIII - Array.pop()
Tags: javascript, webdev, beginners
Published: 2019-10-22 20:47:06

No, we are not popping champagne or anything like that. We want to remove the last item from an array. How do we accomplish this?

There is a Javascript array method called `Array.pop()`, This method removes the last element in an array and returns that element. It leaves you with a shorter array.

**How do I write it?**
Do you mean the syntax? If so then all you have to do is append the `.pop()` method to your array like this:
```javascript
const elem = arr.pop()
```
**[arr]:** This is the array in which whose last element you want to remove.

**[elem]:** This holds the element that is removed from the array.

**Can you use show us an example of how it is being used?** Yea sure.
```javascript
const numArray = [1, 2, 3, 4, 5];
const elem = numArray.pop()

console.log(numArray) // [1, 2, 3, 4];
console.log(elem) // 5
```
As you see above, all you have to do is call the method on the array, no arguments are required. The original array is mutated.

**What if the array is empty, what happens then?** Let's try it out
```javascript
const emptyArray = [];
const elem = emptyArray.pop()

console.log(elem) // undefined
```
It returns undefined because there is no element in the array.

**That's cool and simple, but what if I want to remove the first element of an array?**
  Well, you'll have to wait till tomorrow to find out, follow me here [nedyudombat](https://dev.to/nedyudombat) to get notified when I reveal the answer tomorrow. For now, just practise more on using the `Array.pop()` to remove elements from the end of an array.

That's all for today, See you next time!!! 😆 😁

Thank you for reading. 👍
I need to serve files from grapghql, is it possible?
Tags: graphql
Published: 2019-10-22 20:45:52

---
title: I need to serve files from grapghql, is it possible?
published: true
description: 
tags: Discuss, graphql 
---

So the need is to allow files to be a payload from the grapghql server. The current setup is the server is running express which is responsible for auth and grapghql. 

The team in charge is wanting to avoid modifying express to allow rest endpoints and lock it down to just the graphql server. 

So since we don’t have an easy option to add a rest endpoint to serve the files (large PDFs), I feel as though grapghql should have a way to serve files via the web sockets. 

Can anyone give me direction in this?
How to build your own cryptocurrency exchange with python
Tags: python, blockchain, bitcoin, ethereum
Published: 2019-10-22 20:40:52

https://youtu.be/S2GxvwhjOrA


People complain about bitcoin being slow and high transfer fees. To solve all of these problems, lightning network is being developed, but a successful and straightforward solution was not produced, maybe it will never be found. 

By using what I have described in this tutorial, you can make a real-time and free of charge crypto money transfer possible. All you have to do is move transactions off-chain. 

There is a detailed description of off chain transactions on bitcoin's official information page. As a trusted third party, it is possible to create wallets or payment services that could be worth millions of dollars. I can't believe that people still haven't stepped foot on this. But they are not able to engage in such activity because they do not know BitCoin's infrastructure described in this tutorial. Here is the full link to this tutorial : https://en.bitcoin.it/wiki/Off-Chain_... aiming to explain the basics of crypto money, enabling you to develop services. 

When the internet was discovered, everyone had purchased all the valuable domains, with the dream that they would sell them for a lot of money in the future. 

Those who held these domains for a very long time, actually made money, but those who really earned money and became billionaires with the discovery of the internet are designers of internet sites and programmers of websites. 


When you buy this training and build something using crypto money infrastructure, you'll have achieved a much more valuable thing than keeping crypto money in your hands.
From 0 to 100 within seconds in dynamic rendering of Vue Components
Tags: vue, javascript, todayilearned
Published: 2019-10-22 20:33:26

# Straight to the point like fast and furious

![](https://media1.giphy.com/media/wz1FgPibXAJWg/giphy.gif?cid=790b76112e1ede6106f28b9ed12c1ca71c68d5d9892e0500&rid=giphy.gif)
I've been working on a project where there was a need to render Vue components programmatically, which is the hard way 😅, even passing props.

So I will quickly show you how to do this.

So let's suppose we have a component called **Card**, which gets its **title** via **props**
```javascript
import Card from 'Card.vue'
import Vue from 'vue'
let ComponentClass = Vue.extend(Card)
let instance = new ComponentClass({
    propsData: {
        title: 'My Title'
    }
})
instance.$mount() 
this.$refs.container.appendChild(instance.$el)
```
  
First of all, `$refs` is the most recommended way to get a **DOM** element referenced in Vue.

 You need to specify an attribute on the **DOM** element you want to reference (`<div ref="container"> </div>` in our case), and then that element is available in the **key** defined in the `$refs` property of the component. 

Finally, to get the native **DOM** element reference from an instance of the Vue component, you can use the `$el` property.

  
From 0 to 100 within seconds in dynamic rendering like a *Dodge Charger*, anything I am available in the comments, for today that's my consecrated 🍻

![](https://media.giphy.com/media/yoGQO4ZI5FnbO/giphy.gif)
About .Net Backend-developer's Skill and Knowledge
Published: 2019-10-22 20:07:36

Hello,

What expectation of knowledge and skill as a .Net backend-developer should you enable to handle?

My reflectation is:

*Entity framework .net / EF Core
*Threads
*LINQ
*Object based programming
*Visual Studio XXXX / Visual Studio Code
*ASP.NET MVC / ASP.NET Core / ASP.NET WebAPI
*Azure
*SQL Server
*C#

What more from the list is missing?

What more knowledge is needed that is not only .net development?

Thank you!
Acknowledging a World Designed for Men
Tags: discuss, watercooler, womenintech, healthydebate
Published: 2019-10-22 19:57:36

I've just ordered "Invisible Women: Exposing Data Bias in a World Designed for Men". I haven't read it yet (obviously), so here's a summary I found:

  > Imagine a world where your phone is too big for your hand, where your doctor prescribes a drug that is wrong for your body, where in a car accident you are 47% more likely to be seriously injured, where every week the countless hours of work you do are not recognised or valued.

  > If any of this sounds familiar, chances are that you're a woman.

For example, did you know that women are more at risk in case of heart attack because they show different symptoms from the classic "left arm pain", and are therefore sent home by the doctor with the only prescription of "resting a bit"?

We work in a sector that is dominated by men, we all know it, and the causes are probably a mix of natural predisposition (to be clear: I'm NOT saying that males are in any way better or more successful; I mean that males _may be generally more inclined to be interested_ in coding - and to be honest I'm not even sure of this) and a bunch of toxic practices that for the sake of simplicity I'll call gatekeeping.

It's not difficult to come across issues around bias in data (starting from what is collected and how) and in algorithms (think all those AI algorithms that end up reinforcing the dominant narrative). It's even easier to come across huge issues in recruiting.

I may be naïve, but up until now I thought all these were solvable problems, and that someday hopefully soon we would all be living in a more equal, fair world.

But not all is up to the hiring manager. Seeing for the first time how _the whole world_ is basically designed to be unfit for women is shocking.

Reading a book is not a lot of work, and it may not do much to change my own biases, but understanding how deeply these issues affect half of our population is a first step towards a better self and a better future.

Our impact goes way beyond the code we write, and I'm wondering: what can we do as a community, and what can I do as a developer/freelancer/employee to not only passively support those in non-privileged positions, but to actively make an impact? I'm looking for concrete actions here.

Ps: I understand this post is concerned with only one part of the problem and it oversimplifies it in the "male vs. female" narrative. I'm aware we should also be talking about races, other genders, sexual orientations, disabilities, etc. But this book, which sparked my post, is specifically about the impact of a male-dominated society on female-body-bearers so to say. Do feel free to expand the discussion in the comments though!
Using Hook inside initialize state function() in useReducer() Hook
Tags: react, javascript, reacthooks
Published: 2019-10-22 19:55:46

So I had this issue with using `Hook` inside `Initialize Function` of react `useReducer Hook`, as a third argument to it.

And the problem is that I was getting 

[](https://www.notion.so/0ed4f6238f81452fb2363a9f62e98b68#138bf08975fa4730b3bbd356f8f3b903)

```error
    Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function.
```

The problem is that i was using Hook inside of `Initialize` function of `useReducer Hook`

And it took me a while to find where I was getting this from.

As a solution I tried to pass that hook value that Im trying to get inside of  `Initialize` function directly from the `functional component` where I use the `useReducer` hook but it turns out that `init` function only accepts only one argument so that was a bummer 🙃 .

My simple and time saving solution was just to get rid of the `init function` and set try to determine initial state directly in my `functional component` and that worked just fine

Before
```javascript
    export const InitState = (initialState) => {
      const hookMeUp = useMyHook(); // <- PROBLEM
    
      return {
        ...initialState,
      yyy: hookMeUp.yyy,
      };
    };
    
    export const FunComp = ()=>{
    const initialState = {
        xxx: 1,
    		yyy: 2,
      };
    
    const [state, dispatch] = React.useReducer(MyReducerFun, initialState, InitState);
    
    ...aaand so onnn...
    }
   ``` 
    

After
```javascript
    export const FunComp = ()=>{
    
    const hookMeUp = useMyHook();
    ****
    const xxx =  hookMeUp.xxx;
    const yyy =  hookMeUp.yyy;
    
    
    const initialState: MyStateType = {
    xxx,
    yyy
      };
    
      React.useEffect(() => {
        const onResizeCallBack = () => dispatch({ type: "onResize" });
        window.addEventListener("resize", onResizeCallBack);
        return () => window.removeEventListener("resize", onResizeCallBack);
      });
    
      const [state, dispatch] = React.useReducer(MyReducerFun, initialState);
    
    ...aaand so onnn...
    }
```
    

links:
- [https://reactjs.org/docs/hooks-reference.html](https://reactjs.org/docs/hooks-reference.html)
What is your favorite editor and why?
Tags: discuss
Published: 2019-10-22 19:50:49

I used to use TextMate, but switched to Sublime Text when they stopped supporting TextMate 1 (many years ago), and have gotten really fast with Sublime.

Recently though I've played around with VS Code and really like it (because of how customizable it is), but I still find myself opening Sublime more.

So: without starting any editor "wars", I was just curious: **what is your favorite editor right now and why?**

If you'd like to give more context, I'd also love to know: *What is your favorite plugin/extension for that editor?*

For Sublime, one fun one is "Emoji" (so you can insert emojis with just a few keystrokes): https://packagecontrol.io/packages/Emoji

And for VS Code, an underrated one I think is "Custom CSS", which lets you fully customize the VSCode experience by writing custom css: https://github.com/be5invis/vscode-custom-css
Storybook Storyshots with NextJS, Typescript, and Jest
Tags: react, hacktoberfest, testing, typescript
Published: 2019-10-22 19:48:44

Hi everyone, 

I had an issue while I was looking for a way to use storybook storyshots.

Can someone take a look?

More details on the GitHub issue: [https://github.com/hugos29dev/the-Project-Alpha/issues/31](https://github.com/hugos29dev/the-Project-Alpha/issues/31)

{% github https://github.com/hugos29dev/the-Project-Alpha/issues/31 %}

{% twitter 1186728121057402882 %}

Bye, 
Hugo