« first day (533 days earlier)      last day (3494 days later) » 
00:00 - 18:0018:00 - 00:00

12:05 AM
1
Q: Applying scalar multiplication to matrix

NoolThis is one of my first programs in C. Please review and help me improve it. I create a matrix and apply scalar multiplication on it. Then I print the result. #include <stdio.h> int main(void) { void scalarMultiply(int matrix[3][5], int scalar); void displayMatrix (int matrix[3][5]); ...

 
12:29 AM
Monkevening!
If you can spare the rep, would you reward this great SO answer? Not only solved my problem, but CR style suggested a better way to do it:
1
A: date strtotime() calculation returns 1969 date

Pedro Amaral CoutoThe string supplied to strtotime is invalid. You started a double quote, but you didn't end it correctly: $departureTime = date("l, Y-M-d H:i:s"); $travelTimeOperator = '+'; $timeAmount = 1; $travelTimeInterval = 'days'; $departureTimeString = "$departureTime .' ' .$travelTim...

Hey @Mat'sMug !
 
Well that's a nice answer! +1 and you should check out Code Review :) — retailcoder 20 secs ago
Hey @Phrancis!
 
How's it going this fine (cold) Saturday night?
 
12:47 AM
Watching TV..
 
Been working on fixing up my legendary beer marinade for steaks, along with finishing up a music project, and hopefully getting to finish my PHP script so I can post a question, maybe tonight, more likely tomorrow. Still a few bugs to work out.
 
legendary?
;)
 
Well, somewhat.
It's really good though, you should try it sometime.
 
I should!
 
1 onion, 2-3 cloves garlic, chop up. Fry in about 1/2 cup oil until onions look clear. Add beer (not cheap beer, use your favorite ale or porter), let it reduce by cooking it a bit longer. Cool down, marinate steaks overnight, then cook steaks.
I got some Scotch style ale this time, should be lovely.
 
1:06 AM
Hmm
Seen ducky today?
 
I just got here, haven't seen him
 
I wonder.. my VBA answer went completely under the radar
 
Link?
 
here more looking for comments than votes though.
 
It looks pretty thorough
I don't know much about VBA, but this paragraph seems like it points out a real problem:
> I think if VbeProcedure had a Body property, you wouldn't need to expose Lines, and you could remove the dependency on CodeModule, and remove the need to "kill" procedures, since VbeProcedure would simply become a container for some strings and enum values that VbeCodeModule assigns when it parses a module.
 
1:26 AM
That dependency on CodeModule had been bugging me all along! It enables any procedure to parse any other, ...and basically do anything that's possible to do with a `CodeModule!
Like, deleting everything in the module
Or adding a new procedure
Clearly beyond the scope of a procedure object
 
@Mat'sMug I need some new music to listen to... any band from QC make anything cool lately? I'm not very picky on genres
 
lol I still listen to Metallica...
 
Hahah.
Guess good old Bad Religion will do just fine :)
 
better without the drop shadows
user image
2
 
That looks good. Though I kind of like the Jon Skeet one better ;-)
That's purely subjective though. This one would work better for the general feel of the site.
 
1:39 AM
the Jon Skeet joke just got me a meta-[badge:good-answer]!
2 hours ago, by Mat's Mug
For the record, I like that word cloud much more than the Skeet joke
hello 200
 
1:53 AM
Hi fishy!
 
Filling out a logbook isn't fun
 
Doesn't sound like it @TheKittyKat
 
Hi
 
Hi
 
2:03 AM
Hi
 
lol! ...time to catch up on my Game of Thrones ...later CR!
2
 
Later, @Mat'sMug!
0
Q: Name to substitute setDimensionAndLocation

user3163916I'd like to have a function name that is brief but comprehensive, nothing like setDimLoc() or setDL() because they sound funny. function setDimensionAndLocation(selector, w, h, x = "0", y = "0") { setDimension(selector, w, h); setLocation(selector , x, y); } function setDimension(selecto...

 
2:37 AM
user image
4
@Mat'sMug beer marinade in the brewin'!
 
You will need some of this to go with that:
 
2:54 AM
Oh I've had that wine, not bad I must say
 
