Skip to content

Instantly share code, notes, and snippets.

View giautm's full-sized avatar
😍
Nice to meet you ʕ◔ϖ◔ʔ

Giau. Tran Minh giautm

😍
Nice to meet you ʕ◔ϖ◔ʔ
View GitHub Profile
@giautm
giautm / feathersjs-dataloader.js
Created March 7, 2017 15:39
Use facebook's dataloader to batch any Service get
'use strict';
const DataLoader = require('dataloader');
class Service {
constructor({ BaseService, options }) {
this.id = BaseService.id || 'id';
this.service = BaseService;
this.dataloader = new DataLoader(this._batchGet.bind(this), options);
@giautm
giautm / feathersjs-auth0.js
Created March 7, 2017 06:19 — forked from theevangelista/feathersjs-auth0.js
A hook to populate an user from Auth0 into feathersjs
const request = require('request-promise');
const errors = require('feathers-errors');
const options = {
idField: 'sub',
issuer: 'iss'
};
module.exports = function() {
@giautm
giautm / s3-public-bucket-policy.json
Last active February 22, 2017 15:11 — forked from ScottPhillips/s3-public-bucket-policy.json
Amazon S3 Bucket Policy : Restrict Access to Specific Referer
{
"Version":"2008-10-17",
"Id":"http referer policy example",
"Statement":[
{
"Sid":"Allow get requests referred by www.mysite.com and mysite.com",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:GetObject",
"Resource":"arn:aws:s3:::YOUR_S3_BUCKET_NAME/*",
@giautm
giautm / example.js
Last active February 17, 2017 00:42
const template = generateTemplateString("Xin chào ${map.name}, tuổi con ${age}.");
console.log(template({
name: 'None use',
age: 'chó',
map: {
name: 'Trần Minh Giàu',
}
}));
const {
GraphQLEnumType,
GraphQLObjectType,
GraphQLFloat,
GraphQLID,
GraphQLNonNull,
GraphQLString,
} = require('graphql');
const {
globalIdField,
const {
GraphQLObjectType,
} = require('graphql');
const {
fromGlobalId,
nodeDefinitions,
} = require('graphql-relay');
const modelsRegistry = {};
const {
GraphQLObjectType,
} = require('graphql');
const {
fromGlobalId,
nodeDefinitions,
} = require('graphql-relay');
const modelsRegistry = {};
@giautm
giautm / GameMega645.js
Last active November 15, 2016 15:28
Tổng kết sổ xố 645. B1: Copy mã ở bên dưới. B2: Vào http://vietlott.vn/ B3: Nhấn Ctrl + Shift + I để bật cửa sổ Console, dán đoạn mã đã chép và nhấn enter.
(function () {
var reportn = [{},{},{},{},{},{},{}];
var gamesCount = 1;
function resultNumber(jResultNumber) {
var sorted = jResultNumber.find('li:not(.arrow-result)').toArray().map(function (el) {
return el.innerHTML.toString();
}).sort();
[1,2,3,4,5,6].forEach(l => [0,1,2,3,4,5].forEach(i => {
if (l > i) {
@giautm
giautm / react-example.html
Last active June 13, 2016 01:28
React barcode input example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Basic Example with JSX</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/components/input.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/components/table.css"/>
</head>
<body>
@giautm
giautm / validate-date-range.js
Created April 12, 2016 14:04
validate-date-range for magento
Validation.add('validate-date-range', '', function (value, elem) {
var match = elem.id.match(/^(.+)-(from|to)-(date|time)$/);
if (match) {
var fromDate = jQuery('#' + match[1] + '-from-date');
if (match[3] === 'date') {
if (fromDate.val() > value) {
this.error = 'Giá trị cần phải lớn hơn hoặc bằng ' + fromDate.val();
return false;
}
} else {