teleren/devto huggingface dataset:
Bật mí 3 cách tự chế máy lọc không khí ĐỘC ĐÁO tại nhà
Published: 2023-11-18 04:57:46

Nếu bạn chưa đầu tư vào một chiếc máy lọc không khí hiện đại, hãy thử áp dụng ba phương pháp tự chế máy lọc không khí độc đáo từ Chiêm Tài Mobile để nâng cao chất lượng không khí tại gia một cách tiết kiệm và hiệu quả.
Thông tin chi tiết: https://chiemtaimobile.vn/tin-cong-nghe/cach-tu-che-may-loc-khong-khi/
Trên đây là 3 cách tự chế máy lọc không khí tại nhà mà Chiêm Tài Mobile muốn chia sẻ với bạn. Chúc bạn thực hiện thành công. Hiện nay, Chiêm Tài Mobile cung cấp các sản phẩm máy lọc không khí Xiaomi và các thiết bị Xiaomi chính hãng với các ưu đãi đặc biệt. Nếu bạn quan tâm hoặc cần thêm thông tin, xin vui lòng liên hệ qua số hotline 19002667 để được hỗ trợ nhanh chóng!
Building a Next.js 14 E-Commerce Cart with Persistent State Using Zustand
Published: 2023-11-18 04:43:47

import { create } from 'zustand'
import { persist } from "zustand/middleware";

const useCartStore = create(persist((set, get) => ({
  cartItems: [],
  cartTotalQuantity: 0,
  cartTotalAmount: 0,

`ADD TO CART`

  addToCart: (payload) => {
    const cart = get().cartItems
    const cartItem = cart.find(item => item._id === payload._id)

    if (cartItem) {
      const updatedCart = cart.map(item =>
        item._id === payload._id ? { ...item, cartQuantity: (item.cartQuantity) + 1 } : item
      )
      set(state => ({
        cartItems: updatedCart,
        cartTotalQuantity: state.cartTotalQuantity + 1,
        cartTotalAmount: state.cartTotalAmount + payload.price,
      }))
    } else {
      const updatedCart = [...cart, { ...payload, cartQuantity: 1 }]

      set(state => ({
        cartItems: updatedCart,
        cartTotalQuantity: state.cartTotalQuantity + 1,
        cartTotalAmount: state.cartTotalAmount + payload.price,
      }))
    }
  },

`REMOVE FROM CART`

  removeFromCart: (payload) => {
    const cart = get().cartItems;
    const updatedCart = cart.filter((item) => item._id !== payload._id);

    set((state) => ({
      ...state,
      cartItems: updatedCart,
      cartTotalQuantity: state.cartTotalQuantity - 1,
      cartTotalAmount: state.cartTotalAmount - (payload.price * payload.cartQuantity),
    }));
  },


`DECREMENT CART`

  decreaseCart: (payload) => {
    const cart = get().cartItems;
    let updatedCart = [...cart];

    const itemIndex = updatedCart.findIndex((item) => item._id === payload._id);
    if (updatedCart[itemIndex].cartQuantity > 1) {
      updatedCart[itemIndex].cartQuantity -= 1;
    } else {
      updatedCart = updatedCart.filter((item) => item._id !== payload._id);
    }

    set((state) => ({
      cartItems: updatedCart,
      cartTotalQuantity: state.cartTotalQuantity - 1,
      cartTotalAmount: state.cartTotalAmount - payload.price,
    }));
  },

`INCREMENT CART`
  incrementCart: (payload) => {
    const cart = get().cartItems;
    let updatedCart = [...cart];

    const productIndex = updatedCart.findIndex((item) => item._id === payload._id);
    if (productIndex >= 0) {
      updatedCart[productIndex] = {
        ...updatedCart[productIndex],
        cartQuantity: updatedCart[productIndex].cartQuantity + 1,
      };
    } else {
      updatedCart = [...updatedCart, { ...payload, cartQuantity: 1 }];
    }

    set((state) => ({
      ...state,
      cartItems: updatedCart,
    }));
  },

`CLEAR CART`
  clearCart: () => {
    set({
      cartItems: [],
      cartTotalQuantity: 0,
      cartTotalAmount: 0,
    });
  },
}),
  {
    name: 'cart'
  }
));

export default useCartStore;
Adding a Continuous Integration Workflow
Published: 2023-11-18 04:37:03

