Skip to content

Instantly share code, notes, and snippets.

View glee2017's full-sized avatar

glee2017 glee2017

View GitHub Profile
@glee2017
glee2017 / connectDB.js
Last active July 1, 2022 02:43
Express MongoClient using Async await, foreach multiple records
module.exports = async function() {
var MongoClient = require('mongodb').MongoClient;
var client;
const uri = 'mongodb://root:example@mongo:27017/admin?authSource=admin';
if (!client) client = await MongoClient.connect(uri);
return {
db: client.db('sites'),
client: client
@glee2017
glee2017 / app.js
Last active June 30, 2022 19:49
Express MongoClient using Async Await
// application start up
var express = require('express');
var app = express();
app.listen(3000);
var getResults = require('./getResults');
app.get("/", async (req, res, next) => {
try {
@glee2017
glee2017 / app.js
Created June 30, 2022 16:04
Express Async/Await using Anonymous function
var express = require('express');
var app = express();
app.listen(3000);
var getresults = require('./myAsyncFunction');
app.get("/", async (req, res, next) => {
try {
var results = await getresults();
console.log("results:"+results);
@glee2017
glee2017 / Log.js
Created June 30, 2022 16:01
Anonymous functions
# no function name
module.exports = function (msg) {
console.log(msg);
};
@glee2017
glee2017 / app.js
Created June 30, 2022 15:36
Express and Async/Await functions
var express = require('express');
var app = express();
app.listen(3000);
const r = require('./myAsyncFunction');
app.get("/", async (req, res, next) => {
try {
var results = await r.getresults();
console.log("results:"+results);
@glee2017
glee2017 / gist:0ceea87ce69753b18376c2d22a86e8b1
Created November 17, 2021 21:49
docker php-8 fpm alpine
RUN apk add ldb-dev libldap openldap-dev
RUN install-php-extensions ldap
php -m | grep ldap
php -i | grep string
# see packages installed already
apk -vv info | grep string
apk list - list available packages
Power down the vm
vboxmanage list vms
"ubuntu" {31a76259-da84-401f-8fc6-54e335952346}
vboxmanage modifyvm 31a76259-da84-401f-8fc6-54e335952346 --natsettings1 1500,1024,1024,1024,1024
reference: https://www.virtualbox.org/manual/ch08.html
git checkout --orphan newbranch
//you will not see your branch now using git branch -a
git rm -rf .
// add your files
git add your files
git commit -m 'Initial commit'
//you will see your branch now using git branch -a
# swapoff -v ./file
# rm -f ./file
@glee2017
glee2017 / gist:6282a208f7b3427c606015ae8da75bd9
Last active November 10, 2021 02:09
Virtualbox ubuntu share
Virtualbox
Devices -> Shared Folders -> Shared folder settings
Folder Path: choose local Host folder to share
Folder Name: georgel
Mount point: /home/georgel/share
you have to type mount -t command below
Assumption: "georgel" is the shared folder name set up
via Devices | shared folders ... menu