Search Results

Search found 6433 results on 258 pages for 'trouble shooting'.

Page 24/258 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • iPhone -trouble with a loading data from webservice into a tableview

    - by medampudi
    I am using a Window based application and then loading up my initial navigationview based controller. After loading it if the user is not registered/ does not have a credentials present then it takes the user to a login view controller . loginViewController *sampleView = [[loginViewController alloc] initWithNibName:@"loginViewController" bundle:nil]; [self.navigationController presentModalViewController:sampleView animated:YES]; [sampleView release]; then right after that i try to load the table with data that i get from a webservice using asiHTTP .. for this question lets say it takes 3 seconds time to get the data and then deserialize it . now... my question is it works out okey in the later runs as I store the username and password in a seure location... but in the first instance.... i am not able to get the data to laod to the tableview... I have tried a lot of things... 1. Initially the data fetch methods was in a diffrent methods.. so i thought that might be the problem as then moved it the same place as the tbleviewController(navigationController) 2. I event put in the Reload data at the end of the functionality for the data parsing and deserialization... nothing happens. 3. i did not understand the concept of @property and alll.... 4. The screen is black screen with nothing displayed on it for a good 5 seconds in the consecutive launches of the app.... so could we have something like a MBPorgressHUD implemented for the same. could any one please help for these scenarios and guidance as to what paths to take from here...

    Read the article

  • trouble with section headers in UITableView

    - by richard Stephenson
    hi guys , im having a problem with setting my section headers in a uitableview, its probably something really simple i just cant work it out. instead of displaying different headers for different sections it displays the same header for each section help me please :) - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { WorldCupAppDelegate *appDelegate = [UIApplication sharedApplication].delegate; return [appDelegate.matchFixtures count]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { WorldCupAppDelegate *appDelegate = [UIApplication sharedApplication].delegate; Fixtures *fixtures = [appDelegate.matchFixtures objectAtIndex:section]; return fixtures.matchDate; }

    Read the article

  • Custom ASP.net UserControl List<T> Property, having trouble setting declaratively

    - by Chris McCall
    I'm developing a custom UserControl to inject JQuery hotkeys into a page declaratively on the server side. Here's the control (the important parts anyway): [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("HotKeys"), ParseChildren(true, "HotKeys"), ToolboxData("<{0}:HotKeysControl runat=\"server\"> </{0}:HotKeysControl>")] public partial class HotKeysControl : System.Web.UI.WebControls.WebControl { private string crlf = Environment.NewLine; public List<HotKey> _HotKeys; public HotKeysControl() { if (_HotKeys == null) { _HotKeys = new List<HotKey>(); } // if I uncomment this line, script is injected into the page // _HotKeys.Add(new HotKey("ctrl+r","thisControl")); } [ Category("Behavior"), Description("The hotkeys collection"), DesignerSerializationVisibility( DesignerSerializationVisibility.Content), Editor(typeof(HotKeyCollectionEditor), typeof(UITypeEditor)), PersistenceMode(PersistenceMode.InnerDefaultProperty) ] public List<HotKey> HotKeys { set { _HotKeys = value; } get { return _HotKeys; } } Here's the .aspx code: <%@ Register Assembly="MyCompany.ProductName.WebControls" Namespace="MyCompany.ProductName.WebControls" TagPrefix="uc" %> ... <uc:HotKeysControl ID="theHotkeys" runat="server" Visible="false"> <uc:HotKey ControlName="firstControl" KeyCode="ctrl+1" /> <uc:HotKey ControlName="thirdControl" KeyCode="ctrl+2" /> </uc:HotKeysControl> Nothing happens, as if no HotKeys objects are being added to the property collection. What Am I doing wrong? If I uncomment out the line above and "manually" add items, it works. It's something about how I'm declaratively adding hotkeys to the page. Any ideas?

    Read the article

  • Trouble tunneling my local Wordpress install to the mysql database on appfog

    - by alanmoo
    I've set up a wordpress install on appfog (using rackspace), and cloned the install to my local machine for development. I know the install works (using MAMP) because I created a local mysql database and changed wp-config.php to point to it. However, I want to develop without having to change wp-config.php every time I commit. After doing some research, it seems like the Appfog service Caldecott lets me tunnel into the mysql database on the server, using af tunnel. Unfortunately, I'm having issues with getting it working. Even if I change my MAMP mysql port to something like 8889, and tunnel mysql through port 3306, it looks like it's connected but I still get "Error establishing a database connection" when loading my localhost Wordpress. When I quit the mysql monitor (using ctrl+x, ctrl+c), I get a message stating "Error: 'mysql' execution failed; is it in your $PATH?'. Originally, no, it wasn't, but I've fixed my PATH variable on my local machine so that when I go to Terminal and just type mysql, it loads up. So I guess my question is 2 parts: 1.)Am I going with the right approach for Wordpress development on my local machine and 2.)If so, why is the tunnel not working?

    Read the article

  • I am having trouble with my first project in ruby on rails

    - by Sebastian
    Here's my index action in the books controller: http://pastebin.com/XdtGRQKV Here's the view for the action i just mentioned: http://pastebin.com/nQFy400m Here's the result without being logged in: http://i.imgur.com/rQoiw.jpg Here's the result when i'm logged in with the user 'admin': http://i.imgur.com/E1CUr.jpg So the problem is that, in the view, before line 25 the 'user' variable seems to be empty ( or not loaded), and after line 25 the variable 'user' has the expected values. I have tried initializing a variable in the index method of the books controller but get exactly the same results. Thanks in advance! BTW had to make the links text because of stackoverflow limit.

    Read the article

  • trouble setting up TreeViews in pygtk

    - by Chris H
    I've got some code in a class that extends gtk.TreeView, and this is the init method. I want to create a tree view that has 3 columns. A toggle button, a label, and a drop down box that the user can type stuff into. The code below works, except that the toggle button doesn't react to mouse clicks and the label and the ComboEntry aren't drawn. (So I guess you can say it doesn't work). I can add rows just fine however. #make storage enable/disable label user entry self.tv_store = gtk.TreeStore(gtk.ToggleButton, str, gtk.ComboBoxEntry) #make widget gtk.TreeView.__init__(self, self.tv_store) #make renderers self.buttonRenderer = gtk.CellRendererToggle() self.labelRenderer = gtk.CellRendererText() self.entryRenderer = gtk.CellRendererCombo() #make columns self.columnButton = gtk.TreeViewColumn('Enabled') self.columnButton.pack_start(self.buttonRenderer, False) self.columnLabel = gtk.TreeViewColumn('Label') self.columnLabel.pack_start(self.labelRenderer, False) self.columnEntry = gtk.TreeViewColumn('Data') self.columnEntry.pack_start(self.entryRenderer, True) self.append_column(self.columnButton) self.append_column(self.columnLabel) self.append_column(self.columnEntry) self.tmpButton = gtk.ToggleButton('example') self.tmpCombo = gtk.ComboBoxEntry(None) self.tv_store.insert(None, 0, [self.tmpButton, 'example label', self.tmpCombo]) thanks.

    Read the article

  • Neo4j+Gremlin : Trouble with T.gte and floating point node attributes

    - by letronje
    For a type of nodes in my graph, attribute values for an attribute(named 'some_count') is either missing or an integer or a float. I'm trying to write gremlin to filter these nodes based on minimum value for this attribute. I first verified that the values are indeed present by firing the following gremlin g.v(XXX)._().in('category').hasNot('some_count', T.eq, null).back(1).some_count Next, I tried filtering by exact value and that works and show me the matching nodes or gives an empty array if there is no match g.v(XXX)._().in('category').hasNot('some_count', T.eq, null).back(1).has('some_count', T.eq, 120000.0d) But the following query that uses the 'greater than or equal to' comparator doesn't work. g.v(XXX)._().in('category').hasNot('some_count', T.eq, null).back(1).has('some_count', T.gte, 1.0d) this returns nil (I'm querying via ruby/rails using Neo4j AR Adapter ) Instead of returning an empty array for no match, it returns a nil, which tells me something could be wrong with the query itself. I'm running neo4j community server 1.8. Is there a way I can ask Neo4j to log errors/queries, to see what could be going wrong ?

    Read the article

  • Trouble Upgrading Rails 2 Routes for a Redmine Plugin

    - by user1858628
    I am trying to get a Redmine plugin designed for Rails 2 to work with Rails 3. https://github.com/dalyons/redmine-todos-scrum-plugin I've pretty much fixed most parts, but having no success whatsoever in getting the routes to work. The original routes for Rails 2 are as follows: map.resources :todos, :name_prefix => 'project_', :path_prefix => '/projects/:project_id', :member => {:toggle_complete => :post }, :collection => {:sort => :post} map.resources :todos, :name_prefix => 'user_', :path_prefix => '/users/:user_id', :controller => :mytodos, :member => {:toggle_complete => :post }, :collection => {:sort => :post} map.my_todos 'my/todos', :controller => :mytodos, :action => :index map.connect 'projects/:project_id/todos/show/:id', :controller => "todos", :action => "show" rake routes outputs the following: sort_project_todos POST /projects/:project_id/todos/sort(.:format) {:controller=>"todos", :action=>"sort"} project_todos GET /projects/:project_id/todos(.:format) {:controller=>"todos", :action=>"index"} POST /projects/:project_id/todos(.:format) {:controller=>"todos", :action=>"create"} new_project_todo GET /projects/:project_id/todos/new(.:format) {:controller=>"todos", :action=>"new"} toggle_complete_project_todo POST /projects/:project_id/todos/:id/toggle_complete(.:format) {:controller=>"todos", :action=>"toggle_complete"} edit_project_todo GET /projects/:project_id/todos/:id/edit(.:format) {:controller=>"todos", :action=>"edit"} project_todo GET /projects/:project_id/todos/:id(.:format) {:controller=>"todos", :action=>"show"} PUT /projects/:project_id/todos/:id(.:format) {:controller=>"todos", :action=>"update"} DELETE /projects/:project_id/todos/:id(.:format) {:controller=>"todos", :action=>"destroy"} sort_user_todos POST /users/:user_id/todos/sort(.:format) {:controller=>"mytodos", :action=>"sort"} user_todos GET /users/:user_id/todos(.:format) {:controller=>"mytodos", :action=>"index"} POST /users/:user_id/todos(.:format) {:controller=>"mytodos", :action=>"create"} new_user_todo GET /users/:user_id/todos/new(.:format) {:controller=>"mytodos", :action=>"new"} toggle_complete_user_todo POST /users/:user_id/todos/:id/toggle_complete(.:format) {:controller=>"mytodos", :action=>"toggle_complete"} edit_user_todo GET /users/:user_id/todos/:id/edit(.:format) {:controller=>"mytodos", :action=>"edit"} user_todo GET /users/:user_id/todos/:id(.:format) {:controller=>"mytodos", :action=>"show"} PUT /users/:user_id/todos/:id(.:format) {:controller=>"mytodos", :action=>"update"} DELETE /users/:user_id/todos/:id(.:format) {:controller=>"mytodos", :action=>"destroy"} my_todos /my/todos {:controller=>"mytodos", :action=>"index"} /projects/:project_id/todos/show/:id {:controller=>"todos", :action=>"show"} The nearest I have got for Rails 3 is follows: scope '/projects/:project_id', :name_prefix => 'project_' do resources :todos, :controller => 'todos' do member do post :toggle_complete end collection do post :sort end end end scope '/users/:user_id', :name_prefix => 'user_' do resources :todos, :controller => 'mytodos' do member do post :toggle_complete end collection do post :sort end end end match 'my/todos' => 'mytodos#index', :as => :my_todos match 'projects/:project_id/todos/show/:id' => 'todos#show' rake routes outputs the following: toggle_complete_todo POST /projects/:project_id/todos/:id/toggle_complete(.:format) todos#toggle_complete {:name_prefix=>"project_"} sort_todos POST /projects/:project_id/todos/sort(.:format) todos#sort {:name_prefix=>"project_"} todos GET /projects/:project_id/todos(.:format) todos#index {:name_prefix=>"project_"} POST /projects/:project_id/todos(.:format) todos#create {:name_prefix=>"project_"} new_todo GET /projects/:project_id/todos/new(.:format) todos#new {:name_prefix=>"project_"} edit_todo GET /projects/:project_id/todos/:id/edit(.:format) todos#edit {:name_prefix=>"project_"} todo GET /projects/:project_id/todos/:id(.:format) todos#show {:name_prefix=>"project_"} PUT /projects/:project_id/todos/:id(.:format) todos#update {:name_prefix=>"project_"} DELETE /projects/:project_id/todos/:id(.:format) todos#destroy {:name_prefix=>"project_"} POST /users/:user_id/todos/:id/toggle_complete(.:format) mytodos#toggle_complete {:name_prefix=>"user_"} POST /users/:user_id/todos/sort(.:format) mytodos#sort {:name_prefix=>"user_"} GET /users/:user_id/todos(.:format) mytodos#index {:name_prefix=>"user_"} POST /users/:user_id/todos(.:format) mytodos#create {:name_prefix=>"user_"} GET /users/:user_id/todos/new(.:format) mytodos#new {:name_prefix=>"user_"} GET /users/:user_id/todos/:id/edit(.:format) mytodos#edit {:name_prefix=>"user_"} GET /users/:user_id/todos/:id(.:format) mytodos#show {:name_prefix=>"user_"} PUT /users/:user_id/todos/:id(.:format) mytodos#update {:name_prefix=>"user_"} DELETE /users/:user_id/todos/:id(.:format) mytodos#destroy {:name_prefix=>"user_"} my_todos /my/todos(.:format) mytodos#index /projects/:project_id/todos/show/:id(.:format) todos#show I am guessing that I am not using :name_prefix correctly, resulting in duplicate paths which are then omitted. Any help would be greatly appreciated.

    Read the article

  • Trouble swapping values as keys in generic java BST class

    - by user1729869
    I was given a generic binary search tree class with the following declaration: public class BST<K extends Comparable<K>, V> I was asked to write a method that reverses the BST such that the values become the keys and keys become values. When I call the following method (defined in the class given) reverseDict.put(originalDict.get(key), key); I get the following two error messages from Netbeans: Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: BST.put And also: no suitable method found for put(V,K) method BST.put(BST<K,V>.Node,K,V) is not applicable (actual and formal argument lists differ in length) method BST.put(K,V) is not applicable (actual argument V cannot be converted to K by method invocation conversion) where V,K are type-variables: V extends Object declared in method <K,V>reverseBST(BST<K,V>) K extends Comparable<K> declared in method <K,V>reverseBST(BST<K,V>) From what the error messages are telling me, since my values do not extend Comparable I am unable to use them as keys. If I am right, how can I get around that without changing the class given (maybe a cast)?

    Read the article

  • Trouble accessing fields of a serialized object in Java

    - by typoknig
    I have instantized a class that implements Serializable and I am trying to stream that object like this: try{ Socket socket = new Socket("localhost", 8000); ObjectOutputStream toServer = new ObjectOutputStream(socket.getOutputStream()); toServer.writeObject(myObject); } catch (IOException ex) { System.err.println(ex); } All good so far right? Then I am trying to read the fields of that object like this: //This is an inner class class HandleClient implements Runnable{ private ObjectInputStream fromClient; private Socket socket; // This socket was established earlier try { fromClient = new ObjectInputStream(socket.getInputStream()); GetField inputObjectFields = fromClient.readFields(); double myFristVariable = inputObjectFields.get("myFirstVariable", 0); int mySecondVariable = inputObjectFields.get("mySecondVariable", 0); //do stuff } catch (IOException ex) { System.err.println(ex); } catch (ClassNotFoundException ex) { System.err.println(ex); } finally { try { fromClient.close(); } catch (Exception ex) { ex.printStackTrace(); } } } But I always get the error: java.io.NotActiveException: not in call to readObject This is my first time streaming objects instead of primitive data types, what am I doing wrong? BONUS When I do get this working correctly, is the ENTIRE CLASS passed with the serialized object (i.e. will I have access to the methods of the object's class)? My reading suggests that the entire class is passed with the object, but I have been unable to use the objects methods thus far. How exactly do I call on the object's methods? In addition to my code above I also experimented with the readObject method, but I was probably using it wrong too because I couldn't get it to work. Please enlighten me.

    Read the article

  • tomcat startup.sh trouble finding JAVA_HOME

    - by peter
    I am a bit puzzled by this strange behavior on CentOs 5.4 when starting Tomcat 6.0 as a service I've added a script at /etc/init.d/tomcat that can start/stop/restart Apache Tomcat 6.0 with user 'tomcat', and registered it as service. The problem with the service is that I am getting a 'Neither the JAVA_HOME nor the JRE_HOME environment variable is defined'. But when type 'sudo -u tomcat echo $JAVA_HOME' I get '/usr/java/jdk1.5.0_22' which is correct since I am using that JDK. What can I do about this?

    Read the article

  • Trouble editing Word document with PHP

    - by bhoomi-nature
    I want to open a word document and edit it I am opening the word document from the server and at that time it's opening with garbage values (perhaps it's not being properly converted to UTF-8). When I delete those garbage values and insert something from a textarea to that file it is going to insert and from then on it opens properly. I would like the document to open with the English words in the document instead of garbage value - it's only the first opening that's broken at present. <? $filename = 'test.doc'; if(isset($_REQUEST['Submit'])){ $somecontent = stripslashes($_POST['somecontent']); // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'w')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened fi<form action="" method="get"></form>le. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename) <a href=".$_SERVER['PHP_SELF']."> - Continue - "; fclose($handle); } else { echo "The file $filename is not writable"; } } else { // get contents of a file into a string $handle = fopen($filename, 'r'); $somecontent = fread($handle, filesize($filename)); ?> <h1>Edit file <? echo $filename ;?></h1> <form name="form1" method="post" action=""> <p> <textarea name="somecontent" cols="80" rows="10"><? echo $somecontent ;?></textarea> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> <? fclose($handle); } ?>

    Read the article

  • C++ Beginner - Trouble using structs and constants!

    - by Francisco P.
    Hello everyone! I am currently working on a simple Scrabble implementation for a college project. I can't get a part of it to work, though! Check this out: My board.h: http://pastebin.com/J9t8VvvB The subroutine where the error lies: //Following snippet contained in board.cpp //I believe the function is self-explanatory... //Pos is a struct containing a char, y, a int, x and an orientation, o, which is not //used in this particular case void Board::showBoard() { Pos temp; temp.o = 0; for (temp.y = 'A'; temp.y < (65 + TOTAL_COLUMNS); ++temp.y) { for (temp.x = 1; temp-x < (1 + TOTAL_ROWS); ++temp.x) { cout << _matrix[temp].getContents(); } cout << endl; } } The errors returned on compile time: http://pastebin.com/bZv7fggq How come the error states that I am trying to compare two Pos when I am comparing chars and ints? I also really can't place these other errors... Thanks for your time!

    Read the article

  • If statement String trouble

    - by Jeremy Stone
    I'm trying to create a program which takes user input of two words and determines whether or not these words are the same. import java.util.Scanner; public class L7E3 { public static void main(String[] args) { Scanner keyboard = new Scanner(System. in ); String word1, word2; System.out.println("Please enter a word: "); word1 = keyboard.nextLine(); System.out.println("Please enter a word: "); word2 = keyboard.nextLine(); if (word1 == word2) { System.out.println("The words are " + word1 + " and " + word2 + ". These words are the same."); } else { System.out.println("The words are " + word1 + " and " + word2 + ". These words are not the same."); } } } I figured that word1==word2 would have worked to determine whether the two strings were equal, I'm using JGrasp and it goes directly to my else option regardless of input. Am I doing something wrong with strings?

    Read the article

  • trouble with custom 'Text Bubble' component (examples included)

    - by gmoniey
    I'm trying to use a custom Text component to show a series of comments. I got the original idea from: http://www.eonflex.com/?p=40 I've got the base case working but I am stuck with 2 problems I cant seem to figure out: Since I am drawing around the text, the actual height of each bubble is greater than that of the Text field, as a result, the last bubble is always chopped off. I have tried explicitly overriding the height getter, and adding some padding, but I cant seem to get it right. You can see an example here: http://test.lambandtunafish.com/bubbles/CommentTest.swf In my layout, I have 2 VBoxes (one nested inside the other). The first vbox shows a form where the user can enter a comment, and the second box has all the comments. In order to ensure that the scrollbars only show up on the second box, I set minHeight="0" on the nested VBox, but then for some reason, some comments' text is shifted to the right. You can see an example here (look at the first comment): http://test.lambandtunafish.com/bubbles/CommentTest-minHeight.swf Rather than posting the code here, I've provided some links: Container: http://test.lambandtunafish.com/bubbles/CommentTest.mxml Bubble: http://test.lambandtunafish.com/bubbles/CommentBubble.as If anyone has any ideas, I would appreciate it. Thanks!

    Read the article

  • SQL Complex Select - Trouble forming query

    - by JoshSpacher
    I have three tables, Customers, Sales and Products. Sales links a CustomerID with a ProductID and has a SalesPrice. select Products.Category, AVG(SalePrice) from Sales inner join Products on Products.ProductID = Sales.ProductID group by Products.Category This lets me see the average price for all sales by category. However, I only want to include customers that have more than 3 sales records or more in the DB. I am not sure the best way, or any way, to go about this. Ideas?

    Read the article

  • Trouble Passing Parameter to LinqToSql Stored Procedure

    - by Webjedi
    public IEnumerable<T> ExecuteStoredProcedure<T>(params object[] parameters) { Type genericType = typeof(T); string commandthing = genericType.Name.Replace("Result", ""); //_db is my Linq To Sql database return _db.ExecuteQuery<T>(commandthing, parameters).AsEnumerable(); } The stored procedure is named GetOrder and has a single int parameter of orderid. I'm calling the above like so: SqlParameter parm1 = new SqlParameter("@orderid", SqlDbType.Int); parm1.Value = 123; var results = _session.ExecuteStoredProcedure<GetOrderResult>(parm1).Single(); I'm receiving the following error: A query parameter cannot be of type 'System.Data.SqlClient.SqlParameter' Thoughts? Or am I just missing something obvious?

    Read the article

  • C++ abstract class template + type-specific subclass = trouble with linker

    - by user333279
    Hi there, The project in question is about different endpoints communicating with each other. An endpoint sends events (beyond the scope of the current problem) and can process incoming events. Each event is represented in a generic object as follows: #pragma interface ... // some includes template<typename T> class Event { public: Event(int senderId, Type type, T payload); // Type is an enum Event(int senderId, Type type, int priority, T payload); virtual ~Event(); virtual int getSenderId(); virtual int getPriority(); virtual T getPayload(); void setPriority(const int priority); protected: const int senderId; const Type type; const T payload; int priority; }; It has its implementing class with #pragma implementation tag. An endpoint is defined as follows: #pragma interface #include "Event.h" template<typename T> class AbstractEndPoint { public: AbstractEndPoint(int id); virtual ~AbstractEndPoint(); virtual int getId(); virtual void processEvent(Event<T> event) = 0; protected: const int id; }; It has its implementing class too, but only the constructor, destructor and getId() are defined. The idea is to create concrete endpoints for each different payload type. Therefore I have different payload objects and specific event classes for each type, e.g. Event<TelegramFormatA>, Event<TelegramFormatB> and ConcreteEndPoint for TelegramFormatA, ConcreteEndPoint for TelegramFormatB respectively. The latter classes are defined as class ConcreteEndPoint : AbstractEndPoint<TelegramFormatA> { ... } I'm using g++ 4.4.3 and ld 2.19. Everything compiles nicely, but the linker complaints about undefined references to type-specific event classes, like Event<TelegramFormatA>::Event(....) . I tried explicit instantiation using template class AbstractEndPoint<TelegramFormatA>; but couldn't get past the aforementioned linker errors. Any ideas would be appreciated.

    Read the article

  • Trouble with go tour crawler exercise

    - by David Mason
    I'm going through the go tour and I feel like I have a pretty good understanding of the language except for concurrency. On slide 71 there is an exercise that asks the reader to parallelize a web crawler (and to make it not cover repeats but I haven't gotten there yet.) Here is what I have so far: func Crawl(url string, depth int, fetcher Fetcher, ch chan string) { if depth <= 0 { return } body, urls, err := fetcher.Fetch(url) if err != nil { ch <- fmt.Sprintln(err) return } ch <- fmt.Sprintf("found: %s %q\n", url, body) for _, u := range urls { go Crawl(u, depth-1, fetcher, ch) } } func main() { ch := make(chan string, 100) go Crawl("http://golang.org/", 4, fetcher, ch) for i := range ch { fmt.Println(i) } } The issue I have is where to put the close(ch) call. If I put a defer close(ch) somewhere in the Crawl method, then I end up writing to a closed channel in one of the spawned goroutines, since the method will finish execution before the spawned goroutines do. If I omit the call to close(ch), as is shown in my example code, the program deadlocks after all the goroutines finish executing but the main thread is still waiting on the channel in the for loop since the channel was never closed.

    Read the article

  • Rails RESTful routs without #new, rspec trouble

    - by pdkl95
    I'm currently writing a Rails app, and hit a somewhat strange quirk. I have a controller PermissionsController, which is mainly for display purposes at the moment. So my routing is locked down: map.resources :permissions, :only => [:index, :show] Unfortunately, when writing the tests, one of the routing tests fails: it "does not recognize #new" do { :get => "/permissions/new" }.should_not be_routable end with the error: Expected 'GET /permissions/new' to fail, but it routed to {"action"=>"show", "id"=>"new", "controller"=>"permissions"} instead Obviously, the #show action's route is matching with /permissions/:id, which also gives the expected error Couldn't find Permission with ID=new if you actually browse to that URL. This is not a serious error, as it is correctly raising an exception with the bad :id parameter, but it's kind of ugly. Is there any way to actually make Rails reject that route? Some trick in the routing options that I'm missing? I suppose I should just leave that test out and ignore it, or maybe remove the whole RESTful idea altogether and go back to a simpler map.connect 'permissions/:id' style. I strongly suspect I'll be expanding this in the future, though, and kind of wanted to keep my controllers consistent with each other. Just having to add occasional :only or :except rules made routes.rb nice and clean...

    Read the article

  • Trouble with arrays

    - by Ockonal
    Hi guys, I have such string in PHP: $data = '1;3;5;7;9'; And cycle: for ($i=0; $i < count($someArray); $i++) { // If $i == any number in $data } What is the faster way to compare $i from cycle with numbers in string. I have to check that cycle-counter is in string.

    Read the article

  • SQL server connection trouble in network but not in local

    - by user1517139
    for the first time that I would work with SQL SERVER 2005, the jdbc connection doesn't work in the network I searched and have done thousand of things that doesn't work, i also want to precise that i already had worked with other DBMS, so here is the problem: when i try to connect by jdbc from the machine where sql server is installed everything work just fine, but when i try from a different machine, the jdbc is unable to create the connection, i already checked that TCP/IP communication is enabled that the port (not dynamically assigned) is 1433 and i even tried with different ports, i also tried with the same driver and different driver, i checked that i was able to communicate with the http server (who is installed in the machine where SQL server is installed) and it works but that jdbc connection can't, i tried thousand of things until i forgot some of them, someone please help

    Read the article

  • Trouble with QxtGlobalShortcut [solved]

    - by Ockonal
    Hello, i'm trying to set global shortcut for my applcation using QxtGlobalShortcut. Here is my code: QxtGlobalShortcut m_hotkeyHandle; m_hotkeyHandle.setShortcut( QKeySequence("Ctrl+Shift+X") ); m_hotkeyHandle.setEnabled(true); connect( &m_hotkeyHandle, SIGNAL(activated()), this, SLOT(hotkeyPressed()) ); void MainWindow::hotkeyPressed() { QMessageBox::information(this, "Good", "Hot key triggered", "yes", "no"); } But after applcation started i got: QxtGlobalShortcut failed to register: "Ctrl+Shift+X" And my programm doesn't activate after hot key pressing. What should i do? EDIT: There was a bug in Qxt-lib 0.5 with shortcut. I spoke with developer and knew that i just need to update library from dev-branch (0.5.1 is worked).

    Read the article

  • [C++] Trouble declaring and recognizing global functions

    - by Sarah
    I've created some mathematical functions that will be used in main() and by member functions in multiple host classes. I was thinking it would be easiest to make these math functions global in scope, but I'm not sure how to do this. I've currently put all the functions in a file called Rdraws.cpp, with the prototypes in Rdraws.h. Even with all the #includes and externs, I'm getting a "symbol not found" error at the first function call in main(). Here's what I have: // Rdraws.cpp #include <cstdlib> using namespace std; #include <cmath> #include "Rdraws.h" #include "rng.h" extern RNG rgen // this is the PRNG used in the simulation; global scope void rmultinom( double p_trans[], int numTrials, int numTrans, int numEachTrans[] ) { // function 1 def } void rmultinom( const double p_trans[], const int numTrials, int numTrans, int numEachTrans[]) { // function 2 def } int rbinom( int nTrials, double pLeaving ) { // function 3 def } // Rdraws.h #ifndef RDRAWS #define RDRAWS void rmultinom( double[], int, int, int[] ); void rmultinom( const double[], const int, int, int[] ); int rbinom( int, double ); #endif // main.cpp ... #include "Rdraws.h" ... extern void rmultinom(double p_trans[], int numTrials, int numTrans, int numEachTrans[]); extern void rmultinom(const double p_trans[], const int numTrials, int numTrans, int numEachTrans[]); extern int rbinom( int n, double p ); ... int main() { ... } I'm pretty new to programming. If there's a dramatically smarter way to do this, I'd love to know.

    Read the article

  • C++: Trouble with tr1::bind (C2065)

    - by Rosarch
    I'm getting a compiler error with bind: using namespace std; bool odp(int arg1, int arg2); // ... find_if(vec.begin(), vec.end(), tr1::bind(odp, iValue, _1)); // C2065 My goal is to curry odp(), so its first argument is iValue, and apply that function in find_if. The error: C2065: '_1' : undeclared identifier. What am I doing wrong?

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >