Pages

Wednesday, May 13, 2015

centos 7 documentation.

holy shit,,, many has changed in centos version 6 to 7.

I'm shocked at first when using centos7. Many command and features have changed. when i want to restart a service, suddenly i realised there is no script at /etc/init.d/xxx

that i can do usually start stop or even restart a service.

time to learn some new manners guys... here are my documentation of centos 7. I hope it can help you.



service in centos 7

first of all centos 7 use some kind of system called systemctl  to stop, start, restart or even start the service at boot time. 


ex:    $        systemctl status sshd      ->      used for checking status of ssh service

how to restart service in centos7
system ctl output command.


when we type command above, it will show our service status. whether it active or not, can be seen on the mark above (green mark). How long the service have been up, and the white mark at the right ( enabled ) mean it will auto start at boot time. 


pretty simple right. first time i use it i really hate the way centos change the system. But after plenty time of used, im very happy with it. no more /etc/init.d/xxx restart. now become

 systemctl [start | stop | reload | restart | enable | disable ]  [service].


$        systemctl start sshd.service   ->  start service
$        systemctl status sshd  -> check status
$        systemctl stop sshd  ->  stop the service
$        systemctl enable sshd  -> automatically start at boot time
$        systemctl disable sshd -> not automatically start at boot time
$        systemctl status sshd   -> reload configuration changes


oh yeah, dont forget, command above only work as root. if you are not root then need to add sudo in front of the command.  

ex:   $ sudo systemctl start sshd.service



netstat and ifconfig

when at first i land on centos7. I also test some command like netstat, and ifconfig for changing my network. But it doesn't work at all. We need to enabled it first if we want to use the command. How to enable command pretty easy. We need to use yum command to see the packages belong to what at first.


$  yum whatprovides netstat

how to enable nestat, ifconfig centos7


from the output above we can see netstat belong to net-tools-2.0-0.17.20131004git.el7.x86_64.

gotcha,  now get it installed by tying:

$ yum install net-tools


done. Now we can use netstat and ifconfig as usual. 


This documentation is only the basic i can write for this time. I think i will write more next time if i found issues and able to solve it.  (and of course have some free time)!  Hope it helps. cheers :)



Friday, May 8, 2015

Understanding Basic Laravel Framework. Model-View-Controller

after installing laravel and get the environment set, we will try to test our code. If you find some issues while installing composer perhaps this link can help you.


Laravel is a framework that use mvc ( model view controller ) architecture.  It means that there are 3 main component that separate function and responsibility between each method.


Controller is used to control the application.  whenever got request from user, what kind of output / response will be served to user. is it a plain html word? or is it retreiving some data from database ( working with model ). or is it showing a template with html css javascript ( working with view ).  Or both ( take some data from model,  put it on view, then serve it to user ).


Controller is the brain of application. It's control the logic of an application we build.


Model is used to talk with database. Using model. we can also give some boundary / limit to what kind of input should be inserted to database. By using model, we make sure there are no harmful code in other area ( from views / controller ) that can change data which doesn't match rules in model.
Laravel also have something called ORM ( object relational mapping ).  We just need to write some code in laravel (php) format to make a database record ( insert, update, query, delete ) without need to write the sql query itself.




