Skip to content

Instantly share code, notes, and snippets.

View tux89's full-sized avatar
🤧
I may be slow to respond.

Tux89 tux89

🤧
I may be slow to respond.
View GitHub Profile

The JavaScript world is currently in great turbulence. A new framework pops up daily, developers are confused about which tools they’re supposed to pick up, and building user interfaces is experiencing dramatic changes. On top of that, us Rails developers know that .erb views are going out of fashion, too--and being replaced by much more sophisticated JavaScript-based frameworks. Given all this, it can be difficult to pick up something to commit to.

Fortunately, Facebook’s React provides a ray of hope by promising a novel approach to building user interfaces. Even better, Rails can seamlessly integrate with it, and it’s easy to set up a Rails API application and to build its view layer with React. So, let’s take a look at how to build a simple Rails API that accommodates create, read, update and delete functionality for a single model with React.

Setting up a basic Rails API

Setting up the model

We’re going to employ a different approac

@tux89
tux89 / setup-apache.md
Last active September 2, 2016 08:51
Setup Apache, Mysql and Rails

Install apache2

$ sudo yum install httpd
$ sudo service httpd start

Install mysql

Đối với thằng centos thì mặc định phiên bản cũ. Nếu muốn dùng phiên bản mới thì cài đặt hơi lằng nhằng một chút.

Vào trang này http://dev.mysql.com/downloads/repo/yum/ để lấy file. Dưới đây là cách lấy file đối với el7.

#!/bin/bash
function copy_files {
echo "start copy files from $SOURCE TO $1"
# copy file regist_water_info
cp "$SOURCE" "$1"
echo "finish folder $1."
}
SOURCE='/home/user/data'
@tux89
tux89 / rails_model_notes.md
Last active September 1, 2016 04:37 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

人生かくれんぼ - Trò ú tim đời người

惚れていたんだ
Anh đã yêu em rồi
おまえにだけは ぐちになるから 言葉にゃ出さぬ
Chỉ sợ em sẽ giận nên anh không dám ngỏ lời
風がしみるよ 心が寒い
Gió thổi thấu vào tim anh lạnh
ちょいと人生 かくれんぼ
Đời mình nhỏ bé chơi trò trốn tìm nhau

GIT NOTES

Check connect to bitbucket and github

$ ssh -T git@bitbucket.org
$ ssh -T git@github.com
[mysqld]
# --------------------------------------------------
# Base /etc/my.cnf
# --------------------------------------------------
user = mysql
port = 3306
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock
pid-file = /var/run/mysqld/mysqld.pid
symbolic-links = 0

DEBIAN NOTES

Install Erlang

$ wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
$ sudo dpkg -i erlang-solutions_1.0_all.deb
$ wget https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
$ sudo apt-key add erlang_solutions.asc
$ sudo apt-get install elixir
$ sudo apt-get update
# Use Gists to store entire functions
class QuickSort
def self.sort!(keys)
quick(keys,0,keys.size-1)
end
private
def self.quick(keys, left, right)

ENGLISH

  1. Help yourself! - Cứ tự nhiên nhé!
  2. Absolutely! - Chắc chắn rồi!
  3. What have you been doing? - Dạo này đang làm gì?
  4. Nothing much. - Không có gì mới cả.
  5. What's on your mind? - Bạn đang lo lắng (nghĩ) gì vậy?
  6. I was just thinking. - Tôi chỉ nghĩ linh tinh thôi.
  7. I was just daydreaming. - Tôi chỉ đãng trí đôi chút thôi.
  8. It's none of your business. - Không phải là chuyện của bạn.