« first day (334 days earlier)      last day (3674 days later) » 

5:00 PM
the parallism level of the forkjoin pool is equivalent to the number of threads? Or not
 
I give up on the hyperlink syntax!
 
@Edward [text](url)
 
@Mat'sMug yeah I tried to start a chat room with him but I couldn't figure out how to invite him to it. Would have to start a long thread of back and forth comments in one of his questions/answers first I tihnk.
 
With 100 million as range it used 42 threads
 
@skiwi How many cores does your CPU have?
 
5:01 PM
4 physical, 8 logical (hyperthreading)
 
hehe
This is @skiwi's computer: southampton.ac.uk/~sjc/raspberrypi
 
@skiwi I gave you the wrong code snippet, no wonder it creates 42 threads for you there...
 
Sexy
@Mat'sMug I know, I'll make a Twitter account and ask him :)
I've avoided Twitter entirely up to this point, but this is importnant
 
@SimonAndréForsberg Might make sense then
 
5:07 PM
		IntStream tstream = IntStream.rangeClosed(1, 100000000);
		Collector<Object, ?, Map<Object, List<Object>>> collector = Collectors.groupingBy(i -> Thread.currentThread());
		Map<Object, List<Object>> coll = tstream.boxed().parallel().collect(collector);
		coll.replaceAll((thread, list) -> Arrays.asList(list.size()));
		System.out.println(coll.size() + " threads was used: " + coll);
try that, @skiwi
 
We have a new user in the #2 position!
2
 
What position
 
Geez do you people do anything else?
 
@SimonAndréForsberg Are you sure I should use 100 million there?
 
5:12 PM
@skiwi Reduce the number if you'd like.
 
@Koveras No.
 
1 million goes quite fast
 
I am expecting it to either cap at thread limit, or at an implicitely set parallelization limit by the parallel()
 
Do you get paid for this?
 
@Koveras No.
 
5:13 PM
Only in reputation points.
 
unicoins. ;-)
 
We get get paid with self-enrichment.
 
@skiwi My guess is that you will only use 4 or 8 threads
 
I'm trying to figure out how to get @rolfl's callable to work
 
Then do you just answer questions all day at work? How do you get work done?
 
5:14 PM
I might need a Supplier<Callable<T>>, not sure though yet
@SimonAndréForsberg It used 8
 
I don't mean to be condescending I really am curious how you make the time
 
Of course, as indicated in an answer, it caps on amount of CPU's
@Koveras I haven't solved that mystery yet ;)
 
@skiwi My point exactly. And if you would have another thread that'd also be starting a parallel stream, those two threads would use the same pool. This makes it possible for one thread to entirely block another thread
 
@SimonAndréForsberg So the 'discovery' here is that no new thread pool is used in another parallallization encounter?
 
@skiwi Exactly.
This is really important to know for multithreaded applications
 
5:17 PM
@Koveras Most of my CR contributions in the past 6 months have been while I was working on Watson (an IBM thing), and I have been doing a lot of performance work with long-running jobs. Submit the job, wait an hour, analayze the results, and repeat. In the wait-an-hour stage, I put out an answer.
 
@rolfl why did you kill your performance answer on the 'merge sort'
 
And I just realized that my test-code needs a whole lot of memory, silly me. No wonder it takes such a painful amount of time. Poor GC.
 
I have only been doing about 3 or 4 answers a day....
 
@rolfl living the good life.
 
@rolfl I wonder, before CR, what did you do then during those 1 hour waiting periods?
 
5:18 PM
Not really, I was doing it all day, every day ... ;) to like 3am, then up again at 5.
 
@Koveras ;)
2
 
@SimonAndréForsberg - that's the thing, I started on SO, and found CR, and stuck... look at my SO graph....
 
@rolfl And before SO?
 
@rolfl that makes sense then, but @Mat'sMug do you not have deadlines?
 
Work....
 
5:20 PM
@rolfl I'm confused now by your `Callable` suggestion, instead of `Consumer`...
What I intend to do is consume a certain argument
 
@Koveras sort of.. but it's already busted, and the project is about to fail miserably because we're trying to make our custom code work with a broken ERP.
 
