Skip to content

Instantly share code, notes, and snippets.

@quangthe
quangthe / jaas.config
Created November 25, 2021 11:21 — forked from serpensalbus/jaas.config
JAAS config Magnolia example configuration file
/**
* options for JCRAuthenticationModule module:
* realm: to restrict the login to a certain realm
* use_realm_callback: to allow the GUI to pass the realm to login into
* skip_on_previous_success: if true the login is scipped if a former module proceeded a successfull login
*
* example:
* info.magnolia.jaas.sp.jcr.JCRAuthenticationModule requisite realm=public;
* info.magnolia.jaas.sp.jcr.JCRAuthenticationModule requisite realm=admin skip_on_previous_success=true;
*/
@quangthe
quangthe / create_image_pull_secret.sh
Created October 14, 2021 07:18
Create Gitlab image pull secret
# Create image pull secret
kubectl delete secret gitlab-registry-creds --ignore-not-found
kubectl create secret docker-registry gitlab-registry-creds \
--docker-server=https://${CI_REGISTRY} \
--docker-username=${CI_DEPLOY_USER} \
--docker-password=${CI_DEPLOY_PASSWORD}
@quangthe
quangthe / main.go
Created October 12, 2021 03:44
Go error handling
import (
"fmt"
"errors"
tce "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
)
// Way 1
if _, ok := err.(*tce.TencentCloudSDKError); ok {
return fmt.Errorf("An API error has returned: %s", err)
@quangthe
quangthe / SSL-certs-OSX.md
Created February 4, 2021 05:55 — forked from croxton/SSL-certs-OSX.md
Generate ssl certificates with Subject Alt Names

Generate ssl certificates with Subject Alt Names on OSX

Open ssl.conf in a text editor.

Edit the domain(s) listed under the [alt_names] section so that they match the local domain name you want to use for your project, e.g.

DNS.1   = my-project.dev

Additional FQDNs can be added if required:

@quangthe
quangthe / install_docker.sh
Created October 14, 2020 14:51
Install Docker on Linux Mint 20
#!/bin/bash
sudo apt-get update
# install dependencies
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# add the gpg key for docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#!/usr/bin/env bash
# Require environment variable:
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
set -e
BUCKET=dt-odoo-backup
echo "Get latest db backup"
aws s3 ls $BUCKET --recursive | grep \.*sql | sort | tail -n 1 | awk '{print $4}' | while read -r line; do
@quangthe
quangthe / monitoring2.py
Created March 11, 2020 03:22
Simple monitoring for app tienluong
#! /usr/bin/python
import datetime
import time
import urllib2
from contextlib import closing
from urllib import urlencode
def http_get(url):
@quangthe
quangthe / backup-db-and-odoo-files.py
Last active March 11, 2020 03:20
Backup odoo db and files to S3
#! /usr/bin/python
import boto3
import subprocess
import datetime
import os
import zipfile
import humanize
WORKING_DIR = "/tmp"
@quangthe
quangthe / db-backup.sh
Created March 11, 2020 03:16
Backup tienluong-db to S3
#! /usr/bin/python
import boto3
import subprocess
import datetime
import os
now = datetime.datetime.now()
bucket = "dtcorpbackup"
filename = "dump_{}-{:0>2}-{:0>2}_{:0>2}:{:0>2}:{:0>2}.sql".format(now.year, now.month, now.day, now.hour, now.minute, now.second)
@quangthe
quangthe / add-app-metadata-to-jwt.js
Created March 27, 2019 08:27 — forked from philipisapain/add-app-metadata-to-jwt.js
Auth0 Rule for adding app_metadata to JWT
function (user, context, callback) {
var namespace = 'https://tojs.io/';
context.accessToken[namespace + 'user_authorization'] = {
groups: user.app_metadata.groups,
roles: user.app_metadata.roles,
permissions: user.app_metadata.permissions
};
return callback(null, user, context);
}