Skip to content

Instantly share code, notes, and snippets.

View olegon's full-sized avatar

Leandro Gonçalves de Oliveira olegon

View GitHub Profile
@olegon
olegon / main.py
Created February 19, 2024 00:04
AWS Lambda that uses boto3 to send logs to many log groups.
import time
import boto3
# docs: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/logs.html
client = boto3.client('logs')
def get_current_timestamp():
return int(time.time() * 1000)
def lambda_handler(event, context):
class Solution {
public:
vector<int> findAnagrams(string s, string p) {
vector<int> result;
unordered_map<char, int> charToFreqP;
unordered_map<char, int> charToFreqS;
int k = p.size();
for (char c = 'a'; c <= 'z'; c++) {
charToFreqS[c] = 0;
class Solution {
public:
int maxVowels(string s, int k) const {
int local_max = 0;
int global_max = 0;
for (int i = 0; i < k; i++) {
if (isVowel(s, i)) local_max++;
global_max = max(local_max, global_max);
@olegon
olegon / aws-linux-docker-userdata.sh
Created June 2, 2023 20:09
Userdata script for AWS Linux that installs docker and docker-compose.
#!/usr/bin/env bash
set -e
# updating system
yum update -y
# installing docker
yum install docker -y
class Node {
constructor(value, next) {
this.value = value;
this.next = next;
}
}
class Stack {
constructor() {
this.firstNode = null;
function longestPrefix(words) {
if (words.length == 0) return `""`;
const longestPossiblePrefixSize = Math.min(...words.map(word => word.length))
for (let prefixSize = longestPossiblePrefixSize; prefixSize > 0; prefixSize--) {
const [ firstWord, ...otherWords ] = words
if (otherWords.every(word => word.substr(0, prefixSize) == firstWord.substr(0, prefixSize))) {
return `"${firstWord.substr(0, prefixSize)}"`;
#!/usr/bin/env bash
: <<'END_COMMENT'
Read man ls and write an ls command that lists files in the following manner
Includes all files, including hidden files
Sizes are listed in human readable format (e.g. 454M instead of 454279954)
Files are ordered by recency
Output is colorized
END_COMMENT
#!/bin/bash
IN=$(cat << HMARK
pacotes= a, b, c
testes= 1,2,3,4
HMARK
)
readarray -t LINES <<< "$IN"
package com.olegon.javadynamodblimit.controller
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression
import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedQueryList
import com.amazonaws.services.dynamodbv2.model.AttributeValue
import com.amazonaws.services.dynamodbv2.model.ReturnConsumedCapacity
import com.olegon.javadynamodblimit.entity.Song
import org.springframework.web.bind.annotation.GetMapping
@olegon
olegon / App.cs
Last active February 20, 2021 14:44
Unit testing .xlsx file parsing.
using System;
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
using ClosedXML.Excel;
namespace application
{
public class App
{