Skip to content

Instantly share code, notes, and snippets.

View congdinh's full-sized avatar
🤠
Always learning

Neo congdinh

🤠
Always learning
View GitHub Profile
@congdinh
congdinh / index.js
Last active May 9, 2019 10:00
Test node http port
var http = require("http");
var serverFunction = function(req, res) {
if (req.url == "/") {
console.log("get method");
res.writeHead(200, { "content-type": "text/plain" });
res.end("Hello World");
}
};
var server = http.createServer(serverFunction);
server.listen(3002, function() {
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -
wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
######################## http.conf ######################
server {
listen 80;
server_name xxx.com;
access_log /var/log/nginx/xxx.access.log main;
error_log /var/log/nginx/xxx.error.log error;
root /opt;
location / {
@congdinh
congdinh / javascript.json
Last active May 11, 2020 07:59
User snippets Setting Vscode: preferences > Users snippets
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@congdinh
congdinh / setting-vscode-format
Last active January 2, 2019 12:38
File > Preferences > Settings > Tab User Settings
{
"window.zoomLevel": 0,
"editor.renderControlCharacters": true,
"workbench.activityBar.visible": true,
"editor.renderWhitespace": "all",
"diffEditor.ignoreTrimWhitespace": false,
"editor.wordWrap": "on",
// Controls if quick suggestions should show up while typing
"editor.quickSuggestions": true,
// Controls if suggestions should be accepted with "Enter" - in addition to "Tab". Helps to avoid ambiguity between inserting new lines and accepting suggestions.
const removeDiacritics = (str) => {
str = str.toLowerCase();
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
str = str.replace(/đ/g, "d");
str = str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'|\"|\&|\#|\[|\]|~|\$|_|`|-|{|}|\||\\/g, " ");
@congdinh
congdinh / sets.js
Created February 27, 2018 09:47 — forked from clohr/sets.js
ES6 Sets: Intersection, Difference, and Union
const a = new Set([1, 2, 3, 4, 4, 4])
const b = new Set([3, 4, 5, 6])
const intersect = (set1, set2) => [...set1].filter(num => set2.has(num))
const differ = (set1, set2) => [...set1].filter(num => !set2.has(num))
const joinSet = (set1, set2) => [...set1, ...set2]
const myIntersectedSet = new Set(intersect(a, b))
console.log('myIntersectedSet', myIntersectedSet)
import React from 'react';
import { sentiments } from "config";
import { percentage } from 'utils/index';
import './ParentChildLabelBySentimentBar.css';
import { labelFilter } from './filterLabels.js';
export default (props) => {
if (!props.data) {
return <span>No data</span>;
}
[{"_id":"58d1eecdea5f877e43a6afb9","name":"mShield","check":1,"labels":[],"__typename":"Label"},{"_id":"58d230e0ea5f877e43a6b4b4","name":"Thương hiệu","check":1,"labels":[{"_id":"58d2318aea5f877e43a6b4c6","name":"Hoạt động kinh doanh","check":1,"__typename":"Label"},{"_id":"58d231b2ea5f877e43a6b4ca","name":"Ban lãnh đạo","check":1,"__typename":"Label"},{"_id":"58d231cfea5f877e43a6b4ce","name":"Hoạt động xã hội","check":1,"__typename":"Label"}],"__typename":"Label"},{"_id":"58d230efea5f877e43a6b4b6","name":"Chiến dịch truyền thông","check":1,"labels":[{"_id":"58d230e8ea5f877e43a6b4b5","name":"Hoạt động trên fanpage","check":1,"__typename":"Label"},{"_id":"58d23157ea5f877e43a6b4c1","name":"Khuyến mãi","check":1,"__typename":"Label"},{"_id":"58d231bfea5f877e43a6b4cc","name":"Quảng cáo","check":1,"__typename":"Label"},{"_id":"58d231c5ea5f877e43a6b4cd","name":"Sự kiện","check":1,"__typename":"Label"},{"_id":"58e76a389ce313be0eb8c966","name":"Được sử dụng làm quà tặng","check":1,"__typename":"Label"}],"__typename":
import React from 'react';
import HighChart from './HighChart';
import { defaultHighchart } from 'config';
const optionsDefault = {
chart: {
plotBackgroundColor: null,
plotBorderWidth: 0,
plotShadow: false,
style: {