This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var item = document.getElementById("item"); | |
item.parentNode.removeChild(item); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index | |
# get all data and connect with database(Back end logic) | |
# retun html file to client | |
render 'index' | |
end | |
def new | |
# retun html file to client | |
render 'new' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
# v3 example | |
def show | |
#oop I forget add '#' to comment at line 6 then server will thown error 500 | |
check paramter is exist | |
if !params[:id].present? | |
render json: { response: { data: nil }, success: false} and return | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var commend_helper = { | |
':w': 'บันทึกไฟล์', | |
':wq': 'บันทึกและออก', | |
':q': 'ออกแบบปกติ', | |
':q!': 'ออกแบบไม่บันทึก', | |
Esc: 'ออกจากโหมด insert, virtual, normal', | |
':': 'เรียกใช้คำสั่ง Plugin หรือคำสั่ง Buildin' | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person { | |
private String firstName; | |
private String lastName; | |
private String age; | |
public Person(String firstName, String lastName, String age){ | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.age = age; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ขั่นแรกตั่ง iptable เพื่อให้เข้าถึงได้จาก IP ที่ต้องการในที่นี่คือ Applcation Server ตามตัวย่าง | |
$ iptables -A INPUT -s 10.130.29.177 -p tcp --destination-port 27017 -m state --state NEW,ESTABLISHED -j ACCEPT | |
$ iptables -A OUTPUT -d 10.130.29.177 -p tcp --source-port 27017 -m state --state ESTABLISHED -j ACCEPT | |
// ถัดมาให้เพิ่มระดับความปลอดภัยไปอีกคือ | |
$ vim /etc/mongod.conf | |
bind_ip = 127.0.0.1,10.130.29.177 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ vim /etc/mongod.conf | |
# /etc/mongod.conf | |
# Listen to local and LAN interfaces. | |
bind_ip = 127.0.0.1 | |
----------------------------------------- | |
// or allow to connect fron outside server replace <ip-addess> to your IP | |
bind_ip = 127.0.0.1,<ip-addess> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// install | |
sudo apt-get update | |
sudo apt-get install iptables-persistent | |
// save | |
sudo service netfilter-persistent save |