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:
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active November 17, 2024 04:56 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

Exporting your 2FA tokens from Authy to transfer them into another 2FA application

IMPORTANT - Update regarding deprecation of Authy desktop apps

Past August 2024, Authy stopped supported the desktop version of their apps:
See Authy is shutting down its desktop app | The 2FA app Authy will only be available on Android and iOS starting in August for details.

And indeed, after a while, Authy changed something in their backend which now prevents the old desktop app from logging in. If you are already logged in, then you are in luck, and you can follow the instructions below to export to tokens.

If you are not logged in anymore, but can find a backup of the necessary files, then restore those files, and re-install Authy 2.2.3 following the instructions below, and it should work as expected.

@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(