~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

@00Gambit:

If it helps to motivate you, I was a gaming and anime addict long time back (before I had a programming career). These days I have a full-time programming job. I still haven't given up on games/anime but the addiction is no longer around. I make it a point to spend at least some time helping out other folks on forums, learning new things and so on.

I wouldn't really consider myself a very "strong-willed" individual, so if I can break out of the addiction and set my goals to learn something new every once in a while, I'm pretty sure you can do it too!

00Gambit commented: Thanks +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Start hacking on websites like https://www.hackerrank.com/ which give you opportunities to solve problems using your favorite programming language. Trying to work towards a problem will teach you a lot about the different data structures and algorithms.

You gain points and improve in rank as you keep solving problems so that might be one of the motivating factors. I know problem solving doesn't interest everyone but just mentioning in case you might find it interesting.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You have got nothing to be ashamed of. Like mentioned elswhere, it's just your preference. If you have seen my posts on the subject of other Q/A sites, you will know that I am a big fan of the SO concept. It is indeed a revolutionary thing which has happened to the developer community by providing answers to almost all trivial/moderately difficult questions on a single website.

But, I still post to Daniweb because it operates in a completely different manner as opposed to SO. I remember helping a guy long time back solve his problem which spanned around 10 forum pages! This is something which you would absolutely not see in SO; it's a "targeted" Q/A site with no room for subjective opinions/questions. I would say Daniweb has a less "mechanical" feel given that it promotes discussions as opposed to a single correct answer.

The above is of course my personal view of things but to back it up, I have been a prolific contributor to both the sites at different points in time. I have a pretty good rep on SO (13K or so) and a co-admin on this site.

You really need not pick one or the other, just do what you feel comfortable with and enjoy the most. Good luck.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

When I joined Daniweb, my main interest was in helping and learning C/C++ which meant a lot of interactions with the forum regulars which included Dave. I learnt a lot from him: not just about programming but also about how to help beginners push their boundaries and think about problems rather than rote learning. Dave is one of those few people whom I owe my current level-headed posting nature to.

He was always up for a political debate and very keen about Indian democracy. I remember exchanging PM's with him about the state of politics in India, Indian culture, the political issues etc.

He was a IRC regular and talked a lot about his family, work and a lot of other stuff. The fact that he never mentioned his illness to me or to anyone on IRC or forums proves how strong willed & thoughtful he was. Like most of the people here, I never met him in real life but would never forget the impact he had on his friends and in growing the forum.

Link to the original Dave Sinkula thread for those who really want to understand the kind of impact Dave had on this community.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I would like to recommend Ene Uran who has been with Daniweb for a long time now and has contributed to Python/Geek's Lounge forums.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I really don't mind it as long as it's just one size bigger than the actual answer text.

I think the bigger problem is identifying what's the question/who is asking it etc. Daniweb is one of the few forums I have seen that has a lot of "stuff" between the question title and the actual content. Look at any other forums like dreamincode, SO and so on. You have the question title which is immediately followed by a description/actual question. Or in case of some forums it's followed by small buttons or links. In the case of Daniweb, we have the title followed by a lot of free space and then a row of pretty big buttons.

Not to mention the way reputation is shown for OP is different when compared to the actual answers. Wouldn't having a special highlight/border solve the issue?

Just a thought, I'm not exactly claiming that this might be the reason but I wouldn't disagree if someone claims that this forum is unfamiliar, something which is what you should really aim for (familiarity) so that people hopping between forums feel right at home as opposed to confused.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You should really not use a "file" for this use case. Look into in-memory (and optional persistence) solutions like Redis to increment counters. These things will be atomic and managed by Redis.

If all this needs to be "in-memory" and you want to keep it simple, you can just go with ConcurrentHashMap. If you need persistence, it has to be a database of sorts (relational db, key value db etc.). This is so that atomicity in terms of persistence can be handled by a "robust" solution instead of doing it at code level.

Also mildly related and interesting, the XY problem. If you had included the "musical awards scenario" in your initial post, it would have been much easier to directly suggest a better solution. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Updated the main post with:

  1. Change all old Java 6/7 links with Java 8
  2. Added mention about mocking and the mockito library
  3. Removed old/unreachable links and resources from pre-Java 1.5 times
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

For me it's Dragon Nest; fast-paced action based MMO FTW!

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Given that I'm a programmer by profession, easily around 10 hours.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