@SimonAndréForsberg - I managed to get a breakthrough in a performance problem, and in the past 10 days my time has been a bit more relaxed at work. This co-incided with the mod position too.
One of the decisions I had to make was whether my commitment is long-term to CR, and, it is.
2
 
26
Q: How do I lick a plane?

JutschgeA friend of mine told me that I would get an Achievement if I managed to lick the plane that's flying around in the world but he won't tell me how I get close to it. I tried many different things. Jumping on trampolines won't get you high enough and the only thing that looks high enough is the c...

I love Arqade's titles. :-)
 
^^^ only possible if you are a goat.
 
Flag for migration to aviation.stackexchange.com
4
 
5:22 PM
lol
 
Apparently, even as a mod, I am limited to 1 star per second.
> You can perform this action again in 1 seconds
^^^ get the plurals right!
 
My brain, it hurts
    public Duration(final int period, final TimeUnit unit) {
        Objects.requireNonNull(unit);
        this.period = period;
        this.unit = Objects.requireNonNull(unit);
    }
 
^^^ that yours?
 
Appereantly
 
Paste it as a question on CR, we can all score some rep.
 
5:24 PM
hehe
I do want to talk to you about the thing we discussed this afternoon @rolfl
 
The Consumer/Collector/Callable?
 
yes
It was this code I believe
        Files.list(directory)
                .map(UniqueTimePath::new)
                .filter(pathsSubmitted::add)
                .forEach(path -> executor.execute(() -> fileConsumer.accept(path.getPath())));
 
The hell is a goat simulator
 
You haven't missed the new Time API, have you?
 
5:26 PM
@Mat'sMug what's a ERP?
 
Enterprise Resource Planning
 
@SimonAndréForsberg I haven't much looked into it yet
 
That doesn't sound nice
 
@Koveras in normal companies that's a system like SAP or Oracle, here it's a shitty piece of broken software written in the 90's, that's business-critical and that every user in the company uses. 3rd-party and very expensive.
 
Ouch
Are you worried about keeping your job?
 
5:28 PM
normally people worry about losing their job.. yes, I'm worried about keeping this one ;)
 
Oh haha
 
@skiwi So, you use foreach as a collector, and the consumer is executor.execute? agree?
 
Sounds like a perfectly good reason to spend all day on CR then
 
@rolfl I'll rewrite it for more clarity of both of us
 
5:29 PM
@skiwi would help
 
meeting, later!
 
Cya
 
If it's even rewritable...
 
Hi Jeff
 
Now the Mug&Swede can be quiet.
 
5:35 PM
I'm wondering if this made it clearer now...
hang on
nvm
Consumer<UniqueTimePath> consumer = path -> fileConsumer.accept(path.getPath());
Function<UniqueTimePath, Runnable> function = path -> (() -> consumer.accept(path));
Consumer<UniqueTimePath> outerConsumer = path -> executor.execute(function.apply(path));
Files.list(directory)
        .map(UniqueTimePath::new)
        .filter(pathsSubmitted::add)
        .forEach(outerConsumer);
Did this make it clearer?
 
@rolfl Technically I have 15 more until the real cap, but Thanks, Santa Monkey!
 
Thanks Monkey!
 
Quick meeting? ^^^^
 
How does Twitter know who my real friends are
I'm very uncomfortable
 
I know your real name too ;-) 62.
 
5:39 PM
I'm earning [badge:yearling] in just a couple of hours.. my profile already says "member for 1 year"! :D
 
There are eyes... eyes EVERYWHERE
@rolfl pretty sure everyone here does
It's Jack... Jack Ironstag
 
(waiting in boardroom)
 
How do I put a tag in a chat message
 
type [tag:tag-name] which becomes
It is simply a formatting thing, the tag does not need to exist.
 
@Mat'sMug
2
Next you'll tell us you're waiting in line at the coffee shop
After that will be the bathroom break notification
 
5:47 PM
@Koveras - in fairness, I think the board-room response was in reply to:
8 mins ago, by rolfl
Quick meeting? ^^^^
 
:)
 
6:02 PM
@Mat'sMug What a coincidence! I also got yearling today!
On SO, but still....
I <3 PARALLEL STREAMS
 
