Daily Archives

Articles indexed Monday March 8 2010

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

  • Core Data Relationship List

    - by Dylan Copeland
    I'm not sure whether or not this is the appropriate way of doing this, but I was wondering what's the best way to approach a relationship to a value in a list with Core Data? For example, say you have a 'person' entity. Each person can have a different 'hair color'. I'm trying to basically define the hair colors in my data model and allow the 'person' entity to have a relationship to their given 'hair color. Is this possible? Good idea or bad? Thanks in advance.

    Read the article

  • Ruby Net::HTTP - Read only x number of bytes of the body

    - by bvanderw
    It seems like the methods of Ruby's Net::HTTP are all or nothing when it comes to reading the body of a web page. How can I read, say, the just the first 100 bytes of the body? I am trying to read from a content server that returns a short error message in the body of the response if the file requested isn't available. I need to read enough of the body to determine whether the file is there. The files are huge, so I don't want to get the whole body just to check if the file is available.

    Read the article

  • TDD test data loading methods

    - by Dave Hanson
    I am a TDD newb and I would like to figure out how to test the following code. I am trying to write my tests first, but I am having trouble for creating a test that touches my DataAccessor. I can't figure out how to fake it. I've done the extend the shipment class and override the Load() method; to continue testing the object. I feel as though I end up unit testing my Mock objects/stubs and not my real objects. I thought in TDD the unit tests were supposed to hit ALL of the methods on the object; however I can never seem to test that Load() code only the overriden Mock Load My tests were write an object that contains a list of orders based off of shipment number. I have an object that loads itself from the database. public class Shipment { //member variables protected List<string> _listOfOrders = new List<string>(); protected string _id = "" //public properties public List<string> ListOrders { get{ return _listOfOrders; } } public Shipment(string id) { _id = id; Load(); } //PROBLEM METHOD // whenever I write code that needs this Shipment object, this method tries // to hit the DB and fubars my tests // the only way to get around is to have all my tests run on a fake Shipment object. protected void Load() { _listOfOrders = DataAccessor.GetOrders(_id); } } I create my fake shipment class to test the rest of the classes methods .I can't ever test the Real load method without having an actual DB connection public class FakeShipment : Shipment { protected new void Load() { _listOfOrders = new List<string>(); } } Any thoughts? Please advise. Dave

    Read the article

  • Wordpress Template get_the_tags() help

    - by Andy
    Hi Guys, I am using this code to get the tags in my wordpress posts for a theme `<?php $posttags = get_the_tags(); if ($posttags) { foreach ($posttags as $tag) { $tagnames[count($tagnames)] = $tag->name; } $comma_separated_tagnames = implode(", ", $tagnames); print_r($comma_separated_tagnames); } ?>` The PROBLEM is that it is returning tags for "all posts" not just individual posts, and I think the problem is that if a post DOESNT have tags - it just inserts tags anyway. Can anyone help modify this so: It return tags only for a post - not all tags If there are no tags for a post, dont return anything ? Really appreciate any help P.S - Can check out here for the wordpress docs

    Read the article

  • script unable to find directories/files when running from qsub cluster script

    - by user248237
    I'm calling several unix commands and python on a python script from a qsub shell script, meant to run on a cluster. The trouble is that when the script executes, something seems to go awry in the shell, so that directories and files that exist are not found. For example, in the .out output files of qsub I see the following errors: cd: /valid/dir/name: No such file or directory python valid/script/name.py python: can't open file 'valid/script/name.py': [Errno 2] No such file or directory so the script cannot cd into a dir that definitely exist. Similarly, calling python on a python script that definitely exists yields an error. any idea what might be going wrong here, or how I could try to debug this? thanks very much.

    Read the article

  • Avoid trailing zeroes in printf()

    - by Gorpik
    I keep stumbling on the format specifiers for the printf() family of functions. What I want is to be able to print a double (or float) with a maximum given number of digits after the decimal point. If I use: printf("%1.3f", 359.01335); printf("%1.3f", 359.00999); I get 359.013 359.010 Instead of the desired 359.013 359.01 Can anybody help me?

    Read the article

  • How to not allow parts of sortable jquery list to move?

    - by sanpell
    I made a sortable list: <ul> <li class="line"><a href="#" class="food">milk</a></li> <li class="line"><a href="#" class="food">eggs</a></li> <li class="line"><a href="#" class="food">cheese</a></li> </ul> However, I want to make everything with class food not draggable. Since they are links, sometimes when people click them, they accidently reorder the list. Does anyone know how to make just the "food" class items not "draggable"?

    Read the article

  • Best architecture for a social media app

    - by Sky
    Hey guys, Im working on promising project that develops a new social media app for web and mobile. We are at begin defining functionalities. Nevertheless, I'm thinking ahead on architecture. So I'm asking: 1 - Whats the best plataform to develop the core of this aplication that will have a Rest API interface. 2 - Whats the best database that will scale and grow with my application. As far as I researched, these were the answers I found most interesting: For database: Cassandra NoSQL DB, amazing scalabilty, amazing write performance, good read performance (will be improved on 0.6). I think i will choose that one. Zookeer for transactions on Cassandra. I think that 2 technologies rly good for that propose. What do you think guys? On the front end that will serve the REST API, i dont have a final candidate. For this one i have questions based on Perfomance X Scalabilty X Fast Development/Maintenance. Java or .Net As far as I researched, brings the best balance of this requisits. Python, pearl and Rail, has the best (Fast Development/Maintenance), but sux on all other. C or C++ I dont even consider, because its (Fast Development/Maintenance) sux... So what do you guy think about it?

    Read the article

  • Where do you go to tickle your brain (to get programming challenges)?

    - by Prakash
    I am sure we all have some place to go to get our brain teased! Sometimes i visit Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems Where do you all go?

    Read the article

  • java or php tip for small problem

    - by agazerboy
    Hi All, I am having a weird mind gogling problem. Sorry in advance, If I confuse you. I have following data 1 3 5 5 1 2 2 4 8 3 2 9 3 8 4 first column = source 1 second column = source 2 third column = result column First and second column will can create 3rd column and that 3rd column can be used in 1st or 2nd column to make a new 3rd column value. You can see in first row 5 was 3rd column and in 2nd row it was input to make 2 (3rd column) I am looking for a solutin that if it pass 3 it return me (1,4,5) rows and same for other digits. Solution tip can be either in java or php because I just want to get data from a old project to make it work ! Thanks !

    Read the article

  • Saving a "project"-type document (containing sub-documents)

    - by andyvn22
    I'm trying to create a "project"-like document, in that it contains subdocuments in a specified directory. I'd like a brand new save of a document to set up that directory with appropriate subdirectories. I'd like a "Save As" to copy all those subdirectories and any files within them to the new location. But I'd like a "Save" to only update certain data files and (of course) not overwrite all the subdocuments! What's the "safe" way to do this? I tried keeping track of the file's location in my document, and checking to see if it was the same or different than the save location, but it feels messy, and I'm worried that Apple is doing something behind the scenes that will make this direct URL-to-URL comparison fail in some circumstances. Is there a standard way to do something like this?

    Read the article

  • Uploading file is not working

    - by VinTem
    I have done the following form <% form_for @anexo, :url => {:action => "create"}, :html => {:multpart => true} do |f| %> <%= f.error_messages %> <p> <%= f.label :descricao, "Descrição"%> <%= f.text_field :descricao %> </p> <p> <%= f.label :arquivo_anexo, "Arquivo Anexo" %> <%= f.file_field :arquivo_anexo %> </p> <p> <%= f.submit "Adicionar anexo" %> </p> <% end %> With a model like this: def arquivo_anexo=(novo_arqquivo) self.arquivo = novo_arquivo.read self.nome = File.basename(novo_arquivo.original_filename) self.content_type = novo_arquivo.content_type.chomp end But when I my file is not been sent through the form. When I check the params array using the debugger the data is not sent. Does anyone have any idea or sugestions? Thanks

    Read the article

  • OS X terminal command to resolve path of an alias

    - by Josh
    I'm writing a shell script which will rsync files from remote machines, some linux, some macs, to a central backup server. The macs have folders on the root level containing aliases of all files/folders which need to be backed up. What is a terminal command I can use to resolve the path to the files/folders the aliases point to? (I'll need to pass these paths to rsync)

    Read the article

  • Where do Java Applets live?

    - by Wendi Peters
    I'm trying to figure out where java Applets that I run from the browser live. I'm using Firefox 3.0 on Windows XP with Java 1.6 if that makes any difference. From the Java Control Panel on the toolbar, I can access "Temporary Internet Files - Settings" to find the Java cache. From there I can show the resources and see a file called "dws2010066.dat". Does this resource correspond to a file on disk? I did a search in the Java cache/my whole computer and came up empty handed.

    Read the article

  • Linq2XML: Get the count of elements where candidate has won2

    - by user287798
    I had an XML Document in the format below <Pronvice_Data> <Pronvice>PronviceA</Pronvice> <Registered_Voters>115852</Registered_Voters> <Sam_Kea>100</Sam_Kea> <Jeje>500</Jeje> <John_Doe>400</John_Doe> </Pronvice_Data> <Pronvice_Data> <Pronvice>PronviceA</Pronvice> <Registered_Voters>25852</Registered_Voters> <Sam_Kea>200</Sam_Kea> <Jeje>100</Jeje> <John_Doe>300</John_Doe> </Pronvice_Data> <Pronvice_Data> <Pronvice>PronviceC</Pronvice> <Registered_Voters>317684</Registered_Voters> <Sam_Kea>1000</Sam_Kea> <Jeje>1200</Jeje> <John_Doe>190</John_Doe> </Pronvice_Data> As suggested by help here,I used the code below to give me this format below C# Code: void Main() { XDocument xmlVectors2 = XDocument.Load(@"C:\\Province_Data.xml"); var elemList= from elem in xmlVectors2.Descendants("Province_Data") where elem.Elements().Count() > 1 select elem; foreach(XElement element in elemList) { XElement elem1= new XElement("Candidates", new XElement(element.Element("Sam_Kea").Name), new XElement(element.Element("Jeje").Name), new XElement(element.Element("John_Doe").Name) ); XElement elem2 = new XElement("Provinces", new XAttribute("Province", (string)element.Element("Province").Value), new XAttribute("Registered_Voters",element.Element("Registered_Voters").Value), new XElement ("Candidate", new XAttribute("Name",element.Element("Sam_Kea").Name), new XAttribute("Votes",element.Element("Sam_Kea").Value) ), new XElement ("Candidate", new XAttribute("Name",element.Element("Jeje").Name), new XAttribute("Votes",element.Element("Jeje").Value) ), new XElement ("Candidate", new XAttribute("Name",element.Element("John_Doe").Name), new XAttribute("Votes",element.Element("John_Doe").Value) )); } } New Format: <root> <Candidates> <Sam_Kea/> <Jeje/> <John_Doe/> </Candidates> <Provinces> <Province name='ProvinceA' Registered_Voters='115852'> <Candidate name='Sam_Kea' votes='100'/> <Candidate name='Jeje' votes='500'/> <Candidate name='John_Doe' votes='400'/> </Province> <Province name='ProvinceB' Registered_Voters='25852'> <Candidate name='Sam_Kea' votes='200'/> <Candidate name='Jeje' votes='100'/> <Candidate name='John_Doe' votes='300'/> </Province> <Province name='ProvinceC' Registered_Voters='317684'> <Candidate name='Sam_Kea' votes='1000'/> <Candidate name='Jeje' votes='1200'/> <Candidate name='John_Doe' votes='190'/> </Province> </Provinces> </root> How can i use the "foreach" in in my code to get the result in this link. http://stackoverflow.com/questions/2396203/get-the-count-of-elements-where-candidate-has-won

    Read the article

  • What is the basic pattern for using (N)Hibernate?

    - by Vilx-
    I'm creating a simple Windows Forms application with NHibernate and I'm a bit confused about how I'm supposed to use it. To quote the manual: ISession (NHibernate.ISession) A single-threaded, short-lived object representing a conversation between the application and the persistent store. Wraps an ADO.NET connection. Factory for ITransaction. Holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier. Now, suppose I have the following scenario: I have a simple classifier which is a MSSQL table with two columns - ID (auto_increment) and Name (nvarchar). To edit this classifier I create a form which contains a single gridview and two buttons - OK and Cancel. The user can nearly directly edit the table in the gridview, and when he hits OK the changes he made are persisted to the DB (or if he hits cancel, nothing happens). Now, I have several questions about how to organize this: What should the lifetime of my ISession be? Should I create a single ISession for my whole application; an ISession for each of my forms (the application is single-threaded MDI); or an ISession for every DB operation/transaction? Does NHibernate offer some kind of built-in dirty tracking or must I do this myself? The manual mentions something like it here and there but does not go into details. How is this done? Is there not a huge overhead? Is it somehow tied with the cache(s) that NHibernate has? What are these caches for? Are they not specific to a single ISession? That is, if I use a seperate ISession for every transaction, won't it break the dirty tracking? How does the built-in dirty tracking detect deleted objects?

    Read the article

  • Call method with parameters after animation completion

    - by Jean
    I want to call a method with certain parameters once an animation is done. The flow is something like this: -(void) myMethod:(int)val { [self performAnimation]; [self doSomethingElse:val]; // This should be done after animation completion } I presume the 'doSomethingElse' method needs to be called from the method defined in 'setAnimationDidStopSelector' - or is there a way to have the animation block until done? What is the best way to let the method called on 'setAnimationDidStopSelector' know about the method it needs to call and its parameter? Can this be done with selectors? Or is the only way of doing this by storing the methods and its params in class temp variables and access them when needed?

    Read the article

  • PHP: saving multiple tuples to the same table

    - by Binaryrespawn
    Hi all, I am trying to save data into the same table several times from the same $_POST array. You see, on my registration form a family is allowed to specify the names, gender and age of all members they wish to bring along. This data is being stored in a database table called aditional_member. Based on family size, I am dynamically generating html table rows where each row has the number of input fields required. <tr id="additionalmember_3"> <td><input type="text" name="first_name1" maxlength="50" value="" /></td> <td><input type="text" name="last_name1" maxlength="50" value="" /></td> td><select name="gender1" value="" ><option value='Male'>Male</option><option value='Female'>Female</option></select></td> <td><select name="age_group"value="" ><option value='18 to 30'>18 to 30</option><option value='31 to 60'>31 to 60</option></select></td> </tr> When I POST, let us say I have three sets of input(3 table rows as above), Is there a simple way to insert into the addional_member table the data from row one, then row two, and so on. I tried looping the insert statement, which failed. I am basically open to suggestions, I do not need to use a table. Any ideas, Thank you.

    Read the article

  • SMB from fedora 12 to windows network

    - by Jean
    Hello, I got Fedora 12 samab and samba client and permitted the same via the iptables. For some reason, I cannot seem to browse my windows network. What did I do wrong, and how can I achieve this. Thanks Jean [edit] - I want to browse the windows workgroup [edit] - Set the workgroup name, restarted the smb in the services, can browse network, but only my fedora 12 system is being shown

    Read the article

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