teleren/devto huggingface dataset:
SQL 基礎 Part 02 -- docker-compose で立てたコンテナに外部からつなげる
Tags: postgres, docker
Published: 2022-12-13 16:59:33


## why

前回は Docker コンテナ内部で立ち上げた Postgres サーバーにコンテナ内部から psql コマンドで localhost 宛につなげることができた。

次に、コンテナ外部から DB サーバーに接続したい。

なぜなら、Spring のアプリをコンテナ外で立ち上げたいからだ。
そのためには、DB サーバーはコンテナの外からアクセスできる必要が有る。

https://github.com/version-1/kotlin-web-app-sample/blob/master/src/main/resources/application.yml

調べてみると spring だと application.yml のデータソースに接続先情報を書けば接続してくれるようだ。

なので、まずは Spring 関係なく、 Docker コンテナに立てた DB サーバーの、コンテナ外部からの接続を試みる。

---

## コンテナ外部からのポート指定での接続

https://qiita.com/nakamasato/items/4155ec8acbb88af81543#terminal%E3%81%8B%E3%82%89%E6%8E%A5%E7%B6%9A-psql%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%8C%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%95%E3%82%8C%E3%81%A6%E3%81%84%E3%82%8B%E5%A0%B4%E5%90%88

nakamasato さんの記事を見ると

```php
psql -h localhost -p {portNumber} -U {userName}
```

これで Docker Compose で Docker コンテナ側から外部に開放しているポートに当てればいけるようだ。

```yaml
version: '3' 

services:
  db: 
    image: postgres:14
    container_name: postgres_dc
    ports:
      - 5444:5432
    volumes:
      - db-store:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=pass
volumes:                                                                                                                                  
  db-store:
```

