Skip to content

Instantly share code, notes, and snippets.

View mayrop's full-sized avatar
🙈
Try your best, make it happen!

Mayra Valdés mayrop

🙈
Try your best, make it happen!
View GitHub Profile
@mayrop
mayrop / bash_aws_jq_cheatsheet.sh
Created November 8, 2022 03:55 — forked from lukeplausin/bash_aws_jq_cheatsheet.sh
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account

Endpoint: https://api.github.com/graphql Authentication: Bearer {token}

query ($number_of_repos: Int!) {
  viewer {
    name
    repositories(last: $number_of_repos) {
      nodes {
        name
@mayrop
mayrop / covid_mx_descriptions.yaml
Created April 14, 2020 07:05
Descriptions for COVID-19 MX data
origin:
CLAVE:
- 1
- 2
- 99
DESCRIPCION:
- USMER
- FUERA DE USMER
- NO ESPECIFICADO
sector:
@mayrop
mayrop / covid_mx.R
Last active April 14, 2020 07:19
Script to merge COVID MX data with descriptions
library(dplyr)
# this function will soon be added to my R Package: https://github.com/mayrop/r-covid19in-mx
# also get the yaml file from: https://gist.github.com/mayrop/83c955e5038390095aef9e5405c632b6
source("functions.R")
# download CSV from: https://www.gob.mx/salud/documentos/datos-abiertos-152127
input <- read.csv("covid19_mexico_13_04_2020.csv", stringsAsFactors=FALSE, fileEncoding="latin1")

Given a number n, find the sum of all n-digit palindromes.

Given that an "even word" is a word in which each character appears an even number of times, write a function that takes in a string and returns the minimum number of letters to be removed to make that string an even word.

@mayrop
mayrop / rendezvous_cassidoo_126.R
Last active January 17, 2020 07:16
Given a number n, find the sum of all n-digit palindromes.
# Interview Question of the Week: Jan 13, 2020
# 126 of rendezvous with cassidoo
# https://cassidoo.co/newsletter/
# Given a number n, find the sum of all n-digit palindromes.
# >> nPalindromes(2)
# >> 495 // 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99
# Removing exponential notation
options(scipen=999)
FROM ubuntu:18.04
# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update --fix-missing
RUN apt-get install -y curl
RUN apt-get install -y build-essential libssl-dev
RUN apt-get install -y git
# https://thisisnic.github.io/2018/03/31/what-the-heck-is-quasiquotation/
> enquo(Species)
Error in (function (x) : object 'Species' not found
> quo(Species)
<quosure>
expr: ^Species
env: global
> my_test <- function(col) {
import numpy as np...
import numpy as np
import pandas as pd
import re
def get_patterns(ids, debug=False):
max_char = len(str(np.max(ids))) # getting max length
ids = list(map(str, ids)) # changing to chars
@mayrop
mayrop / keybase.md
Last active July 23, 2019 19:46
Keybase ID File

Keybase proof

I hereby claim:

  • I am mayrop on github.
  • I am mayrop (https://keybase.io/mayrop) on keybase.
  • I have a public key ASA7RcLO1hXFlITPiwySykEI4NH3PP6pfarvapgWEWO7oAo

To claim this, I am signing this object: