« first day (2893 days earlier)      last day (2054 days later) » 

12:16 PM
ok, how do I read a csv file as IEnumerable<IDictionary<String, String>> ?
when I google for it, I only find stupid answers with String.Split
and the docs of the lib I used doesnt show how to read it with a header row
 
@Wietlol CsvHelper lib.
 
what's wrong with string.split?
 
@Default you cant use that to parse csv data
 
what's the definition of a csv file?
 
12:19 PM
comma separated value
but values can contain commas
also, values can contain newlines
also, excel cannot read csv files
because its shit and expects them to be separated by semicolons instead
rant.Dispose()
 
@Wietlol Well, some of your rant was actually true this time.
 
some?
 
I've read comma-separated CSVs in excel hundreds of times. Not hard to use.
 
And you actually disposed of your rant properly, which is nice
 
lol
 
12:21 PM
Also, anyone who supplies me CSVs with embedded newlines will be shot.
 
it places them in a single column for me
 
Well, the imperfection is yours.
 
@Neil I should have used a using expression though
 
I would have preferred using (var rant = new Rant()){ }
 
But yes, the main error you get with naive String.Split implementations for CSV is missing escaping/quoted strings.
 
12:22 PM
new Rant().Use(rant => {
    ...
})
oh yes, when the values are escaped, it will also have the quotes around it
which is also bad
@AvnerShahar-Kashtan have you used this library before or did you just google one?
 
it looks viable
 
EnumerateRecords looks... weird
 
Used it in several projects, yes.
 
have you used it to read as a dictionary? and if so, how?
 
Do you specifically need it as an IDictionary, or would just like to access a value by name?
> You can use an indexer to get by position or name. This will return the field as a string.
// By header name
var field = csv["HeaderName"];
 
12:27 PM
well... I suppose that the csv reader doesnt have a common interface with a dictionary
 
// Gets field by header name returning bool
var field = csv.GetField<bool>( "IsTrue" );
 
i need it to work at least for a dictionary
 
Something I see often in Java (unfortunately) is having a List of Maps so that each Map instance contains field:value pairs
 
you could also have it as a IDictionary<String, IList<String>> I guess
but that is weird though...
 
Well you could use a flyweight pattern, it would be better
 
12:30 PM
use .ToDictionary?
 
@Wietlol That wouldn't make sense. CSV is record-oriented, not column-oriented, usually.
 
use the same header list and share it amongst instances representing each individual line
 
You could transform and pivot it, of course, but I wouldn't expect a CSV library to supply that, necessarily.
 
but if you have IList<IDictionary<String, String>>, you have stored a lot of pairs
even though the keys of each dictionary would be the same
 
@Wietlol So use a DataTable.
 
12:31 PM
which is what Neil's point is I guess
 
That's what a CSV is, basically.
 
how do I convert it to a datatable?
or anything like it
 
1
A: How to add CsvHelper records to DataTable to use for SqlBulkCopy to the database

Rahul MisraJosh added support to read headers last year and the following block may be useful to those who just want to build a DataTable using the schema of the CSV document. I wanted to post this as a comment to Josh's answer as it is only a small modification but posting as an answer as I couldn't format...

 
0.o? I dont have FieldHeaders
 
@AvnerShahar-Kashtan none of those answers take into consideration the possibility of running out of memory
 
12:34 PM
 
Which if you're dealing with bulk reads and writes, that's a serious issue
 
running out of memory wont be an issue
we have infinite memory!
.... ok actually not
 
Frankly a little surprised that nobody thought to do it in bite-sized pieces
"What do we do with this massive table insert? Why load it all in memory! It'll hold!"
 
> it will return an IEnumerable that will yield results. This means when iterating the results, only a single record will be in memory at a time, instead of the entire file. Records aren't pulled until you actually start iterating the results.
Honestly, the documentation there is pretty explicit.
 
None of the answers actually mention IEnumerable
 
12:46 PM
wouldnt the entire data be in the data table (which I assume would be in memory)
the whole idea of bulk copy is... well... bulk
and also a tiny bit of copy
 
If you first put it in the data table, it would be in memory yeah
If you load each row, then insert it, then no
 
