« first day (363 days earlier)      last day (3659 days later) » 

7:00 PM
@SimonAndréForsberg I gotta give your answer an upvote... but I don't know yet about the accept ;)
 
Another alternative to the binary question:
0
A: binary-search vs binary-search-tree

Simon André ForsbergI agree that binary-search-tree is not the same thing as binary-search, there is however, another tag that should be considered: binary-tree - or, as that tag apparently doesn't exist at the moment, simply tree. I think binary-search-tree is a bit overly specific, but I be in favor of creating t...

 
I feel something more fundamental in my structure is wrong
 
@skiwi I don't need upvotes, I need accepts!
 
Probably doesn't help for reviewing either that I switch my implementation every few days :D
 
@skiwi That is also possibly an issue, unfortunately I haven't been able to pinpoint what exactly. However, I feel that you might be creating several things that you don't really need.
 
7:02 PM
Well... I stood up, walked a few meters backwards and looked at my code again earlier on, and it just didn't look the same as when I was sitting right in front of it.
But on a more serious note... What do you think about CardAddedEvent, CardPlayedEvent and CardsSwappedEvent?
 
@skiwi I think you definitely should use events, yes. Haven't I already suggested an event driven approach? :)
 
yes, you did a while ago, but I wasn't ready for it yet then
 
@Mat'sMug: Yeah, I was just kidding
I would never take an identity
 
I hope you are now then :)
 
Does it come at the cost of adding a addCardAddedListener(CardAddedListener x) though?
 
7:09 PM
well time to go, good bye all
 
@Nobody Of course you wouldn't, you're a @Nobody.
 
