## Ruby ampersand colon shortcut [duplicate]

Possible Duplicate: What does map(&:name) mean in Ruby? In Ruby, I know that if I do:some_objects.each(&:foo)It's the same assome_objects.each { |obj| obj.foo }That is, &:foo creates the block { |obj| obj.foo }, turns it into a Proc, and

## Is it possible to Pivot data using LINQ?

I am new to LINQ, but I am wondering if it is possible to use LINQ to pivot data from the following layout:CustID | OrderDate | Qty1 | 1/1/2008 | 1002 | 1/2/2008 | 2001 | 2/2/2008 | 3502 | 2/28/2008 | 2211 | 3/12

## Transitioning from Windows Forms to WPF

For a long time now, I have been stuck with Windows Forms development (started with VB6, and has continued through to C# .NET 4.5), and I have pretty much hit the limit of what Windows Forms can do, both using pure .NET, and special effects

## How to clear the canvas for redrawing

After experimenting with composite operations and drawing images on the canvas I'm now trying to remove images and compositing. How do I do this?I need to clear the canvas for redrawing other images; this can go on for a while so I don't th

## Do a “git export” (like “svn export”)?

I've been wondering whether there is a good "git export" solution that creates a copy of a tree without the .git repository directory. There are at least three methods I know of:git clone followed by removing the .git repository directory.g

## Turning query errors to Exceptions in MySQLi

I'm trying to turn MySQLi query errors to Exceptions, but couldn't - mysqli_sql_exception is thrown only if it failed to connect the DB.I used mysqli_report(MYSQLI_REPORT_STRICT) and procedural MySQLi functions embedded to custom wrapper cl

## When should I write the keyword 'inline' for a function/method?

When should I write the keyword inline for a function/method in C++?After seeing some answers, some related questions:When should I not write the keyword 'inline' for a function/method in C++?When will the compiler not know when to make a f

I have a rather big Android App project that is referencing several library projects. Everything was fine until i upgraded the eclipse ADT plugin to the newest version (v22). I also upgraded the SDK of course. I do not see any compile error

## What happens to a declared, uninitialized variable in C? Does it have a value?

If in C I write:int num;Before I assign anything to num, is the value of num indeterminate? 1:Static variables (file scope and function static) are initialized to zero:int x; // zeroint y = 0; // also zerovoid foo() { static int x; //

## Fastest way to list all primes below N

This is the best algorithm I could come up.def get_primes(n): numbers = set(range(n, 1, -1)) primes = [] while numbers: p = numbers.pop() primes.append(p) numbers.difference_update(set(range(p*2, n+1, p))) r

## How to check visibility of software keyboard in Android?

I need to do a very simple thing - find out if the software keyboard is shown. Is this possible in Android? 1:NEW ANSWER added Jan 25th 2012Since writing the below answer, someone clued me in to the existence of ViewTreeObserver and frie

## Converting ISO 8601-compliant String to java.util.Date

I am trying to convert an ISO 8601 formatted String to a java.util.Date. I found the pattern "yyyy-MM-dd'T'HH:mm:ssZ" to be ISO8601-compliant if used with a Locale (compare sample).However, using the java.text.SimpleDateFormat, I cannot con

## How to use MySQLi inside a namespace

MySQLi works fine inside a class with no namespace and outside a class. I recently started using namespace and now I have stumbled on a code much like the following: namespace Project; class ProjectClass{ public static function Project

## SQL Show most recent record in GROUP BY?

I have a table that looks like this:id | SubjectCode | Grade | DateApproved | StudentId1 SUB123 1.25 1/4/2012 2012-123452 SUB123 2.00 1/5/2

## Will ASP.Net MVC's AntiForgeryToken Method work with Load Balancers?

Using ASP.Net MVC v2.0, I am starting to research the use of the Html.AntiForgeryToken() method when submitting forms that process data. I can see it sets a hidden value in the form HTML and it sets the same value in a session cookie. The q

## DesignInstance not working in VS2012

I just spent several hours on an issue when using VS2012, WPF 4.5 and design-time data, specifically the DesignInstance attribute.Goal: I wanted to have design-time data support in my WPF project (MVVM-based), both in VS2012 and Blend, and

## Can an XOR linked list be implemented in C++ without causing undefined behavior?

An XOR linked list is a modified version of a normal doubly-linked list in which each node stores just one "pointer" instead of two. That "pointer" is composed of the XOR of the next and previous pointers. To traverse the list, two pointe

## The most Pythonic way of checking if a value in a dictionary is defined/has zero length

Say I have a dictionary, and I want to check if a key is mapped to a nonempty value. One way of doing this would be the len function:mydict = {"key" : "value", "emptykey" : ""}print "True" if len(mydict["key"]) > 0 else "False" # prints t

## Updating multiple rows Linq vs SQL

Some time ago I wrote a piece of code to update multiple rows in a database table. The code was like thisvar db = new MyDataContext();db.Execute("UPDATE Details SET IsActive = 0 WHERE MasterId = 1");Then the other day when I got the latest

## Java 8: Class JavaLaunchHelper is implemented in both

I'm trying to launch Cassandra and I'm running into an issue with JavaLaunchHelper being located in two places. I'm running Java 8. Here's the exact error:objc[413]: Class JavaLaunchHelper is implemented in both/Library/Java/JavaVirtualMach

## pandas: how to run a pivot with a multi-index?

I would like to run a pivot on a pandas DataFrame, with the index being two columns, not one. For example, one field for the year, one for the month, an 'item' field which shows 'item 1' and 'item 2' and a 'value' field with numerical value

## Entity framework Include command - Left or inner join?

As I was investigating the difference between Include and Join I found that : If the DB does not include a Foreign Keys -it has no navigation props so it's better to use JoinIf It does have a navigation props - then use Include. ( it also