Skip to content

Instantly share code, notes, and snippets.

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

Bryan Nguyen bryanthuan

🏠
Working from home
  • StorHub Group
  • Ho Chi Minh, Vietnam
View GitHub Profile
@bryanthuan
bryanthuan / index.html
Created October 17, 2022 10:34 — forked from jsbonso/index.html
Simple Checkout with Price Rules App using Vanilla JavaScript
<!DOCTYPE html>
<html>
<body>
<h1>Simple Checkout with Price Rules</h1>
<div style="padding-bottom: 25px;">
<h3>Test Case 1: 3 CARI Products</h3>
<p>SKUs Scanned: <code>cari, cari, cari, peti </code></p>
<p>Total expected: $249.00</p>
@bryanthuan
bryanthuan / the best sources.md
Created July 18, 2022 02:26 — forked from zed-dz/the best sources.md
education purpose only
@bryanthuan
bryanthuan / mac-rabbitmq-setup.md
Created September 20, 2021 10:43 — forked from tomysmile/mac-rabbitmq-setup.md
Install RabbitMQ using Brew

Update Homebrew’s package database.

brew update

To install the MongoDB binaries, issue the following command in a system shell:

brew install rabbitmq
@bryanthuan
bryanthuan / mac-setup-redis.md
Created September 20, 2021 10:37 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@bryanthuan
bryanthuan / MessengerChat.js
Created January 2, 2021 07:26
Facebook Messenger Chat Plugin with NextJS
import React, { Component } from 'react'
import PropTypes from 'prop-types'
/**
* Utils
*/
const removeElementByIds = ids => {
ids.forEach(id => {
const element = document.getElementById(id)
if (element && element.parentNode) {
@bryanthuan
bryanthuan / postgres-cheatsheet.md
Created May 31, 2019 07:31 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@bryanthuan
bryanthuan / media-query.css
Created May 15, 2019 06:14 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@bryanthuan
bryanthuan / knex-paginator.js
Created April 27, 2019 17:26 — forked from ionutmilica/knex-paginator.js
Simple paginator function for knex
module.exports = (knex) => {
return async (query, options) => {
const perPage = options.perPage || 10;
let page = options.page || 1;
const countQuery = knex.count('* as total').from(query.clone().as('inner'));
if (page < 1) {
page = 1;
}
@bryanthuan
bryanthuan / nl2p.php
Created April 18, 2019 10:07
Simple nl2p (wraps things in paragraph tags as opposed to line breaks - nl2br)
<?php
/**
* This wraps blocks of text (delimited by \n) in p tags (similar to nl2br)
* @author Scott Dover <[email protected]>
* @param str
* @return str
*/
function nl2p($string) {
/* Explode based on new-line */
@bryanthuan
bryanthuan / js-nl2br-br2nl.md
Created April 18, 2019 10:03 — forked from yidas/js-nl2br-br2nl.md
JavaScript nl2br & br2nl functions

JavaScript nl2br & br2nl functions

The exchange of new line & br HTML tag could refer to PHP - nl2br() function, which uses to inserts HTML line breaks before all newlines in a string.

These JavaScript functions consider whether to use insert or replace to handle the swap.

nl2br