Jump to content

MikeD

Member
  • Posts

    216
  • Joined

  • Last visited

Everything posted by MikeD

  1. '$ sudo visudo' (or '$ sudo EDITOR=/bin/nano visudo' if you don't like vim) Add a line like 'Defaults timestamp_timeout=<minutes>' If you are talking about how long the passwd prompt waits for then it's 'Defaults passwd_timeout=<minutes>' From 'man sudoers': passwd_timeout Number of minutes before the sudo password prompt times out, or 0 for no timeout. The timeout may include a fractional component if minute granularity is insuffi‐ cient, for example 2.5. The default is 0.timestamp_timeout Number of minutes that can elapse before sudo will ask for a passwd again. The timeout may include a frac‐ tional component if minute granularity is insufficient, for example 2.5. The default is 15. Set this to 0 to always prompt for a password. If set to a value less than 0 the user's time stamp will never expire. This can be used to allow users to create or delete their own time stamps via “sudo -v” and “sudo -k” respec‐ tively.
  2. From the first post it is clear that you need to take some time to study and understand the concepts behind Object-Oriented Programming and Java before jumping into any programming. import java.util.*;import javax.swing.JOptionPane;public class ArraysTest{ static String[] items = {"pencil","pen","sharpie","notebook A","notebook B", "eraser","tippex","usb stick","glue","tape" }; static double[] prices = {0.75 , 1.50 , 1.20 , 1.90 , 2.50 , 0.50 , 1.75 , 5.00 , 1.25 , 2.00 }; public static void main(String[] args){ String item; do { item = input("Type the name of an item"); double price = getPrice(item); if(price > 0) { System.out.println(item + " = " + price); } else { System.out.println(item + " was not found"); } } while(item.length() > 0); // type nothing to quit } public static double getPrice(String name) { // search for name, return price // the price is not case-sensitive for(int x=0; x < prices.length; x = x+1) if(items[x].equalsIgnoreCase(name)) // not cases-sensitive return prices[x]; return 0; } public static String input(String prompt) { return javax.swing.JOptionPane.showInputDialog(null,prompt); }} This code should compile and run without any problem. The problem about items and prices is that you are declaring them inside the main function but trying to use them elsewhere. In order for the arrays to be visible to all the functions in a class they need to be declared in the class rather than in a function and, since you are not instantiating any object (you are rather trying to access them from a static context), they, too, need to be static.
  3. On the first example I believe he was complaining about the string not being exactly what was expected. You had "Alas yo do not qualify for a credit card. Capitalism is cruel like that." On the second example I'd say he's complaining because you are logging the string instead of actually returning it.
  4. In Run > Run Configurations... you can select the main class to run (it needs to have a main, obviously).
  5. It's not just in python: any sql queries (in any language) should use prepared statements. A while back I said the same thing to someone working with C# (here) and there is a whole topic for sql injection in this forum (http://linustechtips.com/main/topic/64224-sql-injection-web-programming-with-databases-watch-this/) I just wanted to point out what the error was and keep it simple!
  6. When you do c.fetchall() sql gives you a list with all the rows that match the condidtion specified. Each row has a tuple with the columns requested. Since there is supposed to be only one user with a given username (although, from your previous post a while back it doesn't seem to be enforced) you can use c.fetchone() which will return only the first row. This is equivalent to res = c.fetchall()res = res[0] Then, since you only asked for the column with the password, you can do res[0] to access the password.
  7. If you still need help and are using gcc/g++ (Linux), I may be of assistance!
  8. In that line you are asking the database to give you the password for user "username". You have to concatenate the querry string with the actual input, so something like c.execute("""SELECT password FROM users WHERE username=""" + username)
  9. How so? This usually updates core parts of the system (most notably the kernel and headers) which may lead to problems in some cases. For instance, since I am using the nvidia drivers from their page as opposed to the ubuntu package I have to re-install them every time there is a kernel update. But most of the times problems can be solved without the need to re-install the whole thing. Especially since you can just select an older version from grub and revert back or use a live CD to try and fix it.
  10. This is pretty much what I said in the first topic, so I approve!
  11. Apart from someone moving this to the Programming sub-forum where you may get more help I suggest you rethink the db structure. As far as I know there is no way to indicate a field as a foreign key to more than one table. And even if it was possible it wouldn't make much sense to be honest! I'd make a Work Order table and create a "is a" relation to the six tables you have (you may even be able to reduce the number of replicated attributes in the other 6 tables by moving them to the new "supertype"), create an employee table, and a relation between the Work Order and Employee that may have other attributes.
  12. I think it was Final Fantasy IX on PS1. And the second might have been Metal Gear Solid, also for the PS1.
  13. Well, Ubuntu recognizes that you have a GTX 660 Ti so it would be weird if it didn't work. If it doesn't perhaps there's a problem elsewhere. Bumblebee if for Nvidia Optimus in Linux, be it in a laptop or desktop. Since Optimus is more aimed at power consumption it is used more in laptops and it is unusual to see that problem with desktops. Hence my suggestion to just disable integrated graphics in the bios.
  14. MikeD

    OK then, off to cook my birthday dinner (filet…

    Happy birthday! Enjoy your multi-layered... dinner thing! :)
  15. Vi and Gedit for everything and the usual compilers (javac, gcc, g++) and interpreters (clisp, python, ...). Oh, and gdb to debug! Except when it is more complicated. Then I use Eclipse for Java and I've been using Qt Creator for C++ and some C because I am working in a project that has Cmake and uses gcc builtins and the auto-complete is useful. LaTeX for reports, papers and my thesis, Google Drive or LibreOffice for spreadsheets or powerpoint presentations. P.S.: And the good ol' pencil and paper to draw schemes and stuff! I wish I had a whiteboard at home though...
  16. Well, that command should in fact exist, but the problem seems to be elsewhere. I didn't pay the deserved attention to the fact that the output of lspci indicates that there is an Intel Integrated Graphics Controller present in the system. This, according to what I have read around the ubuntu forums, help pages and bug reports, means that you are using the Optimus thingie and Ubuntu doesn't support it. Or that at least you are using the integrated graphics rather than the nvidia card and that may be why it is not showing any drivers. Now, one way to solve it is to search around how to go about making Optimus work. There is a project that deals with this here: http://bumblebee-project.org/ Another way to solve it is to disable the integrated graphics on the BIOS, which would be the preferred solution. But now I am kind of curious. I have an i7-3770K and an Nvidia GTX 680 and the output of lspci only shows one VGA compatible controller (the nvidia card). I can't remember if I disabled the integrated graphics on the BIOS or not, but I plugged the monitor to the graphics in the first place. Just out of pure curiosity: what port have you plugged the display to, the one on the motherboard or the one on the graphics card? If you are using the one on the motherboard, can you try plugging it to the graphics card, rebooting (without changing the bios) and trying to see if anything changed and running the commands/checking additional drivers (which would be kind of weird, but still!)?
  17. Ok, so it is recognizing your card. Just to be clear, have you tried the first method in the softpedia link? sudo apt-add-repository ppa:ubuntu-x-swat/x-updatessudo apt-get updatesudo apt-get install nvidia-currentsudo nvidia-xconfig//Then check again in the additional drivers If so and it didn't work what error does it give?
  18. There is no one liner for a problem like that. You have to open the file, read the contents and, for each number, check if it is the lowest or the highest you have seen (you need to keep these in two vars) and when there are no more numbers write the min and max to the file and close it. I can't give you any specifics on Pascal because I never used it, but that is the basic principle.
  19. You're welcome! But make sure to double check because it might be all wrong! [spoiler "Funny story actually..."]Today I had a Natural Language test with a few multiple choice questions and at the very last second I decided to change my mind about the answer to a couple of them and I ended up changing from right to wrong... yeahhh....
  20. import sqlite3from functions import *db = sqlite3.connect('accounts.db')c = db.cursor()check_db(c, db) def check_db(c, db): c.execute("""CREATE TABLE IF NOT EXISTS accounts (id NOT NULL PRIMARY KEY, username VCHAR(255) NOT NULL, password VCHAR(255) NOT NULL ) """) db.commit() You actually need both c and db. Passing arguments to functions is just a matter of declaring that the function receives something and calling the function with the actual object you have.
  21. The import is going to import the function before the definition of c (c = ...) so it won't know what c is because it is not yet defined. What you want to do is pass c as an argument to check_db
  22. What's the output of lspci | grep [Vv][Gg][Aa] Edit: I am just about to upgrade mine from the nvidia website!
  23. It is faster if you use the linked clone I believe, since the machines will be tied to the original disk. I think it uses some sort of copy-on-write mechanism where it only copies to its disk any changes that you make, but I am not sure if it's that or if changes to things that existed in the original will be kept there.
  24. And in Portuguese too. Can't click it, useless!
×