|
Well that makes sense if someList is a list of objects which implement IEnumerable (like List<List<int>> . A bit weird but no horror.
|
|
|
|
|
Which is why this forum is called "The Weird and The Wonderful"!!
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
It's not even weird, if you want to flat a list of lists then that's the best way to do it.
|
|
|
|
|
I think one posted in the chatroom a coupla days ago had C++11...
[](){[](){}();}(); ... but I suspect he was trolling.
|
|
|
|
|
The great thing about C++ is: you can never be sure.
|
|
|
|
|
xD .. If i'm not mistaken, that is just an empty lambda nested inside another one ... I wonder if one could go on and on like that. -- But in the end it would do nothing (besides probably a stack overflow, if you take it too far^^)
|
|
|
|
|
|
I think I have to classify this as "wonderful", because it's honestly pretty common.
The simplest case of SelectMany is to flatten a "List of List of Objects" into a "List of Objects". And that's exactly what this lambda does.
I guess the "weird" here is that SelectMany is doing some extra magic merging the lists.
|
|
|
|
|
As well as the actual lambda Greek letter.
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
I hate it when people stand behind me in covert and watch my screen while I peacefully code. I loose my balance.. chemically
|
|
|
|
|
Read the top of this forum, don't think this post fits this.
|
|
|
|
|
it does state Coding Horrors, Worst Practices. well it is a horror.. while coding
|
|
|
|
|
"This forum is purely for amusement and discussions on code snippets."
True, however the last two words in the sentence above are the important ones.
|
|
|
|
|
I guess this explains why his manager thinks he needs to monitor what this guy's coding
|
|
|
|
|
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
I guess I am glad I'm not his manager!
|
|
|
|
|
|
|
Jibesh V P
|
|
|
|
|
|
The solution to this problem is to install a trap door directly behind you where the supervisor always stands.
You then set audio, motion, and location in their appropriate places.
if( audio == null && motion == null && location == true)
{
trigger = true;
}else{
trigger = false;
}
End result, no more supervisor standing behind you while you code.
Heh, heh, I've lost more supervisors that way.
Now, back to reality.
|
|
|
|
|
hahaha.. ooh boy i really wish I could compile this code and run it.
|
|
|
|
|
It is a bit psuedo.
With properly declared variables and keywords it would compile and run. Unfortunately it has a bug and is therefore quite dangerous to anyone stepping on the trap door.
I forgot two important parameters. A variable for a timer and a constant for maximum standing time allowed.
The trap would trigger as soon as you got up to use the restroom.
Now, if you really want to use the code, rather than applying it to a trap door, apply it to an arduino or raspi controlled supper soaker water gun sitting on the desk, pointed in the direction of the standing interloper.
To be not so obvious and have some real fun, place a small hidden water device on the sealing above the spot and have it spew out just enough water to make it feel like a bird just pissed on the individual. For real effectiveness, make the device focus on any area behind the desk that's within the monitors viewing area.
Hmmm; It appears that I have been reading way to many Instructables and Hackadays. And also watching to many YouTube videos utilizing arduino controlled devices.
|
|
|
|
|
You could also turn on your (password-protected) screensaver, turn towards him and do nothing except staring at him. (I for one would enjoy his reaction.)
|
|
|
|
|
An ex-cow-orker needed to create two sections on an ASP.NET webpage with repeated items. Imagine something that gets rendered to HTML like this:
<h2>First Header</h2>
<div>Item 1</div>
<div>Item 2</div>
<h2>Second Header</h2>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
To avoid creating two repeaters, they created a single repeater, and then used the pre-render events to add headers to each section. Here's a short version of it (much simplified):
<script runat="server">
Private Sub myRepeater_PreRender(sender As Object, e As System.EventArgs) Handles myRepeater.PreRender
For Each item In myRepeater.Items
If SomeCondition1() Then
Dim headerContainer As PlaceHolder = item.FindControl("myHeader")
AddHeader(headerContainer, "First Header")
End If
If SomeCondition2() Then
Dim headerContainer As PlaceHolder = item.FindControl("myHeader")
AddHeader(headerContainer, "Second Header")
End If
Next
End Sub
</script>
<asp:Repeater runat="server" ID="myRepeater">
<ItemTemplate>
<asp:PlaceHolder ID="myHeader" runat="server" />
<%--
Not a bad approach, I think, though I'd probably have just created a nested repeater:
<asp:Repeater runat="server" ID="outerRepeater">
<ItemTemplate>
<h2><%# HttpUtility.HtmlEncode(DirectCast(Container.DataItem, ItemCollection).HeaderText) %></h2>
<asp:Repeater runat="server" DataSource="<%# DirectCast(Container.DataItem, ItemCollection).Items %>">
<ItemTemplate>
<%-- ...Rest of item template... -->
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
Of course, I'd have to split out the collection being bound to into two collections and create some wrapper classes and such, but nothing too difficult. I like this approach more, because you can avoid doing unnecessary processing during the render/binding stages (which just seems like a hack to me).
Another reason I prefer my approach is because you could then sort each collection differently. What I had to do instead was to first sort on SomeCondition1() and SomeCondition2() , then perform a secondary sort (which looks pretty awkward in LINQ).
EDIT: Fixed typo.
modified 31-Jan-13 19:01pm.
|
|
|
|