teleren/devto huggingface dataset:
Regex Search in VSCode
Tags: vscode, regex
Published: 2019-08-20 02:16:02

---
title: Regex Search in VSCode
published: true
tags: vscode, regex,
canonical_url: https://stephencharlesweiss.com/blog/2019-08-15/regex-search-vscode/
---

Finding all instances of an imported module in a large app can be challenging.

With the namespace for a module being restricted to the file, searching for a specific name can often lead you astray. The same name can be used for wildly different purposes across the app.

Furthermore, even if you what you’re looking for is only instances where a module has been imported, due to destructuring and the possibility of multiple imports from that resource, the results can be overwhelming to search through.

Take for instance my search for all instances where I imported `Input` from a library, `repaint`.

Searching for just Input I had ~1,500 results. ![](./input-reseults-1500.png)

I could narrow that a bit by searching to for `repaint`, but I still had 300+ results in 250+ files. [![regex results 19](https://stephencharlesweiss.com/static/d415003108f8a3b7a0705d850d5fafaf/2b4b2/regex-results-19.png)](/static/d415003108f8a3b7a0705d850d5fafaf/2b4b2/regex-results-19.png)

This is where Regex really shines. I know the module being imported and the library’s name, but because the pattern of import can change so much, finding them can be hard if I’m looking for an exact match.

I’m no expert, but after a few minutes with some resources I found the pattern I needed: `input(.*)repaint`.<sup>1</sup>

The pattern is specifying a very simple pattern: the strings `input` and `repaint` separated by any characters. Even this generic, basic pattern cut my results from hundreds or thousands … to 19. That’s efficiency. [![repaint results 323](https://stephencharlesweiss.com/static/3ba208202a57062cc98a252fbd708bee/4a15f/repaint-results-323.png)](/static/3ba208202a57062cc98a252fbd708bee/4a15f/repaint-results-323.png)

NB: The Regex option needs to be turned on for this to work (select the `.*` icon or use the keyboard shortcut `⌥⌘R`)

# <svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Resources

- <sup>1</sup> [Regex: Everything You Need To Know | CodePicky](https://www.codepicky.com/regex/)
Selectors in Redux
Tags: redux, explainlikeimfive
Published: 2019-08-14 23:33:50

The concept of selectors in Redux enables retrieval of derived properies from you state. A **selector** is a function that takes the state as arguement and returns a substate or derived properties of it. It can be that they only return a substate of your global state or that they already preprocess your state to return derived properties. The function can take optional argument to support the selection of the derived properties. 

## Plain Selectors

Selectors usually follow the same syntax. The mandatory argument of a selector is the state from where it has to select from. There can be optional arguments that are in a supportive role to select the substate or the derived properties.

    state => derived properties
    (state, arguments) => derived properties

Selectors are optional, and whenever you think of Redux, actions, reducers and the store itself are mandatory - Action Creators are optional likewise - Selectors simplify developer's experience.

    function mapStateToProps(state) {
    	return {
    		windows: state.windows,
    	}
    }

To do this substate retrieval implicitly via **selector**

    function getWindows(state) {
    	return state.windows;
    }
    function maStateToProps(state) {
    	return {
    		windows: getWindows(state)
    	}
    }

It is similar to the action and reducer concepts. Instead of manipulating the state directly in the Redux store, you will use action and reducer to alter it indirectly. The same applies for selectors that don't retrieve the derived properties directly but indirectly from the global state.

It is an advantage, if not to think about it too much. A selector is a pure function, hence it can be reused, tested - derived properties may be required elsewhere in an application. 

Moreover, they may not be as trivial, as in the example above - they may utilize one of the normalizer libraries, of which I sort scribbled a little previously. Therefore it may potentially unload `mapStateToProps()` from excessive complexity.
Pushing Left, Like a Boss — Part 5.8 — Securing Your Cookies
Tags: programming, tutorial, beginners, security
Published: 2019-08-14 22:03:58

---
title: Pushing Left, Like a Boss — Part 5.8 — Securing Your Cookies
published: true
description: The 5th section of this series details various examples of secure coding.
series: Pushing Left Like a Boss
tags: programming, tutorial, beginners, security
---
###This series, and my blog, have moved! [Check it out](https://wehackpurple.com/g8tg)!

The previous article in this series is 5.7 URL Parameters.

Continuing on our long trek through secure coding principles we have come to the topic of cookies, which are used for sending information back and forth from the client and server.

In order to secure the decision-making and/or sensitive data that we need to pass between the client and the server, we need to put in a secure cookie. Secure cookies are **encrypted**, not **encoded**, which means someone needs a key in order to decrypt them, to change or reveal the information that they contain. In the case of secure cookies, that key is stored on the server (a secure location). Anything that is sensitive, used for decision-making within your application, or is otherwise inappropriate to put in a URL parameter or a hidden field, should be passed in a secure cookie.

![My friend Imran A Mohammed and I, #Null Singapore 2019](https://thepracticaldev.s3.amazonaws.com/i/jxa7igg27hx45nz1l3qp.jpeg "My friend Imran A Mohammed and I, #Null Singapore 2019")


###[Read the rest on my NEW blog!](https://wehackpurple.com/wehy)!
Micromanaging, trust, and transparency - Letter No. 9
Tags: leadership, law
Published: 2019-08-14 21:57:12

---
title: Micromanaging, trust, and transparency - Letter No. 9
published: true
description: micromanagement isn't so much a thing you do as an experience your team feels, so here are some ideas about how to do it right
tags: leadership, law
---

Hey folks,

[Letter No. 9](https://michaelrice.substack.com/p/micromanaging-trust-transparency) hit inboxes yesterday. 

In it, I did a deep dive (for a daily letter, anyway) on how you can navigate between being a _hands on manager_ and a _micromanager_. 

And this particular letter is *free*, so give it a read, but [as promised](https://dev.to/leadlawcode/bringing-it-together-leadership-law-and-code-4c46), here's a quick summary here on dev.to!

At the outset, *of course everyone hates being micromanaged.* It destroys trust with your team, so obviously you want to stay away from it.

However, being hands on as a tech lead, engineering manager, or startup founder is inevitable and in some instances desirable. Every manager, sooner or later, will need to dive into the details, whether it's because he or she is managing a high profile project, under time pressure, or something has gone off the rails. Moreover, a lot of EMs at software companies spend a lot of their time writing code.

So the most important question is not whether you are managing details, but **how the folks on your team are reacting to your fine grained management**. "Micromanagement" is less of a process and more of a feeling by the one being micromanaged!

So, [in the letter](https://michaelrice.substack.com/p/micromanaging-trust-transparency), I suggest two approaches to minimize the micromanagement effect. First is to **check our motivations**: if you're feeling the need to control your team for a variety of reasons, that could be a red flag.

Second, **make sure you have a solid understanding of your team**. If you don't, then use this as an opportunity to gain that understanding and gain trust with your team.

Then later in the letter, I mention that--for better or worse--there's no law against micromanagement. There are, however, some really important trust issues that we need to consider as leaders at our companies. 

Without trust, your engineers can't do their best, creative work.
How to use nvm and why
Tags: tutorial, webdev, beginners, node
Published: 2019-08-14 21:03:59

---
title: How to use nvm and why
published: true
description: Introduction to node version manager
tags: tutorial, webdev, beginner, nodejs
cover_image: https://images.unsplash.com/photo-1497051788611-2c64812349fa?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2814&q=80
---

# What is nvm
Node Version Manager is... a node version manager. It allows you to easily change the node version, this comes really helpful for example when you work on multiple projects with different NodeJS versions.
![Image showing how you can change node versions using nvm in the terminal](https://thepracticaldev.s3.amazonaws.com/i/5xw6y0y2aili4a00d8mo.png)
*You can change your node version instantly with a single command - cool* :sunglasses:

---

# Installation
`curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash`
![nvm installation in the terminal](https://thepracticaldev.s3.amazonaws.com/i/o7oxzl56jnto5gljrmii.png)

After the installation is complete you should add the last three lines you see above in your shell configuration file (which means copypasting them in `~/.bash_profile` or whatever you are using). After this, you should restart your terminal to use `nvm`.

Check [this link](https://github.com/nvm-sh/nvm#installation-and-update) for the latest version and more details on how to install `nvm` on your machine (macOS and Linux).
[Based on my own experience I can't recommend using Windows for web development - But you can google "nvm windows" for a Windows-compatible implementation of nvm].

---

# Usage
First of all, install your favorite node version: `nvm install 10`. If you don't specify an exact version, nvm will download the latest version automatically.
After installing any version of NodeJS with `nvm` you can easily switch to that version by running `nvm use <version>`.

Now you're ready to go.

---

# Useful commands
 - `nvm ls` shows the node versions you installed
 - `nvm ls-remote` shows all the node versions available
 - `nvm install <version>` installs the specified version
 - `nvm uninstall <version>` works like the `install` command
 - `nvm alias default <version>` sets your default node version

---

# Tips & Tricks
![How to switch versions using nvm](https://thepracticaldev.s3.amazonaws.com/i/h05nvf8gpt7vj76zpk5c.png)
When you run `nvm install` inside a directory if you have a `.nvmrc` file, `nvm` automatically installs the version specified in the `.nvmrc` file.

This is very useful if you working on a shared project and need a specific NodeJS version.

---

Please comment if you have any suggestion or if you liked the post
hello oerwi! best counter app ever!
Tags: tallysheet, react, javascript, showdev
Published: 2019-08-14 20:43:08

Hey,

I created a little app for a colleague to count cake sale at his sport club events.

Have a look and fork if you like!

https://oerwi.app
github: https://github.com/shroomlife/oerwilist

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/mai707exuzzappa93ilr.png)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/w7h6g9149y7140jevcd1.png)

Happy for any feedback!
Day #1 - Google Map Demo
Tags: android, googlemaps
Published: 2019-08-14 20:25:00

---
title: Day #1 - Google Map Demo  
published: true
description: Tutorial Sharing Series
tags: android, googlemaps
---

Hello, I am practicing android application development every day. I will share my samples daily.

Note: There may be old techniques. The logic is the same.

- Feel free to contact me for any questions.

https://github.com/ardakazanci/GoogleMapDemo
Letting My Mind Rest: How Coding Gets Me Through Those Rough Days
Tags: mentalhealth, beginners, codenewbie, javascript
Published: 2019-08-14 20:23:52

There's a stigma around mental health. Those who suffer from it, and the topic as a whole, are not treated with the care and empathy that's deserved. 

This is why I'm here - to be open and honest about my story, help someone feel less alone, and demonstrate how coding can get me through my roughest days. 

__Ready for me to get candid?__

I was diagnosed with bipolar disorder and anxiety a few years back, and it was such a _relief_. I finally understood why I was so angry or felt on top of the world one week, to then crash so hard I couldn't even get out of bed. It explained why there was this constant weight in the pit of my stomach and always having my heart in my throat.

__TMI? Probably. Important to share? Absolutely.__

Since then, I've settled quite a bit, and have learned techniques to managing my emotions if it all gets to be too much. Sometimes it's meditating, taking a nap, or eating a PB & J; but since beginning my coding journey, I've realized that coding has also become part of my technique repo.

When I'm manic, I feel on top of the world, my head buzzing. Constant ideas bouncing around, never landing on one thing, because I can do it _all_. (_Spoiler: It's exhausting!_) But that's where beautiful, synchronous JavaScript comes into play. I can't just throw around functions or make random variables; I have to stop and think about what I need to accomplish.


##doingGreat()
```javascript
var arr = ["foo", "bar", "baz"];
var random = arr[Math.floor(Math.random() * arr.length)];

function doingGreat() {
  console.log(random);
}

doingGreat();
```
##notSoMuch()
```javascript
notSoMuch();

function notSoMuch() {
  console.log(random);
};

var arr = ["foo", "bar", "baz"];
var random = arr[Math.floor(Math.random() * arr.length)];

```

My beginning looks like this: 
1. Start to code 
2. Mind jumps a few steps ahead 
3. Write my thought down
4. Repeat

But having to think step by step is so calming. It turns my `notSoMuch()` into a `doingGreat()`. Even if my mind whirls begins again after I'm finished, I'm grateful JavaScript can give my mind a rest for that moment in time. 

(Now, that I think about it, I'm quite productive -- but I digress!)

If anyone out there is struggling with the same, I hope you get the chance to try it out; maybe you'll add this to your technique repo as well!

(Also, remember to always be kind to yourself during these times -- you'll get through it!)
10x CSS
Tags: css, codequality, codestyle, frontend
Published: 2019-08-14 19:49:24

Let's get this straight: CSS is messy. It's a beautiful language that allows web to flourish - but it can get very dirty very fast. One of the reasons is the nature of the language itself: it's resilient, it's very forgiving - and it doesn't force almost any rules on you. 

You can use tabs. You can use spaces. You can write everything in one line. You can repeat the same ruleset over and over again, each time adding one new declaration. You don't even need to have _all_ the semicolons. This is your world, you can do whatever you want.

But should you?

Unlike painting, I don't think your CSS code is a place to get crazy. 

There has been a lot of talk over the years about large-scale CSS architecture, and now we have all sorts of methodologies like BEM, SMACSS, and, my personal weapon of choice, Atomic OOBEMITSCSS. But none of them deal with the smaller scale, where most of our actual work is done.

I'm talking about single rulesets.

As said before, nothing stops you from writing declarations in any way or order you want. One might argue it doesn't matter, if it gets the job done; but as for any other language, better code style in CSS leads to better DX, better code quality, and fewer bugs. 

So, lo and behold, my personal approach to lower-scale CSS structure:

```
.classname {
    /* is this thing even visible? */
    display: block;

    /* where is it on the page? */
    position: absolute;
    top: 0;
    left: 0;
    width: 20%;
    height: 300px;

    /* what does its content look like? */
    font-family: 'Roboto', sans-serif;
    font-size: 1.2rem;
    font-weight: bold;
    font-style: italic;
    text-align: center;
    text-transform: uppercase;
    color: rebeccapurple;

    /* what's its box model? */
    padding: 10px 0;
    margin: 20px;
    border: 2px dashed salmon;
    border-radius: 5px;

    /* backgrounds, 'cause declarations tend to get so very long */
    background: url(someawesomepic.jpg) center center no-repeat;
    background-size: cover;

    /* purely a e s t h e t i c s */
    transition: all .25s;
}
```

While by no means complete, this example covers the most frequent properties one usually has to define. No matter what, some declarations stick together, because _together they make more sense_: width and height, border and border-radius, font- and text- properties, positioning properties, and so on. 

I have been following more-or-less this structure for almost a decade now, and it has made my life much easier. I only need a glance at any given ruleset to understand what's going on, what's missing, and spot some minor bugs like duplicates or declarations that will never actually be applied. 

It might seem as if I'm arguing that my system is great - and while it obviously is, what I think is the most important here is to actually _have_ one. It is hard to follow a story when it's all over the place, and it's very hard to work with code like that.

Happy coding, and gods bless.
Hidden feature on Dev.to that motivates people to stay active
Tags: growthhacking, hooked, emailmarketing
Published: 2019-08-14 18:54:41

---
title: Hidden feature on Dev.to that motivates people to stay active
published: true
description: Hidden feature
tags: growth hacking, hooked, email-marketing
cover_image: https://thepracticaldev.s3.amazonaws.com/i/q73mpzqrfimrflwvi3ky.png
---


# Emails from people following you

Ever since I joined I kept getting these emails that someone followed me, which I thought was pretty cool. It gives me a reason to stay on the platform in order to gain a small following.
It wasn't until I found out why exactly I got these emails that I thought it was awesome instead of just cool.

It is because when you visit dev.to the next people to sign on are encouraged to follow the latest active user on their website (in this case me).

# Growth hacker marketing

This is one of the tactics that Twitter used to grow their audience, namely letting people follow someone as soon as they sign up to the platform (described in the book [growth hacker marketing](https://www.amazon.com/gp/product/1591847389/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1591847389&linkCode=as2&tag=veslav-20&linkId=0ad7b61c707cc1ac96e8d143951ab5ef)).
Dev.to probably uses this tactic to make sure new users have something to read and give smaller publishers, like me, the ability to grow.
Edit XML in Scala in a FP way
Tags: scala, xml
Published: 2019-08-14 18:51:27

Hi guys , i'm new here and this in my first post!

I'm here because i'd like to share with you a small project i realized for my company due the difficulties and boilerplates found using Scala XML library's API.

I hope that someone can contribute to it.

Github: https://github.com/geirolz/advxml

Features:
- Append, Remove, Replace XML nodes
- Edit node's attributes
- Read XML handling optionality and mandatory nodes and attributes
- Convert XML into Object and viceversa
- Normalize XML
- Convert Java Document to Scala NodeSeq


Example:

```scala
import com.github.geirolz.advxml.all._
import scala.xml._
import scala.util._


//import MonadError instance for Try
import cats.instances.try_._

val doc: Elem =
<Persons>
 <Person Name="Mimmo">
  <Cars>
   <Car Brand="Fiat"/>
  </Cars>
 </Person>
</Persons>


val rule = $(_ \ "Person" \ "Cars")
 ==> Append(<Car Brand="Lamborghini"/>)
 ==> Append(<Car Brand="Ferrari"/>)
 ==> Append(<Car Brand="Bmw"/>)


val result: Try[NodeSeq] = doc.transform[Try](rule)
```


I hope this small project can help someone in desperation with Scala XML library

Let me know what you think about it :)
Authorization Series - Pt 3: Dynamic Authorization with GraphQL and Rules
Tags: authorization, identitymanagement
Published: 2019-08-14 18:08:09

---
title: Authorization Series - Pt 3: Dynamic Authorization with GraphQL and Rules
published: true
description: Build a Flask and GraphQL quidditch management system that uses Auth0 rules to implement ABAC and GBAC.
tags: #authorization #identitymanagement
canonical_url: https://auth0.com/blog/authorization-series-pt-3-dynamic-authorization-with-graphql-and-rules/
---
TL;DR: In this article we're going to demonstrate how we can use Flask to build a GraphQL API that can create and return flexible and meaningful data. First we'll setup our backend using Flask and an SQLite database. Next we'll bring in GraphQL to build an API that will allow us to interact with quidditch teams, players, and games. Finally we'll demonstrate the value this graph-based database modeling can bring to our application by testing out two different authorization models to extend permissions to players from the Auth0 dashboard.

All code for this application can be found on GitHub. If you want to jump right in, just clone the repository and follow the instructions in the README to run the application.

[Continue Reading 📖](https://auth0.com/blog/authorization-series-pt-3-dynamic-authorization-with-graphql-and-rules/?utm_source=twitter&utm_medium=sc&utm_campaign=authorization_pt3)
OpenCV and Node.js - Image processing 
Tags: node, javascript, tutorial, imageprocessing
Published: 2019-08-14 18:02:04

---
title: OpenCV and Node.js - Image processing 
published: true
description: 
tags: #node #javascript #tutorial #imageprocessing
canonical_url: https://overflowjs.com/posts/Image-Processing-OpenCV-and-Nodejs-Part-3.html
---

A new article is published on overflowjs.com around creating the image filters using Node.js and OpenCV.

The article discusses creating REST endpoint for below stuff:-

1. Smoothing Filters (Some filters and algo’s for it)

2. Thresholding Filters

3. Finding contours in the image


Read full article - https://overflowjs.com/posts/Image-Processing-OpenCV-and-Nodejs-Part-3.html on overflowjs.com


Github code link - https://github.com/overflowjs-com/image_app_opencv_api_part3

Happy coding!