> How to add CsvHelper records to DataTable
however, you might have everything in memory multiple times if you are not careful
 
1:10 PM
Fun fact: sloths poop only once a week, and it can be up to 30% of their body weight.
5
 
@Neil What really
 
apparently so
 
oh my god that is horrifying
 
so suffice to say, don't listen to anything a sloth tells you. odds are, he's full of shit
 
> [..] one of the best hypotheses [..] is that sloths poop in such a weird way to keep a balance between them and moths.
That's even creepier!
 
1:13 PM
> The laborious experience of going up and down the tree is compounded by the actual pooping process. Sloths actually do a little dance at the base of the tree to create a hole for the feces, and then shake their hindquarters once more to cover it up.
 
"pooping process"
 
This was a fun fact.
 
1:55 PM
@Neil Oh, my search query parser isn't for URL query strings, which is what I think you're talking about. It's for MTG card searches, like "cmc>5 && typeline includes skeleton || [cmc>2 && rarity=rare || rarity=mythic rare]"
(in reference to my comment from something like 8 hours ago)
 
@person27 Oh, cool
I could use a search engine like that, honestly
 
hi guys
 
@c0dem0nkey \o
 
hey i got visual studio quick actions broken
i mean i can't right click and auto add references
you know the using statements?
any insights?
 
Repair VS.
Actually, I don't even know, can VS2017 do that? ReSharper can, but I'm not sure w/o it.
 
2:08 PM
Right click? I usually alt+enter when it prompts me. May be R# though.
 
@Neil Scryfall.com has a card search of their own you could try. I haven't fiddled with it enough to know how good it is. I'm replicating it because (A) server calls are expensive and I support some query relationships it doesn't, and (B) because the point is to make a deck generator. It has to generate its own queries randomly based on patterns and baseline guidance for deck size, creature pool, etc. Breaks ties with edhrank, which is just averaged user data for which cards are popular.
 
ah damn @RoelvanUden thats what i was thinkin
 
2:28 PM
1
Q: Is it better to write an efficient algorithm or code that is easier to understand?

Tyler MSo I was recently given a coding assignment from a large financial firm, and I thought of two ways to solve the problem. One of the ways involved 1 outer for loop and 1 inner for loop. In this case, the code would be relatively easy to understand, and I saw this method as a more "obvious" solutio...

Am I the only one thinking that you should simply try to make the more efficient way as clear as possible?
 
I am the one that thinks you should make the clear way as unclear as the efficient way
then it looks like you did the efficient way, but its clearly the clear way
 
2:49 PM
Hey guys, I've a quick question regarding interfaces! I'm taking method A from class A to class B, but there are some other methods in class A that need method A. So I decided to add the declaration of the method to the interface so class A methods can still have access to it. But obviously, the interface is only the declaration, and implementation of the method is in class B now. How can I use the interface to call the method?
I had to ask this question here to prevent the rain fall of down votes
 
0.o?
I am confused!
It hurt itself in its confusion!
 
lol let me explain it this way
 
can you show a concrete (or cement, either work) example?
 
Has anyone requested confirmation code from AWS Cognito
When I do forgot password process I would like to get confirmation code from Cognito, so I could send this code with Email as well
(not only with SMS)
 
you have forgotten your email?
try "I have forgotten my password and my email."
 
3:00 PM
Public class A {
public void doSomething(){ return Console.WriteLine("Hello World"); }
}
I shouldnt have hit Enter, I;m still typing the rest of the code sample
 
appreciate that
 
@Wietlol I am developing solution for forgot pin. It is one simple API call to Cognito to send out verification code by SMS. But now I would need to get this verification code to send out Email from system as well
 
Public class B : IMyInterface {
public void doSomething() {
return Console.Writeline("Hello World");
}
}

public class A {

protected readonly IMyInterface myInterface;
public void writeSomething() {
return myInterface.dosomething();
}
}

interface IMyInterface {
void doSomething();
}
 
paste.ofcode wasnt appreciated enough
 
3:10 PM
I know this is wrong. I just tried to make it clear what I meant! I'm calling dosomething() using the interface
 
yes, ok
 
but how does the interface know where the implementation is
?
 
it shouldnt know
 