@SimonAndréForsberg don't cross streams, that's just wrong
5
4606 REP. 394 until I hit 5k!!
I need to post some code here soon. I need to get on some HTML that is where it is at!
@rolfl it will take you to a tag page though...
 
Question seems to be ready for re-opening:
0
Q: Web API 2 authentication with JWT

NarayanaPlease review my code for bearer token (JWT) authentication of Web Api 2 (Self Hosted using OWIN) Are there any security issues in the implementation? Quick overview: Token creation and validation using JWT Handler Symmetric key encryption CORS support not yet checked for the authorization he...

Not sure why it hasn't been already...
 
6:20 PM
is that Java?
 
No, not Java.
 
Looks like C#
Java doesn't use var keyword
 
ok. I didn't read the whole thing. JWT made me think Java something something
 
At first I thought JWT was Java Web Toolkit. Then I saw [Route("login")]
The Github link says "JSON Web Token Handler from Microsoft"
 
github.com/rnarayana?tab=repositories <--- marks the repository as C#
 
6:24 PM
Afternoon all :)
 
I already marked it with and
 
anyway BTW.Work
 
Huh, anyone see the footnote here:
7
Q: A Library Class : Point

ambigram_makerI am trying to create a library of my own which contains (among others), a class called Point. As the name suggests, it is intended to encapsulate a point represented in 2D space. This is what I've come up with: package geom; import static java.lang.Math.atan2; import static java.lang.Math.cos;...

Scroll down to the bottom of the post.... ;-)
 
Synonymize ?
 
6:30 PM
@rolfl That alone deserves an upvote :)
The fact that it's deserves another one
@200_success If the is used as I would expect it to be, then yes.
 
@200_success I see no problem
 
You do not have the required score on this tag to vote for this tag synonym
 
This could be a problem ... the lack of scored users.
 
6:40 PM
It's quite interesting to look at the timestamps of the tag synonymizations
 
There are enough active folk to make that happen, @JerryCoffin @ChrisWue and @Jamal are also needed.
 
Only users with an answer score of ≥5 for a tag can suggest or vote on synonyms. In addition, on CR, you need ≥1250 total reputation to suggest a synonym. After graduation, that would be ≥2500.
We have about 46 users over 2500.
 
@rolfl, had time yet to look at my code?
 
Right, looking now.
1 hour ago, by skiwi
Consumer<UniqueTimePath> consumer = path -> fileConsumer.accept(path.getPath());
Function<UniqueTimePath, Runnable> function = path -> (() -> consumer.accept(path));
Consumer<UniqueTimePath> outerConsumer = path -> executor.execute(function.apply(path));
Files.list(directory)
        .map(UniqueTimePath::new)
        .filter(pathsSubmitted::add)
        .forEach(outerConsumer);
 
I don't think that new version made it more clear though
 
6:47 PM
So, fileConsumer is a sequence of things that need to be done for each file, right (the billing, etc).
 
A first step is, pick from input directory, give the file an unique identifier/name, put it in output directory
Second step does the same, but then converts a pdf to a tiff file
things like that
 
OK, and I think that the function and the consumer should be a Java class which implements Runnable or preferably Callable,... and then your foreach becomes:
  path -> executor.execute(new ProcessThings(path));
That function and consumer are a different stream to the Files.list one... and it happens in a different thread.,
 
true
I just don't see how implementing Callable would help
what would the type then need to be?
 
@rolfl Except, for me, my synonym vote would be binding.
 
Except, I voted, and it was not.
(or was it .... ?)
 
6:53 PM
Well, I actually never tried it. But I would assume those votes was binding.
 
@200_success recommended it, and I voted on it ... neither was binding.
 
Oh. Perhaps the only "binding" part is when you click on approve.
 
I think the difference is this is going through the merge vs. the suggest API...
 
@rolfl I see that, and I have just upvoted it.
 
0
Q: Run Length Encoding an Image

serdarI am writing an Run Length Image Encoder for an assignment. My code works very well for binary and 8 bit images but when I want to encode an 4 bit image it don't works correctly. I am using Ubuntu 13.10 and Python 3.3.4. Executing following code should print "True" and "True" but it prints "True"...

 
6:57 PM
I now see two upvotes....
 
