Skip to content

Instantly share code, notes, and snippets.

View thuongnn's full-sized avatar
🎯
Focusing

Nguyen Nhu Thuong thuongnn

🎯
Focusing
View GitHub Profile
#!/bin/sh
set +e
set -o noglob
#
# Set Colors
#
bold=$(tput bold)
/* @flow */
const defaultDiacriticsRemovalMap = [{
'base': 'A',
'letters': '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F'
}, {
'base': 'AA',
'letters': '\uA732'
}, {
'base': 'AE',
@thuongnn
thuongnn / SomeComponent.tsx
Created October 2, 2019 14:45 — forked from PTKC/SomeComponent.tsx
Google Autocomplete Example with Ant Design
import { Card, Col, Divider, Form, Input, Row } from "antd";
import { LocationSearchInput } from "./location-search";
import { geocodeByAddress, getLatLng } from "react-places-autocomplete";
import { FormComponentProps } from "antd/lib/form/Form";
type Props = {} & FormComponentProps;
type State = {
address: string;
};
@thuongnn
thuongnn / Find Duplicate Paragraphs MS Word.vb
Last active July 31, 2019 13:41
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window. 2. And then, click Insert > Module, copy and paste below code into the opened blank module. 3. And then press F5 key to run this code, all the duplicate sentences are highlighted at once.
Sub FindDuplicateParas()
Application.ScreenUpdating = False
Dim i As Long, RngSrc As Range, RngFnd As Range
Const Clr As Long = wdBrightGreen
Dim eTime As Single
eTime = Timer
Options.DefaultHighlightColorIndex = Clr
With ActiveDocument
With .Range.Find
.ClearFormatting
let questions = document.getElementsByClassName("SetPageTerm-side SetPageTerm-largeSide");
let answers = document.getElementsByClassName("SetPageTerm-side SetPageTerm-smallSide");
let dataCrawl = localStorage.getItem("dataCrawl") || "";
for (let i = 0; i < questions.length; i++) {
let keyAns = `${answers.item(i).firstChild.firstChild.firstChild.childNodes[0].nodeValue.toLocaleLowerCase()}.`;
questions.item(i).firstChild.firstChild.firstChild.childNodes.forEach((data, index) => {
if (index === 0) dataCrawl += `${data.nodeValue} | `;
else if (data.nodeValue !== null) {
let formatAns = data.nodeValue.toLocaleLowerCase().trim().substring(0, 2);
if (keyAns === formatAns) dataCrawl += `${data.nodeValue.replace(keyAns, "")}\n`;
let questions = document.getElementsByClassName("SetPageTerm-side SetPageTerm-smallSide");
let answers = document.getElementsByClassName("SetPageTerm-side SetPageTerm-largeSide");
let dataCrawl = localStorage.getItem("dataCrawl") || "";
for (let i = 0; i < questions.length; i++) {
let question = questions.item(i).firstChild.firstChild.firstChild.childNodes[0].nodeValue;
let answer = answers.item(i).firstChild.firstChild.firstChild.childNodes[0].nodeValue;
dataCrawl += `${question} | ${answer}\n`;
}
localStorage.setItem("dataCrawl", dataCrawl);
console.log(`Crawl done ${questions.length} records ! Please run [localStorage.getItem("dataCrawl")] to get results.`);
let content = document.getElementsByClassName("content");
let dataCrawl = localStorage.getItem("dataCrawl") || "";
for (let i = 0; i < content.length; i++) {
let data = content.item(i).childNodes[0];
data.childNodes.forEach(child => {
if (child.className === "qtext") dataCrawl += `\n${child.innerText}`;
if (child.className === "ablock") {
dataCrawl += `\n${child.childNodes[0].firstChild.nodeValue}`;
child.childNodes[1].childNodes.forEach(ans => {
if (ans.childNodes[1]) dataCrawl += `\n${ans.childNodes[1].innerText}`;
let dataCrawl = localStorage.getItem("dataCrawl") || "";
let lessonCrawl = localStorage.getItem("lessonCrawl") || "";
let lesson = document.getElementsByClassName("hd hd-2 unit-title")[0].innerText;
lessonCrawl += lessonCrawl === "" ? lesson : `, ${lesson}`;
localStorage.setItem("lessonCrawl", lessonCrawl);
let containers = document.getElementsByClassName("wrapper-problem-response");
for (let i = 0; i < containers.length; i++) {
let correct = "Ans:";
let count = 0;
containers.item(i).getElementsByTagName("fieldset").item(0).childNodes.forEach(con => {
let credits = 0, count = 0, total = 0.0;
document.getElementsByClassName('table table-hover')[0].getElementsByTagName('tbody')[0].childNodes.forEach(tr => {
let x8 = tr.childNodes[8] ? tr.childNodes[8].firstChild ? tr.childNodes[8].firstChild.firstChild : null : null,
x7 = tr.childNodes[7] ? tr.childNodes[7].firstChild ? tr.childNodes[7].firstChild.firstChild : null : null,
x3 = tr.childNodes[3] ? tr.childNodes[3].firstChild : null,
x6 = tr.childNodes[6] ? tr.childNodes[6].firstChild : null;
if (x6 !== null && x7 !== null && x8.textContent === "Passed") {
count++;
console.log("[A" + count + "]: Name: " + x3.textContent + " | Credit: " + x6.textContent + " | Point: " + x7.textContent + " | Status: \x1b[32m" + x8.textContent);
credits += Number(x6.textContent);