Skip to content

Instantly share code, notes, and snippets.

View tonyxu-io's full-sized avatar
😀
Busy?

Tony Xu tonyxu-io

😀
Busy?
View GitHub Profile
@tonyxu-io
tonyxu-io / merge-sort-array.js
Last active June 25, 2018 03:18
Array #DataStructureAlgorithms
// Merge two arrays
function merge(arr1, arr2) {
var res = []
while (arr1.length > 0 && arr2.length > 0) {
if (arr1[0] < arr2[0]) {
res.push(arr1.shift())
} else {
res.push(arr2.shift())
}
}
@tonyxu-io
tonyxu-io / _tree.js
Last active June 25, 2018 03:18
Tree #DataStructureAlgorithms
// Tree Node Definition
function TreeNode(val) {
this.val = val;
this.left = this.right = null;
}
// Tree Creation
var t = new TreeNode(10)
t.left = new TreeNode(-2)
t.right = new TreeNode(6)
@tonyxu-io
tonyxu-io / rest-api-sample-javascript.js
Last active June 25, 2018 03:19
REST API Call Sample Code #snippet
// Vanilla JS - GET
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://reqres.in/api/users', true);
xhr.onload = function () {
console.log(xhr.responseText)
};
xhr.send(null);
// Vanilla JS - POST
var xhr = new XMLHttpRequest();
@tonyxu-io
tonyxu-io / index.html
Last active June 25, 2018 03:19
postMessage sample code #snippet
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index</title>
<button onclick="openWindow()">Open Window</button>
<script type="text/javascript">
function openWindow(){
window.open ("popup.html","popup", "width=350,height=250");
window.addEventListener(
@tonyxu-io
tonyxu-io / sublime-text-cheat-sheet.md
Last active June 25, 2018 03:19
Sublime Text Cheat Sheet #cheatsheet

Sublime快捷键之Mac

备注:具体符号对应的按键

  • ⌘ Command key
  • ⌃ Control key
  • ⌥ Option key
  • ⇧ Shift Key

为了方便大家记忆,将快捷键分成了8个类型, 分别为

@tonyxu-io
tonyxu-io / awesome-cheat-sheets.md
Last active June 25, 2018 03:19
Awesome Cheat Sheets #cheatsheet
@tonyxu-io
tonyxu-io / vi-cheat-sheet.md
Last active June 25, 2018 03:19
VIM Cheat Sheet #cheatsheet

Cursor movement

h - move left
j - move down
k - move up
l - move right
w - jump by start of words (punctuation considered words)
W - jump by words (spaces separate words)

e - jump to end of words (punctuation considered words)

@tonyxu-io
tonyxu-io / git-cheat-sheet.md
Last active June 25, 2018 03:20
Git Cheat Sheet #cheatsheet
@tonyxu-io
tonyxu-io / mac-terminal-cheat-sheet.md
Last active June 25, 2018 03:20
Mac Terminal Cheatsheet #cheatsheet

Mac Terminal Cheat Sheet

SHORTCUTS

Key/Command Description
Ctrl + A Go to the beginning of the line you are currently typing on. This also works for most text input fields system wide. Netbeans being one exception
Ctrl + E Go to the end of the line you are currently typing on. This also works for most text input fields system wide. Netbeans being one exception
Ctrl + Q Clears everything on current line
Ctrl + L Clears the Screen
@tonyxu-io
tonyxu-io / google-oauth-login.html
Last active November 5, 2019 08:00
Google OAuth #snippet
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index</title>
<button onclick="openWindow()">Login</button>
<pre id="access_token"></pre>
<pre id="tokenInfo"></pre>
<pre id="userInfo"></pre>