And it needs two more. If there are not enough eligible users on chat, then we may eventually have to decide if a mod should approve it.
 
anyone here a LoL player?
 
Not really, have played it quite some though
 
did you see their april fools joke?
Ultra Rapid Fire mode, the future of Leages
 
I've seen it, haven't played i tthough
 
7:10 PM
it is super fun
lots of action
 
I can imagine so :)
I'm super tired atm
 
coffee
fixes the world's problems
 
^^^ not quite .....
coffee fixes the world's problem fixers.
6
 
;)
 
Going to bed is for the weak though.
 
7:17 PM
Going home is for the monkeys.
 
climbing trees is for humans
 
transisting is for ... me, I guess.
 
found a 12 line script at work today
vbs -> C# is now 2 lines of code
and now is readable
 
@rolfl I starred that, then I realized: I don't drink coffee! Unstarred
 
7:42 PM
I just made another Stream discovery: The Stream isn't "closed" when you use forEach or collect or another terminal operation on it.
 
@SimonAndréForsberg Closed in what sense?
 
@skiwi Closed as in called all the onClose methods that has been put on it
stream.onClose(() -> System.out.println("We're done!"))
Normally, I assume this doesn't matter much that a terminal operation doesn't close it, but if the source somehow has been a database connection, file input, or something else, then it might matter.
 
heh
It doesn't call the onClose methods then?
 
Nope, it only calls the onClose methods if you explicitly call stream.close();
 
ah
you need to put it in a try-with-resources
which you would do with database connection/file input/etc either way
 
7:51 PM
Need and need... either try-with-resources, or call stream.close();
 
yeah ^^
 
On most CR questions where a Scanner is being used for keyboard input, it's not closed. I don't know how many times I've said that to people.
 
argh, I'm trying to import backup messages from whatsapp
 
The thing is that I expected the .close method to be called internally by the Stream when you call a terminal operation.
 
@SimonAndréForsberg You do not want to close anything off System.in and System.out
That will make subsequent reads/writes fail
 
7:54 PM
Closing a scanner should be called when you're done with the input
 
Nope, as it closes the underlying stream
Though System.in is really the only exception
 
Resource leak: 'sc' is never closed
 
Give me a sec
and I concurrently am figuring out how I backup my messages when there's no SIM card on my old phone
 
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		sc.close();
		sc = new Scanner(System.in);
		sc.nextLine(); // Throws 'java.util.NoSuchElementException: No line found'
		sc.close();
Of course you should never close the Scanner until you're done with it.
 
But different methods/classes might want to read of the System.in
so if you close it, then nobody else can read from it anymore
I might be stupid, but how does my code only execute once?
for (int i = 0; i < 2; i++) {
    try (Scanner scanner = new Scanner(System.in)) {
        while (scanner.hasNextInt()) {
            int next = scanner.nextInt();
            if (next == 0) {
                break;
            }
            System.out.println("Input was: " + next);
        }
    }
}
no exceptions either
 
8:02 PM
0
Q: Utilizing given functions of the same structure efficiently and elegantly

user193138I usually take my school code as a playground to mess around with things. I was given a bunch of premade hash functions and had to test their output and find when they reach a specific lower range. Since the functions all have the same structure, I made a check function that uses a function point...

 
@skiwi Because you call scanner.hasNextInt()
 
You can type 5, then 0, and then it exits
 
As the stream is closed after the first round, hasNextInt returns false
 
it doesn't say it is closed ?
 
Why would it say that it is closed?
 
8:04 PM
Scanner on System.in is one of those abominations that should not happen It was not designed for that
 
The Scanner knows that there are no more ints as you've closed the underlying stream (System.in)
@rolfl What should we tell our dear users to use instead when wanting keyboard input?
 
I never said there was a better alternative... though, maybe I should write one
 
Yeah, somebody should at least.
And why exactly is Scanner on System.in bad?
 
because System.in is not supposed to be closed, and it is a long-running IOStream
It is also being used for user-interaction which should not have a blocking interface
 
I often tend to have a separate thread entirely for user-keyboard-input
 
8:10 PM
Yay, recovered my whatsapp
 
although that causes some weirdness when there's input and output at the same time...
 
