Skip to content

Instantly share code, notes, and snippets.

View dongnguyenltqb's full-sized avatar
🏠
Working from home

Dong Nguyen dongnguyenltqb

🏠
Working from home
View GitHub Profile
@dongnguyenltqb
dongnguyenltqb / remove_tuxera.sh
Created January 13, 2018 16:36 — forked from miguelmota/remove_tuxera.sh
Completely uninstall and remove Tuxera NTFS on MacOs (resets trial version)
rm -rf /Applications/Tuxera\ Disk\ Manager.app
rm -rf /Library/Application\ Support/Tuxera\ NTFS
rm -rf /Library/Filesystems/fusefs_txantfs.fs
function tong(a,b){
while(a.length<b.length) a="0"+a;
while (a.length >b.length) b = "0" + b;
a="0"+a;
b="0"+b;
var du=0;
var c="";
for(var i=a.length-1;i>=0;i--){
c=((Number(a[i])+Number(b[i])+du)%10).toString()+c;
du = Math.floor((Number(a[i]) + Number(b[i]) + du) / 10);
function chuan_hoa_xau(str0) {
var str = "";
for (let i = 0; i < str0.length; i++) {
if ((str0[i] !== `[`) && (str0[i] !== `]`) && (str0[i] !== `;`)
&& (str0[i] !== `=`)
) str += str0[i];
}
str = str.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '');
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
const z_algo=(s)=>{
let n = s.length;
var z = [n];
let l=0,r=0;
for (let i = 1; i < n; i++) {
if (i > r) {
l = r = i;
while (r < n && s[r - l] == s[r]) r += 1;
z[i] = r - l;
r -= 1;
function qs(l, r,a) {
var i = l;
var j = r;
var key = a[Math.floor((l + r) / 2)];
do {
while (a[i] < key) i++;
while (a[j] > key) j--;
if (i <= j) {
let t = a[i];
a[i] = a[j];
@dongnguyenltqb
dongnguyenltqb / imgurl_image_uploader.js
Created July 20, 2018 08:17
upload image base64 and return json data
import axios from 'axios';
export default (base64)=>{
return new Promise(async (solved, reject) => {
try {
let axiosConfig = {
headers: {
'Content-Type': 'application/json;charset=UTF-8',
'Authorization': 'Client-ID 09731551a5dedbe'
}
}
@dongnguyenltqb
dongnguyenltqb / nonAccentVietnamese.js
Created January 5, 2019 14:20 — forked from jarvisluong/nonAccentVietnamese.js
Converting standard Vietnamese Characters to non-accent ones. Example: hải -> hai
function nonAccentVietnamese(str) {
str = str.toLowerCase();
// We can also use this instead of from line 11 to line 17
// str = str.replace(/\u00E0|\u00E1|\u1EA1|\u1EA3|\u00E3|\u00E2|\u1EA7|\u1EA5|\u1EAD|\u1EA9|\u1EAB|\u0103|\u1EB1|\u1EAF|\u1EB7|\u1EB3|\u1EB5/g, "a");
// str = str.replace(/\u00E8|\u00E9|\u1EB9|\u1EBB|\u1EBD|\u00EA|\u1EC1|\u1EBF|\u1EC7|\u1EC3|\u1EC5/g, "e");
// str = str.replace(/\u00EC|\u00ED|\u1ECB|\u1EC9|\u0129/g, "i");
// str = str.replace(/\u00F2|\u00F3|\u1ECD|\u1ECF|\u00F5|\u00F4|\u1ED3|\u1ED1|\u1ED9|\u1ED5|\u1ED7|\u01A1|\u1EDD|\u1EDB|\u1EE3|\u1EDF|\u1EE1/g, "o");
// str = str.replace(/\u00F9|\u00FA|\u1EE5|\u1EE7|\u0169|\u01B0|\u1EEB|\u1EE9|\u1EF1|\u1EED|\u1EEF/g, "u");
// str = str.replace(/\u1EF3|\u00FD|\u1EF5|\u1EF7|\u1EF9/g, "y");
// str = str.replace(/\u0111/g, "d");
@dongnguyenltqb
dongnguyenltqb / google_search.js
Created January 29, 2019 11:02
google_search.js
io.of('/ggseach').on('connection', function (socket) {
console.log(`News user connected :${socket.id}`);
socket.on('getResult',keyword=>{
axios.get(`http://google.com/complete/search`,{
params:{
hl:'vi',
q:keyword,
client:'firefox'
},
responseType:'arraybuffer'
import express from 'express';
import path from 'path';
import logger from 'morgan';
import bodyParser from 'body-parser';
import 'dotenv/config';
import session from 'express-session';
import passport from 'passport';
import GoogleStrategy from 'passport-google-oauth20';
const app = express();
app.disable('x-powered-by');
@dongnguyenltqb
dongnguyenltqb / array_prototype.js
Created November 10, 2019 08:02
Array Prototype
Array.prototype.quicksort = function(){
var qs = function(arr,l,r){
if(l>=r) return;
var key = arr[Math.floor((l+r)/2)];
let i = l,
j = r;
while(i<=j){
while (arr[i] < key) i++;
while (arr[j] > key) j--;
if(i<=j){