Skip to content

Instantly share code, notes, and snippets.

View adamfortuno's full-sized avatar
😁

Adam adamfortuno

😁
View GitHub Profile
@adamfortuno
adamfortuno / try.azure.function.sqlconnect.py
Last active September 9, 2022 02:12
Connect to an Astra DB Serverless database over the cqlsh Interface Using the cassandra module for Python
import logging
import azure.functions as func
import os
from pathlib import Path
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
@adamfortuno
adamfortuno / sample.html
Created July 18, 2022 01:26
Example of Columns in Side by Side Layout in HTML
<!DOCTYPE html>
<html>
<head>
<title>Marcus is a douche bag</title>
<meta charset="UTF-8">
<style>
html,
body {
@adamfortuno
adamfortuno / server.ps1
Last active July 21, 2021 20:46
DataStax Studio server script (written in PowerShell) Created for Testing Purposes
Set-StrictMode -version 5.0
$ErrorActionPreference = 'Stop'
$env:JAVA_HOME = 'C:\Program Files\Java\jre1.8.0_301\'
$script_path = $MyInvocation.MyCommand.Path
$script_directory = Split-Path -Parent $script_path
$install_directory = Split-Path -Parent $script_directory
$install_lib_directory = "${install_directory}\lib\"
@adamfortuno
adamfortuno / cf_build_cassandra.yaml
Created July 6, 2021 02:26
CloudFormation Template to Create a 3 Node Cassandra Cluster
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
License: Apache-2.0
Parameters:
ClusterTargetVPC:
Description: "The name of the VPC to host the cluster."
Type: "String"
ClusterSubnetCIDRRange:
@adamfortuno
adamfortuno / original.sql
Last active April 15, 2021 00:57
Provide a list of products that do not have data for everyday. You may pick a single site to focus on.
--Original query...
SELECT CID,
min_price,
collection_date,
FROM QL2_TMP.PUBLIC.7PLUS_OVERLAP_SAMPLE_DATA_VIEW
WHERE site_name = 'Walmart'
AND year(date(Collection_date, 'dd-mm-yyyy')) = '2020'
AND CID in (4548496, 4548521, 4548615, 4548664, 4548672, 4548681, 4548684, 4548688, 4548732, 4548723)
ORDER BY collection_date DESC;
@adamfortuno
adamfortuno / data_load.js
Created August 14, 2020 11:38
Data Load to DynamoDB
'use strict'
/*
.Synopsis
Import Data from File to DynamoDB Table
.Description
Imports data from a file expressed as JSON to a
DynamoDB table.
## Retrieve a list of log groups
aws logs describe-log-groups --profile development --region us-east-2
## Retrieve a list of log groups matching a specific name
aws logs describe-log-groups --log-group-name /aws/lambda/sandbox --profile development --region us-west-2
## Update a specific log group to a given retention period
aws logs put-retention-policy --log-group-name /aws/lambda/decoNetworkChild --retention-in-days 5 --region us-east-2 --profile development
@adamfortuno
adamfortuno / CloudWatchLogRetention.js
Last active January 15, 2020 19:20
Update AWS CloudWatch Log Retention
const LogGroupRetentionUpdate = async (logGroupNamePrefix, retentionPeriodInDays, profile = "development", region = "'us-wast-1'") => {
const AWS = require('aws-sdk');
process.env.AWS_SDK_LOAD_CONFIG = true;
process.env.AWS_PROFILE = profile;
AWS.config.update( {region: region} );
const logs = new AWS.CloudWatchLogs({apiVersion: '2014-03-28'});
// Make sure the function was passed a valid log group prefix and retention period
@adamfortuno
adamfortuno / ConvertTo-UTC
Created October 17, 2019 17:34
Converts a JSON Snippet with an EST Date Time to its UTC Equivilant
const mtz = require('moment-timezone');
const moment = require('moment');
const original_date_string = "2019/10/15 14:21:14";
const original_date_object = new Date(original_date_string);
const original_date_object_est = moment.tz(original_date_object, 'America/New_York');
console.log("Original: %s", original_date_string);
console.log("UTC: %s", original_date_object_est.utc().toISOString());
exports.handler = async (event) => {
@adamfortuno
adamfortuno / rename.bat
Last active October 17, 2019 14:21
DOS script to Add the `dntz` File Extension to Any Files Without a File Extension
REM Will add the `dntz` file extension to files w/o a file extension
REM in the current directory
for %f IN ("*.") DO ren %f %f.dntz
REM Will add the `dntz` file extension to files w/o a file extension
REM in the current and any sub-directories
for /R %f IN ("*.") DO move %f %f.dntz