docker-compose.yml で
5432 番 ( postgres が Docker コンテナ内部で使われる番号、変えられない ）から 5444 番 ( 外部に開放する接続先ポート ) を設定して

```php
psql -h localhost -p 5444 -U postgres

Password for user postgres: 
psql (12.12 (Ubuntu 12.12-0ubuntu0.20.04.1), server 14.6 (Debian 14.6-1.pgdg110+1))
WARNING: psql major version 12, server major version 14.
         Some psql features might not work.
Type "help" for help.

postgres=# 
```

コンテナ外部から localhost の 5444 ポートに psql でつなぐと、
environment で指定したパスワードで入ることができた！

---

## まとめ

Docker Compose で Docker コンテナ内部に Postgres の DB サーバーを立てて Docker コンテナ外部からつなぎたい時は

docker-compose.yml に

```yaml
    ports:
      - {outSidePortNumber}:5432
```

と記載して docker-compose up して

```php
psql -h localhost -p {outSidePortNumber} -U {userName}
```

コンテナ外で、外部用のポート番号に繋げば OK

以上
How To Create The Best Website In The World
Tags: webdev, webcomponents, devjournal, tutorial
Published: 2022-12-13 16:49:05

How To Create The Best Website In The World.

Well, as developers, we might want our website to be good at performance, search engine optimized, or responsive. But doing all this might be a little difficult if you are a beginner or just lazy like me.

So instead go to chrome, and inspect. Now click on lighthouse and then press analyze page load. Here you can see the performance, accessibility, best practices, SEO, PWA, and much more.

Now instead of wanting to have a perfect website, you can easily make one.
Google’s New Programming Language is Called Carbon. Google Introduced Carbon to be a Successor of C++
Tags: carbon, programming, webdev, tutorial
Published: 2022-12-13 16:44:09

Google’s New Programming Language is Called Carbon.
Google Introduced Carbon to be a Successor of C++.

We know Google’s obsession with creating different frameworks and launching a few programming languages. Dart was one of the programming languages launched by Google which was object-oriented and a web-based programming language.

Dart programming language didn’t gain a huge response from the developers and hence it never got the position of mainstream programming language. Many programmers prefer C++ and JavaScript over Dart due to their strong background.

One programming language named GO gained quite impressive among developers and GO. GO or GoLang was statically typed and explicit. It was a general-purpose programming language that was similar to the C programming language.

Now Google is all set to launch a new programming language called Carbon programming language.

Carbon Programming Language Launch
Recently, CPP north event 2022 was held and basically, it is an event where many developers come together to discuss future developments of C++. So, in this event, a Googler named Chandler Carruth introduced developers to a new programming language called Carbon.

The carbon programming language was announced as an experimental language that could be a successor to the C++ programming language.

Chandler Carruth who is also the technical lead for Google programming language also told us that they would be starting this experimental work with the C++ community.

Build up
This launch was very interesting and the announcement of the Carbon programming language was also done through a comparison of mainstream programming languages with its successors.

As we know, C++ is a successor of C. TypeScript is a Successor of JavaScript. Swift is a successor of Objective C. Kotlin is a successor of Java. But who is the successor of C++?

Is it Rust? Yes, we can call Rust pretty much a successor of C++ but it is very hard for users to learn and is in the very early stage of its development. Hence, it is too early for Rust to be called a successor of C++ and it is pretty difficult for Rust to be a successor for a powerful language like C++.

With a huge amount of developers who are currently programming in C++, a successor is required to overcome the needs of modern programming problems. Therefore, C++ currently doesn’t have a well-defined successor, and Carbon could possibly be a successor of C++.

Goals of Carbon Programming Language
Carbon could possibly be an evolution for both software and programming language. Carbon will mainly focus on code that will be easy to write and read.

The carbon programming language will also be a language that will be fast and scalable in development. It will support all the modern OS platforms and environments.

It will also have a practically safe testing mechanism which would be improved for advanced types of code. Performance critical goal would also be the main goal for the Carbon programming language.
Techstrong TV Interview
Tags: devops, embedded, microservices, luos
Published: 2022-12-13 16:42:07

🎥 Michael Vizard from Techstrong TV interviewed Nicolas Rabault last week.

They talked about how the DevOps workflows will be consistently applied across edge computing platforms at a time when IT is becoming more distributed than ever.

Check out the video: https://techstrong.tv/videos/interviews/devops-workflows-and-edge-computing-platforms-nicolas-rabault-luos
How does an API work???
Tags: api, webdev, beginners, tutorial
Published: 2022-12-13 16:37:28

Continuing where I [left](https://dev.to/bellatrix/design-a-restful-api-jam), this blog is next in series after short introduction of API design

HTTP makes the web work!!🌐

HTTP is protocol, XML is markup language, JSON is notation

REST is none of the above.

SOAP has a very fixed process, detailed scenarios, complex error handling.
REST has very few requirements, flexible based on needs and patterns.

HTTP is well understood protocol that is simple and powerful, every request and response has two parts, header and payload. 
Payload is HTML, JSON, XML, or whatever comes there you can view, interact and process.

## HTTP codes

### 2XX : 

200 OK - Request successful
201 Created - Resources successfully created
202 Accepted - Identify that action is underway but not completed yet
204 No content - Delete a resource 

### 3XX :

301 - Moved permanently
302 - Moved temporarily

### 4XX :

400 - Bad request
401 - Authentication required
402 - Forbidden
404 - Not found

### HTTP Response Codes : 100s

100-199 : Informational
200-299 : Success
300-399 : Redirect
400-499 : Client Error
500-599 : Server Error

Content-Type -  A header that identifies type of payload being provided by server from normal web browser, it'll be normal HTML.

Media types are named and structured payload that allow client to be customize to handle them.

### REST API Constrains

1. Client Server Architecture - API should be designed for this
2. Stateless Architecture - Every request should be processed independently of each other
3. Layered System 
4. Cacheable 
5. Code on demand
6. Uniform interfaces

[For details please refer](https://dev.to/pragyasapkota/introduction-to-rest-api-gk7)

### Authentication and Authorization

Authentication means establishing who you are, login with credentials.

Authorization established your permissions.
APIs have authorization factors, like who you are, your group membership, subscription level, context etc

1. API keys
Long string issues by API provider, appended to URL, not secure as URLs are not safe

2. OAuth
Authorization protocol, upon authentication, a token maps to an authentication description. 

### API Versioning

- Versioning in URL
- Versioning via the accept header 

Thanks for reading 🙌
warcraft thing
Tags: beginners, gamedev, warcraft
Published: 2022-12-13 16:36:40

Is it allowed to ask if anyone can help me in game deve 
if its not allowed pls remove it.

hey there guys , hope you are all great . i have been a world of warcraft player as long as i can remember and i got this idea of starting a private server with some of my friends for wow wotlk which all can enjoy , so i seek some help as i am not a developer myself , would like some developers help me in this project so if there is anyone who is interested please contact me , as he will be a partner to me.
How to end a telnet session (Linux, MAC, Windows)
Tags: beginners, linux, devops, tutorial
Published: 2022-12-13 16:33:17

Hello there 👋

Like me, you have started a telnet connection through the terminal and have no idea how to close it 🤣

If you currently don't have an active telnet connection, you can start one on the terminal by typing:

```
$ telnet address port
```

> To end your current telnet session you must reach the telnet prompt and type quit.

Here are the steps for doing so:

1. Open the telnet prompt by holding down the 'Ctrl' key and push the ']' key. (prompt: telnet>)
2. Type `quit`.
3. Push the `Enter` key.

I hope this helped.

*You're welcome* 💪
Announcing Monokle 1.13, now with cluster management
Tags: kubernetes, deployment, yaml, kustomize
Published: 2022-12-13 16:28:59

It’s a pleasure to share the latest release of our open source project,  _[Monokle Desktop](http://www.monokle.io)_ - a unified visual tool for authoring, analyzing, and deploying Kubernetes configurations, from pre-deployment to cluster.

The most exciting features of our v1.13 release include Cluster Mode for easy cluster management and an addition to our Compare & Sync feature that eliminates the stress of working on projects containing lots of subfolders.

Cluster Mode offers:



* Real-time visibility of resources actively deployed in-cluster
* Clear vision of cluster updates 
* In-cluster resource validation

Read about all new features in the[ announcement blog-post](https://monokle.io/blog/monokle-1-13-release).

Monokle Desktop can be [downloaded](https://monokle.io/download) and used on Windows, Mac OS X, and Linux. 

Feedback is of course appreciated - either here or on our [Discord server](https://discord.com/invite/6zupCZFQbe).
JPG to DST Conversion
Tags: embroidery, digitizing, logo
Published: 2022-12-13 16:23:48


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ds1v659r6kn7txwal966.jpg)
Absolute Digitizing is an embroidery digitizing company with specialize in any kind of digitizing for embroidery machine. We do not compromise on quality for the digitizing , we offer a complete solution for your embroidery digitizing, logo digitizing, vector art and [jpg to dst conversion services](https://www.absolutedigitizing.com/jpg-to-dst-conversion/) conversion and digitizer for embroidery machine.
React Components
Tags: react, javascript, components, beginners
Published: 2022-12-13 16:20:09

React components are one of the key pillars to learning how to use React. They are reusable code that you can import anywhere you want. It's very similar to how gems work in Ruby, if you're familiar with that. The way you'd go about using a react component is by having a React function with a named function written as such:
```
import React from "react"

function ReactExample() {
return (
    "Hello"
  )
}

export default ReactExample;
```
The export default at the end is what allows this component to be used in other components of code. To actually import this block of code into another component you have to do as such:
```
import ReactExample from "component-path"
```
Where it says component-path you'd have to write the path in your file you need to take to read the component. Having a feature like this just makes everything easier to write. You could have a certain format of a card that you're using in one section of your work and want to use it somewhere else as well. Instead of copy pasting it you can import a component by writing:
```
<ReactExample/>
```
This also ties into a previous post that I made about props where you pass props by writing:
```
<ReactExample example={ExampleProps}
```
To clarify, the props that you pass into the component don't have to be titles props. You can title it whatever you want just as I did with titling the props I passed in "example". This is pretty much the gist of all you need to know about components in React.
Multichannel Fulfilment Solutions
Tags: multichannel, retail, fulfilment, solutions
Published: 2022-12-13 16:06:43

With a combined domain experience of over 200 years, Holisol has developed the expertise in designing-implementing-managing the supply chain solutions for **[multi channel retail in India](https://holisollogistics.com/multi-channel-retail/)**. The complete know-how of industry has helped us in the successful completion of greenfield set-ups. But we never stopped there – we continued to innovate the solutions to enable our customers to accomplish their business goals.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9s0gganhrx0cczuvq5w.jpg)
The officials of the Customs Surveillance Service (SVA)
Published: 2022-12-13 15:56:45


Galicia is the main gateway for illegal drugs in Europe. Tobacco smugglers have disappeared from the scene and their place has been taken by youngsters using high speed boats. A report with testimonies from Jhon Jairo Velásquez 'Popeye', Pablo Escobar's hit man, and Judge Baltasar Garzón.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ttipku9c5chpd804xvuv.png)

The officials of the [Customs Surveillance Service](serviciodevigilanciaaduanera.es) (SVA)
How to Scrape Tweets from Twitter with Python using Tweeds
Tags: python, productivity, opensource, security
Published: 2022-12-13 15:51:08

## What is Tweeeds?🌱
Tweeds is an advanced Twitter scraping tool written in Python that allows for scraping Tweets from Twitter. The name might be funny but _"Don't Judge a book by it's cover"_😏
 
{% embed https://github.com/achyuthjoism/tweeds %}

## Why should I use Tweeds?🐐

1. You don't need a Twitter API for scraping tweets
2. You can scrape all the tweets(Twitter API limits 3000 tweets only😢!)
3. No Twitter credentials required 
4. No limitation 
5. It's OpenSource 😃

## Prerequisites ✅

- Python >= 3.9

## Installation ⚙
```bash
pip install tweeds
```
And you are done! Now you can use this tool in your terminal or in your python project. In this post we will discuss both the use case.😎

## Command Line Interface 💻

- Scrape all the tweets from Elon Musk(including replies).
```bash
tweeds -u elonmusk
```
- Scrape all Tweets from the Elon's timeline containing pineapple.    
```bash
tweeds -u elonmusk -s pineapple
```
- Scrape all Tweets from user's tweeting about Coffee near Berlin.
```bash
tweeds -s Coffee --near Berlin
```
- Want to add a limit just add `--limit` argument.
```bash
tweeds -s Coffee --near Berlin --limit 1000
```
- Scrape all Tweets from Elon's timeline since 2022-12-10.
```bash
tweeds -u elonmusk --since 2022-12-10
```
- Scrape Tweets from a radius of 1km around a place in Paris.
```bash 
tweeds --geocode "48.880048,2.385939,1km" --limit 10000  
```
- Want to export the data into CSV or JSON for further analysis just add `--csv` or `--json` argument with the filename.
```bash 
tweeds --geocode "48.880048,2.385939,1km" --csv paris.csv --limit 10000
```
Refer [Docs](https://github.com/achyuthjoism/tweeds#-example) for more example.
## Modules ⚡
Now Tweed can be used as a module and allows custom formatting. Example:

```python
import tweeds

query = tweeds.Query()

query.search = "Yash Boss"
query.limit = 10
query.verified = True

tweeds.search(query)
```
Remember you have 20 options to fiddle with🤯.
## Conclusion 👋
This project was made only for educational purpose only. Thank you for following this tutorial to the end. Hopefully this article helps you, see you in the next article.
{% embed https://github.com/achyuthjoism/tweeds %}
Learn Enough Linux Command Lines to be Dangerous, or to be Safe
Tags: linux
Published: 2022-12-13 15:46:55

This post lists the most commonly used commands in linux (or alike, like MacOS) system. 

## File System
```bash
$ whoami
```
prints the login name of the current user. 

![joke](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0055it2h9m3bnj8ehfdv.jpg)

```bash
$ pwd
```
prints the current working directory (Print Working Directory)

```bash 
$ ls
```
lists files and directories. Often used with options 
- `ls -l`: -l option signifies the long list forma
- `ls -a`: -a option means list hidden files 
- `ls -F`: -F option makes files of different types appear differently. Display a slash ('/') immediately after each pathname that is a directory, an asterisk ('*') after each that is executable, an at sign ('@') after each symbolic link etc. 

```bash
$ cd 
```
change directory. Note often used:
- `cd ..` go to parent directory 
- `cd -` go to previous directory 
- `cd ~` go to home directory 

```bash
$ mkdir
```
creates a directory 


```bash
$ rmdir
```
removes a (empty) directory

```bash
$ cp src dest 
```  
copies files/folders from one location to another 

```bash
$ mv src dest 
```
moves files/folders from one location to another 

```bash 
$ rm 
```
removes files/folders. Often used:
- `rm -r folder_name` removes a folder and its content
- `rm -rf folder_name` removes without prompts

## Processes
```bash
$ ps
``` 
see the processes associated with the current shell. Often used with:
- `ps -ef` get a full listing of all processes in the system 
- `ps -ef | grep process_name` get process_name process 

```bash
top
```
display the processes using the most CPU time. Often used with: 
- `top -n 10` lists the top 10 processes that use the most CPU time 

quit with q 

```bash
kill 
```
terminates a process `kill PID`. Use `kill -9 PID` to force kill. 


## Misc

```bash
$ vim 
```
text editors for writing files. 
Recommended: install plugins [ultimate vim](https://github.com/amix/vimrc) to make vim more powerful and colorful. 

```bash
$ cat
$ more 
$ less
```
view files 

```bash
$ grep
```
search text files

```bash
$ gcc 
$ gdb
```
compilers and debuggers 

## More
One can use `man` to get a detailed explanation of commands 
```bash
man cp
```
Code brushes for GitHub Copilot
Tags: github, githubcopilot, preview
Published: 2022-12-13 15:45:47

---
title: Code brushes for GitHub Copilot
published: true
description: Github Next now showed a new feature in GitHub Copilot labs that allows you to change code you write to make it cleaner and safer 
tags: github, copilot, preview
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cse0gj38clvgkwpkkxck.png
canonical_url: https://christianheilmann.com/2022/12/13/code-brushes-for-github-copilot/
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-13 15:16 +0000
---

GitHub Copilot is incredible, and if you check what's happening in the preview released as the [Copilot Labs extension](https://githubnext.com/projects/copilot-labs/) it will only get more amazing. 

Check this out:

![Code brushes applied to a simple JavaScript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smtv4bienh6ys6piz6bh.gif)

Let's start with a basic JavaScript that checks a string length and reports when it is empty. One with an obvious mistake, as we use a single `=` instead of the type safe `===`. This will always report the string as empty.

```javascript
if (str.length = 0) {
    console.error('String is empty');
}
```

Using the `Fix bugs` brush, this is rectified.

```javascript
if (str.length === 0) {
    console.error('String is empty');
}
```

Using the `Clean` brush also adds reporting when the string is not empty.

```javascript
if (str.length === 0) {
    console.error('String is empty');
} else {
    console.log('String is not empty');
}
```

Using the `List steps` brush adds comments for step (sure, this is redundant, but it also works for much more complex code).

```javascript
// check the length of the string
if (str.length === 0) {
    // if length is 0, print 'String is empty' 
    console.error('String is empty');
} else {
    // if length is not 0, print 'String is not empty'
    console.log('String is not empty');
}
```

Using `Make robust` adds error reporting instead of logging and an extra check to make sure that `str` is really a String and not an empty Array.

```javascript
function test(str) {
    if (str.length === 0) {
        throw new Error('String is empty');
    } else if (typeof str !== 'string') {
        throw new Error('It is not a string');
    } else {
        console.log('String is not empty');
    }
}
```

The `Add types` brush does exactly that.

```Javascript
/**
 * @param {string} str
 * @returns {string}
 */
function test(str) {
    if (str.length === 0) {
        throw new Error('String is empty');
    } else if (typeof str !== 'string') {
        throw new Error('It is not a string');
    } else {
        console.log('String is not empty');
    }
}
```

You can also define custom brushes and there are more to come.
The officials of the Customs Surveillance Service (SVA)
Published: 2022-12-13 15:35:11

The officials of the [Customs Surveillance Service](https://serviciodevigilanciaaduanera.es) (SVA), men and women, have the status of agents of the authority (fiscal police and judicial police), given the missions they carry out and, therefore, are authorized to carry regulation weapons.

Its actions are aimed at the repression of contraband crimes and offenses, the fight against drug trafficking and other related crimes such as money laundering, the fraud of Excise Taxes and other tax fraud and the submerged economy.

For this reason, they have extensive training in administrative, criminal and procedural, community, tax, customs and smuggling law.
Can You Explain Why This Is or Isn't Good UIDesign?
Published: 2022-12-13 15:12:52

Recently a site I use every day to read electronic books changed its format.

It now looks like the following:


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

At first that may not look that bad, but please keep in mind that readers are coming to this site for Content.

Now, take a look at this diagram which is the same page but highlighting all the non-content areas.  


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

Now the user's eyes jump all around the page looking for content.

## Scrolling In a Time of No Scrollbars
Scrollbars have been downplayed in recent design, but these designers have now forced the user to scroll even more.  It doesn't make sense.  This UI Design is creating a bad UX (user experience).

## Bottom Right For Next Page
The designers also moved the [Next Page] link from the upper right (which made logical sense) to the lower right of the page.  That's not a great location.

## Two ToolBars
Previously there was only one toolbar but now there are two taking up even more screen space. 

## Do You Think This Is Good Design?
Can anyone explain why this is good design?  It seems that many sites are moving to this format (less content shown).

Is this simply a marketing ploy to force users to interact more with the page (by forcing them to scroll and move around the page)?

Or, is this just following some new uninformed guide on how to create "better" design?  

Possibly it is just change for change's sake.  Just new.  Not better.

## What Do You Think?
What do you think?  Do you like this format?