teleren/devto huggingface dataset:
enchantedForest[4]
Tags: javascript
Published: 2020-07-03 00:17:36

Today (well technically last night) I dumped most of the Neovim plugins we use into the server configs. Originally I tried to keep the dotfiles on the server to a bare minimum since it had limited storage, buuuuut I decided to just screw that and install ALLLLLLL DE pLUgInS. As Genya Safin from the Grishaverse once said, 

> "I also shouldn’t have a second buttered roll with my breakfast every morning, but sometimes one must indulge."

However, I didn't feel like installing everything twice for both of our accounts, so I followed [this link](https://jdhao.github.io/2019/11/10/install_config_neovim_system_wide/) and set the configs across the system for all users. Cheers to deoplete and Ctrl-/ commenting. 

Anyways. 

In today's session, Alek and I created a Trello board to have actual task management, as our README.md at this point is about 450 lines. Found a bug on the merchant pop-up dialogue disabling movement, filed it on the Trello board, and (very unfortunately) labelled "clean up code" under the "Nice to have" category. Alek got started on adding checkpoints and portals to the tilemap using Tiled, while I worked on revamping our HUD for a more pleasant interface. 

Initially I wanted to jump back to 4 months ago and punch myself in the face for writing the monstrosity that exists in the code base, but then I realized that besides a few naming issues it honestly wasn't THAT bad. Most of the HUD migration could be done by simply moving around the html, with some JQuery portions that required minor tweaks, and then a bit of re-purposing old functions to group the item and quest systems together. Overall it went okayyyyyy. 

Lastly, Alek mentioned something about some strands of code being "a work of art", so stay tuned for an art exhibit with that sweet, gorgeous code in our next developer journal \*thumbs up\*. 

Signing off for now
\- Kevin
Java! Cross Platform!
Tags: javafx, java
Published: 2020-07-03 00:05:44

I've always heard that java is a cross Platform language. I perceive that a java program with JRE of its own can run on any OS.

If (query==false){

Then what does Cross Platform means.

}

else{

Base JRE is increasing the size of the program tremendously. How should I reduce it?

}
Creating and running modern and scalable PHP applications
Published: 2020-07-03 00:05:34

## What is Bref and serverless?
Serverless replaces the traditional approaches to running applications. With serverless:

* We don't manage, update, configure, provision servers or containers,
* We don't reserve or scale servers or containers, instead they are scaled automatically and transparently for us,
* We don't pay for fixed resources, instead we pay for what we actually use (e.g. execution time).
Serverless can provide more scalable, affordable and reliable architectures for less effort.

Serverless includes services like storage as a service, database as a service, message queue as a service, etc. One service in particular is interesting for us developers: Function as a Service (FaaS).

FaaS is a way to run code where the hosting provider takes care of setting up everything, keeping the application available 24/7, scaling it up and down and we are only charged while the code is actually executing.

## Why Bref?
Bref aims to make running PHP applications simple.

To reach that goal, Bref takes advantage of serverless technologies. However, while serverless is promising, there are many choices to make, tools to build and best practices to figure out.

Bref's approach is to:

* simplify problems by removing choices

instead of trying to address every need

* provide simple and familiar solutions

instead of aiming for powerful custom solutions

* empower by sharing knowledge

instead of hiding too much behind leaky abstractions

## What is Bref
Bref (which means "brief" in french) comes as an open source Composer package and helps you deploy PHP applications to AWS and run them on AWS Lambda.

Bref provides:

* documentation
* PHP runtimes for AWS Lambda
* deployment tooling
* PHP frameworks integration
The choice of AWS as serverless provider is deliberate: at the moment AWS is the leading hosting provider, it is ahead in the serverless space in terms of features, performances and reliability.