@SimonAndréForsberg The fun part starts with multithreaded system interaction
 
@skiwi Meaning that two threads handle user input simultaneously?
i.e. running two Scanners on System.in at the same time?
 
or one thread prints=stack
 
@SimonAndréForsberg Well it was for the RPS game some week ago, it was not at the same time, but it was being executed on different threads forom time to time
btw @rolfl, what do you thinka bout the cursor on a ListIterator on a linked list?
Specs say it is always between two elements
So having a pointer to previous and next is conform the specifiation then, right?
 
8:24 PM
@skiwi - the position of an iterator is really hard to get your head around ... not a simple thing at all.
It is obvious that the code implementing the iterator cannot point between nodes, so you have to make it an abstract thing.
 
I already encountred that, yes :(
 
The real trick is to understand how to make previous and next work, that, alternating between previous() and next() means you are going nowhere.
I have not done a linked-list implementation of List ... maybe i should have a crack at it.
Would that interest you, or peeve you off?
 
hey, that part works already
How would it peeve me off?
 
It is certainly not something I can just visualize and debate, without actually seeing it in front of me
 
About to go now though, gotta be afk for 5 minutes then I'll respond quickly
I wouldn't mind you trying it, in fact we need more linked list implementations on CR.
4
or well actually, I'll go off now
 
talk to you later
 
9:09 PM
I need an idea review for collision detection: 1) Register each Sprite with PhysicsHandler. 2) PhysicsHandler stores references to hitboxes. 3) Every time a Sprite moves it raises an event "I am going to move to X, Y." 4) PhysicsHandler listens, raises another event if there's a collision. 5) Sprite listens, does not move if event received.
Hmm... rubber duck approves
 
instad of waiting for a period of time for an event, just use a callback
 
How?
Does Sprite pass the callback?
 
actually, you dont even need that, my bad
you dont need to use events like that... you could just be calling methods saying whether or not something is valid
a valid move
 
But that requires Sprite to have a reference to PhysicsHandler
I dunno if that matters
I'm trying to keep it loosely coupled ala codereview.stackexchange.com/q/45901/29587
 
typically in a physics system, on every tick the main physics method will go through the whole list of all of its physics objects, and call their... do movement method
based on their veolcities they will update their new positions
when calling their do movement methods you can check for collisions, and handle those appropriately
sometimes you want to wait till everything has moved, then check collisions and make appropriate adjustments to everythings positions and velocities accordingly
 
9:16 PM
0
Q: Simplifying a web service method

BrianI have the following method in a web service class. I'm a little unhappy about the big block of new JProperty(...) calls in the for loop. Is there a way to simplify that? public string UserCatalog(string numericSessionId, JObject incomingRequestJson) { JObject json = new JObject(); ...

 
Hmmm
 
@200_success Did you delete all of the comments on this answer?
7
A: Setting and getting bits in C

200_successDrop the inline and register keywords. The compiler will decide what to do better than you can, despite your personal preference for complete mastery over the machine.

 
I did.
 
In my game the Player listens for InputEvents
Then it moves itself
 
Ahh, can you undelete the first one @rolfl?
 
9:16 PM
I would need the PhysicsHandler to listen for those I guess in that case
 
It was still relevent.
The ones after it weren't
 
@Koveras the player should be the one inputting things to make the game happen.....
 
btw, because ticks could happen fast or slow based on the system you are running it on. make sure every domovement method that takes in a delta value of the elapsed time since last tick began
 
sorry I just came in in the middle and don't have anything intelligent to say yet
 
@Malachi feel free to comment on my input system: codereview.stackexchange.com/q/45901/29587
 
9:18 PM
This should probably me threaded in the background
 
@Koveras my last comment was a joke
 
and your GUI is getting fresh values everytime it goes to render on screen
 
o
That must be what GameTime.EllapsedGameTime is for in Monogame...
Do you know of an example? I'm getting confused
 
@syb0rg - the first comment was not really saying anything more than what the answer was saying.... that if you are willing to inline and use register then get rid of it and use the right tools (the compiler).
It was also creating controversy. Comments are ephemeral. If you want that to stand, then put it in an answer.
 
@Koveras I'm pasting it all here as one thought

