Skip to content

Instantly share code, notes, and snippets.

View afromankenobi's full-sized avatar

Jorge Vargas Silva afromankenobi

  • rebuss.com
  • Santiago
View GitHub Profile
We used this query to find out the number of pg connections,
select count(*) from pg_stat_activity
We investigated and found out the there were multiple(upto 17) pg connections from 2 sidekiq processes
we have with 40 concurrent threads.
We used this query to find out sidekiq pg connections,
select pid, usename, application_name, state from pg_stat_activity where usename = 'ringmdstaging' and application_name like 'sidekiq%';
@afromankenobi
afromankenobi / boom_docker.sh
Created August 18, 2020 20:49
Remove anon images from docker without hesitate
docker image ls | grep none | awk '{ print $3}' | xargs docker image rm -f

Keybase proof

I hereby claim:

  • I am afromankenobi on github.
  • I am afromankenobi (https://keybase.io/afromankenobi) on keybase.
  • I have a public key ASAgs52ACsRzWjg0fEsLXfnV-m42Bw0HnzBPzq6vLtv86Qo

To claim this, I am signing this object:

# Cards
class Card
attr_reader :kind, :rank
def initialize(kind, rank)
@kind = kind
@rank = rank
end
def to_s
@afromankenobi
afromankenobi / queries.sql
Created August 27, 2017 04:43
Queries course datamodel
/* Average score per student */
SELECT
members.id, members.name, courses.id, courses.name, avg(evaluations.score)
FROM evaluations
JOIN members ON evaluations.member_id = members.id
JOIN tests ON evaluations.test_id = tests.id
JOIN courses ON tests.course_id = courses.id
WHERE members.type = 'Student'
GROUP BY members.name, members.id, courses.id, courses.name;
@afromankenobi
afromankenobi / courses.sql
Last active August 27, 2017 04:49
Courses datamodel
/* Create table member */
/* A member can have types, ie: Student, Professor */
CREATE TABLE members(
id bigserial PRIMARY KEY,
name character variying,
type character variying NOT NULL
);
/* Create courses */
CREATE TABLE courses(
@afromankenobi
afromankenobi / numbers_to_word.rb
Last active August 25, 2017 15:02
My version of number to words in spanish.
# I think this needs a lot of refactor :(
# Extend the integer class
class Integer
# each group represents positions splitted by 6
# for each group, we need to
# locate the period
# for each period, locate the two classes
# then add classes name (left to right) name
# add period
# add hundreds
@afromankenobi
afromankenobi / factorial.rb
Created August 23, 2017 03:41
Factorial things
# Extend Integer class to add factorial related methods
class Integer
# Iterative factorial
def factorial
# fail if this is called by negative numbers
raise ArgumentError, 'Not valid for negative numbers' if self < 0
return 1 if zero?
# iterates backwards and inject * to the acumulator
downto(1).inject(:*)
source 'https://rubygems.org'
# Explicit ruby version
ruby "2.3.0" # OMG it's magic!
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Continue...