« first day (1286 days earlier)      last day (3645 days later) » 

8:00 PM
@Greg oy
 
posted on April 24, 2014 by Scott Hanselman

I just blogged about how I simplified my home network with a MoCA/Ethernet bridge. As a part of my home network rebuild, I swapped out my Netgear N600 for a shiny new Linksys WRT1900AC Wireless Router. I've been a Linksys WRT54G fan for almost a decade. I ran HyperWRT for a while and then ended up with DD-WRT. Having a reliable, hackable router was a joy back in the day. The Hardware The

 
@ReedCopsey arg, yup just figured it out
ok so I'm having trouble with a date that can be null or not
trying to assign it value this way:
        DateTime? dateOccurrence = null;
        if (!string.IsNullOrEmpty(txtDateOfOccurrence.Text.Trim()))
        {
            try
            {
                dateOccurrence = DateTime.Parse(txtDateOfOccurrence.Text.Trim());
            }
            catch (Exception ex)
            {
                lblMsg.Text = "Invalid date of occurrence. Error: " + ex.Message;
            }
        }
 
@KendallFrey I have data like this:

Heather Bell
3259BD / C / A3 / English
111-111-0678 H
16600 SW Rosa Road, Beaverton, OR 97007
garrigotti@comcast.net

I need a RegEx that will separate them like:

Username: (3259BD)
First Name:
Last Name:
Email:
Street:
City:
State:
Zip:
Phone (111-111-0678)

Right now I've got, @"\s+" which handles most, but it still leaves that lone character after the phone and grabs the address as a whole.
 
but if it is null (and it can be), I run into problems when I parameterize it
 
What are you going for, a Split?
 
8:06 PM
Well, right now I have it doing into a map that does a Split(" "); Then I actually run a Replace on the HtmlEntity/Trim.
 
I'm still not sure what you want the output to be exactly
Is the input a string with multiple lines?
 
@GustavoSuarez your class library knows nothing about the project that references it unless you pass that information to your library.
 
here's a template for you:
 
It is an `html` web-page that I'm moving through nodes:

