Skip to content

Instantly share code, notes, and snippets.

View hoasung01's full-sized avatar
🎯
Focusing

nguyenngochai hoasung01

🎯
Focusing
View GitHub Profile
@hoasung01
hoasung01 / System Design.md
Created December 28, 2019 08:04 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@hoasung01
hoasung01 / callback.rb
Last active August 20, 2019 04:32
[code_smells] - callback
# source: ruby science ebook
# app/models/survey_inviter.rb
def deliver_invitations recipients.map do |recipient_email|
Invitation.create!(
survey: survey,
sender: sender,
recipient_email: recipient_email,
status: 'pending',
message: @message
@hoasung01
hoasung01 / codeforces_problem_572_A.py
Created July 7, 2018 01:54
codeforces_problem_572_A
#### home exercise ####
# http://codeforces.com/problemset/problem/572/A
# wrong test case 6:
# Input
# 3 3
# 1 1
# 1 2 3
# 1 2 3
# Output
@hoasung01
hoasung01 / interviewitems.MD
Created September 10, 2017 08:32 — forked from KWMalik/interviewitems.MD
My answers to over 100 Google interview questions

##Google Interview Questions: Product Marketing Manager

  • Why do you want to join Google? -- Because I want to create tools for others to learn, for free. I didn't have a lot of money when growing up so I didn't get access to the same books, computers and resources that others had which caused money, I want to help ensure that others can learn on the same playing field regardless of their families wealth status or location.
  • What do you know about Google’s product and technology? -- A lot actually, I am a beta tester for numerous products, I use most of the Google tools such as: Search, Gmaill, Drive, Reader, Calendar, G+, YouTube, Web Master Tools, Keyword tools, Analytics etc.
  • If you are Product Manager for Google’s Adwords, how do you plan to market this?
  • What would you say during an AdWords or AdSense product seminar?
  • Who are Google’s competitors, and how does Google compete with them? -- Google competes on numerous fields: --- Search: Baidu, Bing, Duck Duck Go
@hoasung01
hoasung01 / subdomain-localhost-rails-5.md
Created June 11, 2017 07:49 — forked from indiesquidge/subdomain-localhost-rails-5.md
how to access subdomains locally with Rails 5

Subdomaining Localhost with Rails 5

I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api

Rails.application.routes.draw do
  constraints subdomain: "api" do
    scope module: "api" do
module TableHelpers
module ArrayMethods
def find_row(expected_row)
find_index do |row|
expected_row.all? do |expected_column|
first_column = row.find_index do |column|
content = normalize_content(column.content)
expected_content = normalize_content(expected_column)
matching_parts = expected_content.split(/\s*\*\s*/, -1).collect { |part| Regexp.escape(part) }
@hoasung01
hoasung01 / chef.md
Created February 16, 2017 01:33 — forked from oNguyenThanhTung/chef.md
Tìm hiểu về Chef

Tìm hiểu về Chef

##Giới thiệu

Trong các giai đoạn phát triển các ứng dụng, dịch vụ dùng server thì việc xây dựng deployment là không thể thiếu được. Giai đoạn này đòi hỏi người thiết định phải có kinh nghiệm, kiến thức về server, cấu hình hệ thống, performance. Đặc biệt là đối với các hệ thống có số node (server) từ 2 hoặc nhiều hơn thì việc thống nhất giữa 2 server là rất quan trọng. Người thực hiện bắt buộc phải ghi nhớ các libraries, tools của từng loại server (DB server thế nào, Cache server, Web server như thế nào). Ngoài ra các thiết lập, cấu hình đã dùng trong quá trình development và production cũng phải đảm bảo tính thống nhất. Do đó quá trình deployment thường gặp phải các khó khăn

@hoasung01
hoasung01 / cancan_matchers.rb
Created November 26, 2016 23:50 — forked from fotinakis/cancan_matchers.rb
Custom rspec matcher for testing CanCan abilities
# Custom rspec matcher for testing CanCan abilities.
# Originally inspired by https://github.com/ryanb/cancan/wiki/Testing-Abilities
#
# Usage:
# should have_abilities(:create, Post.new)
# should have_abilities([:read, :update], post)
# should have_abilities({manage: false, destroy: true}, post)
# should have_abilities({create: false}, Post.new)
# should not_have_abilities(:update, post)
# should not_have_abilities([:update, :destroy], post)