3:11 AM
Ahhh. Tis a wine kind of night.
Wine & Frank Miller to be exact.
 
-1
Q: WHILE Loops - Sum of squares

annonymous32I am trying to write a program that prompts the user for a number. That number will calculate a sum of values i.e. 1^2+2^2+3^2....+n^2. I am having difficulty testing this program with 3 different values for n in one run. This is my code: value = 1 total = 0 count = 0 while count < 3: num...

-1
Q: stochastic model over 2 patches

kuriousI am trying to simulate a model (infected suceptible recovered)using ssa for a selection of initial values and be able to discuss the results. I have done this in matlab and this is my code which I am not able to run because they errors in the code clear all close all clc % part b %a1 = (beta1...

 
3:28 AM
I made the mistake of going back onto Facebook. It shall be short-lived.
 
3:54 AM
0
Q: Test Scores and Summary Statistics from a file

MorrisB--This program takes a file from a user, "example.txt". The file contains only positive integers, and the first interger in the file is stating how many intergers come after that integer (Ex. 3, 45, 98, 102) It is safe to assume everything in the users file is properly formatted and they put .txt a...

 
4:04 AM
0
Q: Router for nested routes

handsomeI want to make modifications to this router to accept nested routes The router. class Router { private $routes = array(); private $method; public function __construct() { $this->method = $_SERVER['REQUEST_METHOD']; } public function route($pattern, $callback...

 
Not really sure what issue is from your description. This may be better suited for Code Review. If you are only working with concept code and aren't having a programming issue, then your question is off topic. — Crackertastic yesterday
 
4:25 AM
0
Q: Pre-Order Traversal In Heap

abcI am new to clojure as well as to Functional Programming. I am trying to traverse a tree in pre-order using: (def tree {:left 7 :val 4 :right {:left 4 :val 3 :right 1}}) (defn preorder [tree] (if (nil? tree)(0) (let [v (:val tree) l (:left tree) r (:right tree)] (print-str (v (...

 
4:40 AM
0
Q: War Game GenServer Implementation

HavvyOne of the Etudes for Elixir exercises is to create a War game that uses the spawn, send, and receive primitives, but I went all out and made it an OTP GenServer. I run the game in iex with: {:ok, dealer} = War.Dealer.start War.Dealer.add_handler(dealer, War.Printer) War.Dealer.do_round(dealer)...

0
Q: Enhance a Caesar cipher

DrakkorNoirI have just written a simple program to implement the Caesar cipher using lists. The program assumes the input will be all capital letters. I'm quite new to Python and am just curious of some more efficient ways to write this code. print("This encryption program uses the Caesar cipher to encrypt...

 
5:19 AM
This is why we do it.
Thanks for the feedback, appreciate it! — user3496101 1 hour ago
 
5:56 AM
-2
Q: need a solution plz

user56406. Create a class called Distance that has two private data members feet and inches. This class has two constructors. A default constructor (that initialize data member with zero) and a constructor with two arguments that initialize data member with the argument’s values. It has other 4 function...

0
Q: Project Euler #2 Efficiency

Arun PrakashI'd like to reduce the complexity of my code. Problem : Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1,2,3,5,8,13,21,34,55,89,⋯ By considering the terms in the Fibonacci sequence whose values...

 
6:10 AM
0
Q: How to write a Pythonic prime sieve

mattkaeoI'm practicing writing code less by brute force. I'd like feedback for writing a prime sieve more Pythonic, simpler, or more creatively perhaps. def prime_sieve(limit): numbers = dict() limit = int(limit) for n in range(2, limit + 1): numbers[n] = () primes = numbers.copy...

 
6:25 AM
0
Q: C Programming [DIFFICULT]

Johni have this practice question that i have an answer to; In this stage of the project, you will identify any “danger” spots, in which the SPL is greater than or equal to 80 dB (the value above which long-term hearing damage is likely to result). The simplest approach is to logically overlay a reg...

 
I've been called an "arse" 4 times and a tool 3 times for commenting in agreement on a friend's post that points out vaccines are good for disease prevention. Fudge Facebook.
 
O.o
 
7:06 AM
0
Q: Node.js API route for POSTing a resource. Getting rid of callback pyramid

Victor SandI'm writing an API for simple GET and POST routes. The app is a shared to-do-list. Users and lists are stored separately. A list can belong to many users, and a user can have many lists. // User { "_id": "54435e1424afb4c412f388bc", "email": "bruce@wayne.com", "lists": [ "5443...

0
Q: what is the fast and effective regex from this two

getlostwhat i want is split String by time .i want to get text1 and text2 by spliting time format Text1 10:24:02 Text2 so i can used 2 regex for that and both works fine .but i wonder to know what is the fastest regex 1 ([0-9]{2}):([0-9]{2}):([0-9]{2}) regex 2 [0-9][0-9]:[0-9][0-9]:[0-9][0-9]

 
 
1 hour later…
8:08 AM
Someone should just link
300
A: How do I time a method's execution in Java?

DiastrophismThere is always the old-fashioned way: long startTime = System.nanoTime(); methodToTime(); long endTime = System.nanoTime(); long duration = (endTime - startTime); //divide by 1000000 to get milliseconds.

For those questions
Or the language equivalent
 
9:07 AM
@Mat'sMug I like that one!
@Mat'sMug So that's like your.... fifth? Popular Question badge? I'm still waiting for my first...
 
9:38 AM
0
Q: Project Euler #3 Efficiency

Arun PrakashI'd like to reduce the complexity of my code Problem : The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of a given number N? Solution : import java.util.Scanner; import java.util.TreeSet; public class Solution { public static void main(String[] a...

 
monking
 
Monking
 
10:38 AM
0
Q: Catching NullPointerException in Servlets

ohtphI have a servlet that processes user registration to a website. It takes inputs from an HTML form like username, password, email, etc. MySQL Table: CREATE TABLE IF NOT EXISTS user( user_id VARCHAR(255), user_password VARCHAR(255) NOT NULL, user_last_name VARCHAR(255), user_first...

 
10:52 AM
0
Q: Structure to manage a drawing/animating web application

Dhruv KapurSo I am trying to build a small web application, which is supposed to emulate a small set of functionalities of photoshop. It should allow me to add layers. Every layer has a type - Image, Freehand, Vector, Text etc. (Each layer then in turn maps to a canvas object) Depending on the type of th...

 
11:44 AM
0
Q: vector backed by memory pages

lezebulonthe purpose of this class is to wrap a std::vector in a class so that never a new object is added, we dont allocate a new object on the stack but we trying to fit it on the current memory page, or create a new page for it. #include <vector> template<class T> class PagedVector { public : P...

 
11:57 AM
0
Q: declared as a function error

Ricotypedef struct tagPoint { double x, y; } point, *pPoint; typedef struct tagSource { point location; float power; } source, *pSource; typedef struct { struct tagSource tagSource[100],random [2]; struct tagPoint double spl(double w, double r); double spl_total(struct tagS...

0
Q: I am trying to do a task? the task that I am doing is booking a group of seats:

hassanThere is 5 rows labelled a-e.With 10 seats per row numbered 1-10. The input should be: the number of people in a group with a maximum of 6. the desired row,A-E The output should be: confirm there is a block of seats available in the chosen row. the corresponding seat numbers in the format--avai...

 
Hi Simon, we are required to use user-defined exceptions, so I just threw them in there, sorry. For the NPE, is it advisable to have a long if-statement like that? Thanks for your answer btw. — ohtph 2 mins ago
 
0
Q: Extending Codigniter base controller work is working different than the documentation

YasithaAs per the Codeigniter documentation it says to extend a base controller what we need to do are create a file named application/core/MY_Input.php, and declare your class with: class MY_Input extends CI_Input { } Note: If you need to use a constructor in your class make sure you extend the pa...

 
12:20 PM
0
Q: MySQL Java in JTable

rdsarnaThis is an assignment posted here. (Part-B) The aim here is to create a GUI in which the user can search for and insert data into a particular table of a MySQL database. Is this an appropriate design or is it little overkill to make so many classes. The purpose of the DataClass is to make it po...

 
I hate bit masks...
I've got an int storing data in a 12-bit range, and another int storing data in a 4-bit range, and now I need to pack it into a single 16-bit int
(in C)
 
12:36 PM
and what's the problem with that?
I like bitmasks
bitwise AND is your friend
 
I don't like LaTeX. I can handle programs throwing build errors at me, but a stupid text document?
 
Monking all.
 
@skiwi write a utility class for it. It's very likely that this kind of problem will come back to you again and again. Solve it now, put it on GitHub
monking Rolfl
 
@janos I think I managed to get something working for it, I'll never touch it again after this
@JeroenVannevel I don't like LaTeX either
 
@skiwi if I had a penny for every time I said that to myself....
 
12:44 PM
Well, I doubt I'll be using C again anytime soon
 
So, time to run through some SEDE results...... NEW DATA.
@janos - you're ahead of Winston, congrats: data.stackexchange.com/codereview/query/167924/…
 
@rolfl is there a SEDE query for the monthly rankings? To see how I ranked in the monthly leagues in previous months, not only this one and the last?
 
Not in SEDE, the rep things are too complciated, but the rep-league tables on main SE site can help with that....
 
I'm trying really hard to NOT answer today
 
you caan go to it by month, (prev month, etc).
 
12:51 PM
oh I didn't notice the "prev month" links, cool, just what I was looking for
 
Oh, and @janos - I expect the leaderboard rankings to change a whole lot, nudge-nudge, wink wink.
 
hm. I guess you noticed something, nudge-nudge, wink wink
 
Things like this take time, but yes.
 
1:06 PM
0
Q: Scroll table height and set textarea and code to 100% of parent

meridiusI currently work on my little project and I'm stuck at CSS, at which I suck. I'd like to have: specified dimensions in px for whole floating div table in first div should overflow-y: auto textarea and code in second div should have specified same width in px and height of 100% of parent div ...

 
1:25 PM
Welcome my old friend, Segmentation fault (core dumped)
3
 
Oh, he visited me yesterday (Or was it Friday)
 
Lol, while trying to fix the issue, I found a bug that somehow magically didn't mess up my program
@rolfl When working on that Java<->C wrapper?
You would say that you cannot do that much wrong in implementing a circular bounded FIFO-buffer
/* buffer helper methods */
static void push_in_buffer(ITEM item)
{
    write_buffer_safe(buffer_start + items_in_buffer++, item);
}

static ITEM peek_in_buffer()
{
    return read_buffer_safe(buffer_start);
}

static ITEM pop_from_buffer()
{
    ITEM item = read_buffer_safe(buffer_start++);
    items_in_buffer--;
    return item;
}
Apparently you still can make mistakes.
Perhaps... I'm trying to take items when the buffer is empty ;)
But I think I covered that with condition signals
 
yesterday, by rolfl
Hello World!
Segmentation fault (core dumped)
Nothing as complicated as a FIFO ;-)
Also, call it a ring-buffer, much more 'professional' sounding.
 
Yeah, I'll call it that!
Lol!
The buffer has size 10
I got this output: pastebin.com/uyHP9Y3n
Investigate the moment before segfault ;)
 
1:40 PM
0
Q: Is there a more efficient way of executing multiple sql prepared statements at once?

crmI'm updating more than one table at once and as you will see it uses a lot of similar looking code. Is there a more efficient way of doing this, perhaps some way of combining the queries? String sex, age; sex = request.getParameter("sex"); age = request.getParameter("age"); try(Connection con ...

 
If I remove lines 11 and 18, it compiles
If I leave them in, I have 101 errors
If I remove the brackets, they still give as many errors
It feels like a riddle. Why does it act annoying?
Error messages are a repeat of "Missing $ insert", "Extra }, or forgotten $" and "Missing } inserted"
 
@JeroenVannevel Nice Gist name
What's up with the DR_OVERZICHT? Is that literal text or a "variable"?
I suspect it's causing an issue
 
ahhhhh
The underscore is a special character
Stupid latex
It works!
 
in Java, this works right? -> try (PreparedStatement st = con.prepareStatement(updateAgeString)) { ... }
 
yes.
AutoClosable.
 
thanks guys. It's logical, but I've not used it with a PreparedStatement, so just double-checking so I'm not answering rubbish
 
Nope.
Now we wait.
 
@rolfl did you notice before I mentioned it?
 
editing fubar there... no, did not.
 
2:00 PM
@JeroenVannevel Great... I'll remember that for in a few weeks!
Long shot, but I doubt C supports lambdas or "functions"?
Oh snap!
I forgot to make my ring-buffer circular.
 
0
Q: Find next highest number with the same digits

python_loverQuestion: Given any integer, efficiently find the next highest integer that uses the same digits. For example if the number is 15432, you should return 21345. Program: I have written a program which automatically generates a random number in the range random.randint(999, 999999): print "F...

 
that's it.... I'm officially addicted :(
5
I promised myself to cool off after I make Epic
and I... just... cannot...
2
my latest excuse is to cool off after I'm top of October, to make it 3 straight months
 
I am not one to talk.
 
and probably I'll have another bullshit excuse after that
 
I found that odd-ball 'challenges' are fun ... getting badges like sportsmanshio, etc.
You probably have that
 
2:13 PM
you congratulated me for it ;)
 
Probably did.... how about getting tag-badges in your top-30 tags?
 
I'm afraid that will just make things worse
 
Yeah, but you have to learn stuff before you can do that.
 
I've been neglecting personal projects for CR
 
Well, then you can submit them here fore review, and then you not only do the projects, but you do them well, and get rep ;-)
2
 
2:15 PM
it's a good time to cool off now, and then be back in full swing for the winter bash
now you're talking!
 
@janos That's a good point. I have my 1-year anniversary in a couple of weeks.... that's going to be a cool-off-point for me.
I think
 
> the producer determines each item's destination by means of a random generator
 
> visited 354 days, 354 consecutive
3
 
static int get_random()
{
    return 4; //guaranteed random by random rice roll
}
Would the teacher accept this?
@rolfl That's quite crazy
 
@rolfl that's a serious case
 
2:17 PM
Okay, I should shut up with my SO account:
 
int sum = x / z;
Sigh
 
> visited 523 days, 341 consecutive
 
I wanted to take a day off just to avoid being branded awarded Fanatic, but then I "forgot"
 
But, expect them to drop in next week's numbers because that all includes votes/comments on closed questions which get deleted, and thus lost from SEDE.
 
so I wasn't just imagining the new swarm of questions
 
2:19 PM
526 new users last week.
 
@skiwi even more crazy the fact that visited == consecutive... "love at first sight" eh @rolfl ?
3
 
@janos Never missed a day, no.
I'm not the worst, though..... (I am on Code Review, but not on SO).
 
> visited 690 days, 690 consecutive
2
No shame
2
 
@JeroenVannevel Thanks, I was searching for that ;-)
 
:)
hm, and congrats on 20k on SO @JeroenVannevel
 
2:24 PM
As a celebration, I'll go outside the house on the 2-year mark
4
@janos Thanks! I'm important now
Big balla in the Java department
 
Just got your gold tag badge, congrats.
Dup hammered yet?
 
I've got that one for a few weeks already, I just don't really answer much on SO anymore
 
@CaptainObvious OP posted an answer with the same code as in the question.
 
@JeroenVannevel With your mobile phone, obviously
 
But yes, I'm bashing the duplicates
I love it
No more frustratingly having to wait for 4 others while the rep-whores snatch in to answer string == string questions
 
2:28 PM
@MartinR Thanks, deleted, but that is also a good example where flagging Not-an-answer would be the right thing
 
You are right, I'll keep that in mind!
 
@JeroenVannevel The problem about those questions is though that it's quite hard to earn SO rep without them. I would like to go to 10K on SO, but SO questions are either crap, or duplicates.
 
There are genius questions from time to time
 
@SimonAndréForsberg - moderators on SE have a chat room..... and often deleted questions/answers from various sites are referenced when talking about mod-related issues. Since so much happens on SO, a lot of conversations are 'opaque' to me....
not any more ;-)
But damn, it was a pain to get 10K there.
@MartinR Interestingly, what actually happened there, is that the asker put the question in the question, then the code in an answer, and jonrsharpe copied the code from the answer in to the question.
 
0
Q: Is my solution Thread safe?

Cian GallagherI have a Point immutable Point class and a CollectionPoint class which manages instances of my Point class. The CollectionPoint class owns points under its control and must synchronize concurrent activity. I have below what i think is a Thread safe solution but would like another's opinion. Is th...

0
Q: PHP - autoregister model / library / helper - REFACTOR

Ing. Michal HudakI have array $autoload $autoload['models'] = array(); $autoload['libraries'] = array(); $autoload['helpers'] = array('url', 'lang'); and in controller I call each model / library / helper in autoload with this function: private function auto_register() { global $autoload; for...

 
2:48 PM
This 1 producer - n consumer problem is driving me crazy... I can almost conclude that the approach in this assignment simply cannot work due to the requirements of the requirement
 
3:09 PM
Are requests to refactor code actually on-topic here?
As I think we usually place requests to review the code, and not to refactor
 
Let's take this to chat: The 2nd Monitorrolfl ♦ 10 secs ago
Hey there
 
hey
sorry, just getting used to this, never used the chat before
 
Concurrent implies that there's more than one thread.
No problem, with that, chat is just a better palce to have a discussion than the comments
 
So it seems yes! haha
 
Thanks for the reply! Given that I've synchronized the methods in the CollectionPoint class they're going to run in a sequential form anyway, am i right in saying that? So in hindsight this solution is actually not concurrent at all? — Cian Gallagher 6 mins ago
 
3:14 PM
Ok, so am i right in saying that synchronizing my methods will have them run in a sequential form?
 
sunchronization makes the access to the core parts 'sequential', yes.
 
That is a good thing.
that does not mean that you are not concurrent
what that means is that you have controlled concurrency
 
Ahh i see what you mean
 
concurrency is about 'intent' not about 'reality'.
if two trheads are trying to access the resources at the same time, then you have concurrency
You have no concurrent threads in your Main class though....
 
3:16 PM
You mentioned that my solution wasn't tested in a meaningful way, can you elaborate more on that?
As in im creating one thread after the other with each instance of point you mean?
 
Yes, look at you main method's loop:
 
        for(int i=0;i<N;i++) {
            x = (Math.random()*N);
            y = (Math.random()*N);
            Point p = new Point(x,y);
            Thread cp = new CollectionPoint(p);
            cp.start();

            try {
                cp.join();
            } catch(InterruptedException e) {}

        }
OK, that code....
 
you have a loop, you create N threads, but, look at what they do....
you create the thread, start it, then wait for it to finish.
then you loop, start a new thread, wait for it to finish.
you never have more than one thread running at any one time.
 
3:18 PM
I don't know what i was thinking
haha#
 
What's more, is that each thread gets their own independent instance of CollectionPoint.
So, even if the threads were running at the same time, they would all be modifying different CollectionPoint instances....
 
I couldn't think of a way to pass the the references i needed without doing that
 
which means they would never be using the same add methods, etc. the threads would never be locking each other out.
toto2 has also pointed out something I never added to my answer (I saw it, but then deleted a bunch of things to concentrate on the synchronization.
if(list.contains(p.x() == x)) {
 
Ahh this, let me explain
 
does list ever contain Boolean.TRUE or Boolean.FALSE ?
 
3:24 PM
getAllX() is a method that should return a value of p.x (Point) whose x cord matches the the one referenced
reading that now doesn't make a lot of sense..
 
Nope, it doesn't.... ;-)
 
Basically, I'm passing in a value of x to check if it matches p.x(), and if it does i return it
 
but who was x?
 
I've realized this issue that i think you have pointed out in this chat
With my main method
i have no way to check for these
 
There are so many things wrong with that one line.... p.x() is a double, x is an int, and compaing the double to an int with == will return a true/false value, which will be auto-boxed to a Boolean (TRUE or FALSE), and then you will look to see if list.contains(TRUE) or list.contains(FALSE)
 
3:28 PM
That should be a double, apologies for that
 
which will always be false, because list contains Point instances.
 
Should have*
Ok
 
As it happens, your main method never runs that code, so, no problem ;-)
 
I see what you mean
Well that's something i need to change, because it does
 
Also, this is generally a very bad idea:
synchronized void display() {
    for(Point x : list) {
        System.out.println("Point: "+x);
    }
}
Doing a println inside a synchronization block, is not good.
 
3:30 PM
Having it synched you mean?
 
printlns are synchronized themselves.
 
Ahh Ok, I didn't know that
 
So, you have two levels of synchronization, one on your instance, and another on System.out
The right thing to do would be something like:
Stringbuilder sb = new StringBuilder();
synchronized(this) {
    for (.....) {
        sb.append("...");
    }
}
Sysmtem.out.println(sb.toString());
 
or what about something simple like so:
void display() {
		for(Point x : list) {
			System.out.println("Point: "+x);
		}
	}
 
can't do that because you could get a concurrentmodificationexception when iterating the list.
 
3:32 PM
opps, how do i format in chat haha
 
when you type, there's a fixed-font button that appears.
I'll fix yours quickly
 
thanks
 
different topic: @mleyfman was a strong competitor in August, in Java and Python. Then he kinda disappeared. I wonder if we can lure him back with some Santa loving today. For your consideration: codereview.stackexchange.com/users/47450/mleyfman?tab=answers
there's no shortage of Java answerers, but there sure is of Python
 
3:48 PM
@rolfl Wouldn't another idiom also be to copy the list under synchronization before processing unsynchronized?
 
@skiwi Yes, that would work too.
 
And I finally fixed my Heisenbug
Damned spontaneous wake-ups.
 
 I often do a toArray(new XX[...]))
@skiwi Well documented side effects, must check notifications in a loop!
 
@rolfl Well, my case was misleading, as in the example code and assignment it nowhere was mentioned
Perhaps it was mentioned in class, but who am I to pay attention during a lecture?
 
Oh, if you're following example code, you're forgiven, but complain about the example code.
 
3:52 PM
in Java, there's no point caching a Statement object, right?
 
@janos Not normally. A PreparedStatement instance ... yes
> Note: Always invoke wait inside a loop that tests for the condition being waited for. Don't assume that the interrupt was for the particular condition you were waiting for, or that the condition is still true.
 
@rolfl I'm programming this in C though ;) But same rules apply
After being very happy that it all works, I now realize that it is time to check the corner-cases.
 
@rolfl really? Caching a PreparedStatement makes a difference compared to recreating every time?
 
Depending on the JDBC implementation you are using, the PreparedStatement is cached in there anyway
But, yes, caching PreparedStatements makes a difference.
(off to check my facts... bbiab)
 
And my hopes on having a working implementation just shattered...
 
3:58 PM
@rolfl that does sound logical, but I thought that under the hood the implementation will do the right thing and make no practical difference in the end
 
It does work most of the time, though I do not think that qualifies
 
@janos Connection pooling and PreparedStatement pooling are relatively common functionality to have together: commons.apache.org/proper/commons-dbcp
 
0
Q: Fast counting of interactions between groups given users interactions and groups assignments

albertoGiven: An array c that contains the group assignment of every user (c[i]=4 indicates that user i belongs to group 4) A matrix y of 0 and 1 that indicates whether user i interacted with user j (y[i][j] = 1 if i interacted with j, 0 otherwise) What is the fastest way to count the number of int...

 
MySQL allows you to set up the JDBC layer to cache the prepared statements for you.
How that affects your real performance is a very open question, though
Note that, for performance reasons, the pooling/caching only makes sense if the backend database supports server-side prepared statement support
 
thanks @rolfl
 
4:15 PM
Does anyone have tips on how to debug multi-threaded C programs that are "stuck"?
 
@skiwi Remove the deadlocks!
 
@SimonAndréForsberg this looks a very nice improvement over my answer: codereview.stackexchange.com/a/67167/12390
 
@SimonAndréForsberg Well, that's a nice suggestion ;)
How do I remove the deadlocks?
 
-1
Q: is there any simple way to count repeating albhabets in string

Navi Cheemai want to find about the number of times each alphabet is repeated in string Scanner input = new Scanner(System.in); PrintStream out = System.out; out.print("Enter the string : "); String na = input.nextLine(); String n = na.toUpperCase(); int...

twitch
3
 
I see I can add another mutex, it might help.
@JeroenVannevel Someone needs to find out how programmers work...
I couldn't even bring myself to write such code, because I'm way too lazy to write that all
I'd either write the correct solution, or write a program that generates all code that I should write otherwise
2
 
4:24 PM
@CianGallagher Sorry, I just had to down-vote your question. It seemed like it wasn't doing what you thought it was doing, so it's a bit semi-broken. It is on-topic though, but I would recommend testing your code a bit more next time. I hope to give you many up-votes in the future (getting up-votes for me is usually not that hard)
@janos yes indeed, although that code seems to be very similar in a way to the original. It's a big cleanup though.
1
A: Min triangle path - bottom-up

toto2It looks like a good dynamic programming solution. Small Details I don't like that you copy the full triangle in TriangleResult. You can just store the relevant path. You could define rowIndex right before its use in findShortestPath. I don't like raw arrays, but it might OK here for performa...

 
it's essentially mine + cache
 
How on earth is my version recursive?
@janos the cache is essentially what your version needed to be any good
 
I think mine certainly was any good. This makes it very good
 
Apparently, I wasn't even notified about that answer.... here I have spent the entire day thinking that my question was still unanswered...
@janos your version would probably still be working on that triangle with 40 rows if I hadn't interrupted it yesterday, that's the only reason I don't call it 'good'. O(2^n) is not something I call 'good' if it is avoidable.
for smaller triangles, sure, then your version was fine.
 
0
Q: Function composition using std::bind

NicolasRegarding composition of functions/functors in C++11, I have been reading a blog post at bureau14, which is mentioned in this stackoverflow question. The basic question is how to create a function g(f(x)) given two functions g(y) and f(x), where the return type of f(x) is compatible with y. I f...

 
4:32 PM
@SimonAndréForsberg That should be solvable in O(n) time and O(n) space
where n is the number of items in the triangle.
 
@rolfl as far as I know, that is how I solve it. Although I called it O(n^2) where n is the number of rows in the triangle.
 
@SimonAndréForsberg for smaller triangles, it's a beauty. but you're entitled to your opinion. you can probably also take any solution good in some context and put in another context where it is bad
 
OK, I saw the O(n^2) and wondered.
 
@rolfl edited that part, sorry for the confusion
@janos In this case I value speed more. Sorry. You are still an excellent coder though ;)
 
No problem. I think I may need to add an answer....
 
4:43 PM
@rolfl I hope you will.
Why does @toto2 not hang around in chat more?
 
5:02 PM
0
Q: Parsing log files in haskell - beginner

Dustin GetzI am working through the online materials for CIS 194, a upenn haskell class (not taking the class). This exercise is to parse an error log, and it gives a few function signatures to implement, ending with the very last one whatWentWrong. Please help me make the code more idiomatic, particularly ...

 
5:26 PM
Tomorrow first day of work @ new company :D
3
 
0
Q: Function composition using std::bind

Nicolas Given a number of functions f1, f2, f3, ..., fn I want to create a composite function g so that g(x) calls f1(f2(f3(...(fn(x)))). I came across a blog post which was mentioned in a related StackO verflow question. These solutions seem to be very involved. In my own code, I am using a very s...

 
Thanks, Santa! One-away now
 
I'm quite surprised to see some questions for the first time
oh I see, it's from March. that explains it
 
@rolfl Can Java optimize tail recursion to a while loop? Or is that only in some other languages?
 
No, it cannot.
Well, technically, it could, but, the predictability of the stack-support is more significant than the potential optimization
write-once, run everywhere thing
 
5:35 PM
alright.
I'm starting to mix up languages, apparently.
Maybe some day I'll confuse PHP with C++... oh, the horror.
 
5:48 PM
0
A: Min triangle path - bottom-up

rolflWhat I like: unit tests, pass for me too you have turned the Triangle in to an immutable class you have a result class you are using primitive int arrays instead of List<List<Integer>> references the algorithm is efficient Where I think there are problems are: duplication of data in the Res...

 
@rolfl Read it a few minutes ago, voted now, accept will probably come within a few days.
 
No problem... just pimping anyway ;-)
@janos - your epic badge now has Code Review ranked 21 overall of all sites on SE (using my ranking system): data.stackexchange.com/stackoverflow/query/199310/…
 
glad to be of help ;)
 
00:00 - 18:0018:00 - 00:00

« first day (533 days earlier)      last day (3494 days later) »