« first day (505 days earlier)      last day (3511 days later) » 

12:03 AM
Haha, hi
Just a quick question, I'm reading a text file in python and I'm trying to move to the next line in the file
so something like readline()
However, that doesnt seem to pick up the next line
 
(you can edit recent chat messages, arrow-up, or use the hover drop-down menu!)
 
Thanks
 
welcome! and welcome to The 2nd Monitor!
 
12:50 AM
0
Q: Bookmark application AngularJS controller complexity

Michael TrouwI am working on a personal project for managing one's Pinboard bookmarks. Since this is already quite a big project, I am not sure if my question fits the guidelines. My main concern is with the complexity of one of my controllers. I have the feeling I should cut it into smaller controllers or di...

 
 
3 hours later…
3:35 AM
One more answer and upvote, and I get the tag badge!
2
 
4:19 AM
0
Q: Improving performance of a numerical code

maverickI just wrote a program to solve one dimensional Euler equation for fluid dynamics. Attached is a snippet of the vtune profile result for one of the function. There are a few things which looks weird to me. For example, difference in line 72 takes more time than division in line 70. Also line 70 ...

 
 
7 hours later…
10:57 AM
Monking
 
11:44 AM
0
Q: First C++ programme

BarrieThis is my first attempt at a programme. Is it good form? best practice? Or am I completely off the mark? #include "stdafx.h" #include <iostream> #include <string> #include <Windows.h> using namespace std; string a; string b; string enterName() { while (true) { cout << "what is your name?:...

 
11:55 AM
@JeroenVannevel Note that that message has been pinned for two days and only three stars on it :) Probably the least starred pinned message ever
 
@SimonAndréForsberg Just because I know best doesn't mean all of you do!
 
Simon knows better
3
 
12:15 PM
0
Q: Create a country with specific values from a pre-determined list

BonoBackground I'm currently working on an Android application which asks the user a question. At the moment I'm creating the modules for asking the questions. Right now I'm working on a topography module, which will be able to ask the user all kinds of questions about a certain country that will be ...

0
Q: First Gulpfile, any improvements?

Kristofferson// Load plugins var gulp = require('gulp'); var sass = require('gulp-ruby-sass'); var autoprefix = require('gulp-autoprefixer'); var notify = require('gulp-notify'); var gutil = require('gulp-util'); var concat = require('gulp-concat'); var uglify = require('gu...

 
Wow that's been a quiet Saturday! Monking! (anyone here?)
 
@Mat'sMug nope, you're all alone, Mug
 
Well hi Simon-knows-better!
 
12:33 PM
I think I just started a competition against @JeroenVannevel
 
