Daily Archives

Articles indexed Thursday June 10 2010

Page 7/121 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Parallelize Bash Script

    - by thelsdj
    Lets say I have a loop in bash: for foo in `some-command` do do-something $foo done do-something is cpu bound and I have a nice shiny 4 core processor. I'd like to be able to run up to 4 do-something's at once. The naive approach seems to be: for foo in `some-command` do do-something $foo & done This will run all do-somethings at once, but there are a couple downsides, mainly that do-something may also have some significant I/O which performing all at once might slow down a bit. The other problem is that this code block returns immediately, so no way to do other work when all the do-somethings are finished. How would you write this loop so there are always X do-somethings running at once?

    Read the article

  • How to get attribute value using SelectSingleNode?

    - by Nano HE
    I am parsing a xml document, I need find out the gid (an attribute) value (3810). Based on SelectSingleNode(). I found it is not easy to find the attribute name and it's value. Can I use this method or I must switch to other way. Attached my code. How can I use book obj to get the attribute value3810 for gid. Thank you. My test.xml file as below <?xml version="1.0" ?> <root> <VersionInfo date="2007-11-28" version="1.0.0.2" /> <Attributes> <AttrDir name="EFEM" DirID="1"> <AttrDir name="Aligner" DirID="2"> <AttrDir name="SequenceID" DirID="3"> <AttrObj text="Slot01" gid="3810" unit="" scale="1" /> <AttrObjCount value="1" /> </AttrDir> </AttrDir> </AttrDir> </Attributes> </root> I wrote the test.cs as below public class Sample { public static void Main() { XmlDocument doc = new XmlDocument(); doc.Load("test.xml"); XmlNode book; XmlNode root = doc.DocumentElement; book = root.SelectSingleNode("Attributes[AttrDir[@name='EFEM']/AttrDir[@name='Aligner']/AttrDir[@name='SequenceID']/AttrObj[@text='Slot01']]"); Console.WriteLine("Display the modified XML document...."); doc.Save(Console.Out); } } [Update 06/10/2010] The xml file is a complex file. Included thousands of gids. But for each of Xpath, the gid is unique. I load the xml file to a TreeView control. this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);. When treeView1_AfterSelect event occurred, the e.Node.FullPath will return as a String Value. I parse the string Value e.Node.FullPath. Then I got the member of XPath Above. Then I tried to find which gid item was selected. I need find the gid value as a return value indeed.

    Read the article

  • what else to do to establish many-to-many associations in Ruby on Rails? thanks!

    - by john
    Hi, I have two classes and I want to establish a many-to-many assications, here is the code: class Category < ActiveRecord::Base has_and_belongs_to_many :events has_and_belongs_to_many :tips end class Tip < ActiveRecord::Base has_and_belongs_to_many :categories However, I kept getting the following errors and I would appreciate it if some one could educate me what is going wrong: PGError: ERROR: relation "categories_tips" does not exist : SELECT "categories".id FROM "categories" INNER JOIN "categories_tips" ON "categories".id = "categories_tips".category_id WHERE ("categories_tips".tip_id = NULL ) the viewer part: 4: <%= text_field :tip, :title %></label></p> 5: 6: <p><label>Categories<br/> 7: <%= select_tag('categories[]', options_for_select(Category.find(:all).collect {|c| [c.name, c.id] }, @tip.category_ids), :multiple => true ) %></label></p> 8: 9: <p><label>Location<br/> 10: <%= text_field_with_auto_complete :tip, :abstract %></label></p>

    Read the article

  • Android different resolutions problem

    - by user346665
    Hi, I have 9 (vertical) radio buttons and they are all showing in default resolution (320x480) without problems . But when I'm trying in resolution for Htc Tattoo (240x320) the last radio button is hidden - there isn't space to be shown. How to make uniformly size ?

    Read the article

  • calculate distance with linq or subsonic

    - by minus4
    i have this MySQL statement from a search page, the user enters there postcode and it finds the nearest stiocklist within 15 MIles of the entered postcode. SELECT * , ( ( ACOS( SIN( "+SENTLNG +" * PI( ) /180 ) * SIN( s_lat * PI( ) /180 ) + COS( " + SENTLNG +" * PI( ) /180 ) * COS( s_lat * PI( ) /180 ) * COS( ( " + SENTLANG + " - s_lng ) * PI( ) /180 ) ) *180 / PI( ) ) *60 * 1.1515 ) AS distance_miles FROM new_stockists WHERE s_lat IS NOT NULL HAVING distance_miles <15 ORDER BY distance_miles ASC LIMIT 0 , 15 but now i am using linq and subsonic and not got a clue how do do this in linq or subsonic your help would be much appreciated, please also not that i have to sent in a dynamic from address, thats the postcode mentioned at the top of the page, i do a call to google to get then lng and lat from them for the postcode given.

    Read the article

  • Help with Oracle SQL Count function! =)

    - by user363024
    Hi guys.. The question im struggling with is this: i have a list of helicopter names in different charters and i need to find out WHICH helicopter has the least amount of charters booked. Once i find that out i need to ONLY display the one that has the least. I so far have this: SELECT Helicopter_Name COUNT (Distinct Charter_NUM) FROM Charter_Table GROUP BY Helicopter Name ^ this is where i am stuck, i realise MIN could be used to pick out the value that is the smallest but i am not sure how to integrate this into the command. Something like Where MIN = MIN Value Id really appreciate it

    Read the article

  • How do I use a command line tool to install .net 4 to IIS

    - by tehp
    I'm trying to deploy my WCF RIA services application to our in-house server for testing. I've been following the instructions and comments from this blog site: http://timheuer.com/blog/archive/2009/12/10/tips-to-deploy-ria-services-troubleshoot.aspx At the end someone points to this question: http://stackoverflow.com/questions/1528324/how-to-solve-a-http-error-404-3-not-found-error I've been trying to run that same tool with .net 4.0 but it keeps giving me an error: [Warning]The HTTP namespace reservation already exists. I am running the version of the exe that I found inside of C:\Windows\Microsoft.NET\Framework\v4.0.21006 There is also C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation that has (what I assume is) the same exe in it, and I can use it just fine. I've tried to un-install the 3.0 version before installing the 4.0 version, but I am still getting the same warning and failure. Has anyone successfully done this with .net 4.0?

    Read the article

  • Flash Player scripting + IE8

    - by Joel Alejandro
    I've developed a small control bar for a Flash viewer generated by a third-party software. It has a First, Prev, Next & Last button, and a Zoom command. While Zoom works fine in all browsers, the navigation buttons seem to fail at Internet Explorer 8. I use at least two functions. This one locates the Flash object I want to manipulate: function getFlashMovieObject(movieName) { if (window.document[movieName]) { return window.document[movieName]; } if (navigator.appName.indexOf("Microsoft Internet")==-1) { if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; } else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) { return document.getElementById(movieName); } } ...and any of these ones handles the frame navigation: var currentFrame = 0; function gotoFirst(id) { getFlashMovieObject(id + "Blueprints").Rewind(); currentFrame = 0; $("currentFrame").innerHTML = currentFrame + 1; $("frameTitle").innerHTML = frameTitles[id][currentFrame]; } function gotoPrev(id) { var movie = getFlashMovieObject(id + "Blueprints"); if (currentFrame 0) { currentFrame--; } movie.GotoFrame(currentFrame); $("currentFrame").innerHTML = currentFrame + 1; $("frameTitle").innerHTML = frameTitles[id][currentFrame]; } function gotoNext(id) { var movie = getFlashMovieObject(id + "Blueprints"); if (currentFrame < movie.TotalFrames() - 1) { currentFrame++; } movie.GotoFrame(currentFrame); $("currentFrame").innerHTML = currentFrame + 1; $("frameTitle").innerHTML = frameTitles[id][currentFrame]; } function gotoLast(id) { var movie = getFlashMovieObject(id + "Blueprints"); currentFrame = movie.TotalFrames() - 1; movie.GotoFrame(currentFrame); $("currentFrame").innerHTML = currentFrame + 1; $("frameTitle").innerHTML = frameTitles[id][currentFrame]; } Btw, that $ is MooTools, not jQuery. Anyway, IE dies on the movie.TotalFrames() call. What can I do to solve this? Keep in mind I need this to be done via JavaScript, as I cannot edit the SWF.

    Read the article

  • Putting Illustrator CS4 in fullscreen?

    - by thyrgle
    Hi, so I got this drawing tool from my good friend because he got a bigger and better one and I have the Adobe Suite CS4. But, I'm not a good drawer so I am interested in learning and I kind of want to turn Illustrator into a canvas that takes up the whole screen. In addition, I don't want the window to be shown at all. Is there any way to do this? Photoshop or another alternative works also works but I would prefer Illustrator.

    Read the article

  • Is there a way to force HTTPS protocol in a Kohana 2.3 site?

    - by alex
    I've got a site built on top of Kohana 2.3 which I now have to make all links https. I set this in application/config/config.php. $config['site_protocol'] = 'https'; This makes all links on the site use the https protocol. Except, when I first enter the site via http, it will not automatically forward to https. Is there a way to make Kohana do this, or do I just need to do some custom coding? I've found this .htaccess rule too, will it be fine to just drop this in? RewriteEngine On RewriteCond %{SERVER_PORT} !=443 RewriteRule ^ https://yourdomain.tld%{REQUEST_URI} [NS,R,L] Thanks.

    Read the article

  • moq SetupSet is obsolete. In place of what?

    - by jkohlhepp
    Let's say I want to use moq to create a callback on a setter to store the set property in my own field for later use. (Contrived example - but it gets to the point of the question.) I could do something like this: myMock.SetupSet(x => x.MyProperty).Callback(value => myLocalVariable = value); And that works just fine. However, SetupSet is obsolete according to Intellisense. But it doesn't say what should be used as an alternative. I know that moq provides SetupProperty which will autowire the property with a backing field. But that is not what I'm looking for. I want to capture the set value into my own variable. How should I do this using non-obsolete methods?

    Read the article

  • Restlet - Access elements of the request URL

    - by DutrowLLC
    I'm unsure what the proper way is to access parts of the requested URL. In this case, I want to get the requested path without the query variables. This is the only way I found to do it: String path = getRequest().getResourceRef().getHostIdentifier() + getRequest().getResourceRef().getPath(); The result would be the bold part of this url: http://stackoverflow.com/questions/ask?query=value I also found about 6 different ways to get the server name (http://stackoverflow.com) but I'm worried that some of them would fail in certain cases that I am unaware of (why would there be 6 different ways to do one thing): getRequest().getHostRef().getHostIdentifier(); getRequest().getHostRef().getIdentifier(); getRequest().getRootRef().getHostIdentifier(); getRequest().getRootRef().getIdentifier(); getRequest().getResourceRef().getHostIdentifier(); And this seems to get the complete URL with query parameters: getRequest().getResourceRef().getIdentifier(); Any further explanation would be much appreciated.

    Read the article

  • Linux Lightweight Distro and X Windows for Development

    - by Fernando Barrocal
    Heyall... I want to build a lightweight linux configuration to use for development. The first idea is to use it inside a Virtual Machine under Windows, or old Laptops with 1Gb RAM top. Maybe even a distributable environment for developers. So the whole idea is to use a LAMP server, Java Application Server (Tomcat or Jetty) and X Windows (any Window manager, from FVWM to Enlightment), Eclipse, maybe jEdit and of course Firefox. Edit: I am changing this post to compile a possible list of distros and window managers that can be used to configure a real lightweight development environment. I am using as base personal experiences on this matter. Info about the distros can be easily found in their sites. So please, focus on personal use of those systems Distros Ubuntu / Xubuntu Pros: Personal Experience in old systems or low RAM environment - @Schroeder, @SCdF Several sugestions based on personal knowledge - @Kyle, @Peter Hoffmann Gentoo Pros: Not targeted to Desktop Users - @paan Don't come with a huge ammount of applications - @paan Slackware Pros: Suggested as best performance in a wise install/configuration - @Ryan Damn Small Linux Pros: Main focus is the lightweight factor - 50MB LiveCD - @Ryan Debian Pros: Very versatile, can be configured for both heavy and lightweight computers - @Ryan APT as package manager - @Kyle Based on compatibility and usability - @Kyle -- Fell Free to add Prós and Cons on this, so we can compile a good Reference. -- X Windows suggestion keep coming about XFCE. If others are to add here, open a session for it Like the distro one :)

    Read the article

  • Logictech USB HID controller message

    - by rross
    I have a Logitech game controller(http://www.amazon.com/Logitech-Dual-Action-Game-Pad/dp/B0000ALFCI). I'm using c# and Microsoft's HID driver to track what buttons are being pressed. Each button press sends a Byte Array that has 8 values. The problems is that I don't know what those 8 value represent. Here is an example: 0, 128, 126, 127, 130, 24, 24, 0, 4, 252 0, 128, 126, 127, 130, 40, 40, 0, 4, 252 0, 128, 126, 127, 127, 72, 72, 0, 4, 252 0, 128, 126, 127, 127, 136, 136, 0, 4, 252 Those are the values of the Byte Array for button press 1, 2, 3, 4 respectively. I see where the values are changing, but I'm unsure what they represent. I'm unable to find any specs on Microsoft HID driver. Can someone point me in the right direction?

    Read the article

  • How to get more Feed items?

    - by drozzy
    How would I get the next page or more results for a feed? For example, when I go to Security Now feed page, there is no "next" link of any kind and the url parameter of "page=100" does nothing: http://leoville.tv/podcasts/sn.xml I get only 1 page of results of about 20 episodes. However my Google Reader can successfully retrieve episodes that are earlier than that.

    Read the article

  • How doe we name test methods where we are checking for more than one condition?

    - by Sandbox
    I follow the technique specified in Roy Osherove's The Art Of Unit Testing book while naming test methods - MethodName_Scenario_Expectation. It suits perfectly well for my 'unit' tests. But,for tests that I write in 'controller' or 'coordinator' class, there isn't necessarily a method which I want to test. For these tests, I generate multiple conditions which make up one scenario and then I verify the expectation. For example, I may set some properties on different instances, generate an event and then verify that my expectations from controller/coordinator is being met. Now, my controller handles events using a private event handler. Here my scenario is that, I set some properties, say 3 condition1,condition2 and condition3 Also, my scenario includes an event is raised I don't have a method name as my event handler is private. How do I name such a test method?

    Read the article

  • SSLException: Received fatal alert: certificate_unknown - what does it mean?

    - by user338154
    Hi, I am getting the "javax.net.ssl.SSLException: Received fatal alert: certificate_unknown" error when attempting to send a HTTPS message. I believe the message is due to the endpoint not recognising the sent certificate or is rejecting it. But I want to be doubly sure this is a server issue and not a local client issue before I go barking up the wrong tree with my error analysis. Can you guys please clarify the meaning of this error (google isn't helping much) and whether it is client or endpoint server related. FYI: I am using Websphere Application Server 6.1 Thanks

    Read the article

  • Display Computer Info on an ASP.NET Page

    - by Gene
    I want to build a page for end users to visit (in our MPLS Network) and it show the following information in regards to them: Computer Name OS Disk Space Memory IP Address Active Directory User Name Password Expiration Time (As defined by Global Policy) Maybe a few other things such as Trend Micro Office current version vs. their version, # of MS Updates needed (we utilize WSUS), and a few other things in the future. My question is how would I pull this information from the user when they visit the page? What is the proper function for this? Anyone have examples they wish to share for me to learn by if possible?

    Read the article

  • Multiple complexFilter in Magento's api v2

    - by Alekc
    Currently I’m having some difficulties with using new Magento's soap v2 from c# interface. With php i was able to do something like this: $params["created_at"]["from"] = date("Y-m-d H:i:s",Functions::convert_time($dataDa)); $params["created_at"]["to"] = date("Y-m-d H:i:s",Functions::convert_time($dataA)); MageInterface::getSingleton()->shipmentList($params); In this mode i was able to find list of orders which were created from $dataDa to $dataA without problems. With c# however it seems that only the last one of the selectors work. My code: var cpf = new complexFilter[2]; cpf[0] = new complexFilter { key = "created_at", value = new associativeEntity { key = "to", value = uxDataA.DateTime.ToString("yy-MM-dd HH:mm:ss") } }); cpf[1] = new complexFilter { key = "created_at", value = new associativeEntity { key = "from", value = uxDataDa.DateTime.ToString("yy-MM-dd HH:mm:ss") } }); var filters = new filters(); filters.complex_filter = cpf; var risultato = mage.salesOrderList(sessionKey, filters); In this mode only created_at-from criteria is taken in consideration (it's like second complex filter override previous one with the same key). Ideas? Thanks in advance.

    Read the article

  • UIViewTableCell didSelectRowAtIndexPath is calling but not pushing a view controller

    - by Kenneth
    Hi guys, so im having a UIViewController view with a UITableView. So the UIViewController class name is SelectionScreen. The UITableView class name is SelectionScreenTable. Picture: http://img717.imageshack.us/i/screenshot20100609atpm0.png/ I have declared a UITableView *selectionTable in SelectionScreen class and connected it to the xib file of the SelectionScreen what the problem is , is that when i click a row in the table,it stays selected as highlighted blue, it calls the didSelectRowAtIndexPath (checked with NSLog) but not pushing a new view which is called(GraphView). This is the code which i use to call the new controller WHICH WORKS with a normal button GraphView *aSelectionScreenViewController = [[GraphView alloc] initWithNibName:@"GraphView" bundle:nil]; [self presentModalViewController:aSelectionScreenViewController animated: YES]; [aSelectionScreenViewController release]; I searched around and found that I need to set a delegate for the table in the UITableView class itself on the viewload tableview.delegate = self; or self.tableview.delegate = self; But it was not working. the controller was still not being pushed, and yes i have checked the controller is not nil as i tried it with a simple button. So i was thinking whether i should set the delegate of the UITableView at the UIViewController instead, so i tried this code selectionTable.delegate = selectionTable.self; but obviously it did not work =\, it messed up the whole UITableView and caused all the cells to be its predefined settings. So does anybody have any idea on how i can get it to work.

    Read the article

  • How can you tell if an activities state is stored?

    - by Joren
    I have an activity which pulls some JSON from my server, and then uses it to draw a list. That list launches further activities. My problem is that I can't figure out a way to tell if the activity is still alive when you go back to it, so I end up re-querying my JSON from the server and redrawing the list every time the user goes back to the activity. How can I tell if my activity is still alive so I can skip the redraw?

    Read the article

  • Pylons 1.0 AttributeError: 'module' object has no attribute 'metadata'

    - by shiki
    Python noob trying to learn Pylons. I'm using the QuickWiki tutorial (http://pylonshq.com/docs/en/1.0/tutorials/quickwiki_tutorial/) from the 1.0 documentation, but this alleged "1.0" doc seems to just be "0.9.7"; I suspect that this has something to do with the error I'm getting. When I execute "paster setup-app development.ini", I get this: (mydevenv)lucid@lucid-laptop:~/QuickWiki$ paster setup-app development.ini Traceback (most recent call last): ... edited for brevity... File "/home/lucid/mydevenv/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1954, in load File "/home/lucid/QuickWiki/quickwiki/config/middleware.py", line 11, in <module> from quickwiki.config.environment import load_environment File "/home/lucid/QuickWiki/quickwiki/config/environment.py", line 12, in <module> from quickwiki.model import init_model File "/home/lucid/QuickWiki/quickwiki/model/__init__.py", line 27, in <module> pages_table = sa.Table('pages', meta.metadata, AttributeError: 'module' object has no attribute 'metadata' (mydevenv)lucid@lucid-laptop:~/QuickWiki$

    Read the article

  • What is the proper way to code a read-while loop in Scala?

    - by ARKBAN
    What is the "proper" of writing the standard read-while loop in Scala? By proper I mean written in a Scala-like way as opposed to a Java-like way. Here is the code I have in Java: MessageDigest md = MessageDigest.getInstance( "MD5" ); InputStream input = new FileInputStream( "file" ); byte[] buffer = new byte[1024]; int readLen; while( ( readLen = input.read( buffer ) ) != -1 ) md.update( buffer, 0, readLen ); return md.digest(); Here is the code I have in Scala: val md = MessageDigest.getInstance( hashInfo.algorithm ) val input = new FileInputStream( "file" ) val buffer = new Array[ Byte ]( 1024 ) var readLen = 0 while( readLen != -1 ) { readLen = input.read( buffer ) if( readLen != -1 ) md.update( buffer, 0, readLen ) } md.digest The Scala code is correct and works, but feels very un-Scala-ish. For one it is a literal translation of the Java code, taking advantage of none of the advantages of Scala. Further it is actually longer than the Java code! I really feel like I'm missing something, but I can't figure out what. I'm fairly new to Scala, and so I'm asking the question to avoid falling into the pitfall of writing Java-style code in Scala. I'm more interested in the Scala way to solve this kind of problem than in any specific helper method that might be provided by the Scala API to hash a file. (I apologize in advance for my ad hoc Scala adjectives throughout this question.)

    Read the article

  • Can I install Win 7 Pro with a Win 7 Home Premium disc?

    - by SeanJA
    So I got the 64bit Win 7 Pro disc from the Ultimate steal for cheap enough... but I found out that some stuff that I want to run (games mostly... since that is the only reason I keep Windows around...) did not do too well on the 64bit OS. So I have borrowed my friend's install disc, but it turns out that his is only Home Premium rather than Pro which I have a serial for. Can I still just run through the Home Premium install and use my Pro serial number (seems like I should be able to with the whole 'any time upgrade' deal)? Or do I have to go and find a 32bit pro disc to do the install? Are there any hoops that I have to jump through?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >