Skip to content

Instantly share code, notes, and snippets.

View devtin's full-sized avatar
💭
wondering...

Martin Rafael Gonzalez devtin

💭
wondering...
  • Keep Wondering, LLC
  • McKinney, TX
  • X @tin_r
View GitHub Profile
@devtin
devtin / API-endpoints.md
Last active August 23, 2022 11:34
api endpoints documentation template

Endpoints

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

GET /v1/endpoint-1

@devtin
devtin / download-cloudwatch-logs.sh
Last active August 4, 2022 13:50
download entire aws cloudwatch log
#!/bin/bash
# THIS SCRIPT DEPENDS ON:
# aws cli: https://aws.amazon.com/cli/
# jq https://stedolan.github.io/jq/ | $ brew install jq
i=0
NEXT_ID=""
GROUP_NAME="/aws/lambda/prod-some-service"
STREAM_NAME="2022/08/03/[\$LATEST]some-id"
@devtin
devtin / main.go
Last active June 20, 2022 19:36
checks repositories in an organization with circleci
package main
import (
"encoding/json"
"fmt"
"os"
"os/exec"
"path"
"strings"
"sync"
@devtin
devtin / csv-tr-sort.sh
Last active May 23, 2022 23:48
fast process to sorts long csv files from command line
#!/bin/bash
# SPEEDS UP CSV SORTING (~2X) BY DISTRIBUTING THE LOAD INTO 8 DIFFERENT PROCESSES
# USAGE: $ < <input-csv-file> ./csv-tr-sort.sh -c <column-name-to-sort> -o <sort-direction=1,-1> > sorted.csv
# AVERAGES ~22 SECONDS SORTING A 300MB CSV FILE WITH 3MM ENTRIES ON AN M1
ORDER=1
usage() { echo "Usage: $0 [-c <column-name>] [-o <order=1,-1>]" 1>&2; exit 1; }
@devtin
devtin / .github
Last active May 20, 2022 15:10
github commands
#!/bin/bash
# prints remote github-url
function ghr () {
GITHUB_REMOTE=$(git config --get remote.origin.url)
if [ $? -eq 1 ]; then
echo "either not a github repo or remote not found 😙"
return 1
fi
@devtin
devtin / cli regex extract
Created May 4, 2022 20:19
cli regex extract
perl -n -e'/(\d+) events processed!/ && print $1'
@devtin
devtin / mongo-clone
Last active January 6, 2022 14:15
mongoDb collection backup
#!/usr/bin/env bash
SRC_URI=<source-connection-uri>
SRC_DB=<source-database-name>
DST_URI=<destination-connection-uri>
DST_DB=<destination-database-name>
FLOW=1000
mongodump --archive --uri $SRC_URI --db $SRC_DB | mongorestore --archive --uri $DST_URI --db $DST_DB --numInsertionWorkersPerCollection=$FLOW
/**
* As part of a technical on-site screening-interview I was requested to create a function
* able to find two numbers in array `arr` that added together would equal given number `k`.
*
* I initially did an approach equal to run the function below with the option `reduceIterations=false`.
*
* My interviewer asked if I had a better approach: honestly, not only I had a headache but also I was already screened
* remotely and was not expecting more coding review: especially on the spot. I don't know, first time interviewing
* in the US... The thing is, he suggested using a 'table hash' (first time I heard the term) to reduce iteration. At
* the beginning I did not understand him (probably due to my technical language barer) but then I realized he wanted
/**
* As part of a technical screening interview I was requested to create a function
* able to perform a binary search.
*
* @param {Number[]} arr - A sorted array
* @param {Number} k - Number to find
* @return {Number} index position where k was found in the array
*
* @see: https://en.wikipedia.org/wiki/Binary_search_algorithm
*/
/**
* As part of a technical screening interview I was requested to create a function
* able to calculate the total score of a game after all of the given rounds were completed
* following the criteria below:
*
* The function receives an array of strings restricted to the following operation:
* Integer: Directly represents the number of points scored this round.
* +: The points scored this round are the sum of the last two valid round's points.
* D: The points scored this round are double the last valid round's points.
* C: The last valid round's points were invalid and should not be counted towards the total score or any future operations.