Skip to content

Instantly share code, notes, and snippets.

View vanhtuan0409's full-sized avatar

Tuấn Vương vanhtuan0409

View GitHub Profile
import React, { useEffect } from "react";
import Header from "../components/Header";
import SiteMap from "../components/SiteMap";
import Link from "next/link";
const Index = ({ blogs }) => {
console.log("This is a component");
useEffect(() => {
console.log("Index mounted");
});
# config_live_env.py
URL = "https://now.vn"
# config_test_env.py
URL = "http://localhost"
# config.py
import os
env = os.environ.get("APP_ENV", "TEST")
@vanhtuan0409
vanhtuan0409 / main.go
Last active July 16, 2019 08:14
Go Mock and Testing
package main
import (
"errors"
"fmt"
)
var (
errInvalidID = errors.New("invalid id")
)
package main
import (
"fmt"
"strings"
"text/scanner"
)
func test(str string) {
fmt.Println(str, " ==> ", validate(str))
# Add this to ~/.ssh/config
Host <host_alias>
HostName <server_ip>
User <login_username>
IdentityFile <ssh_key>
@vanhtuan0409
vanhtuan0409 / grpclz4.go
Created February 18, 2019 02:19 — forked from linxGnu/grpclz4.go
lz4 encoding for gRPC (connection) encoding. We (at LINE Corp) will try to publish it soon.
// Copyright 2019 LINE Corporation
//
// LINE Corporation licenses this file to you under the Apache License,
// version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//https://leetcode.com/problems/two-sum/description/
function twoSum(nums, target) {
const reversedIndexMapping = {};
for (let i = 0; i < nums.length; i++) {
const num = nums[i];
reversedIndexMapping[num] = i;
}
for (let i = 0; i < nums.length; i++) {
function parseFunctionSignature(s) {
const typeRegex = "(int|string|float|bool|void)";
const nameRegex = "([a-zA-Z]\\w{0,19})";
const paramRegex = `${typeRegex}\\s+${nameRegex}`;
const paramsListRegex = `(?:${paramRegex}(?:,\\s*${paramRegex})*)?`;
const signatureRegex = `${paramRegex}\\(${paramsListRegex}\\)`;
let matches = s.match(signatureRegex);
matches = matches.filter(m => m !== undefined);
const returnType = matches[1];
const functionName = matches[2];
// https://leetcode.com/problems/house-robber/description/
/**
* @param {number[]} nums
* @return {number}
*/
var rob = function(nums) {
if (nums.length === 0) return 0;
if (nums.length === 1) return nums[0];
const dynamicArray = [nums[0]];
const express = require('express');
const http = require('http');
// Line 45 của em
const app = express();
const server = http.Server(app);
// Thay line 97 của em thành
server.listen(port, () => console.log("..."));