I am trying to use Linq to convert a list to Dictionary. I have been able to get proper results with anonymous types as keys, but not with concrete types. Please see code snipped below:          // Works. Produces 329 entries in dictionary, as expected.          var groupByMonth =             from e in list             group e by new { e.chk.Month, e.chk.Year } into g             select new { month = g.Key, rates = g.ToList() };         var monnthlyRates = groupByMonth.ToList();         var monnthlyRatesDict = groupByMonth.ToDictionary(t =&gt; t.month, t =&gt; t.rates);          // IS NOT WORKING. Produces 30K entries in dictionary; same num as in the list.         // i.e. the grouping does not happen         var groupByMonth2 =             from e in list             group e by new MonthYear { Month = e.chk.Month, Year = e.chk.Year } into g             select new MonthYearRates { MonthYear = g.Key, Rates = g.ToList()};         var monnthlyRatesDict2 = groupByMonth2.ToDictionary(t =&gt; t.MonthYear, t =&gt; t.Rates);          // Works. Dictionary has 329 entries         var groupByMonth3 =             from e in list             group e by new DateTime(e.chk.Year, e.chk.Month, 1) into g             select new MonthYearRates2 { MonthYear = g.Key, Rates = g.ToList() };         var monnthlyRatesDict3 = groupByMonth3.ToDictionary(t =&gt; t.MonthYear, t =&gt; t.Rates);   I tried to fix the problem by implementing IComparer and/or IComparable in the concrete type; to no avail  class MonthYear : IComparer // class MonthYear : IComparable, IComparer {     public MonthYear()     {     }     public MonthYear(int month, int year)     {         Month = month;         Year = year;     }     int IComparer.Compare(Object x, Object y)     {         MonthYear xo = (MonthYear)x;         MonthYear yo = (MonthYear)y;          if (yo.Year &gt; xo.Year)             return 1;         else if (yo.Year &lt; xo.Year)             return -1;         else         {             if (yo.Month &gt; xo.Month)                 return 1;             else if (yo.Month &lt; xo.Month)                 return -1;             else                 return 0;         }     }      //int IComparable.CompareTo(object obj)     //{     //    MonthYear o = (MonthYear)obj;      //    if (Year &gt; o.Year)     //        return 1;     //    else if (Year &lt; o.Year)     //        return -1;     //    else     //    {     //        if (Month &gt; o.Month)     //            return 1;     //        else if (Month &lt; o.Month)     //            return -1;     //        else     //            return 0;     //    }     //}     public int Month;     public int Year; }   I understand that Lookup might be a better fit that dictionary; I will lookup Lookup once I am done with anyonymous types.
If I want to use objects as the keys for a Dictionary, what methods will I need to override to make them compare in a specific way?  Say I have a a class which has properties:  class Foo {     public string Name { get; set; }     public int FooID { get; set; }      // elided }    And I want to create a:  Dictionary&lt;Foo, List&lt;Stuff&gt;&gt;   I want Foo objects with the same FooID to be considered the same group.  Which methods will I need to override in the Foo class?  To summarize: I want to categorize Stuff objects into lists, grouped by Foo objects. Stuff objects will have a FooID to link them to their category.
How can I approach implementing the following in Drupal 7?  What I need to do is create a module which defines a new fieldable entity, called 'Company'. I have a list of, let's say, 20 fields that need to be filled out by each Company instance. These questions are predefined and some may contain custom validation.  At the moment, I'm at the point when I can add new fields to the Company entity. This works fine at the moment. My issue is that I need all these fields to be there as soon the module is installed, so adding them via the interface isn't an option.  I was wondering how can I approach this? I'd assume it comes down being able to do what can be done using the 'Manage Fields' UI programmatically. In HLW8012 where should I connect the reference voltage (GND) In the , the both 33nF capacitors , 1K resistor and 0.1uF capacitor are connected to GND. I'm not sure where should I connect those ends of components marked with GND symbol, (To Live, To Natural or the DC GND). I can't read Chinese, I don't really know what everything mean there.  Live directly connects to the shunt resistor and this means that live is also GND (0 volt reference) for the chip? Should I connect those end of components marked as GND symbol to Live wire? Does a creature with Lifelink provide lifegain equal to its power, or the defender's toughness? How to Sync OneDrive Business /Office 365 on Linux? Microsoft OneDrive Business/Office 365 Pro offers 1 TB of cloud storage but unfortunately there has never been a method to sync it on Linux. Given that$(3x-1)^7=a_7x^7+a_6x^6+a_5x^5+...+a_1x+a_0$, find $a_7+a_6+a_5+a_4+...+a_1+a_0$ Given that$$(3x-1)^7=a_7x^7+a_6x^6+a_5x^5+...+a_1x+a_0$$find $$a_7+a_6+a_5+a_4+...+a_1+a_0$$  Is there anyway to do the question without using binomial theorem and expanding the expression on the LHS?? Exporting symbols rather than points in .dxf I have a map I've made in QGIS which is points from a .csv file. These have then be turned into different symbols based on what they represent and then the sizes of said symbols based on values in the .csv.  I need to export this as a .dxf to use in AutoCAD so it basically looks the same as it does in QGIS. However, when I do so it just exports as single dots (points). Is there a way I can export them as the symbols as I can see in QGIS? "The thing is, is that..." On finding polynomials that approximate a function and its derivative (extensions of Stone-Weierstrass?) The Stone-Weierstrass Theorem tells us that we can approximate any continuous $f:\mathbb{R}^n\to\mathbb{R}$ arbitrary well on a compact subset of $\mathbb{R}^n$ by some polynomial. Suppose that $f$ is continuously differentiable, under what conditions can we guarantee we can find a polynomial $p$ such that $p$ approximates arbitrarily well $f$ and the partial derivatives approximate of $p$ arbitrarily well those of $f$ (on a compact subset of $\mathbb{R}^n$)? References are welcome. See below for my (probably naive) approach to the question.    It is straightforward to find conditions if $n=1$: Let $K:=[a,b]\subseteq\mathbb{R}$ and let $K_+$ denote some open cover of $K$. Suppose that $f:K_+\to\mathbb{R}$ is continuously differentiable and let $f'$ denote its derivative. Then, by Weierstrass's approximation Theorem we have that there exists a polynomial $q$ such that   $$||f'(x)-q(x)||\leq \varepsilon$$  for all $x\in K$. Choose some $y\in K$. For any $x\in K$ define  $$p(x):=f(y)+\int_y^xq(t)dt.\quad\quad(*)$$  By the Fundamental Theorem of calculus we have that $p'=q$. So for any $x\in K$  $$||f(x)-p(x)||=\left|\left|\int_y^x (f'(t)-q(t))dt\right|\right|\leq \int_y^x ||f'(t)-q(t)||dt\leq \varepsilon||x-y||\leq \varepsilon (a-b).$$  However, the above argument doesn't work in higher dimensions because the analogue of $(*)$ does not imply that $\nabla p = q$ (since not every vector of polynomials spans a gradient field). Can anyone suggest a way around this? That is, a way to to show that for continuously differentiable $f:\mathbb{R}^n\to\mathbb{R}$ and for any $\varepsilon&gt;0$, we can always find a polynomial $p$ such that   $$||f(x)-p(x)||+||\nabla f(x)-\nabla p(x)||\leq \varepsilon$$  for all $x$ in some compact set $K$? Feel free to add extra conditions on $K$, if it makes life easier. This may be a silly question, and I think I have looked elsewhere to find the answer...  Might be a path issue, but when I open the command line and type from the C:\&gt;: cd D:\  I cannot get to the D drive.  Even if I type: cd D:\&lt;folder name&gt;  The command.exe will auto-complete the line with the tab key, so it knows where I'm at.  It just doesn't print to screen the result or actually get me there.  This problem exists for the network drives as well. Now, if I use the chdir (cd) command like this: chdir D: or cd d: I get the print out of the D:\ below the command but it still says I'm in the C:\. I feel like I'm missing something simple. Is there a noun for something that is "out of place" in space, like an anachronism is "out of place" in time? E.g., an old-timey barber shop in a chic neighborhood. How to fix slow wireless on machines with Intel wireless cards? I have looked through all the previous questions but turning power management off for the Wi-Fi card didn't work. This problem seems to be with the Lenovo Thinkpads. I switched to Ubuntu 11.10 from Windows 7 3 days ago so I'm new to the operating system. The laptop is dual booting with windows 7 and ubuntu 11.10.  For 11.10 to boot, I had to add 'nolapic' in GRUB boot options.  I downloaded 12.04LTS LiveCD yesterday and made a CD and a bootable USB stick.  With both USB and LiveCD, occasionally I can boot into 12.04.  But many times, the boot process stuck at some point.  For USB boot, sometime it works.  But other times, it seems to stuck right after seeing the message:  NMI watchdog enabled. takes one hw-pmu counted [0.408590] #2   The number in [] changes.  Some times it stuck at #2, and sometimes at #3.  For LiveCD boot, sometime it works.  But when it stuck, it stuck at different places.  At times, the boot process go directly to a blank screen with a blink '_' at up left corner.  Sometime it went a bit further, after showing options to try/install ubuntu then stuck with a blank screen with blink '_'.  Anything I can do to get around of this? This is a little bit off topic as it is not exactly related to TeX.  I saw recently that  was updated to 1.020 which comes with math table support.  Does any one had a chance to play with this font and use it with unicode-math, and in particular with the LuaTeX engine?  I am very interested in purchasing a complete set of this nice fonts family. However I am concerned about its usability with the unicode-math package. Unlike Cambria Math or XITS Math, Minion Math does not come with a single font, instead it has 20 (4 weights 5 optical sizes) fonts. So it will be better to know how it works before spending 700 euro.  In particular, say the following minimal document, will it use correct optical size of the fonts for each of the three formulas? I had trouble with using correct optical size of Minion Pro fonts with fontspec. I worked it out with the SizeFeatures and OpticalSize. However, I am not so sure if the same strategy will work for Minion Math with unicode-math. In addition, in Cambria Math, etc., the bold symbols and alphabets are chosen directly from the unicode math enabled fonts. But in Minion Math, from the glyph tables on their websites, there seems no bold alphabets in each font. So will the mathbf in the document below work out of box?  \documentclass{article} \usepackage{fontspec} \setmainfont{Minion Pro} \usepackage{unicode-math} \setmathfont{Minion Math} % or what ever fonts name actually is  \begin{document} \fontsize{5}{5}\selectfont \[ \mathbf{E} = mc^2 \] \fontsize{10}{10}\selectfont \[ \mathbf{E} = mc^2 \] \fontsize{36}{36}\selectfont \[ \mathbf{E} = mc^2 \] \end{document} A limit question (JEE $2014$) The following is a JEE (A national level entrance test) question:  Find the largest value of the non-negative integer ( a ) for which:  $$ \displaystyle \lim_{x \to 1} \left( \dfrac{-ax + \sin(x-1) + a} { x + \sin(x-1) -1 } \right)^{\dfrac{1-x}{1-\sqrt x} } = \dfrac 1 4 $$  On solving this, we get $ a = 0 $ or $ a = 2 $. So we take the answer as $ 2 $. But the official answer key says that the answer is $ 0 $. The reason given (not in the official key - they simple contain the answer. I saw the reason in an "unofficial" solution to the question paper) is that if $ a = 2 $, then the term $\displaystyle \dfrac{-ax + \sin(x-1) + a} { x + \sin(x-1) -1 } $ tends to a negative value ( $-0.5$ ). So $ a = 0$.  BUT:  By putting $a = 2$ in the limit, and inputting that to wolframalpha (), the answer turns out to be $0.25$. So, by putting $ a = 2$ also, we get the same value of the limit - $0.25$.  How to solve this dispute? Also, could you please check with Mathematica? Unfortunately, I don't have access to it!  (This is very important as the change in the answer key will affect the rankings in a dramatic way) Harry is a half-blood and Ginny is a pure-blood, so what does that make his children? I've been told it means they are pure-bloods but I can't be sure. What do you think? Let $\alpha,\beta,\gamma$ be the roots of $x^3-3x^2+1 = 0$. Prove that $$\alpha^n+\beta^n+\gamma^n \equiv 4^n+5^n+(-6)^n \pmod{17}$$ where $n$ is an integer.   It sort of makes sense why they are congruent since we can say $x^3-3x^2+1 \equiv (x-4)(x-5)(x+6) \pmod{17}$, but since $\alpha,\beta,\gamma$ aren't integers, how do we prove this? I can't execute newest Blender 2.80, it says that I need a graphics card that supports OpenGL 3.3 or higher ERROR: A graphics card and driver with support for OpenGL 3.3 or higher is required  Processor: AMD A6-3670 APU with Radeon(tm) HD Graphics, 2695MHz BIOS Version: HPQOEM - 1072009 Dedicated GPU:   This is a very old PC, but when I search online it seems that theoretically Blender 2.8 should run since my openGL is 4.4 Since one or two months ago, my laptop with ubuntu 12.10x64 hangs during shutdown. There's just a black screen, no harddisk activity, it justs sits there. I feel it happens near the end of a normal shutdown cycle, judging from time elapsed.  Only resolution is hard power-off (holding power key for several seconds) - neither Ctrl-Alt-Backspace (which normally works, I have it switched on in Settings) nor Ctrl-Alt-Del help, nor can I get into a text console with Ctrl-Alt-F1.   How do I diagnose that? It does not happen on every shutdown, but often enough to be annoying (as it forces a diskcheck on reboot, of course).   Which log files can tell me what's going wrong? More or less blindly searching in the sys log viewer reminds me of needles in a haystack.  I imagine I could pinpoint the time it happens via log timestamps, but how do I read timestamps like e.g. in kern.log: [36169.146130]? How do I get this human-readable?  Lastly, a bit of a btw, I've never managed to execute an Alt-Sysrq-REISUB to force a cleaner shutdown, but that's probably because I'm on a laptop, PrintScr is only accessible via an Fn key, and I'm not sure of the exact key sequence I need. Is there a "harmless" but user-visible magic command I could practice this with (during normal operation), so I can find out how to do a REISUB next time?  Thanks all! Comment if you need additional data... Show that the set of all finite subsets of $\mathbb{N}$ is countable. Show that the set of all finite subsets of $\mathbb{N}$ is countable.   I'm not sure how to do this problem. I keep trying to think of an explicit formula for 1-1 correspondence like adding all the elements in each subset and sending that sum to itself in the natural numbers, but that wouldn't be 1-1 because, for example, the set {1,2,3} would send to 6 and so would the set {2,4}.  Multiplying all the elements in each subset and sending that product to itself in the natural numbers wouldn't work either since, for example, {2,3} would send to 5 and so would the set {1,5}. Any ideas? register_globals error in php I was stuck up with the error   directive 'register_globals' is no longer available in PHP in unknown on line 0   when tried to check the php version using "php -v" after enabling register_globals in php.ini file. I am not getting any php version info by doing so. Instead it throws the above mentioned error.After turning off this option, php info works quite well. It is very essential for me to have register_globals to be turned on.How can I have this corrected.  my php.ini is as follows:   ; Default Value: None ; Development Value: "GP" ; Production Value: "GP" ; http://php.net/request-order request_order = "GP"  ; Whether or not to register the EGPCS variables as global variables.  You may ; want to turn this off if you don't want to clutter your scripts' global scope ; with user data. ; You should do your best to write your scripts so that they do not require ; register_globals to be on;  Using form variables as globals can easily lead ; to possible security problems, if the code is not very well thought of. ;  register_globals = On  ; Determines whether the deprecated long $HTTP_*_VARS type predefined variables ; are registered by PHP or not. As they are deprecated, we obviously don't ; recommend you use them. They are on by default for compatibility reasons but ; they are not recommended on production servers. ; Default Value: On ; Development Value: Off ; Production Value: Off ;  register_long_arrays = Off  ; This directive determines whether PHP registers $argv &amp; $argc each time it ; runs. $argv contains an array of all the arguments passed to PHP when a script ; is invoked. $argc contains an integer representing the number of arguments ; that were passed when the script was invoked. These arrays are extremely ; useful when running scripts from the command line. When this directive is ; enabled, registering these variables consumes CPU cycles and memory each time ; a script is executed. For performance reasons, this feature should be disabled ; on production servers. ; Note: This directive is hardcoded to On for the CLI SAPI ; Default Value: On ; Development Value: Off ; Production Value: Off ; register_argc_argv = Off  ; When enabled, the SERVER and ENV variables are created when they're first ; used (Just In Time) instead of when the script starts. If these variables ; are not used within a script, having this directive on will result in a ; performance gain. The PHP directives register_globals, register_long_arrays, ; and register_argc_argv must be disabled for this directive to have any affect. ; auto_globals_jit = On