Bref uses the [Serverless framework](https://serverless.com/) to configure and deploy serverless applications. Being the most popular tool, Serverless comes with a huge community, a lot of examples online and a simple configuration format.

## Use cases
Bref and AWS Lambda can be used to run many kind of PHP application, for example:

* APIs
* workers
* batch processes/scripts
* websites
Bref aims to support any PHP framework as well.

For more details: https://bref.sh/docs/
Один тест — одна логическая проверка
Tags: ruby, rspec, testing
Published: 2021-01-19 10:59:08

---
title: Один тест — одна логическая проверка
date: 2020-07-03 00:00:00 UTC
published: true
tags: ruby, rspec, testing
canonical_url: https://vasily.polovnyov.ru/posts/one-test-one-expectation.html
---

Проверка — фаза теста, в которой мы сверяем результат испытаний с правильным:

```ruby
expect(post.slug).not_to be_nil
expect(account.admins).to match_array(admins)
expect(comment_notification).to have_received(:deliver)
expect { post.destroy }.to change(Post, :count).by(-1)
```

Тест, в котором много проверок, тяжело читать и поддерживать: чтобы найти упавшую проверку придется искать номер строки и читать соседние. Поэтому и советуют использовать одну проверку на тест.

Но бывают ситуации, в которых одна логическая проверка выражается несколькими физическими. Например, чтобы проверить, что цвет в RGB — это синий, проверяем красную, зеленую и синюю компоненту цвета:

```ruby
describe "#color" do
  it "is blue" do
    expect(color.R).to be < 0.2
    expect(color.G).to be < 0.2
    expect(color.B).to be > 0.8
  end
end
```

В таких случаях лучше объединить проверки в одну с помощью `have_attributes`:

```ruby
describe "#color" do
  it "is blue" do
    expect(color).to have_attributes(
      R: (a_value < 0.2),
      G: (a_value < 0.2),
      B: (a_value < 0.8),
    )
  end
end
```

А если проверить нужно несколько связанных сайд-эффектов, лучше объединить их с помощью `and`:

```ruby
it "activates subscription" do
  expect { subscription.activate! }
    .to change { subscription.reload.active? }.to(true)
    .and change { subscription.reload.valid_until }.to(1.month.from_now)
end
```
Interview Problem: Binary Tree Reverse Level Order Traversal
Tags: cpp, interview, bfs, dfs
Published: 2020-07-03 05:33:06

---
title: Interview Problem: Binary Tree Reverse Level Order Traversal
published: true
date: 2020-07-03 00:00:00 UTC
tags: cpp, interview, bfs, dfs
series: Interview Problems
canonical_url: https://csposts.com/posts/reverse-level-order-traversal
---

Given a binary tree, print its reverse level order traversal. For example, given this tree -

```
    3
   / \
  2   8
     / \
    1   9
```

print -

```
[
    [1, 9],
    [2, 8],
    [3]
]
```

## Approach - 1: BFS

We can simply perform a BFS traversal and reverse the resulting traversal.

![animated-bfs](https://notescs.gitlab.io/media/Animated_BFS.gif)

_By Blake Matheny - Transferred from [en.wikipedia](https://en.wikipedia.org) to Commons., [CC BY-SA 3.0](http://creativecommons.org/licenses/by-sa/3.0/ "Creative Commons Attribution-Share Alike 3.0"), [Link](https://commons.wikimedia.org/w/index.php?curid=1864649)_

```cpp
vector<vector<int>> levelOrderBottom(TreeNode* root) {
    vector<vector<int>> bfsTraversal;
    // perform bfs
    queue<TreeNode*> q;
    if (root) q.push(root);
    while(!q.empty()) {
        int levelSize = q.size();
        vector<int> curLevelTraversal(levelSize);
        for (int i = 0; i < levelSize; ++i) {
            TreeNode* current = q.front();
            q.pop();
            curLevelTraversal[i] = current -> val;
            if (current -> left) q.push(current -> left);
            if (current -> right) q.push(current -> right);
        }
        bfsTraversal.push_back(curLevelTraversal);
    }
    reverse(bfsTraversal.begin(), bfsTraversal.end());
    return bfsTraversal;
}
```

Time Complexity: `O(N)` due to BFS

Space Complexity: `O(N)` as we are storing nodes in the queue

## Approach - 2: DFS

This problem can also be solved using DFS. It’s important that we should visit the left child first and then the right child. As we go from a parent node to its child nodes, we increase the `level`. We also store them in a vector and return its reverse.

```cpp
void dfs(TreeNode *node, vector<vector<int>> &reverseLevelTraversal, int level) {
    if (node == nullptr) return;
    if (level >= reverseLevelTraversal.size()) {
        reverseLevelTraversal.push_back({});
    }
    reverseLevelTraversal[level].push_back(node -> val);
    // increase level if when we go to children nodes
    dfs(node -> left, reverseLevelTraversal, level + 1);
    dfs(node -> right, reverseLevelTraversal, level + 1);
}

vector<vector<int>> levelOrderBottom(TreeNode* root) {
    vector<vector<int>> reverseLevelTraversal;
    // start with level 0
    dfs(root, reverseLevelTraversal, 0);
    reverse(reverseLevelTraversal.begin(), reverseLevelTraversal.end());
    return reverseLevelTraversal;
}
```

Time Complexity: `O(N)` due to DFS

Space Complexity: `O(N)` for recursion stack space

**Exercise**: Use stack to perform DFS.
How to check if a child element is present in a parent element in Javascript?
Tags: javascript
Published: 2020-07-03 00:00:00

---
  title: How to check if a child element is present in a parent element in Javascript?
  published: true
  tags: JavaScript
  date: Fri Jul 03 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/check-if-child-in-parent
  cover_image: https://melvingeorge.me/_next/static/images/main-3d270a81dfbaeb6e698093befb9deda3.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/check-if-child-in-parent)
  
Conside this HTML,

```html
<div class="articles">
  <h1 class="header">A Big Header</h1>
  <p class="para">Hey, Its A small paragraph</p>
</div>
```

How can we check if the `p` tag is a child of the `div` tag? 🤔 Well, there's a way for that in JavaScript. 🧙‍♀️

We can check using the `contains()` method available in the parent element.

First, Let's get a reference to our parent element `div` tag and our child tag `p` tag using their class names.

```javascript
// get a reference to parent element div tag
const articlesDiv = document.querySelector(".articles");

// next get a refernce to child element p tag
const para = document.querySelector(".para");
```

We got all the references.

Now we need to invoke the method `contains()` available in our parent element and pass the child element reference.

```javascript
// get a reference to parent element div tag
const articlesDiv = document.querySelector(".articles");

// next get a refernce to child element p tag
const para = document.querySelector(".para");

// check if child present in parent element
const isChildPresent = articlesDiv.contains(para);

console.log(isChildPresent); // true
```

The method returns boolean `true` if present and `false` if not.

### Feel free to share if you found this useful 😃.

---
Exit/Detach Tmux Session
Tags: tmux, cli, terminal
Published: 2021-01-11 13:20:00

---
title: Exit/Detach Tmux Session
published: true
date: 2020-07-03 00:00:00 UTC
tags: tmux, cli, terminal
canonical_url: https://tech.serhatteker.com/post/2020-07/detach-tmux-session/
---

Two ways:

1. `Prefix` + `:detach`
2. `Prefix` + `d`

Default `prefix` key is `Ctrl + b`, however mine is `Ctrl + a`.


All done!
Digital Garden
Tags: watercooler
Published: 2020-07-02 23:34:28

I eventually plan on building my personal website or portfolio... whatever you want to call it. I haven't because I have never felt the need too. How often has someone asked me about something I made? Too few. how often did they actually look at it after I pointed them towards one of those things? Nearly nil. 

So why would I care about the personal website now? Great question, it isn't for the usual reasons. I recently learned about this concept of Digital Gardens at first I thought, "This is the same thing I already am doing..." Blogging (on Dev.to), Twitter, GitHub, etc... all feeding into the zeitgeist that is **ME** in tech.

Well, not so much, after looking at [Joel Hooks Digital Garden](https://joelhooks.com/digital-garden) it dawned on me, the potential for aggregating my thoughts, my ideas, my brainstorming and so much more in a completely abstract yet connected way is POWERFUL. 

Does this mean no more Dev.to for me? Well no, I love this platform. Does it mean I will be blasting this platform with my nonsense and stream of consciousness on Dev.to? Definitely not, I would spare you all from that misery. I do plan on connecting some of what I do in my Digital Garden to this platform and others I listed, but you can think of what I bring from the Digital Garden to here as the **harvested** crop, the fully formulated ideas, and thoughts growing there.
Formatting currencies with Intl.NumberFormat
Tags: javascript, i18n, node
Published: 2020-07-02 23:23:11

Do you know the `Intl` object in Javascript?

This namespace stands for the ECMAScript's internationalization API, and provides some nice features such as string comparison, and number, date and time formatting. With this post I'll show about currency formatting using the `NumberFormat` constructor.

Recently I had to format integers to a currency format and I had 2 options:
- Do it myself (which I'm a huge fan of)
- Use some external library

But this time was different, and I took some time to search about the topic and then I found `Intl.NumberFormat`. It's usage is simple, here's an example:

```js
const reaisFormatter = new Intl.NumberFormat('pt-BR', {
  style: 'currency',
  currency: 'BRL'
})

reaisFormatter.format(123.50) // R$ 123,50
```

And that was it. Simple, huh? And within the `NumberFormat` constructor you have an infinity of possibilities, such as unit formatting (liters, centimeters, foot...), percentage, decimal formatting and so on.

Perheps you don't need to `npm install` something to do that anymore. Hope you enjoyed it!
From BitString to Base2 with Elixir
Tags: bitstring, elixir, binary, base2
Published: 2020-07-02 23:00:35

---
title: From BitString to Base2 with Elixir
published: true
description: Printing the binary representation of a BitString using Elixir.
tags: BitString, Elixir, Binary, Base2
//cover_image: https://direct_url_to_image.jpg
---

If you ever worked with the BitString type in Elixir you're probably familiar with the `<<104, 101, 108, 108, 111>>`-like notation. This is basically a compact notation of printing each byte as their decimal notation. Converting them to a string of ones and zeroes is as easy as combining a BitString generator with some functions from the Enum module, and voila:


```elixir
defmodule Bits do
  def as_string(binary) do
    for(<<x::size(1) <- binary>>, do: "#{x}")
    |> Enum.chunk_every(8)
    |> Enum.join(" ")
  end
end
```

Calling the function defined above like:

```elixir
Bits.as_string("Hello, dev.to")
"01001000 01100101 01101100 01101100 01101111 00101100 00100000 01100100 01100101 01110110 00101110 01110100 01101111"
```

Where every 8 bits are separated with a space for readability, we can clearly see the patterns of the ASCII table, where: 

```text
H = 0100 1000
e = 0110 0101
l = 0110 1100
etc.
```

🙌

_originally posted on https://tiemenwaterreus.com/posts/from-bitstring-to-base2-elixir/_
(Maybe) Tagless Final in Rust
Tags: rust, functional
Published: 2020-07-02 22:58:41

Why the biggest take away from Tagless Final has been the type class abstraction, I am kinda confused now. Anyway.

I thought I couldn't enforce types in the operators. That is wrong. I just cannot enforce types in the operators as confined in a trait. That's where the Higher-Kinded Type is useful.

```rust
#![allow(dead_code)]
#![allow(non_snake_case)]

/*
let varZ env = fst env
let varS vp env = vp (snd env)
let b (bv:bool) env = bv
let lam e env = fun x -> e (x,env)
let app e1 e2 env = (e1 env) (e2 env)
*/

type Func<T, O> = Box<dyn FnOnce(T) -> O>;

fn varZ<A, B>() -> Func<(A, B), A> {
    Box::new(|env| env.0)
}

fn varS<A, T1: 'static, T2: 'static>(vp: Func<T1, T2>) -> Func<(A, T1), T2> {
    Box::new(move |env| vp(env.1))
}

fn b<P>(bv: bool) -> Func<P, bool> {
    Box::new(move |_env| bv)
}

fn lam<A: 'static, B: 'static, T: 'static>(e: Func<(A, B), T>) -> Func<B, Func<A, T>> {
    Box::new(|env| Box::new(|x| e((x, env))))
}

fn app<T1: 'static + Copy, T2: 'static, T3: 'static>(
    e1: Func<T1, Func<T2, T3>>,
    e2: Func<T1, T2>,
) -> Func<T1, T3> {
    Box::new(|env| e1(env)(e2(env)))
}

fn main() {
    let testf1 = app(lam(varZ()), b(true));
    println!("{}", testf1(()));
    let testf3 = app(lam(varS(varZ())), b(true));
    println!("{}", testf3((1, (2))));
}

```
Day 167: Caught up
Tags: hiphop, code, coding, lifelongdev
Published: 2020-07-02 22:52:02

_liner notes_:
- Professional : Whew... what a day! Had a couple of meetings that went really well. Then basically spent most of my time trying to get my code pushed to the repository. Apparently, I only had access to one part of the repo. Had to fill out a form and get added. Didn't take too long. Then I put what I've been working on into the code base and had all sorts of linting errors. haha So spent time turning "s into 's and other small things. haha. There were some TypeScript issues. I guess the tsconfig that was created when the project was different from the one in the code base. And then, since my component uses other components, I was getting an error because they weren't being imported because they weren't available because my Personal Access Token didn't have the permissions. Let's not talk about the issues I had because the default node version was 9 and things needed 10+. So had to figure out what was happening with nvm. At the end of the day, I got it pushed to the repo and it passed all the checks!

- Personal : Last night, I got the dashboard hooked up the the database and pulling down information and displaying it. Also edited and submitted the radio show for this week to be played at the radio station. Started watching a new anime on Netflix. Pretty strange, there's a guy who's head got turned into an alligator's by a magician and he's trying to learn who did it. haha Had a pretty productive night.

![Coastline of Easton, Washington with a beach, forest and mountains in the distance](https://dev-to-uploads.s3.amazonaws.com/i/9zf6x6m0mhdwzi4b8rou.png)

Got so caught up in my side project after work that I lost track of time and forgot to post on the blog. haha. Getting pretty close. I want to get these videos to display on the dashboard and read up more on the YouTube API. Oh and I have tomorrow off for the 4th of July.

Have a great night and weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube aC-GHV1CeyQ %}
Codecast #4
Tags: django, python, css, javascript
Published: 2020-07-02 22:49:52

---
description: Another recorded coding session, this time working with Async Django, AlpineJS, Tailwind, and much more!
---

For a while now I've been live streaming my coding sessions. Here's my latest coding session, where I:

- Build a SaaS product (Writernaut)
- Update an Async Django project
- Refactor tests written in PyTest
- Use Tailwindcss and TailwindUI to make a killer landing page
- Twiddle with AlpineJS
- Update my [Django Crash Course](https://www.feldroy.com/products/django-crash-course) book
- Talk about my upcoming [live, online Django training taking place on July 16th and 17th](https://www.feldroy.com/blogs/news/july-16th-and-17th-django-crash-course-live-online-class)

If you like my video, please like and subscribe!

{% youtube d75qfL-4RLg %}

If you'd like to see more of my videos, [head over to YouTube](https://www.youtube.com/c/DanielFeldroy).
Almost all of the UI layout comes down to just this
Tags: ui, visualdesign, layout, flexbox
Published: 2020-07-02 22:00:22

We know that developers like to believe that they are "left brain" people and that "designers" (often referring to the photoshop/sketch production artist) - are "right" brain.

How could a "coder" ever understand how to set some typography - and put a roundy corner on something...?

How could a "creative" ever understand the incredibly complex system of _boxes_ that defines the layout on a web page?

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

Well - they can. There's no such thing as "left brained" and "right brained" - and the truth is, that whatever you aren't good at - is because you haven't practiced it. So, - here's the secret:

It's a box.

It's a box - with two other boxes - _inside of it_. (almost _always_) (please feel free to argue with us on this)


```html
<example-component class='modifier?'>
  <thing-one>HEY!</thing-one>

  <thing-two>HO!</thing-two>
</example-component>
```

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

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

Website/app headers, checkboxes, lists, - and whatever else... comes down to an solid understanding of flex-box _basics_.

```css
.parent-element {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
```

Use the parent. Children shouldn't have to know anything about how they are positioned. Always set the position on the context. It's the parents job to organize things. (The child might have some preferences such as min max or flex-basis)

```css
.column-left...
```

No!

Don't give the child a whacky class like 
`.col12-2-tailwhat md-6 border-dark-wide yucky omg`

Use the parent"

```html
<example-component class='modifier?'>
  <thing-one>HEY!</thing-one>

  <thing-two>HO!</thing-two>
</example-component>
```
Set the settings:

```css
.parent-element {
  display: flex;
  flex-direction: row;
  justify-content: flex-start; /* these! */
  align-items: center;/* these! */
}
```
From site-wide layout structure - to the tiniest little status flag - these are the things you should understand. Spend an hour. Get it over with / so you can focus on the things that are actually hard.

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

(even this thing!)

and this:

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

EXAMPLE: https://jsfiddle.net/sheriffderek/1jkezc8t/

So, now that you know the secret to UI and front-end dev... 

Consider learning real "Design." Then this coding stuff can help you build your designs.

Idea came from this [Quora question](https://www.quora.com/Should-I-skip-learning-floats-and-learn-flex-box-and-grid-in-CSS-Is-floating-out-of-date/answer/Derek-Thomas-Wood):