View is used to make some template. All presentation ( mostly from front end ) usually live here. Laravel using some kind templating called blade.  the syntax is using {{ //our code here }}. We don't have to type    <?php //xxx ?> . Another way to write some code. Basicly it is still the same but with blade we can write more less code  ( the output to user are still the same).










Thursday, May 7, 2015

dokumentasi git

git init        -> inisialisasi git baru.

git status     -> ngecek kondisi saat ini. file di stage area / udah dicommit apa blm.


git add "*.txt"  -> masukin semuanya ke staging area.


git commit -m "bikin web berbasis php"  ->   commit smua file yg ada di stage area. trus dikasih nama


git log   -> ngecek log / hasil commit



git remote add origin https://github.com/try-git/try_git.git   -> bikin remote repository kosongan





git push -u origin master
        ->   -u ga usah ngulang lg. tgl push2. master= default local       branch name.



git pull -u origin master   -> ngambil dari repository.


git diff HEAD      ->     liad perbedaan hasil dari pull repository


git diff --staged  -> liad file yg udah distage


git reset xxx.txt  -> hapus.



git checkout -- xx.txt  -> mengembalikan ke commit pas xx.txt  ( revert to snapshot)



git branch clean_up   -> bikin cabang. biar ga ganggu yg utama.



git branch   -> liad isi directory



git checkout blean_up   ->  pindah ke cabang.



-abis pindah ke cabang bisa diapus semuanya.


git rm "*.txt"




-trus di commit

git commit -m " hapus semua isi cabang"




git checkout master   -> pindah ke master.




git merge clean_up    -> gabungin cabang ke repo master.


git branch -d clean_up       -> hapus cabang yg bernama clean_up



git push            -> commit everything

Monday, May 4, 2015

JSON array example

JSON Array


first of all, what is JSON exactly?  have you heard JSON everywhere? JSON JSON JSON JSON. 
What the f*ck is JSON?


JSON = Javascript Object Notation.  It was called like that because javascript was the first programming language that take an advantage of the format. So what do can we do with JSON?


mainly JSON is used for primarily data transfer, kind of like XML (but not contain tag, readable, and less size). JSON didn't looked like html / css which have an interface/graphic showed to user. JSON must keep it's size small so it contain only important data ( String, Double,Float, Integer, Array,Boolean, Object,Null ). 

JSON also can be used to connect front end application with backend application ( retreiving data ) without a page reload ( which is commonly achievable using javascript with  AJAX request ).


JSON syntax  =     {}

JSON example =  {"name":"toro", "nationality":"indonesia", "hobby":"programming"}

JSON array example  = {"other_hobby": ["swimming","basketball","dota2"]}


very simple right?

also JSON can use line break because it didn't bothered with white space. so we can use line break to break the line code so it is very clear and readable like this:



JSON example with white space :


{
"name" : "toro" ,
"nationality" : "indonesia",
"hobby" : "programming"
}


JSON array example with white space :



{
 "other_hobby" : ["swimming","basketball","dota2"],
 "another_hobby_again" : ["sleeping","rafting", "reading"]
}



json string =  using " "
json integer, double float =  not use " "
json boolean = without " "  , true | false    
json null = without " " , null
json object = {}     -> can contain anything. same as json syntax itself





Friday, May 1, 2015

jquery syntax / command

recently finished half of jquery programming book. These are the most important ( summary ) of jquery command / syntax.

Documentation is very important in programming world. If sometimes we forgot and need to use the syntax just open blog and we will remember suddenly...

:D


$(document).ready(function xxx(){});




document.getElementById();
document.getElementByTagName();   -> javascript way.


#('#banner').html('<h1> hello jquery </h1>');   // selector for id, same ass css

#('.banner').html('<h1> hello jquery </h1>'); // class

#('a').html('<h1> hello jquery </h1>'); // tag

#('#navBar a')                              //descendant of id a ( also accept multiple)

#('#navBar > a')                              //direct descendant of id a

$('input[type="text"]')                        // search for certain type

$('li:has(a)')                                  // if li contain a tag.

$('a:contains(Click Me!)')                     // contain spesific text!





var x = document.getElementById('demo');  -> javascript way
var x = $('#demo');   -> jq way




$('#popUp').width(300).height(300);   // set weight and height of div tab (jquery can chain method)



$('#popUp').width(300).height(300).text('Hi!').fadeIn(1000);  //  chaining method


$('#errors h2').text('No errors found');   // only change text, not html tag



$('#errors').prepend('<p>i was added at the beginning of child tag</p>');
$('#errors').append('<p>i was added at end of child tag');



$('#product101').replaceWith(<p>Added to cart</p>');  -> can be used in cart purchased. to change element to html code.