teleren/devto huggingface dataset:
Rust Style Expressions in Other Programming Languages
Tags: rust, javascript, functional
Published: 2021-06-02 17:10:10

<!-- title: Rust Style Expressions in Other Programming Languages -->
<!-- author: Nimai Patel -->

Lets say we have a variable `animal` and we want to initiate the value of a variable `sound` based on the value of `animal`. In JavaScript, we could do something like this:

```
let sound;
if (animal === 'dog') {
    sound = 'barks';
} else if (animal === 'cat') {
    sound = 'meows';
}
```

While this solution works as expected, if you're obsessed with functional programming like I am, the use of `let` in a codebase that otherwise adheres to FP concepts as much as possible might bother you.

The immutable solution in this case is actually pretty simple though. We can just use a ternary operator in the assignment for `sound`

```
const sound = animal === 'dog' ? 'barks' : 'meows'
```

Well, this kinda works. The problem is that `sound` is assigned `'meows'` as long `animal` isn't `'dog'`. So even if `animal` was `'pig'`, `sound` would be assigned `'meows'`! Also, what do we do if we have more than two types of animals? We could start nesting ternary operators, but that would get ugly quickly!

Now the Rust programming language has a syntactically clean solution to this problem.

```
/* variables are immutable by default in Rust */
let sound = {
    if animal == "dog" {
        "barks"
    } else if animal == "cat" {
        "meows"
    } else if animal == "pig" {
        "oinks"
    } else {
        "not valid animal"
    }
}
```

Expressions inside braces in Rust can evaluate to values. This means you can use control flow key words like if-else statements and loops during the assignment of variables.

Now how do we go about doing something similar in other programming languages like JavaScript? Well, we can use anonymous functions and immediately call them on assignment.

```
const sound = (() => {
    if (animal === "dog") {
        return "barks"
    } else if (animal === "cat") {
        return "meows"
    } else if (animal === "pig") {
        return "oinks"
    }
})()
```

Great! And it doesn't look that bad either, no?
Git 
Published: 2021-06-02 17:03:11

Directory->Folder
CLI->Command Line Inteface
cd->change directory
Repository->Project,or the folder

-> clone
-> add
-> commit
-> push
-> pull

README.md(md: mark down)

git add .
git status
git commit

SSH Keys :
To push code, you need to prove that you are the owner of the github account.
Connect local machine to github using SSH keys


ssh-keygen -t rsa -b 4096 -C "emailId"

testkey.pub-> public key (put on github)
testkey->privatekey

cat[Unix: that reads files sequentially, writing them to standard output] -> type[windows]

Add your SSH private key to the ssh-agent
Adding your SSH public key to the github

Github Workflow:
write code -> Commit changes -> make a pull request

Local Git Workflow:
write code -> stage changes(git add) -> commit changes(git commit) -> push changes (git push) -> make a pull request

git remote rm origin
git remote add origin git@github.com:username/myapp.git

Git Branching:
git branch  (list of all branches)
git checkout -b 'newBranchName'
git checkout BranchName  

git diff (compares two branches and shows lines which have been changed, before merge)
git merge branchName

Undoing:

Undo staging: after git add-> git reset
Undo commit: after git commit-> git reset HEAD~1
Completely remove: git reset --hard commitHash

git log

Forking:
Fork others repo, to have complete control over the code. 

//////////////////////////////////////////////////
git init
git add .
git commit -m "Initial Commit"
git remote add origin [url]
git push -u origin master
Mongoose deep populate
Tags: mongodb, mongoose, node, javascript
Published: 2021-06-02 16:58:59

Sometimes you want to populate more than one level deep a schema using mongoose. i will share with you today how i use pure mongoose **populate** method to access more than one level deep data relation.

Suppose you have a *User* model that has many Posts and each post has Category.

Here we are going to retrieve a user with all posts that are not deleted with the category name and description populated.

