-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
113 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env ruby | ||
# Simple reminders app written in Ruby and DialogBind. | ||
# | ||
# Copyright (C) Tim K 2018-2019. Licensed under MIT License. | ||
# This file is a DialogBind example. | ||
|
||
require 'dialogbind' | ||
require 'time' | ||
|
||
# Get the name of the reminder | ||
notification_name = guigets('What should I remind you?') | ||
if notification_name == '' || notification_name == nil then | ||
# If nil or empty, then exit | ||
guierror('You did not specify a valid name for a reminder. Exiting.') | ||
exit 1 | ||
end | ||
|
||
# Get the time of the reminder | ||
time_alert = guigets('When should I remind you? (type the time in the following format: HH:MM)') | ||
if not time_alert.to_s.include? ':' then | ||
# If there is no :, then the time was not specified at all | ||
guierror('You did not specify a valid time. Exiting.') | ||
exit 2 | ||
elsif time_alert.to_s.include? ' ' then | ||
# If there is a space, then the time was specified in a wrong format | ||
guierror('Please specify the date in the following format next time: HH:MM. For example: 22:30. Exiting for now.') | ||
exit 3 | ||
end | ||
|
||
# Convert our stringified time to Ruby's Time object | ||
time_real = Time.parse(time_alert) | ||
if time_real < Time.now then | ||
guierror('Late night/early morning appointments are not supported.') | ||
exit 3 | ||
end | ||
|
||
# Tell the user that we will remind him about his appointment | ||
guinotify('You will be notified about "' + notification_name + '" on ' + time_real.to_s, 'Reminder added') | ||
|
||
while Time.now < time_real do | ||
sleep 0.01 | ||
end | ||
|
||
guinotify('It\'s "' + notification_name + '" time.', 'Important!') | ||
exit 0 | ||
|
||
exit 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env ruby | ||
# A Ruby program that bulk renames all files in a specific directory | ||
# by prepending a prefix specified by the user. | ||
# | ||
# Copyright (C) Tim K 2018-2019. Licensed under MIT License. | ||
# This file is a DialogBind example. | ||
|
||
require 'dialogbind' | ||
require 'fileutils' | ||
|
||
# First get the directory where the files are stored | ||
directory_original = guidirectoryselect('Please select a directory with the files that you want to rename.') | ||
|
||
# Now get the prefix that the user wants to prepend to each file | ||
prepend_prefix = guigets('What would you like to prepend to each file in that directory?') | ||
|
||
# Iterate over files and rename them | ||
files_processed = 0 | ||
|
||
Dir.glob(directory_original + '/*').each do |file| | ||
path_orig = file | ||
prepend_prefix_applied = prepend_prefix + File.basename(file) | ||
path_final = File.dirname(path_orig) + '/' + prepend_prefix_applied | ||
|
||
FileUtils.mv(path_orig, path_final) | ||
files_processed += 1 | ||
end | ||
|
||
# Notify the user that we have just finished | ||
guinotify('Processed and renamed ' + files_processed.to_s + ' files.', 'Finished!') | ||
|
||
# Exit | ||
exit 0 | ||
|
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