Skip to content

Instantly share code, notes, and snippets.

View sansagara's full-sized avatar
❄️
Deep learning

Leonel Atencio sansagara

❄️
Deep learning
View GitHub Profile
@sansagara
sansagara / model_tracking.py
Created July 14, 2020 11:09
MLflow Log Model decorator
import functools
import logging
import subprocess
import mlflow # type: ignore
import mlflow.sklearn # type: ignore
logger = logging.getLogger(__name__)
@sansagara
sansagara / aws-list-emr-instancetypes.sh
Last active January 14, 2023 08:14
List all EMR Clusters along with the associated EC2 Instance Ids
#!/bin/bash
# lists all EMR Clusters along with the associated EC2 Instance Ids
# Use this directly on your command shell. It will print the result in the format:
# "cluster_id | [$ec2_instance-id]... "
# depends on AWS CLI and JQ
for cluster in `aws emr list-clusters --active --query 'Clusters[].Id' --output text`; do
instances=$(aws emr list-instances --cluster-id ${cluster} --query 'Instances[?Status.State==`RUNNING`].[InstanceGroupId, InstanceType]' | jq -r -c '.[] | @tsv')
echo ${cluster} '|' ${instances//$'\n'/ }
done
@sansagara
sansagara / aws-add-tags-kinesis-stream.sh
Last active April 12, 2020 16:09
Adds a tag to all kinesis streams on the default region.
#!/bin/bash
# Adds a tag to all kinesis streams on the default region.
# depends on AWS CLI and JQ
TAG_KEY="Hello"
TAG_VALUE="World"
for amiId in `aws ec2 describe-images --region us-east-1 --owners self --output json --query 'Images' | jq '.[] | .ImageId' -r`; do
instances=$(aws ec2 describe-instances --region us-east-1 --filters "Name=image-id,Values=${amiId}")
echo ${amiId} '|' ${instances}
@sansagara
sansagara / aws-list-kinesis-streams-with-tags.sh
Created July 24, 2019 21:16
List AWS Kinesis streams along with tags
#!/bin/bash
# lists all Kinesis streams along with their tags in the following format:
# stream_name | { tag_name: tag_value }
# depends on AWS CLI and JQ
for stream in `aws kinesis list-streams | jq .StreamNames[] -r`; do
tags=$(aws kinesis list-tags-for-stream --stream-name ${stream} | jq -c '.[][] | {(.Key): .Value}' | tr '\n' '\t')
echo ${stream} '|' ${tags}
done
@sansagara
sansagara / aws-enable-command-completition.sh
Created July 24, 2019 19:54
Allow command competition to shell
#!/usr/bin/env bash
echo "complete -C aws_completer aws" >> ~/.bash_profile
source ~/.bash_profile
@sansagara
sansagara / aws-s3-buckets-with-tags.sh
Created July 24, 2019 17:53
Print a list of aws buckets along with their tags
#!/bin/bash
# lists all buckets along with their tags in the following format:
# bucket_name | { tag_name: tag_value }
# depends on AWS CLI and JQ
for bucket in `aws s3api list-buckets | jq .Buckets[].Name -r`; do
tags=$(aws s3api get-bucket-tagging --bucket $bucket | jq -c '.[][] | {(.Key): .Value}' | tr '\n' '\t')
echo $bucket '|' $tags
done
@sansagara
sansagara / aws-list-emr-with-tags.sh
Last active September 23, 2022 04:35
Print a list of AWS EMR Cluster names with their respective Tags
#!/bin/bash
# lists all EMR Clusters along with their tags in the following format:
# cluster_id | $cluster_name | { tag_name: tag_value }
# depends on AWS CLI and JQ
```
for cluster in `aws emr list-clusters --active | jq .Clusters[].Id -r`; do
name=$(aws emr describe-cluster --cluster-id $cluster --query Cluster.Name)
tags=$(aws emr describe-cluster --cluster-id $cluster --query Cluster.Tags | jq -c '.[] | {(.Key): .Value}' )
echo $cluster '|' $name '|' $tags
@sansagara
sansagara / aws-list-emr-cluster-name.sh
Created July 24, 2019 16:24
Print a list of AWS EMR Cluster names
#!/bin/bash
# lists all emr cluster names.
# depends on AWS CLI and JQ
```
for cluster in `aws emr list-clusters --active | jq .Clusters[].Name -r`; do
echo $cluster
done
```
@sansagara
sansagara / EarthquakeCityMap.java
Created March 20, 2016 23:37
This is to show what i did for my own extension on the Object Oriented Programming in Java Course on Coursera, module 6.
package module6;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.data.Feature;
import de.fhpotsdam.unfolding.data.GeoJSONReader;
import de.fhpotsdam.unfolding.data.PointFeature;
@sansagara
sansagara / SMSListener.java
Created April 25, 2015 00:50
Java Class for Android App: Premium SMS service using Parse.com
package com.leonelatencio.mysms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Telephony;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.util.Log;
import com.parse.FindCallback;