# Models
```javascript
import * as mongoose from 'mongoose';
import { Schema } from 'mongoose';

// Category schema
export const categorySchema = new Schema({
    categoryName: {type: String, unique: true},
    description: {type: String},
    isDeleted: {type: Boolean, default: false}
}, {timestamps: true});

// Post schema
const postSchema = new Schema({
    title: { type: String },
    description: { type: String },
    category: { type: Schema.Types.ObjectId, ref: "Category"},
    isDeleted: { type: Boolean, default: false }
});

// User schema
const userSchema = new Schema({
    username: { type: String, unique: true },
    email: { type: String, unique: true },
    posts: [
     { type: Schema.Types.ObjectId, ref: "Post" }
    ]
});

export const Category = mongoose.model('Category', categorySchema);
export const Post = mongoose.model('Post', postSchema);
export const User = mongoose.model('User', userSchema);
```

# Query
```javascript
// Query to get all posts with the category 
const userWithPosts = await User.findById(id).populate({
   path: 'posts',
   model: Post,
   match: { isDeleted: false },
   populate: {
      path: 'category',
      model: Category,
      select: "categoryName description"
   }
}).exec();

```

# Thanks
CSS Tip: What is Scroll Chaining?
Tags: css, html, javascript, react
Published: 2021-06-02 16:58:56

Did you ever experienced this behaviour when the parent container starts scrolling once the child scroller reached its full extent .

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i98jqe4h6vjmic5vlefk.gif)

If you're a victim of this problem anytime than you might have used CSS property `overflow-y: hidden` on the parent container or might have used `position: fixed`

You don't need to use such hacks anymore. There is a CSS property to control such overflow effects. Just apply `overscroll-behavior` on the body to prevent it from happening anywhere.

```body {
  overscroll-behavior: contain; /* or "none" */
}```

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/id4glvleu9xvr5c6t234.png)
 
 Demo- https://codepen.io/jyotishman/pen/yLMKvWX


For more such content, follow me on twitter - 
username- frontend_jsx
 

{% twitter 1400091419675480068 %}
June 2021 Releases – Horizon 28.0.0, Meridians 2021.1.1, 2020.1.9, 2019.1.20, 2018.1.29
Tags: news, dscp, horizon, jdk11
Published: 2021-06-07 15:26:10

---
title: June 2021 Releases – Horizon 28.0.0, Meridians 2021.1.1, 2020.1.9, 2019.1.20, 2018.1.29
published: true
cover_image: https://pbs.twimg.com/media/E25p_4iWYAQ6sJx?format=jpg&name=large
date: 2021-06-02 16:49:36 UTC
tags: News,dscp,Horizon,jdk11
canonical_url: https://www.opennms.com/en/blog/2021-06-02-june-2021-releases-horizon-28-0-0-meridians-2021-1-1-2020-1-9-2019-1-20-2018-1-29/?utm_source=rss&utm_medium=rss&utm_campaign=june-2021-releases-horizon-28-0-0-meridians-2021-1-1-2020-1-9-2019-1-20-2018-1-29
---

In June, we released updates to all OpenNMS Meridian versions under active support, and released the first iteration of OpenNMS Horizon 28.

### Horizon 28.0.0

Release 28.0.0 is the first in the Horizon 28 series, introducing a requirement of Java 11, enhancements to flow aggregation to support DSCP ToS/QoS, and more.

