Skip to content

Instantly share code, notes, and snippets.

View NSLog0's full-sized avatar
🦋

NSLog0 NSLog0

🦋
View GitHub Profile
@NSLog0
NSLog0 / main1.js
Last active September 11, 2017 01:59
react tutorail
var item = document.getElementById("item");
item.parentNode.removeChild(item);
@NSLog0
NSLog0 / contrl.rb
Last active September 7, 2017 11:14
api naming article
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
@NSLog0
NSLog0 / comments_controller.rb
Last active September 3, 2017 13:36
http status code article expiation
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
@NSLog0
NSLog0 / .vimrc.md
Last active February 1, 2018 09:39
rc file support vim v8
@NSLog0
NSLog0 / commend_helper_vim.js
Last active May 16, 2018 15:47
Vim tutorials
var commend_helper = {
':w': 'บันทึกไฟล์',
':wq': 'บันทึกและออก',
':q': 'ออกแบบปกติ',
':q!': 'ออกแบบไม่บันทึก',
Esc: 'ออกจากโหมด insert, virtual, normal',
':': 'เรียกใช้คำสั่ง Plugin หรือคำสั่ง Buildin'
};
@NSLog0
NSLog0 / registrations_controller.rb
Created July 19, 2017 16:03 — forked from jwo/registrations_controller.rb
API JSON authentication with Devise
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
@NSLog0
NSLog0 / person_model.java
Last active June 21, 2017 06:48
data class
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;
// ขั่นแรกตั่ง 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
$ 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>
// install
sudo apt-get update
sudo apt-get install iptables-persistent
// save
sudo service netfilter-persistent save