Skip to content

Instantly share code, notes, and snippets.

View dthtien's full-sized avatar
🎯
Focusing

The Tiến dthtien

🎯
Focusing
View GitHub Profile
@dthtien
dthtien / install.md
Created March 15, 2017 10:19 — forked from fongfan999/install.md
Ruby On Rails Ubuntu 16.10 install

Developer libs

mysql, rmagic, curl, git, vim, sqlite, nodejs nokogiri...

sudo apt-get install libxslt1-dev libxml2-dev build-essential patch libsqlite3-dev libcurl4-openssl-dev curl git git-gui vim-gtk exuberant-ctags nodejs nodejs-legacy rar

Ruby

sudo apt-add-repository ppa:brightbox/ruby-ng

sudo apt-get update

require 'watir'
browser = Watir::Browser.new :chrome
browser.goto('https://m.adidas.com/us/myaccount')
browser_iframe = browser.iframe(id: 'loginaccountframe')
browser_iframe.text_field(id: 'username').set('[email protected]')
browser_iframe.text_field(name: 'password').set('09042015a')
browser_iframe.send_keys :enter
Watir::Wait.until { browser.text.include? 'Logout' }
@dthtien
dthtien / gist:ebaf4bd3f273d703028a5e9284976529
Last active May 9, 2017 09:20 — forked from schneems/gist:3029994
Databases and Rails Recap Quiz for Week 4
## 1) What does MVCr stand for?
Model View Control Router
## 2) In what file do we store 'r' from MVCr ?
## Week 5 Quiz
## 0) Name 3 types of variables in Ruby? Put them in order from least scope to greatest.
1. Local variable(new = "foo")
2. Instan variable(@new="foo")
3.Constant(NEW="foo")
## 1) Where do SQL queries belong, the view or controller?
## 1) Instance or class method?
A) User.where(:name => 'rich')
- class method
## 1) What is SQL Injection
QL Injection is a security vulnerability where an attacker can run arbitrary SQL code on your machine because we are not using safe Active Record practices.
## 2) Which of these are safe from SQL Injection attacks?
A) safe
User.where(:name => params[:name])
@dthtien
dthtien / rails-postgres-backbone-bootstrap-bootswatch
Created May 26, 2017 17:20 — forked from sionc/rails-postgres-backbone-bootstrap-bootswatch
Instructions on creating a new app using Ruby on Rails, Postgresql, Backbone.js, Twitter Boostrap, Bootstwatch
- Check rails version
$ rails -v
- To update rails
$ gem update rails
- Creating a new rails app using postgresql
$ mkdir rails_projects
$ cd rails_projects
$ rails new myapp --database=postgresql
@dthtien
dthtien / ubuntu_agnoster_install.md
Created June 8, 2017 13:57 — forked from renshuki/ubuntu_agnoster_install.md
Ubuntu 14.04 + Terminator + Oh My ZSH with Agnoster Theme

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

# config valid for current version and patch releases of Capistrano
lock "~> 3.11.0"
set :message, "Deploy voucher trader api app"
set :application, "voucher_trader_api"
set :repo_url, "[email protected]:dthtien/voucher_trader_api.git "
set :deploy_user, 'deploy'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
@dthtien
dthtien / app.DockerFile
Created August 26, 2018 15:14 — forked from satendra02/app.DockerFile
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran: