« first day (1430 days earlier)      last day (3520 days later) » 

8:03 PM
Every time I see a question along the lines of "This is what I want. Is it possible?" or "This is what must be done. How do I do it?" I have a burning desire to add the comment "Maybe you should hire a developer"
 
user862319
oh my god i just discovered HDBaseT
 
user862319
why is this not a huge thing
 
This is what I want: read messages from a socket efficiently, ideally serialize directly from the stream. Is it possible?
 
user862319
@JohanLarsson google flatbuffers?
 
@JohanLarsson - You should probably find some way to chunk the stream
 
user862319
8:05 PM
in-place deserialization
 
Hey all. Really lost on something here and not even sure how to ask about it. I am loading some assemblies using Assembly.LoadFrom. These assemblies are being used by PRISM modules. There are two modules: A and B. I can load version 1.0 of my assembly for module A, and version 2.0 for module B. The different versions of my assembly are in different folders.
 
@Bob ty ty will check it out
 
However, when I try to do the same for an assembly from a third party (specifically from Syncfusion), both modules only used the first version loaded.
Can someone explain why?
 
The second version was in fact the same as the first version?
 
for my assembly or the third party assembly?
 
8:08 PM
@TravisJ yeah, looking for some lib, feels like all kinds of bugs rollning my own
 
user862319
Such wizardry... 2160p uncompressed video, 100w of DC power and 100mbps LAN on a single cat6 cable @ 328 feet.
 
@Bob - HDBaseT is a transmission process? Still runs over cat5e, not sure I understand the significance of it
 
@JohanLarsson protocol buffers is probably the most efficient thing out there
Marc Gravell has a very nice implementation for .NET
 
user862319
@TravisJ huge convenience? One cat6 wire to your TV and that's it. Don't even need to plug it in.
 
TV's use more power than 100W
 
user862319
8:11 PM
true
 
user862319
it wouldnt work for plasma
 
user862319
but a small outside tv or something...
 
true, but for LED it would
besides, most PoE is at 48v
so if it can support 2.5 amps then you have your 100+w
 
user862319
yep
 
8:12 PM
though I wouldn't do that on anything less than cat 6
 
user862319
yeah they say cat5e is sufficient but i dont believe them.
 
@ReedCopsey ok ty, checking it out. I'm expecting a high volume of these (only want the args)
 
@JohanLarsson is this still the json thing or general-purpose streaming?
 
json thing
 
@JohanLarsson if you can't control the feed, then it won't work
you'd pretty much need to handle parsing the json yourself
 
user862319
8:13 PM
ah yeah for protobuf and flatbuffers you have to compile the object and implement both ends
 
@TravisJ were you asking me about assembly versioning I was referring to?
 
@ReedCopsey ok I'm doing it the dumb way now, ReadLineAsync(), then check for type of message then string split -> deserialize
 
@BrandenBoucher - Perhaps the second one was just a copy on accident?
 
I don't like the temp strings
 
@JohanLarsson Does one feed provide >1 type of message?
that's a pretty bad API
 
8:15 PM
@ReedCopsey yes
 
You could use JSON.NET, grab each feed entry, and parse the cmd yourself
 
@TravisJ Well, I verified the source files on the disk and then I verified the assembly version... Wait. I may have just found my problem
 
then deserialize the args JToken into your class
 
@ReedCopsey grab feed entry meaning saving it as a temp string=?
 
AARG. I hate it when I waste this much time on a dumb mistake
 
8:16 PM
yeah - probably need to read in each line no matter what
 
ok that is what I'm doing now
 
each feed entry come in as one line?
or does it actually come through like that?
 
yes, newline separates them
 
well - if you're using string.split, that's more work than necessary
 
8:17 PM
I'm using var json = await reader.ReadLineAsync();
purrhaps ok apart from the string
 
once you have the line, you should be able to feed that into JSON.Net directly
 
that is probably nicer than the substring I do now
 
yeah - you can use their tokenizers - which will protect you from format changes a bit
 
var o = JObject.Parse(Properties.Resources.Price);
var jToken = o["cmd"];
var token = o["args"]; // What is a clean way to deserialize args here?
token.ToObject<>() maybe just like that?
 
user862319
shouldnt your args just be a json array of objects?
 
8:33 PM
custom parser brah
 
user862319
D:
 
@JohanLarsson Yeah - should be able to do that
provided you put the right type T in there
it'll use the tokens that it needs
 