For this week in [Topics in Open Source Development](https://github.com/Seneca-CDOT/topics-in-open-source-2023) we were tasked with adding continuous integration tests into an existing project. The project that I will be enhancing is [til-to-html](https://github.com/paulkim26/til-to-html) - a markdown to static HTML site generator.
## Bun CI Workflow

[Last week](https://dev.to/paulkim26/writing-tests-30a1), I added automated unit tests to my project. This time, I will add a CI workflow

Up until now, whenever code was merged into the main branch, it was up to the maintainer (me) to manually run tests on incoming code. Now, a workflow will be triggered when anyone attempts to push to or create a pull request to be merged onto the main branch. As this is a [Bun.sh](https://bun.sh/) application, I followed the [official setup guide](https://bun.sh/guides/runtime/cicd) to run Bun in GitHub Actions.

The workflow file I created does the following:

- Whenever someone:
	- pushes to the main branch, or
	- creates a pull request for the main branch…
- GitHub Actions will run a job that:
	- installs Bun using Bun's official [setup-bun](https://github.com/oven-sh/setup-bun) routine
	- uses the latest version of bun
	- installs all package dependencies
	- runs a build
	- runs all unit tests

If any of these steps fail, the push/pull request is rejected.

Bun CI Workflow: https://github.com/paulkim26/til-to-html/blob/main/.github/workflows/bun.yml

## Adding tests to a partner's project

(coming soon)

## Takeaways

This is the first time I incorporated an automatic CI testing workflow into a project. I enjoyed how straightforward and well documented the process was. Adding a CI workflow alleviates a lot of anxiety when it comes to integrating code not just from other developers, but from me as well. These are all checks and balances I would have had to worry and remember to execute myself - there's no reason **not** to automate these trivial tasks.

Thanks for reading!
What do you think of the Sam's removal from OpenAI?
Tags: discuss, openai, chatgpt, programming
Published: 2023-11-18 03:43:09

Quoting from The Verge, Sam Altman has been fired as CEO of OpenAI, the company announced on Friday.

“Mr. Altman’s departure follows a deliberative review process by the board, which concluded that he was not consistently candid in his communications with the board, hindering its ability to exercise its responsibilities,” the company said in its blog post. “The board no longer has confidence in his ability to continue leading OpenAI.”
Github Actions & CI
Published: 2023-11-18 03:41:33

## CI Workflow

This week I worked on adding a CI workflow to my project through Github actions. The set up was easy:

- I selected a new workflow from the "Actions" section in my repo:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q2qlvhpqibasirtqd8h1.png)
- Searched for and selected the .NET workflow:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0g49t1oyjhquipid450.png)
- I edited the template YAML file to work with my project files:
```yaml
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 6.0.x
    - name: Restore dependencies
      run: dotnet restore ./Text2StaticHtml/Text2StaticHtml.sln
    - name: Build
      run: dotnet build ./Text2StaticHtml/Text2StaticHtml.sln --no-restore
    - name: Test
      run: dotnet test ./Text2StaticHtml/Text2StaticHtmlNunitTest/Text2StaticHtmlNunitTest.csproj --no-build --verbosity normal
```
- Committed the YAML file to my repo.

## Testing CI Workflow

After adding the CI workflow, I added new test cases for my project to make sure that the workflow got triggered on push and pull request. Then, I made a faulty logic change to intentionally fail a test during the workflow and fixed the faulty logic after I saw that the CI action failed as a result of the faulty logic. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phmbmrr1qkecgadbxf4a.png)
So, after I was satisfied that the workflow worked, I merged the changes.

## Adding To a Friend's Project

I also added a new test case to my friend's project to make sure that his CI workflow worked as well. Since, his project is written in Python he is using Pytest as a testing framework. Because his testing setup is similar to mine, adding a new test case was very simple. I implemented a new test case to check for non-existent file inputs after I asked my friend if there was a specific test case that he wanted me to add to improve his test coverage. The PR for the changes I made can be found [here](https://github.com/Namatuzio/tiller/pull/24).

## What I Learned

I learned how to setup a CI workflow through Github actions. I can see why a CI workflow is so important, it allows for the automatic building and testing of the project whenever changes are made. I will definitely add CI workflows to my future projects to make my life easier specially with automatic testing.
Security in Angular
Tags: angular, security
Published: 2023-11-18 03:24:00


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

