Tuesday, August 13, 2019

Lesson 1 - GIT - Version Control System

This is the first lesson in the study group, git is very important tool for someone who want to develop software.

Let say, you want to develop a software, but you don't do it yourself, you do it with your friends, so how you will manage your code?, share it with your friends?, and collaborate with your team?

It is hard if you don't have tools to help you to do that, and one of the tools to help you collaborate with your team to write code is Git.

Git is a distributed version control system, originally developed in 2005 by Linux Torvalds, the creator of Linux. Git helps developer tracking changes in source code, also enable developer to collaborate and working together with the team.

The Git Workflow

* git init
* git add
* git commit
* git push

Other git command:
* git status
* git remote
* git clone
* git log

When the first time you creating your project, let say you put a file in a folder, and then start writing code. To enable git to track your code, then initialise git in your project, simply type a command:

$ git init

In your project root directory, usually we called this directory as a Repository. After git init, there will be created a new directory named .git, this directory contain files used by git to track the repository.

To check the status of the git, we can issue a command:

$ git status

This command will show the current status of the git repository, file changed, untracked files, etc.

To add files to the repository simply issue a command:

$ git add <file/directory name>

or we can use:

$ git add .

To add all changed files and folders. After adding the files we can commit our change, to do so issue the following command:

$ git commit -m "commit message"

Here the commit message is to give short and meaningful explanation about what have been changed, what is the purpose of the commit.

After that, we can send it to the remote repository using push command:

$ git push

Sunday, August 11, 2019

Building Web Application Using Laravel - a Study Group

In this article series I want to talk about Laravel, actually I use this material to teach a study group to start writing code and build web application using Laravel framework.

They are all beginners, so the material will walk through very basic and step by step to build Laravel web application.

Study Plan:

1. Git
2. Github
4. Composer
5. Laravel

At the end of the lesson, students will have a running web application that has the following features:

a. show list of products
b. insert a new product
c. edit a product
d. delete a product

We use Telegram group to communicate to each other, sometimes we meet in the real live while enjoying coffee.

Wednesday, June 19, 2019

Install and Configure KVM on Ubuntu 18.04

We can use VirtualBox or KVM on Ubuntu to do virtualization, we often use virtual machine for development, not necessarily on a server, we can use KVM on Ubuntu Desktop.

To setup KVM on Ubuntu 18.04, perform the following steps:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install qemu qemu-kvm libvirt-bin  bridge-utils  virt-manager

What the command does:

1. Update and upgrade Ubuntu
2. Install required packages for running KVM
3. We use qemu and qemu-kvm for hypervisor
4. bridge-utils for working with network bridge
5. virt-manager is GUI application for KVM.

Let see our new network interface created by bridge-utils and KVM by running "ip a" command:

4: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:54:00:2f:e6:3c brd ff:ff:ff:ff:ff:ff
    inet brd scope global virbr0
       valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:2f:e6:3c brd ff:ff:ff:ff:ff:ff

Now, there are two new network interfaces, those are bridge network interface created by libvirt, we can use virbr0 for bridge network with our virtual machine.

Lets run a virtual machine for testing, we will use CentOS minimal as a guest OS, before that, download CentOS minimal image, and put it where ever you want, and the run the following command:

$ virt-install --virt-type=kvm --name centos7 --ram 2000 --vcpus=2 --os-variant=centos7.0 --network=bridge=virbr0,model=virtio --graphics vnc  --cdrom=/var/lib/libvirt/images/CentOS-7-x86_64-Minimal-1810.iso --disk path=/var/lib/libvirt/images/centos.qcow2,size=10,bus=virtio,format=qcow2

We create a virtual machine, with 2GB ram, and 2 cpus, using CentOS 7 as a guest OS, and we create 10GB virtual disk.

That's all.

Nested Virtualization KVM on CentOS 7

Nested Virtualization is disabled by default on CentOS 7, we can verify by running a command:

# cat /sys/module/kvm_intel/parameters/nested

Make sure KVM is intalled on the machine, if output is N, then Nested Virtualization is disabled, to enable the feature, set options kvm-intel nested=1 in /etc/modprobe.d/kvm-nested.conf

# echo "options kvm-intel nested=1" > /etc/modprobe.d/kvm-nested.conf

Reboot the machine, and verify like above command.

Tuesday, March 26, 2019

Delete All Comments in a File With VS Code

What if you want to delete all comments in a file with VS Code? VS Code has a find and replace feature that support regular expression, so we can use that feature to automatically find line starting with hash (#), Here we go: 1. Press ctrl + f 2. Click on "Use regular expression" button on "find and replace" widget 3. Type the regular expression: ^#.*$\n 4. Leave the "Replace" field empty 5. Click "Replace All" button And all of your comment deleted, actually it is replaced by the empty character. Notes ^#.*$\n : • ^ = matches position just before the first character of the string • # = character that we want to find • . = matches a single character. Does not matter what character it is, except newline • * = matches preceding match zero or more times • $ = matches position just after the last character of the string • \n = Line feed character

7 GNU Screen Commands To Make Your Life Easier

Here 7 GNU Screen commands that could make your life easier:

* ^A ^W - window list
* ^A ^C - create new window
* ^A space - next window
* ^A p - previous window
* ^A ^A - switch to previous screen
* ^A [0-9] - go to window [0-9]
* ^A esc - copy mode

Sunday, December 2, 2018

Futsal dan Jogging

Futsal dan Jogging, saya suka dua olah raga ini, karena setiap kali setelah futsal atau jogging seluruh badan saya terasa pegel-pegel, merata dari kepala hingga kaki.

Untuk olah raga yang lain, terutama yang pegelnya di bagian tertentu, saya tidak begitu suka.

Ya, sesederhana itu alasannya :D