The codename for Horizon 28.0.0 is [_Jazz_](https://en.wikipedia.org/wiki/Jazz_(Transformers)).

For an overview of changes in OpenNMS Horizon 28, see [_What's New in OpenNMS Horizon 28_](https://docs.opennms.com/horizon/28.0.0/releasenotes/whatsnew.html)

### Meridian Point Releases

All Meridian releases this month contained just a few small bug fixes and enhancements. As always, it is strongly recommended that you update to the latest release.

For a list of changes, see the release notes:

- [2018.1.28](https://meridian.opennms.com/releasenotes/2018/latest/#releasenotes-changelog-Meridian-2018.1.29) ([_Asteroid Impact_](https://wikipedia.org/wiki/Impact_event))
- [2019.1.20](https://meridian.opennms.com/releasenotes/2019/latest/#releasenotes-changelog-Meridian-2019.1.20) ([_Barajeel_](https://wikipedia.org/wiki/HIP_79431_b))
- [2020.1.9](https://meridian.opennms.com/releasenotes/2020/latest/#releasenotes-changelog-Meridian-2020.1.9) ([_Wave-Cut Platform_](https://wikipedia.org/wiki/Wave-cut_platform))
- [2021.1.1](https://docs.opennms.com/meridian/2021.1.1/releasenotes/changelog.html#releasenotes-changelog-Meridian-2021.1.1) ([_ACE_](https://wikipedia.org/wiki/Advanced_Composition_Explorer))
Ruby Instance Methods
Tags: ruby
Published: 2021-06-02 16:38:42

##Introduction 
Below is some instances method in Ruby might help you easily solving the issue. 

##.flatten()

<code>.flatten()</code> is method will return a new array that flattening of itself and it also taking argument to determine the level of recursion to flatten.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/964hrh02c7dveo1344hu.PNG)

##.reverse()

<code>.reverse()</code> method will return a new array containing self's elements in reverse order.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l0gow25cvaee40llrnv5.PNG)


##.rotate()
<code>.rotate()</code> method will rotate first element of self and return by new array and it also taking argument to determine how many element need to rotate, if passing negative argument like (-1) then it will rotate in opposite direction

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/thj9g2akuq8zqrugykf9.PNG)

###.insert() 

<code>.insert()</code> method is taking at least two argument, first argument is index of array, and second argument is value that you are going to insert, if using negative index will insert the value at the end of array 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqsq8avnbpv8o1r8o3jy.PNG)

*References:*
[API DOCK](https://apidock.com/)
No, Tailwind Doesn't Suck | Podcast
Tags: css, tailwindcss, podcast
Published: 2021-06-02 16:14:27

{% spotify spotify:episode:4QGhQYWI5yD1QAqz6sVPpW %}

## What is HTML All The Things

HTML All The Things is a [web development podcast](https://podcast.htmlallthethings.com/) and [discord community](https://discord.com/invite/jweMCx9) which was started by Matt and Mike, developers based in Ontario, Canada. 

The podcast speaks to web development topics as well as running a small business, self-employment, and time management. You can join them for both their successes and their struggles as they try to manage to expand their Web Development business without stretching themselves too thin. 

## What's This One About?

In this episode Matt and Mike discuss all things Tailwind including [TailwindCSS](https://tailwindcss.com/), [TailwindUI](https://tailwindui.com/), and [Tailwind headless components](https://headlessui.dev/). The duo also discusses the minor "controversy" amongst the community (if you'd even call it that), about whether Tailwind is a good tool to use as it can make markup a bit messy looking, among other things. If you've ever wondered about using Tailwind then this is the episode for you!

## Show Notes
1:45 - What is TailwindCSS?

###Why Use Tailwind?
5:55 - Speed
9:50 - Theming
19:19 - Standarization
21:10 - Community
28:13 - Responsiveness 

###Arugments against TailwindCSS
31:18 - Makes for ugly HTML
40:30 - Prevents people from learning CSS
42:30 - Doesn't support shadow DOM
44:28 - Needs compiling
46:30 - Large CSS size



##Key Takeaways
* TailWindCSS makes prototyping and building UI's a lot more streamlined. The ability to use simplified CSS in line removes the need to jump between files. 
* Most of the arguments against TailwindCSS are either preference based or outright wrong. 


##Social Links

You can find us on all the podcast platforms out there as well as

[Instagram (@htmlallthethings)](https://www.instagram.com/htmlallthethings/)
[Twitter (@htmleverything)](https://twitter.com/htmleverything)
[Facebook (Html All The Things)](https://www.facebook.com/htmlallthethings)
[Tiktok (htmlallthethings)](https://www.tiktok.com/@htmlallthethings?lang=en)
Was ist ein WordPress Child Theme, und wann brauche ich es?
Tags: wordpress, code, functionsphp, wordpressthemes
Published: 2021-06-06 12:48:35

---
title: Was ist ein WordPress Child Theme, und wann brauche ich es?
published: true
date: 2021-06-02 16:13:44 UTC
tags: Wordpress,code,functionsphp,WordPressThemes
canonical_url: https://bloggerpilot.com/wordpress-child-theme/
---

![WordPress Child Theme](https://bloggerpilot.com/wp-content/uploads/2021/05/child-theme.png)

Was ist ein WordPress Child Theme? Wenn du schon länger in der WordPress Welt unterwegs …

[Was ist ein WordPress Child Theme?](https://bloggerpilot.com/wordpress-child-theme/)
Course Launch: Competitive Programming - Crack Your Coding Interview
Tags: career, programming, computerscience
Published: 2021-06-02 15:53:05

Coding interviews. Code-a-thons. Coding challenges. What do they all have in common?

You’re required to solve difficult problems under pressure. Doing this well takes practice. Lots of practice and placing yourself in somewhat uncomfortable situations.

Imagine your CTO reaching out to you about an urgent bug. You have to roll up your sleeves and solve the problem quickly.

Trust me, it happens.

That’s where experience comes in, and it’s like the old saying goes, "practice makes perfect." So today I'm excited to share a new course that will help you crush your next interview or coding challenge.

[Competitive Programming - Crack Your Coding Interview](https://www.educative.io/courses/competitive-programming-intvw?aff=xg3L)

In this course, you will hone your problem-solving skills - one of the biggest assets a software engineer has.

You will solve some of the most frequently asked questions that are brought up in FAANG interviews. You will start with the concepts of Number Theory and Divide & Conquer, then you’ll move towards more complex problems like dynamic programming and graph theory.

With each problem you solve, there will be insightful explanations and full implementation details to really hammer home the concepts. By the time you finish this course, you will have the confidence to solve any problem, no matter the difficulty.
Pug Cheat Sheet
Tags: pug, cheatsheet, programming
Published: 2021-06-02 16:00:48


### [Mixins] Mixin blocks

```jade
mixin article(title)
  article
    h2.title= title
    block
```
{: data-line="1,4"}

```jade
+article('hello there')
  p Content goes here
```

See: [Mixin blocks](https://pugjs.org/language/mixins.html#mixin-blocks)
### [Mixins] Mixin attributes

```jade
mixin pet(name)
  span.pet= name
```
{: data-line="1"}

```jade
+pet('cat')
```

See: [Mixin attributes](https://pugjs.org/language/mixins.html#mixin-attributes)

### [Mixins] Mixins

```jade
mixin list
  ul
    ···
```
{: data-line="1"}

```jade
+list
```

Mixins allow you to create reusable code blocks.
See: [Mixins](https://pugjs.org/language/mixins.html)

### Mixins
{: .-three-column}

### [Pug] Conditionals

```jade
if authenticated
  a(href='/logout') Sign out
else
  a(href='/login') Sign in
```
{: data-line="1,3"}

See: [Conditionals](https://pugjs.org/language/conditionals.html)

### [Pug] Multiline text

```jade
p.
  This is text that doesn't need to
  be prefixed by pipes.
```
{: data-line="1"}

```jade
script.
  // It's great for raw
  // JavaScript and stuff
  alert('hello')
```
{: data-line="1"}

### [Pug] Includes (partials)

```jade
include ./includes/head.pug
```

```jade
include:markdown article.md
```

See: [Includes](https://pugjs.org/language/includes.html)

### [Pug] Layouts

```jade
//- page.pug
extends layout.pug

block title
  | hello

block content
  | hello
```

```jade
//- layout.pug
title
  block title
body
  block content
```

### [Pug] Iteration

```jade
ul
  each user in users
    li= user
```

### [Pug] Comments

```jade
// This comment will appear in the HTML
```

```jade
//- This is a silent comment
```

```jade
//-
  Nesting inside a comment creates
  a comment block
```

See: [Comments](https://pugjs.org/language/attributes.html)

### Reference
* [Pug Cheat Sheet](https://cheatsheetmaker.com/pug) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Golang Cheat Sheet
Tags: go, cheatsheet, programming
Published: 2021-06-02 15:59:51


### Files Embedding
```
package main

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

// content holds the static content (2 files) or the web server.
//go:embed a.txt b.txt
var content embed.FS

func main() {
	http.Handle("/", http.FileServer(http.FS(content)))
	log.Fatal(http.ListenAndServe(":8080", nil))
}
```
### HTTP Server
```
package main

import (
    "fmt"
    "net/http"
)

// define a type for the response
type Hello struct{}

// let that type implement the ServeHTTP method (defined in interface http.Handler)
func (h Hello) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, "Hello!")
}

func main() {
    var h Hello
    http.ListenAndServe("localhost:4000", h)
}

// Here's the method signature of http.ServeHTTP:
// type Handler interface {
//     ServeHTTP(w http.ResponseWriter, r *http.Request)
// }
```
### Reference
* [Golang Cheat Sheet](https://cheatsheetmaker.com/golang) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Let's talk about CSS [Easy Roadmap]
Tags: css, html, beginners
Published: 2021-06-02 15:48:31

For most people like me, CSS was the bane of my existence. It never listens to me when I give it simple instructions and it acts as if it has a mind of its own, relatable right ?. However, CSS acting the way it did was because I didn't understand it back then.

Understanding how layouts and hierarchy works in CSS is the key to mastering the styling language and that is why I have prepared an easy roadmap for mastering CSS

Let's get straight to it...

# **1) Syntax**

Just like every other language out there, you have to master the CSS syntax to be able to confidently write it. 

To master this, you will have to understand basic core CSS principles.

You can find more info on specificity [here](https://www.tutorialrepublic.com/css-tutorial/css-syntax.php)

# **2) Hierarchy**

Hierarchy is important in CSS. Understanding how the *Parent-Child* hierarchy works in CSS helps you write better CSS code.

This idea of CSS having a hierarchy and how it organizes and accesses elements is known as **Specificity**

You can find more info on specificity [here](https://www.w3.org/Style/CSS/read.en.html)

# **3) Layout**

Know your CSS Layouts!, this is very crucial to understanding how to position elements on a webpage.

This is by far the most difficult part of learning CSS and here are some links I have prepared to help you find great resources on CSS Layouts

* [CSS Layouts](https://www.w3schools.com/css/css_website_layout.asp)
* [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)
* [CSS Grids](https://www.w3schools.com/css/css_grid.asp)
* [Positioning](https://www.w3schools.com/css/css_positioning.asp)

Creating great layouts is your key to mastering CSS, learn it vigorously and you won't struggle with positioning in CSS. 

# **Conclusion**

Thank you for reading 🔥🔥🔥, and I hope you found this article useful 🔥

If you enjoyed reading, please consider following me here on Dev.to and also on Twitter @ [heyOnuoha](https://twitter.com/heyOnuoha/) so you don’t miss out on new content on topics like:

* Web Development (JS and Python)
* Improving as a developer
* Machine Learning

#### **Support Me** :
👉 Follow Me on [Twitter](https://twitter.com/heyOnuoha/)
👉 Buy me a ☕
<a href="https://www.buymeacoffee.com/heyOnuoha" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
Time to be me
Tags: mentalhealth, personal
Published: 2021-06-02 15:48:02

---
title: Time to be me
published: true
description: Be yourself, you can't be anyone else.
tags: mentalhealth, personal
cover_image: https://raw.githubusercontent.com/StacyCash/blog-posts/main/general/time-to-be-me/cover-image.jpeg
---

In a recent post I mentioned that I have PTSD, an Anxiety disorder and suffer from Depressive Mood Syndrome.

To try and overcome these, and to work on living with them, I've been in therapy for a while.

Last week we were covering the abject nightmare (for me) that is meeting with other people. The stress from beforehand. The stress during, and the stress after.

I'm a geek. I have passions that other people find childish, pointless, weird, a waste of time.

* I love computers, and playing/experimenting with them
* I love Doctor Who
* I love 50s Swing style and spend most of my days looking like I'm going to a prom
* Whilst I don't love scary movies, I love creepy outfits and several of my swing dresses have halloween vibes
* I love Lego!
* l love streaming my Lego building on my (OTT) computer setup, whilst wearing swing dresses... 😛

What I don't love are the constant comments from people who don't love these things telling me that I'm wasting my time doing pointless things, that they find what I like boring, or childish and to remember how old I am.

In one of exercises we were walking through how I experience family gatherings. I reached the point of the conversations and how I experience them. How I wish I could answer all the criticism

> Well it works for me and makes me happy.

And at that point I was reminded of a quote attributed to John Barrowman (Captain Jack of Doctor Who fame)

> "Never apologize for being nerdy, because unnerdy people will never apologize for being assholes."

I hope I can live up to that. I love my hobbies and interests. They  make me happy.

Be yourself. You're worth it.

> I may not be perfect, but I'm fine as I am
LaTeX: Cross Referencing
Tags: latex, codenewbie
Published: 2021-06-02 15:43:22

Hello :) How are you today? 

In my [last post](https://dev.to/latexteada/latex-crossing-referencing-the-idea-16fh) I told you a situation where you can use cross referencing, and, I told you some commands.

In this post I am going to tell you about cross referencing and some stuff related with that. Let's go !! :) 

# What is *Cross Referencing*?

Cross referencing is a tool which can be used to reference an element without having to remember properties of the element. 

> Cross referencing is *dynamic* in LaTeX, this means, the reference actualizes itself automatically, you do not need to be worrying about it 

# What can I refer in my document? 

Well you can refer each single thing that we have checked until now, this is: Sections, Figures, Tables, Pages, etc. 

- Until now we have checked that, but, in a future we are going to talk about formulas and math in LaTeX, and, of course, you can refer to equations too :) 

# Labeling the elements

We need to *label* the element, this will allow us to refer the element. We label the element with 
```LaTeX
\label{myLabel}
```

Where *myLabel* is the name which we need to use to refer to that element

But, wait!!! I can refer many things, how can I distinguish between all those elements without writing long names to my labels? Well...

## Referencing conventions 

These are not officials, but these are very helpful  

- `ch:` Chapter
- `sec:` Section 
- `subsec:` Subsection
- `subsubsec:` Subsubsection
- `fig:` Figure
- `tbl:` Table

So if we want to label the Chapter *First* and our Figure *White*

```LaTeX
\label{ch: First}
\label{fig: White}
```

## Yes, but where?

Ok, ok we have learned the `\label{something}` command and we can refer to everything, but

> Where can I put the `label` command?

At the beginning? middle? top? or, maybe, at the bottom? 

- In `section`, `subsection`, `subsubsection` can be after the command or below

```LaTeX
\section{My Section}
\label{sec: My Section}

or

\section{My Section}\label{sec: My Section}
```

- In [table](https://dev.to/latexteada/latex-tables-the-tabular-environment-4f0a) or [figure](https://dev.to/latexteada/latex-figures-the-figure-environment-5a75) it is right after `\caption{}`

This is all for today, thank you :)

Do not forget to follow me on twitter `@latexteada`