teleren/devto huggingface dataset:
Code Pet Peeves: What's Yours?
Tags: discuss
Published: 2023-09-06 07:00:00

_Welcome to Code Chatter, your go-to series for conversational coding insights. What makes this series of questions different from all the others? Well, truth be told, not much, but they're still thought-provoking and fun. Join us as we explore the coding world, one witty question at a time._

> What's your secret 'code pet peeve' that, while not critical, drives you crazy?

Follow the DEVteam for more discussions and online camaraderie!

{% embed [https://dev.to/devteam](https://dev.to/devteam) %}
What's the Typical Tech Industry Job Tenure?
Tags: discuss, beginners, codenewbie, career
Published: 2023-09-06 07:00:00

_Get a glimpse into the daily experiences, work routines, and unique perspectives of tech professionals, both novice and experienced alike, in "A Day in the Life."_

> Have you ever wondered: how long do folks in tech typically stay in their roles? How long have you been in your current position and how long do you plan to stay?

Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more discussions and online camaraderie!

*{% embed* https://dev.to/codenewbieteam *%}*
Share Your Proudest UI Element Screenshot!
Tags: discuss, watercooler
Published: 2023-09-06 07:00:00

_Step into our coding showcase series, where you can elevate your projects, exhibit your coding prowess, and collaborate with like-minded developers._

Display a screenshot of a UI element you're proud of.

Follow the DEVteam for more discussions and online camaraderie!

{% embed [https://dev.to/devteam](https://dev.to/devteam) %}
How to install Ghost CMS
Tags: cms, tutorial, beginners, webdev
Published: 2023-09-06 06:47:12

Ghost is a modern content management system - this means that you can host websites with it just like with WordPress. However, since it was only founded in 2013, you can imagine that there are not that many plugins & themes here. But for some themes you have to dig deep into your pocket and sometimes pay more than 100 euros for it.
Today we show you how you can easily install this with one command via Docker.

---
We would appreciate a like :heart and a comment!
Feel free to visit our Ghost page and register for exclusive newsletters to find out everything!
([self-hosted.schächner.de](self-hosted.schächner.de))

---

But to do that, you first need Docker and then Docker-Compose.

```
sudo apt update
sudo apt upgrade
sudo apt install docker.io
sudo apt install docker-compose

```


Then we have to create a docker-compose.yml file – no matter where.sudo nano docker-compose.yml


This contains the following content. Note that the password and username should be changed for security reasons - the port can remain the same.
But what you have to change are the mail settings with which you then send e-mails.

```yml
version: '3.1'

services:

  ghost:
    image: ghost:latest
    restart: always
    ports:
      - 8089:2368
    environment:

      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: Schächner&Tech
      database__connection__database: ghost
      url: http://localhost
      mail__from: "'Schächner' <server@schächner.de>"
      mail__transport: "SMTP"
      mail__options__host: "smtp.strato.de"
      mail__options__port: 587
      mail__options__auth__user: "your-mail"
      mail__options__auth__pass: "your-password"

  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: Schächner&Tech
```


After saving that with ctrl+o and exiting with ctrl+x, we need our actual command:
`sudo docker-compose up -d`

That all starts the container.
If we now wait about 2 minutes and then open our IP address, then you have to specify the port after the IP address:
`XXX.XXX.XXX.XX:8089`


The website should be visible here.
To still be able to access it as an admin, you have to go to the following URL:
`XXX.XXX.XXX.XX:8089/ghost`

Here you create an admin account with which you can then write posts.
Do you have any questions, suggestions or requests?
Feel free to write everything in the comments!
Best regards and see you next time!
Top 10 docker Commands You need To Learn
Tags: docker, devops, newbie, hasanelsherbiny
Published: 2023-09-06 06:43:00

## 1- Docker Run

The docker run command is your gateway to launching containers from Docker images. It allows you to specify image names, options, and runtime configurations.

```
docker run -d -p 8080:80 nginx
```
-d: Run the container in detached mode (in the background).
-p: Map ports from the host to the container.

## 2- Docker Pull
Before running a container, you often need to download the Docker image from a registry like Docker Hub. The docker pull command accomplishes this.

```
docker pull ubuntu:latest
```

## 3- Docker PS
To view the list of running containers, you use the docker ps command. It provides information about container IDs, names, status, and ports. To see all containers, including stopped ones, you can use docker ps -a.

```
docker ps
```

## 4- Docker Stop and Docker Start
These two commands allow you to control the state of a container. docker stop halts a running container, while docker start resumes a stopped one.

```
docker stop {container_name_or_id}
docker start {container_name_or_id}
```

## 5- Docker Logs
The docker logs command is invaluable for troubleshooting and monitoring. It retrieves the logs generated by a container

```
docker logs {container_name_or_id}
```

## 6- Docker Exec
You can execute commands inside a running container using docker exec. This is particularly useful for debugging or running administrative tasks.

```
docker exec -it {container_name_or_id} {bash}
```
-it: Interactive mode with a terminal.
bash: The shell you want to use inside the container.

## 7- Docker Build
When you need to create a custom Docker image, the docker build command is your friend. It uses a Dockerfile to define image instructions.

```
docker build -t custom_image_name .
```

## 8- Docker Images
To list locally available Docker images, use docker images. This command displays image names, sizes, and tags.

```
docker images
```

## 9- Docker RMI
Removing Docker images that are no longer needed frees up disk space. docker rmi allows you to remove images by their name or ID.

```
docker rmi image_name_or_id
```

## 10- Docker Network
Docker provides a networking feature to connect containers and services. The docker network command helps manage these networks.

```
docker network ls
docker network create my_network
```
The Art of Jumping Rope
Tags: beginners, productivity, career, learning
Published: 2023-09-06 06:28:23

A more accurate title would be “The Art of Jumping Rope: a lesson in overcoming your failures”, I guess, but DEV says short and compelling is superior. Have you tried it though? Jumping rope, that is. Not only is it a great, low-impact form of cardiovascular exercise…  Jumping rope teaches you, at the most basic level, how to become comfortable with your personal failures–how to quickly overcome them, and try again.

When you start learning to jump rope, you have to develop a rhythm. This sounds easy …but it’s a sloppy process.
 
**How easy it sounds**: Swing rope, jump rope, swing rope, jump rope, etc etc. No problem! 

**How it be though**: Swing rope, jump rope (WHOO!), swing rope, miss-time jump, hit feet, kill rhythm, fail. Do you curse yourself for your failure? Do you let yourself become frustrated? Negative, triggered reactions like these will only slow down your development and hinder your progress. 

Obviously, we’re working towards a super sick metaphor here. When you fail, fail fast. Forgive yourself, think positive, process the error and let it go, then start again with the knowledge you've gained from the reflection. Each time you start again, aim for more jumps or a longer period of jumping rope without missing a jump. Days, weeks, months, years later… You’re now an advanced jumper of rope; basically a pro! You’ve developed your physical rhythm, increased your endurance, carved up your calves, maybe even learned a few new techniques – Great! No matter how great you become, the occasional failure is inevitable. _And that’s okay._ You may fail for a number of reasons: you’re over-tired, distracted, burned out, toothache (worst). The real test is to remember what your jump rope taught you, Padawan:

Fail fast, be easy on yourself, _reflect and improve_, and go again.

Thanks,
Tim Andes 

PS. I would not recommend jumping rope barefoot unless you really want to feel your failure.
PPS. Prior to beginning a jump rope exercise regimen, it is strongly advised to consult with a qualified physician or healthcare professional to ensure it is safe and appropriate for your individual health and fitness condition.

Photo by <a href="https://unsplash.com/@chichi1813?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Chichi Onyekanne</a> on <a href="https://unsplash.com/photos/mrY3CX8kL0w?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Youtube guides and projects: Do they really contribute to career development?
Tags: discuss
Published: 2023-09-06 06:26:25

Youtube is full of hours-long videos where a developer builds a complete project from A to Z using a specific tech stack. Let's say you follow through with the whole thing from start to finish.

Does that mean you technically have "Experience" in said tech stack now and can add it to your CV? Or is there more to it because you had someone helping you every step of the way?
结构型设计模式-代理 Proxy
Tags: designpatterns
Published: 2023-09-06 06:09:07



### 简介

代理与装饰器很像，都是在原有类基础上，增量做改动。

不同在于，代理模式下，client 直接操作的就是 proxy 对象，new 的就是 proxy 对象，不可以让client 直接操作被代理对象，相当于原始类被完全隐藏掉了。

**类比现实生活，租房代理是不会让客户直接跟房东联系的，客户签合同也是跟代理签，全程没有跟房东交互。**

### 角色

- 基础功能接口 Subject
    
    定义基本动作
    
- 被代理类
    
    实现 Subject 接口，实现业务逻辑
    
- Proxy 代理类
    
    实现 Subject接口
    

### 类图

图中ServiceInterface是基础接口，定义一个operation方法。Service是被代理类，实现了ServiceInterface接口，Proxy是代理类，也实现了ServiceInterface接口。

Proxy类的operation方法做了CheckAccess操作，允许的话再调用被代理类的operation方法。

![类图](https://deb-gmi.oss-cn-beijing.aliyuncs.com/img/20210408234910.png)

### 代码

```php
interface Subject
{
    public function request(): void;
}

class RealSubject implements Subject
{
    public function request(): void
    {
        echo "RealSubject: Handling request.\n";
    }
}

class Proxy implements Subject
{
    private $realSubject;

    public function __construct(RealSubject $realSubject)
    {
        $this->realSubject = $realSubject;
    }

    public function request(): void
    {
        if ($this->checkAccess()) {
            $this->realSubject->request();
            $this->logAccess();
        }
    }

    private function checkAccess(): bool
    {
        echo "Proxy: Checking access prior to firing a real request.\n";

        return true;
    }

    private function logAccess(): void
    {
        echo "Proxy: Logging the time of request.\n";
    }
}

function clientCode(Subject $subject)
{
    $subject->request();
}

echo "Client: Executing the client code with a real subject:\n";
$realSubject = new RealSubject();
clientCode($realSubject);

echo "\n";

echo "Client: Executing the same client code with a proxy:\n";
$proxy = new Proxy($realSubject);
clientCode($proxy);
```

output:

```
Client: Executing the client code with a real subject:
RealSubject: Handling request.

Client: Executing the same client code with a proxy:
Proxy: Checking access prior to firing a real request.
RealSubject: Handling request.
Proxy: Logging the time of request.
```
结构型设计模式-外观 Facade
Tags: designpatterns
Published: 2023-09-06 06:00:41


### 简介

外观模式特点是屏蔽后端复杂的实现逻辑，将其整合成简单的一个或几个接口提供出去，client 只需与 Facade 层提供的简单接口交互即可。

例如银行办业务，后面涉及到很多财务细节，但用户面对的就是一个窗口业务员。

### 角色

- Facade 外观层
- Subsystem 负责具体事务的子系统们

### 类图

![类图](https://deb-gmi.oss-cn-beijing.aliyuncs.com/img/20210408232238.png)

### 代码

```php
class Facade
{
    protected $subsystem1;

    protected $subsystem2;

    public function __construct(
        Subsystem1 $subsystem1 = null,
        Subsystem2 $subsystem2 = null
    ) {
        $this->subsystem1 = $subsystem1 ?: new Subsystem1();
        $this->subsystem2 = $subsystem2 ?: new Subsystem2();
    }

    public function operation(): string
    {
        $result = "Facade initializes subsystems:\n";
        $result .= $this->subsystem1->operation1();
        $result .= $this->subsystem2->operation1();
        $result .= "Facade orders subsystems to perform the action:\n";
        $result .= $this->subsystem1->operationN();
        $result .= $this->subsystem2->operationZ();

        return $result;
    }
}

class Subsystem1
{
    public function operation1(): string
    {
        return "Subsystem1: Ready!\n";
    }

    public function operationN(): string
    {
        return "Subsystem1: Go!\n";
    }
}

class Subsystem2
{
    public function operation1(): string
    {
        return "Subsystem2: Get ready!\n";
    }

    public function operationZ(): string
    {
        return "Subsystem2: Fire!\n";
    }
}

function clientCode(Facade $facade)
{
    echo $facade->operation();
}

$subsystem1 = new Subsystem1();
$subsystem2 = new Subsystem2();
$facade = new Facade($subsystem1, $subsystem2);
clientCode($facade);
```

output:

```
Facade initializes subsystems:
Subsystem1: Ready!
Subsystem2: Get ready!
Facade orders subsystems to perform the action:
Subsystem1: Go!
Subsystem2: Fire!
```
结构型设计模式-装饰器 Decorator
Tags: designpatterns
Published: 2023-09-06 05:58:05



### 简介

装饰器模式可以在目标对象原有的基础上，添加其他功能，实现动态增强。

需要明确的是代理模式也有类似的作用，而装饰器模式与代理模式最大的不同在于，装饰器模式下，**对目标对象设置增强的权利交给了 client**，即 client 先要得到目标对象，之后决定要用哪些装饰器给目标对象增强，一层层嵌套。

具体来说比如 Java 的 IO 操作，一般需要先 new 一个目标对象 FileInputStream，之后将其作为参数传给 BufferedInputStream 即可实现有 buffer 增强功能 InputStream。

**装饰器类和被装饰类应该实现同一接口**，这样可以保证被装饰器增强后的类的调用方式与之前一直，且支持无限次装饰调用。

**装饰器是典型的组合优于继承的例子**，试想如果用继承来实现增强的话，每有一个增强项，都需要重写一个类，而支持多种增强项的类则需要继承多次。

### 角色

- Component 接口
    
    定义基本的操作
    
- Decorator 装饰器
    
    实现 Component 接口，增强代码所在
    
- Wrappee/Concrete Component 被装饰的原始类
    
    实现 Component 接口，是被装饰增强的原始类
    

### 类图

图中所示，Component 是共有的接口，Concrete Component 是被装饰的类，Concrete Decorators 装饰器类。装饰器类接收 Component 为参数，execute 方法即增强方法。

![类图](https://deb-gmi.oss-cn-beijing.aliyuncs.com/img/20210408230523.png)

### 代码

```php
interface Component
{
    public function operation(): string;
}

class ConcreteComponent implements Component
{
    public function operation(): string
    {
        return "ConcreteComponent";
    }
}

class Decorator implements Component
{
    protected $component;

    public function __construct(Component $component)
    {
        $this->component = $component;
    }

    public function operation(): string
    {
        return $this->component->operation();
    }
}

class ConcreteDecoratorA extends Decorator
{
    public function operation(): string
    {
        return "ConcreteDecoratorA(" . parent::operation() . ")";
    }
}

class ConcreteDecoratorB extends Decorator
{
    public function operation(): string
    {
        return "ConcreteDecoratorB(" . parent::operation() . ")";
    }
}

function clientCode(Component $component)
{
    echo "RESULT: " . $component->operation() . "\n";
}

$simple = new ConcreteComponent();
echo "Client: I've got a simple component:\n";
clientCode($simple);

echo "\n";

$decorator1 = new ConcreteDecoratorA($simple);
$decorator2 = new ConcreteDecoratorB($decorator1);
echo "Client: Now I've got a decorated component:\n";
clientCode($decorator2);
```

output:

```
Client: I've got a simple component:
RESULT: ConcreteComponent

Client: Now I've got a decorated component:
RESULT: ConcreteDecoratorB(ConcreteDecoratorA(ConcreteComponent))
```
Closure in javascript
Tags: javascript, beginners, programming, tutorial
Published: 2023-09-06 05:51:02

An important topic in JavaScript is the concept of closures. When a function is created, it has access to a reference to all the variables declared around it, also known as it's lexical environment. The combination of the function and its enviroment is called a closure. This is a powerful and often used feature of the language.

```
function createAdder(a) {
  function f(b) {
    const sum = a + b;
    return sum;
  }
  return f;
}
const f = createAdder(3);
console.log(f(4)); // 7
another example
function createAdder(a){
    return function f1(b){
        return function f2(c){
            const sum=a+b+c;
            return sum;
        }
        
    }
}

const f=createAdder(3);
const f1=f(4);
const f2=f1(5)
console.log(f2)//12
```
What is "main" method in Java?
Tags: javascript, java
Published: 2023-09-06 05:37:49

In Java, the "main" method is a critical entry point for executing a Java program. It is a special method that serves as the starting point for the Java Virtual Machine (JVM) to begin program execution. When a Java application is run, the JVM looks for the "main" method and executes the code within it. The "main" method has a specific signature and structure:

```java
public static void main(String[] args) {
    // The program's logic and functionality go here
}
```

Here's a breakdown of the key elements of the "main" method:

- **public:** It is an access modifier that indicates the "main" method is accessible from outside the class.

- **static:** This keyword signifies that the "main" method belongs to the class itself rather than an instance of the class. This is crucial because the JVM needs to call the "main" method without creating an object of the class.

- **void:** The "main" method doesn't return any value. It simply initiates the program's execution.

- **String[] args:** This parameter is an array of strings that can be used to pass command-line arguments to the program. Command-line arguments are useful for customizing the behavior of the program when it is run.

The code inside the "main" method is where the program's logic resides. It can include statements to perform tasks, calculations, and interactions with the user or external resources. The "main" method is where the program begins execution and continues until it reaches the end of the "main" method or encounters a specific exit condition. Apart from it by obtaining [Java Training](https://www.edureka.co/java-j2ee-training-course), you can advance your career in Java. With this course, you can demonstrate your expertise in Core Java & J2EE basic and advanced concepts and popular frameworks like Hibernate, Spring & SOA, many more fundamental concepts, and many more.

In summary, the "main" method in Java is a special function that serves as the entry point for running a Java program. It is where the program's execution begins, and developers can define the core functionality of their Java applications within this method.
Linux Sistemlerde Chroot kullanarak İmaj Dosyalarına Bağlanma
Tags: linux, beginners, tutorial, productivity
Published: 2023-09-06 05:31:15

Ilk önce örnek imaj dosyamızı indiriyoruz.

``` bash
 wget http://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img
```

Sonrasında bu imajı sistemimize mount edip chroot ile bağlanmamız gerekecek. 

Öncelikle mount edebilmemiz için bir dosya yolu belirlelim.

Bunun için mnt altında bir dosya oluşturuyorum.
``` bash
mkdir /mnt/ubuntu
```

Sonrasında aşağıdaki komutu kullanarak img dosyamızı kontrol edebiliriz.

``` bash
sudo file ubuntu-22.04-server-cloudimg-amd64.img
```

``` bash
ubuntu-22.04-server-cloudimg-amd64.img: QEMU QCOW2 Image (v2), 2361393152 bytes
```

Bu çıktıdan imajımızın **qcow** formatında olduğunu çıkarabilriz.

Aşağıdaki komutlarla işlemimize devam edelim.

``` bash
sudo modprobe nbd
```

``` bash
sudo qemu-nbd --connect=/dev/nbd0 ubuntu-22.04-server-cloudimg-amd64.img
``` 

Ve mount edelim

``` bash
sudo mount /dev/nbd0p1 /mnt/ubuntu/
```
Şimdi mount pointimiin içine girip aşağıdaki 

``` bash
cd /mnt/ubuntu
sudo mount --bind /proc proc/
sudo mount --bind /sys sys/
sudo mount --bind /dev dev/
```
chroot ile giriş yapalım
``` bash
sudo chroot .
```

**pwd** komutu ile kontrol ettiğimizde artık /mnt/ubuntu dizininde chroot dediğimizde imaj makinansının kök dizininde olduğumuzu görebiliriz. Ayrıca ls komutu ile de makinanın dosyalarını görebilir. paket kurabilir veya silebiliriz :)

``` bash
pwd
```
```
/
```

``` bash
ls
```
```
root@OpenStack:/# ls
bin  boot  dev  etc  home  lib  lib32  lib64  libx32  lost+found  media  mnt  opt  proc  root  run  sbin  snap  srv  sys  tmp  usr  var
```
Hoisting in javascript
Tags: javascript, hoist, programming, hoisting
Published: 2023-09-06 05:13:08

Hoisting is a features of JavaScript in which we can use any variable or function before initialisation.
for example

```
console.log(x)
x=10
var x
```
same as we can do for function as well.

```
function createFunction(){
return f;
function f(a,b){
return a+b
}
}
const f=createFunction()
console.log(f(3,4)) // 7
```

Please take reference from [here](https://www.freecodecamp.org/news/javascript-let-and-const-hoisting/#:~:text=As%20I've%20explained%20in,a%20default%20initialization%20of%20undefined%20.)
Unleashing the Power of Python for Data Analysis
Tags: python, programming, coding
Published: 2023-09-06 05:05:30

Data analysis and Python go hand in hand. Python's data manipulation and visualization libraries, such as Pandas and Matplotlib, make it a favorite among data scientists and analysts. In this article, we'll explore how Python can be used to analyze and visualize data effectively. From loading datasets to creating insightful plots, you'll learn how Python can transform raw data into actionable insights.
结构型设计模式-适配器 Adapter
Tags: designpatterns
Published: 2023-09-06 05:03:33

# 结构型设计模式-适配器 Adapter

date: April 13, 2021
slug: design-pattern-adapter
status: Published
tags: 设计模式
type: Page

### 简介

适配器模式是一种结构型设计模式， 它能使接口不兼容的对象能够相互合作

### 角色

- Client 接口 / Target 目标接口
    
    用户使用的接口
    
- Adaptee
    
    被适配的对象，原有方法不能直接给 client 使用
    
- Adapter
    
    适配器，实现 Target 接口，将 Adaptee 的方法改造成兼容 client 的形式，供 client使用
    

### 类图

图示，Adapter 持有 Service 对象实例，method 方法实现自 Client Interface，使 client 可以调用，method 内部逻辑则将 client 的入参转换后交给 service 处理

![类图](https://deb-gmi.oss-cn-beijing.aliyuncs.com/img/20210408184306.png)

### 代码

```php
class Target
{
    public function request(): string
    {
        return "Target: The default target's behavior.";
    }
}

class Adaptee
{
    public function specificRequest(): string
    {
        return ".eetpadA eht fo roivaheb laicepS";
    }
}

class Adapter extends Target
{
    private $adaptee;

    public function __construct(Adaptee $adaptee)
    {
        $this->adaptee = $adaptee;
    }

    public function request(): string
    {
        return "Adapter: (TRANSLATED) " . strrev($this->adaptee->specificRequest());
    }
}

function clientCode(Target $target)
{
    echo $target->request();
}

echo "Client: I can work just fine with the Target objects:\n";
$target = new Target();
clientCode($target);

$adaptee = new Adaptee();
echo "Client: The Adaptee class has a weird interface. See, I don't understand it:\n";
echo "Adaptee: " . $adaptee->specificRequest();

echo "Client: But I can work with it via the Adapter:\n";
$adapter = new Adapter($adaptee);
clientCode($adapter);
```

output:

```
Client: I can work just fine with the Target objects:
Target: The default target's behavior.Client: The Adaptee class has a weird interface. See, I don't understand it:
Adaptee: .eetpadA eht fo roivaheb laicepSClient: But I can work with it via the Adapter:
Adapter: (TRANSLATED) Special behavior of the Adaptee.
```
use of map method in javascript
Published: 2023-09-06 04:39:26

map method return new array 

```
let clothPrices = [350, 200, 500, 800]
let discountPercent = 10 //percent 

let discountedClothPrices =  clothPrices.map((price)=>{
    let amount = (price * discountPercent)/100;
    return (price - amount).toFixed(2);
})  

console.log(discountedClothPrices)
```