« first day (789 days earlier)      last day (4153 days later) » 

11:00 PM
does the db have Exists()?
i dont know much sql but think I remember something like it
 
@JohanLarsson Exists would do the string comparison implicitly
unless he has an index on the column he's looking at, then it would be super fast.
but he would have to have a key to it
I've only been working on SQL for 9 months... why do I know these things... >.>
 
@Pheonixblade9 ok, just I guess, again, from me
 
"Incorrect number of arguments supplied for call to method 'Boolean Equals(System.String, System.String, System.StringComparison)'"
.Any(r => String.Equals(r.Description, desc, StringComparison.OrdinalIgnoreCase))
looks fine to me?
 
nope, nope
 
copy paste error
 
so how is that not what I have?
 
@TravisJ not sure, are you sure your r.Description is not a nullable value?
 
Here I am back!
 
public string Description { get; set; }
it has a value every time
 
With a test in phyics tomorrow and not having a clue on how to do some of the problems on the test, but with examples of such problems.
 
11:06 PM
yes, but sometimes LINQ does weird stuff
 
and when I did the plain toupper check it worked
 
@user1079641 I already told you I would help :)
@TravisJ what about desc?
 
Anyone care to help me in a marathon physics run?
@Pheonixblade9 I'm sorry. I completely forgot that. Thanks so much! But do you want to talk here or in a separate room?
 
desc is just the value passed in, if it was null then the code wouldn't reach that point
 
null would work in equals, I'm 97% sure
 
11:08 PM
@user1079641 here is fine.
 
ok.
 
just know that I'm at work, so I might disappear for awhile. We're in the middle of a big push for a huge feature
 
Well I will throw a bunch of different types of problems.
That's alright.
I'd just like the answers today since the test is tomorrow :D
Some are epicly easy while some are tough. Anyways, here is the first one: A bucket that weighs 32.0 N is being lifted straight up into the air by a rope. The bucket speeds up at a constant rate of 0.560 m/s2 (squared). Find the tension in the rope.
 
