Skip to content

Instantly share code, notes, and snippets.

View nmvuong92's full-sized avatar
🎯
Focusing

Vượng Nguyễn nmvuong92

🎯
Focusing
View GitHub Profile
@nmvuong92
nmvuong92 / ES.md
Last active September 6, 2018 08:52

ELASTICSEARCH

Các khái niệm, đơn vị

NRT near real time

Là ứng dụng gần thời gian thực, dưới 1 giây

cluster (cụm)

  • Một tập hợp Nodes (servers) chứa tất cả các dữ liệu.
  • Cái tên nói lên tất cả, 1 cụm cluster trong Elasticsearch là một nhóm của nhiều nút elasticsearch (nodes) được kết nối với nhau

cấu trúc http://localhost:9200/tên_index/tên_type/mã_id nguồn

https://www.linkedin.com/pulse/big-data-t%E1%BB%95ng-quan-v%E1%BB%81-elasticsearch-donald-trung-manh-nguyen/
$ curl -XPUT 'http://localhost:9200/blog/post/1' -d '{
   "author": "lucas",
 "tags": ["java", "web"],

redux saga

sagas/rootSage.js

import {delay} from 'redux-saga';
import {all} from 'redux-saga/effects';
  • effect là hàm kết nối redux-saga vào reducer
  • all là một redux saga effect dùng để chạy nhiều saga cùng 1 lúc
import { sayHello, watchIncrement, watchDecrement } from './counterSaga'; /*import 3 saga watch function*/

We can't really recommend a way to start root sagas however we can certainly explain better the effect. I think it's probably worth creating a dedicated documentation page.

// single entry point to start all Sagas at once

export default function* rootSaga() {
  yield [
    saga1(),
    saga2(),
    saga3(),

REDIS

  • Là ứng dụng lưu trữ cache key-value trên RAM

By default there are 16 databases (indexed from 0 to 15) and you can navigate between them using select command. Number of databases can be changed in redis config file with databases setting. để chọn database

select index

By default, it selects the database 0. To select a specified one, use redis-cli -n 2 (selects db 2)

@nmvuong92
nmvuong92 / Deffered in jquery.md
Last active December 19, 2018 10:05
Deffered in jquery

First: You cannot use $.Promise(); because it does not exist. A deferred object is an object than can create a promise and change its state to resolved or rejected. Deferreds are typically used if you write your own function and want to provide a promise to the calling code. You are the producer of the value.

A promise is, as the name says, a promise about a future value. You can attach callbacks to it to get that value. The promise was "given" to you and you are the receiver of the future value. You cannot modify the state of the promise. Only the code that created the promise can change its state.

Examples:

  1. (produce) You use deferred objects when you want to provide promise-support for your own functions. You compute a value and want to control when the promise is resolved.
@nmvuong92
nmvuong92 / sử dụng saga.md
Created December 19, 2018 10:09
sử dụng saga

We can't really recommend a way to start root sagas however we can certainly explain better the effect. I think it's probably worth creating a dedicated documentation page.

your examples 1.

// single entry point to start all Sagas at once
export default function* rootSaga() {
  yield [
    saga1(),
    saga2(),
@nmvuong92
nmvuong92 / index.php
Created January 17, 2019 17:15 — forked from ziadoz/index.php
Simple PHP / jQuery CSRF Protection
<?php
// See: http://blog.ircmaxell.com/2013/02/preventing-csrf-attacks.html
// Start a session (which should use cookies over HTTP only).
session_start();
// Create a new CSRF token.
if (! isset($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = base64_encode(openssl_random_pseudo_bytes(32));
}
@nmvuong92
nmvuong92 / php datetime.md
Last active January 18, 2019 06:28
php xử lý datetime timestamp

Datetime Class

Tạo biến dữ liệu thời gian theo chuẩn UTC/GMT/Z bằng Datetime Class

$date1 = new DateTime('now', new DateTimeZone('utc')); //DateTime tạo đối tượng Datetime múi giờ utc chuẩn london có giá trị là hiện tại
$date2 = new DateTime('2019-01-17', new DateTimeZone('utc')); //DateTime  tạo đối tượng Datetime múi giờ utc chuẩn london có giá trị 17/01/2019 00:00:00
var_dump($date1,$date2);

kết quả

D:\www\vsmarty\crfs\demo.php:24: