Skip to content

Instantly share code, notes, and snippets.

Avatar
❄️
Deep learning

Leonel Atencio sansagara

❄️
Deep learning
View GitHub Profile
@sansagara
sansagara / model_tracking.py
Created Jul 14, 2020
MLflow Log Model decorator
View model_tracking.py
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 Apr 12, 2020
List all EMR Clusters along with the associated EC2 Instance Ids
View aws-list-emr-instancetypes.sh
#!/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 Apr 12, 2020
Adds a tag to all kinesis streams on the default region.
View aws-add-tags-kinesis-stream.sh
#!/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 Jul 24, 2019
List AWS Kinesis streams along with tags
View aws-list-kinesis-streams-with-tags.sh
#!/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 Jul 24, 2019
Allow command competition to shell
View aws-enable-command-completition.sh
#!/usr/bin/env bash
echo "complete -C aws_completer aws" >> ~/.bash_profile
source ~/.bash_profile
@sansagara
sansagara / aws-s3-buckets-with-tags.sh
Created Jul 24, 2019
Print a list of aws buckets along with their tags
View aws-s3-buckets-with-tags.sh
#!/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 Jul 24, 2019
Print a list of AWS EMR Cluster names with their respective Tags
View aws-list-emr-with-tags.sh
#!/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 Jul 24, 2019
Print a list of AWS EMR Cluster names
View aws-list-emr-cluster-name.sh
#!/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 Mar 20, 2016
This is to show what i did for my own extension on the Object Oriented Programming in Java Course on Coursera, module 6.
View EarthquakeCityMap.java
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 Apr 25, 2015
Java Class for Android App: Premium SMS service using Parse.com
View SMSListener.java
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;
You can’t perform that action at this time.