teleren/devto huggingface dataset:
Linux安装最新版Tinyproxy
Tags: linux, tinyproxy
Published: 2024-05-04 23:22:31

前言
之前在Linux服务器安装过tinyproxy用于ip代理，但是yum安装的话，版本最高只到1.8.3，是不支持账号密码验证的，也就是说要么限制ip，不然任何人都能连。而到了1.10.0就支持Basic HTTP Authentication了，但是得通过编译安装。目前Github上最新的是1.11.1，本文是安装的简要教程。

Tinyproxy介绍及yum安装教程见：使用Tinyproxy搭建HTTP(S)代理。

安装及配置
如果通过yum安装过1.8.3版本，得先卸载掉。

yum erase tinyproxy
以下是从Github下载安装最新版的命令。

# 获取安装包
wget https://github.com/tinyproxy/tinyproxy/releases/download/1.11.0/tinyproxy-1.11.0.tar.gz
 
# 解压安装包
tar -zxvf tinyproxy-1.11.0.tar.gz
 
# 进入安装文件夹
cd tinyproxy-1.11.0
 
# 编译并安装
./configure
make
make install
安装完成后可用以下命名查看路径和版本。

# 查看路径
which tinyproxy
/usr/local/bin/tinyproxy
 
# 查看版本，最新1.11.0
tinyproxy -v 
tinyproxy 1.11.0
修改配置文件，下面是安装后配置文件位置。

vi /usr/local/etc/tinyproxy/tinyproxy.conf
基本的配置可以见之前那篇文章，主要说下不同。

# 将下面直接注释掉，允许所有ip访问
#Allow 127.0.0.1
#Allow ::1
 
# 设置用户名密码
BasicAuth username password
 
# 顺便将下面两行取消注释，后面有用到
PidFile "/usr/local/var/run/tinyproxy/tinyproxy.pid"
LogFile "/usr/local/var/log/tinyproxy/tinyproxy.log"
保存配置文件后，使用下面的命令启动。

# 指定配置文件启动（后台启动）
tinyproxy -c /usr/local/etc/tinyproxy/tinyproxy.conf
启动后就可以测试下

# 不加验证参数不会正常返回
curl -x http://127.0.0.1:8888 www.baidu.com
 
# 正常返回
curl -x http://username:password@127.0.0.1:8888 www.baidu.com
以上就是简要安装与配置，但是为了方便管理服务，得添加到系统服务。

添加到系统服务
# 新建tinyproxy.service文件
vi /usr/lib/systemd/system/tinyproxy.service
 
# 贴入以下代码
[Unit]
Description=Startup script for the tinyproxy server
After=network.target
 
[Service]
Type=forking
PIDFile=/usr/local/var/run/tinyproxy/tinyproxy.pid
ExecStart=/usr/local/bin/tinyproxy -c /usr/local/etc/tinyproxy/tinyproxy.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
 
[Install]
WantedBy=multi-user.target
上面的配置文件直接仿照yum安装的1.8.3版的，会出现点问题，启动不了，因为tinyproxy配置文件里的log和pid文件不存在，得先通过以下命令创建。

mkdir -p /usr/local/var/run/tinyproxy
mkdir -p /usr/local/var/log/tinyproxy
touch /usr/local/var/log/tinyproxy/tinyproxy.log
touch /usr/local/var/run/tinyproxy/tinyproxy.pid
然后就可以正常使用service命令了。

service tinyproxy start    # 启动
service tinyproxy stop     # 停止
service tinyproxy restart  # 重启
service tinyproxy status   # 状态
 
# 将tinyproxy服务设置开机自启
sudo systemctl enable tinyproxy


最后整理下命令：


# 复制以下命令，直接到修改tinyproxy.conf
yum erase -y tinyproxy
wget https://github.com/tinyproxy/tinyproxy/releases/download/1.11.0/tinyproxy-1.11.0.tar.gz
tar -zxvf tinyproxy-1.11.0.tar.gz
cd tinyproxy-1.11.0
./configure
make
make install
vi /usr/local/etc/tinyproxy/tinyproxy.conf
 
# 修改后，使用以下命令，到编辑tinyproxy.service
mkdir -p /usr/local/var/run/tinyproxy
mkdir -p /usr/local/var/log/tinyproxy
touch /usr/local/var/log/tinyproxy/tinyproxy.log
touch /usr/local/var/run/tinyproxy/tinyproxy.pid
vi /usr/lib/systemd/system/tinyproxy.service
 