In it's simplest form, a RMI load balancer would be a just another RMI server which would have references/handles to other RMI servers providing a service. As an example, let's say you have an adder service:

public interface Adder {
  int add(int a, int b);
}

Along with having RMI servers which implement the above interface, you will also make your "new" load balancer RMI service implement the above interface. This way, the client doesn't care if it's directly hitting the adder service or a load balancer.

When the load balancer starts up, it initializes all the "worker" RMI services (basically references to one-or-more of your adder services) in a loop based on some predefined (or configurable) worker count. When a request comes in, you check which of the adder services are free and dispatch a request to it and wait for the result. If none of the servers are free, you may either "queue" the request in the balancer or send the request to a non-free service anyways and let the RMI service concurrency handling mechanism take care of the queuing.

The devil is in the details though...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

In case it helps, it has somehow magically started working. Since the results are loaded using Javascript, one possibility might be the server not returning back the results (in time at least) using the API call which gives us the impression that search is not working...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That might be the reason; you can simply use a static block in the class to load/call stuff at the time class is loaded. Though I think setting this in code is the wrong approach and the correct way would be to handle these things when deploying your code (for e.g. in the startup script/bat file/shell script which spawns the server and client).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Just use bcrypt, much easier. Also, I'm not really aware of what the project really demands so can't comment on what is OK and what's not. Just for the record, implementing secure sockets is much more involved than doing authentication which might not be what your projet demands. As always, speak with your instructor on what is more important and proceed accordingly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

When it comes to security, the more your rely on advanced libraries, the better for you. I don't like the site linked by James because there is too much to do. Ideally, for a "real" thing, you would just pick up a library like bcrypt in Java and let the library specialized for password management take care of the salt generation and comparison.

Take a look at this SO question for how simple it is to check passwords using a library/algorithm recommended by security experts (just search around for bcrypt).

Also, are you using a secure connection (SSL instead of just plan sockets)? If not, the entire point of hashing is moot because no matter the strength of the password generation/checking algorithm, if you are sending across passwords in plain text, you are doomed anyways...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Since you need to start and stop the server, you might actually need two servers -- an admin server and a print server. The admin-server manages the print server and the client only sees the "admin" server which acts on the admin commands and passes on the rest of the commands to the actual print server.

It seems like a weird design to have normal clients have access to "admin" functions on the server. A more logical design will be to have two GUIs -- an admin UI and a usual client UI. The client can queue/un-queue/restart jobs etc. but when it comes to adminnistering the actual server, you use the admin-console/UI which would require admin credentials. The admin UI will be directly hooked to the admin-server (which in turn still controls the print server as mentioned in my previous suggestion). The client UI will directly interact with the print server but will have access to limited actions.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are using Derby in server-mode (as evident from the host/port in the connection URL). You need to use it in embedded mode.

Read: http://db.apache.org/derby/integrate/plugin_help/derby_app.html and
http://www.codejava.net/java-se/jdbc/connect-to-apache-derby-java-db-via-jdbc

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

All,

