This is my class Debugger. Can anyone try and run it and see whens wrong? Ive spent hours on it already. :(
public class Debugger {
private String codeToDebug = "";
public Debugger(String code) {
codeToDebug = code;
}
/**
* This method itterates over a css file and adds all the properties to an arraylist
*/
public void searchDuplicates() {
boolean isInside = false;
ArrayList<String> methodStorage = new ArrayList();
int stored = 0;
String[] codeArray = codeToDebug.split("");
try {
int i = 0;
while(i<codeArray.length) {
if(codeArray[i].equals("}")) {
isInside = false;
}
if(isInside && !codeArray[i].equals(" ")) {
boolean methodFound = false;
String method = "";
int c = i;
while(!methodFound) {
method += codeArray[c];
if(codeArray[c+1].equals(":")) {
methodFound = true;
} else {
c++;
}
}
methodStorage.add(stored, method);
System.out.println(methodStorage.get(stored));
stored++;
boolean stillInside = true;
int skip = i;
while(stillInside) {
if(codeArray[skip].equals(";")) {
stillInside = false;
} else {
skip++;
}
}
i = skip;
}
if(codeArray[i].equals("{")) {
isInside = true;
}
i++;
}
} catch(ArrayIndexOutOfBoundsException ar) {
System.out.println("------- array out of bounds exception -------");
}
}
/**
* Takes in String and outputs the number of characters it contains
* @param input
* @return Number of characters
*/
public static int countString(String input) {
String[] words = input.split("");
int counter = -1;
for(int i = 0; i<words.length; i++){
counter++;
}
return counter;
}
public static void main(String[] args) {
Debugger h = new Debugger("body {margin:;\n}");
h.searchDuplicates();
}
}
I'm working on my first Ruby on Rails aplication and it's quite big (at least for me ;) - database has about 25 tables). I'm still learning Ruby and Rails and I never wrote anything in Javascript nor Ajax.
Should I add Ajax to my application from the begining? Or maybe it will be better to add it latter?
Or in the other words: is it (relatively) easy to add ajax to existing web application?
Hi,
Laying out the verticies in a DAG in a tree form (i.e. verticies with no in-edges on top, verticies dependent only on those on the next level, etc.) is rather simple. However, is there a simple algorithm to do this that minimizes edge crossing? (For some graphs, it may be impossible to completely eliminate edge crossing.) A picture says a thousand words, so is there an algorithm that would suggest:
instead of:
A popular editor uses highlighting to help programmers avoid using C++ keywords in Java. The following words are displayed using the same colors as a syntax error:
auto delete extern friend inline redeclared register signed sizeof
struct template typedef union unsigned operator
Why would this be considered important?
Given this code:
String test() {
try {
return "1";
} finally {
return "2";
}
}
Do the language specifications define the return value of a call to test()? In other words: Is it always the same in every JVM?
In the Sun JVM the return value is 2, but I want to be sure, that this is not VM-dependant.
I have a regular expression "^[a-zA-Z+#-.0-9]{1,5}$" which validates that the word contains alpha-numeric characters and few special characters and length sould not be more than 5 characters.
How do I make this regular expression to accept a maximum of five words matching the above regular expression.
I heard some people complaining about including the windows header file in a C++ application. They mentioned that it is inefficient. Is this just some urban legend or are there really some real hard facts behind it? In other words, if you believe it is efficient or inefficient please explain how this can be with facts.
I am no C++ Windows programmer guru. It would really be appreciated to have detailed explanations.
I'm analyzing heap dumps in a Portal App.
With the help of OQL I found the MemorySessionData Object with its address.
Now I want to find all SerializableViewState Objects, that are hold by Objects hold by this MemorySessionData object.
In other words: My MemorySessionData Object holds several objects, these hold objects again and so on... I want to find all SerializableViewState Objects in this tree.
How would the OQL look like? :-/
When I invoke add() on a tarfile object with a file path, the file is added to the tarball with directory hiearchy associated .In other words, if I unzip the tarfile the directories in the original dir hiearchy are reproduced.
Is there a way to simply add a plainfile without directory info that untarring the resulting tarball produce a flat list of files?
Is there some kind a engine for Json in the Zend framework, What I mean is some abstraction that all the Json (ajax) responces go through ?
in other words some class to controll all the Ajax calls?
I am writing a windows forms application in C# and I create a RichTextBox (via code, not the designer). I am setting the AutoWordSelection property to false, but when I highlight stuff in the box, it still jumps to the boundaries of words, plus a space. Is this a flaw in .NET or am I doing it wrong?
Take some code like
if (person.IsMale()) {
doGuyStuff();
} else {
doGirlOtherStuff();
}
(Yes, I realize this is bad OO code, it's an example)
Should this be written so that to explicitly check if person.isFemale(), and then add a new else that throws an exception? Or maybe you're checking values in an enum, or something like that. You think that no one will add new elements to the enum, but who knows? "Can never happen" sounds like famous last words.
I am looking for a good dictionary library to translate english words to spanish. Can someone suggest open-source libraries with reasonably comprehensive data.
Hello there,
I am from a networking background and completely new to algorithm and flow charts, so could you please assist me with the following?
Draw flow charts for the following algorithmss:
State whether a number entered at the keyboard is even or odd.
Calculate the mean of a five numbers entered by the user from the keyboard
Count the number of characters and the number of words that are in a text file
Many thanks in advance!
function my_func(a, b){
if(typeof(a) !== 'undefined'){
// do stuff
}
return b;
}
How can I call this function will only the second argument? In other words, I want a to be undefined.
To convince my team mates of the usefulness of design-by-contract, I am looking for well known examples of realistic systems that were built using design by contract. Pointers to realistic, critical evaluations are appreciated.
In other words: what is the best example of a system successfully built using design-by-contract?
Hello,
I'm looking for a library that could perform "easy" pattern matching, a kind of pattern that can be exposed via GUI to users.
It should define a simple matching syntax like * matches any char and alike.
In other words, I want to do glob (globbing) like sun's implemented logic http://openjdk.java.net/projects/nio/javadoc/java/nio/file/PathMatcher.html but without relation to the file system.
Ideas?
Is it possible to extract the ratings (i.e. 5 stars), views and comments of a Youtube video and use it within your own site?
In other words I have a youtube video embeded on my site but i want to include the rating, views and comments of the video. Then use that information to display below video on my own website?
Hope that makes sense!
Cheers
Hi,
where, in your opinnion, should a breadcrumbs path be declared (in other words, in which letter of MVC)? So far I've been declaring it in Controllers, but I've recently started to work with CakePHP, where it is all made in Views and it surprised me.
I'm just curious of your opinions.
If there are more than 2 characters
"Hiiiiiii
My frieeend!!!!!!!"
I need to be reduced to
"Hii
My frieend!!"
Please undestand that in my language there are many words with double chars.
Thnx in advance
kplla