Daily Archives

Articles indexed Thursday May 6 2010

Page 4/118 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Shorten array length once element is remove in Java.

    - by lupin
    Note: Following is my homework/assignment, feel free not to answer if you will. I want to delete/remove an element from an String array(Set) basic, I'm not allowed to use Collections..etc. Now I have this: void remove(String newValue) { for ( int i = 0; i < setElements.length; i++) { if ( setElements[i] == newValue ) { setElements[i] = ""; } } } I does what I want as it remove the element from an array but it doesn't shorten the length. The following is the output, basically it remove the element indexed #1. D:\javaprojects>java SetsDemo Enter string element to be added A You entered A Set size is: 5 Member elements on index: 0 A Member elements on index: 1 b Member elements on index: 2 hello Member elements on index: 3 world Member elements on index: 4 six Set size is: 5 Member elements on index: 0 A Member elements on index: 1 Member elements on index: 2 hello Member elements on index: 3 world Member elements on index: 4 six lupin

    Read the article

  • Read binary file into a struct C#

    - by Robert Höglund
    I'm trying to read binary data using C#. I have all information about the layout of the data in the files I want to read. I'm able to read the data "chunk by chunk", i.e. getting the first 40 bytes of data converting it to a string, get the next 40 bytes, ... Since there are at least three slighlty different version of the data, I would like to read the data directly into a struct. It just feels so much more right than by reading it "line by line". I have tried the following approach but to no avail:StructType aStruct; int count = Marshal.SizeOf(typeof(StructType)); byte[] readBuffer = new byte[count]; BinaryReader reader = new BinaryReader(stream); readBuffer = reader.ReadBytes(count); GCHandle handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned); aStruct = (StructType) Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(StructType)); handle.Free(); The stream is an opened FileStream from which I have began to read from. I get an AccessViolationException when using Marshal.PtrToStructure. The stream contains more information than I'm trying to read since I'm not interested in data at the end of the file. The struct is defined like:[StructLayout(LayoutKind.Explicit)] struct StructType { [FieldOffset(0)] public string FileDate; [FieldOffset(8)] public string FileTime; [FieldOffset(16)] public int Id1; [FieldOffset(20)] public string Id2; } The examples code is changed from original to make this question shorter. How would I read binary data from a file into a struct?

    Read the article

  • Pitfalls and practical Use-Cases: Toplink, Hibernate, Eclipse Link, Ibatis ...

    - by Martin K.
    I worked a lot with Hibernate as my JPA implementation. In most cases it works fine! But I have also seen a lot of pitfalls: Remoting with persisted Objects is difficult, because Hibernate replaces the Java collections with its own collection implementation. So the every client must have the Hibernate .jar libraries. You have to take care on LazyLoading exceptions etc. One way to get around this problem is the use of webservices. Dirty checking is done against the Database without any lock. "Delayed SQL", causes that the data access isn't ACID compliant. (Lost data...) Implict Updates So we don't know if an object is modified or not (commit causes updates). Are there similar issues with Toplink, Eclipse Link and Ibatis? When should I use them? Have they a similar performance? Are there reasons to choose Eclipse Link/Toplink... over Hibernate?

    Read the article

  • Is it possible to modify ASP.NET to no longer require runat="server"?

    - by sean2078
    I know why runat="server" is currently required (ASP.NET why runat="server"), but the consensus is that it should not be required if you incorporate a simple default into the design (I agree of course). Would it be possible to modify, extend, decompile and recreate, intercept or otherwise change the behavior of how ASP.NET parses ASPX and ASCX files so that runat="server" would no longer be required? For instance, I assume that a version of Mono could be branched to accomplish this goal. In case specific requirements are helpful, the following highlights one design: During parsing, when configured namespace tags are encountered (such as "asp"), default the element's runat property to "server" During parsing, when configured namespace tags are encountered (such as "asp"), if the element's runat property value is available, then that value should be used in place of the default New page-level setting introduced (can be set in the page directive or web.config) that specifies the default runat value for a specific namespace tag

    Read the article

  • Target .Net Framework 4 in t4 templates

    - by HeavyWave
    We have a template that goes like this <#@ template language="C#v3.5" #> <#@ assembly name="System.dll" #> <#@ assembly name="System.Core.dll" #> <#@ assembly name="System.Data.Linq.dll" #> It compiles and runs on .Net 3.5, but after we have switched to .Net 4 the template has stopped working, so I've tried using answer from here, but I get errors like this Error 99 Compiling transformation: Metadata file 'System.Data.Linq.dll' could not be found How do I correctly modify the template to run on .Net Framework 4?

    Read the article

  • Collapsing parent POM into the child

    - by Robert Munteanu
    Given a maven project with a parent POM - including mostly plugin and dependency versions - how can I generate a POM which takes the information from the parent, places it into the child and removes the reference to the parent? Ideally this would be done with the maven-assembly-plugin. Update: I need this done automatically, since manually it's boring and tedious. Update 2: I'm preparing the source code for an external and want to deliver only one project, not the whole family.

    Read the article

  • How to scale MySQL with multiple machines?

    - by erotsppa
    I have a web app running LAMP. We recently have an increase in load and is now looking at solutions to scale. Scaling apache is pretty easy we are just going to have multiple multiple machines hosting it and round robin the incoming traffic. However, each instance of apache will talk with MySQL and eventually MySQL will be overloaded. How to scale MySQL across multiple machines in this setup? I have already looked at this but specifically we need the updates from the DB available immediately so I don't think replication is a good strategy here? Also hopefully this can be done with minimal code change. PS. We have around a 1:1 read-write ratio.

    Read the article

  • Does mprotect flush the instruction cache on ARM Linux?

    - by Adam Goode
    I am writing a JIT on ARM Linux that executes an instruction set that contains self-modifying code. The instruction set does not have any cache flush instructions (similar to x86 in that respect). If I write out some code to a page and then call mprotect on that page, is that sufficient to invalidate the instruction cache? Or do I also need to use the cacheflush syscall on those pages?

    Read the article

  • Seeking free project planner with auto resource levelling

    - by mawg
    As the title says, I am seeking a project planner with automatic resource levelling. It must be free for commercial use and a bonus, but not requirement, would be MS project import/export. I like the look of Task Juggler, but it is at a stage of development hovering between v2 and v3. Anything else? Basically, I want to play "what if games" - I will determine the tasks and their effort, and the dependencies between them and then try to figure out how many staff I need. Since many of the tasks can be done in parallel, it is difficult to guess how many are needed. A PM tool with automatic resource levelling seems like a good way to find out.

    Read the article

  • Alternatives to LINQ To SQL on high loaded pages

    - by Alex
    To begin with, I LOVE LINQ TO SQL. It's so much easier to use than direct querying. But, there's one great problem: it doesn't work well on high loaded requests. I have some actions in my ASP.NET MVC project, that are called hundreds times every minute. I used to have LINQ to SQL there, but since the amount of requests is gigantic, LINQ TO SQL almost always returned "Row not found or changed" or "X of X updates failed". And it's understandable. For instance, I have to increase some value by one with every request. var stat = DB.Stats.First(); stat.Visits++; // .... DB.SubmitChanges(); But while ASP.NET was working on those //... instructions, the stats.Visits value stored in the table got changed. I found a solution, I created a stored procedure UPDATE Stats SET Visits=Visits+1 It works well. Unfortunately now I'm getting more and more moments like that. And it sucks to create stored procedures for all cases. So my question is, how to solve this problem? Are there any alternatives that can work here? I hear that Stackoverflow works with LINQ to SQL. And it's more loaded than my site.

    Read the article

  • How to generate a compiler error based on an attribute being missing in C#?

    - by RodH257
    I create a number of add-ins for the Revit Structure API. Each tool has to habe a class which implements the interface IExternalCommand. In the latest version of Revit, for your tool to work you need to have two attributes on the class that implements that interface: [Regeneration(RegenerationOption.Manual)] [Transaction(TransactionMode.Automatic)] The values in brackets can change, but there must be something there. Often I am finding myself forgetting to put the attributes on, then when it comes to runtime it crashes. Is there any way in Visual Studio 2010 to add a compiler warning or error saying that if your class implements that interface it must have those 2 attributes? I have resharper if that helps. Can anyone point me into the right direction?

    Read the article

  • How to log POSTed forms submissions?

    - by justSteve
    Back in the ASP classic days when i needed to write out the name/value pairs of forms submitted by POST i thru this loop into the page: on error resume next for each x in Request.Form Response.AppendToLog x & "=" & Request(x) next It threw all the form fields and values into the log just as GETs are. Does IIS7 .net give me any better method? (this is for the dev/testing portion of the project i don't have any concern about the space or cycles used to accomplish this). thx

    Read the article

  • How do you 'clone' WebControls in C# .NET ?

    - by Adz
    My basic question is, in .NET, how do I clone WebControls? I would like to build a custom tag, which can produce multiple copies of its children. Ultimately I intend to build a tag similar to in JSP/Struts. But the first hurdle I have is the ability to duplicate/clone the contents of a control. Consider this rather contrived example; <custom:duplicate count="2"> <div> <p>Some html</p> <asp:TextBox id="tb1" runat="server" /> </div> </custom:duplicate> The HTML markup which is output would be something like, <div> <p>Some html</p> <input type="text" id="tb1" /> </div> <div> <p>Some html</p> <input type="text" id="tb1" /> </div> Note: I know i have the id duplicated, I can come up with a solution to that later! So what we would have is my custom control with 3 children (I think) - a literal control, a TextBox control, and another literal control. In this example I have said 'count=2' so what the control should do is output/render its children twice. What I would hope to do is write some "OnInit" code which does something like: List<WebControl> clones; for(int i=1; i<count; i++) { foreach(WebControl c in Controls) { WebControl clone = c.Clone(); clones.Add(clone); } } Controls.AddRange(clones); However, as far as I can tell, WebControls do not implement ICloneable, so its not possible to clone them in this way. Any ideas how I can clone WebControls?

    Read the article

  • CS Majors: Hardest concept(s) you learned in school?

    - by Mark Lubin
    For the CS majors out there what were the hardest CS classes or concepts that you learned in your undergraduate schooling? Did you find once you learned the basics,(data structs, OOP fundamentals, discrete math, pointers, recursion, etc) the rest followed naturally or did you hit a wall at any point in your higher classes like OS'es and Compilers? Thanks for the input!

    Read the article

  • multi column sorting of datagrid view:

    - by Bi
    I have a datagridview in a windows form with 3 columns: Serial number, Name and Date-Time. The Name column will always have either of the two values: "name1" or "name2". I need to sort these columns such that the grid displays all the rows with name values in a specific order (first display all the "name1" rows and then all the "name2" rows). Within the "name1" rows, I want the rows to be sorted by the Date-Time. Please note programmatically, all the 3 columns are strings. For example, if I have the rows: 01 |Name1 | 2010-05-05 10:00 PM 02 |Name2 | 2010-05-02 08:00 AM 03 |Name2 | 2010-05-01 08:00 AM 04 |Name1 | 2010-05-01 11:00 AM 05 |Name1 | 2010-05-04 07:00 AM needs to be sorted as 04 |Name1 | 2010-05-01 11:00 AM 05 |Name1 | 2010-05-04 07:00 AM 01 |Name1 | 2010-05-05 10:00 PM 03 |Name2 | 2010-05-01 08:00 AM 02 |Name2 | 2010-05-02 08:00 AM I am not sure how to go about using the below: myGrid.Sort(.....,ListSortDirection.Ascending)

    Read the article

  • launch the emulator, I only see the black window with the string 'ANDROID", and no more desktop and

    - by Jiawelin
    Dear experts, I download the Android code and "make sdk" to build out my own SDK, but the emulator from this SDK does not work well -- it only shows the black window with the "ANDROID" string, but I can't see any desktop picture or any applications. what's wrong here? anyone could please provide me a hint? Thanks a lot. I use the command: $./emulator @jiawelin -debug all and the last output message is: emulator: android_hw_control_init: hw-control qemud handler initialized

    Read the article

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