[Angular Official Docs](https://angular.dev/guide/security/) are pretty great! - Security in Angular is important!

Things we should remember:

🔐 Best Practices
➖ Stay updated with Angular library releases.
➖ Avoid altering Angular core
➖ Steer clear of APIs marked "Security Risk".

🔐 XSS Prevention
➖ Block malicious code entry to DOM.
➖ Angular treats all values as untrusted by default.
➖ Sanitizes values inserted into DOM from templates.
➖ Templates are trusted; avoid creating them with user input.

🔐 Sanitization and Security Contexts
➖ Angular sanitizes values for HTML, styles, and URLs.
➖ Context-specific: HTML, Style, URL, Resource URL.
➖ Development mode warnings for sanitization changes.

🔐 Direct DOM API Use & Explicit Sanitization
➖ Use Angular templates over direct DOM interaction.
➖ For unavoidable cases, use Angular sanitization functions.

🔐 Trusting Safe Values
➖ Use DomSanitizer for necessary executable code or URLs.
➖ Context-specific methods like bypassSecurityTrustHtml.

🔐 Content Security Policy (CSP)
➖ Prevents XSS via web server configuration.
➖ Requires unique per-request nonces for Angular to render styles.

🔐 Enforcing Trusted Types
Use HTTP headers with one of the following Angular Policies:
➖ angular
➖ angular#unsafe-bypass
➖ angular#unsafe-jit
➖ angular#bundler

🔐 Server-side XSS Protection
➖ Avoid creating Angular templates on the server side.
➖ Use templating languages that auto-escape values.

🔐 HTTP-level Vulnerabilities
➖ Built-in support for CSRF/XSRF and XSSI.
➖ Cooperate server and client for anti-XSRF technique.

🔐 Auditing Angular Applications
➖ Follow regular web app security principles.
➖ Audit Angular-specific APIs marked as sensitive.

A more in-depth look can be found in Docs:
[angular.dev/guide/security](angular.dev/guide/security)

---

Let's get connected! You can find me on:
- Medium: [https://medium.com/@nhannguyendevjs](https://medium.com/@nhannguyendevjs)
- dev.to: [https://dev.to/nhannguyendevjs](https://dev.to/nhannguyendevjs)
- Linkedin: [https://www.linkedin.com/in/nhannguyendevjs/](https://www.linkedin.com/in/nhannguyendevjs/)
- X (formerly Twitter): [https://twitter.com/nhannguyendevjs](https://twitter.com/nhannguyendevjs)
VSCode Tunnels from inside Docker
Tags: docker, vscode, linux, remote
Published: 2023-11-18 03:00:04

When it comes to my system, everything gets put into docker containers for easy to destroy environments when they are no longer needed. I have always hated bloating up my main workstation with packages and dependencies for projects that are only going to last me a few weeks. That is why I set out to find a way to run vscode in a lightweight style from docker.

I stumbled upon an [existing project (https://github.com/alexanderdna/container-tunnel)](https://github.com/alexanderdna/container-tunnel) which had what I needed, but achieved this using the tunnels feature, VSCode's new way of remote development. You can access your tunnel from the VSCode editor or event [vscode.dev](https://vscode.dev) website.

I forked this project and was able to clean it up a bit and published it publicly under [domkalan/vscode-tunnel](https://github.com/domkalan/vscode-tunnel) on GitHub. The Docker image is based on Debian Bookworm which is the latest Debian version as of publishing.

### Try it yourself

For more information, view the project’s GitHub page with detailed setup instructions. Or, get started by running this on your server with Docker installed:

```bash
docker run -d --name vscode-tunnel \
-v /opt/vscode/projects:/home/workspace 
--network host --restart always --workdir /home/workspace \
domkalan/vscode-tunnel:latest
```

Once the container is running, you will need to register the tunnel to your GitHub account. View the logs from tunnel to view the steps on how to register.

```bash
docker logs vscode-tunnel
```

You should see something like this in your terminal.

```text
*
* Visual Studio Code Server
*
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*

[2023-11-07 23:53:58] info Using Github for authentication, run `code tunnel user login --provider <provider>` option to change this.
To grant access to the server, please log into https://github.com/login/device and use code XXXX-0000
[2023-11-07 23:56:56] info Creating tunnel with the name: vscode-tunnel

```
Onpipeline - Cloud-based sales CRM software
Tags: crm, salesforce
Published: 2023-11-18 02:46:33

Onpipeline is a powerful cloud-based CRM solution that empowers you to effortlessly manage leads, customers, deals, activities, and your complete sales process from any location.

With Onpipeline, you can seamlessly create price quotes and invoices, streamlining your financial operations. Our platform offers a comprehensive set of features that cater to all your sales CRM needs, combined with exceptional service standards, ensuring you have the support and tools necessary for success in sales and customer relationship management.

[https://www.onpipeline.com](https://www.onpipeline.com)
Fridge Repair in Delhi
Tags: fridggerepairindelhi, refurbishing, repair
Published: 2023-11-18 02:39:26

Are you in need of professional [Fridge repair in Delhi](https://fridgerepairindelhi.com/)? Look no further as we provide the most reliable and efficient fridge repair services in town. Our team of skilled technicians is dedicated to resolving any issues you might face with your refrigerator.

We understand the inconvenience that a malfunctioning fridge can cause, especially in today's fast-paced lifestyle. Therefore, we strive to provide prompt and efficient services to ensure minimum downtime for our clients. Our technicians possess extensive knowledge and experience in repairing all major brands and models of refrigerators, ensuring that your appliance is in safe hands.

Whether your fridge is not cooling properly, making unusual noises, or experiencing any other problem, our team will thoroughly diagnose the issue and provide the best possible solution. We prioritize customer satisfaction and always strive to exceed your expectations. We believe in transparency; therefore, before any repair work, our technicians will provide a detailed explanation of the problem and a cost estimate.

We understand the value of your time, which is why we offer timely and convenient services. Our technicians will arrive at your doorstep at the scheduled time, equipped with all the necessary tools and replacement parts to ensure a quick and efficient repair. They will also provide useful tips and guidelines to help you maintain your fridge properly, preventing future breakdowns.

As a trusted fridge repairing service in Delhi, we take pride in our excellent customer support. Our friendly and knowledgeable staff is available to address any queries or concerns you may have regarding our services. We believe in building long-term relationships with our clients based on trust, reliability, and quality workmanship.

So, if you're looking for professional fridge repair services in Delhi, look no further. Contact us today to book an appointment, and our team will ensure that your fridge is up and running smoothly in no time.
How can I modify or remove the PasswordHash class in XenForo to change the encryption algorithm?
Tags: hash, php, password, xenforo
Published: 2023-11-18 02:11:23

**Estoy utilizando XenForo [2.2.13]. Actualmente, la clase PasswordHash maneja la generación y verificación de contraseñas mediante un algoritmo personalizado y lo que quiero hacer es modificar esa clase para cambiar o eliminar el algoritmo de cifrado, pero la verdad es que no sé cómo hacer esto. Les agradecería mucho si me ayudaran con esto.******

`function gensalt_blowfish($input)
{
    # This one needs to use a different order of characters and a
    # different encoding scheme from the one in encode64() above.
    # We care because the last character in our encoded string will
    # only represent 2 bits.  While two known implementations of
    # bcrypt will happily accept and correct a salt string which
    # has the 4 unused bits set to non-zero, we do not want to take
    # chances and we also do not want to waste an additional byte
    # of entropy.
    $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

    $output = '$2a$';
    $output .= chr(ord('0') + $this->iteration_count_log2 / 10);
    $output .= chr(ord('0') + $this->iteration_count_log2 % 10);
    $output .= '$';

    $i = 0;
    do {
        $c1 = ord($input[$i++]);
        $output .= $itoa64[$c1 >> 2];
        $c1 = ($c1 & 0x03) << 4;
        if ($i >= 16) {
            $output .= $itoa64[$c1];
            break;
        }

        $c2 = ord($input[$i++]);
        $c1 |= $c2 >> 4;
        $output .= $itoa64[$c1];
        $c1 = ($c2 & 0x0f) << 2;

        $c2 = ord($input[$i++]);
        $c1 |= $c2 >> 6;
        $output .= $itoa64[$c1];
        $output .= $itoa64[$c2 & 0x3f];
    } while (1);

    return $output;
}

function HashPassword($password)
{
    $random = '';

    if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
        $random = $this->get_random_bytes(16);
        $hash = $this->gensalt_blowfish($random);
        return $this->crypt_private($password, $hash);
    }

    if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
        $random = $this->get_random_bytes(3);
        $hash = $this->gensalt_extended($random);
        return $this->crypt_private($password, $hash);
    }

    $random = $this->get_random_bytes(6);
    $hash = $this->gensalt_private($random);

    return $this->crypt_private($password, $hash);
}

function CheckPassword($password, $stored_hash)
{
    $hash = $this->crypt_private($password, $stored_hash);

    return hash_equals($stored_hash, $hash);
}

public function reverseItoA64($char)
{
    return strpos($this->itoa64, $char);
}`
What is the data science?And Why it is important ?
Tags: datascience, data, community, dataset
Published: 2023-11-18 02:10:58

📊📈📉

**_The data science:_**
 is a collection of techniques used to extract value from data.

it is rely on finding useful patterns, connections and relationship within data. 
Utilizes certain specialized computational methods in order to discover meaningful and useful
structures within a dataset. and is closely associated with a number of related areas
such as database systems, data engineering, visualization, data analysis,
experimentation, and business intelligence (BI).
Data science involves inference and iteration of many different hypotheses.
One of the key aspects of data science is the process of generalization of patterns
from a dataset.
One of the goals of data science is
finding previously unknown patterns in data.

_**Source**_: From the Data science concept and practice book .


According to what we read, 
we are supposed to know the primary goal, which is to analyze and extract value from data, that is, to find hidden relationships in a large set of data. Suppose that we, as a company, are launching a specific product. With the help of data science, I can explore the users information and based on that I can launch marketing campaigns and understand customers’ needs based on the evidence and patterns extracted from the data. This is a simple example without going into any details of the process.


If you have any additional information, please write it in the comment.🫱🏼‍🫲🏽
How can I modify or remove the PasswordHash class in XenForo to change the encryption algorithm?
Tags: php, hash, xenforo, passwordhash
Published: 2023-11-18 02:05:49

I am using XenForo [2.2.13]. Currently, the PasswordHash class handles password generation and verification using a custom algorithm and what I want to do is to modify that class to change or remove the encryption algorithm, but I really don't know how to do this. I would be very grateful if you could help me with this.
`function gensalt_blowfish($input)
{
    # This one needs to use a different order of characters and a
    # different encoding scheme from the one in encode64() above.
    # We care because the last character in our encoded string will
    # only represent 2 bits.  While two known implementations of
    # bcrypt will happily accept and correct a salt string which
    # has the 4 unused bits set to non-zero, we do not want to take
    # chances and we also do not want to waste an additional byte
    # of entropy.
    $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

    $output = '$2a$';
    $output .= chr(ord('0') + $this->iteration_count_log2 / 10);
    $output .= chr(ord('0') + $this->iteration_count_log2 % 10);
    $output .= '$';

    $i = 0;
    do {
        $c1 = ord($input[$i++]);
        $output .= $itoa64[$c1 >> 2];
        $c1 = ($c1 & 0x03) << 4;
        if ($i >= 16) {
            $output .= $itoa64[$c1];
            break;
        }

        $c2 = ord($input[$i++]);
        $c1 |= $c2 >> 4;
        $output .= $itoa64[$c1];
        $c1 = ($c2 & 0x0f) << 2;

        $c2 = ord($input[$i++]);
        $c1 |= $c2 >> 6;
        $output .= $itoa64[$c1];
        $output .= $itoa64[$c2 & 0x3f];
    } while (1);

    return $output;
}

function HashPassword($password)
{
    $random = '';

    if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
        $random = $this->get_random_bytes(16);
        $hash = $this->gensalt_blowfish($random);
        return $this->crypt_private($password, $hash);
    }

    if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
        $random = $this->get_random_bytes(3);
        $hash = $this->gensalt_extended($random);
        return $this->crypt_private($password, $hash);
    }

    $random = $this->get_random_bytes(6);
    $hash = $this->gensalt_private($random);

    return $this->crypt_private($password, $hash);
}

function CheckPassword($password, $stored_hash)
{
    $hash = $this->crypt_private($password, $stored_hash);

    return hash_equals($stored_hash, $hash);
}

public function reverseItoA64($char)
{
    return strpos($this->itoa64, $char);
}``
The Work-Sanity Paradox
Tags: nontech
Published: 2023-11-18 01:36:44

The quest for logical reasoning can, at times, plunge individuals into an existential crisis, prompting a divergence from what is commonly perceived as "meaningful work" in the tangible realm. 

In contemplating the intricacies of reason, one may find oneself at odds with the conventional understanding of purpose and significance. This divergence may lead to a realization that pursuits widely acknowledged as "great work" in the physical world are often borne out of a deliberate narrowing of focus—an intentional retreat into the realm of vanity. 

The paradox arises as the pursuit of logical coherence and depth may inadvertently distance one from the pragmatic and meaningful endeavors that define success in the material world. 

It is within this nuanced interplay of thought that the tension between abstract reasoning and tangible achievement manifests, beckoning individuals to navigate the delicate balance between intellectual exploration and the pursuit of impactful, real-world contributions.

(Text generated using ChatGPT)