@TravisJ I may have found a way to do it cleaner, apparently the data that is generated in the Template is returned from a Stored Procedure. So I might be able to have him just do it as a return for me. Rather then do that second call.
 
Nice
That would be ideal
 
@TravisJ Yeah, so I've just got to make sure that is the point of this Stored Procedure.
Because it looks like the code behind locates all of the transactions, then builds an XML Document, then for each node it applies to a View State.
Which the XML is matching to that View State.
 
8:40 PM
If I have an event with a string what does eventargs add really? Just feel like an allocation?
 
nothing - .NET 4.5 doesn't require it for EventHandler<T> anymore
so you can do EventHandler<string> now
 
yeah I already did it
Thank you sir for being reg here!
@Bob they come one by one in random order and at random times
 
user862319
the args?
 
the messages, the args is just one instance despite its name
 
yeah - it's one "set" of args, right?
 
8:46 PM
that is probably the correct way to read reed it
 
user862319
id like to see an example json string
 
@ReedCopsey Did you hear that mads torgersen got hired by Coverity?
 
@RyanTernier where did you hear that?
 
@ReedCopsey Coverity - did a demo with their PM's the other day
 
8:55 PM
I do'nt think tha'ts public knowledge (yet) :p
but that's sad for C#
if true - Mads is an awesome guy
 
He was a great presenter! Loved hearing him speak
 
user862319
@JohanLarsson so it looks like you have to parse out the cmd field
 
user862319
and then perform deserialization based upon the command
 
@RyanTernier well, I can't find any mention of it anywhere - so who knows if it's real or not - would be sad if it ends up true, though... C# team would have lost some real talent over the last couple of years in that case
 
user862319
because some of those are going to be singular objects for status and what not and others are going to be variable length fields
 
8:57 PM
@Bob yep
 
@RyanTernier - You got to talk to Mads?
 
@TravisJ Yea, met him at Tech Ed
 
That guy is amazing
jelly
 
He talked about C# (and everything with it) like it was part of his body
 
That is because he implemented part of it
 
8:58 PM
We went for a walk today... C# helped me over the road... we had coffee, kicked Java's ass... Yea C# rocks
 
user862319
@JohanLarsson are you trying to do any low-latency trading or something here?
 
@Bob not really, wrote a thing for fun and made it open source. Was contacted by a guy who wants to use it so giving it some love now.
wtf build fails in release now, works in debug. Missing a RestSharp ref that is where it should be
 
user862319
ok cool... you had me thinking about how to write verilog to deserialize json in an FPGA for a few moments there...
 
hmm, things got slower 41s instead of 24 for handling 1M messages
 
user862319
maybe you should use an fpga :D
 
9:04 PM
dunno what it is
 
user862319
you could handle 1M messages in a few milliseconds
 
TBH, JSON is a horrible format if speed is an issue like that
 
can't do anything about the json
 
how were you deserializing before?
or were you doing it manually?
 
