qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
43,148,553
I want to this list ``` A B C 111 11 123 1 42 5 ``` To be sorted ``` 1 5 11 42 111 123 A B C ``` By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5), But I want to sort numbers like numbers, and than strings that are not numbers. Is there clean solution to sort it like above? It is a list...
2017/03/31
[ "https://Stackoverflow.com/questions/43148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6836183/" ]
This will work for most use cases, but may have odd results if the string starts with control characters, string like "\tabc" will come before the integers: ``` list.OrderBy(x=>int.TryParse(x, out var dummy) ? dummy.ToString("D10") : x); ``` or for versions of C# prior to 7: ``` list.OrderBy(x=> { int dummy; return...
I've created a solution for this. I've divided the `list` into two part then sort and concat. Please check below: ``` public List<ListItem> getSortedList() { int dummy = 0; List<ListItem> list = new List<ListItem>(); list.Add(new ListItem() { Item = "A" }); list.Add(new ListItem() { Item = "B" }); ...
43,148,553
I want to this list ``` A B C 111 11 123 1 42 5 ``` To be sorted ``` 1 5 11 42 111 123 A B C ``` By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5), But I want to sort numbers like numbers, and than strings that are not numbers. Is there clean solution to sort it like above? It is a list...
2017/03/31
[ "https://Stackoverflow.com/questions/43148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6836183/" ]
What you want is called [Natural sort](https://en.wikipedia.org/wiki/Natural_sort_order). I once wrote some code for that: ``` public static class NaturalCompare { public static int Compare(string first, string second, StringComparison comparison = StringComparison.Ordinal) { if (string.Compare(first,...
I haven't tested this code for performance, but you can solve this with a Comparer ``` public class ArrayItemComparer : IComparer<string> { public int Compare(string x, string y) { int xInt = 0, yInt = 0; bool parseX = int.TryParse(x, out xInt); bool parseY = int.TryParse(y, out yInt);...
43,148,553
I want to this list ``` A B C 111 11 123 1 42 5 ``` To be sorted ``` 1 5 11 42 111 123 A B C ``` By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5), But I want to sort numbers like numbers, and than strings that are not numbers. Is there clean solution to sort it like above? It is a list...
2017/03/31
[ "https://Stackoverflow.com/questions/43148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6836183/" ]
I wrote this `IComparer` implementation a few months back to handle something like this. I think it will do what you want by default, though it is built to handle more complex cases where number/letter groups are separated by delimiters that also need to be sorted atomically. You should be able to adjust it to your nee...
Assuming you start with a collection of strings, a simple comparer should do the job: ``` public class Comparer : IComparer<string> { public int Compare(string a, string b) { int ia = 0; int ib = 0; var aIsInt = int.TryParse(a,out ia); var bIsInt = int.TryParse(b,out ib); ...
43,148,553
I want to this list ``` A B C 111 11 123 1 42 5 ``` To be sorted ``` 1 5 11 42 111 123 A B C ``` By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5), But I want to sort numbers like numbers, and than strings that are not numbers. Is there clean solution to sort it like above? It is a list...
2017/03/31
[ "https://Stackoverflow.com/questions/43148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6836183/" ]
What you want is called [Natural sort](https://en.wikipedia.org/wiki/Natural_sort_order). I once wrote some code for that: ``` public static class NaturalCompare { public static int Compare(string first, string second, StringComparison comparison = StringComparison.Ordinal) { if (string.Compare(first,...
You could loop through all the values once, and use int.TryParse to separate them into two separate lists: one for the values where int.TryParse returned true (aka the numbers), and another list for the ones where it returned false (the non-numbers). Then you could sort these two lists separately, and concatenate their...
43,148,553
I want to this list ``` A B C 111 11 123 1 42 5 ``` To be sorted ``` 1 5 11 42 111 123 A B C ``` By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5), But I want to sort numbers like numbers, and than strings that are not numbers. Is there clean solution to sort it like above? It is a list...
2017/03/31
[ "https://Stackoverflow.com/questions/43148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6836183/" ]
This will work for most use cases, but may have odd results if the string starts with control characters, string like "\tabc" will come before the integers: ``` list.OrderBy(x=>int.TryParse(x, out var dummy) ? dummy.ToString("D10") : x); ``` or for versions of C# prior to 7: ``` list.OrderBy(x=> { int dummy; return...
I haven't tested this code for performance, but you can solve this with a Comparer ``` public class ArrayItemComparer : IComparer<string> { public int Compare(string x, string y) { int xInt = 0, yInt = 0; bool parseX = int.TryParse(x, out xInt); bool parseY = int.TryParse(y, out yInt);...
43,148,553
I want to this list ``` A B C 111 11 123 1 42 5 ``` To be sorted ``` 1 5 11 42 111 123 A B C ``` By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5), But I want to sort numbers like numbers, and than strings that are not numbers. Is there clean solution to sort it like above? It is a list...
2017/03/31
[ "https://Stackoverflow.com/questions/43148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6836183/" ]
I wrote this `IComparer` implementation a few months back to handle something like this. I think it will do what you want by default, though it is built to handle more complex cases where number/letter groups are separated by delimiters that also need to be sorted atomically. You should be able to adjust it to your nee...
I've created a solution for this. I've divided the `list` into two part then sort and concat. Please check below: ``` public List<ListItem> getSortedList() { int dummy = 0; List<ListItem> list = new List<ListItem>(); list.Add(new ListItem() { Item = "A" }); list.Add(new ListItem() { Item = "B" }); ...
43,148,553
I want to this list ``` A B C 111 11 123 1 42 5 ``` To be sorted ``` 1 5 11 42 111 123 A B C ``` By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5), But I want to sort numbers like numbers, and than strings that are not numbers. Is there clean solution to sort it like above? It is a list...
2017/03/31
[ "https://Stackoverflow.com/questions/43148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6836183/" ]
What you want is called [Natural sort](https://en.wikipedia.org/wiki/Natural_sort_order). I once wrote some code for that: ``` public static class NaturalCompare { public static int Compare(string first, string second, StringComparison comparison = StringComparison.Ordinal) { if (string.Compare(first,...
I've created a solution for this. I've divided the `list` into two part then sort and concat. Please check below: ``` public List<ListItem> getSortedList() { int dummy = 0; List<ListItem> list = new List<ListItem>(); list.Add(new ListItem() { Item = "A" }); list.Add(new ListItem() { Item = "B" }); ...
43,148,553
I want to this list ``` A B C 111 11 123 1 42 5 ``` To be sorted ``` 1 5 11 42 111 123 A B C ``` By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5), But I want to sort numbers like numbers, and than strings that are not numbers. Is there clean solution to sort it like above? It is a list...
2017/03/31
[ "https://Stackoverflow.com/questions/43148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6836183/" ]
This will work for most use cases, but may have odd results if the string starts with control characters, string like "\tabc" will come before the integers: ``` list.OrderBy(x=>int.TryParse(x, out var dummy) ? dummy.ToString("D10") : x); ``` or for versions of C# prior to 7: ``` list.OrderBy(x=> { int dummy; return...
With Regex.Replace in the "OrderBy" it's one (fairly) simple line of code. And note that the number "3" just has to be a number equal-to or larger than your longest string, so for anyone else increase as needed. ``` using System.Text.RegularExpressions; string[] yourStrings = new string[] { "A", "B", "C", "111", "11"...
43,148,553
I want to this list ``` A B C 111 11 123 1 42 5 ``` To be sorted ``` 1 5 11 42 111 123 A B C ``` By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5), But I want to sort numbers like numbers, and than strings that are not numbers. Is there clean solution to sort it like above? It is a list...
2017/03/31
[ "https://Stackoverflow.com/questions/43148553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6836183/" ]
What you want is called [Natural sort](https://en.wikipedia.org/wiki/Natural_sort_order). I once wrote some code for that: ``` public static class NaturalCompare { public static int Compare(string first, string second, StringComparison comparison = StringComparison.Ordinal) { if (string.Compare(first,...
Assuming you start with a collection of strings, a simple comparer should do the job: ``` public class Comparer : IComparer<string> { public int Compare(string a, string b) { int ia = 0; int ib = 0; var aIsInt = int.TryParse(a,out ia); var bIsInt = int.TryParse(b,out ib); ...
33,573,692
I parse documents from a JSON, which will be added as children of a parent document. I just post the items to the index, without taking care about the id. Sometimes there will be updates to the JSON and items will be added to it. So e.g. I parsed 2 documents from the JSON and after a week or two I parse the same JSON ...
2015/11/06
[ "https://Stackoverflow.com/questions/33573692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1118527/" ]
Duplication needs to be handled in ID handling itself. Choose a key that is unique for a document and make that as the \_id. In the the key is too large or it is multiple keys , create a SHAH checksum out of it and make that as the \_id. If you already have dedupes in the database , you can use terms aggregation neste...
When adding a new document to elasticsearch, it first scans the existing documents to see if any of the IDs match. If there is already an existing document with that ID, the document will be updated instead of adding in a duplicate document (the version field will be updated at the same time to track the amount of upda...
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
The application keeps you logged in to your account once you log in unless you log out, but if you do anything that would require a password entry like managing your wish list, a Touch ID prompt comes up giving you the option to use your fingerprint instead of typing in your password
Ok, I just figured this out (finally), "and yes it does work". But it seems to be a combination of several of the answers provided above. Probably the most important thing to point out is Tpoccu's posting. "The application keeps you logged in to your account once you log in unless you log out", but if you're anythi...
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
I just received this email from Amazon that refutes the existence of the feature: > > Hello, > > > Thank you for contacting Amazon. I've researched "Touch ID" feature > and found this feature it isn't available with the Amazon Appstore > apps at this time. We're constantly adding apps and features to our > sele...
You're not alone, no one knows how to turn it on (or off!) [Amazon app for iPhone adds Touch ID support, but nobody knows how to turn it on…or off](http://www.geekwire.com/2014/amazon-app-iphone-gives-new-meaning-1-click-touch-id-support/) A friend of mine says it works on his iPhone 6+. And so, I log into the same A...
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
Go to settings, scroll down till you find a list of downloaded apps. Locate and tap Amazon app. You will find toggle switch to turn on/off touch id feature. Good Luck.
You're not alone, no one knows how to turn it on (or off!) [Amazon app for iPhone adds Touch ID support, but nobody knows how to turn it on…or off](http://www.geekwire.com/2014/amazon-app-iphone-gives-new-meaning-1-click-touch-id-support/) A friend of mine says it works on his iPhone 6+. And so, I log into the same A...
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
Go to settings, scroll down till you find a list of downloaded apps. Locate and tap Amazon app. You will find toggle switch to turn on/off touch id feature. Good Luck.
I just received this email from Amazon that refutes the existence of the feature: > > Hello, > > > Thank you for contacting Amazon. I've researched "Touch ID" feature > and found this feature it isn't available with the Amazon Appstore > apps at this time. We're constantly adding apps and features to our > sele...
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
The application keeps you logged in to your account once you log in unless you log out, but if you do anything that would require a password entry like managing your wish list, a Touch ID prompt comes up giving you the option to use your fingerprint instead of typing in your password
Settings>Passwords & Accounts>Website & App Passwords>Tap “+” then type www.amazon.com Then type username (your email address) Then type a password of your choice Worked for me. IPhone 6s iOS 13
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
Go to settings, scroll down till you find a list of downloaded apps. Locate and tap Amazon app. You will find toggle switch to turn on/off touch id feature. Good Luck.
Ok, I just figured this out (finally), "and yes it does work". But it seems to be a combination of several of the answers provided above. Probably the most important thing to point out is Tpoccu's posting. "The application keeps you logged in to your account once you log in unless you log out", but if you're anythi...
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
The application keeps you logged in to your account once you log in unless you log out, but if you do anything that would require a password entry like managing your wish list, a Touch ID prompt comes up giving you the option to use your fingerprint instead of typing in your password
You're not alone, no one knows how to turn it on (or off!) [Amazon app for iPhone adds Touch ID support, but nobody knows how to turn it on…or off](http://www.geekwire.com/2014/amazon-app-iphone-gives-new-meaning-1-click-touch-id-support/) A friend of mine says it works on his iPhone 6+. And so, I log into the same A...
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
I just received this email from Amazon that refutes the existence of the feature: > > Hello, > > > Thank you for contacting Amazon. I've researched "Touch ID" feature > and found this feature it isn't available with the Amazon Appstore > apps at this time. We're constantly adding apps and features to our > sele...
Ok, I just figured this out (finally), "and yes it does work". But it seems to be a combination of several of the answers provided above. Probably the most important thing to point out is Tpoccu's posting. "The application keeps you logged in to your account once you log in unless you log out", but if you're anythi...
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
The application keeps you logged in to your account once you log in unless you log out, but if you do anything that would require a password entry like managing your wish list, a Touch ID prompt comes up giving you the option to use your fingerprint instead of typing in your password
I just received this email from Amazon that refutes the existence of the feature: > > Hello, > > > Thank you for contacting Amazon. I've researched "Touch ID" feature > and found this feature it isn't available with the Amazon Appstore > apps at this time. We're constantly adding apps and features to our > sele...
145,857
Is there any way to export non Camera Roll or Photo Stream photo albums from an iPhone to a PC? There are a bunch of "free" software online than can do this, but they all require you to buy the software to transfer the photos, or they can only transfer a few photos before needing to buy the software. The iPhone is hoo...
2014/09/18
[ "https://apple.stackexchange.com/questions/145857", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/91170/" ]
Settings>Passwords & Accounts>Website & App Passwords>Tap “+” then type www.amazon.com Then type username (your email address) Then type a password of your choice Worked for me. IPhone 6s iOS 13
You're not alone, no one knows how to turn it on (or off!) [Amazon app for iPhone adds Touch ID support, but nobody knows how to turn it on…or off](http://www.geekwire.com/2014/amazon-app-iphone-gives-new-meaning-1-click-touch-id-support/) A friend of mine says it works on his iPhone 6+. And so, I log into the same A...
48,675
I got to thinking... Should questions with an open bounty get bumped periodically? Maybe once halfway through the bounty.
2010/05/04
[ "https://meta.stackexchange.com/questions/48675", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/142114/" ]
I think * having a dedicated tab on the homepage * a visual marker that distinguishes them from every other question * a potential reputation award for every new answer * getting bumped to the homepage at the time the bounty is set .. is sufficient.
I've had a few bounties that after making the question a bounty I only saw probably 20 or 30 more views and no new answers or anything. You put a bounty on something to get it answered. Not as the creator of some competition So bounties could be bumped maybe every day of the bounty. This way the question has a much g...
48,675
I got to thinking... Should questions with an open bounty get bumped periodically? Maybe once halfway through the bounty.
2010/05/04
[ "https://meta.stackexchange.com/questions/48675", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/142114/" ]
I think * having a dedicated tab on the homepage * a visual marker that distinguishes them from every other question * a potential reputation award for every new answer * getting bumped to the homepage at the time the bounty is set .. is sufficient.
As with all questions, if you are finding that people are not answering, you have a few options. 1. Do extra research to try and find more information 2. Re-read the question, answers, comments and edit your question 3. Add a bounty. At this point, you have already gone to step 3, so I'll consider steps 2 and 1. **...
13,017,081
I'm trying to create a dynamic searching function but there is a problem I am not able to solve. What's wrong with the following code? JSON: ``` ... $result=$obj->Decode_Serialize($resource);// method to unserialize string value $text= isset($result['text_department_code']) ? $result['text_department_code']: '...
2012/10/22
[ "https://Stackoverflow.com/questions/13017081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1705306/" ]
That's basically the automaton arrow: ``` newtype Auto a b = Auto (a -> (b, Auto a b)) ``` In Haskell it's not possible for a function to replace itself, but the automaton arrow represents functions that return a new version of themselves along with a result: ``` switcher :: Bool -> Auto Bool Bool switcher x = ...
In Haskell, you can provide custom optimization rewritings via the RULES pragma. See [the GHC user guide > Rewrite Rules](http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/rewrite-rules.html) for details.
43,650,421
If you had a List and wanted to merge the sub List for any SomeObject's that have the same Id field how would you do that? Here are the example objects: ``` public class SomeObject { public string Name { get; set; } public int Id { get; set; } public List<KeyPair> ValuePairs {get;set;} } public class Key...
2017/04/27
[ "https://Stackoverflow.com/questions/43650421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5870474/" ]
You need to group them by `Id` and use `SelectMany` to select `KeyPair` list. ``` var result = objects.GroupBy(o => o.Id).Select(group => new SomeObject { Id = group.Key, ValuePairs = group.SelectMany(x => x.ValuePairs).ToList() }).ToList(); ```
You can try this: ``` var res = objects.GroupBy(o => o.Id) .Select(group => new { Id = group.Key, ValuePairs = group.SelectMany(g => g.ValuePairs) }); ``` Original post: ``` var res = objects.Where(o => o.Id == 5).SelectMany(o => o.ValuePa...
43,650,421
If you had a List and wanted to merge the sub List for any SomeObject's that have the same Id field how would you do that? Here are the example objects: ``` public class SomeObject { public string Name { get; set; } public int Id { get; set; } public List<KeyPair> ValuePairs {get;set;} } public class Key...
2017/04/27
[ "https://Stackoverflow.com/questions/43650421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5870474/" ]
You need to group them by `Id` and use `SelectMany` to select `KeyPair` list. ``` var result = objects.GroupBy(o => o.Id).Select(group => new SomeObject { Id = group.Key, ValuePairs = group.SelectMany(x => x.ValuePairs).ToList() }).ToList(); ```
Use this function <https://dotnetfiddle.net/aE6p5H> ``` public List<SomeObject> MergeObj(List<SomeObject> someObjects) { var idList = someObjects.Select(x => x.Id).Distinct().ToList(); var newSomeObjects = new List<SomeObject>(); idList.ForEach(x => { var newValuePairLi...
43,650,421
If you had a List and wanted to merge the sub List for any SomeObject's that have the same Id field how would you do that? Here are the example objects: ``` public class SomeObject { public string Name { get; set; } public int Id { get; set; } public List<KeyPair> ValuePairs {get;set;} } public class Key...
2017/04/27
[ "https://Stackoverflow.com/questions/43650421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5870474/" ]
You can try this: ``` var res = objects.GroupBy(o => o.Id) .Select(group => new { Id = group.Key, ValuePairs = group.SelectMany(g => g.ValuePairs) }); ``` Original post: ``` var res = objects.Where(o => o.Id == 5).SelectMany(o => o.ValuePa...
Use this function <https://dotnetfiddle.net/aE6p5H> ``` public List<SomeObject> MergeObj(List<SomeObject> someObjects) { var idList = someObjects.Select(x => x.Id).Distinct().ToList(); var newSomeObjects = new List<SomeObject>(); idList.ForEach(x => { var newValuePairLi...
1,995,257
Find the point on $z=1-2x^2-y^2$ closest to $2x+3y+z=12$ using Lagrange multipliers. [Point on surface closest to a plane using Lagrange multipliers](https://math.stackexchange.com/questions/1990888/point-on-surface-closest-to-a-plane-using-lagrange-multipliers/1990903#1990903) Although the methods used in the answer...
2016/11/01
[ "https://math.stackexchange.com/questions/1995257", "https://math.stackexchange.com", "https://math.stackexchange.com/users/229023/" ]
Call $\zeta$ the coordinates of the point on the surface $g(\zeta) = 0$, and $\xi$ the coordinates on the plane $h(\xi) = 0$. The problem you are solving is then \begin{eqnarray} \mbox{minize: }\quad f(\zeta, \xi) &=& \frac{1}{2}\sum\_\alpha(\zeta\_\alpha - \xi\_\alpha)^2 \\ \mbox{suject to:}\quad g(\zeta) &=& 0 \\ h...
Answering to "I don' understand..claim that the distance will be minimized when the normals are parallel". On a pure *intuitive* basis (not pretending to be rigorous) consider a point on the given surface, and the tangent plane to the surface at that point. In a small domain around the point, the surface is "approxi...
56,224,091
As the question suggests, I can't figure out their meaning and why I should use it. It's said that it can be used so that when we have many components and we want to pass data from parent to the child's child's child's component, we don't have to use props. Is this true? It'd be nice If you could provide an easier exa...
2019/05/20
[ "https://Stackoverflow.com/questions/56224091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10046099/" ]
Have a look at the ["Disabling Attribute Inheritance"](https://v2.vuejs.org/v2/guide/components-props.html#Disabling-Attribute-Inheritance) section of the docs and the [api description](https://v2.vuejs.org/v2/api/#inheritAttrs) for the full details. It's main usage is to define so-called "transparent" components that...
For me talking about `$attrs` and `inheritAttrs` together, makes it harder to understand. So I will show a bit more observations. I will call my base-inp from HTML like below ``` <base-inp label="Username:" v-model="username" required placeholder="Enter your username"></base-inp> ``` The HTML for base-inp is like ...
38,230,533
I want to programmatically access Adobe's default print folder location if such is set. Is there a way to do that with C#? I think I will be fine with just knowing what its set to, but if its possible to set this setting from my app, then that would be great too. [![enter image description here](https://i.stack.img...
2016/07/06
[ "https://Stackoverflow.com/questions/38230533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3263488/" ]
I sorry, but I don't think that's possible. > > You cannot directly set any of these options (in any case, print driver options are very problematic as they are handled by a level of indirection in Windows and the registry keys can vary). > > > <https://forums.adobe.com/thread/1079735>
Most of the settings in that dialog box live in the registry at: `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Adobe PDF` and `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Adobe PDF\PrinterDriverData` Specifically, the "Port" key which has `Documents\*.pdf` is the one you w...
41,466,956
I have this kind of `email` table ``` id | url | id1 | id2 | mail_date | message ``` Example of my rows ``` id | url | id1 | id2 | mail_date | message 1 | aaa | 2 | 8 | JAN 2016 | blah blah 2 | bbb | 4 | 8 | FEB 2016 | blah blah 3 | aaa | 8 | 2 | MAR 2016 | blah blah 4 | bbb | 8 | 4 | APR 20...
2017/01/04
[ "https://Stackoverflow.com/questions/41466956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7059329/" ]
Distinct will only eliminate records which have the exact same data in all the columns selected. Since your URL varies for each record, distinct will not eliminate any records.. If what you're after is the most recent occurrence of a Sender/Receiver and it's URL, you can achieve this by first getting a set of data wit...
Updated: MySQL version 5.7.14 ``` select l.* from email l inner join ( select id1, id2, max(mail_date) as latest from email where id1 = 8 OR id2 = 8 group by id1, id2 ) r on l.mail_date = r.latest and l.id1 = r.id1 and l.id2 = r.id2 order by mail_date desc ``` If you want more detail you can chec...
41,466,956
I have this kind of `email` table ``` id | url | id1 | id2 | mail_date | message ``` Example of my rows ``` id | url | id1 | id2 | mail_date | message 1 | aaa | 2 | 8 | JAN 2016 | blah blah 2 | bbb | 4 | 8 | FEB 2016 | blah blah 3 | aaa | 8 | 2 | MAR 2016 | blah blah 4 | bbb | 8 | 4 | APR 20...
2017/01/04
[ "https://Stackoverflow.com/questions/41466956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7059329/" ]
Distinct will only eliminate records which have the exact same data in all the columns selected. Since your URL varies for each record, distinct will not eliminate any records.. If what you're after is the most recent occurrence of a Sender/Receiver and it's URL, you can achieve this by first getting a set of data wit...
You can make use of a sub-query. First get the results ordered by date and then group them. SELECT \* FROM ( SELECT url, id1, id2 FROM email WHERE id1 = 8 OR id2 = 8 ORDER BY mail\_date DESC ) tmp GROUP BY tmp.url **UPDATE:** @xQbert What I have understood now is that the required result set should contain...
41,466,956
I have this kind of `email` table ``` id | url | id1 | id2 | mail_date | message ``` Example of my rows ``` id | url | id1 | id2 | mail_date | message 1 | aaa | 2 | 8 | JAN 2016 | blah blah 2 | bbb | 4 | 8 | FEB 2016 | blah blah 3 | aaa | 8 | 2 | MAR 2016 | blah blah 4 | bbb | 8 | 4 | APR 20...
2017/01/04
[ "https://Stackoverflow.com/questions/41466956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7059329/" ]
Distinct will only eliminate records which have the exact same data in all the columns selected. Since your URL varies for each record, distinct will not eliminate any records.. If what you're after is the most recent occurrence of a Sender/Receiver and it's URL, you can achieve this by first getting a set of data wit...
Here is my attempt: <http://sqlfiddle.com/#!9/32c11f/4> ``` SELECT e.url, e.id1, e.id2 FROM email e LEFT JOIN email e1 ON e.url = e1.url AND e.id1 = e1.id1 AND e.id2 = e.id2 AND e.mail_date > e1.mail_date WHERE e.id1 = 8 OR e.id2 = 8 AND e1.url IS NULL ORDER BY e.mail_date DESC; ```
41,466,956
I have this kind of `email` table ``` id | url | id1 | id2 | mail_date | message ``` Example of my rows ``` id | url | id1 | id2 | mail_date | message 1 | aaa | 2 | 8 | JAN 2016 | blah blah 2 | bbb | 4 | 8 | FEB 2016 | blah blah 3 | aaa | 8 | 2 | MAR 2016 | blah blah 4 | bbb | 8 | 4 | APR 20...
2017/01/04
[ "https://Stackoverflow.com/questions/41466956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7059329/" ]
Here is my attempt: <http://sqlfiddle.com/#!9/32c11f/4> ``` SELECT e.url, e.id1, e.id2 FROM email e LEFT JOIN email e1 ON e.url = e1.url AND e.id1 = e1.id1 AND e.id2 = e.id2 AND e.mail_date > e1.mail_date WHERE e.id1 = 8 OR e.id2 = 8 AND e1.url IS NULL ORDER BY e.mail_date DESC; ```
Updated: MySQL version 5.7.14 ``` select l.* from email l inner join ( select id1, id2, max(mail_date) as latest from email where id1 = 8 OR id2 = 8 group by id1, id2 ) r on l.mail_date = r.latest and l.id1 = r.id1 and l.id2 = r.id2 order by mail_date desc ``` If you want more detail you can chec...
41,466,956
I have this kind of `email` table ``` id | url | id1 | id2 | mail_date | message ``` Example of my rows ``` id | url | id1 | id2 | mail_date | message 1 | aaa | 2 | 8 | JAN 2016 | blah blah 2 | bbb | 4 | 8 | FEB 2016 | blah blah 3 | aaa | 8 | 2 | MAR 2016 | blah blah 4 | bbb | 8 | 4 | APR 20...
2017/01/04
[ "https://Stackoverflow.com/questions/41466956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7059329/" ]
Here is my attempt: <http://sqlfiddle.com/#!9/32c11f/4> ``` SELECT e.url, e.id1, e.id2 FROM email e LEFT JOIN email e1 ON e.url = e1.url AND e.id1 = e1.id1 AND e.id2 = e.id2 AND e.mail_date > e1.mail_date WHERE e.id1 = 8 OR e.id2 = 8 AND e1.url IS NULL ORDER BY e.mail_date DESC; ```
You can make use of a sub-query. First get the results ordered by date and then group them. SELECT \* FROM ( SELECT url, id1, id2 FROM email WHERE id1 = 8 OR id2 = 8 ORDER BY mail\_date DESC ) tmp GROUP BY tmp.url **UPDATE:** @xQbert What I have understood now is that the required result set should contain...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
This answer is a conclusion of a discussion in [chat](http://chat.stackexchange.com/rooms/30863/discussion-between-james-webster-and-andyt) Your income and tax will look like this: [![enter image description here](https://i.stack.imgur.com/EgXZv.png)](https://i.stack.imgur.com/EgXZv.png) You also asked about a month...
CORRECT ANSWER FOUND! I'm new to the UK and also started work in September 2015. It also drove me insane I had such a hard time understanding how the taxes worked. After a lot of research, I came upon this thread, and read the whole thing, including the bits in the chat where James, you posted the final excel table. ...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
CORRECT ANSWER FOUND! I'm new to the UK and also started work in September 2015. It also drove me insane I had such a hard time understanding how the taxes worked. After a lot of research, I came upon this thread, and read the whole thing, including the bits in the chat where James, you posted the final excel table. ...
Your payslip should not show tax deductions until you have fully utilised your cumulative personal allowance for the tax year, if you started working somewhere in the middle of the tax year. example, Starting date: 01/01/2016 Salary: 2500 Income tax = 20%( £2500 - £7947(883 \*9) ) = 0 £7947 is cumulative personal all...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
CORRECT ANSWER FOUND! I'm new to the UK and also started work in September 2015. It also drove me insane I had such a hard time understanding how the taxes worked. After a lot of research, I came upon this thread, and read the whole thing, including the bits in the chat where James, you posted the final excel table. ...
In the UK, you pay income tax for your income in a tax year, which is from April to March. Roughly speaking, currently there is I think £10,600 of income tax free, then you pay 20% tax on the next £31,000 or so, 40% on another £110,000 and finally 45% on the rest (I'd love to have that problem). Your employer should ...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
This answer is a conclusion of a discussion in [chat](http://chat.stackexchange.com/rooms/30863/discussion-between-james-webster-and-andyt) Your income and tax will look like this: [![enter image description here](https://i.stack.imgur.com/EgXZv.png)](https://i.stack.imgur.com/EgXZv.png) You also asked about a month...
Your payslip should not show tax deductions until you have fully utilised your cumulative personal allowance for the tax year, if you started working somewhere in the middle of the tax year. example, Starting date: 01/01/2016 Salary: 2500 Income tax = 20%( £2500 - £7947(883 \*9) ) = 0 £7947 is cumulative personal all...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
Tax in the UK is handled on a monthly or weekly basis depending on how often you are paid, so your tax code means that for each month, you will get £10600/12 = £883 tax free and then the rest will be taxed. That means that normally people get about the same amount in each pay packet throughout the year, rather than ini...
In the UK, you pay income tax for your income in a tax year, which is from April to March. Roughly speaking, currently there is I think £10,600 of income tax free, then you pay 20% tax on the next £31,000 or so, 40% on another £110,000 and finally 45% on the rest (I'd love to have that problem). Your employer should ...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
This answer is a conclusion of a discussion in [chat](http://chat.stackexchange.com/rooms/30863/discussion-between-james-webster-and-andyt) Your income and tax will look like this: [![enter image description here](https://i.stack.imgur.com/EgXZv.png)](https://i.stack.imgur.com/EgXZv.png) You also asked about a month...
Tax in the UK is handled on a monthly or weekly basis depending on how often you are paid, so your tax code means that for each month, you will get £10600/12 = £883 tax free and then the rest will be taxed. That means that normally people get about the same amount in each pay packet throughout the year, rather than ini...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
In the UK, you pay income tax for your income in a tax year, which is from April to March. Roughly speaking, currently there is I think £10,600 of income tax free, then you pay 20% tax on the next £31,000 or so, 40% on another £110,000 and finally 45% on the rest (I'd love to have that problem). Your employer should ...
Your payslip should not show tax deductions until you have fully utilised your cumulative personal allowance for the tax year, if you started working somewhere in the middle of the tax year. example, Starting date: 01/01/2016 Salary: 2500 Income tax = 20%( £2500 - £7947(883 \*9) ) = 0 £7947 is cumulative personal all...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
I've *never* had consistent pay for the first couple of months in a new job (UK). Typically there's no tax taken in the first month, most of the first month's tax in the second, and by the third month things have settled down. Although using up the personal allowance over the first few months is sometimes seen, I'm mor...
Your payslip should not show tax deductions until you have fully utilised your cumulative personal allowance for the tax year, if you started working somewhere in the middle of the tax year. example, Starting date: 01/01/2016 Salary: 2500 Income tax = 20%( £2500 - £7947(883 \*9) ) = 0 £7947 is cumulative personal all...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
I've *never* had consistent pay for the first couple of months in a new job (UK). Typically there's no tax taken in the first month, most of the first month's tax in the second, and by the third month things have settled down. Although using up the personal allowance over the first few months is sometimes seen, I'm mor...
In the UK, you pay income tax for your income in a tax year, which is from April to March. Roughly speaking, currently there is I think £10,600 of income tax free, then you pay 20% tax on the next £31,000 or so, 40% on another £110,000 and finally 45% on the rest (I'd love to have that problem). Your employer should ...
55,353
I just started working in the UK for the first time and received my first payslip. Another colleague of mine got his second payslip here, from the same company. We were surprised that in the detail no amount for "Tax" was deducted. I researched a bit and found that for the tax code [1060L](http://taxaid.org.uk/guides...
2015/10/29
[ "https://money.stackexchange.com/questions/55353", "https://money.stackexchange.com", "https://money.stackexchange.com/users/34465/" ]
Tax in the UK is handled on a monthly or weekly basis depending on how often you are paid, so your tax code means that for each month, you will get £10600/12 = £883 tax free and then the rest will be taxed. That means that normally people get about the same amount in each pay packet throughout the year, rather than ini...
I've *never* had consistent pay for the first couple of months in a new job (UK). Typically there's no tax taken in the first month, most of the first month's tax in the second, and by the third month things have settled down. Although using up the personal allowance over the first few months is sometimes seen, I'm mor...
1,842,502
what would be the simplest way to change every nvarchar column in a database to a varchar? I personally would prefer nvarchar, but the data arch has specified that varchar must be used.
2009/12/03
[ "https://Stackoverflow.com/questions/1842502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72858/" ]
Here, to get you started: ``` Select 'Alter Table [' + TABLE_SCHEMA + '].[' + TABLE_NAME + '] Alter Column [' + COLUMN_NAME + '] VarChar(' + CAST(CHARACTER_MAXIMUM_LENGTH As VARCHAR) + ')' From INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'NVARCHAR' ``` This will generate all the needed alter statements for you (cut...
Ask the data arch to do it? or Generate a script of all objects in your system, alter then nvarchar's, then create a new database and import the data into it from the old one. or Write alter scripts to update the existing database. (This may be the best approach if it's a production database, or a client databas...
1,842,502
what would be the simplest way to change every nvarchar column in a database to a varchar? I personally would prefer nvarchar, but the data arch has specified that varchar must be used.
2009/12/03
[ "https://Stackoverflow.com/questions/1842502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72858/" ]
In order to handle MAX and exclude the niggly sysdiagrams: ``` SELECT ' ALTER TABLE [' + TABLE_SCHEMA + '].[' + TABLE_NAME + '] ALTER COLUMN [' + COLUMN_NAME + '] VARCHAR(' + (CASE WHEN CHARACTER_MAXIMUM_LENGTH = -1 THEN 'MAX' ELSE CAST(CHARACTER_MAXIMUM_LENGTH AS VARCHAR) END) + ') ' F...
Ask the data arch to do it? or Generate a script of all objects in your system, alter then nvarchar's, then create a new database and import the data into it from the old one. or Write alter scripts to update the existing database. (This may be the best approach if it's a production database, or a client databas...
1,842,502
what would be the simplest way to change every nvarchar column in a database to a varchar? I personally would prefer nvarchar, but the data arch has specified that varchar must be used.
2009/12/03
[ "https://Stackoverflow.com/questions/1842502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72858/" ]
Here, to get you started: ``` Select 'Alter Table [' + TABLE_SCHEMA + '].[' + TABLE_NAME + '] Alter Column [' + COLUMN_NAME + '] VarChar(' + CAST(CHARACTER_MAXIMUM_LENGTH As VARCHAR) + ')' From INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'NVARCHAR' ``` This will generate all the needed alter statements for you (cut...
In order to handle MAX and exclude the niggly sysdiagrams: ``` SELECT ' ALTER TABLE [' + TABLE_SCHEMA + '].[' + TABLE_NAME + '] ALTER COLUMN [' + COLUMN_NAME + '] VARCHAR(' + (CASE WHEN CHARACTER_MAXIMUM_LENGTH = -1 THEN 'MAX' ELSE CAST(CHARACTER_MAXIMUM_LENGTH AS VARCHAR) END) + ') ' F...
14,346,948
I need to ask for a username and print the name and home directory path associated with that username ``` echo Please enter your username read username ``` I am not sure how to use $username to locate information regarding its home directory and name.
2013/01/15
[ "https://Stackoverflow.com/questions/14346948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1975097/" ]
`awk -F: -v v="$username" '{if ($1==v) print $6}' /etc/passwd` Without awk: `cat /etc/passwd | grep "$username" | cut -d ":" -f6` User name: `cat /etc/passwd | grep "$username" | cut -d ":" -f5`
use [`getent`](http://man.cx/getent) ``` read -p "username: " username IFS=: read username password uid gid gecos homedir shell < <(getent passwd "$username") echo "fullname=${gecos%%,*}" echo "homedir=$homedir" ```
14,346,948
I need to ask for a username and print the name and home directory path associated with that username ``` echo Please enter your username read username ``` I am not sure how to use $username to locate information regarding its home directory and name.
2013/01/15
[ "https://Stackoverflow.com/questions/14346948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1975097/" ]
``` echo Please enter a username read username cat /etc/passwd | grep "$username" | cut -d ":" -f6 cat /etc/passwd | grep "$username" | cut -d ":" -f5 ```
use [`getent`](http://man.cx/getent) ``` read -p "username: " username IFS=: read username password uid gid gecos homedir shell < <(getent passwd "$username") echo "fullname=${gecos%%,*}" echo "homedir=$homedir" ```
10,671,545
-- java -- for the tree > > > ``` > 5 > 4 3 > 30 5 > > ``` > > I need to find the "Maximum track" so for this tree, its 39 (5+4+30) i need a function that do that (Complexity O(n)) can someone help me? ``` public static int GetTreePath(BinTreeNode<Integer> t){ if (t==null) ...
2012/05/20
[ "https://Stackoverflow.com/questions/10671545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
1) code line ``` JTable tblDataGridResults = new JTable(strPledgeArray, columnNames); ``` create a new JTable that isn't added to the GUI 2) better would be to add ColumnNames and Rows to the DefaultTableModel, please read in the tutorial [how TableModel works](http://docs.oracle.com/javase/tutorial/uiswing/compon...
Try this, Use Object[][] array instead of String[][] JTree constructor takes in 2-Dimension object array as the content of the table, and 1-Dimension string array... and then creates a table. For eg : ``` import java.awt.BorderLayout import java.awt.Color; import javax.swing.JFrame; import javax.swing.JPanel; i...
2,211,614
> > Identify $$\lim\limits\_{x \to +\infty } x^2 \left(\sqrt{x^4+x+1}-\sqrt{x^4+x+5}\right)$$ > > > My Try : $$\sqrt{x^4+x+1}=\sqrt{x^4(1+\frac{1}{x^3}+\frac{1}{x^4})}=x^2\sqrt{(1+\frac{1}{x^3}+\frac{1}{x^4})}$$ Now : $$\frac{1}{x^3}+\frac{1}{x^4}=z$$ $$(1+z)^{\frac{1}{n}}= 1 + \frac1n x + \frac{1 - n}{2n^2}x^2...
2017/03/31
[ "https://math.stackexchange.com/questions/2211614", "https://math.stackexchange.com", "https://math.stackexchange.com/users/403529/" ]
Write \begin{align} \sqrt{x^4+x+1}-\sqrt{x^4+x+5} =\frac{(\sqrt{x^4+x+1}-\sqrt{x^4+x+5})(\sqrt{x^4+x+1}+\sqrt{x^4+x+5})}{\sqrt{x^4+x+1}+\sqrt{x^4+x+5}} \end{align} and use \begin{align} \frac{1}{2\sqrt{x^4+x+5}}\leq\frac{1}{\sqrt{x^4+x+1}+\sqrt{x^4+x+5}}\leq \frac{1}{2\sqrt{x^4+x+1}} \end{align} and \begin{align} \sqr...
$$ \begin{aligned} \lim \_{x\to \infty }\left(x^2\:\left(\sqrt{x^4+x+1}-\sqrt{x^4+x+5}\right)\right) & = \lim \_{x\to \infty }\left(-\frac{4x^2}{\sqrt{x^4+x+1}+\sqrt{x^4+x+5}}\right) \\& = \lim \_{x\to \infty }\left(-\frac{4x^2}{x^2\sqrt{1+\frac{x}{x^4}+\frac{1}{x^4}}+x^2\sqrt{1+\frac{x}{x^4}+\frac{5}{x^4}}}\right) \\&...
7,481,529
I have xml configs which are very complex. They are validated using dtds. I am looking for some application which reads the dtds and provides a GUI interface to write xmls. So that we don't have to write xmls by hand. If there is nothing existing already, how to start with developing one?
2011/09/20
[ "https://Stackoverflow.com/questions/7481529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/463758/" ]
did you try [Eclipse](http://www.eclipse.org/)? You can edit XML files according to the DTD. If your audience is not development oriented, you can have a look to [Editix XML Editor](http://www.editix.com/) (the free version is already fully usable) or [Notepad++](http://notepad-plus-plus.org/) (a strange mix between t...
Take a look at [oXygen XML Author](http://www.oxygenxml.com/xml_author.html). It's not intended for programmers/developers like oXygen XML Editor is. It's a WYSIWYG XML authoring tool. You can create CSS stylesheets to display the XML in a way that is easy for the authors to create/modify the XML. It's not free and yo...
11,392,922
I was asked in a interview about the difference between node structures of Doubly linked list and binary Tree. **Doubly Linked List Struct** ``` typedef struct { int data; struct node * next; struct node * prev; }node; ``` **Binary Tree Struct** ``` typedef struct { int data; struct node * left; struct nod...
2012/07/09
[ "https://Stackoverflow.com/questions/11392922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030018/" ]
I think you have answered your own questions. Other than the obvious differences in names of the pointers (`next/prev` and `left/right`), the differences are: * In a doubly linked list, if `n.next` links to `m` then `m.prev` links to `n`. This is not the case in a binary tree. * In a doubly linked list, a node can hav...
You are absolutely right: assuming the same payload type (in your case it is `int`), the binary layout of these two node types is identical. It is only the usage of the two pointers that makes the two node types different. If you do not care about readability, you could use a node ``` typedef struct node { int da...
11,392,922
I was asked in a interview about the difference between node structures of Doubly linked list and binary Tree. **Doubly Linked List Struct** ``` typedef struct { int data; struct node * next; struct node * prev; }node; ``` **Binary Tree Struct** ``` typedef struct { int data; struct node * left; struct nod...
2012/07/09
[ "https://Stackoverflow.com/questions/11392922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030018/" ]
I think you have answered your own questions. Other than the obvious differences in names of the pointers (`next/prev` and `left/right`), the differences are: * In a doubly linked list, if `n.next` links to `m` then `m.prev` links to `n`. This is not the case in a binary tree. * In a doubly linked list, a node can hav...
You can generalize: both a doubly-linked list and a binary tree are examples of a directed graph in which each node can have at most two outgoing edges (since that's how many pointer fields there are in the struct). Each data structure imposes additional restrictions (for example in both cases the whole graph is reach...
66,676,769
I have deep link which redirects user to activity. Deep link looks like "https://example.com/login/userId". Is there any way I can get this userId in activity? UPD. It seems I didn't explain my question clearly. User clicks on link in his email and opens app with intent. And in this activity i need to get part deep li...
2021/03/17
[ "https://Stackoverflow.com/questions/66676769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10787000/" ]
From what I understood, you need to see if your array can be divided into 2 equal arrays and return `True` if it does else you return `False`, you don't need the arrays it gets divided to, just the fact that it can be divided. Well if it your array can be divided into 2 equal arrays, some of its elements should sum to...
Here is the function that you need, it returns True when the array can be divided into 2 equal arrays and False if it cannot, without use of any libraries : ``` def search(numbers): target = sum(numbers)/2 def subset_sum(numbers, target, partial=[]): s = sum(partial) if s == target: ...
69,921,145
I wanted to migrate from BigQuery to CloudSQL to save cost. My problem is that CloudSQL with PostgreSQL is very very slow compare to BigQuery. A query that takes 1.5 seconds in BigQuery takes almost 4.5 minutes(!) on CloudSQL with PostgreSQL. I have CloudSQL with PostgreSQL server with the following configs: [![enter...
2021/11/10
[ "https://Stackoverflow.com/questions/69921145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452602/" ]
For anyone coming here wondering how to tune their postgres machine on cloud sql they call it flags and you can do it from the UI although not all the config options are edit able. <https://cloud.google.com/sql/docs/postgres/flags#console>
PostGreSQL is very slow by design on every queries involving COUNT aggregate function and there is absolutly nothing to do except materialized view to enforces the performances. The tests I have made on my machine with 48 cores about [COUNT performances compare from PostGreSQL to MS SQL Server](http://mssqlserver.fr/p...
69,921,145
I wanted to migrate from BigQuery to CloudSQL to save cost. My problem is that CloudSQL with PostgreSQL is very very slow compare to BigQuery. A query that takes 1.5 seconds in BigQuery takes almost 4.5 minutes(!) on CloudSQL with PostgreSQL. I have CloudSQL with PostgreSQL server with the following configs: [![enter...
2021/11/10
[ "https://Stackoverflow.com/questions/69921145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452602/" ]
For anyone coming here wondering how to tune their postgres machine on cloud sql they call it flags and you can do it from the UI although not all the config options are edit able. <https://cloud.google.com/sql/docs/postgres/flags#console>
I believe you need to use a full-text search and the special GIN index. The steps: 1. Create the helper function for index: `CREATE OR REPLACE FUNCTION immutable_array_to_string(text[]) RETURNS text as $$ SELECT array_to_string($1, ','); $$ LANGUAGE sql IMMUTABLE;` 2. Create index itself: `CREATE INDEX videos_cats_fts...
69,921,145
I wanted to migrate from BigQuery to CloudSQL to save cost. My problem is that CloudSQL with PostgreSQL is very very slow compare to BigQuery. A query that takes 1.5 seconds in BigQuery takes almost 4.5 minutes(!) on CloudSQL with PostgreSQL. I have CloudSQL with PostgreSQL server with the following configs: [![enter...
2021/11/10
[ "https://Stackoverflow.com/questions/69921145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452602/" ]
For anyone coming here wondering how to tune their postgres machine on cloud sql they call it flags and you can do it from the UI although not all the config options are edit able. <https://cloud.google.com/sql/docs/postgres/flags#console>
Apart from the sql syntax optimization, have you tried Postgresql tune? I check the explaination has found only two workers in parallel and 25KMemory used in sorting. > > > > > > Workers Planned: 2" > > Sort Method: quicksort Memory: 25kB" > > > > > > > > > For your query, it is typical OLAP query. it perfo...
69,921,145
I wanted to migrate from BigQuery to CloudSQL to save cost. My problem is that CloudSQL with PostgreSQL is very very slow compare to BigQuery. A query that takes 1.5 seconds in BigQuery takes almost 4.5 minutes(!) on CloudSQL with PostgreSQL. I have CloudSQL with PostgreSQL server with the following configs: [![enter...
2021/11/10
[ "https://Stackoverflow.com/questions/69921145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452602/" ]
The initial query looks overcomplicated. It could be rewritten as: ``` SELECT v."title" FROM public.videos v WHERE array_to_string(v.categories, '^') ILIKE ALL (ARRAY['%thriller%', '%crime%']) ORDER BY views DESC LIMIT 12 OFFSET 0; ``` **[db<>fiddle demo](https://dbfiddle.uk/?rdbms=postgres_14&fiddle=446a8d1d6d366...
PostGreSQL is very slow by design on every queries involving COUNT aggregate function and there is absolutly nothing to do except materialized view to enforces the performances. The tests I have made on my machine with 48 cores about [COUNT performances compare from PostGreSQL to MS SQL Server](http://mssqlserver.fr/p...
69,921,145
I wanted to migrate from BigQuery to CloudSQL to save cost. My problem is that CloudSQL with PostgreSQL is very very slow compare to BigQuery. A query that takes 1.5 seconds in BigQuery takes almost 4.5 minutes(!) on CloudSQL with PostgreSQL. I have CloudSQL with PostgreSQL server with the following configs: [![enter...
2021/11/10
[ "https://Stackoverflow.com/questions/69921145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452602/" ]
The initial query looks overcomplicated. It could be rewritten as: ``` SELECT v."title" FROM public.videos v WHERE array_to_string(v.categories, '^') ILIKE ALL (ARRAY['%thriller%', '%crime%']) ORDER BY views DESC LIMIT 12 OFFSET 0; ``` **[db<>fiddle demo](https://dbfiddle.uk/?rdbms=postgres_14&fiddle=446a8d1d6d366...
I believe you need to use a full-text search and the special GIN index. The steps: 1. Create the helper function for index: `CREATE OR REPLACE FUNCTION immutable_array_to_string(text[]) RETURNS text as $$ SELECT array_to_string($1, ','); $$ LANGUAGE sql IMMUTABLE;` 2. Create index itself: `CREATE INDEX videos_cats_fts...
69,921,145
I wanted to migrate from BigQuery to CloudSQL to save cost. My problem is that CloudSQL with PostgreSQL is very very slow compare to BigQuery. A query that takes 1.5 seconds in BigQuery takes almost 4.5 minutes(!) on CloudSQL with PostgreSQL. I have CloudSQL with PostgreSQL server with the following configs: [![enter...
2021/11/10
[ "https://Stackoverflow.com/questions/69921145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452602/" ]
The initial query looks overcomplicated. It could be rewritten as: ``` SELECT v."title" FROM public.videos v WHERE array_to_string(v.categories, '^') ILIKE ALL (ARRAY['%thriller%', '%crime%']) ORDER BY views DESC LIMIT 12 OFFSET 0; ``` **[db<>fiddle demo](https://dbfiddle.uk/?rdbms=postgres_14&fiddle=446a8d1d6d366...
Apart from the sql syntax optimization, have you tried Postgresql tune? I check the explaination has found only two workers in parallel and 25KMemory used in sorting. > > > > > > Workers Planned: 2" > > Sort Method: quicksort Memory: 25kB" > > > > > > > > > For your query, it is typical OLAP query. it perfo...
57,935,450
I'm writing the following dynamic function call in Groovy, and wanted to know if there is a cleaner way to perform the following: ``` this.actions.each { a -> if (a.component) { this.context."${a.action}"(a.component) } else { this.context."${a.action}"() } } ``...
2019/09/14
[ "https://Stackoverflow.com/questions/57935450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11285086/" ]
groovy objects has [`invokeMethod`](http://docs.groovy-lang.org/latest/html/api/groovy/lang/GroovyObject.html#invokeMethod(java.lang.String,java.lang.Object)) method that could hide the if ``` this.context.invikeMethod( a.action, a.component ? [a.component] : null ) ``` `[a.component]` is in brackets because method ...
Without diving into meta-programming a lot, you could (mis-)use the `spread operator` ``` def a(){ 42 } def a( i ){ i } def b = 'a' def c = [ 22 ] assert 22 == "${b}"( *c ) c = [] assert 42 == "${b}"( *c ) ``` Applied to your specific method: ``` this.context."${a.action}"( *( a.component ? [ a.component ] : [] ...
49,267,671
I am trying to write a regular expression to allow all strings which matching a pattern but excluding few string following the same pattern for example: select all string start with site: but not (site:dev or site:corp) what I have is ... site:.\*[^!site:dev$][^!site:corp$] this does not work if I test it for site:...
2018/03/13
[ "https://Stackoverflow.com/questions/49267671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5983214/" ]
The chief risk is that the optimizer outright removes the call to `memcpy`. That's a perfectly reasonable optimization: the fastest code is code which isn't called, and it's safe to assume code isn't called with incorrect parameters. This also leads to the second risk: the optimizer may remove not just the `memcpy` c...
You can memcpy the objects back and forth as much as you want. The binary representation and alignment requirements of the structs are the same. If you really don't believe it, you can create static\_asserts that check that the size and offsets are the same.
49,267,671
I am trying to write a regular expression to allow all strings which matching a pattern but excluding few string following the same pattern for example: select all string start with site: but not (site:dev or site:corp) what I have is ... site:.\*[^!site:dev$][^!site:corp$] this does not work if I test it for site:...
2018/03/13
[ "https://Stackoverflow.com/questions/49267671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5983214/" ]
The compiler sees you have a copy constructor and backs off. It doesn't care what is in it, though it would be good if this simple case where the assignments add nothing to the default was detected by the compiler. In this particular case, you can get away with it, no real harm done. On the other hand, you leave a ...
You can memcpy the objects back and forth as much as you want. The binary representation and alignment requirements of the structs are the same. If you really don't believe it, you can create static\_asserts that check that the size and offsets are the same.
57,302,477
I made a small mobile app using flutter. When using it, it saves data locally into the Sqlite database. When I uninstall it , the database seems to get deleted as well, so next time I install the app again, the data is gone. Any ideas how to leave the database file in the phone even the app is deleted? Thank you.
2019/08/01
[ "https://Stackoverflow.com/questions/57302477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6215819/" ]
I do not know how to do this in iOS but for Android there is a way. Apps that target Android 6.0 (API level 23) or higher automatically participate in Auto Backup. In your app manifest file, set the boolean value `android:allowBackup` to enable or disable backup. The default value is `true`. ``` <manifest ... >...
I think the best way to take backup, save db as a txt file, and set your file in somewhere disk device . [Reading\_Writing\_file](https://flutter.dev/docs/cookbook/persistence/reading-writing-files) OR create new db as a backup db [Example](https://stackoverflow.com/questions/13502223/backup-restore-sqlite-db-in-and...
57,302,477
I made a small mobile app using flutter. When using it, it saves data locally into the Sqlite database. When I uninstall it , the database seems to get deleted as well, so next time I install the app again, the data is gone. Any ideas how to leave the database file in the phone even the app is deleted? Thank you.
2019/08/01
[ "https://Stackoverflow.com/questions/57302477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6215819/" ]
This issue exists if your device is Android 6 (API level 23) and above, where android supports automatic backup, which means data will be stored in the device even if you uninstall the application. **For Android:** To get rid of this, go to the AndroidManifest file and add ``` <application android:allowBackup=...
I do not know how to do this in iOS but for Android there is a way. Apps that target Android 6.0 (API level 23) or higher automatically participate in Auto Backup. In your app manifest file, set the boolean value `android:allowBackup` to enable or disable backup. The default value is `true`. ``` <manifest ... >...
57,302,477
I made a small mobile app using flutter. When using it, it saves data locally into the Sqlite database. When I uninstall it , the database seems to get deleted as well, so next time I install the app again, the data is gone. Any ideas how to leave the database file in the phone even the app is deleted? Thank you.
2019/08/01
[ "https://Stackoverflow.com/questions/57302477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6215819/" ]
This issue exists if your device is Android 6 (API level 23) and above, where android supports automatic backup, which means data will be stored in the device even if you uninstall the application. **For Android:** To get rid of this, go to the AndroidManifest file and add ``` <application android:allowBackup=...
I think the best way to take backup, save db as a txt file, and set your file in somewhere disk device . [Reading\_Writing\_file](https://flutter.dev/docs/cookbook/persistence/reading-writing-files) OR create new db as a backup db [Example](https://stackoverflow.com/questions/13502223/backup-restore-sqlite-db-in-and...
42,060,254
When I run `/sbin/ebtables --list` in a Ubuntu Docker container, I get the message: ``` root@500790dca629:/core-release-4.8# /sbin/ebtables --list modprobe: ERROR: ../libkmod/libkmod.c:557 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.43-boot2docker/modules.dep.bin' The kernel doesn't support the ...
2017/02/06
[ "https://Stackoverflow.com/questions/42060254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1204766/" ]
By default docker doesn't support this capability. But you can pass below parameter while launching docker container to support Linux capability: ``` --cap-add Add Linux capabilities --cap-drop Drop Linux capabilities ``` For Network capability like iptables, ebtables etc. you have to add `NET_ADMIN` ca...
Adding mount helped me ``` cap_add: - 'ALL' volumes: - '/dev:/dev' - '/lib/modules:/lib/modules' ``` root@linuxbridge-agent:/# ls /lib/modules 5.4.0-26-generic 5.4.0-37-generic 5.4.0-39-generic 5.4.0-40-generic
49,941,379
I'm creating an AJAX function that can make a request for insert a new line in a database and then expose the result in the browser web of the client. So I made this things: **script.js** ``` /* bla bla bla*/ function submitAjaxFunction() { var data = { /*some data*/ }; $.ajax({ type: "POST", ...
2018/04/20
[ "https://Stackoverflow.com/questions/49941379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5553962/" ]
We can use the triple-bang operator with the plural form `parse_exprs` and a modified `e2` expression to parse multiple expressions (see `?parse_quosures`): Explanation: 1. Multiple expressions in `e2` need to be separated either by `;` or by new lines. 2. From `?quasiquotation`: *The `!!!` operator unquotes and spl...
You could always split them outside the expressions for example: ``` e2 = "vs + am" e3 = "am +vs" mtcars %>% mutate(!!parse_expr(e2),!!parse_expr(e3)) ``` You can do this with `parse_exprs` and a semicolon instead of a comma thanks @Maurits Evers. `!!!` takes a list of elements and splices them into to the current ...
49,941,379
I'm creating an AJAX function that can make a request for insert a new line in a database and then expose the result in the browser web of the client. So I made this things: **script.js** ``` /* bla bla bla*/ function submitAjaxFunction() { var data = { /*some data*/ }; $.ajax({ type: "POST", ...
2018/04/20
[ "https://Stackoverflow.com/questions/49941379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5553962/" ]
We can use the triple-bang operator with the plural form `parse_exprs` and a modified `e2` expression to parse multiple expressions (see `?parse_quosures`): Explanation: 1. Multiple expressions in `e2` need to be separated either by `;` or by new lines. 2. From `?quasiquotation`: *The `!!!` operator unquotes and spl...
Here a little trick I use to **name variables** *(as [Genom](https://stackoverflow.com/users/2900822/genom) asked)* Exemple with **2 named expressions :** ``` across_funs <- function(x, .fns, .cols) { stopifnot(length(.fns) == length(.cols)) stopifnot(all(sapply(.fns, class) == "call")) for (i in 1:length(.f...
21,091,867
I'm debugging an oddity with a shell script and wondering whether I've misunderstood how Bash's "fork" (`&`) works, perhaps because I usually use it in single commands through a terminal, e.g.: ``` [~me]$ someExecutable & ``` Now, in a shell script: ``` foo() { echo "logic" } bar() { echo "idic" } baz() { ...
2014/01/13
[ "https://Stackoverflow.com/questions/21091867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560648/" ]
The ampersand is only forking the call to foo() in your example. It is not forking the entire script. Only foo() runs in a separate thread, which exits when foo() finishes. bar() and baz() continue to run in the same thread
The `&` character tells the shell to execute a command (or a group of commands) in the background. The next commands are executed immediately. There is no danger of executing the script twice, so it is different than C's `fork()` in that respect.
21,091,867
I'm debugging an oddity with a shell script and wondering whether I've misunderstood how Bash's "fork" (`&`) works, perhaps because I usually use it in single commands through a terminal, e.g.: ``` [~me]$ someExecutable & ``` Now, in a shell script: ``` foo() { echo "logic" } bar() { echo "idic" } baz() { ...
2014/01/13
[ "https://Stackoverflow.com/questions/21091867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560648/" ]
The `&` in bash is not a fork. It tells bash to launch the command in a subshell, and continue parsing for other commands (instead of waiting for that command to finish). Therefore, as you expected, it runs 'foo' in the background, and continues to process the 'bar' and 'baz' command in the top level shell. No forking...
The `&` character tells the shell to execute a command (or a group of commands) in the background. The next commands are executed immediately. There is no danger of executing the script twice, so it is different than C's `fork()` in that respect.
21,091,867
I'm debugging an oddity with a shell script and wondering whether I've misunderstood how Bash's "fork" (`&`) works, perhaps because I usually use it in single commands through a terminal, e.g.: ``` [~me]$ someExecutable & ``` Now, in a shell script: ``` foo() { echo "logic" } bar() { echo "idic" } baz() { ...
2014/01/13
[ "https://Stackoverflow.com/questions/21091867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560648/" ]
The `&` character tells the shell to execute a command (or a group of commands) in the background. The next commands are executed immediately. There is no danger of executing the script twice, so it is different than C's `fork()` in that respect.
Actually this command does run your function foo the background: ``` foo & ``` But by the time you enter `bar` and `baz` foo has already completed its run and printed its output on your terminal. However if you run your functions like this then you will notice the difference: ``` foo & bar; baz [1] 46453 idic katr...
21,091,867
I'm debugging an oddity with a shell script and wondering whether I've misunderstood how Bash's "fork" (`&`) works, perhaps because I usually use it in single commands through a terminal, e.g.: ``` [~me]$ someExecutable & ``` Now, in a shell script: ``` foo() { echo "logic" } bar() { echo "idic" } baz() { ...
2014/01/13
[ "https://Stackoverflow.com/questions/21091867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560648/" ]
The ampersand is only forking the call to foo() in your example. It is not forking the entire script. Only foo() runs in a separate thread, which exits when foo() finishes. bar() and baz() continue to run in the same thread
The `&` in bash is not a fork. It tells bash to launch the command in a subshell, and continue parsing for other commands (instead of waiting for that command to finish). Therefore, as you expected, it runs 'foo' in the background, and continues to process the 'bar' and 'baz' command in the top level shell. No forking...
21,091,867
I'm debugging an oddity with a shell script and wondering whether I've misunderstood how Bash's "fork" (`&`) works, perhaps because I usually use it in single commands through a terminal, e.g.: ``` [~me]$ someExecutable & ``` Now, in a shell script: ``` foo() { echo "logic" } bar() { echo "idic" } baz() { ...
2014/01/13
[ "https://Stackoverflow.com/questions/21091867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560648/" ]
The ampersand is only forking the call to foo() in your example. It is not forking the entire script. Only foo() runs in a separate thread, which exits when foo() finishes. bar() and baz() continue to run in the same thread
Aside from the fact that the control operator `&` causes the command to be executed asynchronously in a subshell [1](http://www.gnu.org/software/bash/manual/bashref.html#Lists), you could make use of [Coprocesses](http://www.gnu.org/software/bash/manual/bashref.html#Coprocesses) to control the output. Instead of invok...
21,091,867
I'm debugging an oddity with a shell script and wondering whether I've misunderstood how Bash's "fork" (`&`) works, perhaps because I usually use it in single commands through a terminal, e.g.: ``` [~me]$ someExecutable & ``` Now, in a shell script: ``` foo() { echo "logic" } bar() { echo "idic" } baz() { ...
2014/01/13
[ "https://Stackoverflow.com/questions/21091867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560648/" ]
The ampersand is only forking the call to foo() in your example. It is not forking the entire script. Only foo() runs in a separate thread, which exits when foo() finishes. bar() and baz() continue to run in the same thread
Actually this command does run your function foo the background: ``` foo & ``` But by the time you enter `bar` and `baz` foo has already completed its run and printed its output on your terminal. However if you run your functions like this then you will notice the difference: ``` foo & bar; baz [1] 46453 idic katr...
21,091,867
I'm debugging an oddity with a shell script and wondering whether I've misunderstood how Bash's "fork" (`&`) works, perhaps because I usually use it in single commands through a terminal, e.g.: ``` [~me]$ someExecutable & ``` Now, in a shell script: ``` foo() { echo "logic" } bar() { echo "idic" } baz() { ...
2014/01/13
[ "https://Stackoverflow.com/questions/21091867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560648/" ]
The `&` in bash is not a fork. It tells bash to launch the command in a subshell, and continue parsing for other commands (instead of waiting for that command to finish). Therefore, as you expected, it runs 'foo' in the background, and continues to process the 'bar' and 'baz' command in the top level shell. No forking...
Aside from the fact that the control operator `&` causes the command to be executed asynchronously in a subshell [1](http://www.gnu.org/software/bash/manual/bashref.html#Lists), you could make use of [Coprocesses](http://www.gnu.org/software/bash/manual/bashref.html#Coprocesses) to control the output. Instead of invok...
21,091,867
I'm debugging an oddity with a shell script and wondering whether I've misunderstood how Bash's "fork" (`&`) works, perhaps because I usually use it in single commands through a terminal, e.g.: ``` [~me]$ someExecutable & ``` Now, in a shell script: ``` foo() { echo "logic" } bar() { echo "idic" } baz() { ...
2014/01/13
[ "https://Stackoverflow.com/questions/21091867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560648/" ]
The `&` in bash is not a fork. It tells bash to launch the command in a subshell, and continue parsing for other commands (instead of waiting for that command to finish). Therefore, as you expected, it runs 'foo' in the background, and continues to process the 'bar' and 'baz' command in the top level shell. No forking...
Actually this command does run your function foo the background: ``` foo & ``` But by the time you enter `bar` and `baz` foo has already completed its run and printed its output on your terminal. However if you run your functions like this then you will notice the difference: ``` foo & bar; baz [1] 46453 idic katr...
21,091,867
I'm debugging an oddity with a shell script and wondering whether I've misunderstood how Bash's "fork" (`&`) works, perhaps because I usually use it in single commands through a terminal, e.g.: ``` [~me]$ someExecutable & ``` Now, in a shell script: ``` foo() { echo "logic" } bar() { echo "idic" } baz() { ...
2014/01/13
[ "https://Stackoverflow.com/questions/21091867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560648/" ]
Aside from the fact that the control operator `&` causes the command to be executed asynchronously in a subshell [1](http://www.gnu.org/software/bash/manual/bashref.html#Lists), you could make use of [Coprocesses](http://www.gnu.org/software/bash/manual/bashref.html#Coprocesses) to control the output. Instead of invok...
Actually this command does run your function foo the background: ``` foo & ``` But by the time you enter `bar` and `baz` foo has already completed its run and printed its output on your terminal. However if you run your functions like this then you will notice the difference: ``` foo & bar; baz [1] 46453 idic katr...
71,596,888
[![built a class i get this error when i run the code](https://i.stack.imgur.com/fekVn.jpg)](https://i.stack.imgur.com/fekVn.jpg) if unit == 'F': self.number = (number - 32) \* 5/9 UnboundLocalError: local variable 'number' referenced before assignment
2022/03/24
[ "https://Stackoverflow.com/questions/71596888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15150328/" ]
No external module is needed to parse URLs in Deno. The [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) class is available as a global, just like in your browser: ```js const urlString = "https://www.google.com"; const url = new URL(urlString); console.log(`URL: ${url.protocol}//${url.host}`); ```
Aside from using the ECMA script's native [URL class](https://developer.mozilla.org/en-US/docs/Web/API/URL), as illustrated by [jsejcksn's answer](https://stackoverflow.com/a/71599970/286807), you can also use [url](https://nodejs.org/api/url.html) library from the [/std/node](https://deno.land/std@0.130.0/node) compat...
10,359
I have a recurrence relation, it is like the following: $T(e^n) = 2(T(e^{n-1})) + e^n$, where $e$ is the base of the natural logarithm. To solve this and find a $\Theta$ bound, I tried the following: I put $k=e^n$, and the equation transforms into: $$T(k)=2T(k/e)+k$$ Then, I try to use the Master Theorem. According...
2013/03/07
[ "https://cs.stackexchange.com/questions/10359", "https://cs.stackexchange.com", "https://cs.stackexchange.com/users/7175/" ]
$c=1\gt \ln 2\approx0.7$. That's [case 3](http://en.wikipedia.org/wiki/Master_theorem) of the master theorem. It follows that: $$T(n)=\Theta(n)$$ Your solution is fine.
Just use the change of variables $t(n) = T(e^n)$, you get $t(n) = t(n - 1) + e^n$. Linear, first order recurrence, solution is: $\begin{equation\*} t(n) = t(n - 1) + e^n \end{equation\*}$ Solution is: $\begin{align\*} t(n) &= t\_0 - \frac{e}{e - 1} + \frac{e^{n + 1}}{e - 1} \\ T(k) &= (t\_0 - \frac{e}{e - 1}) ...
42,904,322
I have a function, that count the visits of my web site, I tried to send a variable into the view but it doesn't work, the variable has to pass trought a file that contents the templates. When the variable I pass directly to the view it works, but other way doesn't. Please help me. Thanks. in the controller ``` $quer...
2017/03/20
[ "https://Stackoverflow.com/questions/42904322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7643933/" ]
You pass the variable to your template, but you need the variable in the left\_menu view, but you don't give the variable to that view. A quick fix would be just pass the variable along from within your template: ``` <?php $data = array($list1, $list2); $this->load->view('header'); $this->load->view('banner'); $this->...
Assuming that $data['list2'] is an array. Since an array should iterated even though it has a single value on each array key. a foreach will solve your problem. ```html <table border="1" width="250px" cellpading="5px" cellspacing="5px">'; <tr><td>FECHA</td><td>VISITAS</td></tr>'; tr><td><?php echo $list2['current_d...
42,904,322
I have a function, that count the visits of my web site, I tried to send a variable into the view but it doesn't work, the variable has to pass trought a file that contents the templates. When the variable I pass directly to the view it works, but other way doesn't. Please help me. Thanks. in the controller ``` $quer...
2017/03/20
[ "https://Stackoverflow.com/questions/42904322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7643933/" ]
You pass the variable to your template, but you need the variable in the left\_menu view, but you don't give the variable to that view. A quick fix would be just pass the variable along from within your template: ``` <?php $data = array($list1, $list2); $this->load->view('header'); $this->load->view('banner'); $this->...
``` //Controller code $query = $object->Searcher_visits(); if ($query->num_rows > 0){ $data['list2'] = $query->result(); $data['list'] = $obj_forum; } $this->load->view('header'); $this->load->view('banner'); $this->load->view('left_menu',$data); ``` //view page ``` <table border="1" width="250px" cellpading...
42,904,322
I have a function, that count the visits of my web site, I tried to send a variable into the view but it doesn't work, the variable has to pass trought a file that contents the templates. When the variable I pass directly to the view it works, but other way doesn't. Please help me. Thanks. in the controller ``` $quer...
2017/03/20
[ "https://Stackoverflow.com/questions/42904322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7643933/" ]
``` //Controller code $query = $object->Searcher_visits(); if ($query->num_rows > 0){ $data['list2'] = $query->result(); $data['list'] = $obj_forum; } $this->load->view('header'); $this->load->view('banner'); $this->load->view('left_menu',$data); ``` //view page ``` <table border="1" width="250px" cellpading...
Assuming that $data['list2'] is an array. Since an array should iterated even though it has a single value on each array key. a foreach will solve your problem. ```html <table border="1" width="250px" cellpading="5px" cellspacing="5px">'; <tr><td>FECHA</td><td>VISITAS</td></tr>'; tr><td><?php echo $list2['current_d...
38,393,078
In a [science museum in Norway](https://nordnorsk.vitensenter.no/) I came across the following mathematical game: [![enter image description here](https://i.stack.imgur.com/aBECB.jpg)](https://i.stack.imgur.com/aBECB.jpg) The goal is to place the 10 digits from 0 to 9 such that the difference between the two products...
2016/07/15
[ "https://Stackoverflow.com/questions/38393078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50065/" ]
If you assume there is a solution with difference 0, you can do via prime factors. If a*b - c*d = 0, then the prime factors of a*b and c*d must be the same. You can start the search by going through all 3-digit primes (there are only 143) and see whether they have a multiple that only contains disjunctive digits. If t...
As a heuristic you could compute the square root of 12345 (about 111) and go on from there, searching for the nearest values to 123 and 45 which you can create with the remaining numbers. I did not implement this but it could be a more intelligent approach. Another example: sqrt(36189) -> About 190 Remaining numbers...
38,393,078
In a [science museum in Norway](https://nordnorsk.vitensenter.no/) I came across the following mathematical game: [![enter image description here](https://i.stack.imgur.com/aBECB.jpg)](https://i.stack.imgur.com/aBECB.jpg) The goal is to place the 10 digits from 0 to 9 such that the difference between the two products...
2016/07/15
[ "https://Stackoverflow.com/questions/38393078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50065/" ]
12 seconds is too much for my taste. My C++ brute force attack took ~430ms without any heuristics or deep optimizations. Anyway you need to add some heuristics for example: **Bitwidth of multiplication result is around the sum of bitwidth of the operands.** So you need to test only the same bit width combinations of ...
As a heuristic you could compute the square root of 12345 (about 111) and go on from there, searching for the nearest values to 123 and 45 which you can create with the remaining numbers. I did not implement this but it could be a more intelligent approach. Another example: sqrt(36189) -> About 190 Remaining numbers...
38,393,078
In a [science museum in Norway](https://nordnorsk.vitensenter.no/) I came across the following mathematical game: [![enter image description here](https://i.stack.imgur.com/aBECB.jpg)](https://i.stack.imgur.com/aBECB.jpg) The goal is to place the 10 digits from 0 to 9 such that the difference between the two products...
2016/07/15
[ "https://Stackoverflow.com/questions/38393078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50065/" ]
There are 126 ways to split 10 digits into 2 sets of 5 without duplicates. For each set of 5 digits, there are 120 ways (permutations) to arrange them into the form `ab*cde`, or 72 ways if the group contains zero and a leading zero is not allowed. That means a brute-force algorithm would need to check 126 × 120 × 72 = ...
As a heuristic you could compute the square root of 12345 (about 111) and go on from there, searching for the nearest values to 123 and 45 which you can create with the remaining numbers. I did not implement this but it could be a more intelligent approach. Another example: sqrt(36189) -> About 190 Remaining numbers...
38,393,078
In a [science museum in Norway](https://nordnorsk.vitensenter.no/) I came across the following mathematical game: [![enter image description here](https://i.stack.imgur.com/aBECB.jpg)](https://i.stack.imgur.com/aBECB.jpg) The goal is to place the 10 digits from 0 to 9 such that the difference between the two products...
2016/07/15
[ "https://Stackoverflow.com/questions/38393078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50065/" ]
This one assumes a difference of zero is possible (although it could be adapted to finding the minimum/s by sorting — thank you, m69, for that idea — each group of 120 permutations and using binary search, adding a factor of `(log2 120)` to the time complexity): hash the multiples for all `10 choose 5 * 5!` combination...
As a heuristic you could compute the square root of 12345 (about 111) and go on from there, searching for the nearest values to 123 and 45 which you can create with the remaining numbers. I did not implement this but it could be a more intelligent approach. Another example: sqrt(36189) -> About 190 Remaining numbers...
38,393,078
In a [science museum in Norway](https://nordnorsk.vitensenter.no/) I came across the following mathematical game: [![enter image description here](https://i.stack.imgur.com/aBECB.jpg)](https://i.stack.imgur.com/aBECB.jpg) The goal is to place the 10 digits from 0 to 9 such that the difference between the two products...
2016/07/15
[ "https://Stackoverflow.com/questions/38393078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50065/" ]
If you assume there is a solution with difference 0, you can do via prime factors. If a*b - c*d = 0, then the prime factors of a*b and c*d must be the same. You can start the search by going through all 3-digit primes (there are only 143) and see whether they have a multiple that only contains disjunctive digits. If t...
12 seconds is too much for my taste. My C++ brute force attack took ~430ms without any heuristics or deep optimizations. Anyway you need to add some heuristics for example: **Bitwidth of multiplication result is around the sum of bitwidth of the operands.** So you need to test only the same bit width combinations of ...
38,393,078
In a [science museum in Norway](https://nordnorsk.vitensenter.no/) I came across the following mathematical game: [![enter image description here](https://i.stack.imgur.com/aBECB.jpg)](https://i.stack.imgur.com/aBECB.jpg) The goal is to place the 10 digits from 0 to 9 such that the difference between the two products...
2016/07/15
[ "https://Stackoverflow.com/questions/38393078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50065/" ]
If you assume there is a solution with difference 0, you can do via prime factors. If a*b - c*d = 0, then the prime factors of a*b and c*d must be the same. You can start the search by going through all 3-digit primes (there are only 143) and see whether they have a multiple that only contains disjunctive digits. If t...
There are 126 ways to split 10 digits into 2 sets of 5 without duplicates. For each set of 5 digits, there are 120 ways (permutations) to arrange them into the form `ab*cde`, or 72 ways if the group contains zero and a leading zero is not allowed. That means a brute-force algorithm would need to check 126 × 120 × 72 = ...
38,393,078
In a [science museum in Norway](https://nordnorsk.vitensenter.no/) I came across the following mathematical game: [![enter image description here](https://i.stack.imgur.com/aBECB.jpg)](https://i.stack.imgur.com/aBECB.jpg) The goal is to place the 10 digits from 0 to 9 such that the difference between the two products...
2016/07/15
[ "https://Stackoverflow.com/questions/38393078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50065/" ]
This one assumes a difference of zero is possible (although it could be adapted to finding the minimum/s by sorting — thank you, m69, for that idea — each group of 120 permutations and using binary search, adding a factor of `(log2 120)` to the time complexity): hash the multiples for all `10 choose 5 * 5!` combination...
12 seconds is too much for my taste. My C++ brute force attack took ~430ms without any heuristics or deep optimizations. Anyway you need to add some heuristics for example: **Bitwidth of multiplication result is around the sum of bitwidth of the operands.** So you need to test only the same bit width combinations of ...
38,393,078
In a [science museum in Norway](https://nordnorsk.vitensenter.no/) I came across the following mathematical game: [![enter image description here](https://i.stack.imgur.com/aBECB.jpg)](https://i.stack.imgur.com/aBECB.jpg) The goal is to place the 10 digits from 0 to 9 such that the difference between the two products...
2016/07/15
[ "https://Stackoverflow.com/questions/38393078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50065/" ]
This one assumes a difference of zero is possible (although it could be adapted to finding the minimum/s by sorting — thank you, m69, for that idea — each group of 120 permutations and using binary search, adding a factor of `(log2 120)` to the time complexity): hash the multiples for all `10 choose 5 * 5!` combination...
There are 126 ways to split 10 digits into 2 sets of 5 without duplicates. For each set of 5 digits, there are 120 ways (permutations) to arrange them into the form `ab*cde`, or 72 ways if the group contains zero and a leading zero is not allowed. That means a brute-force algorithm would need to check 126 × 120 × 72 = ...
55,254,710
I have a list of user `user_list=["5c471d607f","5c63e9e46a","5c63e9e44e"]` I am trying to insert it into mongodb to insert it inro mongodb my code is: ``` for i in range(0,len(user_list)): collection_4.update_one({'user_id':ObjectId(user_list[i])},{'$set':{'products': temp_list }},upsert=True) This is giving me e...
2019/03/20
[ "https://Stackoverflow.com/questions/55254710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11060688/" ]
You must have another error in your script somewhere. I can reproduce your error by doing the following: ``` from bson import ObjectId l = ['a', 'b', 'c'] l[ObjectId('5c91ec870000000000000000')] ``` gives: ``` TypeError: list indices must be integers or slices, not ObjectId ``` Are you sure you're not attempting ...
try this ``` for i in range(0,len(user_list)): myid = user_list[i] collection_4.update_one({'user_id':str(myid)},{'$set':{'products': temp_list }},upsert=True) ```
41,063,388
I have the following program that is analogous to my codebase. A FunctionState class which performs some sort of algorithm (potentially in multiple threads), and a Function class which controls how the FunctionState classes are used, and might do some algorithm setup/teardown operations. ``` #include <iostream> #inclu...
2016/12/09
[ "https://Stackoverflow.com/questions/41063388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2697007/" ]
What about a mixed solution based on type-erasure and CRTP? It follows a minimal, working example based on the snippet in the question: ``` #include <iostream> #include <vector> class PrintFunctionState; class AddFunctionState; class FunctionState; class Function { template<typename T> static FunctionStat...
`Function` has to have a non-template type as the return value of `NewFunctionState`, so you need an additional base class ``` class FunctionStateBase { virtual void ExecuteFunctionLotsAndLotsOfTimes() = 0; // No void RunState()! } template<typename T> class FunctionState { void ExecuteFunctionLotsAndLots...
41,063,388
I have the following program that is analogous to my codebase. A FunctionState class which performs some sort of algorithm (potentially in multiple threads), and a Function class which controls how the FunctionState classes are used, and might do some algorithm setup/teardown operations. ``` #include <iostream> #inclu...
2016/12/09
[ "https://Stackoverflow.com/questions/41063388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2697007/" ]
What about a mixed solution based on type-erasure and CRTP? It follows a minimal, working example based on the snippet in the question: ``` #include <iostream> #include <vector> class PrintFunctionState; class AddFunctionState; class FunctionState; class Function { template<typename T> static FunctionStat...
If I understand your problem correctly, this can be solved by using template chaining. Here's a rough example of how it works: ``` #include <iostream> /* Just make print invocations a little less cluttered for our purposes here. */ template <typename Type> void Show(Type value) { std::cout << value << std::en...
39,729
> > **Possible Duplicate:** > > [Which words in a title should be capitalized?](https://english.stackexchange.com/questions/14/which-words-in-a-title-should-be-capitalized) > > > If I'm using an idiom in a title then should all the elements of the phrase be capitalized or just the ones that are usually in capi...
2011/08/28
[ "https://english.stackexchange.com/questions/39729", "https://english.stackexchange.com", "https://english.stackexchange.com/users/12476/" ]
An option is *trying to carry water in a sieve*. As this [book](http://books.google.com/books?id=CFO5rVMg4pkC&pg=PA167&lpg=PA167&dq=trying+to+carry+water+with+a+sieve+meaning&source=bl&ots=scJy80bH4n&sig=_-mOgGUa7bihnbjYwnkedQGW3Ao&hl=en&ei=nMVZTufjK4nfiALwiOyiCQ&sa=X&oi=book_result&ct=result&resnum=4&sqi=2&ved=0CCwQ6A...
From the examples you give, i can think of a few: * misguided efforts * benighted attempts * foolish reasoning and so on. Pretty much anything you want to come up with will do, i think. As for idioms...perhaps * going about things in the wrong way * banging their heads against a wall", * flailing about in the dark
39,729
> > **Possible Duplicate:** > > [Which words in a title should be capitalized?](https://english.stackexchange.com/questions/14/which-words-in-a-title-should-be-capitalized) > > > If I'm using an idiom in a title then should all the elements of the phrase be capitalized or just the ones that are usually in capi...
2011/08/28
[ "https://english.stackexchange.com/questions/39729", "https://english.stackexchange.com", "https://english.stackexchange.com/users/12476/" ]
An option is *trying to carry water in a sieve*. As this [book](http://books.google.com/books?id=CFO5rVMg4pkC&pg=PA167&lpg=PA167&dq=trying+to+carry+water+with+a+sieve+meaning&source=bl&ots=scJy80bH4n&sig=_-mOgGUa7bihnbjYwnkedQGW3Ao&hl=en&ei=nMVZTufjK4nfiALwiOyiCQ&sa=X&oi=book_result&ct=result&resnum=4&sqi=2&ved=0CCwQ6A...
If the people concerned are fussing over details while ignoring the big picture, you might say they are [bikeshedding](http://en.wiktionary.org/wiki/bikeshedding): > > implies technical disputes over minor, marginal issues conducted while more serious ones are being overlooked. The implied image is of people arguing ...
39,729
> > **Possible Duplicate:** > > [Which words in a title should be capitalized?](https://english.stackexchange.com/questions/14/which-words-in-a-title-should-be-capitalized) > > > If I'm using an idiom in a title then should all the elements of the phrase be capitalized or just the ones that are usually in capi...
2011/08/28
[ "https://english.stackexchange.com/questions/39729", "https://english.stackexchange.com", "https://english.stackexchange.com/users/12476/" ]
An option is *trying to carry water in a sieve*. As this [book](http://books.google.com/books?id=CFO5rVMg4pkC&pg=PA167&lpg=PA167&dq=trying+to+carry+water+with+a+sieve+meaning&source=bl&ots=scJy80bH4n&sig=_-mOgGUa7bihnbjYwnkedQGW3Ao&hl=en&ei=nMVZTufjK4nfiALwiOyiCQ&sa=X&oi=book_result&ct=result&resnum=4&sqi=2&ved=0CCwQ6A...
succumbing to the sunk cost dilemma. Here's the link: <http://en.wikipedia.org/wiki/Sunk_cost_dilemma>
39,729
> > **Possible Duplicate:** > > [Which words in a title should be capitalized?](https://english.stackexchange.com/questions/14/which-words-in-a-title-should-be-capitalized) > > > If I'm using an idiom in a title then should all the elements of the phrase be capitalized or just the ones that are usually in capi...
2011/08/28
[ "https://english.stackexchange.com/questions/39729", "https://english.stackexchange.com", "https://english.stackexchange.com/users/12476/" ]
If the people concerned are fussing over details while ignoring the big picture, you might say they are [bikeshedding](http://en.wiktionary.org/wiki/bikeshedding): > > implies technical disputes over minor, marginal issues conducted while more serious ones are being overlooked. The implied image is of people arguing ...
From the examples you give, i can think of a few: * misguided efforts * benighted attempts * foolish reasoning and so on. Pretty much anything you want to come up with will do, i think. As for idioms...perhaps * going about things in the wrong way * banging their heads against a wall", * flailing about in the dark
39,729
> > **Possible Duplicate:** > > [Which words in a title should be capitalized?](https://english.stackexchange.com/questions/14/which-words-in-a-title-should-be-capitalized) > > > If I'm using an idiom in a title then should all the elements of the phrase be capitalized or just the ones that are usually in capi...
2011/08/28
[ "https://english.stackexchange.com/questions/39729", "https://english.stackexchange.com", "https://english.stackexchange.com/users/12476/" ]
If the people concerned are fussing over details while ignoring the big picture, you might say they are [bikeshedding](http://en.wiktionary.org/wiki/bikeshedding): > > implies technical disputes over minor, marginal issues conducted while more serious ones are being overlooked. The implied image is of people arguing ...
succumbing to the sunk cost dilemma. Here's the link: <http://en.wikipedia.org/wiki/Sunk_cost_dilemma>