Skip to content

Instantly share code, notes, and snippets.

View tridungle's full-sized avatar

Trí Dũng Lê tridungle

  • Independent
  • Ho Chi Minh
View GitHub Profile
@tridungle
tridungle / get-roles.js
Created July 18, 2019 02:55 — forked from ziad-saab/get-roles.js
Get a list of a user's roles from Parse, including child roles, up to a certain depth
// Maximum depth is 3, after that we get a "" error from Parse
function getUserRoles(user) {
var queries = [
new Parse.Query('_Role').equalTo('users', user)
];
for (var i = 0; i < 2; i++) {
queries.push(new Parse.Query('_Role').matchesQuery('roles', queries[i]));
}
return user.rolesPromise = Parse.Query.or.apply(Parse.Query, queries).find().then(
@tridungle
tridungle / reddit.js
Created July 18, 2019 02:56 — forked from ziad-saab/reddit.js
Reddit MySQL API
var bcrypt = require('bcrypt');
var HASH_ROUNDS = 10;
module.exports = function RedditAPI(conn) {
return {
createUser: function createUser(user, callback) {
// first we have to hash the password...
bcrypt.hash(user.password, HASH_ROUNDS, function(err, hashedPassword) {
if (err) {
@tridungle
tridungle / parse-to-jquery-promise.js
Created July 18, 2019 02:57 — forked from ziad-saab/parse-to-jquery-promise.js
Create a jQuery Promise from a Parse promise
Parse.Promise.prototype.toJqueryPromise = function() {
var def = jQuery.Deferred();
this.then(
def.resolve.bind(def),
def.reject.bind(def)
);
return def.promise();
}
@import "compass/css3/shared";
// NOTE:
// All mixins for the 2009 spec have been written assuming they'll be fed property values that
// correspond to the standard spec. Some mixins can be fed values from the 2009 spec, but don't
// rely on it. The `legacy-order` mixin will increment the value fed to it because the 2009
// `box-ordinal-group` property begins indexing at 1, while the modern `order` property begins
// indexing at 0.
// if `true`, the 2009 properties will be emitted as part of the normal mixin call
@tridungle
tridungle / .gitmodules
Created August 14, 2019 08:33 — forked from kusor/.gitmodules
NodeJS AMQP Exchanges
[submodule "amqp"]
path = amqp
url = http://github.com/ry/node-amqp.git
@tridungle
tridungle / api.js
Created August 15, 2019 06:05 — forked from adrnbttr/api.js
Microservice NodeJs RabbitMQ
'use strict';
const express = require('express');
const app = express();
const port = process.env.PORT || 4001;
const rabbit = {
generateMessage: function(nbMessage) {
let lists = [];
for (let i = 0; i < nbMessage; i++) {
@tridungle
tridungle / data.json
Created October 1, 2019 06:29 — forked from adeelibr/data.json
Sample JSON data for NodeJS FS & Puppeteer
[
{
"invoiceId": 1,
"createdDate": "3/27/2018",
"dueDate": "5/24/2019",
"address": "28058 Hazelcrest Center",
"companyName": "Eayo",
"invoiceName": "Carbonated Water - Peach",
"price": 376
},
@tridungle
tridungle / useIgnore.jsx
Created October 1, 2019 06:32 — forked from adeelibr/useIgnore.jsx
A "hacky" approach to use instead of AbortControllers
/**
* @description Hacky implementation for ignoring
* @param {Function} callback
* @param {Array of primitive dependencies} deps, because
* Arrays & Objects don't work in useEffect deps
*/
const useIgnore = (callback, deps) => {
const [{success, error, loading}, setState] = React.useState({
success: null,
error: null,
@tridungle
tridungle / webpack,prod.js
Created October 1, 2019 06:32 — forked from adeelibr/webpack,prod.js
Webpack configuration [CT 2-19-2019]
/* eslint-disable*/
const merge = require('webpack-merge');
const baseConfig = require('./base.config');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const WebpackVisualizer = require('webpack-visualizer-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const productionConfig = env => {
return merge([
@tridungle
tridungle / app-bar.js
Created October 1, 2019 06:33 — forked from adeelibr/app-bar.js
raw-loader-attempts
import 'docs/src/modules/components/bootstrap';
// --- Post bootstrap -----
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
const req = require.context('markdown', true, /.md$/);
/*
APPRAOCH #1 DOES NOT WORK! HANGS SYSTEM