teleren/devto huggingface dataset:
OSD600 Lab 5
Tags: beginners, opensource, cpp
Published: 2022-10-11 22:26:42

## What I did this week
This week, I refactored my code due to the various changes made by other contributors. While I did make some changes to make sure my code functioned following merging other contributors' code, there were still a few changes to be made. I mostly focused on code readability when improving my code. I had to think about how someone who was unfamiliar with my code would read and understand it, and how I could ease that process. The largest change I made was to an if condition that became unnecessarily cumbersome since some parts of it were redundant. Smaller changers I made were to line spacing and minor variable name changes. 

On a somewhat related note, I had earlier made some changes based on suggestions from other contributors, but they were not part of this lab. Hence I needed to make fewer changes to my code. 

## Rebasing My Code
The experience in rebasing my code went very smoothly. I was surprised how easy it was to squash all my multiple commits into a single commit. The process was straightforward with a bit of guidance from the on-screen instructions as well as the instructions of the lab. [This](https://github.com/rudychung/SauSaGe/commit/9167d64ca9571570a7c9c3190efb2f5aa6d24405) was the commit I made.

## Problems I Encountered
I had some issues changing my project's history since I accidentally put my changes into separate commits. I had to reverse my previous commits in order to get them all into one commit. I had to make use of `git reset` in order to reverse these commits and start the rebasing and merging process over in order to get them all into one commit.
Code Smell 168 - Undocumented Decisions
Tags: webdev, beginners, programming, tutorial
Published: 2022-10-11 22:13:38

*We need to make some changes. We need to be clear on why*

> TL;DR: Be declarative on your design or implementation decisions.

# Problems

- Code Comments

- Lack of testability

# Solutions

1. Be Explicit about the reasons.

2. Convert the comment to a method.

# Context

Sometimes we find arbitrary rules not so easily testable. 

If we cannot write a failing test, we need to have a function with an excellent and declarative name instead of a comment.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/554144e5e61703b8a556328671b0a3dd)
```c
// We need to run this process with more memory
set_memory("512k)
           
run_process();           
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/ab76cec5efd320d5cf9a2e626343d3e8)
```c
increase_memory_to_avoid_false_positives();
run_process();      
```

# Detection

[X] Semi-Automatic 

This is a semantic smell.

We can detect comments and warn us.

# Tags

- Comments

# Conclusion

Code is prose. And design decisions should be narrative.

# Relations

{% post https://dev.to/mcsee/code-smell-05-comment-abusers-2ba5 %}

{% post https://dev.to/mcsee/code-smell-75-comments-inside-a-method-2bk %}

# Disclaimer

Code Smells are just my [opinion](https://dev.to/mcsee/i-wrote-more-than-90-articles-on-2021-here-is-what-i-learned-1n3a).

# Credits

Photo by [Goh Rhy Yan](https://unsplash.com/@gohrhyyan) on [Unsplash](https://unsplash.com/s/photos/warning)
  
* * *

> Programs, like people, get old. We can’t prevent aging, but we can understand its causes, limit its effects and reverse some of the damage.

_Mario Fusco_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
Programmatically create submodules in Python
Tags: python
Published: 2022-10-11 21:49:14

If you've ever wanted to distribute a Python [package](https://docs.python.org/3/tutorial/modules.html#packages) as a single file, but keep the benefits of [dotted namespaces](https://en.wikipedia.org/wiki/Namespace#In_programming_languages), here is a tip.

We can generate submodules programmatically and add them to the current module's namespace using [importlib](https://docs.python.org/3/library/importlib.html).

For example, here is a single file module (named `x` if you save it to a file named `x.py`) with a submodule named `y`:

    import importlib.machinery
    import importlib.util
    import sys

    spec = importlib.machinery.ModuleSpec('y', None)
    y = importlib.util.module_from_spec(spec)
    sys.modules[__name__].y = y

    y.abc = 123

In order to do `import x.y` or `from x import y` as if `x` were a package and not simply a module, just add:

    sys.modules[__name__ + '.y'] = y
CSS: Frameworks and Extensions
Published: 2022-10-11 21:46:05

## What are CSS Frameworks?

CSS frameworks are packages of code, usually installed via NPM in the terminal, that change how a document will read its CSS. Usually these tools will attempt to make writing CSS 'easier' in various ways. For example, the Tailwind CSS framework allows you apply many different properties to an element in a far more succinct way:

```
#credit-box {
@apply m-5 items-center flex
}
```

In the above code, I am using Tailwind CSS to apply three CSS attributes in a single line of text. I am setting the margin of the element to 5px, I am center-aligning the item, and I am assigning the flex display type to the element. In terms of cutting down on unnecessary code, these tools are excellent for trimming the fat of your CSS files.

## CSS Framework limitations

Unfortunately these frameworks often have some pretty glaring limitations. In general CSS frameworks don't handle custom properties particularly well. For example, Tailwind CSS, as far as I am aware, does not accept custom hex codes when coloring elements. If you want to color an object with Tailwind, you'd have to choose from one of their preset colors.

Now this isn't a nail in the coffin for Tailwind, it just means that you can't use it for _everything_. In my last project a lot of my CSS wound up looking like this:

```
#item {
  background-color: #323432;
  @apply mx-0 center-align basis-1/2 
}
```
The above text uses both Tailwind CSS as well as manual CSS to achieve what I wanted out of it.

## CSS Extensions

Separate from frameworks are CSS expansions, which can serve to expand the capabilities of CSS in new and interesting ways. For example in my last project, I installed a CSS extension called Sass, which allowed me to create custom designed borders for my elements. Unfortunately, due to the broad nature of extensions, it can be difficult to talk about them in broad terms, I just find it important to remember that if you find your CSS feels limited in its capabilities, there is likely an extension that can help you get the job done. 


## Summary

CSS frameworks are good for cutting bloat out of a project, but bad for customization. You are unlikely to find one that does everything you want it to do, but that doesn't mean you shouldn't use them. Find one that you like, use it to do what is simple, and then do the rest yourself. As for extensions, they won’t always be helpful or necessary, but they are a good thing to keep in mind if you ever find base CSS limiting.
Proof of Work vs Proof of Stake
Tags: blockchain, beginners
Published: 2022-10-11 21:26:07

Proof of work is not a novel concept and was developed to prevent server abuse. In the form of Bitcoin, it is used as a consensus algorithm. This consensus algorithm is integral for Bitcoin to remain neutral and have no single point of failure. In order for Bitcoin to be produced, it is dependent on miners. These miners produce the cryptocurrency and are rewarded with a block reward for mining the block. In a proof-of-work system, the miner must solve a complicated problem in order to mine the block. As opposed to proof-of-stake, in which miners receive a block reward in the form of transaction fees. There are some problems associated with that, a project will now have a single point of failure and the block is based on a stake, not on merit. Bitcoin, however, relies on computational power and incentivizes miners to solve the problem to get the reward. Another problem with proof-of-stake is that the projects are based on stake, so poorer nations might not be able to participate due to high transaction fees. Proof-of-work coins rely on computational power rather than a stake. The problem associated with proof-of-work is a 51 attack, in which if a computer has more computational power than the other nodes it can take over the network. With computational power, as more people get onto the network, the more difficult it becomes to execute a 51-49 attack.
Representational State Transfer (REST)
Published: 2022-10-11 21:21:37


Architectural style created by Roy Fielding

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


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

You can disable the wrap parameters feature in an individual controller:


```
class BirdsController < ApplicationController
  wrap_parameters format: []
