This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Continuing with the birthdays, todays_birthdays, session, spreadsheet, and ws objects created above... | |
(1..ws.num_rows).each do |row| | |
name = ws[row, 1] | |
birthday = todays_birthdays.find { |bday| bday[:name] == name } | |
next unless birthday | |
next_birthday = birthday[:date].next_year.to_s | |
ws[row, 2] = next_birthday |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Continuing with the birthdays object created above... | |
todays_birthdays = birthdays.select { |birthday| birthday[:date] == Date.today } | |
account_sid = TWILIO_ACCOUNT_SID # Your Twilio phone number | |
auth_token = TWILIO_AUTH_TOKEN # Your Twilio auth token | |
client = Twilio::REST::Client.new(account_sid, auth_token) | |
from = '+11234567890' # Your Twilio number | |
to = '+10987654321' # Your mobile phone number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Continuing with the birthdays, session, spreadsheet, and ws objects created above... | |
birthdays = [] | |
(1..ws.num_rows).each do |row| | |
name = ws[row, 1] | |
date = Date.parse(ws[row, 2]) | |
birthdays << { name: name, date: date} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Continuing with the birthdays object created above... | |
# Initiate and authenticate a Google Drive session | |
session = GoogleDrive::Session.from_service_account_key('client_secret.json') | |
# Open our birthday_bot spreadsheet | |
spreadsheet = session.spreadsheet_by_name('birthday_bot') | |
# Select the first worksheet in the spreadsheet | |
ws = spreadsheet.worksheets.first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
# This will be the name of your .ics file in the root directory | |
file_name = 'birthdays.ics' | |
cal = File.read(file_name).split("BEGIN:VEVENT") | |
cal.shift # First row is meta data from export | |
birthdays = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# continuing from above with s3_image | |
client = Aws::Textract::Client.new | |
resp = client.analyze_document({ | |
document: { s3_object: { bucket: ENV['AWS_BUCKET'], name: s3_image.key } }, | |
feature_types: ['TABLES'] | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This process will upload the image to the S3 bucket | |
image = params[:image] | |
s3 = Aws::S3::Resource.new | |
bucket = ENV['AWS_BUCKET'] | |
name = File.basename(file) | |
obj = s3.bucket(bucket).object(name) | |
s3_image = obj.upload_file(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'aws-sdk-s3', '~> 1' | |
gem 'aws-sdk-textract', '~> 1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias rubo_changes="git ls-files -m | xargs ls -1 2>/dev/null | grep '\.rb$' | xargs rubocop" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function open_pr() { | |
if [ $# -eq 1 ] | |
then | |
br=$(git rev-parse --abbrev-ref HEAD) | |
else | |
br=$2 | |
fi | |
open "https://github.com/$(git remote get-url origin | awk -F '[:.]' '{print $3}')/compare/$1...$br?expand=1" | |
} |
NewerOlder