How to check if a directory/file/symlink exists with one command in Ruby

The standard File module has the usual file tests available: RUBY_VERSION # => “1.9.2” bashrc = ENV[‘HOME’] + ‘/.bashrc’ File.exist?(bashrc) # => true File.file?(bashrc) # => true File.directory?(bashrc) # => false You should be able to find what you want there. OP: “Thanks but I need all three true or false” Obviously not. Ok, try … Read more

SQL – IF EXISTS UPDATE ELSE INSERT INTO

Create a UNIQUE constraint on your subs_email column, if one does not already exist: ALTER TABLE subs ADD UNIQUE (subs_email) Use INSERT … ON DUPLICATE KEY UPDATE: INSERT INTO subs (subs_name, subs_email, subs_birthday) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE subs_name = VALUES(subs_name), subs_birthday = VALUES(subs_birthday) You can use the VALUES(col_name) function in the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)