« first day (1334 days earlier)      last day (1526 days later) » 

12:00 AM
RELOAD! There are 3240 unanswered questions (91.9842% answered)
 
OK, I have a question for y'all.
It seems that, in UWP, the UI updates after the method in the VM runs.
So, if I run property getter Foo, which calls OnPropertyChanged(), the UI element that is bound to Foo won't update until after the final brace of Foo.
 
that makes no sense...
 
Actually, it does. They are both running on the UI thread, and something has to wait.
It is probably started right away, then put on a queue to wait until the thread is free.
 
OnPropertyChanged() should be bound to either synchronously terminate or enqueue into the UI thread. assuming that the getter is accessed on the UI thread isn't a good idea
 
I don't have to assume that.
I know it based on my starting point, and it has to be, or it can't access elements from the UI.
 
12:05 AM
that's an assumption that's generally not true for most UI frameworks
accessing object instances is generally thread-insensitive
 
@Vogel612 Well, it certainly does throw exceptions about it liberally enough whenever I try to update a value from a different task.
 
JavaFX also does that ... I personally think it makes UI programming quite the hassle, because you're forced into that single thread or a special way to access objects
 
Anyway, I need a way to fire the event on the UI thread after I reach a certain point.
 
@Hosch250 throwing an execption is not equal to being inaccessbile
 
So, Task.Run(() => whatever) doesn't work.
 
12:08 AM
JavaFX has Platform.runLater for that
 
How much later?
 
If I understood your question correctly
it just queues it to the UI worker thread
 
Oh, cool.
> The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
It's a COM exception, so it's pretty deep.
 
wtf....
you're not doing VBA, where is COM coming from?
 
Windows.
COM is underneath all the UI's on Windows.
 
12:11 AM
suddenly I am very impressed with Swing being able to run on just about anything
 
It is just wrapped with easier-to-use controls now, typically.
@Vogel612 That's because it has the custom implementations for each platform already done. .NET is working on it :)
And when you read about it, COM is very cool, it is just so close to the hardware that it is a pain to use.
 
12:28 AM
Well, I found this: stackoverflow.com/a/18485317
That's working somewhat.
 
yawns
coding is weird
 
Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation. on topic and how to ask apply here. Stack Overflow is for demonstrable problems with your code, not speculative implementation help. You may want CodeReview.StackExchange.com — Prune 5 secs ago
 
12:44 AM
Guys can you take a look at my Update of this answer here codereview.stackexchange.com/a/150859/98577 and help me improve it ? I'm looking for a way to make the Builder pattern more generic with less duplicate code. Or maybe should I post it as a question ?
 
@denis Rags to Riches is a tag.
 
What do you mean :?
 
Read the description:
Anyway, it looks pretty good.
 