ah, now I see. (the star-wall doesn't show on phone chat)
that one is too good
2 days ago, by Christoph
reading through the memes I come to the conclusion that the people my parents warned me of are here in the CR chat
SE hot questions need more CR posts:
The merits of putting Aquaman on something that (depending on the age) may routinely become wet throughout the night makes me question the decision. Perhaps they should have just sold packs of 4 or 8. — corsiKa yesterday
67
A: Whose underwear is this?

Monty129That would be Aquaman. The logo is a stylized "A" usually seen as a part of his belt buckle.

 
yeah I saw that one yesterday ^^
 
12:51 PM
Monking fellas
 
monking @RubberDuck!
 
Monking @all
 
hi!
 
It was a slow week last week... right? : data.stackexchange.com/codereview/query/161411/…
 
Is "KISS my... unit of work" potentially offensive? or just a good title?
 
1:06 PM
good in what sense ?
 
@rolfl looks like it.. what goes down, goes back up!
0
Q: KISS my... unit of work

Mat's MugI've seen many, many UoW+Repository implementations. Whenever one was built on top of Entity Framework, I'd cringe at the added complexity. Sure the complexity buys you (sometimes) full decoupling from Entity Framework, which in theory would possibly allow swapping EF for, say, NHibernate, or ev...

 
True .... but, the questions-asked is going to drop next week.
looks OK as a title,
will get views, that's for sure.
 
can't wait for this approach to be reviewed. I've been recommending it for as long as I can remember, but never actually posted it for review
31 mins ago, by Mat's Mug
SE hot questions need more CR posts:
and I think @Simon has a RPSLS in the making
 
Argh ... crap.
 
bbl.. got twins [hitting/biting/poking/pulling hair/...] each other here
 
1:18 PM
0
Q: KISS my... unit of work

Mat's MugI've seen many, many UoW+Repository implementations. Whenever one was built on top of Entity Framework, I'd cringe at the added complexity. Sure the complexity buys you (sometimes) full decoupling from Entity Framework, which in theory would possibly allow swapping EF for, say, NHibernate, or ev...

 
Love the smell of fresh coffee, badges, and napalm on Sunday Mornings.
 
Oh coffee... THAT'S what I need right now!
 
1:35 PM
@Mat'sMug that will take quite a while until that's ready. Haven't started it yet, just written down the idea
 
2:23 PM
0
Q: Simple SqlHelper which wraps ADO.NET methods

user960567I am creating a simple SqlHelper which will simplify the ADO.NEt method usage. Can someone please review this class for any issue or missing something, public static class SqlHelper { public static async Task<int> ExecuteNonQueryAsync(string connectionString, CommandType cmdType,...

 
@Captain repository pattern dude!
 
Moar coffee
 
2:39 PM
^^ exactly the complexity I'm talking about
Am I right to claim it's overkill?
Why do people do this all the time? What am I missing?
 
3:03 PM
A thought occurred to me.. wouldn't it be better off on Programmers.SE?
 
It could be, maybe.
 
Programming without objects is truly horrible
 
@skiwi what are you doing?
 
@mariosangiorgio C :(
 
@skiwi I see. In general I don't think objects are required to make programming beautiful. Think for instance at functional programming languages that support algebraic data types. I find them very elegant
2
 
3:19 PM
@mariosangiorgio I find them unreadable
 
Ya know what's worse @skiwi, programming without subroutines...
 
0
Q: Road to MVC: the case of Settings Table View Controller

POBNow that I know that MVC can help do better code, I want to make my SettingsTableViewController class conform to it. SettingsTableViewController is a subClass of UITableViewController. It is linked to a storyboard scene that contains a UITableView with two cells (grouped tableView style, prototy...

 
@RubberDuck That's a bit how non-OOP feels to me, as occasionally it's easier to copy paste than to make functions
I'm struggling how to program some multithreaded action (by nature) in a single process
I need to simultaneously send and receive messages, and both calls are by default blocking until either there is space available in the queue or until a message has been received
And in the tutorial they nicely cheated with sleep(1), but we are not allowed to that in the real assignment
 
3:35 PM
0
Q: Project Euler #17

Kevin MeredithProject Euler presents problem 17: If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many let...

0
Q: How to name bool variable in plural form?

WarlockI know that this is a good practice to use 'is' prefix for bool variables. I have no problems with variables for items in single form like isNotNull, isLoading, isCountryLoading, etc. What is the best practice for plural form like: areItemsLoading, areCountriesLoading and so on.

 
I admit they are quite hard to read for someone who is nor *extremely* into them, and that's a very bad thing. I think that the culprits are not the languages by themselves but the programmers that tend to have a more maths-like style. That means they use a lot of abstractions and symbols that you need to know in advance.
The thing I cannot really stand is their abuse of single-letter-identifiers instead of clear and self-explaining names
@CaptainObvious should this question be migrated to Programmers?
 
3:55 PM
I'd be surprised if this works again in one try
 
 
1 hour later…
5:11 PM
0
Q: Custom Class to show tweets

Zephryte ZephryteI'm busy on a site, and we've made a custom twitter class. The tweets are send from our panel, where they're posted and saved in the DB. In this class, we get the tweets from the database and show them on our site. These are my helping points: Is this code af efficient as possible? Is there a e...

1
Q: Bell Triangle computation in Java

h.j.k.From the Wikipedia article: In mathematics, the Bell triangle is a triangle of numbers analogous to Pascal's triangle, whose values count partitions of a set in which a given element is the largest singleton. It is named for its close connection to the Bell numbers, which may be found on both...

 
damn, crashed Excel again. Refactoring code that uses VBE is ...dangerous!
 
5:26 PM
Huh, in C in my case printing using printf only works when I end the line with a \n, strange
Lovely:
144
Q: Why does printf not flush after the call unless a newline is in the format string?

Crazy ChenzWhy does printf not flush after the call unless a newline is in the format string? Is this POSIX behavior? How might I have printf immediately flush every time?

 
there's all kinds of fun little buffering gotcha's in C
like reading from stdin is guaranteed to first flush stdout's buffer
and stderr isn't buffered
 
I'll leave C as soon as I can
 
stuck doing C?
 
Is C++13 standardized and kind of flawless at least?
Yes... University assignment :(
 
c++13? there's not a 13
there's 11 and 14
and everything around C and C++ is relatively well standardized as long as you don't venture off the expected path
the only problem is that it's incredibly easy to veer off the standard path without realizing it
:/
 
5:35 PM
I meant C++14
 
ah
C++14 is still not finalized as far as I'm aware
(so i guess it'll become c++15... lol)
 
Ah well... C++11 then :)
Because in C it seems like there are 101 ways to do the same thing, each with its own little pesky features and bugs
 
"As of August 2014, C++14 has completed its final international ballot and will be published later this year." ooo nifty C++14 will actually make it in 2014
Hrmm, I suppose from that point of view C++ is a bit better
there's still just as many ways to do things
but which one is the best is usually fairly apparent
without having to understand the drawbacks and advantages of each as in C
(although once you get used to C, there's certain things you learn to just stay the hell away from, and it simplifies things a lot :p)
 
Next week, I have to start writing C code with MPI. :-)
 
Well @Corbin, in Java you also have a bunch of ways to do things, but I feel like C is worse
I want to share this code (it's on Github already), but I feel like I cannot put it up for review until I've actually handed in the assignment
If anyone could be so kind to look at this
//keep reading results if available, mq_receive will not block
while (true)
{
    int result = mq_receive(mq_worker_result, (char*)&worker_result_message, sizeof(worker_result_message), NULL);
    if (result == EAGAIN)
    {
        //no messages available
        break;
    }
    msg_num_received++;
    process_worker_result_message(worker_result_message);
}
Am I doing error checking in the wrong way there?
Nothing is being put in the mq_worker_result queue, so it can impossibly read something from it
 
5:54 PM
0
Q: Efficiently merge large collection of dictionaries in python

RahulI have a multiprocessor program which basically parses some xml information and returns the dictionary (one dictionary object for a file) as output and then, I am merging all the dictionaries into one final_dword . if __name__ == '__main__': numthreads = 2 pool = mp.Pool(processes=numthrea...

 
> If the O_NONBLOCK flag is enabled for the message queue
description, then the call instead fails immediately with the error
EAGAIN.
 
0
Q: Simple key-value store in C, take 2

DaggFollowup to Simple key-value store in C. Response to previous reviews You may want to hide the KVSstore structure Done. Add a comparison function pointer to KVSstore. If this pointer is null, kvs_sort_compare just compare key pointers, otherwise, it passes the keys to the comparison ...

 
6:10 PM
@Simon says: edit all the RPS!!!
 
I forgot that C doesn't automatically report errors... I didn't have enough space for more message queues
 
6:37 PM
@Mat'sMug I'm doing 'em in batches :)
only 6 more now
 
Is @Dagg around?
0
A: Simple key-value store in C, take 2

syb0rgPretty good stuff! A few minor notes: I would have different return codes for different errors. I noticed that you are returning -1 and 0 a lot when you encounter an error. Reusing error codes doesn't help narrow down a problem more when you do encounter an error and try to troubleshoot. Us...

 
A C geek would come in handy right now...
I create a message queue with a given name, it's all fine, then I share that name to another process, I try to open it, and it cannot find it
 
@skiwi @syb0rg is your friend!
 
I hope @syb0rg is still around then...
int main (int argc, char* argv[])
{
    printf("child id %d\n", getpid());

    //open message queues
    char* mq_farmer_request_name = argv[1];
    char* mq_worker_result_name = argv[2];

    printf("farmer %s and worker %s\n", mq_farmer_request_name, mq_worker_result_name);

    mqd_t mq_farmer_request = mq_open(mq_farmer_request_name, O_RDONLY);
    if (mq_farmer_request < 0)
    {
        perror("error opening farmer request message queue in worker");
    }
    mqd_t mq_worker_result = mq_open(mq_worker_result_name, O_WRONLY);
I'm getting those errors with bad file descriptor, and I checked, and the used names are valid and existing message queues
Unless...
Unless I'm stupid
And I attempt to open the message queues in the children before opening it in the parent
 
7:05 PM
@skiwi Poof
@skiwi Is this the full code?
@skiwi I think fork() would work
 
@Jamal Here, have an upvote. Although there are more things that can be said for that question... but not right now, at least not by me
 
Jamal, I do not appreciate you changing the title of my post, and even less you correcting my English. I am English and I like to think my command of the language is of a high level and the changes you suggest are not correct. — Barrie 2 hours ago
 
@SimonAndréForsberg Certainly! I didn't feel like looking through the entire thing, though.
 
Ermagherd op comments...
 
I never changed the title...
But I'm glad it was changed because it was a crappy one.
 
7:27 PM
I saw...
additionally that a comment is on an answer of his question
he also commented on the "last" answer with something belonging to the accepted one..
--> OP has not learned SE yet..
as an aside... my mainly used dictionary gives "programme" as the british english form of "program"
 
@Mat'sMug Done with that now :)
 
@Jamal Upvotedy your comment
 
I hope he was just referring to "programme" and not "best practice?" I don't think the latter is even a complete sentence.
 
@Jamal I hope he was, because else I'd have to place him into the category of "yankee doodle dummies, that are unable to speak or coherently write a simple sentence in their native tounge."
 
@syb0rg No, it wasn't the full code... You still happen to be here?
 
7:36 PM
Yep
 
I'm getting some segment fault error, and I believe I think I know what's wrong
But first, how do you pass structs in C?
To a different method
 
@skiwi Depends if you want to alter the original data or not. I usually pass them by reference so that the original data is what is always taken and altered
 
@syb0rg I only want to read the data
 
@skiwi Then don't use pointers. The struct will be copied into the other function
Then you can alter the data without worrying about the original as well
 
So a regular structname a as argument should work?
 
7:43 PM
It should
Then that should also avoid segfaults
Since you aren't messing with pointers
 
I'm still messing with pointers in the method though ;)
Multitasking doesn't help...
typedef struct
{
    int y;
    int* x_colors;
    int width;
} MQ_WORKER_RESULT_MESSAGE;
static void process_worker_result_message(MQ_WORKER_RESULT_MESSAGE worker_result_message)
{
    int x;
    for (x = 0; x < worker_result_message.width; x++)
    {
        //TODO seg fault below here
        output_draw_pixel(x, worker_result_message.y, worker_result_message.x_colors[x]);
    }
}
 
I think your problem is here: worker_result_message.x_colors[x]
Just by speculating, I could be wrong
 
I think so as well
 
Pass the pointer value instead, not the array value
See if that works
 
It's allocated as:
int* xcolors = calloc(50, sizeof(int));
int x;
for (x = 0; x < 50; x++)
{
    xcolors[x] = rand();
}

worker_result_message.y = farmer_request_message.y;
worker_result_message.x_colors = xcolors;
worker_result_message.width = 50;
@syb0rg I'm not sure if I understand that
 
7:54 PM
&worker_result_message->x_colors
Maybe
 
I thought pointers could be simply indexed as an array
 
They can, but the compiler doesn't actually see them like that
That is why a[5] == 5[a] in C
 
Huh...
What?
 
993
A: With C arrays, why is it the case that a[5] == 5[a] ?

Mehrdad AfshariThe C standard defines the [] operator as follows: a[b] == *(a + b) Therefore a[5] will evaluate to: *(a + 5) and 5[a] will evaluate to: *(5 + a) and from elementary school math we know those are equal. This is the direct artifact of arrays behaving as pointers, "a" is a memory address. ...

 
I believe I've actually read that
Ah, I see what it does now
I know it was doing something along those lines though
 
7:58 PM
@skiwi Have you run the code through the debugger to make sure that we are even dealing with the right line?
 
@syb0rg No, just dealing with C for 2 days... But if I comment it, the error is gone
 
1
A: Kings Cup drinking game

toto2 ArrayList<String>compGender = new ArrayList<>(); should be declared (on the left side) as a List<String> (keep the higher abstraction where possible). Also be careful with spacing; it does compile correctly here, but it could lead to serious problem elsewhere. In Deck, public static ArrayList<...

I knew I would miss some obvious things, such as the public constructor.
 
@skiwi Oh, then it's probably the line we are looking for haha
 
There's no way I will get this assignment done in time... Though handing it in one day late will only let me lose 1 point of 10 - and I can still email the teacher asking for delay
 
@skiwi Put it in a gist so I can run the code
When is it due?
 
8:02 PM
It's multiple files... ugh
Tomorrow 8am, aka I am giving myself 30-60 more minutes :P
It's no big deal
 
@skiwi You can do multiple files in a gist
 
I'd rather just try to fix it... I'll think one more time hard to find the error
 
@skiwi What is the function prototype for output_draw_pixel()?
 
@skiwi @syb0rg I'm not really sure if the x_colors assignment there is correct though
void
output_draw_pixel (int x, int y, int color)
 
Oh, forget everything I was saying about passing the pointer then haha
@skiwi I don't think anything is wrong with it, but why not just assign everything to the struct value directly?
 
8:09 PM
The worker_result_message.x_colors = xcolors; gives me the intuition that it shoudl be passed by reference
@syb0rg How?
 
Where do you initialize your struct values?
Allocate memory for the int* within the struct?
 
That's what I posted a bit up here in the chat
 
No, that's the struct declaration. Where do you actually initialize the values within it?
Don't you have a struct init method?
Cause you need to allocate memory for that int*
 
No struct init method... Haven't seen one in the tutorial
You're looking over the message I"ma fraid, I'll repost
int* xcolors = calloc(50, sizeof(int));
int x;
for (x = 0; x < 50; x++)
{
    xcolors[x] = rand();
}

worker_result_message.y = farmer_request_message.y;
worker_result_message.x_colors = xcolors;
worker_result_message.width = 50;
Here ^
 
Hmmmmmm
Maybe pass by reference on assignment/copy?
Pointers were never my strong suit TBH
 
8:19 PM
I don't know at the moment
Cannot do this today anymore, will need the other day
 
When you do fix it, I would love to know to what was the issue
 
I would love to know it too!
 
@skiwi well, just like Java, C typically has a most-correct option out of all of the available options. The problem is that if you pick a less-good option in Java, it might just be more cumbersome to use or a little bit less efficient. If you pick a less-good option in C, it can often be a security problem or it can just straight up shoot you in the face :).
 
@Corbin Yeah, exactly what I felt :) Well worded
 
0
Q: Analyse an nginx access log with awk and produce a report. Looking for opinion on python application

Neil MastersLooking for your opinions on anything that I am doing wrong in the application below. Best practices, glaringly horrible errors or even just your own personal opinion would all be fantastic and very appreciated. Task: Grab an nginx access log, ask it some questions and dump responses out to a te...

 
8:25 PM
@skiwi just in case: what are you using for the queue names? they are required to start with a leading /.
 
Yeah, that's correct... The problem really was that I was:
1) Creating the names in the parent process
2) Forking children process and let them start reading from the queues
3) Create the queues in the parent process
 
ah
 
Took me an hour to figure out
Having a higher level overview is sometimes important
 
:)
 
9:11 PM
Hi! I was not too sure about this: Is there a site similar to code review that focuses on reviewing design specifically or do we have to just use one of the stack exchange sites that are already available?
 
9:27 PM
0
Q: Foreach within Foreach loop - is this code poor form?

TaylorsukI am using the following code poor form. I am interested in how I can optimise this and use the correct methods. I understand the DRY concept and will look to employ that throughout my code. However, this works and its pretty quick too, even with large result sets. I would like to learn and impro...

 
@user111488 Design reviews are not currently on-topic on any site on SE that I am aware of
On code review... well, they are not code. On Stack Overflow, it's too broad/opinionated.
on Programmers it is too specific to one programmer.
 
@RubberDuck (not here?) 4 bottles on the wall!
 
0
Q: Unit Testing - The Final Solution

Mat's MugFollowing-up on the Automagic testing framework for VBA review, I've refactored much of the TestEngine static class, and introduced a TestMethod class. Refactoring part of the TestEngine into its own class introduced new problems that needed new solutions; because the client code is using the As...

 
Understood@ro
woops understood @rolfl *
 
No problem. SE cannot apparently help with everything ;-)
 
9:42 PM
Agreed! But it does help with so much! :) hopefully someone puts that up as an idea for a SE site.
 
Feel free (and I think there may be something already.... let me look on area 51...)
 
Oh I must have misread...I thought only people with lots f rep could do that.
of*
 
area51.stackexchange.com -- searching for design does not lead to anything existing.
I believe anyone can propose sites.
 
Ill try it right now
Well, I am no expert I just think that from a noobie standpoint it would help me greatly when I want to start a real project.
 
10:05 PM
hey @RubberDuck
 
@Mat'sMug 5. I found one that shouldn't of have the tag.
Hey Mug.
 
oh, with the one currently on-hold, that makes it 6 then
 
Yeah..... That's okay. I'm having issues getting some code com visible anyway.
 
^^ custom ITestOutput implementation works!
 
@Mat'sMug NICE!!!
 
10:12 PM
well it kinda sucks that I have to stick this code in the form though:
Private Sub CommandButton1_Click()
    txtOutput.Text = "TestClass1.cls"
    Set TestEngine.Output = Me
    TestEngine.RunAllTests "VBAProject", New TestClass1
End Sub
 
HAHA! I've got it!
I think you'll like my next project.
@Mat'sMug Small price to pay.
 
I would have liked to be able to say Set TestEngine.Output = New UserForm1... and then launch it from the immediate pane (or another module), and have the form show up when it has results coming in... but I guess it's a lot to ask VBA :(
 
You should be able to.
 
don't... tempt me... ;)
 
You just call UserForm1.Visible when you're ready to show the results.
 
10:17 PM
d'uh!
2
 
Anyway, I'm up to no good ^
 
gotta go.. what's that button?
 
Nothing yet....
But I now know how to write an add-in for vbe. I've gotta jet too. ttyl.
 
0
Q: forking and overwriting child process

CeleritasI'm forking and then execing to write over the new process with a call to a system command. I have the following code, and it works, but there's a few pitfalls. pid_t pid = fork(); if(pid < 0)//error { cerr << "error forking: " << strerror(errno); } ...

 
11:03 PM
Oh you gotta be f**** kidding me - just re-reading my post I found a bug!! @RubberDuck deleting the post until it's fixed.
 
You just want a badge'
 
He already had it. ;-)
 
Haha funny
> This time I've thoroughly verified the output, it's exactly what's expected
Like, yeah, right.
 
11:51 PM
0
Q: Creating custom week start and week number

emaNoNimport org.joda.time.DateTime; import org.joda.time.DateTimeConstants; import org.joda.time.MutableDateTime; import org.joda.time.ReadWritableDateTime; import org.joda.time.Weeks; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManage...

 

« first day (505 days earlier)      last day (3511 days later) »