Skip to content

Instantly share code, notes, and snippets.

@mjclemente
mjclemente / application.cfc
Created January 18, 2022 14:24
CFML Datasource from AWS Secrets Manager
this.datasource = 'appdsn_exactoritos';
this.datasources["appdsn_exactoritos"] = getDatabaseConfig();
private struct function getDatabaseConfig() {
var sys = CreateObject("java", "java.lang.System");
var db_is_configured = sys.getProperty("com.app.db_is_configured");
if( isNull( db_is_configured ) ) {
var aws = new modules.awscfml.aws();
@pahud
pahud / update-ecs-cluster-capacity-providers.sh
Last active January 20, 2023 13:54
Update the capacity providers of your existing ECS clusters for Fargate
# 1. update your aws cli
# https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
#
# 2. update your existing cluster with capacity providers support
CLUSTER_NAME=fargate
SERVICE_NAME=myservice
FARGATE_WEIGHT=1
FARGATE_SPOT_WEIGHT=1
FARGATE_BASE=1
FARGATE_SPOT_BASE=0
@Inori
Inori / switch-gpu.sh
Last active April 8, 2024 07:32
Switch GPU on Debian system with reboot (same as nvidia-prime)
#!/bin/bash
# Switch GPU on Debian system with reboot.
# Because there's no nvidia-prime package for Debian distro,
# I did some work to achieve the same functionality as nvidia-prime provide.
# Follow the instructions here:
# 1. Follow instructions here to install nvidia proprietary driver:
@clarkdave
clarkdave / ecs-task-events-to-cloudwatch-logs.py
Created June 29, 2017 22:27
(AWS Lambda) Send ECS Task events to CloudWatch Logs
# This lambda function can be linked with CloudWatch events to send Task state changes to
# a CloudWatch Logs stream
#
# This is highly recommended as, in my experience, the API does *NOT* return all state change
# events; this is the only way to reliably see them all
import os
import time
import json
import boto3
@krushik
krushik / passwd.yml
Last active May 1, 2023 13:30
ansible playbook to change user password on linux
---
# You may override default target user with -e user=someotheruser
# It is mandatory to choose a strong password! At least consult with https://www.bennish.net/password-strength-checker/
- name: change linux user password
hosts: [all]
gather_facts: no
vars_prompt:
## use this when 656K rounds will be OK for your servers' CPU performance, or when rounds number will become configurable in ansible
# You may need 'apt-get install python-passlib' or 'pip install passlib' for vars_prompt encryption
@jeaguilar
jeaguilar / encryptDecryptWithAWSKMS.cfm
Last active February 23, 2021 05:18
Basic implementation of encryption and decryption in CFML using AWS KMS and the AWS SDK for Java (Tested on Lucee 4.5)
<cfscript>
// Step 1: Download AWS SDK for Java https://aws.amazon.com/sdk-for-java/
// Step 2: Copy [sdk archive]/lib/aws-java-sdk-1.10.47.jar to WEB-INF/lucee/lib
// Step 3: Create IAM User and obtain basic credentials (Access Key ID and Secret Access Key)
// Step 4: Create IAM Encryption Key add "Step 3 IAM User" as a Key User (remove as Key Administrator)
// Step 5: Obtain Key Id for "Step 4 IAM Encryption Key"
// Reference: http://docs.aws.amazon.com/kms/latest/developerguide/programming-top.html
public Any function getBasicAWSCredentials( required string AccessKeyId, required string SecretAccessKey ) {
return CreateObject(