9:11 PM
speed is prolly not an issue either, handling 42k messages/ second is > my bandwidth
private T Deserialize<T>(string message)
{
    const string value = @"""args"":";
    int start = message.IndexOf(value, System.StringComparison.OrdinalIgnoreCase) + value.Length;
    int length = message.Length - start - 1;
    string json = message.Substring(start, length);
    var o = JsonConvert.DeserializeObject<T>(json, _serializerSettings);
    return o;
}
Don't like the substring at all ^
 
user862319
why not just pull a deserialized object out of the args field and then cast it to whatever command type you need?
 
mmm
@JohanLarsson Why not just build a JToken and use JToken.ToObject<T>?
you've already built one to get the T here, right?
 
I just tried it it was slower
 
mmm - it should be faster than going back to the string
and re-calling DeserializeObject<T>
 
ok doing it again now
 
9:23 PM
Hi guys, does anyone know how to read the content of a nuget source via c#, and then take that source to output a zip web deploy package ? just the same way how OctopusDeploy works.
 
By writing some code?
 
yeah programmatically via c#
 
That's how you do it. Perhaps you could ask us something more specific?
 
I'm reading the files at the moment. But I want to take a .nupkg file as input and then read the content particularly config files.
 
Awesome. Those are text files, yes?
 
9:26 PM
web.config files
 
You read those the same way you would read any other text file, unless you want to interpret the XML. Your question is probably a bit broad to be answerable in a chat room.
 
var token = JToken.Parse(message);
if (token["cmd"].Value<string>() == "depth")
{
    var tick = token["args"].ToObject<DepthTick>();
    OnRecievedDepth(tick);
    return;
}
@ReedCopsey ^ is how I implemented it. Takes 2x the time.
 
Can you use JToken.ReadFrom and read from the stream directly?
 
@RobertHarvey My question is how can I just open a .nupkg file so that I can go in and read .config files from the source. I am able to create a .nupkg file of deployable artifacts of my asp.net mvc application.
 
nm - you'd lose the async reading
 
9:28 PM
@ReedCopsey That would be nice but I have not figured out a nice way to do it async
 
yeah :(
 
also it is tcp so I need to buffer until newline
if (message.StartsWith(Depth))
{
    var tick = Deserialize<DepthTick>(message);
    OnRecievedDepth(tick);
    return;
}
 
@Yoda - You can unzip them just like a .zip file.
 
^ the faster implementation
 
This is ugly, but out of curiousity, is this the same speed?
if (token["cmd"].Value<string>() == "depth")
{
    var tick = JsonConvert.DeserializeObject<DepthTick>(token["args"].ToString());
    OnRecievedDepth(tick);
    return;
}
 
9:29 PM
:)
 
@TravisJ do I need any third party library to do that or is there anything built-in to .net ?
 
If you want third party this one is standard icsharpcode.github.io/SharpZipLib
otherwise, you can do it all in .net it just takes more work
 
Or DotNetZip (IMO much nicer than icsharpcode's dotnetzip.codeplex.com )
 
Or Reed's suggestion
I haven't used either so I would go with his
 
@ReedCopsey Slower, I'm getting 24s for the fastest 39s for the ToObject and 49s for that one
 
9:32 PM
(it's been much better, IMO - + has the benefit of a nicer license)
@JohanLarsson okay - just checking - makes sense that it'd be slower, though
 
ok thanks guys I'll give it a go. Actually I'm making a custom packager tool.
 
you're trimming the string before this for message.StartsWith?
 
nope testing the raw message, then doing substring in Deserialize
is a stringreader immutable?
 
if (message.StartsWith(Depth)) - is Depth something like "{ message="Depth"" ?
 
private const string Depth = @"{""cmd"":""depth""";
 
9:34 PM
yeah -okay
what were the possible messages again?
 
you could change StartsWith to an index check
would speed it up, and only need special logic for 't' then
 
indexof("depth") >0 ?
 
ie: a switch on message[8]
no:
if (message[8] == 'd') [though I'd use a switch on message[8] probably)
 
very readable :)
I get your point
 
9:38 PM
that's about the only other optimization I see
other than maybe doing the deserialization yourself manually, but that'd be ugly
 
I have a bunch of ugly ideas about ReadAsync to a buffer, then check for \n and have a memorystream wrap the buffer
to avoid the string, re-use the buffer & memorystream
pretty error prone
 
yeah - I wouldn't worry about the string too much, TBH
ReadLineAsync will already be buffering everything for you
so you'll likely not help much there
and you'll need the string eventually in any case....
 
maybe, I was thinking jsontextreader
and resetting positions and all kinds of ugly
code not even a mother could love
 
Question:
<xsl:if test="AmountOfCreditIncludingDiscount != 0">

Is that referencing the node?
 
9:58 PM
ok so I wrote this pastebin.com/GYLwpihZ can anyone recommend some more practice code, particuarlly something game like? Hopefully the program would give you an idea of my skill level, but you know suggestions are cool.
Also I love you guys.
 
That should be the node and testing that there is zero value correct?
 
10:29 PM
@Tokencodingnewbie what about a card game. that's usually good practice, both functionally and learning OOP
 
Kendall Frey has me doing tic tac toe
 
a simple blackjack, or go fish
that'll work too
 
Just kind of trying to print out the game board now, I think I got it
 
how are you doing it now
 
Looping an array of chars to print.
 
10:31 PM
Where's the thing of the computer guessing the user's number?
I guessed the computer's number
 
Oh, I did it backwards.
I thought you said have you guess against the computer
 
the computer guessing the computer's number?
 
That's kind of... cheaty :P
 
I didn't think it was too cheaty.
 
10:33 PM
only because you didn't cheat
 
Well yeah
I could of just had CompGuess = number;
lul
 
yeah
that's why I don't play games where the computer controls win/loss
When I lose, I want it to be because I'm an idiot.
 
Well I can add that then I suppose.
 
"object orient" it
anyone know if IIS can set the maximum file size downloadable
i.e. only allow people to download something 1GB... if it tries downloading a 2GB file it'll shut down the connection/download
 
Is this right?
Random winner = new Random(0, 100);
Random random = new Random(0, 100);
List<string> person = new List<string>() { // Add logic to add five people. };
Dictionary<int, string> weighted = new Dictionary<int, string>();
foreach(string name in person)
     weighted.add(random, name);

do { Console.WriteLine(weighted.Value.Contains(winner); }
while (winner == random);
 
10:47 PM
what would make it wrong?
 
Does it actually work?
Like random?
It shouldn't write until it finds a random winner right?
 
well there is nothing in person
ahh missedthat comment
they all have the same random number
i would say, no it doesn't work
 
@Greg What do you mean is it right?
Did you try compiling it?
 
Random doesn't constantly add a new random number. Well, that sucks.
 
What do you mean?
 
10:51 PM
no, but new Random(0, 100); does
the while loop makes no sense
 
What language are we talking about here?
I am lost
 
I should of done Random();`
 
thats a 1/101 chance anything gets printed
 
Supposed to represent a random selection of people.
 
SOMEONE EXPLAIN WHAT IS GOING ON
Are you guys really talking about code that doesn't make any sense at all?
 
10:53 PM
@Tokencodingnewbie quiz question #1... tell me why Program.guess isn't 0 at the start of the program
 
@KendallFrey I'm trying to decipher a stack question.
 
you can make sense of the code with some assumptions, and i'm stating what is wrong based on those assumptions
 
@Greg If it has code like that, don't bother
 
@KendallFrey ?
 
is that code you wrote
or someone else
 
10:55 PM
@NETscape Well, both.
I carelessly did the Random being the same.
 
do { Console.WriteLine(weighted.Value.Contains(winner); }
while (winner == random);
think about that
 
No, I want to remain sane
 
it's going to compare once
or forever
 
@NETscape Well, that would be infinite. If those randoms never actually matched.
 
@Greg Actually, it'd be infinite if the randoms did match :)
 
10:59 PM
@ReedCopsey Oh.
 
and that's why i never use the do {} while() syntax
 
@NETscape Well, that makes sense.
 
do..while has its place. But I haven't needed it in a long time
 
@KendallFrey for instance... when?
 
When you want to loop 1..N times
 
11:02 PM
Well, the goal was to randomly choose a winning number. Then take the randomly inserted values in the list, then essentially choose one that actually matches.
So, now that I think about it. I'd almost want to change that quite a bit.
 
> I am working on a "guess my number" game and have ran into a problem. My game is supposed to select a random integer between 1 and 10 and allow the user to guess until they guess the correct number. After each guess, I'm supposed to display a message telling whether their guess was too high, too low, correct, or if they'd guessed that number before.
damn, deja vu
 
I use this for random numbers
public static class rand
{
	public static Random val;
	static rand()
	{
		val = new Random();
	}
	public static int Get(int low, int high)
	{
		return val.Next(low,high);
	}
	public static int Get(int high)
	{
		return val.Next(0,high);
	}
}
 
rand.Get(high: 420);
 
@TravisJ Why break C# naming conventions?
 
c# naming conventions
was going to google that ;)
It is used in linqpad mostly, but Get seemed shortest to write when I made it
 
11:13 PM
well, technically, it's .NET framework naming conventions: msdn.microsoft.com/en-us/library/vstudio/…
but type names should be PascalCase
 
You mean for the caps class name? Or for using Get?
It felt more like a variable than a class. Cannot instantiate a static class and it always gets used as having inherently been instantiated.
 
@NETscape Because int by default initializes to 0?
 
@TravisJ class name - static classes are still classes
@TravisJ that just makes it look like it's an instance variable when it's not - having it capitalized lets the user "know" by how it's used that you're calling a static method - which is valuable
 
@ReedCopsey - If it weren't just for simple testing it would have caps
I tend to avoid static in general though, it doesn't always play nice with others
Nice to have an instance around.
 
yeah - I'd just use a Random instance ;)
 
11:26 PM
@ReedCopsey , have you ever had a chace to use CSLA.net?
 
@RyanTernier I looked at it, but haven't used it
Rocky's a great guy - but I just haven't ever felt like the complexity its adding is worth it, at least in my scenarios
 
Hello everybody
 
it does so many of its own abstractions, in unique ways - just didn't want to try to push it into my stack
 
hey, can anyone give me a hand with this: stackoverflow.com/questions/25840141/…
 
@RyanTernier I also felt that it carried a bit too much of its history in its design
ie: it still feels like it's a port of a VB6 project to me :S
 
11:33 PM
I am working on a project, is it possible to get the location of the image that is set as wallpaper in my windows desktop?
 
@ReedCopsey I sort of feel that way. I've been brought on a project as a "part time C# Expert "(love the title... ugh...) and the lead chose to use it. It's interesting, but yea, reminds me of VB 6 :) It will be interesting to see how it plays out with TDD and DI.
 
could somebody help me in this?
 
@RyanTernier It's horrible with TDD
there's no real way to unit test business objects
that's probably it's major flaw
 
@ReedCopsey Ugh... Even with using mocks?
 
the best you can do is integration testing
but all of the data access and persistence is baked into the business objects
 
user1881400
11:35 PM
For anybody that makes method extensions, is it possible to make an extension that creates an instance of the object? For example: String.FromBlahBlah().

@afzalex http://www.dreamincode.net/forums/topic/124884-get-current-desktop-wallpaper-resolved/. Google is your friend
 
which pretty much breaks the ability to unit test
 
@ReedCopsey Yea, TDD using System/Integration tests is better than "none", but Unit tests are soooooooo nice
 
To be fair, I've found that my dislike for frameworks, in general, has slowly been going up, though
 
Actually I was working on java, but I heard that with C# it could be done easily.
I searched on internet
 
@FizzledOut You can't extend a type
 
11:37 PM
@FizzledOut Now here's your next assignment. Find the wallpaper of your coworkers computer through .NET, and then CHANGE IT using .net from your computer. NOw do the same to their lock screen.
When Complete, watch as your co-worker screams in horror when they see http://fc04.deviantart.net/fs71/f/2013/196/c/2/smexy_unicorn_man_to_da_wesque_by_sissurrealatourium-d6doi9q.jpg as their background
 
@FizzledOut Extension methods are just syntactic sugar around a static method - so just use a normal static method, ie: static string StringFactory.CreateFromBlahBlah()
 
I want to change the whole folder (a set of images) that is set as wallpaper in windows. Is it possible?
 
user1881400
@afzalex Just go to Google and start the query with the name of the programming language, followed by the key phrases, in which I used "get current wallpaper". @RyanTernier That will be my next nightmare. @ReedCopsey I know, but I was hoping I could make it all in one place. I have a class that extends ResourceDictionary and all other extensions can be accessed from ResourceDictionary. I was hoping I wouldn't have the one oddball method, but I guess I have to live with it.
 
@FizzledOut Not allowed in C# ;) You can do it in F#, if you want...
but it won't be usable from outside F# that way ;)
 
ok so I'm using the unicode for a square and it's printing question marks.
 
11:41 PM
@FizzledOut I searched there, and didn't found anything. I thought may be here I could get some help, or may be I could get some direction.
Okay I will come back after searching even harder.
 
@RyanTernier I'm a big fan of persistence ignorance within my type system, though - which is part of why I don't like CSLA (and many ORMs, at that)
 
I hope I will get anything there.
 
@ReedCopsey Some patterns make things super complex. Sometimes all you need are simple POCOs, good polymorphism & OO practices and good music.
 
@Tokencodingnewbie That means you're not using Unicode, you're using ASCII.
 
but it said unicode on the website D:
 
11:47 PM
What website?
 
the one on the interweb
 
Most likely you're trying to display a Unicode character using ASCII
 
@RyanTernier Leave out the "OO practices" and I'd agree 100% ;)
 
@Tokencodingnewbie Where are you printing it?
 
11:54 PM
static private void printGameBoard()
        {
            Console.WriteLine("  A B C");
            Console.WriteLine("1 {0} {1} {2}", gameBoard[0], gameBoard[1], gameBoard[2]);
            Console.WriteLine("2 {0} {1} {2}", gameBoard[3], gameBoard[4], gameBoard[5]);
            Console.WriteLine("3 {0} {1} {2}", gameBoard[6], gameBoard[7], gameBoard[8]);
        }
 
Oh, console?
I don't think it properly supports Unicode
The best you can get is 'extended' ascii
 
yeah
 
Is there a website for that?
 
website for what?
 
protip: box drawing characters are useful for console graphics
 
11:57 PM
Box drawing characters?
A website with the codes for this extended ascii
 
@Tokencodingnewbie You'll find it'd be a lot easier to just build a GUI
console sucks for trying to draw graphics
 
This is newbie practice :(
Building a GUI seems...advanced.
 

« first day (1430 days earlier)      last day (3520 days later) »