Skip to content

Instantly share code, notes, and snippets.

View mejiaro's full-sized avatar

Ricardo Mejía O. mejiaro

View GitHub Profile
@mejiaro
mejiaro / google_oauth2_ruby_client.rb
Created June 23, 2022 12:57
google oauth2 ruby client
# Google can't make a decent no-frills, no shitting around for a whole day client library,
# 'cause probably a machine made the code/docs not a person.
# Fuck you Google.
# Get the client_id, client_secret, token, refresh token from `gcloud auth describe [email protected]`
# I used this to run a cloud run app thingy
gem install 'signet'
@mejiaro
mejiaro / fix-postgresql-linux.md
Last active November 3, 2023 06:49
Fixing Postgresql's "could not connect to server" on Linux Mint (or Ubuntu)

Got the dreaded, only-macOs documented "No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432" but you are using wither Mint or Ubuntu?

Here's how to fix it.

  1. verify the contents of /etc/postgresql/9.5/main/pg_hba.conf

  2. if the file is empty, add this conf

@mejiaro
mejiaro / fizzbuzz.js
Created February 17, 2016 21:38
JS FizzBuzz
for (number = 1; number < 101; number++)
switch(true) {
case number % 3 == 0 && number % 5 == 0:
console.log("FizzBuzz");
break;
case number % 3 == 0:
console.log("Fizz");
break;
case number % 5 == 0:
console.log("Buzz");
@mejiaro
mejiaro / download_files.rb
Last active February 15, 2016 23:10
Ruby script to download files from AWS S3, when you have the AWS key.
require 'net/http'
require 'net/ftp'
require 'uri'
def http_download_uri(uri, filename)
puts "Starting HTTP download for: " + uri.to_s
http_object = Net::HTTP.new("my_AWS_S3_bucket_url", 80)
#http_object.use_ssl = true if uri.scheme == 'https'
puts uri
begin
@mejiaro
mejiaro / leap_year.rb
Created May 1, 2015 21:55
Calculates leap years between two years
def divisible_by_4?(year)
return true if year % 4 == 0
end
def divisible_by_100?(year)
return true if year % 100 == 0
end
def divisible_by_400?(year)
return true if year % 400 == 0