teleren/devto huggingface dataset:
Rails guide - Project patterns - Part 6
Tags: ruby, rails, architecture, webdev
Published: 2022-10-09 07:02:54

Hey guys! How are you?

This article is a part of a series that will teach how to create a production ready rails application. In this article we gonna talk about project patterns and how we'll organize our project.

# Table of content

- [Rails way to do things](#rails-way-to-do-things)
- [Project patterns](#project-patterns)
- [Project tree](#project-tree)
- [Conclusion](#conclusion)

# Rails way to do things

Rails is a framework known by their conventions, you can find the following quote in [Rails official documentation](https://guides.rubyonrails.org/getting_started.html#what-is-rails-questionmark)

> Rails is opinionated software. It makes the assumption that there is a "best" way to do things, and it's designed to encourage that way - and in some cases to discourage alternatives. If you learn "The Rails Way" you'll probably discover a tremendous increase in productivity. If you persist in bringing old habits from other languages to your Rails development, and trying to use patterns you learned elsewhere, you may have a less happy experience.

This quote clearly says that we need to organize our software in a way that respects Rails standards, so, that's how we gonna do this:

# Project patterns

We gonna organize our software following these principles:

1. Controllers will have no logic, it'll either validate parameters or call another class
2. Services will interact with thirdy party services
3. UseCases will create data into our database and interact with our models
4. Models will store application logic

If you already read about [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) probably noticed that the project structure follows the ideia that pattern suggests.

# Folder organization

In the end of the day, we'll use mostly the following folders in our project:

```
- app
-- controllers
-- models
-- services
-- use_cases
- lib
```

The `controller` folder is our interface to the web, that's where we'll define our routes actions.

The `models` folder is where we define our entities and some business logic.

The `services` folder is our interface to third party applications, such as external apis.

The use_cases folder is our interface to our entities.

The `lib` folder will contain all code that's not directly related to our project core, such as parsers.

# Conclusion

I hope everyone understood why we gonna organize the project using this method, please comment if there is any questions.
Univalued Binary Tree
Tags: javascript, leetcode
Published: 2022-10-09 06:54:13

A binary tree is uni-valued if every node in the tree has the same value.

Given the root of a binary tree, return true if the given tree is uni-valued, or false otherwise.

 

Example 1:


Input: root = [1,1,1,1,1,null,1]
Output: true

```js
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
var isUnivalTree = function(root) {
const value = root.val;
  return checkIfUnivalued(root, value);
};

const checkIfUnivalued = (root, value) => {
  if (root === null) {
     return true;
  }

  if (root && root.val !== value) {
    return false;
  }

  return (
    checkIfUnivalued(root.left, value) && checkIfUnivalued(root.right, value)
  );
};
```
在 App Inventor 中找尋積木
Tags: ai2
Published: 2022-10-09 06:46:38

App Inventor 的使用者一定有這樣的經驗, 當你的專案大一點時, 在程式設計介面中常常找不到你想要修改的某一個積木, 而且積木數量越多, 整個介面的反應速度越慢, 就算人工移動頁面找尋也是很痛苦的事, 如果縮小顯示比例, 字也可能小到難以辨識的程度, 還好已經有善心人士寫好了瀏覽器的延伸模組, 可以幫助我們找尋特定的積木。
 
## 安裝 BlockFinder 延伸模組
 
 [Block Finder](https://community.kodular.io/t/find-blocks-blocks-finder/142100) 是一個瀏覽器的延伸模組, 他可以幫你在 App Inventor 中直接找尋特定的積木, 並且讓該積木出現在你的頁面中央, 省去大家耗費時間眼力還不見得找得到的問題。

這個延伸模組通用於主流瀏覽器, 以下說明各種瀏覽器的安裝方式。

### Firefox

直接[下載延伸模組檔案](https://blockfinder.vercel.app/download/Firefox_V5.xpi), Firefox 就會逕行安裝了。

### Opera

1. 下載 [Opera 延伸套件檔案](https://blockfinder.vercel.app/download/Opera.zip)後解開壓縮檔。
1. 切換到**延伸套件**頁面, 開啟**研發人員模式**：

    ![](https://i.imgur.com/sthrg6G.png)

3. 按一下**載入未封裝項目**, 瀏覽到剛剛解壓縮開的資料夾後按**選擇資料夾**就會進行安裝：
    
    ![](https://i.imgur.com/fKRDQgP.png)


### Chrome

1. 下載 [Chrome 擴充功能檔案](https://blockfinder.vercel.app/download/Chrome.zip)後解開壓縮檔。
1. 切換到**擴充功能**頁面, 開啟**開發人員模式**：

    ![](https://i.imgur.com/dsW9icR.png)

3. 按一下**載入未封裝項目**, 瀏覽到剛剛解壓縮開的資料夾後按**選擇資料夾**就會進行安裝：

    ![](https://i.imgur.com/k3VLCv2.png)

## 使用 BlockFinder

1. 我測試時這個延伸模組和中文版的介面好像會有點問題, 建議先將 App Inventor 切換成英文版：

    ![](https://i.imgur.com/8DsSd4J.png)

3. 重新開啟你的 App Inventor 專案, 在程式設計介面的左側, 就會自動出現 BlockFinder 的介面。

    ![](https://i.imgur.com/L2IGypf.png)

3. 你可以根據積木的類型從拉清單中選擇要尋找的積木, 例如以下就是從使用者介面的元件中找出 StopRecog 這個按鈕被點選時的積木：

    ![](https://i.imgur.com/o7dXERE.png)

    找到積木後會以該積木為中心呈現在頁面上, 而且會以不同顏色標示。
    
透過這樣的方式, 我們就可以快速找到積木, 再也不需要在茫茫積木海中胡亂闖蕩了。
Mua backlink tay 4k/1 link cho website cực chất lượng, uy tín
Published: 2022-10-09 06:36:11

Mua backlink là một cách hỗ trợ cho website chúng tôi nhận đi backlink tay 4k/1 linkđi link chất lượng, uy tín, mang lại hiệu quả
Hastags, tag #muabacklink #backlinktay #backlinkgiare #backlinkchatluong
Địa chỉ: Số 16 ngõ 236 Đại từ, Hoàng Mai, Hà Nội
Điện thoại: 0356.241.202
Email: muachungahef1@gmail.com
Website: https://muabacklink.com.vn/

Maps: https://goo.gl/maps/ujXjaBiXZ1ginJwg7
https://issuu.com/muabackink

https://www.openstreetmap.org/user/muabackink

https://about.me/muabackink

https://wefunder.com/muabacklink3

https://app.lookbook.nu/muabackink

https://confengine.com/user/muabackink

https://zoimas.com//profile/muabackink/about

https://www.trainsim.com/vbts/member.php?584112-muabackink

https://trello.com/w/muabacklink5

https://muabackink.livejournal.com/profile

https://weheartit.com/muabackink

https://android.libhunt.com/u/muabackink

https://forum.singaporeexpats.com/memberlist.php?mode=viewprofile&u=472809

https://artmight.com/user/profile/761502

https://www.indiegogo.com/individuals/30523217

https://angel.co/u/mua-backlink-2

https://www.kickstarter.com/profile/muabackink/about

https://kustomcoachwerks.com/Forums/users/muabackink/

https://jsfiddle.net/muabackink/w7udc8ke/

https://pastelink.net/3xai3qjx

https://bitcoinblack.net/community/muabackink/info/

https://www.hebergementweb.org/members/muabackink.310196/

https://www.gametabs.net/user/437470

https://www.veoh.com/users/muabackink

https://www.question2answer.org/qa/user/muabackink

https://forum.kryptronic.com/profile.php?section=essentials&id=192032

https://www.watchfaces.be/forums/users/muabackink/

https://www.couchsurfing.com/users/2016238183

https://www.1forexforum.com/members/muabackink/

https://writeablog.net/muabackink/mua-backlink-tay-4k-1-link-cho-website-cuc-chat-luong-uy-tin

https://gifyu.com/muabackink

https://www.hackathon.io/muabackink

https://www.noteflight.com/profile/435c2071ab2bc78ef3d8a44898c7ee3e0a4895e5

https://timeswriter.com/members/muabackink/profile/

https://dogforum.co.uk/members/muabackink.114611/

http://www.print3dforum.com/member.php/33770-muabackink

https://www.techrum.vn/members/muabackink.223875/#about
About me ...
Published: 2022-10-09 06:31:54

My name is Carlos Jaramillo and my passion is the implementation of technology in different areas of knowledge. I am a lawyer by profession, I have a master's degree in Computer Law, and three years ago I decided that it was time to reinvent myself and complement my professional profile with a Software Engineer degree. So, I study software development, in order to understand the current problems of society and develop custom software to solve these problems. I really believe in software development as a mechanism for social service, and as a tool for transformation.

I have experience as a lawyer, on one hand, in the subject of Natural Language Processing for the classification of legal documents, and on the other, I acquired knowledge during my software development studies, where I learned to work both with the bottom-up methodology for the design, development, testing and deployment of each of the software layers, such as with the technologies like: mongo Db and SQL for the databases, Django, Spring boot and Node.js for the backend, and Vue.js and React for the frontend. Additionally, I learned to work with the architecture of microservices for the development of small autonomous and independent applications, communicated through an API Gateway.

My goal at work, is to work in a company that shares my same passion for technology, and where the fundamental principle of giving the world better opportunities and experiences through technological solutions is valued.

                          “Givers advance the world. Takers advance themselves and hold the world back" –Simon Sinek
what happens when your type google.com in your browser and press enter
Tags: dns, network, tcp, loadbalancer
Published: 2022-10-09 06:24:03

### step 1:
 Check the cache for the domain's IP address, for a sites like google.com it's usualla embedded in most browsers as a trusted site that uses https (this was done after a few man in the middle attacks which would hijack the initial request since the browser uses http (port 80) by default and is re-routed to `https`:(port 443) )
it might also check
- OS cache
- router cache
- ISP cache

 If the requested URL is not in the cache, the browser checks the `DNS` registry

### step 2:
The browser initiates a TCP connection with the server.
Once the browser receives the correct IP address, it will build a connection with the server that matches the IP address to transfer information. Browsers use internet protocols to build such connections. There are several different internet protocols that can be used, but `TCP` is the most common protocol used for many types of HTTP requests.

To transfer data packets between your computer(client) and the server, it is important to have a `TCP/IP` connection established. This connection is established using a process called the TCP/IP three-way handshake. This is a three-step process where the client and the server exchange SYN(synchronize) and ACK(acknowledge) messages to establish a connection.

1. The client machine sends a SYN packet to the server over the internet, asking if it is open for new connections.

2. If the server has open ports that can accept and initiate new connections, it’ll respond with an ACKnowledgment of the SYN packet using a SYN/ACK packet.

3. The client will receive the SYN/ACK packet from the server and will acknowledge it by sending an ACK packet.

Then a TCP connection is established for data transmission!
after that an `SSL` connection is initialized  to supprt communication over the secure `https`

### step 3:
The browser now sends the request and the server's loadbalancer will then redirect your request to the respective destination and send a response back t the application

### step 4:
The browser then renders the response html and awaits further interactions
653. Leetcode Solution in Java
Tags: java
Published: 2022-10-09 05:36:31

```java
class BSTIterator {
  public BSTIterator(TreeNode root, boolean leftToRight) {
    this.leftToRight = leftToRight;
    pushLeftsUntilNull(root);
  }

  public int next() {
    TreeNode root = stack.pop();
    pushLeftsUntilNull(leftToRight ? root.right : root.left);
    return root.val;
  }

  public boolean hasNext() {
    return !stack.isEmpty();
  }

  private Deque<TreeNode> stack = new ArrayDeque<>();
  private boolean leftToRight;

  private void pushLeftsUntilNull(TreeNode root) {
    while (root != null) {
      stack.push(root);
      root = leftToRight ? root.left : root.right;
    }
  }
}

class Solution {
  public boolean findTarget(TreeNode root, int k) {
    if (root == null)
      return false;

    BSTIterator left = new BSTIterator(root, true);
    BSTIterator right = new BSTIterator(root, false);

    for (int l = left.next(), r = right.next(); l < r;) {
      final int sum = l + r;
      if (sum == k)
        return true;
      if (sum < k)
        l = left.next();
      else
        r = right.next();
    }

    return false;
  }
}

```

#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/two-sum-iv-input-is-a-bst/
Python - SciPy basic Introduction
Tags: python, programming, computerscience, staticwebapps
Published: 2022-10-09 05:19:50



**What is SciPy?**
SciPy is a scientific computation library that uses NumPy underneath.

_SciPy stands for Scientific Python_.

It provides more utility functions for optimization, stats and signal processing.

Like _NumPy_, _SciPy_ is open source so we can use it freely.

SciPy was created by NumPy's creator Travis Olliphant.

**Why Use SciPy?**
If SciPy uses NumPy underneath, why can we not just use NumPy?
SciPy has optimized and added functions that are frequently used in NumPy and Data Science.

**Which Language is SciPy Written in?**
SciPy is predominantly written in Python, but a few segments are written in C.


**Where is the SciPy Codebase?**
The source code for SciPy is located at this github repository 
[Github repo](https://github.com/scipy/scipy)
github: enables many people to work on the same codebase.
REACT JS TOPICS TO LEARN
Published: 2022-10-09 05:16:30

React Guidance :

JavaScript Basics

Es6 features

SPA vd MPA

Library vs Framework

Angular vs React Js

React Js Concepts:

React Js

Component

JSX

Virtual DOM

Bable

Webpack

npm vs npx

Yarn

Create-React-App

State

Props

State vs Props

Working with Events

Rendering List

Conditional Content

Event Handling and Conditional Rendering

Styling React Components

List and Keys

Error Handling

React Js lifting the state up

Debugging React Apps

Parent child communication

Life Cycle Methods

Forms(Controlled and Uncontrolled forms)

Formik yup

REST Api Calls

Working With Fragments

Class Components

Functional Components

Class Components vs Functional Components

Routing

React Router v6

React Js nested routes

CRUD

Validate

Hooks

Custom Hooks

State Lift up

Props Drilling

Context API

Redux State management and what problems it solves?

Middle ware

Redux-Thunk

Redux-Saga

Redux-Promise

Redux-ToolKit

Advance Redux

Material UI

Performance

React lazy loading and profiler api

React context and developer tools

Authentication

Unit Testing

React with Typescript

Dockerization with react Js

Build and Deployment 

Logging and Debugging

React Js with Typescript

React Js Frameworks:

Next js

GatsBy

Remix js
Hacktoberfest PR#1: Language is key for supporting the nation
Published: 2022-10-09 04:49:52

Hey! Thanks for checking in. This week, I've been working on contributing a Ukrainian translation to an Open Source project, so let me tell you about how it went :) 

## The project

The project I contributed to is called [Telescope](https://github.com/Seneca-CDOT/telescope). It's a RSS feed aggregator of contributors' blog posts, and it is the main Open Source project of Seneca.

## My contribution

I am Ukrainian, and believe that language is one of the key things that defines a nation. So, I decided to add some Ukrainian translation to a part of Telescope's documentation.

I have contributed to some smaller Open Source projects in the past, but the scale of Telescope was much bigger than anything I have contributed to before, so I took some time to read through CONTRIBUTIONS.md and some general tips.

So after I have gone through some of that, I created the [issue](https://github.com/Seneca-CDOT/telescope/issues/3699), like with all Open Source projects, forked the repo, and started working. It is also important that your issue is approved of before you start any work.

## Translation

It is surprisingly hard to translate, even if you are fluent in both languages. It appears that when I usually speak English, the language in which I think changes, so perfect knowledge of 2 languages does not at all make you a good translator. Another factor was trying to convert idioms. You know as a rule what a certain idiom means, but it is really hard to find a corresponding idiom in another language.

Because of this factor, the work was a bit more challenging than I initially anticipated, but I do love myself a good challenge to take on, especially when it's connected to my mother tongue.

## Finishing up

After my work has been done, I pushed it to my fork and opened a [pull request](https://github.com/Seneca-CDOT/telescope/pull/3701). Pull requests in bigger projects take longer, especially when there are probably no Ukrainian-speakers to review the work.

## Summary

Content in Ukrainian is one thing the Internet doesn't offer a lot of. And this is something we should change sooner than later. We need a clear display that our nation is independent and sovereign, rather than depending on enemy resources. I hope that my contribution gets approved soon, and will be a small part of fighting for the definition of Ukrainian nation.

Слава Україні :ukraine:
A little about me
Tags: personal, aboutme
Published: 2022-10-09 04:06:54

My name is Ulises Alexander A.M. For a few years I studied **Computer Engineering** at the **School of Engineering** (FI) of the **National Autonomous University of Mexico** (UNAM). That didn't go as expected, so I dropped out and return to my hometown. Then I started studying **Software Engineering** at the **School of Business and Technologies** of the **Universidad Veracruzana** (UV). I also dropped out from this last program.

Currently, I'm learning Haskell and functional programming. Furthermore, I know Python, a bit of SQL, Git, GitHub Actions, concepts of agile software development, continuous delivery, and other software development related concepts I've learned in college or by myself. If this paragraph seems like an extraction of a CV or cover letter, it's because that's part of the intention, given that I'm job hunting.

I've been writing some functions in _fish shell_ to ease the management a use of my OS. As well, I'm working in a _**Reading Management System**_ as well. About this project, I'll talk about it in a series of posts. But for the moment, I can say that I'm focusing first in the design and coding of a book related library. All in Haskell. If you want to help me with the design, code, uses cases, or simply want to check it out, the repository is here: 

{% embed https://github.com/UlisesAlexanderAM/book %}

My hobbies are: listening to music, watching anime and series; reading manga, webtoons, webcomics, and books; programming, traveling when possible, going to the movies, going out for a walk.

I think that is a nice summary of myself. I hope you enjoy my content.
Binary Tree Zigzag Level Order Traversal
Tags: javascript, leetcode
Published: 2022-10-09 03:53:02

Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between).


Example 1:

Input: root = [3,9,20,null,null,15,7]
Output: [[3],[20,9],[15,7]]

```js
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number[][]}
 */
var zigzagLevelOrder = function (root) {
  if (!root) return [];
  let queue = [root];
  let levels = [];
  while (queue.length > 0) {
    let levelSize = queue.length;
    levels.push([]);
    for (let i = 0; i < levelSize; i++) {
      let curr = queue.shift();
      if (levels.length % 2 == 1) levels[levels.length - 1].push(curr.val);
      else levels[levels.length - 1].unshift(curr.val);

      if (curr.left) queue.push(curr.left);
      if (curr.right) queue.push(curr.right);
    }
  }

  return levels;
};

```

Solution 2 : via Recurssion

```js
var zigzagLevelOrder = function(root, res = [], lvl = 0) {
    if(!root) return res;
    
    if(!res[lvl]){
        res[lvl] = [];
    }
    if(lvl%2==0)
        res[lvl].push(root.val);
    else
        res[lvl].unshift(root.val);
    
    zigzagLevelOrder(root.left, res, lvl+1);
    zigzagLevelOrder(root.right, res, lvl+1);
    
    return res;
};
```
Toronto Tree Removal - Arborist Toronto
Published: 2022-10-09 03:28:06

Address:2 Forest Laneway, Toronto, ON M2N 5X7, Canada

Website:http://torontotreeremoval.ninja/

Contact:647-558-1366
If you're looking for tree removal in Toronto, look no further. Arborist Toronto is the best in the business! We'll clear your tree without breaking a sweat.

What makes us so great? We have all the right tools, and we use them to get the job done quickly and efficiently. We don't waste time chitchatting with you—we just get to work and make sure that the job is done right.

We use state-of-the-art equipment to safely remove trees from your property, so you don't have to worry about getting hurt or damaging your home or business in any way. We also make sure that we clean up after ourselves so there are no harmful chemicals left behind when we're done working on your property.

We know that not everyone can afford to hire an arborist like us for every single tree removal job—that's why we offer free consultations at our office in Forest Hill Village (just off of Yonge Street). If you'd like us to come out to your house or business and give you an estimate before going ahead with any work on your trees, that'd be great!
#tree removal toronto
#tree removal in toronto
#arborist toronto
#arborist in toronto
#tree removal in toronto
#toronto arborist
#arborist in toronto
#remove tree toronto
#tree services in toronto
#tree service in toronto
#tree removal city of toronto
#tree trimming toronto
#tree pruning toronto
PostgresSQL unit-3
Tags: postgres, sql, database, javascript
Published: 2022-10-09 03:26:15

> Jadvalga malumot qo'shish

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uxbemr8hyefqliiito1n.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vjxjsm7dub25hjs01lpv.png)

> jadvaldagi malumotlarni ko'rish

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/of7t6mr1djzxszls5gzz.png)
The username in dev.to
Published: 2022-10-09 03:15:13

When I find my post has url likes:

```
https://dev.to/peterlitszo/docker-network-4047
```

Of course it is readable. But what happen if the author change his/her username?

I try to rename me as peterlitszoxxx, and I try to access the same post. I find it redirect to my new username! Awesome!

There are a lot of website use user's ID rather than username. I do not think it is a bad idea - Althorgh we loss the readable, but we will never change the user's ID (just because it is not readable).

But when we use a readable thing in the website, what happen if we want to change it? For example, the article in other website may hold the origin url to the post and we cannot change it. If the user change his/her username, the url will be broken.

Redirect is a good idea. We can let a user has a lot of usernames, and limit the speed of change his/her username. But what happen if another user want to use the username nobody using?

Unreadable url looks not well, but it is not a bad idea. and urls in the web are broken easily always. Using unreadable things can make the url avoid being broken rather than using readable things as ID.
Sum all primes (freecodecamp)
Tags: javascript
Published: 2022-10-09 02:10:00

I struggled with this one... 
My solution may not be the most efficient but here is what I came up with:

My solution: 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tc83sprosokwjveowqrs.png)

with comments: 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vojo6df6elu8bkfgizhs.png)