ok, draw me a diagram :)
(I'm not going to solve them for you like I did the last one, rather help you solve them)
so start with the things we know
Fb = -32.0N
a = + 0.560
we know the force of the rope is in an upward direction
so Fr = +Y N
so we can do the following
F = m * a
 
one sec, let me just get that thing started.
 
11:13 PM
we know the mass of the bucket = 32N / 9.81 = 3.262 kg
so we have:
F = 3.262 kg * a
we know the acceleration upwards
that's 0.560
so F = 3.262 kg * 0.560 m/s^2
F = 1.827 N upward
so the total force on the rope is F + Fr
 
@TravisJ fired up studio now
 
Yay. Physics.
 
@Johan - I am pretty sure that the toupper is the only option
 
Ft = F + Fr
Ft = 1.827 N + 32 N
Ft = 33.83 N
 
omg i need a break from javascript...ugh...how is everyone?
 
11:16 PM
@TomW we can move to another room if you want.
 
alert("well!");
 
thats good
 
No, that's cool. I was mostly planning on belittling the questioner ;)
 
is == or .Equals faster?
 
i start on loops in a min
 
11:17 PM
@TravisJ s1.Equals(s2, StringComparison.OrdinalIgnoreCase);
 
think they are the same
 
(overload)
 
@TravisJ for reference types there shouldn't be any difference, IMHO. I think the compiler ought to know that they're the same and do the same thing. Whether or not it actually does, is a different matter
 
for( var i=0,max=9;i<max;i++ )console.log(i);
 
but if i had to guess it would make since that operations would be faster
 
11:18 PM
@Johan - I cannot use that :(
 
yeah i pretty much know my for loops...is that the only loop in js?
 
I will try though
for( var i in arr )
{
i = key;
arr[i] = value;
}
for in loops in javascript are not guaranteed to be in order
 
@Pheonixblade9 I am not sure what Fr is?
 
while(true){console.log("ouch");}
 
oh its 32 N, the weight. ok.
 
11:21 PM
is there a foreach loop as well?
 
@Johan - Winner! :)
 
@user1079641 sorry, Fr should be Fb in the final equation
 
if (!gr.inDb(r => r.Description.Equals(desc, StringComparison.OrdinalIgnoreCase)))
 
@TravisJ yay!
 
[Test]
public void EqualsTest()
{
    string s1 = "aBc";
    string s2 = "abc";
    bool b;
    var stopwatch = new Stopwatch();
    stopwatch.Start();
    b = s1.ToUpper() == s2;
    Console.WriteLine(" s1.ToUpper() == s2; : " + stopwatch.ElapsedTicks);
    stopwatch.Restart();
    b = s1.Equals(s2, StringComparison.OrdinalIgnoreCase);
    Console.WriteLine("Equals(s1, s2, StringComparison.OrdinalIgnoreCase) : " + stopwatch.ElapsedTicks);
}
s1.ToUpper() == s2; : 1316
Equals(s1, s2, StringComparison.OrdinalIgnoreCase) : 9
 
11:22 PM
@Pheonixblade9 - :D
@Johan - It is fastr
 
@PheonixBlade9 does Fb mean Weight?
 
The test is not very scientific
 
Hanselman just made me laugh out loud
 
I mean in my runtime environment, it is faster
 
Since the teacher didn't teach us that variable.
 
11:23 PM
@TravisJ yeah, this is debug mode also
I would not trust this test much
 
Fn = Normal Force; Ft = Tension Force; Fg = Gravitational Force (Weight)...
 
@user1079641 Stop that right now. Number one point of failure with new university students in my experience? Expecting derivations to look the same as someone else's
 
@Johan - Well I just testing it in the live application and it is visibly faster. I can live with this speed.
 
There definitely is not a rule for what you call things. The notation should be clear but it can be anything - so what do you think Fb should be?
 
@TomW, you are misunderstanding me. I am not trying to make my thing look like someone else's. I don't understand what he meant by Fb, hence I asked.
 
11:24 PM
@TravisJ the StringComparison.OrdinalIgnoreCase is faster?
 
@Johan - Than .ToUpper? Greatly
 
sweet, then I'm glad
 
I am pretty sure Fb is weight, but I might be wrong, hence I asked.
 
me too, because I can move on to something else :) haha
 
Force on bucket, presumably
 
11:25 PM
Ok, I didn't know. I am sorry I asked.
 
That was a bit of an overreaction, and not my conversation either
So sorry - I have a knee-jerk reaction to stuff like that
 
The reason I asked what Fb means is because I didn't understand it. I don't see what's the problem with it or how it means I am trying to make my work look like someone else's, but oh well. ok.
 
I didn't say you were
 
"Expecting derivations to look the same as someone else's"
 
What you said was, the teacher didn't teach us that variable
 
11:27 PM
@user1079641 Fb is the weight of the bucket, yes.
I am running to get coffee
 
Why would you expect them to?
 
Anyways, I don't think there is any point of this conversation (argument).
Yes, she didn''t. So I thought he might be doing it a different way, or there might be multiple ways to solve the problem. I am a high school student, not a big experience guy who knows just about everything.
 
The reaction of "I don't understand this because I don't recognise the notation" is something to run far, far away from, is all I'm saying
You probably never will recognise the notation, everyone does it differently
 
