Skip to content

Instantly share code, notes, and snippets.

@alpham
alpham / assume_aws_role.sh
Last active March 2, 2023 09:54
Login using `$ aws sts assume-role` command and export the credentials in shell environment
# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"
function assume_aws_role() {
# Define a function to print the help message
function print_help {
echo "Usage: assume_aws_role [OPTIONS]"
echo "Assumes an AWS IAM role and exports the required credentials and assumed role information as environment variables."
echo ""
echo "Options:"
@alpham
alpham / hello_blogger.py
Created January 22, 2020 18:00
testing blogger gist loader
print('hello blogger')
@alpham
alpham / Dockerfile
Created October 28, 2017 13:21
Dockerfile to solve the lang error for odoo:11.0
FROM odoo:11.0
ENV LANG C.UTF-8
@alpham
alpham / docker-compose.yaml
Created October 28, 2017 12:15
docker compose file to run odoo 11
version: "3"
services:
db:
image: postgres:9.4
deploy:
replicas: 1
volumes:
- pgsql_data:/var/lib/postgresql/data:rw,Z
environment:
@alpham
alpham / html2pdf.py
Created October 2, 2017 13:38
install pyqt5 on python3
import os
import sys
import argparse
import os
import sys
import argparse
from PyQt5.QtWebEngineWidgets import QWebEnginePage
from PyQt5.QtWidgets import QApplication
@alpham
alpham / days_to_finish_the_military.py
Last active May 10, 2017 19:24
days_to_finish_the_military.py created by alpham - https://repl.it/HrWK/0
from datetime import datetime
print('%d days to finish the military !!' % (datetime(2017, 9, 1) - datetime.today()).days)
from itertools import groupby
def pack(arr):
uniqe_items = []
count_items = []
for i in groupby(arr):
if i[0] not in uniqe_items:
count_items.append(len(list(i[1])))
'use strict';
function pack(arr){
// prev_item is the first item
var prev_item = arr[0];
// count of the first item is 1 at this stage
var count_items = [1];
// first item is very new to unique_items so it is unique
var unique_items = [prev_item];
function createPyramid(base){
if (base%2 == 0){
throw "Pyramid base must be odd number"
}
var left = createLeftSide(base);
var right = createRightSide(base);
var final = [];
for (var i = 0; i < left.length; i++) {
final[i] = left[i].concat(right[i]);
'use stirct';
function calculator(){
this.ans = 0;
var self = this;
this.add = add;
this.miniz = miniz;
this.div = div;