Two Days Ago
In Quino: an overview of query-mapping in the data driver we took a look at some of the basics of querying data with Quino while maintaining acceptable performance and memory usage.
Now we’ll take a look at what happens with partially-mapped queries. Before explaining what those are, we need a more concrete example to work with. Here’s the most-optimized query we ended up with in the previous article:
With so many entries, we’ll want to trim down the list a bit more before we actually create objects. Let’s choose only people whose last names start with the letter “M”.
This is the kind of stuff that works just fine in other ORMs, like Entity Framework. Where Quino goes just a little farther is in being more forgiving when a query can be only partially mapped to the server. If you’ve used EF for anything beyond trivial queries, you’ve surely run into an exception that tells you that some portion of your query could not be mapped.
Instead of throwing an exception, Quino sends what it can to the database and uses LINQ to post-process the data sent back by the database to complete the query.
Introducing unmappable expressions
Unmappable code can easily sneak in through aspects in the metadata that define filters or sorts using local methods or delegates that do not exist on the server. Instead of building a complex case, we’re going to knowingly include an unmappable expression in the query.
The new expression performs the same check as the previous example, but in a way that cannot be mapped to SQL. With our new example, we’ve provoked a situation where any of the following could happen:
What happens when we evaluate the query above? With partial mapping, we know that the restriction to “IBM” will be applied on the database. But we still have an additional restriction that must be applied locally. Instead of being able to get the count from the server without creating any objects, we’re now forced to create objects in memory so that we can apply the local restrictions and only count the objects that match them all.
But as you’ll recall from the previous article, the number of matches for “IBM” is 140,000 objects. The garbage collector just gave you a dirty look again.
There is no way to further optimized this query because of the local evaluation, but there is a way to avoid another particularly nasty issue: memory bubbles.
What is a memory bubble you might ask? It describes what happens when your application is using nMB and then is suddenly using n + 100MB because you created 140,000 objects all at once. Milliseconds later, the garbage collector is thrashing furiously to clean up all of these objects—and all because you created them only in order to filter and count them. A few milliseconds after that, your application is back at nMB but the garbage collector’s fur is ruffled and it’s still trembling slightly from the shock.
The way to avoid this is to stream the objects through your analyzer one at a time rather than to create them all at once. Quino uses lazily-evaluated
6 days Ago
U.S. Olympic Hockey
Patrick Kane never showed up—he missed again and again and took horrible penalties. His face after his second penalty sums things up nicely for the U.S. (see left).
And the US didn’t even both covering the greatest Olympic goal-scorer ever, warming the hearts of 40+ year-old guys everywhere by letting Teemu score not once, but twice.
I noticed the following during one of the boarder-cross races: almost everyone stood in the gate at the top with hands on the posts, ready to jump at the sound of the bell (picture at left). The French guy, though, was just leaning back, arm akimbo and relaxed (picture at right). All that was missing was a cigarette and a shot of espresso.
Do you see the difference? I think he won the qualifier race as well, but who really cares? He’d already won our hearts on style.
1 week Ago
When you grew up in the countryside, you tend to have to prove the extreme rurality of your origin to others who share a similarly bucolic provenance. Should I become embroiled in future such contests of micturial prowess and find myself in trouble, struggling to triumph against a backwoods foe prodigiously well-equipped with a backwoods background that threatens to overshadow my own, I will rest assured that I can break the glass in case of such an emergency to retrieve the following link to end the discussion.
Oh, you guys used to tip cows when you got drunk?
Wow, that’s crazy.
So the farmer filmed them filming themselves “hav[ing] sexual contact with several cows”? Will Ilion police be pressing charges against the farmer for producing bestiality porn as well?
2 weeks Ago
I’ve been using CSS since pretty much its inception. It’s powerful but quite low-level and lacks support for DRY. So, I switched to generating CSS with LESS a while back. This has gone quite well and I’ve been pretty happy with it.
Recently, I was converting some older, theme stylesheets for earthli. A theme stylesheet provides no structural CSS, mostly setting text, background and border colors to let users choose the basic color set. This is a perfect candidate for LESS.
So I constructed a common stylesheet that referenced LESS variables that I would define in the theme stylesheet. Very basically, it looks like this:
This is just about the most basic use of LESS that even an amateur user could possibly imagine. I’m keeping it simple because I’d like to illustrate a subtlety to variables in LESS that tripped me up at first—but for which I’m very thankful. I’ll give you a hint: LESS treats variables as a stylesheet would, whereas SASS treats them as one would expect in a programming language.
Let’s expand the
Let’s see an example before we continue.
You’ll notice that I avoided setting a value for
I want to be able to set some values and just use defaults for everything that I don’t want to override. There is a construct in SASS called
The clue is further down in one of the answers:
It was at this point that the lightbulb went on for me. I was thinking like a programmer where a file is processed top-down and variable values can vary depending on location in the source text. That the output of the following C# code is
In fact, we would totally expect our IDE to indicate that the value in the final assignment is never used and can be removed. Using LESS variable semantics, though, where variables are global in scope and assignment are treated as they are in CSS, we would get
This is exactly as the developer from LESS said: stop fighting it and just let LESS do what it does best. Do you want default values? Define the defaults first, then define your override values. The overridden value will be used even when used for setting the value of another default value that you didn’t even override.
Now let’s go fix our stylesheet to use these terse semantics of LESS. Here’s a first cut at a setup that feels pretty right. I put the files in the order that you would read them so that you can see the overridden values and everything makes sense again.
You can see in the example above that the required variables are all declared, then overridden and then used. From what we learned above, we know that the value of
We can do better though. The example above hasn’t quite embraced the power of LESS fully. Let’s try again.
Boom! That’s all you have to do. Set up everything in your base stylesheet file. Define all variables and define them in terms of each other in as convoluted a manner as you like. The final value of each value is determined before any CSS is generated.
This final version also has the added advantage that a syntax-checking IDE like JetBrains WebStorm or PHPStorm will be able to provide perfect assistance and validity checking. That wasn’t true at all for any of the previous versions, where variable declarations were in different files.
Although I was seriously considering moving away from LESS and over to SASS—because at least they didn’t leave out such a basic feature, as I had thought crossly to myself—I’m quite happy to have learned this lesson and am more happy with LESS than ever.
 For those of you who already know how to fix this, stop smirking. I’m writing this post because it wasn’t intuitive for me—although now I see the utter elegance of it.↩
 I’d also seen the same concept in NAnt
 There are exceptions, but “variables are global in LESS is a good rule of thumb”. One example is that if a parameter for a mixin has the same name as a globally assigned variable, the value within that mixin is taken from the parameter rather than the global.↩
 Seriously, LESS experts, stop smirking. I’m taking a long time to get there because a programmer’s intuitive understanding of how variables work is a hard habit to break. Almost there.↩