# 粘贴以下代码
====
 
[Unit]
Description=Startup script for the tinyproxy server
After=network.target
 
[Service]
Type=forking
PIDFile=/usr/local/var/run/tinyproxy/tinyproxy.pid
ExecStart=/usr/local/bin/tinyproxy -c /usr/local/etc/tinyproxy/tinyproxy.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
 
[Install]
WantedBy=multi-user.target
 
====
 
# 保存后，再使用以下命令启动tinyproxy
sudo systemctl enable tinyproxy
service tinyproxy start
service tinyproxy status
How Javascript makes web pages more interactive
Published: 2024-05-04 22:56:38

ACCESS CONTENT : You can use JavaScript to select any element, attribute, or text from an HTML page▪ For example: Select the text inside all of the <hl> elements on a page▪ Select any elements that have a c1ass attribute with a value of note▪ Find out what was entered into a text input whose id attribute has a value of emai1▪ Javascript allows you to make web pages more interactive by accessing and modifying the content and markup used in a web page while it is being view in the browser.
A Powerful Git Trick No One Knows About
Tags: git, productivity, development, softwareengineering
Published: 2024-05-04 22:39:28

Here is a Git trick I learned a long time ago that I can’t live without (and when I say no one knows about it, I mean it - it is not well documented, and no developers I have worked with knew about it):

**Some git commands take `-` (dash) as the reference to the previous branch.**

`git checkout` and `git merge` are two commands I use it with all the time.

`git checkout -` switches to the previous branch. This makes toggling between the two most recently used branches quick and super easy:

{% youtube G9mjjgxNzLY %}

`git merge -` merges the previous branch to the current branch. It is especially powerful when combined with `git checkout -`. You can switch to the target branch and then merge from the previous branch like this:

{% youtube WFM_Mc3wYtQ %}

One command I wish supported `-` is `git branch -d`. It would make cleaning branches after merging effortless. Presumably, this option is not available to prevent accidentally deleting the wrong branches.

### Bonus trick 
While we are at it - did you know that the `cd` (change directory) shell command also supports `-`? You can use `cd -` to toggle between the two most recent directories.

---

💙 **If you liked this article...**

I publish a weekly newsletter for software engineers who want to grow their careers. I share mistakes I’ve made and lessons I’ve learned over the past 20 years as a software engineer.

