Daily Archives

Articles indexed Tuesday April 13 2010

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

  • Moving and resizing JPanels object inside JFrame.

    - by Gabriel A. Zorrilla
    Continuing my quest of learning Java by doing a simple game, i stumbled upon a little issue. My gameboard extends JPanel as well as each piece of the board. Now, this presents some problems: Cant set size of each piece, therefore, each piece JPanel ocupy the whole JFrame, concealing the rest of the pieces and the background (gameboard). Cant set the position of the pieces. I have the default flow manager. Tried setbounds and no luck. Perhaps i should make the piece to extend other JComponent?

    Read the article

  • Core Data - How to check if a managed object's properties have been deallocated?

    - by georryan
    I've created a program that uses core data and it works beautifully. I've since attempted to move all my core data methods calls and fetch routines into a class that is self contained. My main program then instantiates that class and makes some basic method calls into that class, and the class then does all the core data stuff behind the scenes. What I'm running into, is that sometimes I'll find that when I grab a managed object from the context, I'll have a valid object, but its properties have been deallocated, and I'll cause a crash. I've played with the zombies and looked for memory leaks, and what I have gathered is it seems that the run loop is probably responsible for deallocating the memory, but I'm not sure. Is there a way to determine if that memory has been deallocated and force the core data to get it back if I need to access it? My managedObjectContext never gets deallocated, and the fetchedResultsController never does, either. I thought maybe I needed to use the [managedObjectContext refreshObject:mergeData:] method, or the [managedObjectContext setRetainsRegisteredObjects:] method. Although, I'm under the impression that last one may not be the best bet since it will be more memory intensive (from what I understand). These errors only popped up when I moved the core data calls into another class file, and they are random when they show up. Any insight would be appreciated. -Ryan

    Read the article

  • Linq to SQL and concurrency with Rob Conery repository pattern

    - by David Hall
    I have implemented a DAL using Rob Conery's spin on the repository pattern (from the MVC Storefront project) where I map database objects to domain objects using Linq and use Linq to SQL to actually get the data. This is all working wonderfully giving me the full control over the shape of my domain objects that I want, but I have hit a problem with concurrency that I thought I'd ask about here. I have concurrency working but the solution feels like it might be wrong (just one of those gitchy feelings). The basic pattern is: private MyDataContext _datacontext private Table _tasks; public Repository(MyDataContext datacontext) { _dataContext = datacontext; } public void GetTasks() { _tasks = from t in _dataContext.Tasks; return from t in _tasks select new Domain.Task { Name = t.Name, Id = t.TaskId, Description = t.Description }; } public void SaveTask(Domain.Task task) { Task dbTask = null; // Logic for new tasks omitted... dbTask = (from t in _tasks where t.TaskId == task.Id select t).SingleOrDefault(); dbTask.Description = task.Description, dbTask.Name = task.Name, _dataContext.SubmitChanges(); } So with that implementation I've lost concurrency tracking because of the mapping to the domain task. I get it back by storing the private Table which is my datacontext list of tasks at the time of getting the original task. I then update the tasks from this stored Table and save what I've updated This is working - I get change conflict exceptions raised when there are concurrency violations, just as I want. However, it just screams to me that I've missed a trick. Is there a better way of doing this? I've looked at the .Attach method on the datacontext but that appears to require storing the original version in a similar way to what I'm already doing. I also know that I could avoid all this by doing away with the domain objects and letting the Linq to SQL generated objects all the way up my stack - but I dislike that just as much as I dislike the way I'm handling concurrency.

    Read the article

  • Of patents, open source, and IBM

    <b>Cyber Cynic:</b> "After covering the war of words over IBM's use of patents in a business dispute with French start-up TurboHercules and giving my two cents on this open-source family fight, I'd hope the matter would die down. I was wrong."

    Read the article

  • Exploratory Question for Security Admins (/etc/passwd + PHP)

    - by JPerkSter
    Hi everyone, I've been seeing a few issues lately on a few of my servers where an account gets hacked via outdated scripts, and the hacker uploads a cPanel / FTP Brute forcing PHP script inside the account. The PHP File reads /etc/passwd to get the usernames, and than uses a passwd.txt file to try and brute force it's way in to 127.0.0.1:2082. I'm trying to think of a way to block this. It doesn't POST anything except "GET /path/phpfile.php", so I can't use mod_security to block this. I've been thinking of maybe changing permissions on /etc/passwd to 600, however I'm unsure how this will result in regards to my users. I was also thinking of rate-limiting localhost connections to :2082, however I'm worried about mod_proxy being affected. Any suggestions?

    Read the article

  • Compile C# into objective-C

    - by Ali Shafai
    Now that monotouch is being banned, I was wondering if there is a way to translate C# (or some other modern language for that matter) into objective-C? I won't mind using apple's api as long as I don't have to declare my variables in 3-4 stages (ivar-property-synthesize-dealloc). All I want is a less wordy language to concentrate on my intent and not on the compiler syntax. unfortunately apple in its arrogance thinks objective-c is a "modern" language and if you are looking for an alternative (monotouch) it's because you are incapable of coding. also if you don't find programming in itunes; sorry, xcode enjoyable, it is not because there are better alternatives, it's because you are stupid. anyway back to my original question: can it be done?

    Read the article

  • How to display image that is located on another server on the network (ASP.NET)

    - by eviljack
    I've got a ASP.NET site that's located on a local server (MY_SERVER). And one of the things it does is pull up tiff files which are located on another server (ANOTHER_SERVER). The location of each of these files is stored in SQL. I pull up each of these images and am supposed to display them. The problem is: the files are not named with a tiff extension (does it matter?) they aren't displaying at all. I am using an Image control to display these images, and I'm not sure if it matters that the extension is not set (does the image control know the difference between an jpg and a tiff without the extension?) I am guessing the images aren't displaying because they are not on the same server MY_SERVER that the images are located (ANOTHER_SERVER). Any ideas on how to fix this?

    Read the article

  • SQL model optimization question

    - by supermogx
    I need to keep track of number of "hits" on a particular item in a DB. The thing is that the "hits" should stay unique with a user ID, so if a user hits the item 3 times, it should still count for a hit of 1. Also, I need to display the total number of hits for a particular item. Is there a better way than to store each hits for each items by each users in a separate table? Would keeping the user ID in a string separated by commas a better and efficient way?

    Read the article

  • ViewModel updates after Model server roundtrip

    - by Pavel Savara
    I have stateless services and anemic domain objects on server side. Model between server and client is POCO DTO. The client should become MVVM. The model could be graph of about 100 instances of 20 different classes. The client editor contains diverse tab-pages all of them live-connected to model/viewmodel. My problem is how to propagate changes after server round-trip nice way. It's quite easy to propagate changes from ViewModel to DTO. For way back it would be possible to throw away old DTO and replace it whole with new one, but it will cause lot of redrawing for lists/DataTemplates. I could gather the server side changes and transmit them to client side. But the names of fields changed would be domain/DTO specific, not ViewModel specific. And the mapping seems nontrivial to me. If I should do it imperative way after round-trip, it would break SOC/modularity of viewModels. I'm thinking about some kind of mapping rule engine, something like automappper or emit mapper. But it solves just very plain use-cases. I don't see how it would map/propagate/convert adding items to list or removal. How to identify instances in collections so it could merge values to existing instances. As well it should propagate validation/error info. Maybe I should implement INotifyPropertyChanged on DTO and try to replay server side events on it ? And then bind ViewModel to it ? Would binding solve the problems with collection merges nice way ? Is EventAgregator from PRISM useful for that ? Is there any event record-replay component ? Is there better client side pattern for architecture with server side logic ?

    Read the article

  • HOM with Objective C

    - by Coxer
    Hey, i am new to objective C, but i tried to use HOM in order to iterate over an NSArray and append a string to each element. here is my code: void print( NSArray *array ) { NSEnumerator *enumerator = [array objectEnumerator]; id obj; while ( nil!=(obj = [enumerator nextObject]) ) { printf( "%s\n", [[obj description] cString] ); } } int main( int argc, const char *argv[] ) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *names = [[NSArray alloc] init]; NSArray *names_concat = [[NSArray alloc] init]; names = [NSArray arrayWithObjects:@"John",@"Mary",@"Bob",nil]; names_concat = [[names collect] stringByAppendingString: @" Doe"]; print(names_concat); [pool release]; } What is wrong with this code? My compiler (gcc) says NSArray may not respond to "-collect"

    Read the article

  • AS3 Classes - Should I use them?

    - by Eric
    I'm working on a project in Flash CS4/AS3 and I have a document class set up but I am wondering about using that, as opposed to frame-based scripting. Most of what I have seen so far deals with how to create them, but doesn't offer much about why or when to use them. I know I can also pull in other classes beyond the document class but, again, why and when? Could I get some input from you fine people out there on usage/best practice, etc? Thanks

    Read the article

  • load testing of "cookieless Session" asp.net

    - by anshu
    I have been trying using MS VSTS 2008, no luck so far.. After the redirection from server to accomodate the sessionID in URL, the test fails during the first time recording. I am open to looking at other tools which are not very expensive. Does anyone have any experience using any tool for testing cookieless sessionID website?

    Read the article

  • How to parse IP addresses with perl?

    - by Andrey Zentavr
    Hello! I have list of IPs: 238.51.208.96/28 238.51.209.180-199 238.51.209.100-109 238.51.213.2-254 ... How can I easily parse them? I need first and last IP from range. For First line I can use Net::Netmask CPAN module, but what can I do with others lines?

    Read the article

  • When is a PHP project too small for a framework?

    - by Jonathan Nicol
    I'm about to start on a small, static website project: no database or CMS required. Basically, a brochure website. I used the CodeIgniter framework recently to develop a full-blown web application, and I'm wondering if it appropriate to also use CI for smaller, simpler sites. Typically for a static brochure site I would write regular PHP pages with a few includes thrown in to save on repetition (i.e. HTML with a sprinking of PHP), but this time around I'm wondering if my new friend CodeIgniter might be able to streamline the development process. Is it sensible to consider a framework for such a simple project, or is it overkill? I'm worried that I might be the proverbial carpenter whose only tool is a hammer, and sees every problem as a nail!

    Read the article

  • How to get maven gwt 2.0 build working

    - by Pieter Breed
    EDIT: Added some of the output of the mvn -X -e commands at the end My company is developing a GWT application. We've been using maven 2 and GWT 1.7 successfully for quite a while. We recently decided to upgrade to GWT 2.0. We've already updated the eclipse project and we are able to successfully run the application in dev-mode. We are struggling to get the application built using maven though. I'm hoping somebody can tell me what I'm doing wrong here since I'm running out of time on this. The exacty bit of the output that worries me is the 'GWT compilation skipped' message: [INFO] Copying 119 resources [INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 704 source files to K:\iCura\assessor\target\classes [INFO] [gwt:compile {execution: default}] [INFO] using GWT jars for specified version 2.0.0 [INFO] establishing classpath list (scope = compile) [INFO] com.curasoftware.assessor.Assessor is up to date. GWT compilation skipped [INFO] [jspc:compile {execution: jspc}] [INFO] Built File: \index.jsp I'm pasting the gwt-maven-plugin section below. If you need anything else please ask. <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <version>1.2</version> <configuration> <localWorkers>1</localWorkers> <warSourceDirectory>${basedir}/war</warSourceDirectory> <logLevel>ALL</logLevel> <module>${cura.assessor.module}</module> <!-- use style OBF for prod --> <style>OBFUSCATED</style> <extraJvmArgs>-Xmx2048m -Xss1024k</extraJvmArgs> <gwtVersion>${version.gwt}</gwtVersion> <disableCastChecking>true</disableCastChecking> <soyc>false</soyc> </configuration> <executions> <execution> <goals> <!-- plugin goals --> <goal>clean</goal> <goal>compile</goal> </goals> </execution> </executions> </plugin> I executed mvn clean install -X -e and this is some of the output that I get: [DEBUG] Configuring mojo 'org.codehaus.mojo:gwt-maven-plugin:1.2:compile' --> [DEBUG] (f) disableCastChecking = true [DEBUG] (f) disableClassMetadata = false [DEBUG] (f) draftCompile = false [DEBUG] (f) enableAssertions = false [DEBUG] (f) extra = K:\iCura\assessor\target\extra [DEBUG] (f) extraJvmArgs = -Xmx2048m -Xss1024k [DEBUG] (f) force = false [DEBUG] (f) gen = K:\iCura\assessor\target\.generated [DEBUG] (f) generateDirectory = K:\iCura\assessor\target\generated-sources\gwt [DEBUG] (f) gwtVersion = 2.0.0 [DEBUG] (f) inplace = false [DEBUG] (f) localRepository = Repository[local|file://K:/iCura/lib] [DEBUG] (f) localWorkers = 1 [DEBUG] (f) logLevel = ALL [DEBUG] (f) module = com.curasoftware.assessor.Assessor [DEBUG] (f) project = MavenProject: com.curasoftware.assessor:assessor:3.5.0.0 @ K:\iCura\assessor\pom.xml [DEBUG] (f) remoteRepositories = [Repository[gwt-maven|http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/], Repository[main-maven|http://www.ibiblio.org/maven2/], Repository[central|http://repo1.maven.org/maven2]] [DEBUG] (f) skip = false [DEBUG] (f) sourceDirectory = K:\iCura\assessor\src [DEBUG] (f) soyc = false [DEBUG] (f) style = OBFUSCATED [DEBUG] (f) treeLogger = false [DEBUG] (f) validateOnly = false [DEBUG] (f) warSourceDirectory = K:\iCura\assessor\war [DEBUG] (f) webappDirectory = K:\iCura\assessor\target\assessor [DEBUG] -- end configuration -- and then this: [DEBUG] SOYC has been disabled by user [DEBUG] GWT module com.curasoftware.assessor.Assessor found in K:\iCura\assessor\src [INFO] com.curasoftware.assessor.Assessor is up to date. GWT compilation skipped [DEBUG] com.curasoftware.assessor:assessor:war:3.5.0.0 (selected for null) [DEBUG] com.curasoftware.dto:dto-gen:jar:3.5.0.0:compile (selected for compile) ... It's finding the correct sourceDirectory. That folders has a 'com' folder within which ultimately is the source of the application organized in folders as per the package structure.

    Read the article

  • posix pthreads in c

    - by Codenotguru
    Iam new to c programming and needs some help. long *taskids[NUM_THREADS]; for(t=0; t<NUM_THREADS; t++) { taskids[t] = (long *) malloc(sizeof(long)); *taskids[t] = t; printf("Creating thread %ld\n", t); rc = pthread_create(&threads[t], NULL, PrintHello, (void *) taskids[t]); ... } This code fragment demonstrates how to pass a simple integer to each thread. The calling thread uses a unique data structure for each thread, insuring that each thread's argument remains intact throughout the program. Iam not able to understand how this is happening can somebody explain it??

    Read the article

  • Convert 12-hour date/time to 24-hour date/time

    - by Patrick Cuff
    I have a tab delimited file where each record has a timestamp field in 12-hour format: mm/dd/yyyy hh:mm:ss [AM|PM]. I need to quickly convert these fields to 24-hour time: mm/dd/yyyy HH:mm:ss. What would be the best way to do this? I'm running on a Windows platform, but I have access to sed, awk, perl, python, and tcl in addition to the usual Windows tools.

    Read the article

  • C# 4.0: Covariance And Contravariance In Generics

    - by Paulo Morgado
    C# 4.0 (and .NET 4.0) introduced covariance and contravariance to generic interfaces and delegates. But what is this variance thing? According to Wikipedia, in multilinear algebra and tensor analysis, covariance and contravariance describe how the quantitative description of certain geometrical or physical entities changes when passing from one coordinate system to another.(*) But what does this have to do with C# or .NET? In type theory, a the type T is greater (>) than type S if S is a subtype (derives from) T, which means that there is a quantitative description for types in a type hierarchy. So, how does covariance and contravariance apply to C# (and .NET) generic types? In C# (and .NET), variance applies to generic type parameters and not to the resulting generic type. A generic type parameter is: covariant if the ordering of the generic types follows the ordering of the generic type parameters: Generic<T> = Generic<S> for T = S. contravariant if the ordering of the generic types is reversed from the ordering of the generic type parameters: Generic<T> = Generic<S> for T = S. invariant if neither of the above apply. If this definition is applied to arrays, we can see that arrays have always been covariant because this is valid code: object[] objectArray = new string[] { "string 1", "string 2" }; objectArray[0] = "string 3"; objectArray[1] = new object(); However, when we try to run this code, the second assignment will throw an ArrayTypeMismatchException. Although the compiler was fooled into thinking this was valid code because an object is being assigned to an element of an array of object, at run time, there is always a type check to guarantee that the runtime type of the definition of the elements of the array is greater or equal to the instance being assigned to the element. In the above example, because the runtime type of the array is array of string, the first assignment of array elements is valid because string = string and the second is invalid because string = object. This leads to the conclusion that, although arrays have always been covariant, they are not safely covariant – code that compiles is not guaranteed to run without errors. In C#, the way to define that a generic type parameter as covariant is using the out generic modifier: public interface IEnumerable<out T> { IEnumerator<T> GetEnumerator(); } public interface IEnumerator<out T> { T Current { get; } bool MoveNext(); } Notice the convenient use the pre-existing out keyword. Besides the benefit of not having to remember a new hypothetic covariant keyword, out is easier to remember because it defines that the generic type parameter can only appear in output positions — read-only properties and method return values. In a similar way, the way to define a type parameter as contravariant is using the in generic modifier: public interface IComparer<in T> { int Compare(T x, T y); } Once again, the use of the pre-existing in keyword makes it easier to remember that the generic type parameter can only be used in input positions — write-only properties and method non ref and non out parameters. Because covariance and contravariance apply only to the generic type parameters, a generic type definition can have both covariant and contravariant generic type parameters in its definition: public delegate TResult Func<in T, out TResult>(T arg); A generic type parameter that is not marked covariant (out) or contravariant (in) is invariant. All the types in the .NET Framework where variance could be applied to its generic type parameters have been modified to take advantage of this new feature. In summary, the rules for variance in C# (and .NET) are: Variance in type parameters are restricted to generic interface and generic delegate types. A generic interface or generic delegate type can have both covariant and contravariant type parameters. Variance applies only to reference types; if you specify a value type for a variant type parameter, that type parameter is invariant for the resulting constructed type. Variance does not apply to delegate combination. That is, given two delegates of types Action<Derived> and Action<Base>, you cannot combine the second delegate with the first although the result would be type safe. Variance allows the second delegate to be assigned to a variable of type Action<Derived>, but delegates can combine only if their types match exactly. If you want to learn more about variance in C# (and .NET), you can always read: Covariance and Contravariance in Generics — MSDN Library Exact rules for variance validity — Eric Lippert Events get a little overhaul in C# 4, Afterward: Effective Events — Chris Burrows Note: Because variance is a feature of .NET 4.0 and not only of C# 4.0, all this also applies to Visual Basic 10.

    Read the article

  • SQL SERVER – Configure Management Data Collection in Quick Steps – T-SQL Tuesday #005

    - by pinaldave
    This article was written as a response to T-SQL Tuesday #005 – Reporting. The three most important components of any computer and server are the CPU, Memory, and Hard disk specification. This post talks about  how to get more details about these three most important components using the Management Data Collection. Management Data Collection generates the reports for the three said components by default. Configuring Data Collection is a very easy task and can be done very quickly. Please note: There are many different ways to get reports generated for CPU, Memory and IO. You can use DMVs, Extended Events as well Perfmon to trace the data. Keeping the T-SQL Tuesday subject of reporting this post is created to give visual tutorial to quickly configure Data Collection and generate Reports. From Book On-Line: The data collector is a core component of the Data Collection platform for SQL Server 2008 and the tools that are provided by SQL Server. The data collector provides one central point for data collection across your database servers and applications. This collection point can obtain data from a variety of sources and is not limited to performance data, unlike SQL Trace. Let us go over the visual tutorial on how quickly Data Collection can be configured. Expand the management node under the main server node and follow the direction in the pictures. This reports can be exported to PDF as well Excel by writing clicking on reports. Now let us see more additional screenshots of the reports. The reports are very self-explanatory  but can be drilled down to get further details. Click on the image to make it larger. Well, as we can see, it is very easy to configure and utilize this tool. Do you use this tool in your organization? Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL Performance, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology Tagged: SQL Reporting, SQL Reports

    Read the article

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