Typically in a physics system, on every tick the main physics method will go through the whole list of all of its physics objects, and call their... do movement method
based on their velocities they will update their new positions
when calling their do movement methods you can check for collisions, and handle those appropriately
sometimes you want to wait till everything has moved, then check collisions and make appropriate adjustments to everything's positions and velocities accordingly
 
9:22 PM
@syb0rg Wasn't me who deleted the comments.
 
@rolfl Ehh, this could all be solved better by @200_success editing in the jist of my comment into his answer. That new answer wouldn't add anything.
 
which is why I am happy with the comment delete.
 
@200_success Are you willing to edit that in?
 
You're saying two different things I think
1) Physics should listen for input events and move everything, not the Sprites themselves. 2) Everything should take a GameTime parameter because some systems are slow.
1 I can handle I think but 2 is not making sense to me
The Update and Draw methods in Game class have a GameTime parameter but I have no idea what to do with it actually - all I've used it for is updating the timer I use for animation
 
@syb0rg I don't mind if you edit my answer.
 
9:27 PM
And I recently changed that to just a constant 0.2 because I didn't see the pointof GameTime - it's always 0.16 or something
 
@Koveras there are no events in this
here is some psudo C# code

Main
{
    Spawn PhysicsThread(DateTime.Now);
    Spawn GUI Thread
}

PhysicsThread(initialTime)
{
	DateTime lastRan = initialTime;
	while(True)
	{
		DateTime now = DateTime.Now;
		TimeSpan delta = now - lastRan;
		lastRan = now;
		foreach(PhysicsObject po in AllPhysicsObjects)
		{
			po.DoPhysics(delta);
		}
	}
}
 
What is DoPhysics?
 
0
Q: Wrong loop executing (brainfuck interpreter in Java)

Andrew VershininThe problem is that, for example, the program the prints to the output numbers from 00 to 99 prints 00 01 02 03 04 05 06 07 08 09 0: 1/ 10 11 12 13 14 15 16 17 18 19 1: 2/ 20 21 The program was checked with one standalone and one online interpreter to be ok. Main.java import java.io.IOExcept...

 
9:57 PM
^ off-topic
 
brain wah?
 
Community♦ has two badges on Area 51.
 
0
Q: find byte[] in byte[] java

nimssonI made a search method because I want to use binary data like png files. The point of this is to be able to find strings like IEND in a png file. I think it works properly. Any improvements/fixes would be appreciated. public static int findString(byte[] in, byte[] find) { boolean done = ...

 
10:25 PM
@BenVlodgi, it appears that if your game has IsFixedTimeStep set to true that you don't need to worry about passing around GameTime, multiplying movement/animation speed by it and what not: msdn.microsoft.com/en-us/library/bb203873.aspx#ID4E4G
Pretty relieving, I thought I was going to have to change everything
 
10:37 PM
re
 
10:52 PM
...gards
 
0
Q: First time with wxPython feel like my code is falling apart Suggestions on organization/improvements for coding

jmunschI work in e-commerce. Went to school for fine art. Interested in programming, and really think that python is neat, but have been learning to program in a very non-linear way. What is the best method to keep code organized? What kind of NO-NOs should I get rid of before they become bad habits? ...

No explanation of how the code works, and lots of noise.
 
@rolfl Thanks!:)
 
0
Q: First time with wxPython feel like my code is falling apart Suggestions on organization/improvements for coding

jmunsch What is the best method to keep code organized? What kind of NO-NOs should I get rid of before they become bad habits? Inversely what kind of good coding habits should I be picking up? I am including code that I have been working on for the past couple weeks. Basically it will help to increase...

 
11:09 PM
I have to say that what you did here is composition :-). Unfortunately I didn't have time earlier to show a complete example like this one but I'm glad that you write it. Furthermore, I've found the constructor injection really easy to test with mocked executors. So it's much better than creating a new ThreadPoolExecutor inside the class could be. — palacsint 9 secs ago
 
11:25 PM
@palacsint - that problem of @skiwi's is a gross overengineering of a relatively simple pipeline..... I think I have convinced him that the bulk of the code he has posted is unnecessary
 

« first day (334 days earlier)      last day (3674 days later) »