The following article was originally published on the Encodo blogs and is cross-published here.
Encodo is a member of the Microsoft Partner Program with a Silver Competency. We maintain this competency through a combination of the following:
This involves no small amount of work and means that the competency isn’t that easy to get. You can also use Microsoft competencies (e.g. MCSE) but we don’t have any of those (yet).
We’ve had this membership for a while in order to get partner benefits, which basically translates to having licenses for Microsoft software at our disposal in order to develop and test .NET software. This includes 10 licenses for all premium versions of Visual Studio, up to and including the latest and greatest.
The partner web site
In previous versions, we were able to go to the partner web site and, after a lot of effort, get license keys for our 10 licenses and distribute them among our developers.
I mention the effort only because the partner site(s) and page(s) and application(s) are so notoriously hard to navigate. Every year, Microsoft improves something on the site, generally to the style but not the usability. I pluralized the components above because it’s hard to tell how many different teams, applications and technologies are actually behind the site.
It’s basically always been a mess and still is a mess and our suspicion is that Microsoft deliberately makes it hard to redeem your licenses so that you’ll either (A) just purchase more licenses via a channel that actually delivers them or (B) call their for-fee hotline and spend a bunch of money waiting on hold before you get forwarded from one person to another until finally ending up with someone who can answer your question.
 You can confirm our impressions just by looking at the screenshots attached below.↩
The convoluted path to licenses
That question being, in case we’ve forgotten, “how can I please get your software to recognize the licenses that I purchased instead of threatening me that it will go dark in 90 days?”
The magical answer to that question is below.
First, what are we actually trying to accomplish? We have a multi-pack license and we want some way of letting our users/developers register products. In most cases, this still works as it always has: get a license key and enter it/register it with the local installation of the product (e.g. Office, Windows, etc.)
With Visual Studio 2013 (VS2013), things are slightly different. There are no multi-pack license keys anymore. Instead, users log in to their Visual Studio with a particular user. VS2013 checks that account for a license on the MSDN server and enables its functionality accordingly. If you have no license registered, then you get a 90-day trial license.
If the license is a multi-pack and the user accounts are individual…how does that work? Easy: just associate individual users with the partner account and assign them licenses. However, this all works via MSDN, so it’s not enough to just have a Windows Live account. That user must also be registered as an MSDN subscriber.
So, for each user, you’re going to have to do the following:
The solution (with screenshots)
Sounds easy, right?. Once you know what to do, it’s not so bad. But we had a lot of trouble discovering this process on our own. So here are the exact steps you need to take, with screenshots and hints to help you along.
Logging in has other benefits: you can store your VS2013 settings on the Live server and use them wherever you work with VS2013 and have logged in.