Skip to content

Instantly share code, notes, and snippets.

View xuannghia's full-sized avatar
:octocat:
hihi

Xuân Nghĩa xuannghia

:octocat:
hihi
View GitHub Profile
@xuannghia
xuannghia / slugify.js
Last active March 29, 2023 06:46
Xóa dấu tiếng Việt để làm slug
/**
* Slugify a string
* @param {string} str
* @param {string=} separator
* @returns {string}
*/
export const slugify = (str, separator = '-') => {
return str
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
FROM php:7.4-fpm-alpine
WORKDIR /var/www/html
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY ./onecom_api /var/www/html
@xuannghia
xuannghia / requests.js
Last active May 28, 2019 10:04
Send requests with axios include xsrf token (Reactjs)
import axios from 'axios'
import React from 'react'
axios.defaults.xsrfHeaderName = 'X-CSRFToken'
axios.defaults.xsrfCookieName = 'csrftoken'
axios.defaults.withCredentials = true
const checkError = response => {
let status = response.status
if (status >= 400 && status < 500) {
@xuannghia
xuannghia / macbook.md
Last active March 22, 2020 04:54
Dăm ba cái app Macbook
export PATH=$PATH:/usr/local/sbin

1. Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. Python 3, virtutalenv

brew install python3
@xuannghia
xuannghia / get_alphabet_from_index.php
Last active August 25, 2018 07:23
Chuyển index sang dạng chữ alphabet. 0 => A; 1 => B;...25 => Z; 26 => AA...
<?php
// Get alphabet from index number
// 0 => A; 1 => B
// 25 => Z; 26 => AA
function get_alphabet_from_index($num)
{
$numeric = $num % 26;
$letter = chr(65 + $numeric);
$num2 = intval($num / 26);
if ($num2 > 0) {
@xuannghia
xuannghia / Install-MongoDB-4-CentOS-7.md
Last active July 21, 2018 10:18
Install MongoDB 4.0 on CentOS 7

1. Add MongoDB Repository

sudo vi /etc/yum.repos.d/mongodb-org-4.0.repo

Change content to:

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
@xuannghia
xuannghia / Initial-Server-CentOS-7.md
Last active October 28, 2020 19:58
Initial Server CentOS 7 - with NGINX, PHP 7.2, MariaDB 10.2, PostgreSQL 10 ,phpMyAdmin 4.8, MongoDB, Redis, Python3.6, NodeJS 10.15.3

1. Add Repositories

EPEL repository

sudo yum install -y epel-release

SCLo Software collections Repository

yum -y install centos-release-scl-rh centos-release-scl

Remi repository