Posts

Showing posts from June, 2018

Git: Thay Đổi Commit Cuối Cùng (commit amend)

Nếu như bạn thực hiện xong commit và rồi sau đó mới nhận ra rằng đã quên tổ chức các thay đổi trong tập tin bạn muốn để thêm vào commit đó, bạn có thể chạy lệnh sau: $ git add forgotten_file $ git commit --amend $ git push --force

Delete the second last commit

Delete the second last commit Let's say the bad commit  dd61ab32  is not the top commit, but a slightly older one, e.g. the second last one. We want to remove it, but keep all commits that followed it. In other words, we want to rewrite the history and force the result back to  mathnet/master . The easiest way to rewrite history is to do an interactive rebase down to the parent of the offending commit: 1: $ git rebase -i dd61ab32^ This will open an editor and show a list of all commits since the commit we want to get rid of: 1: 2: 3: pick dd61ab32 pick dsadhj278 .. . Simply remove the line with the offending commit, likely that will be the first line (vi: delete current line =  dd ). Save and close the editor (vi: press  :wq  and return). Resolve any conflicts if there are any, and your local branch should be fixed. Force it to the remote and you're done: 1: $ git push mathnet -f

Git Rebase

Image
Referal link:  https://git-scm.com/book/vi/v1/Ph%C3%A2n-Nh%C3%A1nh-Trong-Git-Rebasing - Firstly: - Merge: - Rebase: - Step 1: $ git checkout experiment $ git rebase master First, rewinding head to replay your work on top of it... Applying: added staged command - Step 2: Đến lúc này, bạn có thể quay lại nhánh  master  và thực hiện fast-forward merge $ git checkout master $ git merge experiment **Note** - rebase vo "nhanh chinh". - merge tu "nhanh phu"

Understand promises before you start using async/await

Referal link:  https://medium.com/@bluepnume/learn-about-promises-before-you-start-using-async-await-eb148164a9c8 Understand promises before you start using async/await With Babel now supporting async/await out of the box, and ES2016 (or ES7) just around the corner, more and more people are realizing how awesome this pattern is for writing asynchronous code, using synchronous code structure. This is a good thing™, and ought to improve code quality a whole lot. However, what a lot of people may have missed is that the entire foundation for async/await is promises . In fact every async function you write will return a promise, and every single thing you await will ordinarily be a promise. Why am I emphasizing this? Because so much javascript written today is written using the callback pattern, a lot of people just never got on the promise bandwagon, and they’re missing an important part of the async/await puzzle. What even is a promise? I’ll keep this b...

Beginner’s guide to Webpack

Image
Beginner’s guide to Webpack Referal Link:  https://medium.com/javascript-training/beginner-s-guide-to-webpack-b1f1a3638460 Or what I wish I knew when starting with Wepback. Click here to go to the final Github repo. We are using Webpack 1.x. Webpack 2 will not work with this tutorial. Click here to view the Webpack changelog. Webpack is the latest and greatest in front-end development tools. It is a module bundler that works great with the most modern of front-end workflows including Babel, ReactJS, CommonJS, among others. As a beginner to Webpack, this is what I have learned. This tutorial has been updated to use Babel 6 Getting Started Webpack Conventions Webpack works best with NPM, not Bower Uses a module system (AMD, CommonJS, ES6) Installing Webpack globally: npm install webpack -g The most basic of builds: In your root directory create 2 files: index.html & app.js In app.js: document.write('welcome to my app'); console.log('...