Skip to content

Instantly share code, notes, and snippets.

View xeusteerapat's full-sized avatar
🤔
Focusing

Teerapat Prommarak xeusteerapat

🤔
Focusing
View GitHub Profile

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@xeusteerapat
xeusteerapat / after_res_hooks.js
Created November 4, 2021 12:31 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@xeusteerapat
xeusteerapat / hyper.js
Created October 29, 2021 09:29
my hyper configuration
"use strict";
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
// default font size in pixels for all tabs
@xeusteerapat
xeusteerapat / multi-git-win.md
Created October 21, 2021 03:48 — forked from rosswd/multi-git-win.md
Setting up a Github and Bitbucket account on the same computer on Mac OS. Now with a guide for Windows 10.

Setting up github and bitbucket on the same computer (Windows)

Guide for Windows

mix3d asked for some help using this guide with windows so here we go. This was tested with Windows 10. Run all commands in Git Bash once it's installed.

Github will be the main account and bitbucket the secondary.

Git for Windows

  • Download and install Git for Windows
    • In the installer, select everything but decide if you want a desktop icon (2nd step)
@xeusteerapat
xeusteerapat / handler.js
Created October 4, 2021 05:49 — forked from kidsil/handler.js
Get AWS Cognito Token ID (JWT) with JavaScript (NodeJS)
const AWS = require('aws-sdk');
const CognitoSDK = require('amazon-cognito-identity-js-node');
AWS.CognitoIdentityServiceProvider.AuthenticationDetails = CognitoSDK.AuthenticationDetails;
AWS.CognitoIdentityServiceProvider.CognitoUserPool = CognitoSDK.CognitoUserPool;
AWS.CognitoIdentityServiceProvider.CognitoUser = CognitoSDK.CognitoUser;
const Username = 'testuser';
const TempPassword = 'TemporaryPassword2!';
const NewPassword = 'NewPassword@#@!19';
const Email = 'some@email.com';
@xeusteerapat
xeusteerapat / aws_serverless_recipes.md
Created August 24, 2021 10:59 — forked from nicolasdao/aws_serverless_recipes.md
Recipes for AWS Lambda with Serverless Framework. A series of recipes to get shit done using the Serverless Framework. Keywords: serverless recipe code recipes lambda lambdas function
const axios = require('axios');
const fs = require('fs/promises');
const main = async () => {
const { data } = await axios.get('API_ENDPOINT');
const tableOfContents = data.instance.details.toc.categories.map(item => {
return item.title;
});
const asyncWrap = promise => promise.then(result => [null, result]).catch(err => [err])
const func = async () => {
const [error, result] = await asyncWrap(doAsyncThing())
}
@xeusteerapat
xeusteerapat / node_nginx_ssl.md
Created November 5, 2020 15:31 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@xeusteerapat
xeusteerapat / autoScroll.js
Created May 31, 2020 06:12
Auto scroll mouse to the bottom of the page.
let intervalID = window.setInterval(function() {
window.scrollTo(0, document.body.scrollHeight)
}, 1000)
// to stop
window.clearInterval(intervalID)