teleren/devto huggingface dataset:
csvkit  tools ดีๆ ไม่มีไม่ได้แล้ว...
Tags: csvkit, python
Published: 2021-01-31 15:25:59

เมื่อไม่นานมานี้ได้มีโอกาสพบเจอ cli-tool ตัวนึงที่เจ๋งมากทำให้เราทำงานกับไฟล์ csv ได้อย่างมีประสิทธิภาพมากขึ้น เร็วขึ้น ง่ายขึ้น ปัญหามันเริ่มมาจากว่าต้องทำ report ชิ้นหนึ่งที่ ข้อมูลจะต้องมาจาก 2 database แต่ อนิจจาแต้มบุณน้อย database ที่ใช้นั้น คือ postgres ซึ่งไม่ได้รองรับการ join กันระหว่าง database ทำได้แค่ join table ใน database เดียวกัน แล้วทำไงหล่ะทีนี้เพราะ database ทำได้ แค่ read   only เท่านั้น ครั้นจะไป set up อะไรเพิ่มเติมให้มันทำ join ข้าม database มันก็ดูจะเป็นไปได้ยากหน่อย งั้นเราเลือกทางนี้ คือ ส่งquery ไป run เอาผลลัพธ์ ที่เป็นcsvกลับมาแล้ว มาหาทาง join กันเพื่อให้ได้ ไฟล์ report สุดท้ายที่เราอยากได้ 
มาดูตัวอย่างกันดีกว่า
สมมติ เรามีไฟล์ csv สอง อัน คือ flight.csv หน้าตาแบบนี้
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rdee4rpeqfq8i6yt6kbi.png)
เป็นข้อมูลจะนวนเที่ยวบิน และ ข้อมูลของสนามบิน
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gs1aqydepa9oh24e7urt.png) 
สิ่งที่เราต้องการคือ report ที่ทำการเรียงลำดับเมืองที่มีการบินระหว่างกัน และข้อมูลของ สนามบินต้นทาง และ ปลายทาง
หน้าตาประมาณนี้ 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oj93ws7h1qlv8sdeiae2.png)
เอาละงั้นมาลงวิธีทำกันดีกว่า หลังจากพิจารณา สักครู่หนึ่งก็จะพบว่าเราต้องการที่จะแปลผลข้อมูลของ code เช่นเราต้องการแปลผลว่า ABE มันคือ สนามบินอะไรที่เมืองไหน ซึ่งเราต้องใช้วิธีการ inner join ในการที่จะรวมตาราง เพื่อเอาข้อมูล
ok งั้นลงมือกัน
อันดับแรก ติดตั้ง csvkit ก่อนตาม document ดังนี้

https://csvkit.readthedocs.io/en/latest/tutorial/1_getting_started.html#installing-csvkit

เมื่อทุกอย่างพร้อมก็เริ่มกันเลย

```bash
csvjoin -c "origin,iata" flights-airport.csv  airports.csv 
```
หลังจากรัน คำสั่งนี้ มันจะได้ ผลลัพธ์ดังนี้
option -c คือ ระบุว่าจะ ใช้ column ไหนในการให้มัน join on สอง column นั้นต้องมีค่าที่ตรงกัน มันถึงจะทำการ join กันได้ 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ja0rccb00qqj0lhgieie.png)
แต่ว่าเราได้ column ที่เราไม่ต้องการมาด้วย ok งั้นเราต้องเอาไป ตัดออก ด้วย csvcut
```bash
svjoin -c "origin,iata" flights-airport.csv  airports.csv  | csvcut -c 2,3,4,5 > joined_origin.csv
```
คำสั่ง csvcut option c คือ column ที่จะตัด ซึ่งเราจะเอา columnที่ 2 3 4 และ 5 หลังจากนั้น ก็ stream เข้า ไฟล์ ไปพักไว้ก่อน เพื่อรอทำแบบข้างบนอีกครั้ง สำหรับ destination
หลังจากได้ joined_origin.csv มาแล้ว จะเห็นว่ายังเหลือ destination ที่ยังไม่ได้ join ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uuwp161z7s43cz0qe6me.png)
ดังนั้นเราก็ทำแบบนั้นอีกครั้งนึง
```bash
csvjoin -c "destination,iata" joined_origin.csv  airports.csv |  csvcut -c 3,4,5,6,2 | csvsort -c count -r > flight_detail_report.csv
```
csvsort คือ การเอาข้อมูลมา เรียงลำดับ option -r คือ เรียงจากมากไปน้อย
สุดท้ายจะได้ไฟล์ csv หน้าตาประมาณนี้มา
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1ajdkpolq32ac7knpm8u.png)
แก้ไขชื่อ column อีกนิดหน่อยก็เรียบร้อยพร้อมใช้งานแล้ว 
 
