Skip to content

Instantly share code, notes, and snippets.

View ktpm489's full-sized avatar
🎯
Focusing

ktpm489

🎯
Focusing
View GitHub Profile
@paulnguyen-mn
paulnguyen-mn / js-expired-token.js
Created March 24, 2020 16:04
Xử lý expired token trong javascript (js nâng cao)
// Easy Frontend
// Học FE đơn giản, dễ hiểu và đặc biệt phải vui ❤️
// JS NÂNG CAO - Xử lý expired token trong Javascript như thế nào?
// ❓ Chuyện gì xảy ra nếu giữa chừng token bị expired?
// Ví dụ: 3 api requests đồng thời với nhau
// TRƯỜNG HỢP 1: Token chưa expired, vẫn còn tốt chán 🤣
// --request 1-->
@ktpm489
ktpm489 / cache.service.js
Created August 5, 2019 07:59 — forked from dsternlicht/cache.service.js
Cache service wrapper for node-cache module
import NodeCache from 'node-cache';
class Cache {
constructor(ttlSeconds) {
this.cache = new NodeCache({ stdTTL: ttlSeconds, checkperiod: ttlSeconds * 0.2, useClones: false });
}
get(key, storeFunction) {
const value = this.cache.get(key);
@ktpm489
ktpm489 / Cryptojs
Last active April 16, 2019 12:12 — forked from MAAARKIN/Cryptojs
//var salt = CryptoJS.lib.WordArray.random(256/32);
//var iv = CryptoJS.lib.WordArray.random(256/32);
//console.log('salt '+ salt );
//console.log('iv '+ iv );
var salt = CryptoJS.enc.Hex.parse("28698aadc97f3ad8");
var iv = CryptoJS.enc.Hex.parse("73ac39603da6e205");
console.log('salt '+ salt );
console.log('iv '+ iv );
var key128Bits = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 256/32 });
@quangdh
quangdh / codepush.md
Last active May 6, 2021 02:48
Tổng hợp các lệnh Code Push cơ bản

TỔNG HỢP CÁC LỆNH CODEPUSH CLI CƠ BẢN

Nhóm lệnh cơ bản

Login vào tài khoản AppCenter

code-push login

Logout tài khoản AppCenter

code-push logout

Xem đang login vào tài khoản AppCenter nào

code-push whoami

@asoorm
asoorm / docker-compose-mongo-replicaset.yml
Created September 14, 2018 19:00
Mongo Replica Set docker compose
version: "3"
services:
mongo1:
hostname: mongo1
container_name: localmongo1
image: mongo:4.0-xenial
expose:
- 27017
ports:
- 27011:27017
@SagiMedina
SagiMedina / ImageTools.js
Last active September 7, 2024 04:39
Resize and crop images in the Browser with orientation fix using exif
import EXIF from 'exif-js';
const hasBlobConstructor = typeof (Blob) !== 'undefined' && (function checkBlobConstructor() {
try {
return Boolean(new Blob());
} catch (error) {
return false;
}
}());
@ktpm489
ktpm489 / node-folder-structure-options.md
Created May 29, 2018 16:06 — forked from lancejpollard/node-folder-structure-options.md
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@luciopaiva
luciopaiva / _Full-socketio-client-and-server-example.md
Last active January 24, 2025 14:53
Full socket.io client and server example

Full socket.io client and server example

Last updated: 2021-02-21, tested with socket.io v3.1.1

This is the simplest implementation you will find for a client/server WebSockets architecture using socket.io.

To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.

If you're looking for examples using frameworks, check these links:

@dsternlicht
dsternlicht / feeds.model.js
Last active January 5, 2021 10:24
Feeds model with cache
// Feeds model after cache
import DB from '../db';
import CacheService from '../cache.service';
const ttl = 60 * 60 * 1; // cache for 1 Hour
const cache = new CacheService(ttl); // Create a new cache service instance
const FeedModel = {