We have some unfortunate news which was confirmed by Dani and Prit. Our good old friend, Melvin aka Ancient Dragon passed away on Aug 21, 2014. :`(

His obituary can be found here (link courtesy of Prit).

Those who have been here for a long time and those who lurk in the Software Development forums would surely know of his contributions and the impact he made on the community as a whole. He loved gaming and was passionate about programming and helping out others.

RIP Mel, you and your contributions will surely be missed...

.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Even if the processor has a single core, newer Operating systems (not DOS for sure) employ preemptive scheduling which gives the "illusion" of threads running in parallel. Also, even if there is just a single core, the preemptive scheduling means that threads would run in "random" order as scheduled by the OS.

In short, one guaranteed way of printing your output would be to start up the first thread after your second thread is done. Or use synchronization primitives to ensure that first thread always "blocks" until the second one is complete.

EDIT: Also priority is just a "hint" to the OS and is interpreted in an OS specific way. There is "no guarantee" that a thread with higher priority will execute completely before giving way to a thread with lower priority. Read this

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I'm not sure I understand. You asked "what's the 3rd main" to which the answer was "it's the thread-group name". To which you then wrote "i think it is a process name in which the thread is create is it write".

To answer the last statement, no, it's not the process name but the thread group name as mentioned in my previous post.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Although usernames often include multibyte chars, do passwords also share this catholicism? Genuinely curious.

That's a very interesting/good question actually. Since I had a bit of free time, I tried randomly creating accounts on famous websites. I noticed that reddit, facebook and namecheap allow for Japanese passwords (so safe to assume other global languages are also supported). On the flip side, Yahoo and Gmail/google restrict you to ASCII character set.

So to conclude, there are some big corporations who don't support unicode passwords. Also interesting to notice that almost all global social networks allow for unicode passwords. So I would say it really depends on the domain of your application. If there is a need for it, go for unicode passwords but if you can get away with restricting to ASCII, much easy for you. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Not sure why you are restricting yourself to ASCII by putting in validate calls? Can't PHP deal with unicode chars (e.g. German, Russian passwords)?

diafol commented: good point +15
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAIK you can attach rules to Test suites. So all you would need to do is "group" your tests logically into suites based on whether they need a timeout or not and then apply a timeout rule to the suite.

Or you can create a parent class for performance sensitive tests with a particular timeout rule and make sure all tests which need to follow a particular timeout extend this parent class.

Not ideal but much better than adding timeouts to each and every test...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That's the thread group name. Always consult the sources when in doubt.

Thread#toString

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

but there is a problem read() return -1 and we assign it to char c

Because you need a value to denote EOF/EOS which is not a valid char. Since -1 is not acceptable for a char (char is unsigned after all), read() returns an int.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I believe your problem is more suited to a "job queue" library rather than trying to implement monitoring, scheduling etc. on top of a raw process pool. Take a look at Celery which implements a job queue + provides monitoring facilities.

http://www.celeryproject.org/

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

My personal vote would go to WinPython because:

  1. It provides debugging support
  2. Build in linter
  3. Good autocompletion
  4. A complete bundle which includes an IDE (Spyder) and libraries like numpy, scipy and matplotlib
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

some nice person can test HiHe's multiprocessor-decorator version on a Unix box.

It works fine on a *nix box (as expected)

sos@ubuntu_14.04:~/personal$ python test.py 
counting 0
hello
counting 1
counting 2
counting 3
world
counting 4
counting 5
counting 6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Can I choose my own IP and any non-dedicated port number such as 88888 and 88889?

You can't have 88888 as your port number. Quoting wikipedia:

A port number is a 16-bit unsigned integer, thus ranging from 1 to 65535 (for TCP, port number 0 is reserved and can't be used. For UDP the source port is optional and a value of zero means no port)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I'm not sure about the purpose of this exercise but if it is learning more about generics, it would be much better to implement your own wrapper types instead of fighting with the type system. As a simple example:

public class GenericTest {

    public static void main(String[] args) {
        GenericArithmetic<RichInt> gai = new GenericArithmetic<>();
        RichInt addRes = gai.add(RichInt.of(100), RichInt.of(400));
        System.out.printf("Result of adding integers => %s%n", addRes);

        GenericArithmetic<RichDouble> gad = new GenericArithmetic<>();
        RichDouble subRes = gad.subtract(RichDouble.of(100.8), RichDouble.of(50.3));
        System.out.printf("Result of subtracting doubles => %s%n", subRes);
    }

}

interface Numeric<T> {
    T plus(T other);

    T minus(T other);
}

class GenericArithmetic<T extends Numeric<T>> {
    public T add(T first, T second) {
        return first.plus(second);
    }

    public T subtract(T first, T second) {
        return first.minus(second);
    }
}

class RichInt implements Numeric<RichInt> {
    private int i;

    private RichInt(int i) {
        this.i = i;
    }

    public static RichInt of(int i) {
        return new RichInt(i);
    }

    @Override
    public RichInt plus(RichInt other) {
        return RichInt.of(this.i + other.i);
    }

    @Override
    public RichInt minus(RichInt other) {
        return RichInt.of(this.i - other.i);
    }

    @Override
    public String toString() {
        return String.format("%s(%s)", "RichInt", i);
    }
}

class RichDouble implements Numeric<RichDouble> {
    private double d;

    private RichDouble(double d) {
        this.d = d;
    }

    public static RichDouble of(double d) {
        return new RichDouble(d);
    }

    @Override
    public RichDouble plus(RichDouble other) {
        return RichDouble.of(this.d + other.d);
    }

    @Override
    public RichDouble minus(RichDouble other) {
        return RichDouble.of(this.d - other.d);
    }

    @Override
    public String toString() {
        return String.format("%s(%s)", "RichDouble", d);
    }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

RMI applications are not as simple as standalone Java applications since they require specific steps to be followed (specifying the policy file etc.). You have provided absolutely no details as to the command line used to invoke the client, the client code and so on.

I would recommend starting with the official tutorial which highlights the steps to be followed when setting up the RMI server and client.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Sure, but that defeats the purpose of the generic arithmetic class. Let's suppose I create the above GenericsArithmetic class with type parameter as Byte. How would you know which conversion method to use inside the generic add method? My point being, without ugly casts and instanceof checks, it's pretty much impossible to implement a typesafe generic adder without "wrapping" the existing Number type and providing type-safe wrappers.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This really isn't possible given that the Number interface doesn't expose arithmetic methods so even though you can write a GenericArithmetic class which takes only instance of numbers, you can't do implement the operations without casting based on the types passed in.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Sorry to say, but the output using Windows 8.1 is not the desired one. All you get is:

Are you running this from the command line or some sort of an IDE? It works fine for me on Windows 8.1

D:\misc>python test.py
counting 0
hello
counting 1
counting 2
counting 3
world
counting 4
counting 5
counting 6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Multiprocessing on Windows does work, but is a bit crippled when compared to multiprocessing on *nix. For e.g., the following code snippet works fine on Windows:

from __future__ import print_function
import time
import functools
import multiprocessing

def runFuncInMp(func, *args, **kwargs):
    p = multiprocessing.Process(target=func, args=args, kwargs=kwargs)
    p.start()

def counter(n):
    """show the count every second"""
    for k in range(n):
        print("counting %d" % k)
        time.sleep(1)

if __name__ == '__main__':
    # start the counter
    runFuncInMp(counter, 7)
    time.sleep(0.9)
    print('hello')   # prints hello, before counter prints 1
    time.sleep(3)
    print('world')   # prints world, before counter prints 4

Notice the removal of the decorator and adding in the if __name__ == '__main__' check.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As someone who has interviewed for financial organizations and has been involved with setting up an entire team, I really don't care about the degree as long as the candidate has:

  1. The right skillset
  2. Humility
  3. Desire to learn a bit more

As an example, is there any reason to not consider a junior candidate who has a good grasp of the relevant data structures (lists, stack, queues, maps) and algorithm techniques just because he/she doesn't have a CS degree? I personally don't think so.

Though I must say that the unfortunate reality is such that some big companies put a threshold on "who" can apply for their positions due to some arbitrary standards set by the hiring/management committee. Thankfully, this is not a norm and most of the organizations are content with candidates having the relevant experience and skills.

iamthwee commented: true +14
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

OP, are you talking about creating something like IDEOne which is an "online compiler" and allows executing code remotely (or in the "cloud" as you put it)? If yes, that should be a doable project wherein you provide a web interface to your users for putting in code and submitting the code executes it in a sandboxed environment. A challenging project for sure but definitely easier than "creating" compiler in Java for all the languages...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

In language-agnostic terms, an interfaces determines "what" and the implementers determine "how".

For e.g. if you have an interface Moveable with a method move, it tells you "what" is to expected from something which is a moveable viz. the ability to move. As to "how" that can be done, it depends on "who" is moving.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

From my understanding, generic class is for handling a range of types of incoming object class. So comparison part will be very tricky because one needs to determine the domain and range of the data and how to compare them. If the domain and range are narrow (and specific), implementing the class to be generic is not worth the time because it is not really a generic class...

This is the reason we have interfaces like Comparable. It doesn't matter what your class is; as long as you are satisfying the Comparable contract, two objects of that type can be compared. This is how classes like TreeSet work under the hood; they are generic even though it requires comparing two objects before deciding their location in the tree. Since generic type parameters can have bounds, it's very much possible to have generic containers which allow storage of arbitrary types as long as the type implements the Comparable interface....

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Because I'm also not too familiar with java the only thing that forced me to change from VB.NET to Java was the ability to support multi-threading

Not sure why you say that...The CLR (on which VB.NET runs) is perfectly capable of creating threads. But I agree, since you are talking about "server" application, Java fits the role much better than VB.NET.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No, because with Java you can create keyloggers for "Java applications". You would need to implement some sort of Windows API hooks if you want to intercept keystrokes across all applications (at the OS level), which is what keyloggers which we all know of are supposed to do.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This is a typical map-reduce problem. You map the files you read and create intermediate data structures (dicts in this case). And after all the files have been read, you "reduce" the intermediate data structures to create a final data structure. Why do you think anything has to be read twice unless you mean to say that reading the hashmap created out of the file is the same as "reading the data twice". :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The biggest point is about consistency. I really don't give a damn what someone uses as long as no one on the team is affected by what they use. For e.g. Eclipse has style/formatting rules which dictate whether you use tabs or spaces, wrap happens at xxx char count, particular style of brace placement etc. If everyone in the team is using Eclipse, it's simple to import these rules but someone working in a non-Eclipse IDE/editor has to do these things manually or write macros and what not.

It would be totally unacceptable for me if someone checks in code in a completely different format just because they were using their favorite text editor. It would also be unacceptable if that person spends 30/60 mins everyday messing around with custom configurations to ensure consistency is maintained because that's 30/60 mins off time the member could have been productive...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This means that there is an extra layer of indirection on top of everything

Almost everything; this doesn't apply to method scoped primitives which are allocated on the stack.

which also implies some amount of version compatibility headaches

Do you have examples for this? Code written for JDK 1.1 works on the JDK 8 with pretty much no changes.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That's like telling him he can't use his own chair.

I disagree; that's more like saying you can't come in denims when the rest of the team comes to office in formal wear because that's the "dress code". I would seriously doubt the expertise of a programmer who insists on using IntelliJ because that's what he has been using in his previous company and doesn't want to switch to Eclipse because he would have to learn new key bindings.

Just to clarify, if you are working on your own, use whatever you feel like using (yeah Notepad, I'm looking at you). But in a team setting, please don't be the one who insists on using Emacs when everyone else is using IntelliJ or Eclipse.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

but it only opens the browser--firefox only--for a second, fills out the iframe, and then automatically closes.

I believe this is because the context manager in this case destroys the browser instance the moment it goes out of scope (i.e. as soon as you exit the with block). You can test this out by removing the with block and using your code like:

browser = Browser()
browser.visit(url)
# other stuff
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I would personally use something like Eclipse/IntelliJ because it "just works" out of the box and makes it easy to navigate complicated projects. Sure, you can use your Vim'fu to do all the same stuff I'm not a big fan of carefully tweaking each and every aspect of an "editor" to make it work like an "IDE".

And mind you, this is coming from someone who uses Emacs in Viper mode for his text editing needs...

JeffGrigg commented: Yep! +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There are two main problems with your above approach:

  1. Using the wrong datastructure
  2. Needless repeated computationss burning the CPU

Contains check on a List data structure is expensive due to its O(n) nature and should be avoided; prefer using a Set variant like HashSet.

The needless computation aspect of this problem is very similar to when you are recursively computing factorials. If you want 5! and you are using the naive approach, you end up computing stuff needlessly an exponential number of times. Try tracing the recursive call 10! on a piece of paper to understand more.

If you log the values passed to the method getNextStone, you'll see it getting called countless times for the same set of inputs. The solution here is to use memoization and remember the result of the computations instead of getting into the recursive death spiral. A small change to your code and it now runs pretty fast IMO.

// Java 8 specific code; you might have to change it
class Solution {

    private static HashSet<Integer> listPossibleValues;

    private static HashSet<String> alreadyComputed = new HashSet<>();

    private static int maxStone;

    private static int cnt = 0;

    public static void main(int n, int a, int b) {
        long start = System.nanoTime();
        getPossibleLastValue(n, a, b);
        System.out.printf("It took %s milliseconds for naive approach%n%n", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
    }

    private static void getPossibleLastValue(int n, int a, int b) {
        maxStone = n;
        listPossibleValues = new HashSet<Integer>();
        int stone = 0;
        getNextStone(stone, 0, a, b);
        System.out.println(listPossibleValues.stream().sorted().collect(Collectors.toList()));
        System.out.printf("Count=%s%n", cnt);
    }

    private …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Very strange for you to bring this up; I had the same thing happen to me on Friday when I navigated to the watched article page. I thought "no way Daniweb could have caused this" but now I'm curious. ;)