Skip to content

Instantly share code, notes, and snippets.

View poacosta's full-sized avatar
:atom:
ἐρευνητής

Pedro Orlando Acosta Pereira poacosta

:atom:
ἐρευνητής
View GitHub Profile
This file has been truncated, but you can view the full file.
IdCliente,Provincia,Grupo,Ventas 2018,Unidades 2018,Tickets 2018,Antigüedad,Ventas 2017,Unidades 2017,Tickets 2017,Ventas 2016,Unidades 2016,Tickets 2016,Ventas 2015,Unidades 2015,Tickets 2015,Ventas 2014,Unidades 2014,Tickets 2014
Cliente 1,29,Tienda/Supermercado de Alimentacion,1525.788,2213.28,46,2009-01-05 09:45:21.000,3292.9751,2307.37,38,3545.6107,4569.7,49,6306.3445,8004.09,91,6439.1802,8519.13,83
Cliente 2,29,,115.8179,82.97,1,2009-01-03 10:48:33.000,286.9034,145.04,3,446.0571,321.39,12,135.4624,91.62,4,190.4443,175.68,7
Cliente 3,29,Tienda/Supermercado de Alimentacion,25670.9588,35516.11,236,2009-01-03 09:07:38.000,27947.2056,36381.85,256,33964.779,41264.9,257,36267.5888,42266.22,338,36096.9745,41184.69,348
Cliente 4,29,Tienda/Supermercado de Alimentacion,39519.3851,42299.2,358,2009-01-05 05:31:46.000,25968.0955,38376.72,231,14953.0722,24823.03,170,15524.3915,25823.11,248,13159.2442,21074.77,175
Cliente 5,29,Tienda/Supermercado de Alimentacion,2555.5218,2587.39,20,2009-01-12 11:39:56.000,3455.6742,26
@poacosta
poacosta / row_count.sql
Created August 21, 2024 10:25
PostgreSQL: How to count rows in tables
DO $$
DECLARE
r RECORD;
row_count BIGINT;
BEGIN
FOR r IN (SELECT relname FROM pg_stat_user_tables) LOOP
EXECUTE 'SELECT COUNT(*) FROM ' || quote_ident(r.relname) INTO row_count;
RAISE NOTICE 'Table: %, Row count: %', r.relname, row_count;
END LOOP;
END $$;
@poacosta
poacosta / elastic-beanstalk-cheatsheet.sh
Last active December 6, 2023 06:47
Elastic Beanstalk CLI Cheatsheet
# This command will list all your environments which are setup in Elastic Beanstalk (EB)
$ eb list
EnvironmentName1 # Name of the first environment
EnvironmentName2 # Name of the second environment
EnvironmentName3 # Name of the third environment
# This command is used to display the status of the specified environment (EnvironmentName1)
$ eb status EnvironmentName1
# The following command will set an environment variable (ENV_VAR_NAME) to a specific value (value)
@poacosta
poacosta / create_admin_user.sql
Last active April 10, 2025 06:57
Create users and grant permissions in PostgreSQL
-- The below query is used to fetch all the role names from the 'pg_roles' system catalog table.
-- It will return a list of all user (role) names in the current PostgreSQL database.
SELECT rolname FROM pg_roles;
-- This command is used to create a new PostgreSQL user with the specified username and password.
-- In this case, the newly created username is 'username' and the password is 'P@55w0rd'.
CREATE USER username WITH PASSWORD 'P@55w0rd';
-- This command grants all privileges to the user 'username' on the database 'dbname'.
-- These privileges include SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER, CREATE, CONNECT, TEMPORARY, EXECUTE, and USAGE
@poacosta
poacosta / cometchat-script.py
Last active July 31, 2023 20:55
Delete Cometchat users and groups using Pyhon
# python -m pip install requests
import requests
url = "https://api-us.cometchat.io/v2"
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Accept": "application/json",
"appId": "---",
@poacosta
poacosta / mail_sent_from_ror_console.rb
Last active May 6, 2023 07:35
Send email from RoR console
# frozen_string_literal: true
mailer = ActionMailer::Base.new
mailer.delivery_method
mailer.smtp_settings
mailer.mail(from: '[email protected]', to: '[email protected]', subject: 'Testing email', body: "Hello, you've got mail!").deliver!
@poacosta
poacosta / README.MD
Created March 14, 2023 18:00
Happy Pi Day! (Codewars Kumite)

Calculate Pi to a precision p.

Pi Day is an annual celebration of the mathematical constant π (pi). Pi Day is observed on March 14 (3/14 in the month/day format) since 3, 1, and 4 are the first three significant figures of π. It was founded in 1988 by Larry Shaw, an employee of the San Francisco, California science museum, the Exploratorium.

@poacosta
poacosta / huge_n-th_fibonacci.py
Last active February 19, 2023 15:33
n-th fibonacci with n up to 2_000_000
from numpy import matrix
def fib(n):
return (matrix(
'0 1; 1 1' if n >= 0 else '-1 1; 1 0', object
) ** abs(n))[0, 1]
@poacosta
poacosta / fibonacci.cs
Last active February 24, 2023 16:46
n-th fibonacci (3 ways)
namespace Fibonacci;
/// <summary>
/// The Fibonacci sequence is a sequence of numbers where a number is the sum of the two preceding numbers.
/// The first 10 numbers in the Fibonacci sequence are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34.
/// </summary>
public static class Fibonacci
{
/// <summary>
/// Fibonacci in a recursive version
@poacosta
poacosta / create-files-by-extensions-given-a-path.py
Last active February 7, 2023 11:54
Create files by extensions given a path using Python
import os
EXTENSIONS = ['py', 'rb', 'cs', 'ex', 'js', 'go', 'rs', 'dart', 'php', 'sql']
def create_files_by_extension_given_a_filename(name, directory):
for extension in EXTENSIONS:
file = f"{name}.{extension}"
if os.path.exists(os.path.join(directory, file)):
print('{0}: already exists!'.format(file))