end
```

You can also disable it for all controllers if you like, by going into the config/initializers/wrap_parameters.rb file and updating it like so:

```

ActiveSupport.on_load(:action_controller) do
  wrap_parameters format: []
end
```
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2022-10-11 21:11:13

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---
Every Monday we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week. ❤️
 
## 15 GitHub Repos Open for Hacktoberfest

Hacktoberfest is a yearly festival celebrating open source. Thanks to @atapas for gathering 15 different GitHub repositories that you can contribute to during this event!

{% embed https://dev.to/atapas/15-github-repositories-to-contribute-for-hacktoberfest-2022-215d %}

## How a Hacker Stole $556m

One of the larger blockchains, BNB Chain, had to be halted on Oct 7th, 2022. This is shocking because blockchains are meant to be decentralized. Here are more details on what happened from @mcsee.

{% embed https://dev.to/mcsee/how-a-hacker-stole-566m-usd-exploiting-a-code-smell-2fkn %}


## Understanding Async/Await

Async/Await can be daunting, but with the right approach anyone can write modern asynchronous code that works. Here’s some guidance from @maximization.

{% embed https://dev.to/maximization/understanding-async-await-22o6 %}


## Turn your Git Mistakes Around

Mistakes are inevitable, so what can we do to turn them into something valuable? @smitterhane shows us how Git can be an excellent safety net to give you another chance when you make the wrong move.

{% embed https://dev.to/smitterhane/turn-around-your-git-mistakes-in-17-ways-2mn1 %}


## TypeScript Validator Library but 1,000x Faster

This DEV user made a TypeScript library that turned out to be a thousand times faster than zod in a benchmark test. Take a look at the details in this article by the author, @samchon.

{% embed https://dev.to/samchon/typescript-json-is-10-1000x-times-faster-than-zod-and-io-ts-8n6 %}


## :where :is CSS?

In this post, @mustapha will talk about the functional pseudo-class selectors :is() and :where(). Let’s take a look at how we can get the most out of these features!

{% embed https://dev.to/mustapha/where-is-css-20nk %}


## React Image Search Engine

@franklin030601 talks about making an image search engine with the help of Unsplash API and React Query. If you want to try it yourself, knowing some basic hooks will really help in seeing this project through. 

{% embed https://dev.to/franklin030601/image-search-engine-with-react-js-react-query-39 %}

_That's it for our weekly wrap up! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Monday!_
If( a==1 && a==2&&a==3 ) is equal to true under what circumstances?
Tags: javascript, interview
Published: 2022-10-11 21:03:59

#### `Object.defineProperty()`

```js
//Using the principle of data hijacking, ES6 proxy can also be implemented
let bValue = 1;
Object.defineProperty(window, "a", {
  get() { return bValue++; }
});