columnMapping.Add(Regex.Replace(HtmlEntity.DeEntitize(column.InnerText).Trim(), @"\s+, " "));
 
@NETscape how to pass that info?
 
8:09 PM
Hello,

I'm ******, a resident of Congressman *****'s district. I live in ******** and work as a software engineer.

I'd like to request a meeting to speak with one of Congressman **********'s staffers regarding the proposed FCC rules resulting from the recent DC circuit court ruling:

http://www.cadc.uscourts.gov/internet/opinions.nsf/3AF8B4D938CDEEA685257C6000532062/$file/11-1355-1474943.pdf

The FCC rules proposal resulting from this have been proposed by FCC chairman Tom Wheeler, a former cable lobbyist:
3
 
so you'd have to pass a ref of the property setting or something, have your library change the value, then after the function exits, save your config in the application that references it
int val = (int)Properties.Settings["SomeKey"]
NumOfTimesReferencedLibrary(ref val);
Properties.Settings.Save()

public void NumOfTimesReferencedLibrary(ref int num)
{
    num++;
}
 
I'm having trouble with a date that can be null or not:
    DateTime? dateOccurrence = null;
    if (!string.IsNullOrEmpty(txtDateOfOccurrence.Text.Trim()))
    {
        try
        {
            dateOccurrence = DateTime.Parse(txtDateOfOccurrence.Text.Trim());
        }
        catch (Exception ex)
        {
            lblMsg.Text = "Invalid date of occurrence. Error: " + ex.Message;
        }
    }
 
@Daи Did she call you to confirm it?
ba dum tiss
 
@ShotgunNinja :P
then later when trying to use it:
                if (dateOccurrence != null)
                {
                    cmd.Parameters.AddWithValue("@dateOccur", dateOccurrence);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@dateOccur", "NULL");
                }
but this isn't working
 
@Greg I'm confused. It looks like you have a missing quote somewhere there
 
8:11 PM
or something like that.
 
I get Conversion failed when converting character string to smalldatetime data type.
 
Try passing null
 
@KendallFrey Quote, where?
 
If that doesn't work, pass DBNull.Value
@Greg @"\s+, " "
 
@Daи What format is the date field being delivered in? It might be using the DateTime.Parse for SQL, which might depend on a different string format...
 
8:13 PM
@KendallFrey Yes I was.
@"\s+", " "
 
@ShotgunNinja mm/dd/yyyy
if I could create a validator or something to help that would be good, but everything I've found on SO doesn't work right for me thus far
 
Now can I have an example of what HtmlEntity.DeEntitize(column.InnerText).Trim() is returning?
 
@Daи pass in a formatter.
 
@NETscape thing is I want to add complete sections to the config file...what I'm doing is a message inspector, but in order to use it you need to add <behaviorExtensions> and behaviors to your config file. I'm not just looking to use some settings
 
8:15 PM
@ShotgunNinja do you have a link to a complete example where it allows a null for the datetime field?
 
It returns everything correct except:

- It doesn't account for double value first names, (Carole Ann)
- It doesn't remove the H, C, or W at the end of phone number (Home, Work, Cell)
- It doesn't separate the Address.
 
I find bits and pieces everywhere but none that work together
@ShotgunNinja by complete, I mean follows it from client to server side then from code to database
 
All though I think I need to separate the address in the Map class where the initial Split(" "); is done.
 
So, if you're doing a split, what pieces of information do you want to get out of it? Provide me a list of sample strings.
 
@KendallFrey What is your email?
 
8:20 PM
Hi guys, I need some guidance..
 
kendfrey@gmail
 
kendall.frey@gmail.com was taken by that 14 year old girl?
 
ok here we go: DotNetFiddle
 
what's your problem @Daи?
 
@Pheonixblade9 Why would it be?
 
8:23 PM
@KendallFrey just giving you a hard time :)
 
you like giving 14 year old girl a hard time? :P
 
I have a console application, which does loop through a bunch of sql tables, performs some bulk operation on each table.. I implemented that. But now I want to use Parallel.For loop.. My concern is with the number of simultaneous sql connection objects that can exist at a time.. What do you think is the best (tried and tested) way to achieve it without making it too complicated?
 
don't do the null check
 
@ReedCopsey better yet
 
8:25 PM
@VenkatRenukaPrasad Retrieve the data first, then process them in parallel perhaps?
 
@KendallFrey seriously wtf
 
@ReedCopsey same error
 
@ShotgunNinja Yes, I am that way
 
By "that way" I assume you mean either "gay" or "with child".
!!kendall
 
8:26 PM
aw you changed it
 
@ReedCopsey I replaced the null check with cmd.Parameters.AddWithValue("@dateOccur", dateOccurrence); and still have same error
 
!!undo
 
@ShotgunNinja You do not have permission to use the command undo
 
awwwww
destroys self
 
@LasseV.Karlsen well, the data is too large (millions of rows in each table, half the time).. it's much harder to retrieve it operate on it and push it to the db
 
8:27 PM
@GustavoSuarez i'm not sure a library thats referenced in a project should be changing the projects config file.
 
@ReedCopsey updated fiddle
 
the library should know nothing about the project that is referencing it, i would think
 
@ShotgunNinja What were you thinking of? !!kendallfrey?
 
@KendallFrey I sent an email.
 
got it, I'll try to look into more tonight
 
8:29 PM
@NETscape add EF as a reference to your project via Nuget it'll add the required default configiguration settings
 
!!kendallfrey
 
hai
 
cmd.Parameters.AddWithValue("@dateOccur", dateOccurrence ?? DbNull.Value);
does that work?
 
8:32 PM
Yep, looks like you need DBNull.Value
It's kind of an odd quirk
 
DbNull is the stupidest thing... I know it's required, but damn is it a gotcha
 
kik
 
@ReedCopsey dbnull doesn't exist in this context
is the error
 
using System;
 
^my career in a nutshell
 
8:37 PM
And make sure you have the capitalization right
it's "DBNull"
 
@KendallFrey apparently capitalization matters
I just copied and pasted it from there
now it says I can't use ?? for datetime objects
 
that's because DateTime is not nullable
 
Try (object)dateOccurrence ?? DBNull.Value
 
you can use DateTime?
 
Operator '??' cannot be applied to operands of type 'System.DateTime?' and 'System.DBNull'
 
8:39 PM
add a cast
 
Yeah, I'm pretty sure (object) will fix that
 
@KendallFrey yes it did
 
oh good, I was worried for a second
 
1
Q: What effect would introducing a small barrier for new users to ask a question have on Stack Overflow?

Travis JRecently I asked How many new users does Stack Overflow get per day? According to the user's page, when sorted by creation date, there are roughly 100 pages per day (this is fairly accurate even back to 3 weeks time) - or roughly 3600 new registered users per day. As far as a I can tell, this wh...

 
@KendallFrey thanks all!
 
8:45 PM
oh, neat. another notable question badge :)
2
Q: System.Xml.XmlException: Unexpected end of file while parsing Name has occurred

