Daily Archives

Articles indexed Wednesday June 16 2010

Page 16/119 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • disable Opera function key in javascript

    - by DonDon
    I'm writing javascript code for a web emulator containing function keys. The user is able to press keyboard function keys to process something in the emulator, I used stopPropagation and preventDefault javascript function to stop/cancel browsers invoking their function key shortcut (e.g. F1 will invoke Firefox to open its help page) and the code works fine under Firefox and Chrome. But Opera didn't work. I'm using latest Opera 10.5 here. Can anyone help ?

    Read the article

  • AWS Amazon EC2 - password-less SSH login for non-root users using PEM keypairs

    - by Mark White
    We've got a couple of clusters running on AWS (HAProxy/Solr, PGPool/PostgreSQL) and we've setup scripts to allow new slave instances to be auto-included into the clusters by updating their IPs to config files held on S3, then SSHing to the master instance to kick them to download the revised config and restart the service. It's all working nicely, but in testing we're using our master pem for SSH which means it needs to be stored on an instance. Not good. I want a non-root user that can use an AWS keypair who will have sudo access to run the download-config-and-restart scripts, but nothing else. rbash seems to be the way to go, but I understand this can be insecure unless setup correctly. So what security holes are there in this approach: New AWS keypair created for user.pem (not really called 'user') New user on instances: user Public key for user is in ~user/.ssh/authorized_keys (taken by creating new instance with user.pem, and copying it from /root/.ssh/authorized_keys) Private key for user is in ~user/.ssh/user.pem 'user' has login shell of /home/user/bin/rbash ~user/bin/ contains symbolic links to /bin/rbash and /usr/bin/sudo /etc/sudoers has entry "user ALL=(root) NOPASSWD: ~user/.bashrc sets PATH to /home/user/bin/ only ~user/.inputrc has 'set disable-completion on' to prevent double tabbing from 'sudo /' to find paths. ~user/ -R is owned by root with read-only access to user, except for ~user/.ssh which has write access for user (for writing known_hosts), and ~user/bin/* which are +x Inter-instance communication uses 'ssh -o StrictHostKeyChecking=no -i ~user/.ssh/user.pem user@ sudo ' Any thoughts would be welcome. Mark...

    Read the article

  • Create table with PHP and populate from MySQL

    - by typoknig
    Hi all, I am creating a table to display on a web page and that table is populated from data in a MySQL database. I am trying to do a couple of things that are making it difficult for me. First I am trying to have call the PHP code that exists in a separate file in HTML via JavaScript. I think I have that working right but I am not 100% sure (because the table will not display). I think it is working right because some of the code for the table (which is in the PHP file) displays in FireBug. Second I am trying to make it so the rows alternate colors for easy viewing too. My PHP code so far is below. The table does not display at all in any browser. $query = "SELECT * FROM employees"; $result = mysql_query($query); $num = mysql_num_rows($result); echo '<table>'; for ($i = 0; $i < $num; $i++){ $row = mysql_fetch_array($result); $id = $row['id']; $l_name = $row['l_name']; $f_name = $row['f_name']; $ssn = $row['ssn']; $class = (($i % 2) == 0) ? "table_odd_row" : "table_even_row"; echo "<tr>"; echo "<td class=" . $class . ">$wrap_id</td>"; echo "<td class=" . $class . ">$wrap_l_name</td>"; echo "<td class=" . $class . ">$wrap_f_name</td>"; echo "<td class=" . $class . ">$wrap_ssn</td>"; echo "</tr>"; } echo '</table>'; mysql_close($link); }

    Read the article

  • NullPointerException with CallableStatement.getResultSet()

    - by Raj
    Hello, I have a stored proc in SQL Server 2005, which looks like the following (simplified) CREATE PROCEDURE FOO @PARAMS AS BEGIN -- STEP 1: POPULATE tmp_table DECLARE @tmp_table TABLE (...) INSERT INTO @tmp_table SELECT * FROM BAR -- STEP 2: USE @tmp_table FOR FINAL SELECT SELECT abc, pqr FROM BAZ JOIN @tmp_table ON some_criteria END When I run this proc from SQL Server Management Studio, things work fine. However, when I call the same proc from a Java program, using something like: cs = connection.prepareCall("exec proc ?,"); cs.setParam(...); rs = cs.getResultSet(); // BOOM - Null! while(rs.next()) {...} // NPE! I fail to understand why the first result set returned is NULL. Can someone explain this to me? As a workaround, if I check cs.getMoreResults() and if true, try another getResultSet() - THIS time it returns the proper result set. Any pointers please? (I'm using JTDS drivers, if it matters) Thanks, Raj

    Read the article

  • Domain Model and Contracts

    - by devoured elysium
    I am modelling a DVD Rental Store: A Client gives its clientNumber to the System. The System checks whenever the given clientNumber is valid. The Client gives the name of the DVD he wants to rent. ... n. ...I will later have to form an association between a new instance of "RentDVD" class concept to the current Client c. My Domain Model is something like: I've made the Contract for the first and second operations as: Preconditions: none Postconditions: there exists a Client c such that c.clientNumber = clientNumber. Now, I don't know if I should form an association between this Client c and the DVDStore(that I intend to use as front-end). If I don't make the association, how will I later be able to "reference" this same Client? Should I be making an association between Client and a different concept? Thanks

    Read the article

  • Python shortcuts

    - by lyrae
    Python is filled with little neat shortcuts. For example: self.data = map(lambda x: list(x), data) and (although not so pretty) tuple(t[0] for t in self.result if t[0] != 'mysql' and t[0] != 'information_schema') among countless others. In the irc channel, they said "too many to know them all". I think we should list some here, as i love using these shortcuts to shorten & refctor my code. I'm sure this would benefit many.

    Read the article

  • Problem using form builder & DOM manipulation in Rails with multiple levels of nested partials

    - by Chris Hart
    I'm having a problem using nested partials with dynamic form builder code (from the "complex form example" code on github) in Rails. I have my top level view "new" (where I attempt to generate the template): <% form_for (@transaction_group) do |txngroup_form| %> <%= txngroup_form.error_messages %> <% content_for :jstemplates do -%> <%= "var transaction='#{generate_template(txngroup_form, :transactions)}'" %> <% end -%> <%= render :partial => 'transaction_group', :locals => { :f => txngroup_form, :txn_group => @transaction_group }%> <% end -%> This renders the transaction_group partial: <div class="content"> <% logger.debug "in partial, class name = " + txn_group.class.name %> <% f.fields_for txn_group.transactions do |txn_form| %> <table id="transactions" class="form"> <tr class="header"><td>Price</td><td>Quantity</td></tr> <%= render :partial => 'transaction', :locals => { :tf => txn_form } %> </table> <% end %> <div>&nbsp;</div><div id="container"> <%= link_to 'Add a transaction', '#transaction', :class => "add_nested_item", :rel => "transactions" %> </div> <div>&nbsp;</div> ... which in turn renders the transaction partial: <tr><td><%= tf.text_field :price, :size => 5 %></td> <td><%= tf.text_field :quantity, :size => 2 %></td></tr> The generate_template code looks like this: def generate_html(form_builder, method, options = {}) options[:object] ||= form_builder.object.class.reflect_on_association(method).klass.new options[:partial] ||= method.to_s.singularize options[:form_builder_local] ||= :f form_builder.fields_for(method, options[:object], :child_index => 'NEW_RECORD') do |f| render(:partial => options[:partial], :locals => { options[:form_builder_local] => f }) end end def generate_template(form_builder, method, options = {}) escape_javascript generate_html(form_builder, method, options) end (Obviously my code is not the most elegant - I was trying to get this nested partial thing worked out first.) My problem is that I get an undefined variable exception from the transaction partial when loading the view: /Users/chris/dev/ss/app/views/transaction_groups/_transaction.html.erb:2:in _run_erb_app47views47transaction_groups47_transaction46html46erb_locals_f_object_transaction' /Users/chris/dev/ss/app/helpers/customers_helper.rb:29:in generate_html' /Users/chris/dev/ss/app/helpers/customers_helper.rb:28:in generate_html' /Users/chris/dev/ss/app/helpers/customers_helper.rb:34:in generate_template' /Users/chris/dev/ss/app/views/transaction_groups/new.html.erb:4:in _run_erb_app47views47transaction_groups47new46html46erb' /Users/chris/dev/ss/app/views/transaction_groups/new.html.erb:3:in _run_erb_app47views47transaction_groups47new46html46erb' /Users/chris/dev/ss/app/views/transaction_groups/new.html.erb:1:in _run_erb_app47views47transaction_groups47new46html46erb' /Users/chris/dev/ss/app/controllers/transaction_groups_controller.rb:17:in new' I'm pretty sure this is because the do loop for form_for hasn't executed yet (?)... I'm not sure that my approach to this problem is the best, but I haven't been able to find a better solution for dynamically adding form partials to the DOM. Basically I need a way to add records to a has_many model dynamically on a nested form. Any recommendations on a way to fix this particular problem or (even better!) a cleaner solution are appreciated. Thanks in advance. Chris

    Read the article

  • The Linux Desktop isn't Dead, it's Pining

    <b>DaniWeb: </b>"I know it sounds crazy but the Linux Desktop isn't dead, it's just pining. It's pining for the correct platform--a tablet computer. And, I'm not referring to some cheap imitation tablet that will merely satisfy a few observers and nerdlets who use Linux. I'm thinking of a tablet computer for hardcore Linux moguls."

    Read the article

  • To what point is making an HTML page valid worth it?

    - by Martín Fixman
    Since a long time ago, when I found out about the W3C Validator, I made sure every HTML document I made was valid HTML. However, I think sometimes it just isn't necessary to waste time making it valid. Of course, for actual Internet pages may be important, but is making pages on an Intranet, or even little front-ends that are used with other programs, when the HTML page renders correctly in the most used browsers (not necessarily counting IE 6 and 7). I think I'm mostly talking about little improvements over code, such as wrapping every shown element of the page on <p> or <div> tags.

    Read the article

  • Which langauge should i use for Artificial intelligence on web projects

    - by Mirage
    I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods. I only know PHP/mysq/JS, and there is not much AI stuff examples in PHP. There are some books on AI on internet but they use Java , Python. Now I have to apply AI techniques on web application. Which language should i choose java or python. I searhed on internet that I can call java classes inside my php so that can help as as I am very good at php I have also seen that python can also be used with php as well So which way should I go and roughly how much it will take me to learn java I have done java basics but that was 6 years ago

    Read the article

  • ActiveMQ 5.2.0 + REST + HTTP POST = java.lang.OutOfMemoryError

    - by Bruce Loth
    First off, I am a newbie when it comes to JMS & ActiveMQ. I have been looking into a messaging solution to serve as middleware for a message producer that will insert XML messages into a queue via HTTP POST. The producer is an existing system written in C++ that cannot be modified (so Java and the C++ API are out). Using the "demo" examples and some trial and error, I have cobbled together a working example of what I want to do (on a windows box). The web.xml I configured in a test directory under "webapps" specifies that the HTTP POST messages received from the producer are to be handled by the MessageServlet. I added a line for the text app in "activemq.xml" ('ow' is the test app dir): I created a test script to "insert" messages into the queue which works well. The problem I am running into is that it as I continue to insert messages via REST/HTTP POST, the memory consumption and thread count used by ActiveMQ continues to rise (It happens when I have timely consumers as well as slow or non-existent consumers). When memory consumption gets around 250MB's and the thread count exceeds 5000 (as shown in windows task manager), ActiveMQ crashes and I see this in the log: Exception in thread "ActiveMQ Transport Initiator: vm://localhost#3564" java.lang.OutOfMemoryError: unable to create new native thread It is as if Jetty is spawning a new thread to handle each HTTP POST and the thread never dies. I did look at this page: http://activemq.apache.org/javalangoutofmemory.html and tried but that didn't fix the problem (although I didn't fully understand the implications of the change either). Does anyone have any ideas? Thanks! Bruce Loth PS - I included the "test message producer" python script below for what it is worth. I created batches of 100 messages and continued to run the script manually from the command line while watching the memory consumption and thread count of ActiveMQ in task manager. def foo(): import httplib, urllib body = "<?xml version='1.0' encoding='UTF-8'?>\n \ <ROOT>\n \ [snip: xml deleted to save space] </ROOT>" headers = {"content-type": "text/xml", "content-length": str(len(body))} conn = httplib.HTTPConnection("127.0.0.1:8161") conn.request("POST", "/ow/message/RDRCP_Inbox?type=queue", body, headers) response = conn.getresponse() print response.status, response.reason data = response.read() conn.close() ## end method definition ## Begin test code count = 0; while(count < 100): # Test with batches of 100 msgs count += 1 foo()

    Read the article

  • Ajax request using mootools not working

    - by benny
    Hi everyone, I try loading content into a div with this tutorial. Unfortunately, this simply loads the HTML file as a new page. This is the javascript that should do the job window.addEvent('domready', function() {      $('runAjax').addEvent('click', function(event) {          event.stop();          var req = new Request({              method: 'get',              url: $('runAjax').get('href'),              data: { 'do' : '1' },              onRequest: function() { alert('The request has been made, please wait until it has finished.'); },   onComplete: function(response) { alert('Response received.); $('container').set('html', response); }          }).send(); $('runAjax').removeEvent('click');      }); }); this is the link that should initiate the function <a href="about.html" id="runAjax" class="panel">Profil</a> and this is the div-structure of index.html. i want the content to be loaded into the "container"-div <div id="view"> <div id="sidebar"> mib </div> <div id="container"> <div id="logo"> <!--img src="img/logo.png"--> </div> <div align="center" id="tagline"> content </div> </div> </div> I dont really care what script i use as long as its compatible with MooTools 1.2, because i need it for a sliding top panel and it would be a lot more work to change it to a jquery panel for example.

    Read the article

  • iPhone Development with Bluetooth SPP OS 3/4

    - by nigel-jewell
    Hi all, I am in the process of developing an iPhone application that communicates with a number of Bluetooth devices that all support Serial Port Profile - well I assume that it is SPP as they show on my MacBook as Serial Port DevB etc. I understand that iPhone OS 3.x does not support SPP - is that correct? Does anyone know if that has been "fixed" in OS 4? I've seen reports of OS 4 supporting keyboards, but is that a locked version of HID, or will SPP be available via the SDK? Kind Regards, Nige.

    Read the article

  • Has anyone been successful at a assembler based led blinker for an xcore?

    - by dwelch
    I am liking the http://www.xmos.com chips but want to get a lower level understanding of what is going on. Basically assembler. I am trying to sort out something as simple as an led blinker, set the led, count to N clear the led, count to N, loop forever. Sure I can disassemble a 10 line XC program, but if you have tried that you will see there is a lot of bloat in there that is in every program, what bits are to support the compiler output and what bits are actually setting up the gpio?

    Read the article

  • Android: Problems downloading images and converting to bitmaps

    - by Mike
    Hi all, I am working on an application that downloads images from a url. The problem is that only some images are being correctly downloaded and others are not. First off, here is the problem code: public Bitmap downloadImage(String url) { HttpClient client = new DefaultHttpClient(); HttpResponse response = null; try { response = client.execute(new HttpGet(url)); } catch (ClientProtocolException cpe) { Log.i(LOG_FILE, "client protocol exception"); return null; } catch (IOException ioe) { Log.i(LOG_FILE, "IOE downloading image"); return null; } catch (Exception e) { Log.i(LOG_FILE, "Other exception downloading image"); return null; } // Convert images from stream to bitmap object try { Bitmap image = BitmapFactory.decodeStream(response.getEntity().getContent()); if(image==null) Log.i(LOG_FILE, "image conversion failed"); return image; } catch (Exception e) { Log.i(LOG_FILE, "Other exception while converting image"); return null; } } So what I have is a method that takes the url as a string argument and then downloads the image, converts the HttpResponse stream to a bitmap by means of the BitmapFactory.decodeStream method, and returns it. The problem is that when I am on a slow network connection (almost always 3G rather than Wi-Fi) some images are converted to null--not all of them, only some of them. Using a Wi-Fi connection works perfectly; all the images are downloaded and converted properly. Does anyone know why this is happening? Or better, how can I fix this? How would I even go about testing to determine the problem? Any help is awesome; thank you!

    Read the article

  • How to create dependencies in automake?

    - by Sam
    Hello, I have a Makefile.am file right now that looks like this: lib_LIBRARIES = foo.a foo_a_SOURCES = bar.F90 baz.F90 When compiled, bar.F90 gives bar.o. However, bar.F90 depends on several other Fortran files (cat.F90, dog.F90, pig.F90). I want to set up Automake to rebuild bar.o if the source of one of these dependencies change. I've been reading the GNU manuals for automake/autoconf and was unable to find a solution to this. Thanks for reading.

    Read the article

  • Adding map overlays

    - by diana
    Hi all, I am using iPhone os4 for development. I need to add overlays to mapview. Apple now provides overlays as a new feature of os4. How can i add overlays.Any help will be greatly appreciated.

    Read the article

  • Table modifications while running db replication (MS SQL 2008)

    - by typemismatch
    I'm running SQL Server 2008 Std with a database that is being published in a "Transactional Publication" to a single subscriber. We are unable to make any changes to the tables on the publisher without getting the "cannot modify table because it is published for replication". This seems odd because schema changes (or scripts run to do this) should be pushed to the subscriber. We currently have to drop the entire publication system to make table changes. What am I missing? There must be a way to update the publisher tables? thanks!

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >