IamCalvinBrown.com a Blog Site

Code Examples, Consulting Advice and lots of other cool things

Check to see if an S3 object exists

In Amazon S3 we sometimes need to check for the existence of an object (picture, file, etc) before taking the next actions. Here's how we do it in C#. If we find anything that matches, it brings it bk in a list.

Note: The variables App.awsKey & App.awsSecretyKey are my global variables in my Xamarin forms app. You should replace these with the text values for your key and secretKey from your AWS account.

Note: Prefix = key (key is just a string -- the name of the object you want to find)

Amazon.S3.AmazonS3Client s3Client = new Amazon.S3.AmazonS3Client(App.awsKey, App.awsSecretKey, Amazon.RegionEndpoint.USEast1);

            var request = new ListObjectsRequest


                Prefix = key,

                MaxKeys = 1


            ListObjectsResponse response = await s3Client.ListObjectsAsync(request);

            if (response.S3Objects.Count == 0)


                return false;


            return true;

Send a text message (SMS) using Amazon SNS

(This assumes you've already setup the topic and have your own Topic ARN)

using Amazon.SimpleNotificationService;

using Amazon.SimpleNotificationService.Model;

// be sure this is the region you're choosing

AmazonSimpleNotificationServiceClient client = new AmazonSimpleNotificationServiceClient(Amazon.RegionEndpoint.USEast1);

// Publish a message to an Amazon SNS topic.

PublishRequest publishRequest = new PublishRequest("arn:aws:sns:us-east-1:123456:TESTTOPIC","this is the message");

var publishResponse = await client.PublishAsync(publishRequest);

AWS Connect to SQL Server using Lambda

/* there's a package that needs to be uploaded -- email calvin@kairuconsulting.com for this package. It's a zip that can be uploaded to AWS Lambda  */

const sql = require('mssql');

exports.handler = function(event, context, callback) {   

    const config = {

        user: 'your_user',

        password: 'your_password',

        server: 'abcd1234.us-east-1.rds.amazonaws.com',

        database: 'AdventureWork'


    sql.connect(config, (err) => {


    if (err) 


      console.log('Error ' + err);





        const req = new sql.Request();

        req.query('SELECT * FROM your_table', (error, result) => {

        if (error) 


          console.log('Error' + error);





          console.log('Result' + result);


          callback(null, result.recordset);






    //callback(null, "some success message");


AWS CLI - Delete all files matching a filter in an S3 bucket

Amazon AWS can be amazing and interesting to deal with at times. When you host a static website using S3 and Route 53, it sometimes creates files for each request the service receives. To purge these files and avoid having tens of thousands or even millions of useless files, use this command on your local CLI:

#Delete all files that name start with "2018" files from the bucket:

aws s3 rm s3://[your-aws-bucket-name]/ --recursive --exclude '*' --include '2018*'

Google Big Query - Patents DB






abstract.text as ab_text



  UNNEST(claims_localized) AS claims,

  UNNEST(abstract_localized) AS abstract


Run the same app twice on a MAC

Many of us have the need to run the same app twice. Especially during development testing. If you're like me, you'd like to see the iPad and iPhone versions of the app side-by-side. It's possible, and there's only 1 line required to make that happen.


ex: open -n -a "Visual Studio"

You're welcome

What device am I on? - Xamarin Forms

When a customer uses their tablet versus their phone, your app may appear less than stellar. Here's the code necessary to determine which device your app is running on and make changes to item sizes (ex: fonts, spacing, etc) to make your app appear made for all devices.

if ( Device.Idiom == TargetIdiom.Tablet)


        // perform all operations tablet related