Pheonixblade9I'm using an XmlReader retrieved using SqlCommand.ExecuteXmlReader. Here is my input When I run this line of code: XDocument currentXDoc = XDocument.Load(ktXmlReader.ReadSubtree()); it works the first time, reading in the first Product node as expected. The second time it runs, I get the fo...

@EvanL ...maaaaybe
 
lol.. well I hadn't read that you answered the question yet. But was about to blame the complexity ;)
 
@Daи use dateOccurrence ?? (object)DbNull.Value
 
@ReedCopsey late to the party :P
 
@ReedCopsey hooray! I love it when you make the suggestion I did :P
 
I made it first
:P
 
8:55 PM
I'd do the cast on the other side of the operator ;) which is why I pasted that
but either will work
 
why, pray tell?
performance?
 
yes, and it's more readable to me (personal preference)
 
ok, now explain why it gets more performance.
I thought it was all resolved at compile time
 
@KendallFrey it doesn't have to do the cast if dateOccurrence is not null.
 
I thought it didn't have to cast at all
 
8:57 PM
no, casting can be expensive
 
@GustavoSuarez are you talking about project.config?
 
140
Q: Casting vs using the 'as' keyword in the CLR

Frank VI'm learning about design patterns and because of that I've ended using a lot of interfaces. One of my "goals" is to program to an interface, not an implementation. What I've found is that I'm doing a lot of casting or object type conversion. What I'd like to know is if there is a difference bet...

 
I thought the (object) simply re-typed the expression, not did a cast
 
@NETscape not sure..it's the actual web.config or app.config depending on the project
 
@KendallFrey pretty sure it only does the cast if it's required
 
8:58 PM
required how?
If it needs boxing, it will get boxed regardless of where the 'cast' goes
 
if execution hits that point
 
ok, time to LINQPad
 
What's the best way to return from an async Task method with no implementation without compiler warning or error?
 
await Task.Yield(); throw new NotImplementedException();
forst thing that comes to mind
not sure if correct
 
@Shoe await Task.FromResult(true);
won't have any overhead, since it's a completed task
(other than the await mechanism)
better to make the method non=-async, and just return it, though
 
9:05 PM
still synchronous, right?
 
ie: Task FooAsync() { return Task.FromResult(true); }
yes, but that wasn't listed as a requirement :)
 
i know, just making sure
 
I'd change the interface but it comes from asp.net Identity
 
@Shoe You can kill the async modifier
it'll still match the interface
it's not part of the API
 
Alright, I see now, the Nullable boxes regardless of whether it's null or not
 
9:08 PM
Didn't know that, neat
 
@KendallFrey You referring to why I put the cast on the other side?
 
yeah
 
yep ;) that's the main technical advantage
 
yours only checks HasValue, and then boxes Value
so yours is better in the average case
mine is probably better if nulls are very rare
 
ehh is there is a smart way to check multiple values and return the one that is not null?
e.g:
company.manager.phoneNumber
if it is null or empty
company.supervisor.phoneNumber
..
company.Employee.phoneNumber
looks like a null check nightmare.
 
9:13 PM
there will be in C# 6
 
are they all strings?
(you mentioned "or empty")
 
yes
 
if it's just null checks, then it's not so bad
but if you need to check for string empty, it's kind of ugly
 
I mean null check for "employee" existing
 
oh, yeah, need to wait for ?. in C# 6
do all 3 implement the same interface or are they the same type?
 
9:14 PM
company.null.phone is an exception waiting to happen lol
 
you could do:
 
alright
 
var person = company.manager ?? (company.supervisor ?? company.Employee);
var num = person == null ? "No number" : person.PhoneNumber;
but that'll only work if there's a common type
 
yeah that is how I had it. I just knew it is gonna be lots and lots of code and hoped for a mystery easy way of doing it.
and nhibernate is now teaching me to nullcheck ALL the things
thanks
 
@ReedCopsey - Is there an expected release date for 6?
 
9:21 PM
nope - not that's been announced
my guess (this is 100% pure speculation) is that it'll be when the next version of Windows is released, since it seems like they've tied VS releases to the Windows release cycle
but who knows - its not done yet
 
I think about switching to 6 at work, think I saw Anders on build saying that MS uses it internally for most things already.
I think/hope that we will see things at a high frequency from MS now when Roslyn is finished.
should free up resources + something nice to build on
Speculation overflow as I have absolutely no idea
 
9:39 PM
plot twist, reed and johan work for MS and are secretly releasing confidential info
 
lol
plot twist, they are double spies and actually work for apple
 
9:51 PM
plot twist, Reed is actually Watson
!!wiki Watson (computer)
 