if not, the function wont do anything
 
why wouldnt the function do anything?
 
3:11 PM
because it is calling the declaration of the function inside the interface
the implementation is in class B
 
you dont call declarations
an interface is basically a classification
every instance has a method "doSomething" that takes no arguments and returns nothing
 
yeah but I want to call the method in class B using the interface
how should I do that?
 
class B says "I implement this interface" or "I sign this contract that I have this method "doSomething" without parameters and without return value"
the type of an object can never be an interface
because you cannot do new IMyInterface()
or new IHateIPrefixes()
you do new B()
 
but isnt that againt the low coupling thing?
I thought we shouldnt do newing
 
wut
 
3:15 PM
alright I guess I'm too confused with the way dependency injection works
 
if you dont change anything, myInterface will be null
 
if you want to avoid coupling you can use dependency injection.. but ultimately, someone has to do new. otherwise you won't have any objects to use
 
(the property of A)
 
I see
thank you guys
 
one way of having the dependency inverted is by providing the implementation of MyInterface to A by its constructor
public A(IMyInterface gimmeAnImplementationPlox)
{
	this.myInterface = gimmeAnImplementationPlox;
}
this way, A is not tightly coupled to B
instead, it is loosely coupled to IMyInterface
the implementation could be B, but might be C
it depends on what the program that creates the instance of A prefers
that is low coupling
classes are never low coupled, because of the lack of MI and classes can have members that cannot be fully overridden
 
3:21 PM
ok thank you..
 
