Binary Search

ค้นหาจากตำแหน่งกึ่งกลาง ถ้าเจอก็จบ
ถ้าไม่เจอ แล้วเลขที่ค้นหามีค่ามากกว่า ก็หาต่อทางครึ่งซ้าย
ถ้าไม่เจอ แล้วเลขที่ค้นหามีค่าน้อยกว่า ก็หาต่อทางครึ่งขวา

โค๊ด

ผลการรัน
[code]
Search term found at index 4.
Press any key to continue . . .
[/code]

การเรียกใช้ HTTP ด้วย Provider

นำโปรเจ็กส์จาก การเรียกใช้ HTTP แบบ GET มาพัฒนาเพิ่ม

A provider is an Angular component that can be injected into other pages which allows us to call some functions.
A provider has no view, it’s only returning data to us. And that’s exactly what we need.

สร้าง provider ใหม่ชื่อ api

[code]
$ ionic g provider api
[/code]

Continue reading

ASP.Net: WebApi คืนค่าจากคลาส

สร้างโปรเจ็กส์แบบ WebApi
แล้วกำหนดให้คืนค่าเฉพาะ application/json

แก้ไข Controllers > ValuesController.cs

Continue reading

ติดตั้ง vsftpd บน ubuntu 16.04 server

vsftpd – FTP Server Installation
vsftpd is an FTP daemon available in Ubuntu.

[code]
sudo apt install vsftpd
[/code]

Anonymous FTP Configuration
By default vsftpd is not configured to allow anonymous download. If you wish to enable anonymous download edit /etc/vsftpd.conf by changing:

[code]
anonymous_enable=Yes
[/code]

During installation a ftp user is created with a home directory of /srv/ftp. This is the default FTP directory.

If you wish to change this location, to /srv/files/ftp for example, simply create a directory in another location and change the ftp user’s home directory:

[code]
sudo mkdir /srv/files/ftp
sudo usermod -d /srv/files/ftp ftp
[/code]

After making the change restart vsftpd:

[code]
sudo systemctl restart vsftpd.service
[/code]

Finally, copy any files and directories you would like to make available through anonymous FTP to /srv/files/ftp, or /srv/ftp if you wish to use the default.

กำหนดให้สามารถ upload ไฟล์เข้ามาได้

แก้ไขไฟล์ /etc/vsftpd.conf

[code]
write_enable=YES
[/code]

เสร็จแล้ว restart vsftpd:

[code]
sudo systemctl restart vsftpd.service
[/code]

Link

Remove Gitlab from Ubuntu 16.04

Uninstall gitlab
To remove just gitlab package itself from Ubuntu 16.04 (Xenial Xerus) execute on terminal:
[code]
sudo apt-get remove gitlab
[/code]

Uninstall gitlab and it’s dependent packages
To remove the gitlab package and any other dependant package which are no longer needed from Ubuntu Xenial.
[code]
sudo apt-get remove –auto-remove gitlab
[/code]

Purging gitlab
If you also want to delete configuration and/or data files of gitlab from Ubuntu Xenial then this will work:
[code]
sudo apt-get purge gitlab
[/code]

To delete configuration and/or data files of gitlab and it’s dependencies from Ubuntu Xenial then execute:

[code]
sudo apt-get purge –auto-remove gitlab
[/code]

Link

Android: Spinner เตรียมข้อมูลด้วยโค๊ด

activity_main.xml

Continue reading