1:12 AM
@gnasher729 Although I hesitate to believe that something like this could be necessary (even for a tremendously complex problem), the design is also given by the structure: You almost certainly did not write these 20 nested loops in a single method. (And if you did, then I'd be curious to see you at codereview.stackexchange.com :-D) — Marco13 1 min ago
 
1:57 AM
Good night everyone.
 
2:20 AM
0
Q: Convert a numeric string to number but without python's built in function

Don Fox""" Convert numeric string to number withoutusing python's built in functions. """ dec_places = {6:100000, 5:10000, 4:1000, 3:100, 2:10, 1:1} char_digit = {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9} def str2int(num_str): iter = len(num_str) number = 0 for...

 
2:34 AM
> Everyone started with Amazon Fire tablets which will invariably get destroyed--which is okay because they seem to self-destruct on their own anyways.
It would be awesome if they spontaneously combusted.
 
3:01 AM
Samsung tried that, didn't work out too well ;-P
 
3:15 AM
Monkevening
 
\o
 
@CaptainObvious that return is not indented correctly, pretty sure that Python wouldn't let that run
Good. Clever. Choose one. — Jerry Coffin 28 mins ago
 
4:18 AM
@Phrancis They didn't have the name "Fire", though.
 
0
Q: Project Euler Peoblem 23

Ingyu BangWhat is wrong with my code, my result shows 4178876 but the answer turns out to be 4179871 public static long Solve() { long sum = 0; int[] Abundants = new int[28124]; boolean[] result = new boolean[28124]; for(int i = 1; i < 28124; i++){ if(isAbundant(i)){ ...

 
@CaptainObvious Off-topic(Broken Code) - Debag mah code
 
4:37 AM
hey guys! how's it going?
 
@Dair Hi!
Doing quite well, how are you?
 
Hi, @Dair. New to the chat?
 
@Hosch250: Yeah, I've spent some time talking in the main math one though
 
Ah. Welcome.
 
@Phrancis: I'm doing pretty well just chilling and answering questions
 
4:42 AM
Yeah saw your answer on that str2int Python one from a bit ago
@Hosch250 what would you suggest is a good abstraction to write to work my way to trees? Probably will try using C so OOP is not possible
 
Haha yeah. I really wish this site was more popular, the number of questions we get isn't every second :(
 
Linked list? Or even just a list?
 
I don't know. I've never used C.
 
@Phrancis What project is this?
 
If it were me, I'd do Functional or OOP, and just make a tree node that has a pointer to a parent (of the same type), a list of children (of the same type), and some information about the particular node.
 
4:45 AM
C is functional/procedural
@Dair Just learning stuff for learning's sake, no particular project
 
OK.
 
Just felt like trying the challenge of a very low-level language to learn
 
Does C have types, or did they not come until C++?
 
C has types but the number of types C++ is much greater
 
Because really, all you need is a data structure that contains a pointer to a parent, its own information, and children.
 
4:46 AM
It has some types, signed/unsigned ints, floats, chars, and of course pointers
 
I would honestly just put C into procedural programming...
not even functional, although all subjective to an extent
 
Yeah I guess it's really more procedural than functional
 
Yeah, I did Procedural in C++ for the most part.
 
Looks like there's a neat way to make "generic" C functions using the preprocessor
18
A: Pseudo-generics in C

Paul RYou can do something like this in a header file: // // generic.h // #define TOKENPASTE(x, y) x ## y #define GET_MINIMUM(T) TOKENPASTE(get_minimum_, T) TYPE GET_MINIMUM (TYPE) (TYPE * nums, size_t len){ TYPE min = nums[0]; for (size_t i = 1; i < len; i++) { if (nums[i] < min) ...

 
What do you need generics for? C works lower than that, for the most part.
You need a data structure like this:
ds TreeNode {
    Parent :ds;
    Children :ds[]
    name :string
    age :int
}
Where name and age are the node's data.
 
4:51 AM
That's what structs are for.
 
Huh, can C structs be self-referencing?
 
You could use that simple node to make a genealogical tree. The first node's Parent is null, and the last node's Children is an empty array.
 
deftype struct Node {
  Node *parent;
  Node *children[];
} Node
 
Yep, except that is useless as you can't store any information about the particular node.
And, for a binary tree, you could do Node *rightNode; Node *leftNode;
 
4:54 AM
Right, not as worried about the data, that part's simple
@Dair Cool I will read over that thank you
 
It's all simple, once you've done it once.
3
 
I'm sure. Just understanding what a pointer actually is made a big difference in how I think about code now, compared to how I did a few days ago.
 
Do you understand malloc and related functions?
 
Yeah sorta, haven't used them much yet
 
You're probably going to be using them quite a bit more when dealing with these data structures.
@Hosch250 Working on any projects?
 
5:05 AM
I can see how a linked list would be really good at inserting and removing elements at random links, since it is just changing pointers
 
@Phrancis Although there certainly is a place for linked lists, be careful. Academia seems to think they're really really good. I would also watch at least some of this: youtube.com/watch?v=YQs6IC-vgmo
 
0
Q: find two numbers that sum closest to a given number

Lin MaWorking on the problem of finding 2 numbers that their sum is closest to a specific number. Input numbers are not sorted. Here is my code and my major idea is to sort the numbers and find from two ends. Wondering if any better ideas in terms of algorithm time complexity? Any advice of code bug a...

 
I'm voting to close this question as off-topic because it belong to code review. — N J 22 secs ago
 
@Dair Yeah I'm aware that they are more useful in theory than in practice
 
5:14 AM
@Duga The question just posted by Captain Obvious?
 
@Dair Duga is a bot. Those posts are from when people mention Code Review in Stack Overflow comments
So we can check to make sure they are valid recommendations and avoid migrating crap that is off-topic here
 
Oh lol. Threw me off because he has like 354 reputation
 
Yeah Duga is an actual real user account (as opposed to a feed like CaptainObvious)
It serves other purposes as well, but that is its primary function in this room (as well as reporting possible answer invalidation, i.e.: code edits to questions after an answer to it has been posted)
 
This question by Lin Ma... She needs to revise her code before posting, she has been making similar stylistic errors repeatedly...
 
@Dair She.
 
5:18 AM
@Hosch250 My bad.
 
@Dair As in, posting code with the same flaws over and over, after receiving answers to past questions?
 
Yeah. She has been in repeated violation of PEP 8 for example.
 
Feel welcome to downvote it and leave a comment, if you feel so inclined. Got to find a way to give feedback somehow
@RMunroe lol that's pretty clever
 
I would love to know how/where to post to code review. The only place I have found to post publicly is by clicking the "ask" button. — Oliver 16 secs ago
 
> I got everyone on the software team a new keyboard for Christmas.
> I hope everyone likes them. It was such a great sale, they were marked "No Returns."
 
5:23 AM
Here is a link to ask on Code Review site. You could basically copy the post from Stack Overflow there, and then delete your question here. — Phrancis 31 secs ago
 
Would it make sense to initialize a new pointer to NULL in C, if there's not a value to point it to yet? Is a null pointer the same as a bad pointer, or is null pointer less problematic?
 
No, a null pointer is not the same as a bad pointer.
A bad pointer is one that doesn't point to any meaningful data anymore.
 
So dereferencing a null pointer has more or less no consequences?
 
Ask "Da Google" that (Yep, just read the two latest Pearls Before Swine).
 
The value will be indeterminate though wont it?
 
5:28 AM
I'm not sure. In C#, it points to a specific "null" value.
> In C, NULL is defined as (void *)0.
I thought it point point to something about 0.
 
A pointer to NULL in C is the same idea, since mem location 0 is unusable anyways
 
Yeah, a null pointer is set to 0. A bad pointer is a valid pointer that doesn't point at valid data anymore (or maybe it does by sheer accident).
 
So in that sense, a null pointer is better because you know it points at nothing
 
Yes
 
Obviously.
 
5:31 AM
Knowing is half the battle.
 
C will definitely shoot you in the foot. I would be as explicit as possible.
 
@Dair Make it so you shoot yourself in the foot explicitly on purpose instead of by accident on purpose?
 
@Hosch250 Nah, but it helps to know where it shot you in the foot.
Instead of having some garbage value work like 50% of the time.
 
5:50 AM
Hey @t3chb0t
 
hi
 
How's it going?
 
hungry, I just got up :]
 
Haha, pretty late here.
 
Whooo!!!
I just got my checkers game to update correctly after each move.
The solution? Run getting the move off the UI thread. Only do the UI thread for the things that trigger updates to the UI.
 
6:06 AM
Congrats
 
Now who's zorro? Lots of new people around here, which is a good thing, of course.
 
@Hosch250 you're doing most parts in F#, aren't you?
 
The actual checkers logic and AI.
All interaction with the user is in C#.
 
@AlexanderMills I'm not on codereview, but wait, what... did you just monkey patch your own object from inside a subscribe call? — Asti 11 secs ago
 
0
Q: Find paths whose sum equals target value in binary tree

zorroYou are given a binary tree in which each node contains an integer value (which might be positive or negative). Design an algorithm to count the number of paths that sum to a given value. The path does not need to start or end at the root or a leaf, but it must go downwards (traveling only from p...

 
6:12 AM
It plays itself without crashing now!
 
@Asti I am going to update the code review question, I made a bunch of changes since I first posted the question. — Alexander Mills 44 secs ago
 
Now I'm having occasional multithreading issues. Will fix tomorrow. Go to bed, me!
 
possible answer invalidation by Alexander Mills on question by Alexander Mills: codereview.stackexchange.com/posts/150192/revisions
 
6:41 AM
0
Q: Beautiful Binary String

CodeYogiOnline challenge on Hacker Rank. Alice has a binary string, B, of length n. She thinks a binary string is beautiful if and only if it doesn't contain the substring 010. In one step, Alice can change a 0 to 1 a (or vice-versa). Count and print the minimum number of steps needed to ...

 
6:53 AM
We're slowly working the zombie rate back down! :)
 
Sweet!
 
mhmm, but the answer rate is decreasing, isn't that a bad thing? shouldn't it increase?
 
@t3chb0t Which answer rate?
Look at the end of the graph towards recent stuff.
The answered rate has gone up (very slowly).
And in general our stats are looking slightly better.
 
on the screenshot you've just posted, there's the Answered Rate in % which is decreasing...
oh, you mean the last few days _)
:)
 
Yeah. :)
 
7:01 AM
I wonder what's the difference in answered question count for this percentage change :-]
I know anohter way to fight the zombies...let's close some of the ununswarable questions :-P
 
unanswerable != off-topic
C has strange naming conventions
 
there are so many interesting questions but the day is too short
 
struct FooBar {
  int foo;
  Foobar* ptr;
};
void do_something_with_foo_bar(FooBar* foo_bar) {
  // ...
}
 
7:22 AM
linkedList.c(22): warning C4047: '=': 'Node *' differs in levels of indirection from 'int'
Getting this warning for each of the 3 malloc here, what does that mean?
struct Node {
	int data;
	struct Node* next;
};

struct Node* BuildOneTwoThree() {
	// create 3 node pointers
	struct Node* head = NULL;
	struct Node* second = NULL;
	struct Node* third = NULL;

	// allocate 3 nodes in the heap
	head = malloc(sizeof(struct Node));
	second = malloc(sizeof(struct Node));
	third = malloc(sizeof(struct Node));
 
@gnasher Um, maybe, but I could just as easily say the same thing about you. The fact that the simplest design you could come up with was a 20-deep nesting of loops suggests that you may be lacking imagination in coming up with a better design. Like Marco said, do consider getting that code reviewed. Fresh eyes always help. I am guilty as charged in finding it difficult to imagine that that could ever be the most clear way to write the code. It is certainly not the most optimal. — Cody Gray 19 secs ago
 
:34388241 I suppose you're getting that warning because those are of different types
Read more about levels of indirection here: A pointer can point to a variable (one level of indirection), to another pointer that points to a variable (two levels of indirection), and so on.
 
@Dex'ter int *******something;
 
@EBrown pointception
 
As in, the int data in the struct has one less level of indirection as the Node* pointer?
 
7:36 AM
Make everything indirect.
"I may have indirectly told the computer to not do anything you say."
 
Why would I want the struct to have an int* though? I gotta put the data somewhere!
 
@Phrancis You put it at &field.
 
That's annoying as hell, though, no?
 
Yes, it is.
 
Guess I can try it, eh...
 
7:39 AM
I don't think you need a int*
If it was a generic data type you would probably want to do that though
 
Nope. Now I'm getting double the warnings :D
 
@Phrancis you can leave that as an int and use malloc() differently
for me, it's weird to see sizeof(some_struct)
it doesn't feel natural
 
OH CRAP
 
OK, just using the example code from that Stanford document
 
Academia :P
That's probably not the problem, they really shouldn't have warnings like that in the stanford doc...
 
7:42 AM
I'm kind of missing C. I wanted to start using it again but d'ohh, I have a life!
 
Could be Microsoft's compiler too, I suppose
Despite the warnings, it works just fine that I can tell
 
@Phrancis I spammed your Skype.
 
I noticed ;P
 
I made pretty SQL with PRINT.
 
@Dex'ter What would actually feel natural/idiomatic to you?
 
8:16 AM
0
Q: Call multiple services from angular2 component

ShanThis is my first Angular2 component which makes two api calls with the first one providing input to the second.The following is my attempt at this code. Please let me know how I can improve it. @Component({ selector: 'result-panel', templateUrl: 'panel.component.html', styleUr...

 
TTGTB
 
8:38 AM
0
Q: Implementing realloc in C

TenTen PeterI have an assignment to implement realloc in C, This's my code please review it. void *my_realloc(void *ptr, size_t len) { void *real; real = malloc(len); memset(real, 0, len); if (real) memcpy(real, ptr, len); free(ptr); return (real); }

 
9:06 AM
Hi all :)
(I'm with yes)
 
9:21 AM
in Cardshifter and other projects, 9 hours ago, by Duga
[skiwi2/ArenaDraftAssistant\‌​] 5 commits. 392 additions. 16 deletions.
@Vogel612 You are not alone anymore ^
 
once it works, I suggest that you try asking on codereview.stackexchange.com. post a working code there, you'll get advice / improvements. — Jean-François Fabre 53 secs ago
By the way, if its working code, you may visit CodeReview — Jonas w 37 secs ago
 
@BhargavRao I'd suggest that the OP posts the question here himself, I personally don't see value in moving it at this point
 
They've requested it to be moved. :/
Hmm, Wait
The OP hasn't asked it to be moved. I'll just let it go.
 
9:47 AM
0
Q: Alternating Characters

CodeYogiOnline challenge on Hacker Rank. Shashank likes strings in which consecutive characters are different. For example, he likes ABABA, while he doesn't like ABAA. Given a string containing characters A and B only, he wants to change it into a string he likes. To do this, he is allowed to d...

 
9:59 AM
0
Q: Python Inherit, long super all over the place

DualinityI'm wondering if I'm using super correctly here: from collections import defaultdict, Counter class DependencyVectorizer(DictVectorizer): def __init__(self, **kwargs): super(DependencyVectorizer, self).__init__(**kwargs) self.occurences = defaultdict(Counter) de...

 
10:40 AM
Oh well...
 
I wish I was a mathematician
 
@t3chb0t I was in math class and my teacher asked "what comes after 69?" Apparently "I do" was not the correct answer.
 
69,@Dex'ter, 71
(just joking, I know what you mean)
 
I know ^^ :))
 
11:09 AM
0
Q: simpler pattern/extension built on top of telepot (telegram bot api wrapper)

FATZOMBIsimpler pattern/extension built on top of telepot (telegram bot api wrapper) filter usage from nimmy import Bot from re import match, search bot = Bot("TELEGRAM_BOT_API_TOKEN") # filter model function returns, keys return None on failure def adminOnly(msg): return { 'admin': match...

0
Q: Prevent duplicate rows from 2 crons job

may saghiraI have a script that inserts into a database, the script is called from 2 cron jobs simultaneously so in many cases I can have the same data at the same time ( hour,minute,second ). Actually I don't have control on the cron jobs but I have it on the script. So is that any way to prevent duplicati...

 
11:32 AM
Hello
 
 
Monking
Having 1000 tabs open starts to really take its toll :/ Every time I shut down my PC Firefox crashes
 
0
Q: Generalizing work orders

Ismail KarchiHello StackExchangians, I am working on designing tables for work orders. The problem: There is different work order models (from now on called WOM) The WOMs share some attributes (Num, Date, Description, ... etc) The WOMs have details such as: Sectors on wich the work is done. Some WOMs us...

 
There are no new C# questions :(
 
@skiwi in the old opera 12 you could have 200 of them and it still worked, unfortunatelly it does not support high dpi monitors :(
 
11:47 AM
The only real problem I'm facing is that I have some cache issues
 
@denis ;-]
 
I'd need to do a clean install or something... The 350 MB cache fills up as soon as I boot up the browser, even if I just emptied it
 
I already forgot firefox existed
 
0
Q: MVC mongo, express, angular code reviev

Kaflan KatrushaI am need small code review: https://github.com/kaflanTech/testForNodeJS/tree/MVC Senks for help.

 
there should be a separate site for all the hackerranck, leetcode and what not questions
 
11:51 AM
Why?
 
because those problems are never real and there's nothing to learn from them, just some weird array search, sort, group
and mostly it's a math problem that has nothing to do with programming
 
That's not true
They're equally eligible for feedback and I could make a point that they're even more useful for a bigger audience
 
@t3chb0t it depends on the solution, there might be no time-limit so you can go OO as much as you want..
 
I don't mean they aren't I just mean they're different category
 
But I agree with you to a certain degree
 
11:55 AM
and... they've been solved hundred of times already
 
I think we even need them if we want to keep our zombie rate down and attract new answerers
I agree they're a different class, but that's why the tag exists
 
programming-challenge is a really broad tag @skiwi
A new C# question ! Aaand it's off-topic ..
 
Python 3.6 nested f-string oddity:
>>> f"""{f'''{f'{f"{42}"}'}'''}"""
42
 
@denis "all the hackerranck, leetcode and what not questions" this is all pretty broad :P
@Dex'ter ... wat
Or do you mean the distinction between mathematical and logical problems? @t3chb0t @denis
 
@skiwi I think I do mean it, all the single-method problems an 99% mathematical
 
12:03 PM
That might be a good point then, it does involve a major re-tagging though, but there's an argument to be made that you can filter them out if you don't want to see them, or if you do want to see them
 
It might be an exercise you got at some programming-competition which doesn't necessary means it's a math problem solved with programming.
 
I've just added this tag to the ignored ones, they're now quite invisible :)
 
I've tons of ignored tags makes it easier to find something suitable to review
 
-2
Q: How do I register application-local keyboard hooks in C#?

user126782How do I register application-local keyboard hooks in C#? I need it for PowerPoint Add-In development with C# specifically. There are lots of code samples on SO for global keyboard hooks e.g. with RegisterHotKey, but not for application-local keyboard hooks. I don't want to use GetAsyncKeyState ...

 
there should be one more opiton showing when a particular user was last seen without looking into his profile, it would be easier to tell if there's a chance that your answer has any chance to be ever accepted or upvoted
 
12:10 PM
Hmm, C# WPF with MVVM is a bit difficult in the start :/
There's too many ways you can do something :D
 
lol
Monking all
 
@skiwi you suddenly decided to learn every programming language ?
 
@Dex'ter I've always been doing that :P
 
@CaptainObvious One more VTC.
 
@skiwi I'm just in the process of reading msdn about wpf, page after page, and it actually makes more and more sense
 
12:12 PM
Hi @Mast
 
Producing working code isn't that difficult, producing code of good quality is more difficult :P
And I'm trying very hard to not give a damn about the layout :P
Now I'm curious though, I'm using MVVM as suggested, but apparently WPF has full support for navigation with urls
 
@t3chb0t There used to be an accept rate on SO, years ago
Was disposed of for obvious reasons: people would avoid answering questions asked by someone with a low accept rate
@skiwi MVVM is data binding, navigation is.. navigation. How would you use them interchangeably?
 
@JeroenVannevel I'm navigating between different views in MVVM right now
 
That's probably a reason why I'm stuck ^^
 
12:28 PM
codereview.stackexchange.com is much better place for that — Dekel 24 secs ago
 
I don't see what the issue is
 
I'm not exactly sure at what point I would need navigation support from WPF, because right now I have a MainWindow with a ContentPresenter that presents a different ViewModel and View respectively
 
Ah, so it's the desktop equivalent of a SPA
 
Pretty much, my application isn't terribly complicated
I'm supposed to bind an ICommand to the button in view 1 to load view 2, but didn't know I could just bind a parameter to the command
 
I've got no experience with that. Looking at my winphone code from 2 years ago, I see that I just made multiple pages and navigate to them through <HyperlinkButton Content="About" Padding="20 20 20 20" NavigateUri="/Views/About.xaml" />
 
12:33 PM
Sounds like that's the way that WPF suggests too
but then everyone on SO is going wild on the MVVM :D
 
That is MVVM as well
MVVM is just the databinding part
navigation (multiple pages) or not is separate
MVVM is just the logical way of populating the view with data from models that get translated through a viewmodel object
 
So right now I'm just pretending it hosts a single page that is a SPA
 
1:16 PM
I think he's saying that he talked to you about it in chat, as opposed to having posted the same question twice, thus he wasn't purposely duplicating himself. @digEmAll If you don't get an answer here perhaps try Code Review SE site (after deleting to avoid cross-posting) since this is more about the best way to code something rather than how to code it. — Hack-R 54 secs ago
 
0
Q: Minecraft Protocol Data Type Implementation

DownvoterI'm at writing a basic Minecraft client and have started with implementing the various data types exchanged in packets between client and server. My basic design is an abstract class Type, from which all types inherit in order to (1) enable polymorphism and (2) force the concrete types to implem...

0
Q: Move nodes if no veto from councilors

Peter RaderWorking on a DTP based on Maven/Spring having a JTree(containing nodes as layers) try to implement a Authorithy for decide if layers can be droped to a target-layer. Instead of osgi I use the maven dependency to create plug-ins who are allowed to contribute to the council using CDI. The Impl: ...

0
Q: SFTP Ruby script for downloading files from server

Ashish WadekarFind the original script at this link #This script is used to download file from the server to your local machine #The implementation is based on pure Ruby implementation of SFTP using gem Net SFTP #To install this on your local machine please run the following command in your terminal 'gem inst...

 
Would be cool if WPF doesn't crash for no reason
Okay, there's a reason, but I don't understand it
> When the View is closed the ComboBox Selection is emptied. You can check this by handling SelectionChanged event and inspecting the SelectionChangedEventArgs RemovedItems collection. This ends in String.Empty being passed into your ValueConverter.
Really :|
 
why not make the value-converter more robust?
 
I can now I know what the issue is, but I was not expected it to need to handle strings
Still seems incorrect behavior to me
 
alone the thing that everything is an object is already anoying, you always need to check the types and cast all over the place
 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string && string.IsNullOrEmpty(value as string))
            {
                return string.Empty;
            }

            var heroClass = (HeroClass) value;
            return heroClass?.Name ?? string.Empty;
        }
