Tuesday, December 1, 2015

How to combine gets.chomp and ARGV in a Ruby script

Are trying to learn Ruby? Nice!
You have just written a  script that combines gets.chomp and command line arguments via ARGV

 and you are getting this error ?

`gets': No such file or directory @ rb_sysopen

Well the solution is to modify slightly gets.chomp, it needs to be $stdin.gets.chomp

Here is a working script (example1.rb) .



# -*- coding: utf-8 -*-
puts ""
puts "Hello World (in Ruby)"

print "Insert some input here: "
user_input = $stdin.gets.chomp
print "You inserted: #{user_input} \n"

# parse 3 command line arguments...

f1, f2, f3 = ARGV

puts "First argument is: #{f1}"
puts "Second argument is: #{f2}"
puts "Third argument is: #{f3}" 




Try it! 

>> ruby example1.rb Hello1 Hello2 Hello3



Friday, November 6, 2015

How to kill a windows services that hangs on "starting" or "stopping"

To kill a Windows process that hasn't started correctly you need to use the terminal.

1) Get the name of the service from the services window (run "services.msc", select your service and then with a right click get the services name)

2) In a command prompt enter:

sc queryex <servicename>

where <servicename> is what you got at step 1)

3)  Get the <PID> from the output of  step 2) and use it in the command:



taskkill /f /pid <PID>


Source:
http://www.examiner.com/list/how-to-kill-a-windows-service-that-s-stuck-on-stopping-or-starting

Sunday, August 30, 2015

How to sort files and folder by date in total commander... in five clicks!

TotalCommander is a great tool but by default it does not sort folders by date, it sorts them by name no matter when they were created. This is pretty annoying.  However the solution is just five-clicks away :)

The first two clicks: Select Configuration -> Options...

Choose Display (the third click), and then select (fourth click) Like Files (also by time) in the Sorting directories section.

Last click for OK. :)

Enjoy!