Skip to content

Instantly share code, notes, and snippets.

View vunamhung's full-sized avatar
🎯
Focusing

Hung Vu vunamhung

🎯
Focusing
View GitHub Profile
@vunamhung
vunamhung / clamav-mac.md
Created May 5, 2020 09:09 — forked from Uchean/clamav-mac.md
Get ClamAV running on Mac OS X (using Homebrew)

Get ClamAV running on Mac OS X (using Homebrew)

The easiest way to get the ClamAV package is using Homebrew

$ brew install clamav

Before trying to start the clamd process, you'll need a copy of the ClamAV databases.

Create a freshclam.conf file and configure as so

@vunamhung
vunamhung / scrollToEl.js
Created August 17, 2020 04:17 — forked from benhatsor/scrollToEl.js
Smooth scroll to element - Pure JS
function scrollToEl(el) {
var rect = el.getBoundingClientRect(),
scrollTop = window.pageYOffset || document.documentElement.scrollTop,
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
elTop = rect.top + scrollTop,
elLeft = rect.left + scrollLeft;
window.scrollTo({
top: elTop,
left: elLeft,
@vunamhung
vunamhung / mongoose.dbref.example.js
Created September 27, 2020 03:34 — forked from hastebrot/mongoose.dbref.example.js
Example of DBRef support in Mongoose 2.0
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
mongoose.connect("127.0.0.1", "mongoose_dbref", 27017);
var PersonSchema = new Schema({
name : String
, age : Number
, stories : [{ type: Schema.ObjectId, ref: 'Story' }]
});
var StorySchema = new Schema({
SQL Aggregation Framework
WHERE / HAVING $match
GROUP BY $group
SELECT $project
ORDER BY $sort
LIMIT $limit
sum() / count() $sum
join $lookup
function countdown() {
var days, hours, minutes, seconds, runTimer;
var totalTime = Date.now() + 60 * 60 * (Math.random() * 14 + 10) * 1000;
var expires = Math.random() * 3;
var path = window.location.pathname;
if (!Cookies.get("cdTime")) {
Cookies.set("firstTime", Date.now(), { expires, path });
[
{
"title": "Header",
"name": "header",
"subSetting": [
{
"title": "Show search button",
"description": "Show/hide button search",
"name": "enableSearch",
"values": [
curl 'https://beta2.teeshirt21.dev/api/cart-checkout/add-cart' \
-H 'authority: beta2.teeshirt21.dev' \
-H 'pragma: no-cache' \
-H 'cache-control: no-cache' \
-H 'sec-ch-ua: "Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"' \
-H 'accept: application/json, text/plain, */*' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36' \
-H 'content-type: application/json;charset=UTF-8' \
-H 'origin: https://teeshirt21.vercel.app' \

Install Zsh and Oh-my-zsh on CentOS 7

Based on this article

ALL INSTALLATIONS ASSUME YES WHEN PROMPTED, that's what -y does

This script can be copy paste to ssh as is. No hands installation. :-)

yum install zsh -y
import axios, { AxiosError } from 'axios';
import { parse } from 'json-bigint';
const http = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_URL,
transformResponse(response) {
return parse(response);
},
});