Skip to content

Instantly share code, notes, and snippets.

View ikhanhmai's full-sized avatar
🎯
Focusing

Khanh Mai ikhanhmai

🎯
Focusing
View GitHub Profile
@ikhanhmai
ikhanhmai / postgres_queries_and_commands.sql
Created October 20, 2023 04:17 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@ikhanhmai
ikhanhmai / 01_add_cors.config.yaml
Created March 13, 2023 07:47 — forked from vsviridov/01_add_cors.config.yaml
Add CORS to Nginx on AWS Elastic Beanstalk
container_commands:
01_fix_static_cors:
command: "/tmp/fix_static_cors.sh"
files:
"/tmp/fix_static_cors.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash

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.
import Foundation
extension String
{
// Works in Xcode but not Playgrounds because of a bug with .insert()
mutating func insertString(string:String,ind:Int) {
var insertIndex = advance(self.startIndex, ind, self.endIndex)
for c in string {