Sign up [here](https://www.growingdev.net/) to get my articles delivered to your inbox.

https://www.growingdev.net/

---

Attribution: Git Logo by Jason Long, source: https://git-scm.com/downloads/logos
train,val,test
Published: 2024-05-04 22:03:30

Yes, we can separate the data into train, validation and test sets. This is usually done to evaluate the performance of the model and prevent overfitting. In Python, the train_test_split function of the scikit-learn library is often used to perform this operation.

Here is an example:

```
from sklearn.model_selection import train_test_split

# First of all, we separate the data into train and test.
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Then we separate the train set into train and validation.

X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size=0.25, random_state=42) # 0.25
```

In this code, the test_size parameter determines the size of the test set. In the first stage, 80% of the data is allocated for the training set and 20% for the test set. In the second stage, 25% of the training set (that is, 20% of the original data) is reserved for the validation set. As a result, 60% of the data is used for training, 20% for validation and 20% for testing.

The random_state parameter ensures the repeatability of the process. Thanks to this parameter, we can have the same split data set every time. The value of this parameter is usually an integer, and it is entirely up to you which value you use.
NexaScale Mentorship: A Journey of Growth
Tags: mentorship, javascript
Published: 2024-05-04 19:43:30

My name is Afolabi Abigeal, and I'm currently enrolled in the NexaScale mentorship program. It's already been an incredible journey that's helping me grow both personally and professionally.

**Supportive Mentors and Valuable Skills**

The program is filled with warmth and support. My mentors are always there to guide me and push me to reach my full potential. I'm learning a lot about DevOps, from version control with Git to continuous integration and deployment.

**Learning with Compassion**

What truly sets NexaScale apart is the sense of community and empathy. My mentors have created a safe space where I can ask questions, make mistakes, and learn from them. Their encouragement gives me the confidence to tackle challenges head-on.

**Weekly Activities Make a Difference**

The weekly activities are a highlight. From webinars and Q&A sessions to hands-on labs and projects, they're helping me expand my knowledge, network with others, and develop practical skills.

**Looking Ahead with Excitement**

I'm excited to see what the rest of the program holds. I'm confident that the NexaScale mentorship will empower me to pursue a career in DevOps. I'm also grateful for the opportunity to be part of such a supportive and inspiring community.
A Song For StarWars Day
Tags: music, starwars, maythefourthbewithyou, maythe4th
Published: 2024-05-04 19:59:30

To celebrate StarWars day, I thought I'd share this song I wrote about my favorite little green StarWars dude. Enjoy!

## [Grogu Song](https://montyharper.com/track/2714275/grogu)

<img width="100%", style="width:100%", src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExNmRyeDZyN3EyZnc2ZDdlcGhhcTlsajByaWo4Mnlka3h3cGgxdTRxdCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/s3SYj6zfj3QldFkici/giphy.gif">
Typealias vs Interface in TypeScript: Which to use in 2024.
Tags: webdev, typescript, beginners, programming
Published: 2024-05-04 19:50:28

>TypeScript is JavaScript and more, it is a subset of JavaScript that allows you to define the data types used within the code. 

There are two ways of defining types in TypeScript: type aliases and interfaces. Based on performance, there is no difference between the two, but questions on whether to use type aliases or interfaces often arise.

To answer this question, it often depends on personal preferences, as none of them affect performance, although based on simplicity and clarity, we could prefer one over the other. 

In this blog post, I will discuss the advantages type aliases have over interfaces and use cases.

### Using type aliases and interfaces.

#### Type aliases
Type aliases can be used to define primitives like strings or more complex types like objects and arrays.

#### Interfaces
Interfaces are similar to type aliases, except they are used to define object types. 

**Reasons why you should use type alias instead of interface all through your projects:**


#### Simplicity.

* Interface can only describe objects, whereas a type alias can describe objects and everything.

![code snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e41miiyvq60kxdyl9o56.png)




* Type aliases can describe union types, while interfaces cannot.

![code snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/etyke92rsc1rid20bse3.png)



* Extracting types from something else.

![code snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hr9wjbtnb6dcy3qjxhf7.png)



#### Clarity and improved readability.

* Type aliases can easily use utility types; interfaces can too, but only with ugly syntax.

![code snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whkte5js5s0n8adp7spa.png)



* Type aliases can easily describe tuples; interfaces can, but with ugly syntax.

![code snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3cjdm3ss3xxqpuusq5vf.png)



### Conclusion
In this article, we've discussed type aliases and interfaces, and the advantages type aliases have over interfaces.
We've discussed up to six scenarios where type alias is preferred over interface, but it still depends on one's preference.
I like using types because of its incredible type system. So why not use it throughout your code?
Buy Verified Stripe Account
Published: 2024-05-04 19:21:34

Buy [Verified Stripe](https://topsmmaccount.com/product/buy-verified-stripe-account/
) Account- Old verified with transaction

Buy Verified Stripe Account from TopSmmAccount :- Your trusted partner for seamless online payments and financial transactions. Old verified stripe

Replay and contact 24/7 Live Support

E-mail : topsmmacount@gmail.com
WhatsApp : +1(315) 514-9654
Telegram : @topsmmaccount
Skype : topsmmaccount
twitter : @topsmmaccount


https://topsmmaccount.com/product/buy-verified-stripe-account/

#topsmmaccount
#buy_verified_stripe_account
#verified_stripe_account
#old_verified_stripe_account
#verified_stripe_buy
#old_stripe_account_onlineee
Junit Badge For Git Project
Tags: github, junit, java, maven
Published: 2024-05-04 19:07:39

What are badges?

They look like this ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xul6ey76cj4qzztiigjt.png)

Now lets create a custom badge for your git project


The Plugins to update the JUnit test number seem not working very well specially if you do not have JaCOCO , here is a simple work around

1) Create a GIST file 

https://docs.github.com/en/get-started/writing-on-github/editing-and-sharing-content-with-gists/creating-gists

2)Get your GIST ID
https://docs.github.com/en/rest/gists/gists?apiVersion=2022-11-28

3)Create GIT TOken with GIST permission
https://docs.github.com/en/enterprise-server@3.9/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

4)Add The token to your repo secret for action

5)Create shell script