if(a == 1 && a == 2 && a == 3) {
  console.log("Hello World!");
}
```

#### `Proxy`

```js
let test = {
  number: 1
};
test = new Proxy(test, {
  get(target, key) {
    return target[key]++;
  }
});
if(test.number === 1 && test.number ===2 && test.number ===3){
    console.log('Hello World!');
}
```

#### `Object.toString()`

```js
let a = [1, 2, 3];
//Use the array method shift to override toString, take the first element of the array and return
a.toString = a.shift;

if (a == 1 && a == 2 && a == 3) {
  console.log("Hello World!");
}

//Override toString method
let a = {
    bValue: 1,
    toString: ()=> {
        return a.bValue++;
    }
}

if (a == 1 && a == 2 && a == 3) {
  console.log("Hello World!");
}
```

#### `Object.valueOf()`

```js
let a = [1, 2, 3];
//Use the array method shift to override valueOf, take the first element of the array and return
a.valueOf = a.shift;

if (a == 1 && a == 2 && a == 3) {
  console.log("Hello World!");
}

/ **
* Override valueOf method
*/

let a = {
    bValue: 1,
    valueOf: ()=> {
        return a.bValue++
    }
};

if (a == 1 && a == 2 && a == 3) {
  console.log("Hello World!");
}
```
Create-react-app or Vite ?
Tags: discuss, react, productivity, javascript
Published: 2022-10-11 20:47:34

Hey there,

I am not too familiar with vite but I've explored a bit and as of today there are many developers promoting the use of vite instead of create-react-app to build React projects.
The main argument in favor of vite is that it is blazing fast compared to CRA.
I feel more and more concerned by the growing adoption of vite instead of CRA since I'm building [Reactirator](https://github.com/Leopold-V/Reactirator) and I consider to add support for vite and maybe choose it as the default choice.

In order to take the best possible choice, I'm questionning the community.
So what is your preference, vite or Create-react-app ? Whats are the reasons ?

Thanks a lot by advance to people engaging in this discussion!

Have a good day.
Do you know about bfcache?
Tags: frontend, webdev
Published: 2022-10-11 20:31:34

Backward/forward cache is the optimization which enables faster backward & forward webpages for browsers. It saves them as "in-memory cache" in browsers which stores complete page as snapshots and serves them to the user when they move forward & backward. Cool right ?

Now what is in-memory cache ?

In-memory cache stays until you close browser (Rmbr RAM ?). The other one is called as "Disk cache" which won't be destroyed (ROM).
Rocket and web components
Tags: webdev, webcomponents
Published: 2022-10-11 20:22:01

[Rocket](https://rocket.modern-web.dev) is a tool used for creating web pages and it is fabulous for generating static content starting from markdown files. One of the cool thing about Rocket is the fact that web components and javascript can be used inside the markdown files.
​
Creating a project with Rocket is quite straightforward, you can take a look at the [documentation](https://rocket.modern-web.dev/docs/) or if you like to learn by looking at examples, you can find good ones in the [Rocket’s GitHub repository](https://github.com/modernweb-dev/rocket/tree/main/examples) .
​
This guide is created for getting you started with Rocket and [FicusJS](https://docs.ficusjs.org/). FicusJS is a set of lightweight functions for developing applications using web components.
​
Using the [Create Ficus App](https://github.com/ficusjs/create-ficus-app) CLI you can quickly scaffold a project that contains a basic structure for working with Rocket and FicusJS.
​
The project will contain:
- Rocket development set-up
* FicusJS web components
* Unit testing with  [Ava and JSDom](https://dev.to/ficusjs/unit-testing-web-components-with-ava-and-jsdom-2ofp).


## Getting Started
​
Create Ficus App lets you focus on code, not build tools. It also gives you an idea of how you should structure your project, which can be useful if this is the first time that you are using Rocket or FicusJS.
​
To create a new project called “my-app”, run this command:
​
```bash
npx create-ficus-app my-app
```
​
Using the arrow keys, select “rocket-app” and then press enter. Once the `my-app` folder is created, you can install the dependencies and start the project with the following commands:
​
```bash
cd  my-app
​
# install the dependencies using npm or yarn
npm install
yarn
​
# start the project
npm run dev
```
​
## Starter Projects
​
If you ran the previous commands you probably noticed that Create Ficus App offers a selection of starter projects:
​
* Basic app - a simple, single HTML page with inline scripts
* [11ty](https://www.11ty.dev/)  app - a Jamstack site based on 11ty - you can take a look at [our previous post](https://dev.to/ficusjs/11ty-and-web-components-an-awesome-combination-4li7)
* [Vite](https://vitejs.dev/) app - a single HTML page with Vite configuration
* [Snowpack](https://www.snowpack.dev) app - a single HTML page with Snowpack configuration
* [Rocket](https://rocket.modern-web.dev/) app - a Jamstack site based on Rocket.
​

More projects are in development and will come soon!
​

## Summary
​
Having a simple tool like Create Ficus App can save a lot of time when creating new projects. It gives you a headstart and allows you to incrementally add new tools and features as your project grows.
If you have any feedback on the tool, or want to suggest new integrations between FicusJS and existing tools and framework, please visit the [Github repo](https://github.com/ficusjs/create-ficus-app).
Polymorphism
Tags: python, polymorphism, webdev, beginners
Published: 2022-10-11 20:21:03

## Polymorphism Explained

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

Coding interviews use technical jargon for what is simply implementing the self-init function(def __init__(self)) or calling the same name with different signatures. The image above portrays a simple implementation of polymorphism within a class-based component. Here, we are calling into the class “Bitcoin” to obtain a {name}, {price}, {time}, and {date} using self.{}. After we ‘pass’ in the function, we call 4 variables of “b1”, “b2”, “b3”, 
and “b4”. Finally, we print our four variables called to our above function values.
EX 2.
``
class BitcoinCharacteristics():
 def currency(self):
   print("Cryptocurrency")
 def verification(self):
   print("POW")
class ETHCharacteristics(): 
 def currency(self):
   print("Cryptocurrency")
 def verification(self):
   print("POS")

obj_btc = BitcoinCharacteristics()
obj_eth = ETHCharacteristics()
for char in (obj_btc, obj_eth):
   char.currency()
   char.verification()
``
Polymorphism can also work with two classes, like the one above. Instead of self-calling values, define each value in a print statement within a self-function. Below it, the “obj_btc” and “obj_eth” variables are equal to the class method above. A for loop will loop through our values for both Ethereum and Bitcoin. Notice how this implementation worked similarly to the first, a loop would not be necessary for one class of values, no matter the size.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wcpzjil6r2lbwaxzi689.png
)
Finally, let’s use inheritance so that our Bitcoin class can implement a subclass for Layer-2 Network Lightning. Inheritance in Python is when a subclass inherits from a parent class. Our subclass (Lightning_present) calls from the parent class(Lightning_past) via its “nodes” value. If we wanted, we could have multiple subclasses inherited from our parents. The major benefit of polymorphism is the ability to work with multiple data types efficiently.
React Course Overview
Tags: react, node, beginners
Published: 2022-10-11 20:07:15

## React Course Overview and Outline
{% embed https://www.youtube.com/watch?v=pnlQAwWwgx0&feature=youtu.be %}

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5xg278v58iwdnk7gkdto.png)
Obfuscate .NET Strings then hide them into Cloud
Tags: dotnet, obfuscate, programming, tutorial
Published: 2022-10-11 19:57:56

Strings are vital code parts. It makes sense to store them in a separate location away from a distributed assembly. Skater puts the protected Strings somewhere in a cloud. This Skater’s option protects algorithms by encoding Strings and store them into a virtual cloud Vault. Maybe that technic can be reverse engineered but it is a very tough job. Plus, Strings are encrypt-protected in the Vault.
[Read more on LinkedIn](https://www.linkedin.com/pulse/protect-net-string-values-hiding-them-virtual-cloud-net-obfuscator/)
Python Course Overview
Tags: python, datascience, beginners, webdev
Published: 2022-10-11 19:53:09

## Python Course Overview
{% embed https://www.youtube.com/watch?v=3MUs-Aaakdg&t=3313s %}
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xii4vt44e350ok1wa7b3.png)
C++ Course Overview
Tags: cpp, beginners, programming, webdev
Published: 2022-10-11 19:47:23

C++ Course Overview
{% embed https://www.youtube.com/watch?v=pheC-eH8o24 %}

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4kc9nbmujxsxwkxeiwg.PNG)
Elixir & Phoenix Fundamentals Full Course For Beginners
Tags: elixir, programming, tutorial, webdev
Published: 2022-10-11 19:46:51

&nbsp;
&nbsp;

{% youtube gRQIPvDFuts %}

&nbsp;
&nbsp;


Learn the functional programming language Elixir, and how to build web applications with the Phoenix framework from scratch with this free video crash course. In this one video course, we will get introduced to the Elixir ecosystem, then we will build 2 real-world web applications with the Phoenix web development framework.

Topics covered on the video course:

### What is Elixir

A quick introduction and history of the Elixir functional programming language.

### Why build web applications with Elixir & Phoenix

Benefits of the language, and why the Phoenix web development framework is a great choice.

### Who Am I

A quick introduction of the instructor.

### Elixir Basics

We go over the fundamentals of the Elixir functional programming language. We go over data types, operators, pattern matching, conditionals, anonymous functions, modules, functions, the pipe operator.

### Password Generator Module Project

We build a fully tested passwords generator module.

### Phoenix Framework Basics

We go over the basics of the phoenix web development framework, like the directory structure of a project, routing, controllers, views and templates, databases.

### Phoenix Password Generator Web App Project

We build a real-world password generator web application with the phoenix framework.

### Phoenix Todo Web App Project

We build a fully-featured todo list web application with the phoenix framework.


&nbsp;
&nbsp;


[![Join The Elixir Army](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cv2q172ztuekdtw82vo9.png)](https://elixirprogrammer.com)
Bitcoin Role in Money
Tags: blockchain, bitcoin, beginners
Published: 2022-10-11 19:41:07

## Bitcoin Overview and History of Money
{% embed https://www.youtube.com/watch?v=qF5xkoZxG2A&t=489s %}

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