Daily Archives

Articles indexed Sunday March 14 2010

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

  • How to access application.xml file of an EAR deployed to IBM WebSphere 6.1

    - by Matt1776
    I am deploying an EAR file to the IBM WebSpehre server 6.1 - I want to be able to access the EAR application name which is stored in the deployment file under 'display-name'. Looking through stack overflow posts on related subjects, I've been able to gather that this is possible via the Java MBean API - or IBM's WAS API - Problem is I cannot find a place where these API lists are summarized, i.e. cannot figure out which one to begin looking at. I could hardcode the WAS install location and find the file by looking in the 'installedApps' directory, but this is not dynamic. Does anyone have any experience working with these APIs? Any other way to dynamically find the deployed EAR's display name? EDIT - I should add that the reason I would like this information is to dynamically load our properties files - that are named by the following convention "EARAppName.properties" - so you see there IS a reasonable 'rationale' behind desiring this information in my application EDIT 2 - I should also note that this app will always be deployed on a WAS - but in the case that it isnt, a generic non-proprietary solution would be preferred, but not necessary at this moment. EDIT 3 - What I want to accomplish: Is there a way to dynamically find the deployed EAR's display name from within the application code?

    Read the article

  • Criticize my code, please

    - by Micky
    Hey, I was applying for a position, and they asked me to complete a coding problem for them. I did so and submitted it, but I later found out I was rejected from the position. Anyways, I have an eclectic programming background so I'm not sure if my code is grossly wrong or if I just didn't have the best solution out there. I would like to post my code and get some feedback about it. Before I do, here's a description of a problem: You are given a sorted array of integers, say, {1, 2, 4, 4, 5, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 11, 13 }. Now you are supposed to write a program (in C or C++, but I chose C) that prompts the user for an element to search for. The program will then search for the element. If it is found, then it should return the first index the entry was found at and the number of instances of that element. If the element is not found, then it should return "not found" or something similar. Here's a simple run of it (with the array I just put up): Enter a number to search for: 4 4 was found at index 2. There are 2 instances for 4 in the array. Enter a number to search for: -4. -4 is not in the array. They made a comment that my code should scale well with large arrays (so I wrote up a binary search). Anyways, my code basically runs as follows: Prompts user for input. Then it checks if it is within bounds (bigger than a[0] in the array and smaller than the largest element of the array). If so, then I perform a binary search. If the element is found, then I wrote two while loops. One while loop will count to the left of the element found, and the second while loop will count to the right of the element found. The loops terminate when the adjacent elements do not match with the desired value. EX: 4, 4, 4, 4, 4 The bold 4 is the value the binary search landed on. One loop will check to the left of it, and another loop will check to the right of it. Their sum will be the total number of instances of the the number four. Anyways, I don't know if there are any advanced techniques that I am missing or if I just don't have the CS background and made a big error. Any constructive critiques would be appreciated! #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stddef.h> /* function prototype */ int get_num_of_ints( const int* arr, size_t r, int N, size_t* first, size_t* count ); int main() { int N; /* input variable */ int arr[]={1,1,2,3,3,4,4,4,4,5,5,7,7,7,7,8,8,8,9,11,12,12}; /* array of sorted integers */ size_t r = sizeof(arr)/sizeof(arr[0]); /* right bound */ size_t first; /* first match index */ size_t count; /* total number of matches */ /* prompts the user to enter input */ printf( "\nPlease input the integer you would like to find.\n" ); scanf( "%d", &N ); int a = get_num_of_ints( arr, r, N, &first, &count ); /* If the function returns -1 then the value is not found. Else it is returned */ if( a == -1) printf( "%d has not been found.\n", N ); else if(a >= 0){ printf( "The first matching index is %d.\n", first ); printf( "The total number of instances is %d.\n", count ); } return 0; } /* function definition */ int get_num_of_ints( const int* arr, size_t r, int N, size_t* first, size_t* count ) { int lo=0; /* lower bound for search */ int m=0; /* middle value obtained */ int hi=r-1; /* upper bound for search */ int w=r-1; /* used as a fixed upper bound to calculate the number of right instances of a particular value. */ /* binary search to find if a value exists */ /* first check if the element is out of bounds */ if( N < arr[0] || arr[hi] < N ){ m = -1; } else{ /* binary search to find a value, if it exists, within given parameters */ while(lo <= hi){ m = (hi + lo)/2; if(arr[m] < N) lo = m+1; else if(arr[m] > N) hi = m-1; else if(arr[m]==N){ m=m; break; } } if (lo > hi) /* if it doesn't we assign it -1 */ m = -1; } /* If the value is found, then we compute the left and right instances of it */ if( m >= 0 ){ int j = m-1; /* starting with the first term to the left */ int L = 0; /* total number of left instances */ /* while loop computes total number of left instances */ while( j >= 0 && arr[j] == arr[m] ){ L++; j--; } /* There are six possible outcomes of this. Depending on the outcome, we must assign the first index variable accordingly */ if( j > 0 && L > 0 ) *first=j+1; else if( j==0 && L==0) *first=m; else if( j > 0 && L==0 ) *first=m; else if(j < 0 && L==0 ) *first=m; else if( j < 0 && L > 0 ) *first=0; else if( j=0 && L > 0 ) *first=j+1; int h = m + 1; /* starting with the first term to the right */ int R = 0; /* total number of right instances */ /* while loop computes total number of right instances */ /* we fixed w earlier so that it's value does not change */ while( arr[h]==arr[m] && h <= w ){ R++; h++; } *count = (R + L + 1); /* total number of instances stored as value of count */ return *first; /* first instance index stored here */ } /* if value does not exist, then we return a negative value */ else if( m==-1) return -1; }

    Read the article

  • navigateToUrl AS3 is not opening a web browser

    - by Ronnie
    I have a textField on my stage named 'adBuy', which when clicked I want to open up my browser with the defined in URL request. However when I click on the 'adBuy' textField on my SWF it opens Coda, the piece of software I'm using to write this small piece of code? I am puzzled. Here is my code: adBuy.defaultTextFormat = adFormat; adBuy.textColor = 0xFF65CB; adBuy.x = 640; adBuy.y = 455; adBuy.text = "Buy Now"; parent.addChild(adBuy); adBuy.addEventListener(MouseEvent.CLICK, buyAdvert); var request:URLRequest = new URLRequest("http://www.google.co.uk"); function buyAdvert(event:MouseEvent):void { navigateToURL(request, "_blank"); trace("link clicked"); } Is there an error in my code, or is this a common problem for which there is an answer?

    Read the article

  • public key email encryption

    - by anatak
    Who has their email fully encrypted ? I would like to encrypt my email but I am not sure how to start. If I use encrypted email and I send an email to someone who does not encrypt his email how can the receiver read the email ? What email client would you recommend to run on a windows systems for encrypted email ? I am using Thunderbird at the moment. As I understand you have to generate 2 keys (one public and one private) but how do you generate this key? I also think that you have to put your key somewhere to download but I don't understand how you can trust the downloaded keys. Any links to a good (not too complicated) guide about the working an implementing of email encryption would be very much appreciated. kind regards wim hendrix anatak

    Read the article

  • warning in python with MySQLdb

    - by juanpablo
    hi, when I use MySQLdb get this message: /var/lib/python-support/python2.6/MySQLdb/init.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet I try filter the warning with import warnings warnings.filterwarnings("ignore", message="the sets module is deprecated from sets import ImmutableSet") but, I not get changes. any suggestion? Many thanks.

    Read the article

  • Java: omitting a data member from the equals method.

    - by cchampion
    public class GamePiece { public GamePiece(char cLetter, int nPointValue) { m_cLetter=cLetter; m_nPointValue=nPointValue; m_nTurnPlaced=0; //has not been placed on game board yet. } public char GetLetter() {return m_cLetter;} public int GetPointValue() {return m_nPointValue;} public int GetTurnPlaced() {return m_nTurnPlaced;} public void SetTurnPlaced(int nTurnPlaced) { m_nTurnPlaced=nTurnPlaced; } @Override public boolean equals(Object obj) { /*NOTE to keep this shorter I omitted some of the null checking and instanceof stuff. */ GamePiece other = (GamePiece) obj; //not case sensitive, and I don`t think we want it to be here. if(m_cLetter != other.m_cLetter) { return false; } if(m_nPointValue != other.m_nPointValue) { return false; } /* NOTICE! m_nPointValue purposely omitted. It does not affect hashcode or equals */ return true; } @Override public int hashCode() { /* NOTICE! m_nPointValue purposely omitted. It should not affect hashcode or equals */ final int prime = 41; return prime * (prime + m_nPointValue + m_cLetter); } private char m_cLetter; private int m_nPointValue; private int m_nTurnPlaced;//turn which the game piece was placed on the game board. Does not affect equals or has code! } Consider the given piece of code. This object has been immutable until the introduction of the m_nTurnPlaced member (which can be modified by the SetTurnPlaced method, so now GamePiece becomes mutable). GamePiece is used in an ArrayList, I call contains and remove methods which both rely on the equals method to be implemented. My question is this, is it ok or common practice in Java for some members to not affect equals and hashcode? How will this affect its use in my ArrayList? What type of java Collections would it NOT be safe to use this object now that it is mutable? I've been told that you're not supposed to override equals on mutable objects because it causes some collections to behave "strangely" (I read that somewhere in the java documentation).

    Read the article

  • What software should I install on a new PC?

    - by Armentia
    What software would be a good idea to get for a new/freshly reformatted PC? Feel free to rank how vital each piece of software is, as well as possible alternatives. Microsoft Office Suite // OpenOffice is the first thing to come to mind, but things such as .net framework doesn't pop up to mind and things of that nature are a pain to deal with later on in certain situations.

    Read the article

  • UML Class Relationships

    - by 01010011
    Hi, I would like to confirm whether I am on the right track when identifying common UML class relationships. For example, is the relationship between: 1 a stackoverflow member and his/her stackoverflow user account categorized as a composition relationship or an aggregation relationship? At first I thought it was an association because this member "has a" account. However on second thought, I am thinking its composition because each "part" (user account) belongs to only one whole (user) at a time, meaning for as long as I am logged into stackoverflow, I have to use this one and only account until I log off. If I log back onto stackoverflow with a different account then its composition again. Do you agree? 2 a database and a person's user account an aggregation relationship? I think so because 1 database (the whole) can store 0...* number of user accounts (the parts) but another database can store the same user accounts. Finally, can anyone recommend a website that specializes in designing code using UML? Thanks in advance

    Read the article

  • Protect Windows folder without encrypting the contents

    - by Jad
    Hi, I want to protect the "www" folder in my Apache server. Checked some tools on the net like TrueCrypt, FolderEncrypt etc. All these encrypt the folder contents. If the www folder is encrypted, then my php won't work. Is there a way to lock the folder in windows without encrypting its contents.[ A little harder to crack then no lock at all] Regards Jad

    Read the article

  • Language+IDE for teaching high school students?

    - by daveagp
    I'm investigating languages and IDEs for a project involving teaching high-school students (around grade 11). It will teach basics of programming as an introduction to computer science (e.g., including how numbers/strings/characters are represented, using procedures and arrays, control flow, a little bit of algorithms, only very basic I/O). The non-negotiable requirements for this project are: a free up-to-date cross-platform IDE (Win & Mac incl. 64-bit) with debug a compiler where it's easy to learn from your mistakes together with the IDE, a gentle installation+learning curve So far, the best options I see are the following. Are there others I should know about? I am giving a short explanation with each one to generally show what I am looking for. In order from most to least promising: Pascal + FreePascal IDE (it seems a little buggy but actively developed?) Python + Eclipse + PyDev (good but features are overwhelming/hard to navigate) Groovy + Eclipse ('') Python + IDLE (looks unnatural to do debugging, to me) Pascal + Lazarus (IDE overwhelming, e.g. not obvious how to "start from scratch") Preferably, as a rule of thumb, the language should be direct enough that you don't need to wrap every program in a class, don't need to reference a System object to println, etc. I tried a little bit to see if there is something in JavaScript or (non-Visual) Basic along the lines of what I want, but found nothing so far. I would say that C/C++/C#, Java, Ruby, Lisp, VB do not fit my criteria for languages for this project. To reiterate my questions: are any of those 5 options really awesome or un-awesome? Are there other options which are even MORE awesome? Anything for Basic or JavaScript which meets all of the criteria? Thanks!

    Read the article

  • Git branch unknown to local clone

    - by Rimian
    I have a git repository with two branches. If I clone my repo I can only see the master branch. I have both branches up to date. The problem is I don't fully understand merging and branching. Darn it! My example can be seen here: http://github.com/rimian/rimian/network Can anyone tell me how to get this back to normal?

    Read the article

  • Force copy files off CRC error filled hard drive

    - by TheLakersHighlights
    So I got a dying Western Digital hard drive here and I have a new Western Digital hard drive to transfer all the data to. I have the new HDD hooked up by a SATA to USB. I want to transfer all the pictures, etc to the new HDD. I am unable to because of the CRC error. I have ran chkdsk /f /r and it didnt work because the drive is just simply dying. What tool will let me bypass CRC and continue on with the copying? OS: Vista Home Prem. 32bit

    Read the article

  • How do I left join tables in unidirectional many-to-one in Hibernate?

    - by jbarz
    I'm piggy-backing off of http://stackoverflow.com/questions/2368195/how-to-join-tables-in-unidirectional-many-to-one-condition. If you have two classes: class A { @Id public Long id; } class B { @Id public Long id; @ManyToOne @JoinColumn(name = "parent_id", referencedColumnName = "id") public A parent; } B - A is a many to one relationship. I understand that I could add a Collection of Bs to A however I do not want that association. So my actual question is, Is there an HQL or Criteria way of creating the SQL query: select * from A left join B on (b.parent_id = a.id) This will retrieve all A records with a Cartesian product of each B record that references A and will include A records that have no B referencing them. If you use: from A a, B b where b.a = a then it is an inner join and you do not receive the A records that do not have a B referencing them. I have not found a good way of doing this without two queries so anything less than that would be great. Thanks.

    Read the article

  • Random JSON Generator

    - by Gjorgji
    Hi, I need a tool which generates random JSON objects. I want to use this tool to do testing on my HTTP POST requests and use the random JSON object in it. Any suggestions?

    Read the article

  • jQuery autocomplete function, how to add support for words not available in the database yet?

    - by Lyon
    Hi, I'm looking to implement a tag system like how SO uses on their site, where users can specify multiple tag words. However, on top of all the other autocomplete functions available as jquery plugins, I also want to allow users to enter new words not in the database. Does anyone know of any plugin that can do that? Or if there isn't, how one can add that functionality to an existing autocomplete function? I'm exploring Drew Wilson's autosuggest plugin at the moment, as it supports multiple tags well: http://code.drewwilson.com/entry/autosuggest-jquery-plugin Any help appreciated! Thanks :)

    Read the article

  • XCode Developer Documentation crashes after clicking any link on the startup screen

    - by Noah Sussman
    I just installed XCode 3.2.1. When I open the Developer Documentation and click any link on the startup screen, XCode crashes. Has anyone run into this problem? Also hints as to how to debug would be excellent -- I've only been using XCode for a week. I can still get into the documentation if I open some code and then right-click a symbol and choose "Find in Documentation." But its annoying that I can't just open the docs and browse them.

    Read the article

  • Cached/offline maps for iPhone?

    - by Konstantin
    I'd like to use use maps in my application, so that there will be as less as possible traffic. Perfect solution would be caching of map slices. I know it's not possible with google maps (license). I took a look on OpenStreetMaps and it seems as good solution. The next: SDK. The only one I've found is from CloudMade. The problem is, I found no related API methods for caching/offline calls. Are there any alternative solutions?

    Read the article

  • Update EntitySet<> LINQ to SQL references

    - by gtas
    I know that when attaching an entity into a DataContext you have to also attach the related referenced objects manually too. While I'm attaching the EntityRef<'s everything works as expected and my entities are updated to the database. But i have noticed that a problem occurs while trying to attach the EntitySet<'s. I dont use rowversion columns so I'm attaching for every entity on the EntitySet< using original values. Tried just attaching AttachAll() the EntitySet< with no luck and no exception too. There is no exception but the update is not really happening. What am i missing?

    Read the article

  • Javascript: prototypeal inheritance and the prototype proprity

    - by JanD
    Hi, I have a simple code fragment in JS working with prototype inheritance. function object(o) { function F() {} F.prototype = o; return new F(); } //the following code block has a alternate version var mammal={ color: "brown", getColor: function(){ return this.color; } } var myCat = object(mammal); myCat.meow = function(){return "meow";} that worked fine but adding this: mammal.prototype.kindOf = "predator"; does not. ("mammal.prototype is undefined") Since I guessed that object maybe have no prototype I rewrote it, replacing the var mammal={... block with: function mammal(){ this.color="brown"; this.getColor = function(){return this.color;} } which gave me a bunch of other errors: "Function.prototype.toString called on incompatible object" and if I try to call _myCat.getColor() "myCat.getColor is not a function" Now I am totally confused. After reading Crockford, and Flanagan I did not get the solution for the errors. So it would be great if somebody knows... - why is the prototype undefined in the first example (which is foremost concern; I thought the prototype of explicitly set in the object() function) - why get I these strange errors trying to use the mammal function as prototype object in the object() function?

    Read the article

  • how to use variable name with image tag

    - by drake
    my controller uses code like this: if params[:commit] == "Submit" this used to work fine when I just had buttons. however, now I am using images as buttons like below: <%= image_submit_tag 'butons/Add-08.png', :class => 'image-button-submit' %> How can I pass the commit variable with value Submit along with this image_submit_tag?

    Read the article

  • Why not port Linux kernel to Common Lisp?

    - by rplevy
    Conventional wisdom states that OS kernels must be written in C in order to achieve the necessary levels of performance. This has been the justification for not using more expressive high level languages. However, for a few years now implementations of Common Lisp such as SBCL have proven to be just as performant as C. What then are the arguments against redoing the kernel in a powerfully expressive language, namely Common Lisp? I don't think anyone (at least anyone who knows what they are talking about) could argue against the fact that the benefits in transparency and readability would be tremendous, not to mention all the things that can't be done in C that can be done in Lisp, but there may be implementation details that would make this a bad idea.

    Read the article

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