What are the coolest Ruby on Rails features, why choose it?
I blogged in detail about why I love Rails three years ago, but for me for number one cool feature is that it makes developing web applications easy and fun.
Create a hidden folder for logging information in Ruby
I succeeded in creating a hidden folder using a shell command.
module LogEmail
def log(email)
username = Etc.getlogin
dir = "c:/users/#{username}/log"
if File.exists?(dir)
separator = "[#{Date.today} #{Time.now.strftime('%T')}] ----------"
File.open("#{dir}/email_log.LOG", 'a+') { |s| s.puts(separator, email) }
else
Dir.mkdir(dir)
`attrib +h #{dir}` #<= Creates a hidden folder.
separator = "[#{Date.today} #{Time.now.strftime('%T')}] ----------"
File.open("#{dir}/email_log.LOG", 'a+') { |s| s.puts(separator, email) }
end
end
end
how can ruby optionparser hidden password when user type
To hide your input when asking from input in a ruby program you can use the IO built in class.
require 'io/console'
STDIN.noecho(&:gets
This is directly from the ruby standard library. Use ruby docs IO class for more information. Here is the link
If I had time I would implement it into option parse for you but you can most likely figure it out pretty easily. If not, I will help you tomorrow.
Happy coding!
Hidden features of Groovy?
Using the spread-dot operator
def animals = ['ant', 'buffalo', 'canary', 'dog']
assert animals.size() == 4
assert animals*.size() == [3, 7, 6, 3]
This is a shortcut for animals.collect { it.size() }
.
Related Topics
How to Make a Http Request Using Ruby on Rails
The 'Json' Native Gem Requires Installed Build Tools
How to Specify a Local Gem in My Gemfile
Pass Variables to Ruby Script Via Command Line
Why Does Ruby Have Both Private and Protected Methods
Using Rails Serialize to Save Hash to Database
How to Determine If One Array Contains All Elements of Another Array
Test If String Is a Number in Ruby on Rails
Require': Cannot Load Such File - 'Nokogiri\Nokogiri' (Loaderror) When Running 'Rails Server'
Gem Installation Error: You Have to Install Development Tools First (Windows)
Best Way to Escape and Unescape Strings in Ruby