*** ขอขอบคุณ ****
https://github.com/datapackage-examples/vega-airports สำหรับข้อมูลที่เอามาใช้ และ 
https://csvkit.readthedocs.io/en/latest/index.html สำหรับ tools ดีๆ
Fixing "sqlite3 gem which is not supported on Heroku"
Tags: rails, heroku, tutorial
Published: 2021-01-31 15:21:38

{% youtube AA6GZBPeveU %}

When I first tried to deploy my Ruby on Rails app to Heroku, I ran into a really annoying error which said:

```
Failed to install gems via Bundler.
Detected sqlite3 gem which is not supported on Heroku:
https://devcenter.heroku.com/articles/sqlite3
```

The solution, was to change my apps database to use Postgres instead of Sqlite3. In rails there in a terminal command you can run which will do this for you:

```bash
$ bundle exec rails db:system:change --to=postgresql
```

# But why do I have to do this?!

Heroku uses an [Ephemeral filesystem](https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem), which means anything you write to disk won't be persisted between instances of you app. This makes a lot of sense for as you start scaling your app up & need multiple machines to handle requests. But as a result, it's best to treat your apps filesystem as if it's read-only.

The issue is [Sqlite3](https://devcenter.heroku.com/articles/sqlite3) writes your database to disk, on your local dev machine it's probably stored in `db/development.sqlite3`. If you had to sync that file between multiple servers running your app, it would be really hard!

So instead we use Postgres which lives on another machine in Heroku world & can share easily offer shared access between multiple instances of our app.
Simplify foreach loops with the null-coalescing operator
Tags: dotnet, csharp
Published: 2021-01-31 14:51:27

Do you ever get tired of writing code like this?

```csharp
if (listOfStrings != null)
{
    foreach (string item in listOfStrings)
    { ... }
}
```

Wouldn't it be nice if the `foreach` loop automatically checked for null and skipped the loop the same way it does when there are no items?

Here's where the null-coalescing operator can help:

```csharp
foreach (string item in listOfStrings ?? Enumerable.Empty<string>())
{ ... }
```

Lots more in the [official docs from Microsoft](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator)
Selenium Input Text Python
Tags: python, testing, webdev, tutorial
Published: 2021-01-31 14:34:32

One of the most common scenarios that you will run into as part of browser automation is filling the input fields. In this tutorial, we will cover how to work with input text elements in Selenium Python using the SeleniumBase framework.

### **Test Scenario**
In this test, we will be filling all the fields below and clicking the submit button to submit the contact form.

![test](https://automationbro.com/wp-content/uploads/2021/01/image-2.png)

### **Test Solution**
You can use the `send_keys` command to add text to your input fields. See the example below –

![code](https://dev-to-uploads.s3.amazonaws.com/i/jqze6rgwb0tb7fk3cbg6.png)

SeleniumBase provides additional capabilities with the `send_keys`command such as waiting for an element to be visible, making sure the element is in the ready state, etc…

---

### **Check out the video below to learn how to work with input fields in Selenium Python –**
{% youtube DlZH8f0dc4E%}

---

📧 Subscribe to my [mailing list](https://automationbro.com/mailing-list) to get access to more content like this 

👍 Follow [automationbro](https://twitter.com/automationbro) on Twitter for the latest updates

...

I love coffees! And, if this post helped you out and you would like to support my work, you can do that by clicking on the button below and buying me a cup of coffee -

<a href="https://www.buymeacoffee.com/automationbro">![Buy me a coffee](https://dev-to-uploads.s3.amazonaws.com/i/4aw2ub3f4qkyjk0ivwt4.png)</a>

You can also support me by liking and sharing this content.

Thanks for reading!
A relief - updating my Wordpress theme development setup
Tags: wordpress, javascript, css
Published: 2021-01-31 13:24:55

`TLDR: Try Parcel.`

Coming from grunt, I wasn’t really disappointed with my current setup. It worked, was reliable but it felt a little clumsy and slow over time copying more and more features into the tasking chain. Certainly not necessarily grunt’s fault, but I wanted to try something new and slicker. Kinda like a fresh start.

While searching for a CRA like developing experience for developing Wordpress themes, I tried different task managers, bundlers and tooling setups. All promised to do the job and I’m pretty sure they are able to do it, but I was surprised how difficult it seemed to be for me to enable a simple list of features I aimed for. I tried [webpack](https://github.com/webpack/webpack) setups, [wpack.io](https://github.com/swashata/wp-webpack-script), [gulp](https://github.com/swashata/wp-webpack-script), [grunt](https://github.com/gruntjs/grunt) and [parcel](https://github.com/parcel-bundler/parcel) and started out with a basic list of demands:

**Styling**
- SCSS support
- Autoprefixer
- Minification
- Preferable CSS stylesheets and not CSS in JS solutions
- Watching and recompiling

**Scripts**
- Compiling of modern syntax
- Direct import of npm packages (neither relative nor absolute imports) 
- Minification
- Watching and recompiling

**… and as a plus**
- Auto Reload
- Asset management

##New Setup
I ended up being very satisfied with [parcel](https://github.com/parcel-bundler/parcel). The setup is super easy

`yarn add parcel-bundler --dev`

or

`npm install parcel-bundler --save-dev`

And adding your scripts to your package.json

`"scripts": {
    "dev": "parcel watch src/js/index.js src/styles/_.scss --public-url /wp-content/themes/THEME/dist",
    "build": "parcel build src/js/index.js src/styles/_.scss --public-url /wp-content/themes/THEME/dist"
  },`

That’s it. It worked out of the box for me with all the features I required. I ended up using v1 of the package, because I ran into compatibility issues with v2, but nothing unsolvable I assume. Since the development is somehow in between two major version, the documentation was sometimes a little bit confusing to me not knowing which version it was referring to, but this little setup above did the trick for me. 

What are you using? What are your experiences?

[Photo by Markus Winkler](https://unsplash.com/@markuswinkler?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText")
How to begin to set up Data Services file for a Web Application's Database
Tags: csharp, webdev, security, design
Published: 2021-01-31 13:21:17

Between Identity Framework, authentication, authorization, and data services, the .net environment allows developers to build applications with security at the forefront. Seeding Data into a database is essential for developers to test programs. When in development, you can test this seed data without having to depend on your client’s information to test. You can also seed certain types of data into programs such as administrator accounts, moderator accounts, and accounts for other developers who will be working on the program. This sort of information you would want to isolate for two reasons. First, you wouldn’t want to seed data inside the Program.cs file because this would violate the single responsibility principle. The Program.cs should not have the responsibility of seeding data and calling the startup.cs file. The single responsibility principle is strictly enforced to make programs reusable and to simplify error handling. Second, If someone were to be able to access the program using nefarious techniques, sensitive information can be decrypted and stolen. In order to solve both problems, a developer will need to create an entirely separate file for Services. Next, the developer will need to pass an instance of IHost to the DataService.cs. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/n5n672a5h0ktklqdis4g.PNG)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/on1q3pyb129eyfri6uol.png)


The Service file will feature a DataServices file whose single responsibility will be to seed data for the program. The instance of IHost will allow different objects of the program to obtain their specific services. The specific services are instantiated implicitly since it is easier for it to take on the form that it’ll be assigned to. Lastly, the variables with their specified services will be passed as parameters into the private asynchronous methods.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d095tkxunat6xabb7tfk.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7bo38kqn19rnbif90se5.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0dqgmxqw3wl20571po81.png)

This method of data managment is known as a wrapper method, or in design terms, the adapter pattern. This pattern allows two interfaces, both with separate responsibilities, to interact with each other. The first interface (the client) will call another interface (the adaptee) in order to complete a service such as providing data, or instantiating a certain number of objects via its private static classes. This method of seeding an administrator and a moderator inside an adaptee is a top tier security technique. If need be, this design pattern can also be used for other services in order to instantiate more objects via multiple incompatible interfaces.

This is just the skeleton of the implementation. As the cohort goes along, our cohort will properly configure interfaces and properly implement dependency injection.
Open a new tab dynamically
Tags: javascript, webdev, codenewbie, beginners
Published: 2021-01-31 13:18:12

```js
window.open('www.google.com', '__target');
```

---

**Thanks for reading 💙**  
Follow **@codedrops.tech** for daily posts.  
[Instagram](https://www.instagram.com/codedrops.tech/) ● [Twitter](https://twitter.com/codedrops_tech) ● [Facebook](https://www.facebook.com/codedrops.tech/)

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript  
**[codedrops.tech](https://www.codedrops.tech/)**
How Google Passage Rank Work
Published: 2021-01-31 13:11:18

##How Google Passage Ranking Works
Passages allow Google to rank specific, relevant passages from a specific page. Not just the page itself.

(Kind of like a souped-up version of Featured Snippets.)

Here’s an example from Google’s feature announcement:

Google – Understanding passages
So instead of Google ONLY taking into account the relevancy of an entire page.

They’ll now also size up the relevancy of a specific section of that page.

Google passage ranking will evaluate content sections independently
That said, Google has made it clear that they will still evaluate entire pages.

##Twitter – Google on evaluating whole pages
So backlinks, on-page SEO, UX signals, and Google’s other page-level ranking factors will still apply.

The only difference is that a single page now has more chances to rank. That is, assuming the page is optimized and organized.

Which is exactly what I’m going to cover right now.

Organize Your Content Into Discrete Sections
Yes, Google will <a href="https://rankmove.com/">rank</a> passages of your page semi-independently.

But that doesn’t mean they can easily divvy up a disorganized page.

Why?

Google may now look at each section like a mini web page.

Organizing content into discrete sections may help with Google passage ranking
This means your content needs to be divided up into dedicated sections.

And each section should cover a specific subtopic.

You may have been doing this already. If not, I recommend going back and organizing your content into VERY clear sections.

For example “SEO vs. SEM: What’s The Difference?”.
Weekly Challenge 097
Tags: perl, theweeklychallenge, perlweeklychallenge
Published: 2021-01-31 13:11:01

[Challenge 097](https://perlweeklychallenge.org/blog/perl-weekly-challenge-097/)

# TASK #1 › Caesar Cipher

## The task

You are given string `$S` containing alphabets A..Z only and a number `$N`.

Write a script to encrypt the given string `$S` using [Caesar Cipher](https://en.wikipedia.org/wiki/Caesar_cipher) with left shift of size `$N`.

## My solution

First thing to note is the [tr function](https://perldoc.perl.org/perlop#tr) does not support string interpolation, as the translation table is built at compile time.

I broke down the task into these steps:
 * Check the string only contains A - Z and spaces. Check the number is an integer between 1 and 25.
 * Use `substr` to create the cipher table
 * Create a `%mapping` hash mapping plain text characters to their cipher equivalent.
 * Use split, map and join to generate the cipher text, and then display it

## Examples

```
» ./ch-1.pl "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG" 3
QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD

» ./ch-1.pl "QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD" 23
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
```

# TASK #2 › Binary Substrings

## The task

You are given a binary string `$B` and an integer `$S`.

Write a script to split the binary string `$B` of size `$S` and then find the minimum number of flips required to make it all the same.

## The solution

This is one of those tasks where the solution I submit isn't the fastest one, but one that is well explained.

1. I first check that the binary value contains only 0's and 1's. I also check the second value is a positive integer. While the tasks that $S is an integer, a zero or negative integer is nonsensical in this sense.
1. I add leading zeros to the binary value if it's length is not dividable by the integer. I think use `unpack` to break up the binary value into the array `@chunks`
1. Next I work through each character position determining whether the bit is set (1) or not set (0) more frequently. If it's half and half, I use '0' but could use '1' as it would give the same result. The resulting value is stored as `$most_used`
1. Finally, I go through each `@chunk` and each character, and add to the `$flips` value if the bit is different from that in the `$most_used` string. I then display the minimum number of flips required.

This code could more concise by skipping the last step and doing the calculations in the third step. For example, if the first character was '0, 1, 1, 1' then we would only need one flip to make them all the same.

## Examples

```
» ./ch-2.pl 101100101 3
1

» ./ch-2.pl 10110111 4
2
```
30 Days of Flutter
Tags: flutter, mobileapp, appdevelopment
Published: 2021-01-31 13:10:15

---
title: 30 Days of Flutter
published: true
description: Learning Flutter and participate in 30 Days of Flutter
tags: flutter, mobileapp, appdevelopment
cover_image: https://images.unsplash.com/photo-1597075095400-fb3f0de70140?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=670&q=80
---

# Introduction
As a developer its important to always keep learning. Learn about the stuff you know and learn new stuff!
I really like how Flutter works and the beautiful Apps you can build with it - Cross Platform!

So i decided to myself to dive in into Mobile App Development beside my Web Development Journey to learn some new skill and stay up-to-date with the newest technology.

# Quick: What is Flutter
Flutter is an open source framework from Google to build cross-platform apps. You write code once and you are good to go, iOS, Android, Web... you can do all these things with Flutter!

In Flutter everything is a Widget. So you build your App with existing Widget and build new ones. You can use existing Widgets and build new Widgets with these Widgets. Its like lego blocks where you put together several blocks (Widgets) and build for example the Enterprise or the Death Star. Everything you can imagine!

For example imagine you want to display just a text in the center of your screen.
In Flutter you have a Text Widget where you put your string as a parameter. And to center it you can wrap this Text Widget into a Center Widget that takes a Widget as a parameter. And this is only one way to center a Text.

# 30 Days of Flutter
This february the Google Flutter Team starts the 30 Days of Flutter. I will participate and maybe you will join too! You can easily join here:  [30 Days of Flutter](https://developers.googleblog.com/2021/01/join-us-for-30daysofflutter.html)

You also can join the Discord and chat with real Flutter Developers and learn together a cool new skill.

As i will learn throughout the month ill update my progress here on my blog to keep you guys updated and hopefully introduce you to a real cool technology that might be the next big deal when it comes to Mobile App Development.

# Conclusion
Hopefully i encourage one or two of you to join the way of Flutter. Maybe you are already a Flutter developer. If so please feel free to leave some tips and tricks or learning resources right in the comment section.

Stay connected to me and my content on [Twitter](https://twitter.com/danytulumidis).

I love to improve myself every single day even if its just a tiny bit!

Stay save and healthy guys!

And as always: develop yourself!
What is a search engine?
Tags: seo
Published: 2021-01-31 13:03:02

##What is a search engine?

A search engine is a complete system designed to show what a user wants to see. It involves gathering data from different websites and organizing it by keeping in mind at least 200 ranking factors. A search engine result is mostly in text form. However, it depends upon the intention behind the search term. The result can be an image, video, book, and product, etc.


##How does a search engine work?
Every search engine has different bots. These bots scan all websites present in the internet world. During the scanning process, they copy the data and organize it. When a search engine user searches a term, the data is displayed in multiple results. This process is also known as crawling and indexing.

Every search engine has its algorithms, and they are updated continually. Mostly, search engines inform the website owners about the algorithm updates. However, none of the search engines releases the details of the changes to avoid user manipulation.

A website can rank higher by following the guidelines offered by the search engine. You can find the search engine guidelines by Google on <a href="https://rankmove.com">Rank Move</a> .
Recommend an iOS SSH tool-iTerminal Pro
Tags: ssh, terminal, telnet, sftp
Published: 2021-01-31 13:01:15

Programmers often need to connect and manage remote servers to deal with various problems. Sitting at the desk and staring at the computer is our normal working status, but when we are out or off work, we encounter problems that need to be dealt with in time. How to deal with it? Have you ever thought that you can remotely connect and manage your server anytime and anywhere with just a mobile phone or a tablet? Now I recommend a powerful iOS version of SSH and Telnet client.
iTerminal Pro is a powerful SSH and Telnet client on iPhone/iPad, through which you can connect and manage remote servers. You can use your mobile phone to troubleshoot online problems at any time on the subway and bus. The programmer only needs a mobile phone to solve it.

Download link: https://apps.apple.com/app/iterminal-pro-ssh-telnet-app/id1544449135

Features:
-Use SSH to connect to the server, support the use of username/password authentication and key authentication.
-Support private key management, support PEM (RSA (PKCS#1), PKCS#8, DSA (OpenSSL), ECDSA) and PPK (RSA (PKCS#1), DSA (OpenSSL), ECDSA, ED25519) keys.
-Supports importing keys from Wifi or file management transmission, safer and more convenient importing keys from computer.
-Support multi-level proxy server function, which can connect to the server through the springboard.
-Support local port forwarding or forwarding through a proxy server. For example, by forwarding the Jenkins server, the phone can directly access the Jenkins website, so that you can debug with the phone.
-Start (run) saved commands/scripts when the connection is started.
-Support different theme terminals, various classic themes such as Grass, Homebrew, Man Page, etc. 
-Support terminal screen copy/paste and easy text selection.
-Support SFTP