Skip to content

Instantly share code, notes, and snippets.

View otmjka's full-sized avatar

akjmto otmjka

View GitHub Profile
@otmjka
otmjka / gist:0dae1b3ed26320910057966ca5857f84
Last active March 8, 2025 05:34
record terminal commands history

✅ How can I display all the terminal commands I have executed in the current terminal window?

Ways to Display Executed Terminal Commands

1️⃣ Use history Command (Shows Full Command History)

history

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
https://maclovin.org/blog-native/2018/ssh-key-how-to-use-the-keychain-for-the-passphrase
@otmjka
otmjka / settings.json
Created December 19, 2021 20:18
vscode prettier auto format on save .vscode/settings.json
{
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
@otmjka
otmjka / react_input_enter.md
Created December 27, 2019 14:19
react input enter
handleChange(e) {
  this.setState({ value: e.target.value });
}
@otmjka
otmjka / wma2mp3.sh
Created December 6, 2019 12:10 — forked from tun/wma2mp3.sh
Convert wma files to mp3 using ffmpeg & lame
#!/bin/bash
# wma2mp3.sh
# Ricardo Tun <[email protected]>
#
# Depends: lame, ffmpeg
# Use: ./wma2mp3.sh path_to_wma_files
# If directory is not specified, the current working directory will be used to find wma files.
wma2mp3() {
if [ ! -e *.wma ]; then
@otmjka
otmjka / access_postgresql_with_docker.md
Created December 2, 2019 23:14 — forked from MauricioMoraes/access_postgresql_with_docker.md
Allow Docker Container Access to Host's Postgres Database on linux (ubuntu)

You have to do 2 things in order to allow your container to access your host's postgresql database

  1. Make your postgresql listen to an external ip address
  2. Let this client ip (your docker container) access your postgresql database with a given user

Obs: By "Host" here I mean "the server where docker is running on".

Make your postgresql listen to an external ip address

Find your postgresql.conf (in case you don't know where it is)

$ sudo find / -type f -name postgresql.conf

@otmjka
otmjka / nginxproxy.md
Created November 28, 2019 21:40 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@otmjka
otmjka / index.js
Created November 27, 2019 11:56 — forked from akexorcist/index.js
Axios post method requesting with x-www-form-urlencoded content type
const axios = require('axios')
const qs = require('querystring')
...
const requestBody = {
name: 'Akexorcist',
age: '28',
position: 'Android Developer',
description: 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/',
// npm i body-parser
const bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
const {name, email} = req.body