Category Jekyll

Xây dựng trang cá nhân với gem Jekyll

Hướng dẫn tạo 1 trang cá nhân, static blog trong vòng 10 phút với gem Jekyll.

Category Rails

Thread.new.join

Thread.new.join

Devise paranoid

For security and privacy, hide email not found message

[Shopify App] Open any link in new tab

You can't not open link in new tab with stacks: Rails, Turbolinks, React Polaris

Confident Rails ENV

This is my way to make sure all environment variables is filled

Rails 6.1 form_with update

Change form_with to generate non-remote forms by default

Better Rails where like query

Problem user_name = "I'm Tony" User.where("name like '%#{user_name}%'") # => SELECT `users`.* FROM `users` WHERE (name like '%I'm Tony%') => ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax;...

Set basic auth for specific environment

For all environment Set authentication in ApplicationController # app/controllers/application_controller.rb class ApplicationController < ActionController::Base http_basic_authenticate_with name: 'username', password: 'password' end

Rails cache fetch

Problem ```ruby def generate_job_id cached_value = Rails.cache.fetch(“cache_key”, expires_in: 24.hours) do

Ruby Array uniq

List post post_a (topic_name: "Ruby", priority: 10) post_b (topic_name: "PHP", priority: 9) post_c (topic_name: "Ruby", priority: 8)

Rails Size & Count

Mỗi khi exec query, Active Record sẽ tạo ra biến @loaded = true cho Relation đó.

Tối ưu CSV import với fingerprint

Mình đã giảm thời gian import CSV từ 6 tiếng xuống còn 50 phút với kĩ thuật fingerprint.

Ruby Set

Ruby Set - a list of unique items. Two special attributes: Fast lookup times (with include?) Unique values

Boolean type in Rails & Mysql

MySQL BOOLEAN data type, which is the synonym of TINYINT(1), value range [-128..127]

Be careful when use find_by

City.find_by(name: "Maria") || City.find_by(name: "Aoi") Liệu có giống với: City.find_by(name: ["Maria", "Aoi"])

Rails Logger and Rails Logging Best Practices

Logging provides critical value to applications with insight to usage, stats, and metrics, and saves us when debugging a problem. But we often leave logging to poorly implemented afterthoughts. So...

Category Git

Git branching model mà mình theo đuổi

Flow này có gọi là mô hình xương rồng (cactus model), xu hướng rewrite history. Tối giản tối đa git tree của bạn.

Dùng 2 account github trên cùng 1 thiết bị

Config lại file ~/.ssh/config

Category Memo

Category MySQL

Boolean type in Rails & Mysql

MySQL BOOLEAN data type, which is the synonym of TINYINT(1), value range [-128..127]

Category Bootstrap

Bootstrap 4 grid tier & reordering

Grid option From v4.0.0-alpha.6, the xs tier no longer requires a breakpoint abbreviation

Category HTML

HTML target _blank and blank

<a> tag document

Category ruby

Set basic auth for specific environment

For all environment Set authentication in ApplicationController # app/controllers/application_controller.rb class ApplicationController < ActionController::Base http_basic_authenticate_with name: 'username', password: 'password' end

Rails cache fetch

Problem ```ruby def generate_job_id cached_value = Rails.cache.fetch(“cache_key”, expires_in: 24.hours) do

Ruby Array uniq

List post post_a (topic_name: "Ruby", priority: 10) post_b (topic_name: "PHP", priority: 9) post_c (topic_name: "Ruby", priority: 8)

Category Server

Free HTTPS setup for your site

Let’s Encrypt is a free, automated, and open Certificate Authority.

Category Other

[VS Code] Add extensions enough to be dangerous

Visual Studio Code - Add extensions enough to be dangerous

Một vài Atom package hữu ích với web developer

Hôm nay mình xin phép được giới thiệu 1 số package mà mình thường sử dụng

Create instagram feed

Instagram is a simple way to capture and share the world's moments. Follow your friends and family to see what they're up to, and discover accounts from all ...

Category SQL

Better Rails where like query

Problem user_name = "I'm Tony" User.where("name like '%#{user_name}%'") # => SELECT `users`.* FROM `users` WHERE (name like '%I'm Tony%') => ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax;...

Category Node.js

Using Puppeteer in Google Cloud Functions

Setup package.js { "name": "sample-http", "version": "0.0.1", "dependencies": { "puppeteer": "^1.9.0" } }

Category javascript

You dont need Momentjs

Moment.js is a fantastic time & date library with lots of great features and utilities. However, if you are working on a performance sensitive web application, it might cause a...

Category Gcloud

GraphQL Invalid IAP credentials: empty token

Google App engine + Apollo GraphQL Invalid IAP credentials: empty token

Category GraphQL

GraphQL Invalid IAP credentials: empty token

Google App engine + Apollo GraphQL Invalid IAP credentials: empty token

Category HTML/CSS

Japanese kerning CSS

Khoảng cách của các kí tự tiếng Nhật của mình trông cứ sai sai...

Category Javascript

Spread object support for safari 10

Unexpected token '...'. Expected a property name on Safari 10

Category React

[Shopify App] Open any link in new tab

You can't not open link in new tab with stacks: Rails, Turbolinks, React Polaris

Category Shopify

[Shopify App] Open any link in new tab

You can't not open link in new tab with stacks: Rails, Turbolinks, React Polaris