```
#!/bin/bash

# Assuming Maven generates XML test reports in the "target/surefire-reports" directory
TEST_REPORT_DIR="target/surefire-reports"
# Print current directory
echo "Current directory: $(pwd)"

xml_files=$(find "$(pwd)" -name "TEST-*.xml")

# Concatenate all XML files and count the occurrences of "<testcase" using grep
test_count=$(cat $xml_files | grep -c "<testcase")
echo "Total number of tests: $test_count"




echo "GIST_ID: $GIST_ID"


json_data='{"schemaVersion": "1", "label": "testcount", "message": "'$test_count'", "color": "orange"}'

echo "JSON data: $json_data"

# Prevent any output from the script
exec > /dev/null
exec 2>&1

# Create or update the Gist with the test count
curl -s -X PATCH \
     -H "Authorization: token $GIST_TOKEN" \
     -H "Content-Type: application/vnd.github+json" \
     -d '{"files":{"test.json":{"content": "{\"schemaVersion\": 1,\"label\": \"testcount\", \"message\": \"'$test_count'\", \"color\":\"orange\"}" }}}' \
     "https://api.github.com/gists/$GIST_ID"
```
7)Add script to your workflow 

```
      - name: Upload test custom
        env:
          GIST_TOKEN: ${{ secrets.GIST_TOKEN }}
          GIST_ID: ${{ secrets.GIST_ID }}
        run: bash uploadnumber.sh
```

8)Create the Shield badge from the raw gist file
https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/{gitusername}/{gist_id}/raw/{file_name}
FIRST Principles and Test Smells 🚀
Tags: testing, javascript, webdev, programming
Published: 2024-05-04 18:53:35

When it comes to writing high-quality unit tests, there are some basic principles, grouped under the acronym **FIRST**, that can be quite helpful.

---

## Fast ⚡
Unit tests should always be fast. The idea is that you can run them all the time, without having to wait. If you need a coffee while your tests run, they probably aren't fast enough.

## Independent 🧍
Each unit test should be able to stand on its own. It doesn't matter in what order you decide to run them; they should not depend on each other.

## Repeatable 🔁
If you run the same test multiple times, the outcome should always be the same: either the test always passes or always fails. Tests that sometimes pass and sometimes fail without any apparent reason are called "flaky" or erratic.

## Self-checking ✅
Once the test execution is complete, the result should be self-explanatory (passed/failed). This way, the outcome can be quickly verified and interpreted.

## Timely 🕰️
It's a good idea to write your unit tests as early as possible in your development process. Many people even prefer to write the tests before the code they will test; this helps ensure that your code will do exactly what you expect from the start.

---

## Test Smells 🐟👃
Some signs in your test code may indicate that something could be improved. These signs are called "Test Smells":

## Obscure Test 🌫️🤔
In code, an "Obscure Test" is complicated, long, and difficult to understand. Tests should be simple and straightforward so that anyone can understand what is being tested and why. It is important to have a clear and easy-to-understand logic.

## Test with Conditional Logic ➰❓
A test with many "ifs" and "elses" makes it difficult to understand exactly what is being tested and under what conditions. Ideally, unit tests should be linear; conditional logic in tests hampers understanding.

## Code Duplication in Tests 📄🚫
If you have repeated code in several tests, there might be a more efficient way to organize this.

Test Smells are like a signal that maybe you can simplify or better organize your tests. It's not that you can never have an "if" in a test or a slightly longer test, but it's a reminder to stop and think: "Is there a simpler way to do this?”

---

Most of this content came from the book "Modern Software Engineering", written by Marco Tulio Valente. This book is a treasure trove of tips on how to create tests the right way, using the latest and most efficient in the programming world. However, the only difference is that the book is in Java and here I adapted it to use JavaScript.

---
Easy to install Python -> Mac | Fix $PATH
Published: 2024-05-04 18:36:01

#1. Install homebrew
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
#2.Install Pyenv

```
brew install pyenv pyenv-virtualenv
pyenv install -l
```
#3.Test pyenv
```
pyenv virtualenv 3.12.0 myproject

pyenv local myproject

pyenv virtualenv-delete my project
```
#4.Test python
```
$ python3 --version
Python 3.9.6
$ which -a python3
/usr/bin/python3
```
==================================================
FIX Python not found in ZSH

Rus this ``` brew info python```

```
Python has been installed as
  /opt/homebrew/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /opt/homebrew/opt/python@3.11/libexec/bin
```
# Open profile config
```
nano ~/.bash_profile
```
I use zsh and VS Code, so I ran this:

```
code ~/.zshrc
```
Add the following lines to the file:
```
export PATH="/opt/homebrew/opt/python@3.11/libexec/bin:$PATH"
```

Now reload the shell profile by running the following command:

``` source ~/.bash_profile ```

For zsh, you could use this:

``` source ~/.zshrc ```
Day 34/366
Tags: 1percentplusplus, 100daysofcode
Published: 2024-05-04 18:20:42

🚀 **Today's Learning:**

🌟 DSA

- Is Perfect square
- Search in a rotated array

🌟 Dev

- Redux for state management

🔍 **Some Key Highlights:**

DSA

To determine if a given number is a perfect square, the algorithm iteratively narrows down the search range by dividing the number by 2 and checking if the square of the midpoint is equal to the target number. This process continues until the search range is sufficiently small or until the square of the midpoint matches the target number. If a match is found, the algorithm returns true; otherwise, it returns false, indicating that the number is not a perfect square.

For searching in a rotated sorted array, the algorithm follows a binary search approach. It first identifies the pivot point where the array was rotated, dividing the array into two sorted halves. Then, it applies binary search separately on each half, adjusting the search range based on whether the target value falls within the sorted range of the current half. This process continues until the target value is found or until the search range becomes empty, indicating that the target value is not present in the array.

DEV

Redux is a predictable state container for JavaScript apps, commonly used with React. It provides a centralized store to manage the state of an application and facilitates predictable state mutations through actions. The Redux pattern involves defining actions to describe state changes, reducers to specify how those actions modify the state, and a store to hold the application state. When an action is dispatched, it flows through the reducers, which update the state accordingly. Components can subscribe to the store to receive updates when the state changes, ensuring a single source of truth for the application's data and enabling efficient management of complex state logic.

 #100daysofcode #1percentplusplus #coding #dsa
Thunder Client: How to use to test APIs
Tags: thunder, tutorial, api, testing
Published: 2024-05-04 18:20:08

Recently, I started using an amazing VSCode extension called **"Thunder Client"** which makes it easy to make HTTP requests for testing APIs. I'm loving this tool! In this article, I will share what Thunder Client is how you can install it, and start using it today!

Let's go!🚀

## What is Thunder Client?

Thunder Client is an extension for Visual Studio Code that simplifies API and web service testing. With it, you can make HTTP requests using GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS methods. This extension aims to provide a simple, fast, and clean usability for the user.

## How to install

The installation is simple,  just search for the name **"Thunder Client"** in the "Extensions" of Vscode and click on install

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

By clicking **"New request"** we can see all the available HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD...) for making requests.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bziifgqpwvk0jltcowal.png)

In just a few minutes, we can test it out. Here, I made a call to test an API that I had created. Basically, you input the URL, method, headers, or body if necessary on the left side, and on the right side, we receive the response.

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

We can create a collection and save our tests by clicking on the three dots and selecting the **"Save to Collection"** option.

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

Simply enter a request name, URL, select the Create New option and enter the new name. After that, save the changes.

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

Finally, we can see our saved collection on the left side under the **"Collections"** section.

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

If you found this article helpful, please leave a comment.❤️
Motivation is the wrong reason.
Tags: experiencedriven, motivation, bored, growth
Published: 2024-05-04 18:09:22

I had the privilege of speaking as a guest speaker at the Re-inventing Self in Tech programme. It was an honour because it provided me with the opportunity to discuss key areas often overlooked in the EduTech sector: 1. Motivation; 2. Building Systems; and 3. Experiential Learning.

**Motivation**: While it's commendable, I firmly believe that motivation alone isn't sufficient to embark on or sustain a tech career. This is because motivation is primarily driven by inherently inconsistent emotions. What happens when you encounter boredom, lack daily motivation, struggle with understanding a concept, or face challenges securing an internship or job? Motivation can only offer temporary drive. You need something more stable, a more substantial reason.

**Building Systems**: Certain systems foster growth and the development of positive habits; mere wishing for success isn't enough. Building a system requires self-understanding and honesty about your strengths and weaknesses. With a better grasp of yourself, you can research industry skill trends and identify sustainable skills. Seek professional advice from experienced individuals at adplist.org and utilise roadmap.sh to understand the requirements for acquiring those skills. Additionally, understand your learning patterns and seek a mentor, friends, or a supportive community to hold you accountable on your journey.

**Experiential Learning**: Believe me, you'll likely forget about 70% of what you learn within a week. That's why I discourage beginners from immediately purchasing courses. Once you understand the roadmap to your desired career, utilise a crash course and start applying your collective knowledge to build something first. After engaging in at least three to four challenging projects, you can then look for a well-structured course to purchase. With this approach, anything you learn from those courses will stick much better. Remember, the power lies in utilising knowledge, not simply possessing it. Learn through doing.