Or would an addListener do aswell that can accept multiple subtypes of listeners that are applicable on a hand? (I'm sure I could get that to work and would mean less testing)
 
@skiwi No, all you'd need than is a reference to an EventBus, if you go for the Event-approach fully.
 
I looked at it a few days ago, but I don't like the @Event annotations and registering that much
 
@skiwi What do you dislike about registering?
 
7:12 PM
@skiwi You prefer setters?
I suggest you try the real EventBus approach.
 
It's not an easy thing to explain as I don't really know why I dislike it
 
My own project uses an event bus, and I did eliminate one of the things that I used to dislike about that - unregistering.
 
Maybe I should take yet another look at it again
 
In fact, the event bus classes are all in a code review question.
 
@skiwi I will shortly update my Event-driven code on GitHub, which allows easy use of lambdas for events.
 
7:19 PM
Totally unrelated, but I love this "Adaptive AI" on some racing game... I'm driving carefully and perhaps got a bit too slow into a corner, another driver who was 10 seconds behind me comes in and just rams me out of the track
@Donald.McLean You mean one of your questions?
If so, then I found it
 
@skiwi Yes, one of mine. It won't help you though - it's all written in Scala.
Some of the discussions of Java Lamdas go out of their way to be obtuse.
 
It's indeed very hard for me to read
So an event listener basically replaces the system of hardcoded interfaces, etc.
With a bus where you can supply events onto (my Hand class), and 'listeners' which react when such events happen?
Maybe it's not that bad after all
 
@skiwi You put events on the bus where anyone who wants a given kind of event can listen for it.
 
this just gave me a very great idea
annotations can contain any type of objects, right?
 
What do you mean by "contain"?
 
7:34 PM
in the annotation itself
 
show an example
 
Assume an CardAddedEvent, where you have access to cardAddedEvent.getHand(), cardAddedEvent.getCard()
@Event(predicate = cardAddedEvent -> cardAddedEvent.getHand().getSize() > 3)
public void onCardAddedEventConditional(final CardAddedEvent cardAddedEvent) {
    ...
}
 
No. In predicate = xxx, the xxx part must be a constant. Can't be a lambda expression (instance of an interface, i.e. not a lambda expression)
 
:(
 
I think there are better ways in doing what you are trying to do
 
7:38 PM
Annotations can't even be generic so there is a big issue already
 
What exactly are you trying to accomplish - and why?
 
Nothing yet
It's specified by section 9.7 of the JLS. The annotation member types must be one of:

    primitive
    String
    Class
    an Enum
    another Annotation
    an array of any of the above
This would be the issue though
So I think I understand most of it
only thing I fail to understand is how an event bus is synchronous
 
@skiwi I used actors.
 
Or well... maybe I see it
the registered classes for a certain event are known during runtime
and when an event reaches the bus, it immediatly delivers them
 
Of course they are
 
7:47 PM
Don't feel hurt, but I'm trying to come up with my own eventbus system
I have a feeling I will understand it much better then as compared to merely using it
 
@skiwi Why should I feel hurt? I wrote my own.
 
@skiwi Why should I feel hurt? I wrote my own.
 
That idiotic moment when you do rm -rf * on your entire project directory, when you thought you were in a subdirectory.
4
 
That was creepy as hell.
 
Blame @SimonAndréForsberg.
 
7:49 PM
I'm trying to figure out why they do not end on the exact same pixel, while the statements are similar and they do start on the same pixel.
 
I might have copied what @Donald.McLean said there on purpose, yes :)
@syb0rg O u c h !
 
@syb0rg Good thing dropbox or something similar or git always have backups
 
@syb0rg From my experience though, there are a bunch of "undelete" features out there. I've restored some things in the past. If not completely, then at least partially.
 
 
Luckily I used git reset --hard, unluckily I used it one too many times (don't ask why).
 
7:51 PM
@syb0rg My advice. On the computer that it happened on. Unplug it from the internet, shut down all processes so that as few things as possible is changed on the hard drive. Then google for undeleting.
It all depends on how much effort you're willing to spend on it though. Seems like you might have the situation in hand already
 
@SimonAndréForsberg I already kinda recovered the main stuff. I just lost the CMake file that I had spent my entire day on though.
I can recover that from my own knowledge though.
 
If all else fails... cry in a corner
4
I found a small weird thing in your implementation @SimonAndréForsberg
@Retention(value = RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
The value = there is redundant I think?
 
4500+ edits...
7
 
@Jamal Can't give you a life. Have a star instead.
8
 
@SimonAndréForsberg I'm still a bit confused... I am able to get the methods using an annotation easily, but how do I store those methods then for later invocation?
 
8:03 PM
@JerryCoffin YAY STAR
6
 
8:17 PM
LOL I could still become a moderator... superuser.com/election
 
First lol comment on a review of mine I think, codereview.stackexchange.com/questions/48792/…
 
You've earned the "Constituent" badge for an election.
 
@Malachi I really have nothing with those people over there that feel like they are the chosen ones to become a moderator.
 
Hey, me too
 
Like the one with Your wildest dreams will come true. Your job as a moderator is not to change everything that is in place now, it is to guide things as they go now.
 
8:30 PM
TTGH - later @all!
 
laters @Mat'sMug
I forgot about type erasure :(
private static final class Either<U, V> {
    private final U u;
    private final V v;

    private final StoredType storedType;

    public Either(final U u) {
        this.u = u;
        this.v = null;
        this.storedType = StoredType.U;
    }

    public Either(final V v) {
        this.u = null;
        this.v = v;
        this.storedType = StoredType.V;
    }

    private static enum StoredType {
        U, V;
    }
}
Doesn't work
That's why we can't have all good things
 
@skiwi to this
 
@skiwi You're right, value is redundant there. You store the methods by using a List<Method> or similar.
@skiwi What is your Either class trying to accomplish?
 
It was trying to replicate type union
As opposed to storing it in an Object
but now I choose to just use two different mappings
 
8:48 PM
if I can get this person to accept my answer I will get another silver badge [badge:enlightened]
15
A: Stored Procedure logically or coding

Malachiyou have a lot of if statements in your SQL, this screams at me that you are doing something in your SQL that should be done in the application, and that this SQL should be separated into two distinct stored procedures. the benefits faster stored procedures use an actual coding language to d...

 
@Malachi Odd statistic of the day: at least at one time on SO, I had something like 14 accepted answers that would all turn into gold badges if they were un-accepted.
3
 
@JerryCoffin how is that?
 
Well... this is helpful
Incompatible types: V is not a functional interface <- I have nowhere used a V.
 
@Malachi They'd all turn into Populist badges.
 
@JerryCoffin oh nice
 
8:59 PM
Then what have you used, @skiwi?
 
if I can get my answer score up to 20 I will get a different badge as well. it would be the first reversal on CodeReview
 
@SimonAndréForsberg I think I fixed it
A quick check though: A cast from Consumer<T> to Consumer<Object> can never give exceptions, right?
crap, I got a 3 (on a scale of 10) for an exam of 2 or 3 weeks ago...
 
@skiwi Not as far as I know, no.
 
I might have a simple event bus if it works
@SimonAndréForsberg any clue?
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalAccessException: Class com.skiwi.tcg.events.SimpleEventBus can not access a member of class com.skiwi.tcg.main.TCGGame$1 with modifiers "public"
 
9:15 PM
@skiwi code?
 
Pretty much similar to yours
and
private void init() {
    EventBus eventBus = new SimpleEventBus();
    final AtomicInteger counter = new AtomicInteger(0);
    eventBus.registerListeners(new Object() {
        @Event
        public void onTestEvent(final TestEvent testEvent) {
            counter.incrementAndGet();
        }
    });
    eventBus.executeEvent(new TestEvent());
    System.out.println("counter = " + counter);
}

private static class TestEvent {

}
TCGGame$1 is the anonymous class
Which is rather strange... as I believe it is public
 
Ah, the TCGGame$1 is probably not a public class (as it's anonymous). Show the code context of where the exception occurs.
 
method = public void com.skiwi.tcg.main.TCGGame$1.onTestEvent(com.skiwi.tcg.main.TCGGame$TestEvent)
private void invoke(final Method method, final Object object, final Object event) {
    try {
        System.out.println("method = " + method);
        method.invoke(object, event);
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
        throw new RuntimeException(ex);
    }
}
so it can't access anonymous inner classes?
 
before .invoke, do method.setAccessible(true);
 
I see
 
9:18 PM
it can, if you set it to accessible first :)
 
and set it back to what it was again?
or set it to public only once when I am loading in the method handles?
 
There's no need to set it back, it can continue to be accessible (at least that's how I do it)
 
nevermind on that, I can't even get accessability status
Wee, it works!
 
0
Q: Tag Cloud using 2 queries (one nested), and 2 foreach loops: Is there a better way?

Matthew JohnsonI have a database that, among other things, stores publications and publication tags. There is a many-to-many relationship between publications and publication tags. Simply put, I query the database for all the publication tags and the corresponding id. While looping through that query, I have...

0
Q: Better Way to Calculate Golf Score against Course Par in PHP

ConorThis php script will translate shots on 18 holes to a total under par or E which is 0. $course = array(0, 4, 5, 4, 3, 5, 3, 4, 4, 4, 4, 4, 4, 4, 3, 5, 3, 4, 5); if ($totalpar == 0) { $score = 'E'; $played = 0; } else { if(!empty($h1)) { $h1score = $course[1] - $h1; } else { $h1score ...

 
9:39 PM
0
Q: Learning VIM and would like critiques of a map

ErdsBackground I've just started using VIM and have become comfortable with navigation. I'm attempting to reduce repetitive tasks and thought I would take a crack at mapping. I was able to accomplish my task below with a map command, but would like to know what the best way is to do what I am doing....

 
10:28 PM
2
Q: Map command in VIM

ErdsBackground I've just started using VIM and have become comfortable with navigation. I'm attempting to reduce repetitive tasks and thought I would take a crack at mapping. I was able to accomplish my task below with a map command, but would like to know what the best way is to do what I am doing....

^^^ napalming in order
 
Another happy (and new) customer. :-)
 
@rolfl I don't believe in napalm. I believe in carpet bombing (what can I say--I was in the Air Force).
 
@JerryCoffin Fair enough. It's part of the meme.
 
10:43 PM
@Jamal I know--but that meme could stand some review and improvement.
 
fix it ;-)
Hey all.
 
Alright. I have no military experience anyway.
 
Never played Call Of Duty?
 
Me? I have, as well as other related games. I just haven't been in the real military.
 
Meh, people nowdays, if they have played the game, they are qualified to talk the talk.
 
10:46 PM
COD rep-whoring == killing everything that moves
 
@Jamal I've yet to see a game that was anything like (my time in) the real military.
 
I suppose Battlefield and Battlefield: Bad Company are a little closer than CoD.
 
If there was one, nobody'd remember it--be the most boring game ever.
 
0
Q: Implementing the merge sort with only arrays, out of place

KKPThis has been asked a few times here, but I was wondering what I could do to improve the efficiency and readability of my code. My programming skill has gotten rusty, so I would like to elicit all constructive criticism that can make me write code better. #include <iostream> using namespace std...

 
11:03 PM
0
Q: Airline/Hotel reservation system in Python

ArmanI am trying to teach myself OOP in python. I am picking up some projects from github and trying it out on my own. I wrote a Airline/Hotel Reservation System. Where I want to maintain the customer name, id and maintain a record for Airline or Hotel or Both. I am not sure if i my design is correct....

0
Q: Image handling class [Android]

javaLet me start by saying that I am very happy with this code. I want to share it with other people because I think they will find it helpful, but I want to make sure I did everything in good form before I do so. The code allows users to easily manage their image memory. The class handles all of ...

 
11:40 PM
@CaptainObvious Let me start by saying: private ArrayList<Bitmap> images; --> private final List<Bitmap> images;
Will give that one a review maybe later, or maybe tomorrow.
 
0
Q: 2D Sprite animating

CemI tried to make a WPF Application that can animate sprite images. It seems like running smoothly but I wonder if any improvements can be done. If you want the complete code to compile, I can send the solution folder to you. First, user creates a SpriteSheet object (crops the image to get each fr...

 
Heya
 
I think I just answered my first multithreading question with an actual multithreading-focused review!
 
Well done!
 
11:52 PM
0
A: Implementation of Parallel.ForEach

Mat's Mug if (items == null) throw new ArgumentNullException("enumerable"); In the execution path where this exception is thrown, the reported argument name will not match the actual argument name. If this is the result of a rename refactoring (i.e. it's the parameter formerly known as "enum...

^^ from the excerpt it does look like the typical "cosmetic" answer though :/
@SimonAndréForsberg you beat me by 4 tiny little points!
 
4 points is always 4 points :)
Reading your answer now, except another 10 points shortly.
 
trying to get the Bolt Start hat?
 
21
A: Daily vote limit reached; vote again just now

retailcoderThis looks like a pretty good place to hide a hat. Congratulations, you've earned the Bolt Start hat. See your profile. In August 2009 the IAAF announced that from January 2010, a zero-tolerance stance to false-starts would be adopted. Athletes false starting are now immediately disquali...

too late! ;)
 

« first day (363 days earlier)      last day (3659 days later) »