And what I am saying is that I wasn't think of Fb as Force on Bucket. Anyways...
 
    [Test]
    public void ExpressionTest()
    {
        var stopwatch = new Stopwatch();
        stopwatch.Start();
        Expression<Func<string, string, bool>> expression = (string1, string2) => string1.Equals(string2,StringComparison.OrdinalIgnoreCase);
        stopwatch.Restart();
        Func<string, string, bool> func = expression.Compile();
        Console.WriteLine("Compile : " + stopwatch.ElapsedTicks);
        stopwatch.Restart();
        bool b = func("abc", "aBc");
        Console.WriteLine("Invoke : " + stopwatch.ElapsedTicks);
 
11:30 PM
Anyone here play brass?
 
Compile is expensive^^
 
how can I avoid it though? here is my method:
 
But it looks like IQueriable wants an Expression<Func<>>
 
public bool inDb(Expression<Func<TEntity, bool>> filter)
        {
            IQueryable<TEntity> query = dbSet;
            return query.Any(filter);
        }
I tried with just using Func and it didn't work
It didn't throw an exception, it just didn't work at all.
 
@Pheonixblade9, A 60.0-kg man is riding in an elevator that is moving up. The force of the elevator floor on the man is equal to 720 N. Find the acceleration of the elevator.
I have a feeling this is easy to solve and I am just overthinking, but I don't want to risk it.
 
11:32 PM
@TravisJ then it is no luck I guess but it is hopefully optimized in the other end, would be an outrage if it gets compiled on every iteration
 
@Pheonixblade9 F=MA, 720N=60.0KG * M. Is that all with this problem?
 
That seems right ^
 
@Johan - An interesting point.
 
solve for m
 
I should point out that I have only rudimentary knowledge of that stuff
 
11:32 PM
@Johan - Could I pass it in as a Func and then compile it once?
 
@user1079641 12?
 
@TravisJ how do you mean?
 
@CCInc, I don't know if it is really that simple or some extra steps involved.
 
@Johan - I thought that as an expression, you just implied it would be compiled for every iteration of Any. So, that made me ask if I should just pass the Func in, and then compile it into an expression once? And then use it in Any so that it wouldn't be compiled every iteration. Maybe I misunderstood.
 
I think there is something with Expression that lets linq to sql build its querys
 
11:34 PM
There is a ton of stuff that goes on behind the scenes.
 
but query.Any(filter); wants an expression?
 
yes
I use that pattern all over the place, so if there is a way to speed it up, let me know :P
 
then I don't think there is any way around it
@TravisJ always remember to get second opinion when you hear things from me
How long time does the query take btw?
And how many rows
Sproc candidate?
 
For which query?
With the new ordinal approach, it takes no time at all, <1s, perhaps even closer to <500ms
before it was taking around 3s
I managed to remove a ToList by creating that new method, using Any saved some time, and the ordinal topped it off.
overall, it was pretty successful imo
 
post the final code again
 
11:45 PM
public bool inDb(Expression<Func<TEntity, bool>> filter)
        {
            IQueryable<TEntity> query = dbSet;
            return query.Any(filter);
        }
 
and the filter (where you invoke it)
 
if (!gr.inDb(r => r.Description.Equals(model.Description, StringComparison.OrdinalIgnoreCase)))
 
looks redundant
 
Not sure, I will test the difference.
That is out of habit though, I usually make a query which I then edit.
 
should not be that expensive to just pass a reference though
 
11:48 PM
Making that change did not affect the speed
 
@TravisJ i <3 you
 
?
 
I'm switching over to horizontal position now
 
lol ok
 
@TravisJ <---- my fav user
 
11:49 PM
:)
 
@TravisJ -----> @m44m31 fav user
 
Travis really is the Jon Skeet of this chat
 
more like the god of this chat
 
@user1079641 did you solve the physics stuff?
@m44m31 they are two very similar things
 
11:52 PM
@user1079641 post again, I'm too lazy to scroll
good to see you back @CCInc
 
@JohanLarsson well then @TravisJ is the god of gods
 
All right, I'm back
A 60.0-kg man is riding in an elevator that is moving up. The force of the elevator floor on the man is equal to 720 N. Find the acceleration of the elevator.
720N = 60.0kg * a
 
0.2 m/s"?
 
a = 12
 
42! (it's always 42)
 
11:56 PM
@JohanLarsson yuppy
 
@Pheonixblade9 720 - 60 *9.82 = 60 *a?
 
hold on. everything is solved by drawing pictures.
 
@Pheonixblade9 that is solid advice
 
Umm, 720=60x, x = 12
12 * 60 = 720
 
total force = (720N) - (60kg * 9.81m/s^2)
total force = 131.4N
 
11:58 PM
@TravisJ 42! is a very large number wolframalpha.com/input/?i=42%21
 
@JohanLarsson Whats "!" do?
 
131.4 = 60kg * a
 
Oh, it's one sexdecillion...
 
a = 2.19 m/s^2
@CCInc ! is the factorial operator
 

« first day (789 days earlier)      last day (4153 days later) »