Meh, this will do
 
I'm voting to close this question as off-topic because it is a code review question, without actual problem. — hyde 41 secs ago
 
If it's not the expected class nor a string then I don't know either and it can just crash
 
this is enough string.IsNullOrEmpty(value as string), you don't need the first check
it'll be null if it's not a string and will evaluate to false
 
1:28 PM
This question is too broad for Stack Overflow. I think it would be better suited to the Game Development Stack Exchange and/or Code Review Stack Exchange sites. — Bobulous 14 secs ago
 
actaully you can do this
return (value as HeroClass)?.Name ?? string.Emtpy
 
@digEmAll: Congratulations. You just won the prize for lamest excuse to not do any research yourself. There is a SE site for code review. This isn't it. — Dirk Eddelbuettel 35 secs ago
 
(HeroClass) value
this cast isn't save and will crash rather then be null
that's why we have the as operator, it will eval to null if the cast didn't work
 
@t3chb0t I think I do, if I leave it out and it's HeroClass then casting value as string will fail
 
Btw why do you have all those parameters when you you use only the first one :?
 
1:31 PM
@t3chb0t Oh... okay, didn't know that
 
Is this just a chunk of the code ?
 
@JeroenVannevel Isn't that kind-of hacky?
 
@denis Because it doesn't compile if I delete them
 