(statements made above are correct for C#, but not necessarily for other languages)
 
@Wietlol explain your last line please?
 
what part in particular?
 
what does multiple inheritance have to do with coupling?
 
classes are tightly coupled because you cant extend classes costlessly
- you can only directly extend one class
- you inherit all fields of the parent class
 
3:25 PM
you can have multiple interfaces
 
- you cannot override non-virtual methods of the parent class
etc
so, extending a class might not always be possible and even if it is possible, might carry dead weight
implementing an interface is often possible (if not, you have some design issue) and carries no dead weight
 
if your consumers of your classes accepts interfaces instead of some base class then the coupling IMO is as low as it gets because the interface explains exactly what the consumer needs
 
MI, being the part where Abstract classes would be equal to interfaces, would allow you to extend any class whenever you want
(assuming its not sealed)
it could still carry dead weight, but that is another distiction
 
you don't need to extend classes, because the classes are usually not referenced since it's the interfaces that are used
 
@Default true, hence why interfaces are really good for low coupling
 
3:28 PM
alright.
 
cya grills
 
oh, you meant classes particularly
take care! \o
 
but if you dont use interfaces (like a lot of places in C# base libraries), you dont have this low coupling
 
I'm following. thanks for explaining :)
 
the first time I had to deal with it was with XmlParser... or something
XmlSerializer?
!!wietlol and !!wietlol2 come from that
which are Cap commands which quote some of my statements
 
3:31 PM
well, you should probably go with.. what's it called.. using stuff instead of extending..
 
stuff?
composition?
not always
there are cases where composition is better to use
but there are also cases where inheritance is much better
often times, you could use composition much easier though
 
composition!
!!wietlol
 
Oct 6 '17 at 14:56, by Wietlol
i have no idea where to put it
 
the names were different back then
 
mine wasnt
 
3:35 PM
touché
 
I havent changed name since I used Wietlol
 
but the videos seems to be the same
 
wait... was that Fredas?
oh, it was
on a side note, in Java, there is some black magic with interfaces
you can make a repository for persistence stuff and the implementation is automatically generated
you just define your interface as something like this:
public interface UserRepository extends JpaRepository<User, Long>
{
	Optional<User> findUserByUsername(String username);
}
after you made the User entity model class
and the implementation is generated for you
if you want to get data from an sql server, get it from an sql server
if you want to get it from in-memory repository, you do just that
if you want to get it from a mongo db, why the hell not?
etc
and you even get autocompletion when writing these methods:
shame though that the return type is before the method name, so you first do have to know what you actually want
if the return type would be after the name, that could be auto generated when you have the full method name
 
4:08 PM
Making this in WPF is a massive pain in the ass
 
hey want to ask something --

I am trying to send mails containing <a href....... link in the content. even though I did IsBodyHtml=true the mail that gets delivered does not create the clickable link. its just as text. what's to be done?
 
Could be the client not trusting the sender?
 
mm... sending from development environment now, localhost ie.
could it be that? i tried sending to outlook.com, live.com both ...
any other possible reason that could be,
...
?
I am going to check for gmail now...
if that fails too..
 
Are they even coming through?
 
4:23 PM
yes they are being delivered good, but the hyperlink becomes just text
yes now tested for gmail outlook, live .... same for all 3.
that 'Click here ...... ' text you see,
https://imagebin.ca/v/4G1zoZmFc9m2
that is supposed to be a clickable part. But it has become simple text instead ...

happening for all ..
 
Try clicking the "Download pictures" or whatever and after that does it work? If still nor then maybe your tag is broken, in which case show the code you make the tag with
 
@LeeButler okk..
let's try that too,
 
It might be that the email client is stripping the links
 
@LeeButler hmm,..
@LeeButler but how does one usually do.... is there a full working sample example out there for developers on this one? specially for doing it from localhost...
any links or tutorials,
 
Post the code which you're using, specifically the part which makes that link. It might be just your <a> tag is built wrong
 
4:38 PM
okk, let me just try the option with 'download all images' .. if still not works, going to post the full code,
(Y)
oh well,

public IActionResult EmailInvoice([FromBody]EmailInvoice emlI)
        {
            string webRoot = _env.WebRootPath;
            string contentRootPath = _env.ContentRootPath;

            string invoiceHtml = emlI.invoice_content;
            string linktoClick = "<a href='"+emlI.fdback_link.ToString()+"' style='color:indigo; font-size:24px'><b>Click here to visit feedback page and submit your feedback!</b></a>";

            try
            {
                string email_from = _conf.GetValue<string>("MailSettings:email_from");
public class EmailInvoice
    {
        public string email_from { get; set; }

        public string email_to { get; set; }

        public string password { get; set; }

        public string invoice_content { get; set; }

        public string fdback_link { get; set; }
    }
@LeeButler so that's my code block,
 
You need to use Double quotes on the <a> tag attributes, not single quotes
Also for that much you should have used gist
But anyway, try changing to double quotes on the href and style attributes in the <a> tag and it should be fine
 
okk!!
let me try this out!
 
If that still doesn't work, view the source of the email as recieved by gmail or whatever, and find the A tag and see if it's coming out correctly
 
@LeeButler basically like, href="+emlI.fdback_link.ToString()+ " .. the inside singlq quotes not needed I suppose,..
 
No you definitely need the quotes, so if you insist on doing it that way, you'd do
href=\""+emlI.fdback_link.ToString()+ "\" style...
 
4:50 PM
okk !!
i see
 
However I would look at using string interpolation to make adding text in the string nicer
Possibly along with the verbatim identifier (@)
 
hmm
they are using placeholders and then the variables,
nah. it is still the same. and when I inspect element
the href is not even there with the <a>

!!
 
@PrabirChoudhury That didn't make much sense. Maybe you meant: 3, u, d, y, !, ^, π, ?, א
 
:43966034
@LeeButler maybe I should try as that placeholder approach
 
No href at all? try sending it to outlook or some shitty email
 
5:02 PM
tried all three
 
There should definitely be one, and the only reason there wouldn't be is if something is stripping the links
 
Maybe the SMTP server /account you're sending from is stripping the links. Hardcode it as a link to google or something and see if it works
 
doing from localhost now, dev. environment only, and from another gmail id as the 'from'

gmail strips links like that?
 
No idea, I don't use gmail
 
5:12 PM
does BeginReceive() (TCP socket) only callback whenever a new data is in the stream? So say I get 1 message from the server, and it goes to the callback, can I only request like 4 bytes from it, and call BeginReceive again to get the rest without a second message coming in?
 
 
3 hours later…
8:26 PM
in a .net project, where does the main URL for the web application is stored in?
hey guys
I'd appreciate if someone can help here
I meant API Urls. nvm, I got it
 

« first day (2893 days earlier)      last day (2054 days later) »