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!




Sunday, August 16, 2015

GCC 4.8 on CentOS

I finally found a simple way to install gcc/g++ 4.8 (required to use c++11 syntax) on my CentOS 6 distribution!

Here is the link:

http://braaten-family.org/ed/blog/2014-05-28-devtools-for-centos/

NOTE:

I suggest you to update your .bashrc file with the following line

source /opt/rh/devtoolset-2/enable


Otherwise you cannot run the newest version of the gcc/g++!


NOTE
Adding only this line to .bashrc: 

scl enable devtoolset-2 bash 

causes a fork-bomb!!!!


REFERENCES:
http://unix.stackexchange.com
http://braaten-family.org/ed/blog/2014-05-28-devtools-for-centos/ 

Sunday, June 28, 2015

eatsyscall.asm could not read symbols: File in wrong format

If you are reading Assembly Language Step-by-Step: Programming with Linux (3rd edition) by Jeff Dantemann and you came to the first program eatsyscall.asm you'll probably get this error when you link the file with the command:

ld -o eatsyscall eatsyscall.o

eatsyscall.o: could not read symbols: File in wrong format

the solution is to add another parameter to the ld command:

ld -o eatsysdemo eatsyscall.o -m elf_i386


The problem is that you are running a Linux system where both 32bit and 64bit libraries are present and ld will complain if you link libraries of different types.
Enjoy the reading.

Monday, June 8, 2015

Where to download Oracle Client "FULL" (Not the instant version)

To  download the Full Oracle Client, not the Instant version, you need to go the download page for the Oracle Database and then select the "View All" option next to the Oracle Database for your Operating System.
For Oracle 12c this is the url
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index-092322.html


Sunday, February 15, 2015

A super reference for manipulating jar/ear/war files directly from command line

Here is the reference javaworld.com/

My favorite commands are:

// listing all files
jar tvf "fileJAR/EAR"  

//updating a file in a JAR/EAR file
jar uvf "fileJAR/EAR" path/to/file/to/update 

//extracting a file from a JAR/EAR/WAR file
jar xvf "fileJAR/EAR" path/to/file/to/extract

Friday, January 23, 2015

MySQL: a short introductory guide

Here is the link.
It covers pretty much everything the MySQL-newbie might need... installation, most used commands and some very useful tips!
This is the link you are looking for, if your goal is to learn SQL and MySQL!

Tuesday, January 13, 2015

How to fix the error "user" is not in the sudoers file. This incident will be reported."

In order not to have this message anymore, you need to had "user" to the sodoers file.
To solve this issue,  you need to log in a terminal as root (command: su) and then type the command visudo.
In the file it appears, locate the line containing:
 
root    ALL=(ALL)       ALL

and right below, add the line:

"user"    ALL=(ALL)       ALL
Where, obviously, "user" is the name of the user you want to add.
Close the file (ESC :w and :q  OR just give ESC :x)

No more incidents to be reported! :)