Search Results

Search found 7418 results on 297 pages for 'argument passing'.

Page 156/297 | < Previous Page | 152 153 154 155 156 157 158 159 160 161 162 163  | Next Page >

  • j2ME setLocationListener()

    - by Jeff Catania
    I'm programming a GPS tracking system using the Motorola i335 running on Sprint's IDEN network. I'm using the javax.microedition.location api to find the GPS coordinates. To set up the updating, you use the [setLocationListener][1] method. I originally tried passing (listener,2,1,1). However there was too many invalid locations being received (where the GPS could not get the fix in the specified time), so I changed the parameters to (listener, 20, 20, 1). Now the system barely throws any invalid locations. My goal is to get the fastest number of updates that are realistic. Have any of you found a happy medium for parameters of this method? [1]: http://www-users.cs.umn.edu/~czhou/docs/jsr179/lapi/javax/microedition/location/LocationProvider.html#setLocationListener(javax.microedition.location.LocationListener, int, int, int)

    Read the article

  • How to execute a shell script on startup?

    - by vijay.shad
    I have create a script to start a server(my first question). Now I want it to run on the system boot and start the defined server. What should I do to get this done? My findings tell me put this file in /etc/init.d location and it will execute when the system will boot. But I am not able to understand how the first argument on the startup will be start? Is this predefined somewhere to use start as $1? If I want to have a case startall that will start all the servers in the script, then what are the options I can manage. My Script is like this: #!/bin/bash case "$1" in start) start ;; stop) stop ;; restart) $0 stop $0 start ;; *) echo "usage: $0 (start|stop|restart)" ;; esac

    Read the article

  • Rails: redirect_to :controller=>'tips', :action => 'show', :id => @tip.permalink

    - by john
    hi, I tried to redirect rails to show action by passing controller, action, and params. However, rails ignores the name of action totally! what I got is http://mysite/controllername/paramId so i have error message.... here is the action code I used: def update @tip = current_user.tips.find(params[:id]) @tip.attributes = params[:tip] @tip.category_ids = params[:categories] @tip.tag_with(params[:tags]) if params[:tags] if @tip.save flash[:notice] = 'Tip was successfully updated.' redirect_to :controller=>'tips', :action => 'show', :id => @tip.permalink else render :action => 'edit' end end

    Read the article

  • Perl, treat string as binary byte array

    - by Mike
    In Perl, is it appropriate to use a string as a byte array containing 8-bit data? All the documentation I can find on this subject focuses on 7-bit strings. For instance, if I read some data from a binary file into $data my $data; open FILE, "<", $filepath; binmode FILE; read FILE $data 1024; and I want to get the first byte out, is substr($data,1,1) appropriate? (again, assuming it is 8-bit data) I come from a mostly C background, and I am used to passing a char pointer to a read() function. My problem might be that I don't understand what the underlying representation of a string is in Perl.

    Read the article

  • How to generate a good random seed to pass to srand()?

    - by zr
    Hi, I am writing a C++ program which needs to create a temporary file for its internal usage. I would like to allow concurrent executions of the program by running multiple proccesses, so the temporary file name needs to be randomized, that way each spawned process will generate a unique temporary file name for its own use. I am using rand() to generate random characters for part of the file name, so i need to initialize the random number generator's seed using srand(). What options are there for passing a good argument to srand() such that two processes will not be initialized with the same seed value? My code needs to work both on Windows and pn Linux TIA.

    Read the article

  • Using Google Weather API with Lat and Lon - how to format?

    - by Paul
    I am wanting to use the Google Weather API - by passing lat and long values. However it seems Google is needing these formatted differently to the values I have stored. i.e. For the town of McTavish I have values of 45.5 and -73.583 This works here: http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=45.5,-73.583 But when I use Google it does not: See: www.google.com/ig/api?weather=,,,45.5,-73.583 Any help appreciated. I would prefer to use the Google Data.

    Read the article

  • How to pass interface type/GUID reference to an automation method in Delphi

    - by Alan Clark
    In Delphi you can pass class references around to compare the types of objects, and to instantiate them. Can you do the same with interface references being passed to a COM automation server? For example, you can define a method taking a GUID parameter using the type library editor: function ChildNodesOfType(NodeType: TGUID): IMBNode; safecall; In this function I would like to return automation types that support the interface specified by NodeType, e.g. if Supports(SomeNode, NodeType) then result := SomeNode; But the Supports call always fails, I tried passing in the Guids defined in the type library but none of the different types (Ixxx, Class_xxxx, IId_Ixxxx) seem to work.

    Read the article

  • Is there anything wrong with my Factory class?

    - by Alex
    class PieceFactory { @SuppressWarnings("rawtypes") public Piece createPiece(String pieceType) throws Throwable{ Class pieceClass = Class.forName(pieceType); Piece piece = (Piece) pieceClass.newInstance(); return piece; } } I'm not all used to handling exceptions yet therefore I'm just throwing them, but everywhere I use a method that uses this factory it tells me I have to throw exceptions like throwable. For example, in one of my classes I have a method that instantiates a lot of objects using the method that uses the factory. I can use the method in that class by just throwing the exception, however it won't work if I try to pass a reference to that class to another class and then use the method from there. Then it forces me to try catch the exception. I probably don't need a factory but it seemed interesting and I'd like to try to use patterns. The reason I created the factory was that I have 6 subclasses of Piece and I wan't to use a method to instantiate them by passing the type of subclass I want as an argument to the method.

    Read the article

  • Returning references while using shared_ptrs

    - by Goose Bumper
    Suppose I have a rather large class Matrix, and I've overloaded operator== to check for equality like so: bool operator==(Matrix &a, Matrix &b); Of course I'm passing the Matrix objects by reference because they are so large. Now i have a method Matrix::inverse() that returns a new Matrix object. Now I want to use the inverse directly in a comparison, like so: if (a.inverse()==b) { ... }` The problem is, this means the inverse method needs to return a reference to a Matrix object. Two questions: Since I'm just using that reference in this once comparison, is this a memory leak? What happens if the object-to-be-returned in the inverse() method belongs to a boost::shared_ptr? As soon as the method exits, the shared_ptr is destroyed and the object is no longer valid. Is there a way to return a reference to an object that belongs to a shared_ptr?

    Read the article

  • Is AMQP suitable as both an intra and inter-machine software bus?

    - by Bwooce
    I'm trying to get my head around AMQP. It looks great for inter-machine (cluster, LAN, WAN) communication between applications but I'm not sure if it is suitable (in architectural, and current implementation terms) for use as a software bus within one machine. Would it be worth pulling out a current high performance message passing framework to replace it with AMQP, or is this falling into the same trap as RPC by blurring the distinction between local and non-local communication? I'm also wary of the performance impacts of using a WAN technology for intra-machine communications, although this may be more of an implementation concern than architecture. War stories would be appreciated.

    Read the article

  • Convert Stream to IEnumerable. If possible when "keeping laziness"

    - by Binary255
    Hi, I recieve a Stream and need to pass in a IEnumerable to another method. public static void streamPairSwitchCipher(Stream someStream) { ... someStreamAsIEnumerable = ... IEnumerable returned = anotherMethodWhichWantsAnIEnumerable(someStreamAsIEnumerable); ... } One way is to read the entire Stream, convert it to an Array of bytes and pass it in, as Array implements IEnumerable. But it would be much nicer if I could pass in it in such a way that I don't have to read the entire Stream before passing it in. public static IEnumerable<T> anotherMethodWhichWantsAnIEnumerable<T>(IEnumerable<T> p) { ... // Something uninteresting }

    Read the article

  • How to access a String Array location in android?

    - by Vamsi Challa
    Android 2.3.3 This is my code... String[] expression = {""}; //globally declared as empty somewhere in the code below, I am trying to assign a string to it. expression[0] = "Hi"; I keep getting the following error... 12-08 22:12:19.063: E/AndroidRuntime(405): java.lang.ArrayIndexOutOfBoundsException Can someone help me with this.. Can we access the index 0, directly as i am doing? Actual Code ::: static int x = 0; // global declaration String[] assembledArray = {""}; // global declaration assembleArray(strSubString, expression.charAt(i)); //Passing string to the method //Method Implementation private void assembleArray(String strSubString, char charAt) { // TODO Auto-generated method stub assembledArray[x] = strSubString; assembledArray[x+1] = String.valueOf(charAt); x = x+2; }

    Read the article

  • Using jmock how to reuse parameter

    - by BenZen
    I'm building a test, in wich i need to send question, and wait for the answer. Message passing is not the problem. In fact to figure out wich answer correspond to wich question, i use an id. My id is generated using an UUID. an i want to retrieve this id, wich is given as a parameter to a mocked object. It look like this: oneOf(message).setJMSCorrelationID(with(correlationId)); inSequence(sequence); Where correlationId is the string i'd like to keep for an other expecteation like this one: oneOf(session).createBrowser(with(inputChannel), with("JMSType ='pong' AND JMSCorrelationId = '"+correlationId+"'")); have you got an answer?

    Read the article

  • URLClassLoader does not find folders in jar if not ending with '/'?

    - by IttayD
    A 3rd party library (jersey) is trying to find Java packages by ClassLoader#findResource passing in the package name as file name (replacing dots with slashes). What I see is that if I pass a package name as 'a.b.c' (converted to 'a/b/c') it is not found, but if I pass 'a.b.c.' it is found. This translated directly to URL#inputStream that uses ZipFile which doesn't find the entry a/b/c, but finds the entry a/b/c/ I'm trying to find if this is the intended behavior or is there something wrong with my packaging (maven) or the URLs passed to the classloader (which look like jar:file://C:/.../foo.jar!/)

    Read the article

  • Mimic an HTTPRequest and HTTPResponse object in Java

    - by Ankur
    How do I mimic an HTTPServletRequest and HTTPServletResponse object. The reason is I want to test the behaviour of some servlets. I know JUnit probably provides this functionality but I don't know how to use it (I will learn soon) and need to do this reasonably quickly. HTTPServletRequest and HTTPServletResponse are both interfaces so they can't be instantiated. There is a HttpServletRequestWrapper which implements HttpServletRequest but it doesn't seem to have any setParameter() type methods and HttpServletResponse doesn't seem to have any implementing classes at all. How can I test my code by passing a suitable HttpServletRequest object and then checking that the received HttpServletResponse object matches what I expect?

    Read the article

  • How do I route watir through a proxy pragmatically?

    - by feydr
    I'm trying to route watir through a proxy pragmatically -- this means within the script I'd like to change my proxy dynamically before launching the browser. Here's what I've tried so far (and so far am failing): I'm running chrome and lucid lynx ubuntu. I chose TREX cause I thought watir might be making use of PROXY or something. I rewrote /usr/bin/google-chrome as: #!/bin/bash /opt/google/chrome/chrome --proxy-server="$TREX" $@ The reason I'm passing in the environment variable to proxy-server rather than http_proxy is because I never could get http_proxy to work as is anyways then I did a simple: require 'rubygems' require 'watir-webdriver' ENV['TREX'] = "XX.XX.XX.XX:YY" browser = Watir::Browser.new(:chrome) browser.goto("http://mysite.com") Anyways, what is happening here is that it is forwarding me to the login page of the proxy rather than just forwarding the request. What am I missing here? I feel like I'm pretty close.

    Read the article

  • How to change theme in Windows 7 with Powershell script?

    - by Greg McGuffey
    I would like to have a script that would change the current theme of Windows 7. I found the registry entry where this stored, but I apparently need to take some further action to get windows to load the theme. Any ideas? Here is the script that I'm trying to use, but isn't working (registry updated, but theme not changed): ###################################### # Change theme by updating registry. # ###################################### # Define argument which defines which theme to apply. param ( [string] $theme = $(Read-Host -prompt "Theme") ) # Define the themes we know about. $knownThemes = @{ "myTheme" = "mytheme.theme"; "alien" = "oem.theme" } # Identify paths to user themes. $userThemes = " C:\Users\yoda\AppData\Local\Microsoft\Windows\" # Get name of theme file, based on theme provided $themeFile = $knownThemes["$theme"] # Build path to theme and set registry. $newThemePath = "$userThemes$themeFile" $regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\" Set-ItemProperty -path $regPath -name CurrentTheme -value $newThemePath # Update system with this info...this isn't working! rundll32.exe user32.dll, UpdatePerUserSystemParameters Thanks!

    Read the article

  • Accessing NHibernate Repository using ASP.NET Ajax WebMethod

    - by LooDaFunk
    Hi there! on my page I have a save button that gets the values from the form and then saves it in the database using NHibernate. This works using ASP.net postback buttons. I have now added an Ajax WebMethod to make things sleek and quicker. Howver, when trying to access the data in the repository it doesn't seem to get it. I am passing in the correct values, and everything looks the same as when you are using the postback but no Joy! I should point out here that I'm a newbie with NHibernate and I'm working with someone elses code. Here's the code: the main problem is this line: Solution.Entities.Hierarchy.Tag tag = tagRep.Get(tagId); The tagID is fine, but when it does the get no exception is raised it just comes out the method and goes back to the page???? http://pastebin.com/cBTp9pnC Anyone have any ideas? Merry Christmas!

    Read the article

  • Java singleton VO class implementing serializable, having default values using getter methods

    - by user309281
    Hi All I have a J2SE application having user threads running in a separate JVM outside JBOSS server. During startup, J2SE invokes a EJB inside jboss, by passing a new object(singleton) of simple JAVA VO class having getter/setter methods. {The VO class is a singleton and implements serialiable(as mandated by EJB)}. EJB receives the object, reads all db configuration and uses the setter methods of new object to set all the values. It then returns back this updated object back to J2SE in the same remote call. After J2SE receives the object(singleton/serializable), if i invoke getter methods, I could see only default values set during object creation before EJB call, and not the values set by the EJB. Kindly throw some light on, why the received object from EJB does not see any updated values and how to rectify this. I believe it got to do with object initialization during deserialization. And i tried overriding readResolve() in the VO class, but of no help. With Regards, Krishna

    Read the article

  • Lock HTML select element, allow value to be sent on submit

    - by ILMV
    I have a select box (for a customer field) on a complex order form, when the user starts to add lines to the order they should not be allowed to change the customer select box (unless all lines are deleted). My immediate thought was that I could use the disabled attribute, but when the box is disabled the selected value is no longer passed to the target. When the problem arose a while ago one of the other developers worked around this by looping through all the options and disabling all but the selected option, and sure enough the value was passed to the target and we've been using since. But now I'm looking for a proper solution, I don't want to loop through all the options because are data is expanding and it's starting to introduce performance issues. I'd prefer not to enable this / all the elements when the submit button is hit. How can I lock the input, whilst maintaining the selected option and passing that value to the target script? I would prefer a non-JavaScript solution if possible, but if needed we are running jQuery 1.4.2 so that could be used.

    Read the article

  • How do I create a random method name

    - by Russ Bradberry
    I plan on using JSONP to call an external webservice to get around the fact that I dont want to create a global function that could potentially conflict with the calling page. I thought that creating a random function name and passing it up would work. Something like this: <script src="www.foo.com/b?cb=d357534"> where cb is the callback function name, the server would return d357534({my json data}); what i want to know is how to create the random function name, im sure i could use eval but is this the best way to go about it? essentially, what i am trying to do is this: var d + Math.floor(Math.random()*1000001) = function(){...

    Read the article

  • Starting with asp.net MVC

    - by Josemalive
    Hello, Actually im doing a home page that only have an action called Index() that returns the view Index.ascx. This index page will be composed by lastest news and lastest registered users, i think that create two partial views is the best idea (this way i could use it in other views). for other hand i have a data access class that calls to database for get stuff (get last news, get last users, etc...) My question is simple, should i call to the this data access class in the Index() action of my HomeController, and add to the ViewData the data obtained? I think that this index() action shouldnt be the responsable of passing this data to the partial views, right? Could you give me a hand? im messing too much? ;-) Thanks in advance. Best Regards. Jose

    Read the article

  • Django: cannot pass variable to included template?

    - by duy
    Hi, I got a problem where I want to use template including in Django. Here is the real example: I got 3 file: home.html (will get the context variable passed from Views), base.html (the skeleton template file) and the header.html (included by base.html). If if put the code below directly in base.html without including the header.html, the {{title}} variable passing from home is correctly called. But if I include the header.html in base.html, the {{title}} variable's value cannot be called. <title>{% block title %}{% endblock %} | {{ SITE_INFO_TITLE }}</title> Is there any solution to this problem? Thanks.

    Read the article

  • Does lighter wallpaper consumes lesser power than a Darker one

    - by Lamb
    My VAIO advised me to switch to a White Background, to reduce power consumption. But it seems contradictory to common logic. Its like saying a brighter Torch consuming less than a dimmer one. Common Logic says that, Screen is BLACK when not using any POWER, so displaying black color should not consume any power (because without powering any pixel it gives black color) Also a white screen gives me more light than a darker one, so it should use more Energy. White Wallpaper = More Light Output = More Electrical Energy Consumed Black Wallpaper = Less Light = Less Electricity Consumed My question is - Is there anything wrong with the above argument ? A Lighter Wallpaper consumes less power than a Darker one. Is it true ? If yes, Why ?

    Read the article

  • const read only local copies

    - by robUK
    Hello gcc 4.4.4 c89 I am just wondering is it worth passing a const into a function. i.e. void do_something(const char *dest, const int size) The size is a read-only so I don't want to change it. However, some developers never have this as const has it is a local copy that is being used. The pointer is const as you can change the value in the calling routine. I always have a const on read-only local copies, as it confirms to anyone reading my code that it is a read-only variable. And also, when coding I don't make the mistake of changing it without realizing. Many thanks for any suggestions,

    Read the article

< Previous Page | 152 153 154 155 156 157 158 159 160 161 162 163  | Next Page >