Watson is an artificially intelligent computer system capable of answering questions posed in natural language, developed in IBM's DeepQA project by a research team led by principal investigator David Ferrucci. Watson was named after IBM's first CEO and well-known business reformator Thomas J. Watson. The computer system was specifically developed to answer questions on the quiz show Jeopardy!. In 2011, Watson competed on Jeopardy! against former winners Brad Rutter and Ken Jennings. Watson received the first prize of $1 million. Watson had access to 200 million pages of structured and ...
 
plot twist, Watson actually founded Microsoft
 
plot twist, Roslyn infects Watson
 
plot twist, which was designed by Reed
yes, the plot twist was designed by reed.
 
plot twist, their bastard child grew up and started SO
 
9:55 PM
plot twist, Kendall was then finally adopted from an orphanage
 
plot twist, that has nothing to do with the plot
 
plot twist, DEVELOPERS
 
I need a team name for our "Stair Challenge" team. It's a challenge which team runs the stairs the most during the day
Stair Bears is already taken. :(
 
SO adopted you kendall.
 
Fare hair stair czars is what I though tof
 
9:57 PM
Quit Stairing at Me, Swannnn.
close enough
 
@RyanTernier - Stair Wars?
@RyanTernier - Get Steppin'?
 
Stairway to Heaven
Stairway to Huffin
Staircrows
NextStep
Step by Step (Oh Baby)
Stairmaster 42
Cynergi (hahahahahhaha) *inside joke
Run till you *** *** ** ** ** * * ******* drop
Too Cheap to take the Elevator
Arrive As late as we can
 
Butts of Steel
 
Stairy eyed
 
Kim K.
 
10:06 PM
Escalator temporary stairs
 
10:20 PM
Interview tomorrow... nervous. They told me to prepare to "not talk about code too much"... but that's what I'm good at ;)
 
@KendallFrey Any ideas?
 
@Greg eh?
 
@KendallFrey Regular Expression.
 
ah, ok
looks like you'll have a hard time splitting the string, and you should probably try matching the sections instead
 
10:35 PM
@KendallFrey What do you mean?
It is doing it based on td that it pulls out of particular tr.
 
Let's start at the start
 
posted on April 24, 2014 by The .NET Team

This post was authored by Xy Ziemba, the Program Manager for .NET Native performance, and Andrew Pardoe, Program Manager on the .NET runtime team. In our previous blog post introducing .NET Native, we talked about how .NET Native gives you the performance of C++ with the productivity of C#. Putting that in quantitative terms, Windows Store apps compiled with .NET Native start up to 60% faster

 
(.+) for the name, and then \s(\w+)\s/\s\w+\s/\s\w+\s/\s\w+ for the next line
You want to insert () around any field you want to extract
 
@KendallFrey wtf does that Expression do? The \s grabs special characters and all that precede it.
 
\s is space
\w is word character (letter, number, underscore)
\s(\d{3}-\d{3}-\d{4}) should cover the phone
 
10:41 PM
what about (555)123-4567
 
oh, and then \s\w for the phone type
@TravisJ It's not in the sample data he sent me
 
Okay
 
Correct this if its not good plz :) pastebin.com/cb0LcSmc
 
I suppose \s(.+) is best for the address
 
So this should suffice: \s(.+) for all of it?
 
10:43 PM
followed by \s.+@.+\..+ for the email
@Greg yup
So if you concatenate everything I gave you together, you will hopefully end up with a regex that matches a single record of data
It'll probbaly need some tweaking
 
@KendallFrey Thanks- That is a big Regex.
 
I forgot to put () around the email, so \s(.+@.+\..+)
Big, but not the biggest I've written :)
 
Parse html with regex :P
 
done already
 
hi everybody!
 
10:48 PM
I know, I remember that was your big thing :D
 
does somebody know how to change this VB line to C#?
currentCellData = CStr(dgLibros(currentCell.RowNumber, currentCell.ColumnNumber))
 
I think all you need to do is replace CStr with .ToString()
 
Yeah
 
i have: data = Convert.ToString(dtgGrid.CurrentCell.RowNumber, dtgGrid.CurrentCell.ColumnNumber);
but it doesnt work
 
What happened to dgLibros?
 
10:51 PM
dtgLibros is the name of mi grid in VB
dtgGrid is the name of my grid in C#
oh wait!
no, i don't know what's wrong! :S
 
@Greg What were the fields you wanted to extract again?
 
Username, First, Last, Email, Unit, Street, City, State, Zip, and Phone
 
Forget the address for now, we'll work on that later
What is username?
 
You have access to that file still?
 
10:54 PM
It is the random number / letter below the name.
 
ok, cool
 
Not the / portion, but before that.
 
so now I've got Name, Username, Phone, Address, and Email extracted
 
Hey @KendallFrey It works! juas juas juas
 
First step: How do we treat the name?
 
10:55 PM
thank you so much!
 
The simplest I can think of is take the last word and make it the last name
Is there a situation where that will be wrong?
 
@KendallFrey Well, I need to account for double first names. So if Carole Ann Bell is present, it grabs Carole Ann as the first name.
 
Carole Ann|Bell
not too hard
What about Roel van|Uden?
van would typically go in the last name, right?
 
Yeah.
 
Can you think of a way to distinguish those that's explainable to a computer?
 
10:58 PM
lower case naming is a last name prefix
 
But honestly my boss doesn't care so much about the last name, they can be fixed if need be.
 
@TravisJ what about poor lazy carole ann bell who can't be arsed to use caps?
 
@KendallFrey @TravisJ has a valid point about it though, lowercase is usually associated to last name.
 
she's a witch
 
@KendallFrey Well, my boss would rather error on side of First Name then last, they can fix it otherwise.
 
10:59 PM
ok, we'll do that then
Now the address
Can you guarantee that it will be formatted a specific way?
For example, the commas that you have would be very useful if they are guaranteed
 
That is the real bitch, Well- Basically based on the `html` I can ensure it will be:

Unit Street,<br>City,State Zip

or

Unit Street<br>City, State Zip
 
And will state always be two letters, or might it be Oregon?
 
@KendallFrey Will always be two letters.
 
good, the commas we can definitely use
alright, let me conjure something up
Unit will be one word, correct?
 
Well, Unit would be represented with random number as:

16600
952
9600
10
25200
 
I. Have. No. Idea.
 
??
 
ok, I have a regex that works for one record
^(.+)\s+(\S+)\s+(\w+)\s+/\s+\w+\s+/\s+\w+\s+/\s+\w+\s+(\d{3}-\d{3}-\d{4})\s+\w\s+(\d+)\s+(.+),\s+(.+),\s+(..)\s+(.+?)\s+(.+@.+\..+)$
Do you know how to extract captured groups? Your fields are in captured groups
wut?
 
Rather then explain, I sent you most of the code.
 
Can you change your IList<string>?
The regex will have to be run before the split
 
11:14 PM
Um, not really that would break my Extension.
 
what extension?
 
Hey guys!
 
@KendallFrey I can run the one for the address first.
 
Been scratching my head for a while....Is it possible to write e.g. a Queue<string> into a file, while another class is adding to the queue...without having problem of block or lock or anything that prevent the other class to add to the queue and we be sure that everything goes to the disk at the ned?
end*
 
It doesn't seem like it would be a problem so long as nothing being read was modified
 
11:21 PM
I am a C# guy but unfortunately I have to this in Java....
public class AccelerometerQueue implements Runnable {

private static final String TAG = "AccelerometerQueue";

private Queue<AccelerometerVector> mQueue;

public AccelerometerQueue(Context) {
mQueue = new LinkedList<AccelerometerVector>();
}

public void addToQueue(AccelerometerVector vector) {
mQueue.add(vector);
}

@Override
public void run() {
while(true){
//Write queue to disk
}
}
}
 
Well its been fun, but I am takin off 30 mins early
see you all monday
 
I put filestream in the while loop ...but it eats up the CPU
and I dont want to use Thread.sleep because then other class can not add to the Queue obviously
 
@KendallFrey For just the address portion, would it be @"\s(.+)"
 
no, I modified it
Try ^(\d+)\s+(.+),\s+(.+),\s+(..)\s+(.+)$
the fields are unit, street, city, state, zip
 
I keep getting a "Index was outside the bounds of the array."
If I do a Regex split it pulls them into an array right?
 
11:27 PM
You don't want to split on that, you want to match on it
the fields are in the captured groups
 
Then how would I get it to assign to the properties correctly?
 
match.Groups[i].Value I think
Nope, make that match.Captures
both might work, I'm not entirely sure
 
I assign it five groups to match to?
I've never used that @KendallFrey
 
Have you called Regex.Match?
 
No. I've never had to use a Match. I've only used Split.
 
11:31 PM
it will return the match that you can extract information from
The first field you want is index 1 (not 0)
 
Doesn't the Regex convert to a String rather then the Split which does char[]. So won't I have to cast?
 
huh?
Split return string[], Match returns Match
 
@KendallFrey Okay, well... Give me 20 minutes to get home.
 
Kendal no tips foe me :P ?
:D
 
:16055763
 

« first day (1286 days earlier)      last day (3645 days later) »