trigger PaymentTrigger on Money_Received__c (after insert, after update, after delete) {      Money_Received__c moneyReceived = [SELECT Reservation__c FROM Money_Received__c];      Reservation__c reservation = [SELECT Id, Name, Total_Recieved__c FROM Reservation__c where Id =: moneyReceived.Reservation__c];     Decimal totalReceived = reservation.Total_Recieved__c;      if(Trigger.IsInsert){         for(Money_Received__c payment: Trigger.new){             totalReceived += payment.Amount_Received__c;         }         update reservation;     }      if(Trigger.IsDelete){          for(Money_Received__c payment: Trigger.old){             totalReceived -= payment.Amount_Received__c;         }         update reservation;     } }   I'm trying to write a trigger that sum up payments.  reservation__c and money_received__c are look-up relationship.  sum of Money_Received__c. Amount_Received__c  should be equal to Reservation__c. Total_Recieved__c.  I wrote this trigger, but gives me an error message saying     PaymentTrigger: execution of AfterInsert caused by: System.QueryException: List has more than 1 row for assignment to SObject Trigger.PaymentTrigger: line 3, column 1   Any suggestions on how to fix this? Also, how do I write 'trigger.updated'?  your help is appreciated.
I am trying to get this trigger to work but it is giving me an error and I am not able to figure out why. The error I am getting is "attempt to de-reference a null object)  Why trigger? We have a Destinations object which is linked to Supplier products object via a lookup relationship. There are two types of supplier products(marketplace and curated) We want to count the number of live Supplier products and put them in a separate fields(live counts for each type).  I have gotten so far to actually count the number of live products and it is giving me an error. Can any one help? I am posting the code below  Trigger code :   trigger NoOfLiveProducts on Supplier_Product__c (after insert, after Delete, after update, after undelete) {       set&lt;string&gt; destinationids = new set&lt;string&gt;();      if(trigger.isInsert) {         for(Supplier_product__c products : Trigger.new) {             destinationids.add(products.Destination__c);         }     } else if(trigger.isDelete) {         for(Supplier_product__c products : Trigger.old) {             destinationids.add(products.Destination__c);         }     }else if(trigger.isUnDelete) {         for(Supplier_product__c products : Trigger.new){             destinationids.add(products.Destination__c);         }      } else if(trigger.isUpdate) {         for(Supplier_product__c products : Trigger.new) {             destinationids.add(products.Destination__c);         }     }      if(destinationids.size() &gt; 0){         Productcounter pc = new Productcounter();         pc.updateproductCount(destinationids);     }    }   Class code :  public class Productcounter {      public void updateproductcount(set&lt;string&gt; productIDs) {           if(productIDs == null){                return;         }          if(productIDs.size() == 0){             return;         }           list&lt;Supplier_Product__c&gt; ProductList = new list&lt;Supplier_Product__c&gt;();         ProductList = [Select ID,Destination__c                     From Supplier_Product__c                     Where Destination__c = :productIDs];          integer totalCount;         map&lt;string, integer&gt; DestinationIDToProductCountMap = new map&lt;string, integer&gt;();                for(Supplier_product__c ProductItem : ProductList){             if(DestinationIDToProductCountMap.containsKey(ProductItem.Destination__c)){                 totalCount = DestinationIDToProductCountMap.get(ProductItem.Destination__c);             }else{                 totalCount = 0;             }             totalCount += 1;             DestinationIDToProductCountMap.put(ProductItem.Destination__c, totalCount);         }          list&lt;Destination__c&gt; DestinationUpdateList = new list&lt;Destination__c&gt;();         Destination__c DestinationTemp;         for(string ProductID : DestinationIDToProductCountMap.keySet()){             DestinationTemp.ID = ProductID;             DestinationTemp.No_of_Live_Curated_Products__c = DestinationIDToProductCountMap.get(ProductID);             DestinationUpdateList.add(DestinationTemp);         }         if(DestinationUpdateList.size() &gt; 0){             update DestinationUpdateList;         }           }           }
How can I edit/create new launcher items in Unity by hand? Will Unity allow making custom launcher icons from .desktop files or via menu editing system? (Right now the launcher doesn't give the option to "keep in launcher" on all programs.  For some programs I use, I have to make custom launchers or .desktop files.  For instance, daily blender builds are generally just folders with an executable.  In basic Gnome or KDE, I can make a new menu entry with the menu editing system. Then, I can also add it to Docky either from the menu or by dragging a .desktop file to it. Unity launcher doesn't support drag and drop, so thats not a bug or anything, but when I open a .desktop file, it has unpredictable results. Most time it will not have "keep in launcher". Sometime it will have a pinnable item without the .desktop's icon, and if I pin the item to the launcher, it will not call upon the program again after closing it. I've also gotten it to just work with a .desktop file for celtx. How can I modify the advanced search form when my hook runs too early? How to find all files with the same extension within a directory I want to search for all .conf files in /etc/. I tried grep -r *.conf /etc, but the result isn't right. What am I doing wrong? \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \begin{document} \tl_to_str:n { testing _ things }  \par  \tl_set:Nn \l_tmpa_tl { testing _ things } \tl_to_str:N \l_tmpa_tl \end{document}   gives a strange result (testing ̇things).  How can I get testing_things?  I basically want verbatim content (with line breaking). I want to validate a set of credentials against the domain controller. e.g.:  Username: STACKOVERFLOW\joel Password: splotchy   Method 1. Query Active Directory with Impersonation  A lot of people suggest querying the Active Directory for something. If an exception is thrown, then you know the credentials are not valid - as is suggested in .  There are some serious  however:   You are not only authenticating a domain account, but you are also doing an implicit authorization check. That is, you are reading properties from the AD using an impersonation token. What if the otherwise valid account has no rights to read from the AD? By default all users have read access, but domain policies can be set to disable access permissions for restricted accounts (and or groups). Binding against the AD has a serious overhead, the AD schema cache has to be loaded at the client (ADSI cache in the ADSI provider used by DirectoryServices). This is both network, and AD server, resource consuming - and is too expensive for a simple operation like authenticating a user account. You're relying on an exception failure for a non-exceptional case, and assuming that means invalid username and password. Other problems (e.g. network failure, AD connectivity failure, memory allocation error, etc) are then mis-intrepreted as authentication failure.   Method 2. LogonUser Win32 API   have suggested using the  API function. This sounds nice, but unfortunately the calling user sometimes needs a permission usually only given to the operating system itself:     The process calling LogonUser requires   the SE_TCB_NAME privilege. If the   calling process does not have this   privilege, LogonUser fails and   GetLastError returns   ERROR_PRIVILEGE_NOT_HELD.       In some   cases, the process that calls   LogonUser must also have the   SE_CHANGE_NOTIFY_NAME privilege   enabled; otherwise, LogonUser fails   and GetLastError returns   ERROR_ACCESS_DENIED. This privilege is   not required for the local system   account or accounts that are members   of the administrators group. By   default, SE_CHANGE_NOTIFY_NAME is   enabled for all users, but some   administrators may disable it for   everyone.   Handing out the "Act as a part of the operating system" privilege is not something you want to do willy-nilly - as Microsoft points out in a :     ...the process that is calling   LogonUser must have the SE_TCB_NAME   privilege (in User Manager, this is   the "Act as part of the Operating   System" right). The SE_TCB_NAME   privilege is very powerful and   should not be granted to any arbitrary user just so that they can   run an application that needs to   validate credentials.   Additionally, a call to LogonUser() will fail if a blank password is specified.    What is the proper way to authenticate a set of domain credentials?    I happen to be calling from managed code, but this is a a general Windows question. It can be assumed that the customers have the .NET Framework 2.0 installed. preventDefault() on an  tag Err http://archive.canonical.com natty InRelease     Err http://security.ubuntu.com oneiric-security InRelease                Err http://extras.ubuntu.com natty InRelease                             Err http://security.ubuntu.com oneiric-security Release.gpg   Temporary failure resolving ‘security.ubuntu.com’ Err http://archive.canonical.com natty Release.gpg   Temporary failure resolving ‘archive.canonical.com’ Err http://extras.ubuntu.com natty Release.gpg   Temporary failure resolving ‘extras.ubuntu.com’ Err http://gb.archive.ubuntu.com oneiric InRelease Err http://gb.archive.ubuntu.com oneiric-updates InRelease Err http://gb.archive.ubuntu.com natty-backports InRelease Err http://gb.archive.ubuntu.com oneiric Release.gpg   Temporary failure resolving ‘gb.archive.ubuntu.com’ Err http://gb.archive.ubuntu.com oneiric-updates Release.gpg   Temporary failure resolving ‘gb.archive.ubuntu.com’ Err http://gb.archive.ubuntu.com natty-backports Release.gpg   Temporary failure resolving ‘gb.archive.ubuntu.com’  Reading package lists... Done W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric/InRelease       W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric-updates/InRelease   W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/natty-backports/InRelease   W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/InRelease   W: Failed to fetch http://archive.canonical.com/ubuntu/dists/natty/InRelease   W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/natty/InRelease   W: Failed to fetch http://archive.canonical.com/ubuntu/dists/natty/Release.gpg  Temporary failure resolving ‘archive.canonical.com’ W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/Release.gpg  Temporary failure resolving ‘security.ubuntu.com’ W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/natty/Release.gpg  Temporary failure resolving ‘extras.ubuntu.com’ W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric/Release.gpg  Temporary failure resolving ‘gb.archive.ubuntu.com’ W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric-updates/Release.gpg  Temporary failure resolving ‘gb.archive.ubuntu.com’ W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/natty-backports/Release.gpg  Temporary failure resolving ‘gb.archive.ubuntu.com’ W: Some index files failed to download. They have been ignored, or old ones used instead.   This is what I'm seeing when I try to run sudo apt-get update. I did an update on my instance yesterday and am now experiencing this. Allow the creation of links in formatted code through markdown or the GUI As pointed out in  it is possible to create a link in formatted code. But, only by using explicit HTML. Since I think creating a link to documentation within a code block is a fairly common use case, it should be possible to do this using the GUI.   I should be able to highlight some code. Press the  code formatting button. Then highlight some code within that and press the link button and create a link.  Today this results in:  [parseInt][3]("01", 10);   it should result in:  ("01",10); In C#, why can't a List object be stored in a List variable It seems that a List object cannot be stored in a List variable in C#, and can't even be explicitly cast that way.  List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = sl;   results in Cannot implicitly convert type System.Collections.Generic.List&lt;string&gt; to System.Collections.Generic.List&lt;object&gt;  And then...  List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = (List&lt;object&gt;)sl;   results in Cannot convert type System.Collections.Generic.List&lt;string&gt; to System.Collections.Generic.List&lt;object&gt;  Of course, you can do it by pulling everything out of the string list and putting it back in one at a time, but it is a rather convoluted solution. What is wrong with my date regex? I have a series of layers of lines (shapefiles) in My Project. The CRS of some are different and to merge them they all must have same CRS.  When I use Processing/Toolbox/Qgis_algorithims/Reproject_layer the reprojection only works if it is allowed to save to temporary file somewhere (it will not change the CRS when I reproject if I try to save and replace it in My Project directory);   I must remove the original from the layer list and reproject the temp file (without changing the CRS) to get it into my project and name it appropriately.  Is there a better way to reproject a layer in Qgis? Who is the Lord, as referred to in the title? Frodo? Sauron? Someone else? Or is it more of an abstract title, not referring to a single person, like "He who wields the One Ring"? I have a problem understanding the proof of Rencontres numbers (Derangements) I understand the whole concept of Rencontres numbers but I can't understand how to prove this equation  $$D_{n,0}=\left[\frac{n!}{e}\right]$$  where $[\cdot]$ denotes the rounding function (i.e., $[x]$ is the integer nearest to $x$). This equation that I wrote comes from solving the following recursion, but I don't understand how exactly the author calculated this recursion.  $$\begin {align*}  D_{n+2,0} &amp; =(n+1)(D_{n+1,0}+D_{n,0}) \\ D_{0,0} &amp; = 1 \\ D_{1,0} &amp; = 0  \end {align*} $$ Is diamagnetism a static or dynamic effect? When we put a diamagnetic material in the presence of an external magnetic field $\vec B_0$, the magnetic field inside the material decreases to $$\vec B=(1+\chi_m)\vec B_0,$$ where the magnetic susceptibility $\chi_m$ is a small negative number. I am assuming the material is linear and isotropic.  On the other hand the diamagnetism is explained in terms of Lenz law. When we change the magnetic flux of the external field over the material, atomic currents generate an induced magnetic field trying to restore the flux. But then the induced field could have any sign (in the appropriated direction), depending if we are increasing or decreasing the flux of the external field. It seems diamagnetism is a dynamic effect. How come the sign of $\chi_m$ is always negative? Moreover, the magnitude of $\chi_m$ should depend on how large is the variation of the flux but I do not see any suggestion of this when looking at tables of $\chi_m$. Detecting absolute motion inside a box This is not a contradiction and I know it is impossible but still consider a thought experiment by me and point out if something is wrong. See the following picture and then the explanation follows.    Rest frames are easy to understand. They are just for clarification. Lets move on to the moving frames. The velocity of the box is $0.1\ c$. Now a photon is emitted (I am not taking a light ray to avoid complication in discussion). After emission the box also moves a certain distance ahead. So the photon takes more than one second to reach the wall. But even the source moves that much distance ahead. When the light is reflected back, the source and the wall again move forward as the box is moving. But after reflection the wall has no role to play. We are concerned about the source. The source moves a certain distance ahead and therefore light takes less than one second to reach back. But the difference of the first case and the second case is not the same. To explain, I will give some equations.  Moving frame 1:  Velocity of the box: $0.1\ c = 30,000km/s$  Time taken by light to reach the wall $=\frac{330,000\ \text{km}}{300,000\ \text{kms}^{-1}}= 1.1s$  Distance moved ahead by the box from original position: $30,000\ \text{km}$  Moving frame 2:  distance moved ahead by the box from original position  $&gt;30,000\ \text{km}$ as the box also moves ahead after reflection.  let $d$ be the distance moved ahead by the box after reflection.  Time taken by light to reach the source: $\frac{270,000\ \text{km}\ -\ d}{300,000\ \text{kms}^{-1}} &lt;0.9s$  Therefore we see that this could possibly determine the absolute motion.  So in total we see that the light will take lesser time to reach the source. Please correct me if I am wrong and give your opinion why is it so.  EDIT 2 for clarification  The box is the compartment in space in which you are moving and I am calculating the time the light takes to reach back the source. I am not even adding velocities. Please correct me and tell me where did I add velocities. For clarification just let me give a simple example. Suppose person A is standing still and B is running towards a light source. Obviously he will see the light before person A even though the speed would be the same. So, what I am doing over here is not increasing the speed of light, but instead decreasing the distance to be covered by it. Diagonal lines in table cell I need this table:    (each row and column should have the same height and length, last cell should be divided by diagonal line). I tried the following code:  \documentclass[11pt]{article} \usepackage[T1]{fontenc} \usepackage{array} \usepackage{makecell} \newcolumntype{x}[1]{&gt;{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}} \begin{document} \setlength{\extrarowheight}{0.1cm} \begin{tabular}{|x{0.5cm}|x{0.5cm}|x{0.5cm}|x{0.5cm}|x{0.5cm}|}\hline &amp;&amp;&amp;&amp;20\\ \hline &amp;&amp;&amp;&amp;30\\ \hline &amp;&amp;&amp;&amp;45\\ \hline 15&amp;12&amp;18&amp;50&amp;\diaghead(-3,2){\hskip \hsize}{$a_i$}{$b_j$}\\ \hline \end{tabular} \end{document}   but text in the last cell is displayed incorrectly and cells are not the same.     How can I change that? How to isolate the text from a bitmap logo? I have been given a logo from a client that they want me to 'extract' or 'cut' the text out of and use just the text with a transparent background to fit with the design ethos of their marketing.   I'm using Photoshop CS6 and have tried using channels, magic wand and eraser but I can't get clean edges on the text.  I'm pretty new to Photoshop and any help appreciated. Unable to disable assignment rules I have a condition where I need to disable standard Lead Assignment Rules if certain criteria are met.   if(emailWithAccIdMap.containsKey(ledRec.Email) &amp;&amp; emailWithAccIdMap.get(ledRec.Email) != null &amp;&amp; !openOppMap.isEmpty() &amp;&amp; openOppMap.get(emailWithAccIdMap.get(ledRec.Email)) != null &amp;&amp; openOppMap.get(emailWithAccIdMap.get(ledRec.Email)).Owner.isActive ==true){                     ledRec.Status = 'Duplicate';                     System.debug('Changing the Status');                     //then assign the original lead owner to new lead owner                     ledRec.OwnerId = openOppMap.get(emailWithAccIdMap.get(ledRec.Email)).OwnerId;                     ledRec.Account_Name__c = openOppMap.get(emailWithAccIdMap.get(ledRec.Email)).AccountId;                     ledRec.Field_for_Lead_Workflow__c = true;                     Database.DMLOptions dmo = new Database.DMLOptions();                     dmo.assignmentRuleHeader.useDefaultRule = false;                     ledRec.setOptions(dmo);                     //since owner is assigned, it shouledRec not pass through round robin                     ledRec.checkAssignment__c = false;  }   This is my code snippet which is running on before insert. The control is entering the IF condition as the debug statement is getting printed. Yet, the owner assigned through this snippet is being overridden by the assignment rules.  I also tried executing this in after insert trigger context but it did not work. Can somebody tell me what I'm doing wrong? I have several files with the same base filename. I'd like to remove all but one  foo.org #keep foo.tex #delete foo.fls #delete foo.bib #delete etc   If I didn't need to keep one, I know I could use rm foo.*.    demonstrates ^ to negate a match. Through trial and error, I was able to find that  rm foo.*[^org]   does what I need, but I don't really understand the syntax.   Also, while not a limitation in my use case, I think this pattern also ignores foo.o and foo.or. How does this pattern work, and what would a glob that ignores only foo.org look like? How fast does gravity propagate? A thought experiment: Imagine the Sun is suddenly removed. We wouldn't notice a difference for 8 minutes, because that's how long light takes to get from the Sun's surface to Earth.   However, what about the Sun's gravitational effect? If gravity propagates at the speed of light, for 8 minutes the Earth will continue to follow an orbit around nothing. If however, gravity is due to a distortion of spacetime, this distortion will cease to exist as soon as the mass is removed, thus the Earth will leave through the orbit tangent, so we could observe the Sun's disappearance more quickly.  What is the state of the research around such a thought experiment? Can this be inferred from observation?