Daily Archives

Articles indexed Tuesday May 11 2010

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

  • Split String in C#

    - by ritu
    I thought this will be trivial but I can't get this to work. Assume a line in a CSV file: "Barak Obama", 48, "President", "1600 Penn Ave, Washington DC" string[] tokens = line.split(',') I expect this: "Barak Obama" 48 "President" "1600 Penn Ave, Washington DC" but the last token is 'Washington DC' not "1600 Penn Ave, Washington DC". Is there an easy way to get the split function to ignore the comma within quotes?

    Read the article

  • creating 2d sprites for games ?

    - by dfafa
    i am pretty new to developing games...i thought i would begin by making a simple 2d game.... curious what tools are commonly used to transform images to pixel sprites ? or is this done by hand, if so what tools are used ? even better, is there a marketplace where i can purchase game sprites and other game assets ?

    Read the article

  • TSQL -- Make it better

    - by user319353
    Hi: -- Very Narrow (all IDs are passed in) IF(@EmpID IS NOT NULL AND @DeptID IS NOT NULL AND @CityID IS NOT NULL) BEGIN SELECT e.EmpName ,d.DeptName ,c.CityName FROM Employee e WITH (NOLOCK) JOIN Department d WITH (NOLOCK) ON e.deptid = d.deptid JOIN City c WITH (NOLOCK) ON e.CityID = c.CityID WHERE e.EmpID = @EmpID END -- Just 2 IDs passed in ELSE IF(@DeptID IS NOT NULL AND @CityID IS NOT NULL) BEGIN SELECT e.EmpName ,d.DeptName ,NULL AS [CityName] FROM Employee e WITH (NOLOCK) JOIN Department d WITH (NOLOCK) ON e.deptid = d.deptid JOIN City c WITH (NOLOCK) ON e.CityID = c.CityID WHERE d.deptID = @DeptID END -- Very Broad (just 1 ID passed in) ELSE IF(@CityID IS NOT NULL) BEGIN SELECT e.EmpName ,NULL AS [DeptName] ,NULL AS [CityName] FROM Employee e WITH (NOLOCK) JOIN Department d WITH (NOLOCK) ON e.deptid = d.deptid JOIN City c WITH (NOLOCK) ON e.CityID = c.CityID WHERE c.CityID = @CityID END -- None (Nothing passed in) ELSE BEGIN SELECT NULL AS [EmpName] ,NULL AS [DeptName] ,NULL AS [CityName] END Question: Is there any better way (OR specifically can I do anything without IF...ELSE condition?

    Read the article

  • ObservableCollection Implementation

    - by wpfwannabe
    I know I am missing something obvious but I can't seem to implement ObservableCollection in my class below. IE it won't show up in intellsense. Can someone please let me know what I am missing. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Collections.ObjectModel; using System.Reflection; using System.ComponentModel; namespace MyBTOList { public class InventoryListBTO : List<InventoryBTO> { /// <summary> /// Get all inventory records from local database /// </summary> /// <returns></returns> public static InventoryListBTO GetAllInventoryRecords() { return GetInventoryListBO(Inventory.GetAllInventoryRecordsDb()); } } public class InventoryBTO : INotifyPropertyChanged { }

    Read the article

  • Redirect old directory to new website

    - by JonP
    I want to use htaccess to redirect all traffic from www.oldsite.com/directory to www.newsite.com I want to make it so that when visitors view any webpage within www.oldsite.com/directory (ie. www.oldsite.com/directory/contact.html) it gets redirected to the homepage of www.newsite.com I tried "Redirect /directory http:www.newsite.com" but the webpage the visitor is trying to access within the directory gets attached to the new sites url (ie. www.newsite.com/contact.html)

    Read the article

  • convert class object collection to List

    - by prince23
    hi, here i have an return type as class object collection. where Emp is class , having properties like Fname, lname,Age WebApplication1.kumar .Job Emp = objEmp.GetJobInfo2(1); i need to convert the oject collections into List List objEmp = new List(); what is the steps that i need to do here to convert class object to List thanks in advance

    Read the article

  • printf("... %c ...",'\0') and family - what will happen?

    - by SF.
    How will various functions that take printf format string behave upon encountering the %c format given value of \0/NULL? How should they behave? Is it safe? Is it defined? Is it compiler-specific? e.g. sprintf() - will it crop the result string at the NULL? What length will it return? Will printf() output the whole format string or just up to the new NULL? Will va_args + vsprintf/vprintf be affected somehow? If so, how? Do I risk memory leaks or other problems if I e.g. shoot this NULL at a point in std::string.c_str()? What are the best ways to avoid this caveat (sanitize input?)

    Read the article

  • mysql error using Rails-- Please help

    - by Cypher
    Alright I am sry for the noob question but this has been driving me up a wall-especially because I got it to work yesterday and I can't remember what I did.... I am just trying to use mysql with rails with a mongrel server. I set up the server fine and can run rails applications that don't need mysql but when I create a project using (for example) rails -d mysql blog and then create some simple controller e.g. ruby script/generate Test then put this code in the controller... class TestController < ApplicationController def index render :text => 'WORK' end end then when I start the server up and open up localhost:3000/test I get the following error: = Booting Mongrel = Rails 2.3.5 application starting on http://0.0.0.0:3000 = Call with -d to detach = Ctrl-C to shutdown server /!\ FAILSAFE /!\ Mon May 10 20:15:06 -0500 2010 Status: 500 Internal Server Error Can't connect to MySQL server on 'localhost' (10061) C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:589:in 'real_connect' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:589:in 'connect' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:203:in 'initialize' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:75:in 'new' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/mysql_adapter.rb:75:in 'mysql_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:223:in 'send' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:223:in 'new_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:245:in 'checkout_new_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:188:in 'checkout' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:184:in 'loop' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:184:in 'checkout' C:/Ruby/lib/ruby/1.8/monitor.rb:242:in 'synchronize' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:183:in 'checkout' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:98:in 'connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_pool.rb:326:in 'retrieve_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_specification.rb:123:in 'retrieve_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapter s/abstract/connection_specification.rb:115:in 'connection' etc... In the browser i get a 'We're sorry, but something went wrong' Does anyone know what I am doing wrong?

    Read the article

  • Android - Using Camera Intent but not updating correctly?

    - by Tyler
    Hello - I am using an intent to capture a picture: Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "test.jpg"))); startActivityForResult(i, 2); And then once taken I do the following: sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); launchGallery(); While the above seems to work the first time without issue, whenever I run through a second time (so test.jpg already exists) the image actually saves correctly to /sdcard/ but I am finding that the thumbnail does not update and when the gallery loads it shows the previous test.jpg image! I was under the impression that sendBroadcast should update the thumbnails, but it doesn't appear to be.. Is there some other way to go about this and ensure when I call my launchGallery(); method the most recent image I just took appears? Thanks!

    Read the article

  • jQuery UI + Gmaps = Problems (for me at least) HELP!!

    - by Luis
    Hi there! I started using jQuery as soon as I found out about it, it is very powerfull but I started struggling when I tried to load Gmaps api into the tabs jQuery UI brings. Strangly enough in IE 6,7,8 it works fine, but in Firefox, Safari (I'm using mac but tested it in windows and they both give the same problems) the map doesn't load entirely. When I click on the tab where the map loads in, only part of the map is fully operational, the rest is grey and not clickable. Please take a look at the link below and click the third tab in firefox/safari and IE and you will see the problem. http://movewithusoverseas.com/index-new.php?z=product-info.html&pid=1 I don't know if it is a bug in the jQuery UI code or I'm doing something wrong. If I load the map out of the tabs the map is shown OK. I'm fighting with this problem for a week and a half... any help will be much appreciated. Thanks in advance. Luis

    Read the article

  • Delete only reference to child object

    - by Al
    I'm running in to a bit of a problem where any attempt to delete just the reference to a child also deletes the child record. My schema looks like this Person Organisation OrganisationContacts : Person OrgId PersonId Role When removing an Organisation i want to only delete the record in OrgnaisationContacts, but not touch the Person record. My Mapping looks like this Code: public OrganisationMap() { Table("Organsations"); .... HasMany<OrganisationContact>(x => x.Contacts) .Table("OrganisationContacts ") .KeyColumn("OrgId") .Not.Inverse() .Cascade.AllDeleteOrphan(); } public class OrganisationContactMap : SubclassMap<OrganisationContact> { public OrganisationContactMap() { Table("OrganisationContacts"); Map(x => x.Role, "PersonRole"); Map(x => x.IsPrimary); } } At the moment just removing a contact from the IList either doesn't reflect in the database at all, or it issues two delete statements DELETE FROM OrganisationContact & DELETE FROM Person, or tries to set PersonId to null in the OrganisationContacts table. All of which are not desirable. Any help would be great appreciated.

    Read the article

  • Simple way to repeat a String in java

    - by e5
    I'm looking for a simple commons method or operator that allows me to repeat some String n times. I know I could write this using a for loop, but I wish to avoid for loops whenever necessary and a simple direct method should exist somewhere. String str = "abc"; String repeated = str.repeat(3); repeated.equals("abcabcabc"); Related to: repeat string javascript Create NSString by repeating another string a given number of times Edited I try to avoid for loops when they are not completely necessary because: They add to the number of lines of code even if they are tucked away in another function. Someone reading my code has to figure out what I am doing in that for loop. Even if it is commented and has meaningful variables names, they still have to make sure it is not doing anything "clever". Programmers love to put clever things in for loops, even if I write it to "only do what it is intended to do", that does not preclude someone coming along and adding some additional clever "fix". They are very often easy to get wrong. For loops that involving indexes tend to generate off by one bugs. For loops often reuse the same variables, increasing the chance of really hard to find scoping bugs. For loops increase the number of places a bug hunter has to look.

    Read the article

  • Custom Key Bindings in SWT

    - by Dimitar
    Hey all, Is it at all possible to add custom key bindings to buttons in SWT? I can't use & in the text of the button to set a mnenomic because my buttons have no text (only an image). Is there a good way to do this using key listeners or is there something like the input/action map in swing? Thanks in advance.

    Read the article

  • Doubts in System call mechanism in linux

    - by bala1486
    We transit from ring3 to ring0 using 'int' or the new 'syscall/sysenter' instruction. Does that mean that the page tables and other stuffs that needs to be modified for the kernel is automatically done by the 'int' instruction or the interrupt handler for the 'int 0x80' will do the required stuff and jump to the respective system call. Also when returning from a system call, we again need to go to user space. For this we need to know the instruction address in the user space to continue the user application. Where is that address stored. Does the 'ret' instruction automatically changes the ring from ring3 to ring0 or where/how this ring changing mechanism takes place? Then, i read that changing from ring3 to ring0 is not as costly as changing from ring0 to ring3. Why is this so?? Thanks, Bala

    Read the article

  • WCF Self Host Service - Endpoints in C#

    - by Kyle
    My first few attempts at creating a self hosted service. Trying to make something up which will accept a query string and return some text but have have a few issues: All the documentation talks about endpoints being created automatically for each base address if they are not found in a config file. This doesn't seem to be the case for me, I get the "Service has zero application endpoints..." exception. Manually specifying a base endpoint as below seems to resolve this: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.ServiceModel.Description; namespace TestService { [ServiceContract] public interface IHelloWorldService { [OperationContract] string SayHello(string name); } public class HelloWorldService : IHelloWorldService { public string SayHello(string name) { return string.Format("Hello, {0}", name); } } class Program { static void Main(string[] args) { string baseaddr = "http://localhost:8080/HelloWorldService/"; Uri baseAddress = new Uri(baseaddr); // Create the ServiceHost. using (ServiceHost host = new ServiceHost(typeof(HelloWorldService), baseAddress)) { // Enable metadata publishing. ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; host.Description.Behaviors.Add(smb); host.AddServiceEndpoint(typeof(IHelloWorldService), new BasicHttpBinding(), baseaddr + "SayHello"); //for some reason a default endpoint does not get created here host.Open(); Console.WriteLine("The service is ready at {0}", baseAddress); Console.WriteLine("Press to stop the service."); Console.ReadLine(); // Close the ServiceHost. host.Close(); } } } } I still think I'm doing something wrong as I don't get the normal "This is a web service...etc..." page when I load up the url How would I go about setting this up to return the value of name in SayHello(string name) when requested thusly: localhost:8080/HelloWorldService/SayHello?name=kyle Do I have to create an endpoing for the SayHello contract as well? I'm trying to walk before running, but this just seems like crawling...Service has zero application endpoints...

    Read the article

  • building Mozilla Spider Monkey on Ubuntu

    - by Hussain
    Hi. I'm trying to build spider monkey on ubuntu 10.04 (lucid). However, when I run autoconf2.13 on the js/src directory, it tells me there is no configure.in file. I can't just do the usual ./configure make sudo make install , either. What's up with it?

    Read the article

  • NHibernate Session per Call in WCF - How to Rollback

    - by Corey Coogan
    I've implemented some components to use WCF with both an IoC Container (StructureMap) and the Session per Call pattern. The NHibernate stuff is most taken from here: http://realfiction.net/Content/Entry/133. It seems to be OK, but I want to open a transaction with each call and commit at the end, rather than just Flush() which how its being done in the article. Here's where I am running into some problems and could use some advice. I haven't figured out a good way to rollback. I realize I can check the CommunicationState and if there's an exception, rollback, like so: public void Detach(InstanceContext owner) { if (Session != null) { try { if(owner.State == CommunicationState.Faulted) RollbackTransaction(); else CommitTransaction(); } finally { Session.Dispose(); } } } void CommitTransaction() { if(Session.Transaction != null && Session.Transaction.IsActive) Session.Transaction.Commit(); } void RollbackTransaction() { if (Session.Transaction != null && Session.Transaction.IsActive) Session.Transaction.Rollback(); } However, I almost never return a faulted state from a service call. I would typically handle the exception and return an appropriate indicator on my response object and rollback the transaction myself. The only way I can think of handling this would be to inject not only repositories into my WCF services, but also an ISession so I can rollback and handle the way I want. That doesn't sit well with me and seems kind of leaky. Anyone else handling the same problem?

    Read the article

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