How come is this used as some event handler ?
 
@Mast in what way?
 
1:32 PM
@skiwi Deleted code usually doesn't compile, no.
 
@denis It's part of my class that implements IValueConverter
 
@skiwi make it a one-liner ;-]
 
@t3chb0t Yeah, just saw it, way better
 
@JeroenVannevel I thought that kind of links were intended for external things, not for thing part of the original design.
 
@skiwi is it possible to make them optional parameters ? Or maybe create additional overloads ?
 
1:34 PM
Nope, and not my problem either :)
 
@denis nope, the converter interface is given and cannot be changed
 
Oh I see :/
 
@Mast Not that I'm aware of but to be fair I know almost nothing about WPF
 
Neither do I.
 
I think it's a bit like <a> in html which is fine to reference internal or external pages
 
1:35 PM
I need to try to create a type save converter ;-]
 
That'd be pretty cool
 
@t3chb0t I think it'll involve quite some hacks though, I never expected it to try to parse an empty string for example
This means the core of WPF is flawed in this regard
if it was typesafe in the first place then the worst it could throw at you would be null
 
@skiwi if WPF would ignore null values or empty strings then there would be no way to reset something
 
well, I just don't want them passed to my value converter
 
0
Q: Implementing JoinWithAnd method

codingkapoorObjective Write a function JoinWithAnd in Java with following signature: String JoinWithAnd(String a, String b, String c, String d, String e) So that: 1.If no input is provided, it returns an empty string 2.If any one input is provided, it returns the string as it is 3.If more than one inp...

 
1:43 PM
If you want others to review code you have written, SO has a sister site just for that: Code Review. I don't hang out there, but there is good advise. Another good thing for users new to SO is to look at the list of top answers for a tag and seek out their answers first. — Guy Coder 16 secs ago
 
