Search Results

Search found 609 results on 25 pages for 'stephen g'.

Page 19/25 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Looking for Go equivalent of scanf.

    - by Stephen Hsu
    I'm looking for the Go equivalent of scanf(). I tried with following code: 1 package main 2 3 import ( 4 "scanner" 5 "os" 6 "fmt" 7 ) 8 9 func main() { 10 var s scanner.Scanner 11 s.Init(os.Stdin) 12 s.Mode = scanner.ScanInts 13 tok := s.Scan() 14 for tok != scanner.EOF { 15 fmt.Printf("%d ", tok) 16 tok = s.Scan() 17 } 18 fmt.Println() 19 } I run it with input from a text with a line of integers. But it always output -3 -3 ... And how to scan a line composed of a string and some integers? Changing the mode whenever encounter a new data type? The Package documentation: Package scanner A general-purpose scanner for UTF-8 encoded text. But it seems that the scanner is not for general use. Updated code: func main() { n := scanf() fmt.Println(n) fmt.Println(len(n)) } func scanf() []int { nums := new(vector.IntVector) reader := bufio.NewReader(os.Stdin) str, err := reader.ReadString('\n') for err != os.EOF { fields := strings.Fields(str) for _, f := range fields { i, _ := strconv.Atoi(f) nums.Push(i) } str, err = reader.ReadString('\n') } r := make([]int, nums.Len()) for i := 0; i < nums.Len(); i++ { r[i] = nums.At(i) } return r }

    Read the article

  • Are Thread.stop and friends ever safe in Java?

    - by Stephen C
    The stop(), suspend(), and resume() in java.lang.Thread are deprecated because they are unsafe. The Sun recommended work around is to use Thread.interrupt(), but that approach doesn't work in all cases. For example, if you are call a library method that doesn't explicitly or implicitly check the interrupted flag, you have no choice but to wait for the call to finish. So, I'm wondering if it is possible to characterize situations where it is (provably) safe to call stop() on a Thread. For example, would it be safe to stop() a thread that did nothing but call find(...) or match(...) on a java.util.regex.Matcher? (If there are any Sun engineers reading this ... a definitive answer would be really appreciated.) EDIT: Answers that simply restate the mantra that you should not call stop() because it is deprecated, unsafe, whatever are missing the point of this question. I know that that it is genuinely unsafe in the majority of cases, and that if there is a viable alternative you should always use that instead. This question is about the subset cases where it is safe. Specifically, what is that subset?

    Read the article

  • Developing web app, question for mobile developers

    - by Stephen Kellett
    I'm going to develop a web app that I expect some people will also end up wanting to view on their phones. The UI will be fairly straightforward (no frames, just CSS/HTML). May have a bit of Flash, but not for the first version. My question is, for testing viewing of the web app on mobile devices what devices would you recommend that I test on (and thus, most likely, have to purchase)? Windows Mobile iPhone Android Other? or can I use emulators for any/all of these? Note that I'm not developing a platform (android, iPhone) specific app, just a web application that I expect will also be accessed from a mobile phone. I apologise if this seems like a niave/stupid question, but this hobby project is totally away from my commercial experience and I just don't know the answers to these questions, hence asking here. Thanks for reading.

    Read the article

  • Can tomcat perform ssl redirection by filtering host alias?

    - by Stephen
    Hi, We have a tomcat server (6.0.20) running one web application behind two urls, e.g. www.foo and secure.foo This is configured in the server.xml as one host with a single alias: <Host name="www.foo" appBase="webapps"> <Context docBase="foo" path=""></Context> <Alias>secure.foo</Alias> </Host> Ideally we'd like any requests to secure.foo on port 80 to be automatically redirected to use ssl. However, I can only find instructions for redirecting based on the path after the hostname, so I could add a /* security constraint but then this would apply to both urls. Does anyone know if it's possible to apply the redirection by filtering on hostname requested? (We've already got the ssl connector, certificate, etc. working ok). I know we could do it by sticking an apache server in front of tomcat and handling the redirection there, but I'm curious to know if tomcat can do this on its own. Thanks

    Read the article

  • How does hibernate use an empty string for an equality restriction?

    - by Stephen
    I have a column that potentially has some bad data and I can't clean it up, so I need to check for either null or empty string. I'm doing a Hibernate Criteria query so I've got the following that returns incorrectly right now: Session session = getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); Criteria myCriteria = session.createCriteria(Object); ... myCriteria.add(Restrictions.or(Restrictions.isNull("stringColumn"), Restrictions.eq("stringColumn", ""))); List<Objects> list = myCriteria.list(); I can't get it to properly return the results I'd expect. So as an experiment I changed the second restriction to read: Restrictions.eq("stringColumn", "''") And it started returning the expected results, so is hibernate incorrectly translating my empty string (e.g. "") into a SQL empty string (e.g. ''), or am I just doing this wrong?

    Read the article

  • Specifying SOAP Headers for a Zend_Soap Service

    - by Stephen
    I have a generally straight forward web service that I've written (converting code to ZF from a Java implementation of the same service and trying to maintain the same wsdl structure as much as possible). The service loads a PHP class, rather than individual functions. The PHP class contains three different functions within it. Everything seems to be working just fine, except that I can't seem to figure out how to specify that a given function parameter should be passed as a SOAP header. I've not seen any mention of SOAP headers in the Server context, only how to pass header parameters with a client to a server. In addition to the standard parameters for the function that would be sent in the SOAP body and detailed in the docblock, I would like to specify two parameters (a username and password) that would be sent in a SOAP header. I have to assume this is possible, but haven't been able to find anything online, nor have I had any responses to a similar post on Zend's forum. Is there something that can be added in the docblock area to specify a parameter as a header (maybe in a similar fashion to using WebParam?)? Any suggestions/examples on how to get this accomplished would be greatly appreciated!

    Read the article

  • Differences between Ruby on Rails versions? Which should I use?

    - by Stephen Kellett
    I first used Rails when it was not so well known about, in 2005. I did some experimental work with it but it has languished due to lack of time. I'm now thinking of persuing the original idea again (with a new implementation) and when researching the latest Ruby and Ruby-on_Rails versions I see Ruby 1.9.2 and a Rails 3.0 beta. I haven't managed to find a concise description of the differences between any of the Rails major versions. I have looked on the official Rails site and a few others as well. No joy. Maybe i'm looking in the wrong places or for the wrong thing? My project isn't commercial in nature (it's a hobby thing) so the beta nature of Rails 3.0 doesn't put me off. I'd just like to know what the differences are. Can anyone explain please? If it makes any odds to the answer, I'll be working on a Linux box and/or a Windows box.

    Read the article

  • Phantom horizontal scroll bars on the whole window in IE.

    - by Stephen
    I'm working on a website layout you can find at dev.movingcost.com In most browsers, everything seems fine... but I'm getting a horizontal scroll bar on the window when viewing the page in IE. I'm using a fixed width of 960px with auto margins to center the content. I've even tried using "overflow-x:hidden" on the html and body tags to no avail... any clue where the problem is?

    Read the article

  • how to implement a game character task queue

    - by Stephen Lee Parker
    I'm working on a personal game engine in C# and need to give certain characters / sprites responses to conditions or certain patterns that they follow and since these patterns will be repeated over and over for other characters / sprites, I don't want to tie the patterns to the character / sprite. I will likely want to define the conditions / actions in level data files... I plan to use this for platformers, space shooters, and pack man like games... Almost an extenable AI system. Any suggestions on how this can be implemented?

    Read the article

  • Cygwin GCC + WinXP cmd.exe does nothing

    - by Stephen Friederichs
    My basic problem is that if I run GCC from the windows command line (cmd.exe in Windows XP) and it does nothing: no .o files are created, no error messages, nothing. It will only throw an error message if I use DOS-style paths, but nothing else. When I run from the Cygwin shell then it will throws error messages as appropriate for the errors in the source and produces the .o files as it needs. Using 'make' from the DOS command line doesn't work either. Has anyone encountered this behavior before?

    Read the article

  • NSCoding and ostream

    - by Stephen Furlani
    Is there a better way to serialize an ObjC object than using /NSKeyedArchive? I need to distribute the object through a C++ std:ostream-like object to put on another computer. The object has over 122 members of various types... for which wants me to [coder encodeObject: (id) forKey: @"blah"]; for all of them... Does anyone have a nice Perl Script that will at least write it out? I don't even know if the objects it contains implement which means this could turn into a huge ugly mess since I can't change the source of the object - I'll have to inherit & add the @interface to it... Or am I being dumb? Apple's guide doesn't help me since archiving to XML won't pass nicely though the ostream. Is there a better way to do this? -S!

    Read the article

  • How can I speed up Netbeans Task Marker resolution?

    - by Stephen
    I'm trying to quickly navigate and fix problems in code in Netbeans, and it just takes too long. I'll fix a problem, and it will take seconds to re-compile. While this is happening, the marker remains, and all the others that depend on it will too (requiring multiple next-marker key strokes to get to a "new" problem). If I'm doing a fix that changes the number of lines (e.g. organise imports), the markers will navigate to the wrong place, even though the correct text is underlined. Is there a way to speed this up? I presume it's because it's doing a full file compilation via javac to calculate the markers. BUT the information is available in netbeans, because the correct text is underlined, even when the compilation occurs.

    Read the article

  • How to normalize a database where different user groups have different kinds of profiles?

    - by Stephen
    My application database has a Groups table that separates users into logical roles and defines access levels (admin, owner, salesperson, customer service, etc.) Groups has many Users. The Users table contains login details such as username and password. Now I wish to add user profiles to my database. The trouble I'm having (probably due to my relative unfamiliarity with proper database normalization) is that different user groups have different kinds of profiles. Ergo, a salesperson's profile will include his commission percentage, whereas an admin or customer service would not need this value. So, would the proper method be to create a unique profile table for each group? (e.g. admin_profiles, or salesperson_profiles). or is there a better way that combines certain details in a generic profile, while some users have extended info. And if so, whats a good example of how to do this with the commission example given?

    Read the article

  • What to Learn after C++?

    - by Stephen Whitmore
    I have been learning C++ for a while now, I find it very powerful. But, the problem is the the level of abstraction is not much and I have to do memory management myself. What are the languages that I can use which uses a higher level of abstraction.

    Read the article

  • WMI to reboot remote machine

    - by Stephen Murby
    I found this code on an old thread to shutdown the local machine: using System.Management; void Shutdown() { ManagementBaseObject mboShutdown = null; ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem"); mcWin32.Get(); // You can't shutdown without security privileges mcWin32.Scope.Options.EnablePrivileges = true; ManagementBaseObject mboShutdownParams = mcWin32.GetMethodParameters("Win32Shutdown"); // Flag 1 means we want to shut down the system. Use "2" to reboot. mboShutdownParams["Flags"] = "1"; mboShutdownParams["Reserved"] = "0"; foreach (ManagementObject manObj in mcWin32.GetInstances()) { mboShutdown = manObj.InvokeMethod("Win32Shutdown", mboShutdownParams, null); } } Is it possible to use a similar WMI method to reboot flag"2" a remote machine, for which i only have machine name, not IPaddress. EDIT: I currently have; SearchResultCollection allMachinesCollected = machineSearch.FindAll(); Methods myMethods = new Methods(); string pcName; ArrayList allComputers = new ArrayList(); foreach (SearchResult oneMachine in allMachinesCollected) { //pcName = oneMachine.Properties.PropertyNames.ToString(); pcName = oneMachine.Properties["name"][0].ToString(); allComputers.Add(pcName); MessageBox.Show(pcName + "has been sent the restart command."); Process.Start("shutdown.exe", "-r -f -t 0 -m \" + pcName); } but this doesn't work, and i would prefer WMI going forward.

    Read the article

  • NullPointerException on TextView

    - by Stephen Adipradhana
    i get a null pointer exception and the program crash on each time i want to update the highscore text using setText(). what causes this problem? this code is when i set my layout, the layout is a part of the gameView using opengl, and i put the highscore textview on the upper left corner public void onCreate(Bundle savedInstanceState) { SFEngine.display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();//ambl ukuran width height layar super.onCreate(savedInstanceState); gameView = new SFGameView(this); gameView.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); RelativeLayout layout = new RelativeLayout(this); layout.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView textBox = new TextView(this); textBox.setId(1); textBox.setText("HIGH SCORE"); textBox.setBackgroundColor(Color.BLUE); textBox.setWidth(SFEngine.display.getWidth()/2); textBox.setHeight(50); Button pauseButton = new Button(this); pauseButton.setText("PAUSE"); pauseButton.setHeight(50); pauseButton.setWidth(SFEngine.display.getWidth()/2); pauseButton.setOnTouchListener(new OnTouchListener(){ public boolean onTouch(View v, MotionEvent e) { //pause game SFEngine.isPlaying = false; Intent i1 = new Intent(SFGames.this, pause.class); gameView.onPause(); startActivityForResult(i1,0);//hrs pk result soalny mw blk lg return true; } }); RelativeLayout.LayoutParams lp_pause = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams lp_hs = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp_hs.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp_pause.addRule(RelativeLayout.ALIGN_PARENT_TOP); lp_pause.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); textBox.setLayoutParams(lp_hs); pauseButton.setLayoutParams(lp_pause); layout.addView(gameView); layout.addView(textBox); layout.addView(pauseButton); setContentView(layout); and here is the setText code public boolean onTouchEvent (MotionEvent event){//buat nerima input user if(!SFEngine.isPlaying){ finish(); } textBox.setText("High Score :" + SFEngine.score);//here is the source of the prob .....

    Read the article

  • iPhone App takes up too much memory

    - by Stephen Furlani
    Ok, so here's my problem. My iPhone app is 1.2MB on disk. Granted I have a bunch of Images for the GUI buttons and backgrounds, etc. In-memory, my app takes up a whopping 15MB! That means if I then take a picture with the camera, 8MB default, it gives a memory warning (several) even before the picker calls its delegate! How can I tell what is grabbing so much memory, and how to remove it? I've removed all of my debugging symbols and added [-Os], but it still takes up a huge amount of memory! Also, (how) can I change the default resolution of the camera?

    Read the article

  • Is it safe to unset PHP super-globals if this behavior is documented?

    - by Stephen
    I'm building a PHP framework, and in it I have a request object that parses the url as well as the $_GET, $_POST and $_FILE superglobals. I want to encourage safe web habits, so I'm protecting the data against SQL injection, etc. In order to ensure users of this framework are accessing the safe, clean data through the request object, I plan to use unset($_GET, $_POST, $_REQUEST); after parsing those variables. I will document this in the method comments, and explain in the framework documentation that this is happening. My question is: Would this be desirable behavior? What are the potential pitfalls that I have not foreseen?

    Read the article

  • Why does this SELECT ... JOIN statement return no results?

    - by Stephen
    I have two tables: 1. tableA is a list of records with many columns. There is a timestamp column called "created" 2. tableB is used to track users in my application that have locked a record in tableA for review. It consists of four columns: id, user_id, record_id, and another timestamp collumn. I'm trying to select up to 10 records from tableA that have not been locked by for review by anyone in tableB (I'm also filtering in the WHERE clause by a few other columns from tableA like record status). Here's what I've come up with so far: SELECT tableA.* FROM tableA LEFT OUTER JOIN tableB ON tableA.id = tableB.record_id WHERE tableB.id = NULL AND tableA.status = 'new' AND tableA.project != 'someproject' AND tableA.created BETWEEN '1999-01-01 00:00:00' AND '2010-05-06 23:59:59' ORDER BY tableA.created ASC LIMIT 0, 10; There are currently a few thousand records in tableA and zero records in tableB. There are definitely records that fall between those timestamps, and I've verified this with a simple SELECT * FROM tableA WHERE created BETWEEN '1999-01-01 00:00:00' AND '2010-05-06 23:59:59' The first statement above returns zero rows, and the second one returns over 2,000 rows.

    Read the article

  • To use package properly, how to arrange directory, file name, unit test file?

    - by Stephen Hsu
    My source files tree is like this: /src /pkg /foo foo.go foo_test.go Inside foo.go: package foo func bar(n int) { ... } inside foo_test.go: package foo func testBar(t *testing.T) { bar(10) ... } My questions are: Does package name relates to directory name, source file name? If there is only one source file for a package, need I put it in a directory? Should I put foo.go and foo_test.go in the same package? In the foo_test.go, as it's in the same package as foo.go, I didn't import foo. But when I compile foo_test.go with 6g, it says bar() is undefined. What should I do?

    Read the article

  • findBy(x) Using Zend_Navigation with custom route

    - by Stephen
    I am creating my navigation from a db generated array and defining which route to use for some of the uris. when I set the route i am no longer able to use findByUri() as the uri seems to be moved under the properties key example array being used: [id] => 7 [label] => Legal [controller] => index [uri] => /legal [route] => cmsPage [visible] => 1 [params] => Array ( [first] => legal ) snippet of the output: [_properties:protected] => Array ( [uri] => /legal [created] => 2012-10-20 10:23:23 ) When I don't define the route I am able to use findByUri() successfully. currently I am looping through each to find the property that matches the request but it seems a long / wrong approach Is there a way to search by the nested param - or am i doing something wrong with the setup (everything else behaves as expected)

    Read the article

  • ( Sql Server 2005 C#.Net ) - I want just the insert query for a temp table.

    - by John Stephen
    Hi..I am using C#.Net and Sql Server ( Windows Application ). I had created a temporary table. When a button is clicked, temporary table (#tmp_emp_details) is created. I am having another button called "insert Values" and also 5 textboxes. The values that are entered in the textbox are used and whenever com.ExecuteNonQuery(); line comes, it throws an error message called "Invalid object name '#tbl_emp_answer'.". Below is the set of code..Please give me a solution. Code for insert (in insert value button): private void btninsertvalues_Click(object sender, EventArgs e) { username = txtusername.Text; examloginid = txtexamloginid.Text; question = txtquestion.Text; answer = txtanswer.Text; useranswer = txtanswer.Text; SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=tempdb;Integrated Security=True;"); SqlCommand com = new SqlCommand("Insert into #tbl_emp_answer values('"+username+"','"+examloginid+"','"+question+"','"+answer+"','"+useranswer+"')", con); con.Open(); com.ExecuteNonQuery(); con.Close(); }

    Read the article

  • Which computing publisher has the best refereed research resources for the working programmer?

    - by Stephen
    When I have a problem I often search the computing literature. Some of the resources[*] I use are: The professional associations? ACM Digital Library IEEE Xplore The scientific publishers? Lecture Notes in Computer Science HCI Bibliography What do you use? What is the best resource source (if there is one) for the working programmer? [*] after stackoverflow and google of course :) PS what tags should I use for this question?

    Read the article

  • Recordset Update errors when updating sql_variant field

    - by Stephen Nutt
    I'm using C++ and ADO to add data to a SQL Server 2005 database. When calling the Recordset Update method for a sql_variant column I'm getting the error DB_E_ERRORSOCCURRED and the error message Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. If the value I'm adding is NULL all works fine and all values going to the fields that are not sql_variant types work. Does anyone know what I might be doing wrong? Thanks [Edit] I have some more information. The value we are storing is the empty string - ADO appears to want to store this in the sql_variant as a nchar(0), which of course is not a valid SQL data type. Is there a way to get an empty string in a sql_variant using the ADO batch commands?

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25  | Next Page >