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 / apache
Last active November 4, 2016 03:54 — forked from felipelavinz/apache
Canonical redirects for Apache, lighttpd and nginx
## Canonical redirect for Apache
# BEGIN Canonical Redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC] ## will match any domain that's not our main domain
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>
# END Canonical Redirect
@hoasung01
hoasung01 / SOLID.markdown
Created November 1, 2016 07:19 — forked from emaraschio/SOLID.markdown
SOLID Principles with ruby examples

#SOLID Principles with ruby examples

##SRP - Single responsibility principle A class should have only a single responsibility.

Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.

##OCP - Open/closed principle Software entities should be open for extension, but closed for modification.

@hoasung01
hoasung01 / post_comment_chart.js.jsx
Created October 22, 2016 04:29
post-comment-chart
var PostsCommentsChart = React.createClass({
getInitialState: function() {
return {
data: [],
step: ""
};
},
handleChange: function(data) {
var self = this;
@hoasung01
hoasung01 / tab-avenue28
Created September 23, 2016 09:30
tab-avenue28-stuck-js-when-class-changed
.tab-content{:style => "margin-bottom: 80px"}
#summary.tab-pane.fade.in.active
.content-box
%h4.block-header
= t("labels.project.opportunity_summary")
.show-more-content
.short-content
= raw(@project.investment_sumary)
.show-more-gradient
.text-right.show-more-link Show more
@hoasung01
hoasung01 / contact-us.php
Last active September 16, 2016 03:43
mailerphp
<?php
require_once('./Mail-1.3.0/Mail.php');
echo '>>> vao diiiii >>>>';
if(isset($_POST['send'])):
echo '>>>>vao submit>>>>';
if(isset($_POST['g-recaptcha-response'])):
echo '>>>>vao check recaptcha >>>';
//your site secret key
$secret = 'xxx';
// information made available through the dataLayer is easily used in Google Tag Manager.
// GTM-XXXXXX has to be changed to the actual GTM-code as shown in the implementation document
dataLayer = [{
'pageTitle': 'page title variable', //example
'loggedIn': 'TRUE', //example
'CLV': '2249.50', //example (only use . seperator for cents)
'userID': 'AB12345678' //example
}];
<!-- Google Tag Manager -->
@hoasung01
hoasung01 / jquery-mousewheel-fix-on-firefox
Created July 19, 2016 08:52
fix jquery mousewheel work on firefox
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Horizontally Scrolling Site from CSS-Tricks</title>
<link rel="stylesheet" href="style.css">