@CaptainObvious That question looks pretty useless to me, in a practical setting
 
@skiwi More useless than a Brainfuck interpreter in ASM?
 
@Mast Yes
The code in that question would not have any purpose to be re-used in Java, maybe it'd be valid if it was coded in C
My Brainfuck interpreter in ASM on the other hand has tons of practical value
Right
Hmmm reading over return (value as HeroClass)?.Name ?? string.Empty; again it looks like I have no clue what I'm doing because of all the question marks
 
@skiwi Stop using ternaries and all will be clear again.
 
I don't use a ternary ^^
 
1:54 PM
but it's pretty and short
 
If the value is of type HeroClass, use its name. Otherwise use an empty string
seems fine to me
But if you're getting used to the C# operators then it might not be clear
 
It's clear to me, was more sarcastically :P
 
@skiwi Whatever all those question marks are called then.
 
ah like that
 
The ?? is called null-coalescing, the former one I don't know but I do know what it does
 
2:02 PM
null propagating
 
Ripe zombie; open question with answers, at least one answer having score 0, no answer having score > 0: Finding vowels, digits, whitespaces and consonants
 
2:24 PM
0
Q: Endianness conversion in C

Jack WilsdonI have written a simple C header for converting the endianness of short integers and long integers. It uses the GCC macro __BYTE_ORDER__ to check the system's byte order and define the macros based on that. The header creates the macros LITTLE_ENDIAN_SHORT(n), LITTLE_ENDIAN_LONG(n), BIG_ENDIAN_S...

0
Q: Library to play and create AI for "Connect Four"

KayI am looking for some advice to this code I made, which enables a fellow programmer to create his own AI for Connect Four whilst not really having to code the game itself Match class public sealed class Match { public const int cWidth = 7; public const int cHeight = 6; private stati...

 
2:46 PM
@skiwi @Mast --> (value as HeroClass)?.Name this is a null dereference
> x?.y – null conditional member access. Returns null if the left hand operand is null.
 
Monking
 
Monking @Phrancis
@Malachi That's probably obvious once you're used to them, but I'm not a fan of such constructs.
 
Monking @Phrancis
@Mast I'm less of a fan of filling my codebase with stupid null checks
2
 
0
Q: Pruning unwanted columns from a selected row

gelliott181I've got this little module that returns basic user data required for a web app that's extracted from a large number of columns per row. I was asked to replace the small, column specific select statement I'd prepared with a stored procedure that returns the entire row. This moves column pruning i...

 

« first day (1334 days earlier)      last day (1526 days later) »