qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
201,475
When I delete photos from my iPhone on My Photo Stream, will the same photos also be deleted on other devices connected to the same Apple ID automatically?
2015/08/22
[ "https://apple.stackexchange.com/questions/201475", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/142567/" ]
It depends - if the photo is out of the Photo Stream Window and your deletion included the message that "this photo will be deleted from all devices" then yes - one delete wipes it forever. If not, you may need to clean things up using iCloud.com and/or wiping your entire photo stream once you have the photos you wish to keep stored outside photo stream. You can review the basics on cleaning up Photo Stream here: * [How do you erase pictures from the Photo Stream album on an iPhone running iOS 5?](https://apple.stackexchange.com/questions/27398/) Things have changed since then and you have more options: If you have sensitive photos, you can add them all to a hidden album. That places them in a "no thumbnail" / no preview state. If that's not enough, look over your current Deleted Items online directly from the cloud using <https://www.icloud.com/#photos> That way, you know you are working with the authoritative version of all photos stored in iCloud. 1. Delete anything you don't need from deleted items to make sure your account is working and make it easy to permanently delete the offending images you want really purged. 2. Delete the images you want - follow up with purging them from Deleted Items. 3. Check your devices to make sure they followed the cloud deletion and don't have any stragglers. Pay attention to the message that arrives when you delete an item. If it says it will be deleted on all devices, you know that device is in sync. If not, you will have to patrol all devices. This is easier by going to Settings - <https://www.icloud.com/#settings> - and making a check list of all the devices that could have your Photos from the stream.
First, for your picture to arrive at other Apple devices you'll have to have either 1. iCloud Photo Library on or 2. My Photo Stream on with automatic upload on the device that took the picture or 3. A shared album and iCloud Photo Sharing on On the first case, deleting a picture from your Camera Roll will [delete it from any device with the same Apple ID](https://support.apple.com/en-us/HT204570). In the second scenario deleting a picture will pop up a message that warns you that > > The photo will also be deleted from Photo Stream on all your devices > > > ![delete photo stream warning](https://i.stack.imgur.com/gubpP.jpg) If you delete it, it will remove it from Photo Stream an all connected devices. But it **won't** remove it from the Camera Roll on iOS if someone already made a copy there, nor it will remove it from the library on [iPhoto](https://support.apple.com/kb/PH2712) if you have "Automatic Import" switched on or [Photos app on OS X](https://support.apple.com/en-us/HT201317) with "Copy items to the Photos library" on. Same on Windows with iCloud. The only way I can think it won't import to computers set up as described is that they were turned off or offline when the picture was deleted from Photo Stream, so there wasn't time for them to download and copy to the main library. I'm not sure if you need iPhoto or Photos open on OS X for the importing to happen. On the third case, removing a photo from a shared album will remove it from all associated devices, if you are the owner of the album. As suggested by @bmike, you should go check if the picture is available at icloud.com. It should look something like this: [![icloud.com home](https://i.stack.imgur.com/Kn2XQ.jpg)](https://i.stack.imgur.com/Kn2XQ.jpg) You have to enter this address in a computer, as an Apple iOS device won't let you enter. Click on the "Photos" icon and see what you can find there. Removing photos from there should remove it from associated devices, if they are setup as described before.
11,852,926
I would like to create a list with a string and an int value at the same time like follows: ``` @Html.ActionLink("Back to List", "IndexEvent", new { location = "location" }) ``` and ``` @Html.ActionLink("Back to List", "IndexEvent", new { locationID = 1 }) ``` It didn't work. I guess MVC controller didn't get the type difference of parameter. So, I had to make a new Action as "IndexEvenyByID" but it requires to have a new view. Since I wanted to keep it simple, is there any way to use same view with respect to different parameters?
2012/08/07
[ "https://Stackoverflow.com/questions/11852926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/137675/" ]
Try adding two optional parameters to the `IndexEvent` action like this: ``` public ActionResult IndexEvent(string location = "", int? locationID = null) ```
This should not require a new view or view model. You should have two actions as you have described, but the code could be as follows: **Controller** ``` public ActionResult GetEvents(string location){ var model = service.GetEventsByLocation(location); return View("Events", model); } public ActionResult GetEventsById(int id){ var model = service.GetEventsById(id); return View("Events", model); } ``` **Service** ``` public MyViewModel GetEventsByLocation(string location){ //do stuff to populate a view model of type MyViewModel using a string } public MyViewModel GetEventsById(int id){ //do stuff to populate a view model of type MyViewModel using an id } ``` Basically, if your View is going to use the same view model and the only thing that is changing is how you get that data, you can completely reuse the View.
11,852,926
I would like to create a list with a string and an int value at the same time like follows: ``` @Html.ActionLink("Back to List", "IndexEvent", new { location = "location" }) ``` and ``` @Html.ActionLink("Back to List", "IndexEvent", new { locationID = 1 }) ``` It didn't work. I guess MVC controller didn't get the type difference of parameter. So, I had to make a new Action as "IndexEvenyByID" but it requires to have a new view. Since I wanted to keep it simple, is there any way to use same view with respect to different parameters?
2012/08/07
[ "https://Stackoverflow.com/questions/11852926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/137675/" ]
Try adding two optional parameters to the `IndexEvent` action like this: ``` public ActionResult IndexEvent(string location = "", int? locationID = null) ```
If you really want to stick to a single action and multiple type, you could use a object parameter. ``` public ActionResult GetEvents(object location) { int locationID; if(int.TryParse(location, out locationID)) var model = service.GetEventsByID(locationID); else var model = service.GetEventsByLocation(location as string); return View("Events", model); } ``` Something like that (Not completly right but it gives you an idea). This, however, wouldn't really be a "clean" way to do it IMO. (Edit) But the 2 actions method is still by far preferable (eg. What happens if we're able to parse a location name into a int?)
11,852,926
I would like to create a list with a string and an int value at the same time like follows: ``` @Html.ActionLink("Back to List", "IndexEvent", new { location = "location" }) ``` and ``` @Html.ActionLink("Back to List", "IndexEvent", new { locationID = 1 }) ``` It didn't work. I guess MVC controller didn't get the type difference of parameter. So, I had to make a new Action as "IndexEvenyByID" but it requires to have a new view. Since I wanted to keep it simple, is there any way to use same view with respect to different parameters?
2012/08/07
[ "https://Stackoverflow.com/questions/11852926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/137675/" ]
This should not require a new view or view model. You should have two actions as you have described, but the code could be as follows: **Controller** ``` public ActionResult GetEvents(string location){ var model = service.GetEventsByLocation(location); return View("Events", model); } public ActionResult GetEventsById(int id){ var model = service.GetEventsById(id); return View("Events", model); } ``` **Service** ``` public MyViewModel GetEventsByLocation(string location){ //do stuff to populate a view model of type MyViewModel using a string } public MyViewModel GetEventsById(int id){ //do stuff to populate a view model of type MyViewModel using an id } ``` Basically, if your View is going to use the same view model and the only thing that is changing is how you get that data, you can completely reuse the View.
If you really want to stick to a single action and multiple type, you could use a object parameter. ``` public ActionResult GetEvents(object location) { int locationID; if(int.TryParse(location, out locationID)) var model = service.GetEventsByID(locationID); else var model = service.GetEventsByLocation(location as string); return View("Events", model); } ``` Something like that (Not completly right but it gives you an idea). This, however, wouldn't really be a "clean" way to do it IMO. (Edit) But the 2 actions method is still by far preferable (eg. What happens if we're able to parse a location name into a int?)
4,522,237
I am writing a function in R that will evaluate the fit of a model, but each model takes the same arguments. How can I avoid repeating the same argument to each call to a model? It is probably more clear here, where the arguments ``` data=data, na.action = na.exclude, subset = block == site) ``` Are repeated. ``` modelfit <- function(order, response, predictor, site) { if(order == 0) { m <- lm(response ~ 1, data=data, na.action = na.exclude, subset = block == site) } else if (is.numeric(order)) { m <- lm(response ~ poly(predictor, order), data=data, na.action = na.exclude, subset = block == site) } else if (order == 'monod') { x<-predictor m <- nls(response ~ a*x/(b+x), start = list(a=1, b=1), data=data, na.action = na.exclude, subset = block == site) } else if (order == 'log') { m <- lm(response ~ poly(log(predictor), 1), data=data, na.action = na.exclude, subset = block == site) } AIC(m) } ``` Additional suggestions for better approaches to this question always appreciated.
2010/12/23
[ "https://Stackoverflow.com/questions/4522237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/513006/" ]
You can use the `...` idiom to do this. You include `...` in the argument definition of your function and then within the `lm()` calls include `...` as an extra argument. The `...` effectively is a placeholder for all the extra arguments you wish to pass. Here is a (not tested) modification of your function that employs this approach: ``` modelfit <- function(order, response, predictor, site, ...) { if(order == 0) { m <- lm(response ~ 1, ...) } else if (is.numeric(order)) { m <- lm(response ~ poly(predictor, order), ...) } else if (order == 'monod') { x<-predictor m <- nls(response ~ a*x/(b+x), start = list(a=1, b=1), ...) } else if (order == 'log') { m <- lm(response ~ poly(log(predictor), 1), ...) } AIC(m) } ``` You then call this function and provide the repeated arguments in place of `...`: ``` with(myData, modelfit(2, myResponse, myPredictor, mySite, data = myData, na.action = na.exclude, subset = block == mySite)) ``` where `myResponse`, `myPredictor` and `mySite` are the variables you want to use that **exist** in your `myData` data frame.
I would like to clarify a point in Gavin's answer with a simplified example: Here is a dataframe `d`: ``` d <- data.frame(x1 = c(1, 1, 1, 1, 2, 2, 2, 2), x2 = c(1, 1, 1, 2, 1, 1, 1, 2), y = c(1, 1, 3, 4, 5, 6, 7, 8)) ``` Here is a function: ``` mf <- function(response, predictor, ...) { lm(response~predictor, ...) } ``` Note that ``` mf(d$y, d$x1, subset = d$x2 == 1, data = d) ``` works, but ``` mf(y, x1, subset = x2 == 1, data = d) ``` does not.
19,623,484
This is for a project, most of it is finished, but I need to be able to count the amount of words there are in a String or file. I have to use a nested for loop, and I have to use a String containing the delimiters for a word. Right now this is what I have: ``` public static int wordCounter(String text) { String WORDS_GROUP = ",\n "; String text= "This is my sample text"; int wordCount=0; for(int i=0; i<text.length(); i++){ for(int j=0; j<WORDS_GROUP.length(); j++){ if(text.charAt(i)==WORDS_GROUP.charAt(j)){ wordCount++; } } } } ```
2013/10/27
[ "https://Stackoverflow.com/questions/19623484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2924444/" ]
I have experienced same problem with you. What i did is added a javascript validation to the Mailchimp embed code. This is the example of the code. I was using radio buttons. I'll just remove the form action button for personal reasons ``` <!-- Begin MailChimp Signup Form --> <link href="//cdn-images.mailchimp.com/embedcode/classic-081711.css" rel="stylesheet" type="text/css"> <style type="text/css"> #mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; width:650px;margin:auto;} .mc-field-group{width:50% !important;margin:auto;} .mc-field-group.input-group{width:96% !important;margin:auto;} #mc-embedded-subscribe{ margin: auto; width: 150px !important; height: 30px !important; font-size: 15px !important; background: #eb593c !important; position: relative !important; color: #fff !important; margin-left: 38% !important; } /* Add your own MailChimp form style overrides in your site stylesheet or in this style block. We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */ </style> <div id="mc_embed_signup"> <form action="" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> <div class="indicates-required"><span class="asterisk">*</span> indicates required</div> <div class="mc-field-group"> <label for="mce-EMAIL">Email Address <span class="asterisk">*</span> </label> <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL"> </div> <div class="mc-field-group"> <label for="mce-FNAME">First Name </label> <input type="text" value="" name="FNAME" class="" id="mce-FNAME"> </div> <div class="mc-field-group input-group"> <strong>How Often Would You Like to Hear From Us: <span class="asterisk">*</span></strong> <ul><li><input type="radio" value="4" name="group[10709]" id="mce-group[10709]-10709-0"><label for="mce-group[10709]-10709-0">Somewhat Weekly: THRIVING IS THE NEW YOU Blog Posts sent via Email</label></li> <li><input type="radio" value="8" name="group[10709]" id="mce-group[10709]-10709-1"><label for="mce-group[10709]-10709-1">Monthly Vibrancy Roundup: It's like a E-Newsletter but way groovier.</label></li> </ul> </div> <div id="mce-responses" class="clear"> <div class="response" id="mce-error-response" style="display:none"></div> <div class="response" id="mce-success-response" style="display:none"></div> </div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups--> <div style="position: absolute; left: -5000px;"><input type="text" name="b_ef38bee7ba91bb0815db87917_22d8d62dc8" tabindex="-1" value=""></div> <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"> </form> <script type="text/javascript"> var forms = document.getElementById('mc-embedded-subscribe-form'); try { forms.addEventListener("submit", function(event) { var off_payment_method = document.getElementsByName('group[10709]'); //this is the name of the radio buttons var email = document.getElementById('mce-EMAIL');//email field var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(email.value)) { alert('Please provide a valid email address'); event.preventDefault(); return false; } var ischecked_method = false; for ( var i = 0; i < off_payment_method.length; i++) { if(off_payment_method[i].checked) { ischecked_method = true; } } if(!ischecked_method){ alert("Please choose from How Often Would You Like to Hear From Us:"); event.preventDefault(); return false; }else{ return true; } }, false); } catch(e) { forms.attachEvent("onsubmit", function(event) { var off_payment_method = document.getElementsByName('group[10709]'); //this is the name of the radio buttons var email = document.getElementById('mce-EMAIL');//email field var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(email.value)) { alert('Please provide a valid email address'); event.preventDefault(); return false; } var ischecked_method = false; for ( var i = 0; i < off_payment_method.length; i++) { if(off_payment_method[i].checked) { ischecked_method = true; } } if(!ischecked_method){ alert("Please choose from How Often Would You Like to Hear From Us:"); event.preventDefault(); return false; }else{ return true; } }); //Internet Explorer 8- } </script> </div> <!--End mc_embed_signup--> ```
Have you tried adding *class="required"* to each group field in the advanced editor? When I look at my required fields, they are declared with this class (except the email, which seems to have a special "email required" class: ``` <div class="mc-field-group"><label for="mce-FNAME">First Name <span class="asterisk">*</span> </label> <input class="required" id="mce-FNAME" type="text" name="FNAME" value="" /></div> <div class="mc-field-group"><label for="mce-LNAME">Last Name </label> <input id="mce-LNAME" type="text" name="LNAME" value="" /></div> ``` In this example, taken from one of my forms (hosted on a WP page), FNAME is required, but LNAME is not.
149,293
I'm having trouble distinguishing between the three. What are the major differences between these types?
2017/01/04
[ "https://scifi.stackexchange.com/questions/149293", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/76464/" ]
Let's break it down. -------------------- In official canon, there are no **[Light Sith](https://starwars.fandom.com/wiki/Light_Sith)**. This is because [the very existence of the Sith is an affront to the Force, due to the way they use it.](https://scifi.stackexchange.com/questions/23906/how-was-the-chosen-one-meant-to-bring-balance-to-the-force) In Legends (EU) canon, however (specifically in the Star Wars: Old Republic MMO), Light Sith are adherents to the Sith order who utilize the Light Side of the Force (and perform acts accordingly). Due to their different approach to things, they are labeled renegades and hunted down by the other Sith. The exception here is the player character in The Old Republic, who can manage to play off their actions as pure pragmatism. **[Grey Jedi](https://starwars.fandom.com/wiki/Gray_Jedi)** is a Legends canon term referring to trained Force sensitives who could potentially use both the Light and Dark Sides of the Force, but more importantly worked toward personal ethics rather than those established by the Sith or the Jedi order. Originally, the term was specifically meant for Jedi who left the order due to ideological differences. In the years that followed, this term started also being used for those trained Force sensitives from orders unrelated to the Jedi. **[Dark Jedi](https://starwars.fandom.com/wiki/Dark_Jedi)** use the Dark Side of the Force, but are not Sith Lords. In present canon, that includes trained Force sensitives from outside the Jedi order, such as Asajj Ventress. In the Legends canon, Dark Jedi reject the Light Side of the Force entirely; they hold an axiomatic position which rejects the Light in favor of the Dark. The first Dark Jedi started the order known as the Dark Lords of the Sith, which was related ideologically (and, in some cases, genetically) to the Sith Empire. ![Picture for completeness](https://orig10.deviantart.net/90cd/f/2014/126/e/e/star_wars_dark_side___light_side_wallpaper_by_soulreaper919-d7hfqch.jpg)
Its quite elementary. Think of it this way - the Jedi Order did NOT always exist. In SW Canon, the Dark Siders (eventually the Sith) branched off from the Order during the early years of the Jedi. The Force however, like a Universal Law, has and will always be in existence and is the original source (or mojo sauce, if you prefer ;-) as described by Master Yoda. It is everywhere and in all things, which means it encompasses BOTH good & bad, light & dark sides. George Lucas basically copy-pasted some ancient Eastern Mystical traditions wherein all duality (or dualistic conceptions) is an illusion. The Jedi is merely a structured organization, for better or worse. Its identity as a coherent hierarchy comes & goes or be called by different names (by different species) in the long arc of SW Galactic history. By convention, any being "trained" (no definition of for how long) by this group implies he/she becomes a "Jedi". Luke becomes a "Jedi" because he got what little training from Master Yoda even though he didn't actually "finish" his training course work. Lol. Same with many of the Sith "apprenticeships" whereby many of their "Rule of Two" often ends prematurely. Furthermore in official SW movies, there were non-Jedi and non-Sith trained beings who had naturally-acquired "Force" powers. E.g.) the "Broom Boy". These could probably be called "Grey Force Users" but non-Jedi, and how they utilize their gifts will determine whether they lean more on the "Light" or "Dark" spectrum. Therefore, there is definitely "Grey Jedi" and every shade in-between both ends, just as there is every shade of lightsaber colors. Strictly speaking and in actuality, the definitions of "color" itself is also merely by convention, since all colors blends into each other seamlessly in the EM spectrum. There is really NO non-arbitrary marker to say Blue starts at this exact wavelength/frequency or Green ends at some other point on.
73,615,599
Trying to setup bindless textures, whenever I call `glGetTextureHandleARB()` it results in the OpenGL error `GL_INVALID_OPERATION`. [This page](https://registry.khronos.org/OpenGL/extensions/ARB/ARB_bindless_texture.txt) says this is because my texture object specified is not complete. After spending (too) much time trying to figure out texture completeness [here](https://www.khronos.org/opengl/wiki/Texture#Texture_completeness) (and trying things with `glTexParameters()` to tell OpenGL that I don't have mipmaps), I don't see what I am doing wrong before the call and would appreciate some help. **texture.c**: ``` #include "texture.h" #include <glad/glad.h> #define STB_IMAGE_IMPLEMENTATION #include <stb/stb_image.h> struct Texture texture_create_bindless_texture(const char *path) { struct Texture texture; int components; void *data = stbi_load(path, &texture.width, &texture.height, &components, 4); glGenTextures(1, &texture.id); glBindTexture(GL_TEXTURE_2D, texture.id); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.width, texture.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); texture.bindless_handle = glGetTextureHandleARB(texture.id); glMakeTextureHandleResidentARB(texture.bindless_handle); glBindTexture(GL_TEXTURE_2D, 0); stbi_image_free(data); return texture; } ``` **texture.h**: ``` #ifndef TEXTURE_INCLUDED #define TEXTURE_INCLUDED #include <glad/glad.h> struct Texture { int width; int height; GLuint id; GLuint64 bindless_handle; }; struct Texture texture_create_bindless_texture(const char *path); #endif ```
2022/09/06
[ "https://Stackoverflow.com/questions/73615599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19371708/" ]
I don't think its a completeness issue; Try adding this code: ```cs GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToBorderArb); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToBorderArb); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureBorderColor, new float[4]); ``` (This is copied from my C# project, but it should be ez to translate) --- This might work because bindless textures must have either one of these 4 border colors: (0,0,0,0), (0,0,0,1), (1,1,1,0), or (1,1,1,1) according to [documentation](https://registry.khronos.org/OpenGL/extensions/ARB/ARB_bindless_texture.txt). (I'd love to link the specific paragraph but I can't, so just ctrl+f and search for (0,0,0,0) to find the relevant paragraph)
By mistake I gave `stbi_load()` a path that didn't exist, and neglected to add a check if the pointer returned was `NULL` (or if the path existed). I guess somewhere OpenGL didn't like that, but only told me about it when I tried to call `glGetTextureHandleARB()`. At least now I learned my lesson to check stuff passed to me by someone else :)
7,687,062
I have a list of strings , I browse it and count number of "x" strings as below but the count doesn't print me the expected value: ``` ArrayList<Integer> list = new ArrayList<Integer>(); List<String> strings = table.getValue(); //this gives ["y","z","d","x","x","d"] int count = 0; for (int i = 0; i < strings.size(); i++) { if ((strings.get(i) == "x")) { count++; list.add(count); } } System.out.println(list); ``` this gives `[]` it should be 2 as I have 2 occurrences of "x"
2011/10/07
[ "https://Stackoverflow.com/questions/7687062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928859/" ]
You should compare strings using `equals` instead of `==`. I.e. change ``` if ((list.get(i) == "x")) ^^ ``` to ``` if ((list.get(i).equals("x"))) ^^^^^^ ``` `==` compares references, while `.equals` compares actual content of strings. --- **Related questions:** * [How do I compare strings in Java?](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) * [Java Compare Strings](https://stackoverflow.com/questions/6730907/java-compare-strings) * [Comparing strings in Java](https://stackoverflow.com/questions/4700357/comparing-strings-in-java) * <https://stackoverflow.com/questions/5116595/compare-two-strings-java> * [What's the quickest way to compare strings in Java?](https://stackoverflow.com/questions/3805601/whats-the-quickest-way-to-compare-strings-in-java) * [String Comparison in Java](https://stackoverflow.com/questions/4064633/string-comparison-in-java) * [Java String.equals versus ==](https://stackoverflow.com/questions/767372/java-string-equals-versus) * [How do I make my string comparison case insensitive?](https://stackoverflow.com/questions/2220400/compare-two-strings-in-java) * [comparing strings in java](https://stackoverflow.com/questions/5505981/comparing-strings-in-java) * [Strings don't seem to be equal in Java on Android, even though they print the same](https://stackoverflow.com/questions/2704956/strings-dont-seem-to-be-equal-in-java-on-android-even-though-they-print-the-sam) * [Comparing java Strings with ==](https://stackoverflow.com/questions/6940521/comparing-java-strings-with) * [How can I compare String value with ArrayList of String type in Java?](https://stackoverflow.com/questions/6607888/how-can-i-compare-string-value-with-arraylist-of-string-type-in-java) * [How can I compare two strings in java and define which of them is smaller than the other alphabetically?](https://stackoverflow.com/questions/5153496/how-can-i-compare-two-strings-in-java-and-define-which-of-them-is-smaller-than-th)
You need to use: ``` list.get(i).equals("x"); ``` != / == only checks the reference. I don't knwo why you're using a ArrayList to count. You would probably something like that: ``` int count = 0; for (String s : table.getValue()) { if (s.equals("x")) { count++; } } System.out.println( count ); ```
7,687,062
I have a list of strings , I browse it and count number of "x" strings as below but the count doesn't print me the expected value: ``` ArrayList<Integer> list = new ArrayList<Integer>(); List<String> strings = table.getValue(); //this gives ["y","z","d","x","x","d"] int count = 0; for (int i = 0; i < strings.size(); i++) { if ((strings.get(i) == "x")) { count++; list.add(count); } } System.out.println(list); ``` this gives `[]` it should be 2 as I have 2 occurrences of "x"
2011/10/07
[ "https://Stackoverflow.com/questions/7687062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928859/" ]
There already is an [existing method](http://download.oracle.com/javase/6/docs/api/java/util/Collections.html#frequency%28java.util.Collection,%20java.lang.Object%29) for this: ``` Collections.frequency(collection, object); ``` In your case, use like this (replace all of your posted code with this): ``` System.out.println(java.util.Collections.frequency(table.getValue(), "x")); ```
You should compare strings using `equals` instead of `==`. I.e. change ``` if ((list.get(i) == "x")) ^^ ``` to ``` if ((list.get(i).equals("x"))) ^^^^^^ ``` `==` compares references, while `.equals` compares actual content of strings. --- **Related questions:** * [How do I compare strings in Java?](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) * [Java Compare Strings](https://stackoverflow.com/questions/6730907/java-compare-strings) * [Comparing strings in Java](https://stackoverflow.com/questions/4700357/comparing-strings-in-java) * <https://stackoverflow.com/questions/5116595/compare-two-strings-java> * [What's the quickest way to compare strings in Java?](https://stackoverflow.com/questions/3805601/whats-the-quickest-way-to-compare-strings-in-java) * [String Comparison in Java](https://stackoverflow.com/questions/4064633/string-comparison-in-java) * [Java String.equals versus ==](https://stackoverflow.com/questions/767372/java-string-equals-versus) * [How do I make my string comparison case insensitive?](https://stackoverflow.com/questions/2220400/compare-two-strings-in-java) * [comparing strings in java](https://stackoverflow.com/questions/5505981/comparing-strings-in-java) * [Strings don't seem to be equal in Java on Android, even though they print the same](https://stackoverflow.com/questions/2704956/strings-dont-seem-to-be-equal-in-java-on-android-even-though-they-print-the-sam) * [Comparing java Strings with ==](https://stackoverflow.com/questions/6940521/comparing-java-strings-with) * [How can I compare String value with ArrayList of String type in Java?](https://stackoverflow.com/questions/6607888/how-can-i-compare-string-value-with-arraylist-of-string-type-in-java) * [How can I compare two strings in java and define which of them is smaller than the other alphabetically?](https://stackoverflow.com/questions/5153496/how-can-i-compare-two-strings-in-java-and-define-which-of-them-is-smaller-than-th)
7,687,062
I have a list of strings , I browse it and count number of "x" strings as below but the count doesn't print me the expected value: ``` ArrayList<Integer> list = new ArrayList<Integer>(); List<String> strings = table.getValue(); //this gives ["y","z","d","x","x","d"] int count = 0; for (int i = 0; i < strings.size(); i++) { if ((strings.get(i) == "x")) { count++; list.add(count); } } System.out.println(list); ``` this gives `[]` it should be 2 as I have 2 occurrences of "x"
2011/10/07
[ "https://Stackoverflow.com/questions/7687062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928859/" ]
You should compare strings using `equals` instead of `==`. I.e. change ``` if ((list.get(i) == "x")) ^^ ``` to ``` if ((list.get(i).equals("x"))) ^^^^^^ ``` `==` compares references, while `.equals` compares actual content of strings. --- **Related questions:** * [How do I compare strings in Java?](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) * [Java Compare Strings](https://stackoverflow.com/questions/6730907/java-compare-strings) * [Comparing strings in Java](https://stackoverflow.com/questions/4700357/comparing-strings-in-java) * <https://stackoverflow.com/questions/5116595/compare-two-strings-java> * [What's the quickest way to compare strings in Java?](https://stackoverflow.com/questions/3805601/whats-the-quickest-way-to-compare-strings-in-java) * [String Comparison in Java](https://stackoverflow.com/questions/4064633/string-comparison-in-java) * [Java String.equals versus ==](https://stackoverflow.com/questions/767372/java-string-equals-versus) * [How do I make my string comparison case insensitive?](https://stackoverflow.com/questions/2220400/compare-two-strings-in-java) * [comparing strings in java](https://stackoverflow.com/questions/5505981/comparing-strings-in-java) * [Strings don't seem to be equal in Java on Android, even though they print the same](https://stackoverflow.com/questions/2704956/strings-dont-seem-to-be-equal-in-java-on-android-even-though-they-print-the-sam) * [Comparing java Strings with ==](https://stackoverflow.com/questions/6940521/comparing-java-strings-with) * [How can I compare String value with ArrayList of String type in Java?](https://stackoverflow.com/questions/6607888/how-can-i-compare-string-value-with-arraylist-of-string-type-in-java) * [How can I compare two strings in java and define which of them is smaller than the other alphabetically?](https://stackoverflow.com/questions/5153496/how-can-i-compare-two-strings-in-java-and-define-which-of-them-is-smaller-than-th)
For String you should use equals method. ``` int ct = 0; for (String str : table.getValue()) { if ("x".equals(str)) { // "x".equals to avoid NullPoniterException count++; } } System.out.println(ct); ```
7,687,062
I have a list of strings , I browse it and count number of "x" strings as below but the count doesn't print me the expected value: ``` ArrayList<Integer> list = new ArrayList<Integer>(); List<String> strings = table.getValue(); //this gives ["y","z","d","x","x","d"] int count = 0; for (int i = 0; i < strings.size(); i++) { if ((strings.get(i) == "x")) { count++; list.add(count); } } System.out.println(list); ``` this gives `[]` it should be 2 as I have 2 occurrences of "x"
2011/10/07
[ "https://Stackoverflow.com/questions/7687062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928859/" ]
You should compare strings using `equals` instead of `==`. I.e. change ``` if ((list.get(i) == "x")) ^^ ``` to ``` if ((list.get(i).equals("x"))) ^^^^^^ ``` `==` compares references, while `.equals` compares actual content of strings. --- **Related questions:** * [How do I compare strings in Java?](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) * [Java Compare Strings](https://stackoverflow.com/questions/6730907/java-compare-strings) * [Comparing strings in Java](https://stackoverflow.com/questions/4700357/comparing-strings-in-java) * <https://stackoverflow.com/questions/5116595/compare-two-strings-java> * [What's the quickest way to compare strings in Java?](https://stackoverflow.com/questions/3805601/whats-the-quickest-way-to-compare-strings-in-java) * [String Comparison in Java](https://stackoverflow.com/questions/4064633/string-comparison-in-java) * [Java String.equals versus ==](https://stackoverflow.com/questions/767372/java-string-equals-versus) * [How do I make my string comparison case insensitive?](https://stackoverflow.com/questions/2220400/compare-two-strings-in-java) * [comparing strings in java](https://stackoverflow.com/questions/5505981/comparing-strings-in-java) * [Strings don't seem to be equal in Java on Android, even though they print the same](https://stackoverflow.com/questions/2704956/strings-dont-seem-to-be-equal-in-java-on-android-even-though-they-print-the-sam) * [Comparing java Strings with ==](https://stackoverflow.com/questions/6940521/comparing-java-strings-with) * [How can I compare String value with ArrayList of String type in Java?](https://stackoverflow.com/questions/6607888/how-can-i-compare-string-value-with-arraylist-of-string-type-in-java) * [How can I compare two strings in java and define which of them is smaller than the other alphabetically?](https://stackoverflow.com/questions/5153496/how-can-i-compare-two-strings-in-java-and-define-which-of-them-is-smaller-than-th)
Since you are looking for both the elements as well as the size, I would recommend Guava's [Iterables.filter](http://docs.guava-libraries.googlecode.com/git-history/v10.0/javadoc/com/google/common/collect/Iterables.html#filter%28java.lang.Iterable,%20com.google.common.base.Predicate%29) method ``` List<String> filtered = Lists.newArrayList( Iterables.filter(myList, Predicates.equalTo("x"))); int count = filtered.size(); ``` But as everyone else has pointed out, the reason your code is not working is the `==`
7,687,062
I have a list of strings , I browse it and count number of "x" strings as below but the count doesn't print me the expected value: ``` ArrayList<Integer> list = new ArrayList<Integer>(); List<String> strings = table.getValue(); //this gives ["y","z","d","x","x","d"] int count = 0; for (int i = 0; i < strings.size(); i++) { if ((strings.get(i) == "x")) { count++; list.add(count); } } System.out.println(list); ``` this gives `[]` it should be 2 as I have 2 occurrences of "x"
2011/10/07
[ "https://Stackoverflow.com/questions/7687062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928859/" ]
There already is an [existing method](http://download.oracle.com/javase/6/docs/api/java/util/Collections.html#frequency%28java.util.Collection,%20java.lang.Object%29) for this: ``` Collections.frequency(collection, object); ``` In your case, use like this (replace all of your posted code with this): ``` System.out.println(java.util.Collections.frequency(table.getValue(), "x")); ```
You need to use: ``` list.get(i).equals("x"); ``` != / == only checks the reference. I don't knwo why you're using a ArrayList to count. You would probably something like that: ``` int count = 0; for (String s : table.getValue()) { if (s.equals("x")) { count++; } } System.out.println( count ); ```
7,687,062
I have a list of strings , I browse it and count number of "x" strings as below but the count doesn't print me the expected value: ``` ArrayList<Integer> list = new ArrayList<Integer>(); List<String> strings = table.getValue(); //this gives ["y","z","d","x","x","d"] int count = 0; for (int i = 0; i < strings.size(); i++) { if ((strings.get(i) == "x")) { count++; list.add(count); } } System.out.println(list); ``` this gives `[]` it should be 2 as I have 2 occurrences of "x"
2011/10/07
[ "https://Stackoverflow.com/questions/7687062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928859/" ]
You need to use: ``` list.get(i).equals("x"); ``` != / == only checks the reference. I don't knwo why you're using a ArrayList to count. You would probably something like that: ``` int count = 0; for (String s : table.getValue()) { if (s.equals("x")) { count++; } } System.out.println( count ); ```
For String you should use equals method. ``` int ct = 0; for (String str : table.getValue()) { if ("x".equals(str)) { // "x".equals to avoid NullPoniterException count++; } } System.out.println(ct); ```
7,687,062
I have a list of strings , I browse it and count number of "x" strings as below but the count doesn't print me the expected value: ``` ArrayList<Integer> list = new ArrayList<Integer>(); List<String> strings = table.getValue(); //this gives ["y","z","d","x","x","d"] int count = 0; for (int i = 0; i < strings.size(); i++) { if ((strings.get(i) == "x")) { count++; list.add(count); } } System.out.println(list); ``` this gives `[]` it should be 2 as I have 2 occurrences of "x"
2011/10/07
[ "https://Stackoverflow.com/questions/7687062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928859/" ]
You need to use: ``` list.get(i).equals("x"); ``` != / == only checks the reference. I don't knwo why you're using a ArrayList to count. You would probably something like that: ``` int count = 0; for (String s : table.getValue()) { if (s.equals("x")) { count++; } } System.out.println( count ); ```
Since you are looking for both the elements as well as the size, I would recommend Guava's [Iterables.filter](http://docs.guava-libraries.googlecode.com/git-history/v10.0/javadoc/com/google/common/collect/Iterables.html#filter%28java.lang.Iterable,%20com.google.common.base.Predicate%29) method ``` List<String> filtered = Lists.newArrayList( Iterables.filter(myList, Predicates.equalTo("x"))); int count = filtered.size(); ``` But as everyone else has pointed out, the reason your code is not working is the `==`
7,687,062
I have a list of strings , I browse it and count number of "x" strings as below but the count doesn't print me the expected value: ``` ArrayList<Integer> list = new ArrayList<Integer>(); List<String> strings = table.getValue(); //this gives ["y","z","d","x","x","d"] int count = 0; for (int i = 0; i < strings.size(); i++) { if ((strings.get(i) == "x")) { count++; list.add(count); } } System.out.println(list); ``` this gives `[]` it should be 2 as I have 2 occurrences of "x"
2011/10/07
[ "https://Stackoverflow.com/questions/7687062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928859/" ]
There already is an [existing method](http://download.oracle.com/javase/6/docs/api/java/util/Collections.html#frequency%28java.util.Collection,%20java.lang.Object%29) for this: ``` Collections.frequency(collection, object); ``` In your case, use like this (replace all of your posted code with this): ``` System.out.println(java.util.Collections.frequency(table.getValue(), "x")); ```
For String you should use equals method. ``` int ct = 0; for (String str : table.getValue()) { if ("x".equals(str)) { // "x".equals to avoid NullPoniterException count++; } } System.out.println(ct); ```
7,687,062
I have a list of strings , I browse it and count number of "x" strings as below but the count doesn't print me the expected value: ``` ArrayList<Integer> list = new ArrayList<Integer>(); List<String> strings = table.getValue(); //this gives ["y","z","d","x","x","d"] int count = 0; for (int i = 0; i < strings.size(); i++) { if ((strings.get(i) == "x")) { count++; list.add(count); } } System.out.println(list); ``` this gives `[]` it should be 2 as I have 2 occurrences of "x"
2011/10/07
[ "https://Stackoverflow.com/questions/7687062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928859/" ]
There already is an [existing method](http://download.oracle.com/javase/6/docs/api/java/util/Collections.html#frequency%28java.util.Collection,%20java.lang.Object%29) for this: ``` Collections.frequency(collection, object); ``` In your case, use like this (replace all of your posted code with this): ``` System.out.println(java.util.Collections.frequency(table.getValue(), "x")); ```
Since you are looking for both the elements as well as the size, I would recommend Guava's [Iterables.filter](http://docs.guava-libraries.googlecode.com/git-history/v10.0/javadoc/com/google/common/collect/Iterables.html#filter%28java.lang.Iterable,%20com.google.common.base.Predicate%29) method ``` List<String> filtered = Lists.newArrayList( Iterables.filter(myList, Predicates.equalTo("x"))); int count = filtered.size(); ``` But as everyone else has pointed out, the reason your code is not working is the `==`
8,973,563
Using VS2008, why is this OK (not allowed to use 2010). ``` void assert(int exp, int actual) {if (exp!=actual) printf("assert failed\n");} void assert(unsigned int exp, unsigned int actual) {if (exp!=actual) printf("assert failed\n");} ``` But this is ambiguous. ``` void assert(__int64 exp, __int64 actual) {if (exp!=actual) printf("assert failed\n");} void assert(unsigned __int64 exp, unsigned __int64 actual) {if (exp!=actual) printf("assert failed\n");} ``` Sample error text ``` d:\my documents\visual studio 2008\projects\classtest\classtest\classtest.cpp(31) : error C2668: 'assert' : ambiguous call to overloaded function d:\my documents\visual studio 2008\projects\classtest\classtest\classtest.cpp(12): could be 'void assert(unsigned __int64,unsigned __int64)' d:\my documents\visual studio 2008\projects\classtest\classtest\classtest.cpp(10): or 'void assert(__int64,__int64)' while trying to match the argument list '(int, int)' ``` It only gets ambiguous with regards to the 'unsigned' overload. Having and "int" version and an "\_\_int64" version is not ambiguous.
2012/01/23
[ "https://Stackoverflow.com/questions/8973563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191399/" ]
Your code is actually using int and int as the parameters. In the first case it has an exact match. In the second case it does not, and it treats int->uint64 and int->int64 as equally valid conversions so it doesn't know which one to pick.
You're getting this because `int` can be implicitly converted to both `__int64` **and** `unsigned __int64`. The following also doesn't compile: ``` void assert(__int64 exp, __int64 actual) {if (exp!=actual) printf("assert failed\n");} void assert(unsigned __int64 exp, unsigned __int64 actual){if (exp!=actual) printf("assert failed\n");} int x = 0; assert(x,x); ``` But if `x` is of type `__int64` the ambiguity is solved. ``` void assert(__int64 exp, __int64 actual) {if (exp!=actual) printf("assert failed\n");} void assert(unsigned __int64 exp, unsigned __int64 actual){if (exp!=actual) printf("assert failed\n");} __int64 x = 0; assert(x,x);\ //compiles ```
18,177,082
so I think this should be really simple but I am not sure what I am missing. I have a DIV that I want to fade out, then change some text, and then fade back in. It sort of works, but it does the text update then the fade out and fade in, although I thought I had the chaining correct. Here is the basic code ``` <div id="box" style="width:300px;height:200px;background-color:yellow"> <span id="game">Game 1</span> <br/> <a href="javaScript:ChangeGame()">Next Game</a> </div> window.game = 1; window.ChangeGame = function () { $("#box") .fadeOut(1000, nextGame()).fadeIn(); } window.nextGame = function() { $("#game").text("Game " + game++); } ``` and here is a jsFiddle that shows the problem <http://jsfiddle.net/mdq6f/4/> Thanks for your help kind folk
2013/08/11
[ "https://Stackoverflow.com/questions/18177082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1450391/" ]
Change `nextGame()` to `nextGame`: ``` $("#box") .fadeOut(1000, nextGame).fadeIn(); ``` You were calling the function directly instead of just *pointing* to it. In case you need to provide some arguments to `nextGame` you need to wrap it into an anonomous function: ``` $("#box") .fadeOut(1000, function() { nextGame(/* enter arguments as you wish */); }) .fadeIn(); ```
Use ``` $("#box").fadeOut(1000, nextGame).fadeIn(); ``` instead of ``` $("#box").fadeOut(1000, nextGame()).fadeIn(); ``` using `nextGame()` in callback calls the function immediately on executing the above line, rather than passing on the function to be called after fadeIn is complete.
18,177,082
so I think this should be really simple but I am not sure what I am missing. I have a DIV that I want to fade out, then change some text, and then fade back in. It sort of works, but it does the text update then the fade out and fade in, although I thought I had the chaining correct. Here is the basic code ``` <div id="box" style="width:300px;height:200px;background-color:yellow"> <span id="game">Game 1</span> <br/> <a href="javaScript:ChangeGame()">Next Game</a> </div> window.game = 1; window.ChangeGame = function () { $("#box") .fadeOut(1000, nextGame()).fadeIn(); } window.nextGame = function() { $("#game").text("Game " + game++); } ``` and here is a jsFiddle that shows the problem <http://jsfiddle.net/mdq6f/4/> Thanks for your help kind folk
2013/08/11
[ "https://Stackoverflow.com/questions/18177082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1450391/" ]
Change `nextGame()` to `nextGame`: ``` $("#box") .fadeOut(1000, nextGame).fadeIn(); ``` You were calling the function directly instead of just *pointing* to it. In case you need to provide some arguments to `nextGame` you need to wrap it into an anonomous function: ``` $("#box") .fadeOut(1000, function() { nextGame(/* enter arguments as you wish */); }) .fadeIn(); ```
``` window.ChangeGame = function () { $("#box").fadeOut(1000, nextGame).fadeIn(1000); } ``` Will do what you want and perform the fade In and Out at equal speeds.
66,724,696
Let's suppose I have a function named the same and with the same parameters in two different files that I want to import to my main. ``` void foo(int a) { // Some code, this function in file A } void foo(int a) { // Some code, this function in file B } ``` How can I do it? If it is possible, how could the compiler differentiate between the two functions?
2021/03/20
[ "https://Stackoverflow.com/questions/66724696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9820269/" ]
The simplest way is to use namespaces: ### filea.hpp ```cpp namespace a { inline void foo(int a) { // Some code, this function in file A } } ``` ### fileb.hpp ```cpp namespace b { inline void foo(int a) { // Some code, this function in file A } } ``` ### main.cpp ```cpp #include "filea.hpp" #include "fileb.hpp" int main() { a::foo(1); b::foo(1); return 0; } ```
``` enum class file { A, B }; void foo(int a, file f) { if(f == file::A) { // Do some stuff for A }else{ // Do some stuff for B } } ``` Or just declare them in different `namespace`s
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
I have two suggestions to start. The first you're not going to like. No matter how stable you think your overclocked system is, it would be my first suspect. And any developer you report the problem to will say the same thing. Your stable test workload isn't necessarily using the same instructions, stressing the memory subsystem as much, whatever. Stop overclocking. If you want people to believe the problem's not overclocking, then make it happen when not overclocking so you can get a clean bug report. This will make a huge difference in how much effort other people will invest in solving this problem. Having bug-free software is a point of pride, but reports from people with particularly questionable hardware setups are frustrating time-sinks that probably don't involve a real bug at all. The second is to get the oops data, which as you've noticed doesn't go to any of the places you've mentioned. If the crash only happens while running X11, I think local console is pretty much out (it's a pain anyway), so you need to do this over a serial console, over the network, or by saving to local disk (which is trickier than it may sound because you don't want an untrustworthy kernel to corrupt your filesystem). Here are some ways to do this: * use [netdump](http://linux.die.net/man/8/netdump) to save to a server over the network. I haven't done this in years, so I'm not sure this software is still around and working with modern kernels, but it's easy enough that it's worth a shot. * boot using a [serial console](http://www.kernel.org/doc/Documentation/serial-console.txt); you'll need a serial port free on both machines (whether an old-school one or a USB serial adapter) and a null modem cable; you'd configure the other machine to save the output. * [kdump](http://www.kernel.org/doc/Documentation/kdump/kdump.txt) seems to be what the cool kids use nowadays, and seems quite flexible, although it wouldn't be my preference because it looks complex to set up. In short, it involves booting a different kernel that can do anything and inspect the former kernel's memory contents, but you have to essentially build the whole process and I don't see a lot of canned options out there. **Update:** There are some nice distro things, actually; on Ubuntu, [linux-crashdump](https://help.ubuntu.com/lts/serverguide/kernel-crash-dump.html) Once you get the debug info, there's a tool called [ksymoops](http://linuxcommand.org/man_pages/ksymoops8.html) that you can use to turn the addresses into symbol names and start getting an idea how your kernel crashed. And if the symbolized dump doesn't mean anything to you, at least this is something helpful to report here or perhaps on your Linux distribution's mailing list / bug tracker. --- From `crash` on your crashdump, you can try typing `log` and `bt` to get a bit more information (things logged during the panic and a stack backtrace). Your `Fatal Machine check` seems to be coming from [here](http://lxr.linux.no/linux+v3.7.1/arch/x86/kernel/cpu/mcheck/mce.c#L768), though. From skimming the code, your processor has reported a [Machine Check Exception](http://en.wikipedia.org/wiki/Machine_Check_Exception) - a hardware problem. Again, my first bet would be due to overclocking. It seems like there might be a more specific message in the `log` output which could tell you more. Also from that code, it looks like if you boot with the `mce=3` kernel parameter, it will stop crashing...but I wouldn't really recommend this except as a diagnostic step. If the Linux kernel thinks this error is worth crashing over, it's probably right.
a) Check if kernel messages are being logged to a file by rsyslog daemon ``` vi /etc/rsyslog.conf ``` And add the following ``` kern.* /var/log/kernel.log ``` Restart the `rsyslog` service. ``` /etc/initd.d/rsyslog restart ``` b) Take a note of the loaded modules ``` `lsmod >/your/home/dir` ``` c) As the panic is not reproducible, wait for it to happen d) Once the panic has occurred, boot the system using a live or emergency CD e) Mount the filesystems (usually / will suffice if /var and /home are not separate file systems) of the affected system (`pvs`, `vgs`, `lvs` commands need to be run if you are using LVM on the affected system to bring up the LV) `mount -t ext4 /dev/sdXN /mnt` f) Go to `/mnt/var/log/` directory and check the `kernel.log` file. This should give you enough information to figure out if the panic is happening for a particular module or something else.
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
a) Check if kernel messages are being logged to a file by rsyslog daemon ``` vi /etc/rsyslog.conf ``` And add the following ``` kern.* /var/log/kernel.log ``` Restart the `rsyslog` service. ``` /etc/initd.d/rsyslog restart ``` b) Take a note of the loaded modules ``` `lsmod >/your/home/dir` ``` c) As the panic is not reproducible, wait for it to happen d) Once the panic has occurred, boot the system using a live or emergency CD e) Mount the filesystems (usually / will suffice if /var and /home are not separate file systems) of the affected system (`pvs`, `vgs`, `lvs` commands need to be run if you are using LVM on the affected system to bring up the LV) `mount -t ext4 /dev/sdXN /mnt` f) Go to `/mnt/var/log/` directory and check the `kernel.log` file. This should give you enough information to figure out if the panic is happening for a particular module or something else.
We had a mikrotik router installed on an old rig. The fan stopped spinning and causing the processor to heat up. The router then starts to Kernel Panic every now and then. After changing the CPU fan everything went well. Since your are overclocking your machine it can be a possible cause.
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
a) Check if kernel messages are being logged to a file by rsyslog daemon ``` vi /etc/rsyslog.conf ``` And add the following ``` kern.* /var/log/kernel.log ``` Restart the `rsyslog` service. ``` /etc/initd.d/rsyslog restart ``` b) Take a note of the loaded modules ``` `lsmod >/your/home/dir` ``` c) As the panic is not reproducible, wait for it to happen d) Once the panic has occurred, boot the system using a live or emergency CD e) Mount the filesystems (usually / will suffice if /var and /home are not separate file systems) of the affected system (`pvs`, `vgs`, `lvs` commands need to be run if you are using LVM on the affected system to bring up the LV) `mount -t ext4 /dev/sdXN /mnt` f) Go to `/mnt/var/log/` directory and check the `kernel.log` file. This should give you enough information to figure out if the panic is happening for a particular module or something else.
Is your processor overclocked? I had this same issue today when I was playing with the multiplier in the over-clocking menu in my BIOS; various multipliers around 20x would cause this to happen. I reduced it down to 18.5x (3.7GHz) and the problem went away; I think it was a motherboard/power issue.
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
a) Check if kernel messages are being logged to a file by rsyslog daemon ``` vi /etc/rsyslog.conf ``` And add the following ``` kern.* /var/log/kernel.log ``` Restart the `rsyslog` service. ``` /etc/initd.d/rsyslog restart ``` b) Take a note of the loaded modules ``` `lsmod >/your/home/dir` ``` c) As the panic is not reproducible, wait for it to happen d) Once the panic has occurred, boot the system using a live or emergency CD e) Mount the filesystems (usually / will suffice if /var and /home are not separate file systems) of the affected system (`pvs`, `vgs`, `lvs` commands need to be run if you are using LVM on the affected system to bring up the LV) `mount -t ext4 /dev/sdXN /mnt` f) Go to `/mnt/var/log/` directory and check the `kernel.log` file. This should give you enough information to figure out if the panic is happening for a particular module or something else.
Most definitely a processor issue, notice the lines that say: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28. Processor 0 is what the kernel used to process the crash (matters in multi-cpu systems) and socket 0 is the offending processor (though I assume you only have 1). Either it is bad or as you noted being overclocked cause for faults. I know you said you took it through prime95 but since I do not have more information on how old the system is I am grabbing at a few straws, how does your thermal paste look, and have you checked to make sure your LGA (under the CPU) looks alright? I am thinking maybe bent pins or some paste under the LGA. Again just root causing here. If that fails to fix the issue there is a little trick you can do to use your SMBIOS to find where the panic hits exactly, another line (TSC 539b174de9d ADDR 3fe98d264ebd MISC 1) is basically SMBIOS data that can show where the crash happened. When your machine is up, in command line run, echo "TSC 539b174de9d ADDR 3fe98d264ebd MISC 1" | sudo mcelog --ascii --dmi to get the output, this will tell you it is a hardware error and even what DIMM it was processing on, this can point to a faulty DIMM or bus path, if the DIMM failure jumps around with every crash however, this points to the CPU.
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
I have two suggestions to start. The first you're not going to like. No matter how stable you think your overclocked system is, it would be my first suspect. And any developer you report the problem to will say the same thing. Your stable test workload isn't necessarily using the same instructions, stressing the memory subsystem as much, whatever. Stop overclocking. If you want people to believe the problem's not overclocking, then make it happen when not overclocking so you can get a clean bug report. This will make a huge difference in how much effort other people will invest in solving this problem. Having bug-free software is a point of pride, but reports from people with particularly questionable hardware setups are frustrating time-sinks that probably don't involve a real bug at all. The second is to get the oops data, which as you've noticed doesn't go to any of the places you've mentioned. If the crash only happens while running X11, I think local console is pretty much out (it's a pain anyway), so you need to do this over a serial console, over the network, or by saving to local disk (which is trickier than it may sound because you don't want an untrustworthy kernel to corrupt your filesystem). Here are some ways to do this: * use [netdump](http://linux.die.net/man/8/netdump) to save to a server over the network. I haven't done this in years, so I'm not sure this software is still around and working with modern kernels, but it's easy enough that it's worth a shot. * boot using a [serial console](http://www.kernel.org/doc/Documentation/serial-console.txt); you'll need a serial port free on both machines (whether an old-school one or a USB serial adapter) and a null modem cable; you'd configure the other machine to save the output. * [kdump](http://www.kernel.org/doc/Documentation/kdump/kdump.txt) seems to be what the cool kids use nowadays, and seems quite flexible, although it wouldn't be my preference because it looks complex to set up. In short, it involves booting a different kernel that can do anything and inspect the former kernel's memory contents, but you have to essentially build the whole process and I don't see a lot of canned options out there. **Update:** There are some nice distro things, actually; on Ubuntu, [linux-crashdump](https://help.ubuntu.com/lts/serverguide/kernel-crash-dump.html) Once you get the debug info, there's a tool called [ksymoops](http://linuxcommand.org/man_pages/ksymoops8.html) that you can use to turn the addresses into symbol names and start getting an idea how your kernel crashed. And if the symbolized dump doesn't mean anything to you, at least this is something helpful to report here or perhaps on your Linux distribution's mailing list / bug tracker. --- From `crash` on your crashdump, you can try typing `log` and `bt` to get a bit more information (things logged during the panic and a stack backtrace). Your `Fatal Machine check` seems to be coming from [here](http://lxr.linux.no/linux+v3.7.1/arch/x86/kernel/cpu/mcheck/mce.c#L768), though. From skimming the code, your processor has reported a [Machine Check Exception](http://en.wikipedia.org/wiki/Machine_Check_Exception) - a hardware problem. Again, my first bet would be due to overclocking. It seems like there might be a more specific message in the `log` output which could tell you more. Also from that code, it looks like if you boot with the `mce=3` kernel parameter, it will stop crashing...but I wouldn't really recommend this except as a diagnostic step. If the Linux kernel thinks this error is worth crashing over, it's probably right.
We had a mikrotik router installed on an old rig. The fan stopped spinning and causing the processor to heat up. The router then starts to Kernel Panic every now and then. After changing the CPU fan everything went well. Since your are overclocking your machine it can be a possible cause.
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
I have two suggestions to start. The first you're not going to like. No matter how stable you think your overclocked system is, it would be my first suspect. And any developer you report the problem to will say the same thing. Your stable test workload isn't necessarily using the same instructions, stressing the memory subsystem as much, whatever. Stop overclocking. If you want people to believe the problem's not overclocking, then make it happen when not overclocking so you can get a clean bug report. This will make a huge difference in how much effort other people will invest in solving this problem. Having bug-free software is a point of pride, but reports from people with particularly questionable hardware setups are frustrating time-sinks that probably don't involve a real bug at all. The second is to get the oops data, which as you've noticed doesn't go to any of the places you've mentioned. If the crash only happens while running X11, I think local console is pretty much out (it's a pain anyway), so you need to do this over a serial console, over the network, or by saving to local disk (which is trickier than it may sound because you don't want an untrustworthy kernel to corrupt your filesystem). Here are some ways to do this: * use [netdump](http://linux.die.net/man/8/netdump) to save to a server over the network. I haven't done this in years, so I'm not sure this software is still around and working with modern kernels, but it's easy enough that it's worth a shot. * boot using a [serial console](http://www.kernel.org/doc/Documentation/serial-console.txt); you'll need a serial port free on both machines (whether an old-school one or a USB serial adapter) and a null modem cable; you'd configure the other machine to save the output. * [kdump](http://www.kernel.org/doc/Documentation/kdump/kdump.txt) seems to be what the cool kids use nowadays, and seems quite flexible, although it wouldn't be my preference because it looks complex to set up. In short, it involves booting a different kernel that can do anything and inspect the former kernel's memory contents, but you have to essentially build the whole process and I don't see a lot of canned options out there. **Update:** There are some nice distro things, actually; on Ubuntu, [linux-crashdump](https://help.ubuntu.com/lts/serverguide/kernel-crash-dump.html) Once you get the debug info, there's a tool called [ksymoops](http://linuxcommand.org/man_pages/ksymoops8.html) that you can use to turn the addresses into symbol names and start getting an idea how your kernel crashed. And if the symbolized dump doesn't mean anything to you, at least this is something helpful to report here or perhaps on your Linux distribution's mailing list / bug tracker. --- From `crash` on your crashdump, you can try typing `log` and `bt` to get a bit more information (things logged during the panic and a stack backtrace). Your `Fatal Machine check` seems to be coming from [here](http://lxr.linux.no/linux+v3.7.1/arch/x86/kernel/cpu/mcheck/mce.c#L768), though. From skimming the code, your processor has reported a [Machine Check Exception](http://en.wikipedia.org/wiki/Machine_Check_Exception) - a hardware problem. Again, my first bet would be due to overclocking. It seems like there might be a more specific message in the `log` output which could tell you more. Also from that code, it looks like if you boot with the `mce=3` kernel parameter, it will stop crashing...but I wouldn't really recommend this except as a diagnostic step. If the Linux kernel thinks this error is worth crashing over, it's probably right.
Is your processor overclocked? I had this same issue today when I was playing with the multiplier in the over-clocking menu in my BIOS; various multipliers around 20x would cause this to happen. I reduced it down to 18.5x (3.7GHz) and the problem went away; I think it was a motherboard/power issue.
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
I have two suggestions to start. The first you're not going to like. No matter how stable you think your overclocked system is, it would be my first suspect. And any developer you report the problem to will say the same thing. Your stable test workload isn't necessarily using the same instructions, stressing the memory subsystem as much, whatever. Stop overclocking. If you want people to believe the problem's not overclocking, then make it happen when not overclocking so you can get a clean bug report. This will make a huge difference in how much effort other people will invest in solving this problem. Having bug-free software is a point of pride, but reports from people with particularly questionable hardware setups are frustrating time-sinks that probably don't involve a real bug at all. The second is to get the oops data, which as you've noticed doesn't go to any of the places you've mentioned. If the crash only happens while running X11, I think local console is pretty much out (it's a pain anyway), so you need to do this over a serial console, over the network, or by saving to local disk (which is trickier than it may sound because you don't want an untrustworthy kernel to corrupt your filesystem). Here are some ways to do this: * use [netdump](http://linux.die.net/man/8/netdump) to save to a server over the network. I haven't done this in years, so I'm not sure this software is still around and working with modern kernels, but it's easy enough that it's worth a shot. * boot using a [serial console](http://www.kernel.org/doc/Documentation/serial-console.txt); you'll need a serial port free on both machines (whether an old-school one or a USB serial adapter) and a null modem cable; you'd configure the other machine to save the output. * [kdump](http://www.kernel.org/doc/Documentation/kdump/kdump.txt) seems to be what the cool kids use nowadays, and seems quite flexible, although it wouldn't be my preference because it looks complex to set up. In short, it involves booting a different kernel that can do anything and inspect the former kernel's memory contents, but you have to essentially build the whole process and I don't see a lot of canned options out there. **Update:** There are some nice distro things, actually; on Ubuntu, [linux-crashdump](https://help.ubuntu.com/lts/serverguide/kernel-crash-dump.html) Once you get the debug info, there's a tool called [ksymoops](http://linuxcommand.org/man_pages/ksymoops8.html) that you can use to turn the addresses into symbol names and start getting an idea how your kernel crashed. And if the symbolized dump doesn't mean anything to you, at least this is something helpful to report here or perhaps on your Linux distribution's mailing list / bug tracker. --- From `crash` on your crashdump, you can try typing `log` and `bt` to get a bit more information (things logged during the panic and a stack backtrace). Your `Fatal Machine check` seems to be coming from [here](http://lxr.linux.no/linux+v3.7.1/arch/x86/kernel/cpu/mcheck/mce.c#L768), though. From skimming the code, your processor has reported a [Machine Check Exception](http://en.wikipedia.org/wiki/Machine_Check_Exception) - a hardware problem. Again, my first bet would be due to overclocking. It seems like there might be a more specific message in the `log` output which could tell you more. Also from that code, it looks like if you boot with the `mce=3` kernel parameter, it will stop crashing...but I wouldn't really recommend this except as a diagnostic step. If the Linux kernel thinks this error is worth crashing over, it's probably right.
Most definitely a processor issue, notice the lines that say: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28. Processor 0 is what the kernel used to process the crash (matters in multi-cpu systems) and socket 0 is the offending processor (though I assume you only have 1). Either it is bad or as you noted being overclocked cause for faults. I know you said you took it through prime95 but since I do not have more information on how old the system is I am grabbing at a few straws, how does your thermal paste look, and have you checked to make sure your LGA (under the CPU) looks alright? I am thinking maybe bent pins or some paste under the LGA. Again just root causing here. If that fails to fix the issue there is a little trick you can do to use your SMBIOS to find where the panic hits exactly, another line (TSC 539b174de9d ADDR 3fe98d264ebd MISC 1) is basically SMBIOS data that can show where the crash happened. When your machine is up, in command line run, echo "TSC 539b174de9d ADDR 3fe98d264ebd MISC 1" | sudo mcelog --ascii --dmi to get the output, this will tell you it is a hardware error and even what DIMM it was processing on, this can point to a faulty DIMM or bus path, if the DIMM failure jumps around with every crash however, this points to the CPU.
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
Is your processor overclocked? I had this same issue today when I was playing with the multiplier in the over-clocking menu in my BIOS; various multipliers around 20x would cause this to happen. I reduced it down to 18.5x (3.7GHz) and the problem went away; I think it was a motherboard/power issue.
We had a mikrotik router installed on an old rig. The fan stopped spinning and causing the processor to heat up. The router then starts to Kernel Panic every now and then. After changing the CPU fan everything went well. Since your are overclocking your machine it can be a possible cause.
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
Most definitely a processor issue, notice the lines that say: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28. Processor 0 is what the kernel used to process the crash (matters in multi-cpu systems) and socket 0 is the offending processor (though I assume you only have 1). Either it is bad or as you noted being overclocked cause for faults. I know you said you took it through prime95 but since I do not have more information on how old the system is I am grabbing at a few straws, how does your thermal paste look, and have you checked to make sure your LGA (under the CPU) looks alright? I am thinking maybe bent pins or some paste under the LGA. Again just root causing here. If that fails to fix the issue there is a little trick you can do to use your SMBIOS to find where the panic hits exactly, another line (TSC 539b174de9d ADDR 3fe98d264ebd MISC 1) is basically SMBIOS data that can show where the crash happened. When your machine is up, in command line run, echo "TSC 539b174de9d ADDR 3fe98d264ebd MISC 1" | sudo mcelog --ascii --dmi to get the output, this will tell you it is a hardware error and even what DIMM it was processing on, this can point to a faulty DIMM or bus path, if the DIMM failure jumps around with every crash however, this points to the CPU.
We had a mikrotik router installed on an old rig. The fan stopped spinning and causing the processor to heat up. The router then starts to Kernel Panic every now and then. After changing the CPU fan everything went well. Since your are overclocking your machine it can be a possible cause.
60,574
I'm running an Ubuntu 12.04 derivative (amd64) and I've been having really strange issues recently. Out of the blue, seemingly, X will freeze completely for a while (1-3 minutes?) and then the system will reboot. This system is overclocked, but very stable as verified in Windows, which leads me to believe I'm having a kernel panic or an issue with one of my modules. Even in Linux, I can run LINPACK and won't see a crash despite putting ridiculous load on the CPU. Crashes seem to happen at random times, even when the machine is sitting idle. How can I debug what's crashing the system? On a hunch that it might be the proprietary NVIDIA driver, I reverted all the way down to the stable version of the driver, version 304 and I still experience the crash. Can anyone walk me through a good debugging procedure for after a crash? I'd be more than happy to boot into a thumb drive and post all of my post-crash configuration files, I'm just not sure what they would be. How can I find out what's crashing my system? Here are a bunch of logs, the usual culprits. **.xsession-errors**: <http://pastebin.com/EEDtVkVm> **/var/log/Xorg.0.log**: <http://pastebin.com/ftsG5VAn> **/var/log/kern.log**: <http://pastebin.com/Hsy7jcHZ> **/var/log/syslog**: <http://pastebin.com/9Fkp3FMz> I can't even seem to find a record of the crash at all. Triggering the crash is not so simple, it seem to happen when the GPU is trying to draw multiple things at once. If I put on a YouTube video in full screen and let it repeat for a while or scroll through a ton of GIFs and a Skype notification pops up, sometimes it'll crash. Totally scratching my head on this one. The CPU is overclocked to 4.8GHz, but it's completely stable and has survived huge LINPACK runs and 9 hours of Prime95 yesterday without a single crash. Update ------ I've installed `kdump`, `crash`, and `linux-crashdump`, as well as the kernel debug symbols for my kernel version 3.2.0-35. When I run `apport-unpack` on the crashed kernel file and then `crash` on the `VmCore` crash dump, here's what I see: ``` KERNEL: /usr/lib/debug/boot/vmlinux-3.2.0-35-generic DUMPFILE: Downloads/crash/VmCore CPUS: 8 DATE: Thu Jan 10 16:05:55 2013 UPTIME: 00:26:04 LOAD AVERAGE: 2.20, 0.84, 0.49 TASKS: 614 NODENAME: mightymoose RELEASE: 3.2.0-35-generic VERSION: #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 MACHINE: x86_64 (3499 Mhz) MEMORY: 8 GB PANIC: "[ 1561.519960] Kernel panic - not syncing: Fatal Machine check" PID: 0 COMMAND: "swapper/5" TASK: ffff880211251700 (1 of 8) [THREAD_INFO: ffff880211260000] CPU: 5 STATE: TASK_RUNNING (PANIC) ``` When I run `log` from the `crash` utility, I see this at the bottom of the log: ``` [ 1561.519943] [Hardware Error]: CPU 4: Machine Check Exception: 5 Bank 3: be00000000800400 [ 1561.519946] [Hardware Error]: RIP !INEXACT! 33:<00007fe99ae93e54> [ 1561.519948] [Hardware Error]: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28 [ 1561.519951] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519953] [Hardware Error]: CPU 0: Machine Check Exception: 4 Bank 3: be00000000800400 [ 1561.519955] [Hardware Error]: TSC 539b174de9d ADDR 3fe98d264ebd MISC 1 [ 1561.519957] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 0 microcode 28 [ 1561.519958] [Hardware Error]: Run the above through 'mcelog --ascii' [ 1561.519959] [Hardware Error]: Machine check: Processor context corrupt [ 1561.519960] Kernel panic - not syncing: Fatal Machine check [ 1561.519962] Pid: 0, comm: swapper/5 Tainted: P M C O 3.2.0-35-generic #55-Ubuntu [ 1561.519963] Call Trace: [ 1561.519964] <#MC> [<ffffffff81644340>] panic+0x91/0x1a4 [ 1561.519971] [<ffffffff8102abeb>] mce_panic.part.14+0x18b/0x1c0 [ 1561.519973] [<ffffffff8102ac80>] mce_panic+0x60/0xb0 [ 1561.519975] [<ffffffff8102aec4>] mce_reign+0x1f4/0x200 [ 1561.519977] [<ffffffff8102b175>] mce_end+0xf5/0x100 [ 1561.519979] [<ffffffff8102b92c>] do_machine_check+0x3fc/0x600 [ 1561.519982] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519984] [<ffffffff8165d78c>] machine_check+0x1c/0x30 [ 1561.519986] [<ffffffff8136d48f>] ? intel_idle+0xbf/0x150 [ 1561.519987] <<EOE>> [<ffffffff81509697>] ? menu_select+0xe7/0x2c0 [ 1561.519991] [<ffffffff815082d1>] cpuidle_idle_call+0xc1/0x280 [ 1561.519994] [<ffffffff8101322a>] cpu_idle+0xca/0x120 [ 1561.519996] [<ffffffff8163aa9a>] start_secondary+0xd9/0xdb ``` `bt` outputs the backtrace: ``` PID: 0 TASK: ffff880211251700 CPU: 5 COMMAND: "swapper/5" #0 [ffff88021ed4aba0] machine_kexec at ffffffff8103947a #1 [ffff88021ed4ac10] crash_kexec at ffffffff810b52c8 #2 [ffff88021ed4ace0] panic at ffffffff81644347 #3 [ffff88021ed4ad60] mce_panic.part.14 at ffffffff8102abeb #4 [ffff88021ed4adb0] mce_panic at ffffffff8102ac80 #5 [ffff88021ed4ade0] mce_reign at ffffffff8102aec4 #6 [ffff88021ed4ae40] mce_end at ffffffff8102b175 #7 [ffff88021ed4ae70] do_machine_check at ffffffff8102b92c #8 [ffff88021ed4af50] machine_check at ffffffff8165d78c [exception RIP: intel_idle+191] RIP: ffffffff8136d48f RSP: ffff880211261e38 RFLAGS: 00000046 RAX: 0000000000000020 RBX: 0000000000000008 RCX: 0000000000000001 RDX: 0000000000000000 RSI: ffff880211261fd8 RDI: ffffffff81c12f00 RBP: ffff880211261e98 R8: 00000000fffffffc R9: 0000000000000f9f R10: 0000000000001e95 R11: 0000000000000000 R12: 0000000000000003 R13: ffff88021ed5ac70 R14: 0000000000000020 R15: 12d818fb42cfe42b ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 --- <MCE exception stack> --- #9 [ffff880211261e38] intel_idle at ffffffff8136d48f #10 [ffff880211261ea0] cpuidle_idle_call at ffffffff815082d1 #11 [ffff880211261f00] cpu_idle at ffffffff8101322a ``` Any ideas?
2013/01/07
[ "https://unix.stackexchange.com/questions/60574", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/5614/" ]
Is your processor overclocked? I had this same issue today when I was playing with the multiplier in the over-clocking menu in my BIOS; various multipliers around 20x would cause this to happen. I reduced it down to 18.5x (3.7GHz) and the problem went away; I think it was a motherboard/power issue.
Most definitely a processor issue, notice the lines that say: TSC 539b174dead ADDR 3fe98d264ebd MISC 1 [ 1561.519950] [Hardware Error]: PROCESSOR 0:206a7 TIME 1357862746 SOCKET 0 APIC 1 microcode 28. Processor 0 is what the kernel used to process the crash (matters in multi-cpu systems) and socket 0 is the offending processor (though I assume you only have 1). Either it is bad or as you noted being overclocked cause for faults. I know you said you took it through prime95 but since I do not have more information on how old the system is I am grabbing at a few straws, how does your thermal paste look, and have you checked to make sure your LGA (under the CPU) looks alright? I am thinking maybe bent pins or some paste under the LGA. Again just root causing here. If that fails to fix the issue there is a little trick you can do to use your SMBIOS to find where the panic hits exactly, another line (TSC 539b174de9d ADDR 3fe98d264ebd MISC 1) is basically SMBIOS data that can show where the crash happened. When your machine is up, in command line run, echo "TSC 539b174de9d ADDR 3fe98d264ebd MISC 1" | sudo mcelog --ascii --dmi to get the output, this will tell you it is a hardware error and even what DIMM it was processing on, this can point to a faulty DIMM or bus path, if the DIMM failure jumps around with every crash however, this points to the CPU.
37,990,519
Any idea how to use Carrierwave to upload images with Heroku. I added this to the uploader file: ``` def cache_dir "#{Rails.root}/tmp/uploads" end ``` but images still don't save! After uploading an image, it saves and once you refresh the page, the image breaks. Any help would be appreciated! Thanks
2016/06/23
[ "https://Stackoverflow.com/questions/37990519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6094382/" ]
I do not think you can use Heroku and upload images without 3rd party storage service like Amazon S3. <https://devcenter.heroku.com/articles/s3> Heroku allows you store files inside tmp but just in order to send to a 3rd party service. Inside carrierwave uploader class you can set for example storage :fog instead of default :file and setup uploads to AWS S3. There are other options as well. One thing is that if you are using a free tier instance on Heroku your upload needs to finish in abut a minute - I would recommend setup where you upload files directly to s3 account. <https://github.com/dwilkie/carrierwave_direct> Hope it helps
The filesystem on Heroku is not persisted. Only files uploaded through deployment mechanisms (git push) are "persisted". Others like the ones in your `"#{Rails.root}/tmp/uploads"` folder will be erased. That's why they are disappearing. --- I have answered a [similar question here](https://stackoverflow.com/a/37361940/52317). Here is a quote: Your dyno on Heroku has a "read-only" filesystem. In a sense, your files will not be persisted between your dyno restarts and there is no guarantee that they will persist between any two requests. Here is an [excerpt from the docs](https://devcenter.heroku.com/articles/one-off-dynos#formation-dynos-vs-one-off-dynos): > > Each dyno has its own ephemeral file system, not shared with any other dyno, that is discarded as soon as you disconnect. This file system is populated with the slug archive so one-off dynos can make full use of anything deployed in the application. > > > You can use the `#{Rails.root}/tmp` folder as temporary folder, but you need to upload your files to some external storage (S3, some CDN, etc.). Heroku has some addons that makes it easy to handle.
28,834,395
I have written code to display a simple alert popup when a button is clicked. When trying the app in simulator iPhone 4s (8.1), it's working as expected, but when trying in simulator iPhone 4s (7.1), the app keeps crashing. Here the code: @IBAction func buttonPressed(sender: UIButton) { ``` let controller = UIAlertController(title: "This is a title", message: "Hello, my friend", preferredStyle: UIAlertControllerStyle.Alert) let cancelAction = UIAlertAction(title: "Phew!", style: .Cancel, handler: nil) controller.addAction(cancelAction) self.presentViewController(controller, animated: true, completion: nil) } ``` Here's the error message: The first line code (the one creating the "controller" constant) is highlighted in green with the message "Thread 1: EXC\_BAD\_ACCESS(Code=1,address=0x10)" I would appreciate any help
2015/03/03
[ "https://Stackoverflow.com/questions/28834395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1903379/" ]
UIAlertController is available for iOS >= 8.0 You have to use UIAlertView for iOS < 8.0
Thanks to recommended links from Dom Bryan, I managed the following solution: @IBAction func buttonPressed(sender: UIButton) { ``` if NSClassFromString("UIAlertController") == nil{ let alert = UIAlertView(title: "This is a title", message: "I am an iOS7 alert", delegate: self, cancelButtonTitle: "Phew!") alert.show() }else{ let controller = UIAlertController(title: "This is a title", message: "Hello, my friend", preferredStyle: .Alert) let cancelAction = UIAlertAction(title: "Phew!", style: .Cancel, handler: nil) controller.addAction(cancelAction) self.presentViewController(controller, animated: true, completion: nil) } } ``` And it's working fine on iOS7 and iOS8 devices
28,834,395
I have written code to display a simple alert popup when a button is clicked. When trying the app in simulator iPhone 4s (8.1), it's working as expected, but when trying in simulator iPhone 4s (7.1), the app keeps crashing. Here the code: @IBAction func buttonPressed(sender: UIButton) { ``` let controller = UIAlertController(title: "This is a title", message: "Hello, my friend", preferredStyle: UIAlertControllerStyle.Alert) let cancelAction = UIAlertAction(title: "Phew!", style: .Cancel, handler: nil) controller.addAction(cancelAction) self.presentViewController(controller, animated: true, completion: nil) } ``` Here's the error message: The first line code (the one creating the "controller" constant) is highlighted in green with the message "Thread 1: EXC\_BAD\_ACCESS(Code=1,address=0x10)" I would appreciate any help
2015/03/03
[ "https://Stackoverflow.com/questions/28834395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1903379/" ]
UIAlertController is only available in iOS 8.0 and on wards unfortunately, here is documentation and it states this on the right: <https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_class/#//apple_ref/doc/uid/TP40014538-CH1-SW2> I believe this replaced the now deprecated UIAlertView which can be found here in Apple Documentation: <https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertView_Class/index.html#//apple_ref/occ/cl/UIAlertView> Swift doesn't like the old but consider and "if" clause and create both a UIAlertView and UIAlertController for the respective iOS system using the app.
Thanks to recommended links from Dom Bryan, I managed the following solution: @IBAction func buttonPressed(sender: UIButton) { ``` if NSClassFromString("UIAlertController") == nil{ let alert = UIAlertView(title: "This is a title", message: "I am an iOS7 alert", delegate: self, cancelButtonTitle: "Phew!") alert.show() }else{ let controller = UIAlertController(title: "This is a title", message: "Hello, my friend", preferredStyle: .Alert) let cancelAction = UIAlertAction(title: "Phew!", style: .Cancel, handler: nil) controller.addAction(cancelAction) self.presentViewController(controller, animated: true, completion: nil) } } ``` And it's working fine on iOS7 and iOS8 devices
13,034,468
This would seem stupid but i can't seem to understand the documentation. I'm talking about [This](https://github.com/blueimp/jQuery-File-Upload) plugin for file upload. Now according to the documentation there's an option : > > **formData** > > > Additional form data to be sent along with the file uploads can be set using this > option, which accepts an array of objects with name and value properties, a function > returning such an array, a FormData object (for XHR file uploads), or a simple object. > The form of the first fileInput is given as parameter to the function. > > > **Note**: Additional form data is ignored when the multipart option is set to false. > > > Type: Array, Object, function or FormData Default: A function > returning the form fields as serialized Array: > > > > ``` > function (form) { > return form.serializeArray(); > } > > ``` > > **Example:** > > > [ > { > name: 'a', > value: 1 > }, > { > name: 'b', > value: 2 > } ] > > > Which i fail to understand what i'm suppoused to do with that. This is how i initialize the plugin : ``` $('#add_image_upload').fileupload({ dataType: 'json', sequentialUploads: true, formData : getDate }); ``` And this is my attempt to the function : ``` function getDate(){ //if user didn't selected a date if(!selectedDate || selectedDate=="undefined"){ selectedDate = "1/1/"+$('#timeline').html(); } var date= new Array(selectedDate); return date; } ```
2012/10/23
[ "https://Stackoverflow.com/questions/13034468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1026199/" ]
try turning your data into in object - with what they showed in their example ``` $('#add_image_upload').fileupload({ dataType: 'json', sequentialUploads: true, formData : {name:'thedate',value:getDate} }); ``` Then to add more params ``` //name of param // value formData : [{name:'thedate',value:getDate},{name:'thedate2',value:'seconddate'},etc..] ``` > > Example: > > > [ { name: 'a', value: 1 }, { name: 'b', value: 2 } ] > > > Changing `thedate` with whatever you want to name the param Though it sounds like a simple object should work fine ``` //name:value formData : {thedate:getDate} ```
Do you have `multipart` set to `false` on your form? Also, ensure the format of what you're sending back is acceptable. Try hard-coding the following line and sending back the info: ``` new dateobject = { "date": "1/1/2012" } ```
26,881,665
I have a certain number of files for which I need the filenames in my program. The files have a fixed naming fashion i.e. (prefix + digits).jpg. For e.g.: `head001.jpg`, `head002.jpg`, `head003.jpg` etc. etc. The number of digits, in the end, can be varying - so the program has variables to change where the file naming starts from, where it ends and how many number digits are used in the naming. For e.g: A second scenario could be - `tail00001.jpg`, `tail00002.jpg`, `tail00003.jpg` etc. until `tail00100.jpg` And in this case: start digit would be 0, end digit would be 100 and numDigits would be 5 In C++, I’ve seen this formatting being done as follows: `format <<prefix<<"%0"<<numDigits<<"d."<<filetype;` //where `format` is a `stringstream` However, I’m not quite sure about the best way to do this in C# and would like to know how to solve this.
2014/11/12
[ "https://Stackoverflow.com/questions/26881665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1240679/" ]
Just use `string.Format`, with a *precision specifier* saying how many digits you want: ``` string name = string.Format("tail{0:d6}.jpg", index); ``` See the MSDN documentation for [standard numeric string formats](http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx) for more details. You can build the string format up programmatically of course: ``` string name = string.Format("tail{0:d" + digits + "}.jpg", index); ``` Or use `PadLeft` as suggested by Vano. You might still want to use `string.Format` though: ``` string name = string.Format("tail{0}.jpg", index.ToString().PadLeft(digits, '0')); ``` Using `PadLeft` has the advantage that it's easier to change the padding value, although I would imagine you'd always want it to be `0` anyway.
string has *PadLeft* method: ``` int n1 = 1; string t1 = n1.ToString().PadLeft(5, '0'); // This will return 00001 int n10 = 10; string t2 = n10.ToString().PadLeft(5, '0'); // This will return 00010 and so on... ```
26,881,665
I have a certain number of files for which I need the filenames in my program. The files have a fixed naming fashion i.e. (prefix + digits).jpg. For e.g.: `head001.jpg`, `head002.jpg`, `head003.jpg` etc. etc. The number of digits, in the end, can be varying - so the program has variables to change where the file naming starts from, where it ends and how many number digits are used in the naming. For e.g: A second scenario could be - `tail00001.jpg`, `tail00002.jpg`, `tail00003.jpg` etc. until `tail00100.jpg` And in this case: start digit would be 0, end digit would be 100 and numDigits would be 5 In C++, I’ve seen this formatting being done as follows: `format <<prefix<<"%0"<<numDigits<<"d."<<filetype;` //where `format` is a `stringstream` However, I’m not quite sure about the best way to do this in C# and would like to know how to solve this.
2014/11/12
[ "https://Stackoverflow.com/questions/26881665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1240679/" ]
Just use `string.Format`, with a *precision specifier* saying how many digits you want: ``` string name = string.Format("tail{0:d6}.jpg", index); ``` See the MSDN documentation for [standard numeric string formats](http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx) for more details. You can build the string format up programmatically of course: ``` string name = string.Format("tail{0:d" + digits + "}.jpg", index); ``` Or use `PadLeft` as suggested by Vano. You might still want to use `string.Format` though: ``` string name = string.Format("tail{0}.jpg", index.ToString().PadLeft(digits, '0')); ``` Using `PadLeft` has the advantage that it's easier to change the padding value, although I would imagine you'd always want it to be `0` anyway.
> > ..and in this case: start digit would be 0, end digit would be 100 and > numDigits would be 5 > > > You could use [`String.Format`](http://msdn.microsoft.com/en-us/library/b1csw23d(v=vs.110).aspx) and the [decimal format/precision specifier "D"`](http://msdn.microsoft.com/en-us/library/vstudio/dwhawy9k(v=vs.100).aspx#DFormatString) and a for-loop: ``` int start = 0; int end = 100; int numDigits = 5; string name = "tail"; string extension = ".jpg"; for(int i = start; i <= end; i++) { string fileName = string.Format( "{0}{1}{2}", name, i.ToString("D" + numDigits), extension); Console.WriteLine(fileName); } ``` Outputs: ``` tail00000.jpg tail00001.jpg tail00002.jpg tail00003.jpg tail00004.jpg tail00005.jpg tail00006.jpg tail00007.jpg tail00008.jpg tail00009.jpg tail00010.jpg .... tail100.jpg ```
26,881,665
I have a certain number of files for which I need the filenames in my program. The files have a fixed naming fashion i.e. (prefix + digits).jpg. For e.g.: `head001.jpg`, `head002.jpg`, `head003.jpg` etc. etc. The number of digits, in the end, can be varying - so the program has variables to change where the file naming starts from, where it ends and how many number digits are used in the naming. For e.g: A second scenario could be - `tail00001.jpg`, `tail00002.jpg`, `tail00003.jpg` etc. until `tail00100.jpg` And in this case: start digit would be 0, end digit would be 100 and numDigits would be 5 In C++, I’ve seen this formatting being done as follows: `format <<prefix<<"%0"<<numDigits<<"d."<<filetype;` //where `format` is a `stringstream` However, I’m not quite sure about the best way to do this in C# and would like to know how to solve this.
2014/11/12
[ "https://Stackoverflow.com/questions/26881665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1240679/" ]
Just use `string.Format`, with a *precision specifier* saying how many digits you want: ``` string name = string.Format("tail{0:d6}.jpg", index); ``` See the MSDN documentation for [standard numeric string formats](http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx) for more details. You can build the string format up programmatically of course: ``` string name = string.Format("tail{0:d" + digits + "}.jpg", index); ``` Or use `PadLeft` as suggested by Vano. You might still want to use `string.Format` though: ``` string name = string.Format("tail{0}.jpg", index.ToString().PadLeft(digits, '0')); ``` Using `PadLeft` has the advantage that it's easier to change the padding value, although I would imagine you'd always want it to be `0` anyway.
You can do this using string.Format ``` var result = string.Format("{0}{1:00000}{2}", prefix, number, filetype) ``` Or you could use padleft ``` var result = prefix + number.ToString().PadLeft('0', numDigits) + "." + extension; ``` Or you can use a mix of the two :)
26,881,665
I have a certain number of files for which I need the filenames in my program. The files have a fixed naming fashion i.e. (prefix + digits).jpg. For e.g.: `head001.jpg`, `head002.jpg`, `head003.jpg` etc. etc. The number of digits, in the end, can be varying - so the program has variables to change where the file naming starts from, where it ends and how many number digits are used in the naming. For e.g: A second scenario could be - `tail00001.jpg`, `tail00002.jpg`, `tail00003.jpg` etc. until `tail00100.jpg` And in this case: start digit would be 0, end digit would be 100 and numDigits would be 5 In C++, I’ve seen this formatting being done as follows: `format <<prefix<<"%0"<<numDigits<<"d."<<filetype;` //where `format` is a `stringstream` However, I’m not quite sure about the best way to do this in C# and would like to know how to solve this.
2014/11/12
[ "https://Stackoverflow.com/questions/26881665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1240679/" ]
Just use `string.Format`, with a *precision specifier* saying how many digits you want: ``` string name = string.Format("tail{0:d6}.jpg", index); ``` See the MSDN documentation for [standard numeric string formats](http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx) for more details. You can build the string format up programmatically of course: ``` string name = string.Format("tail{0:d" + digits + "}.jpg", index); ``` Or use `PadLeft` as suggested by Vano. You might still want to use `string.Format` though: ``` string name = string.Format("tail{0}.jpg", index.ToString().PadLeft(digits, '0')); ``` Using `PadLeft` has the advantage that it's easier to change the padding value, although I would imagine you'd always want it to be `0` anyway.
**For modern .NET 5.0+** (2021 update) ``` int myint = 100; string zeroPadded = $"{myint:d8}"; // "00000100" string spacePadded = $"{myint,8}"; // " 100" ```
26,881,665
I have a certain number of files for which I need the filenames in my program. The files have a fixed naming fashion i.e. (prefix + digits).jpg. For e.g.: `head001.jpg`, `head002.jpg`, `head003.jpg` etc. etc. The number of digits, in the end, can be varying - so the program has variables to change where the file naming starts from, where it ends and how many number digits are used in the naming. For e.g: A second scenario could be - `tail00001.jpg`, `tail00002.jpg`, `tail00003.jpg` etc. until `tail00100.jpg` And in this case: start digit would be 0, end digit would be 100 and numDigits would be 5 In C++, I’ve seen this formatting being done as follows: `format <<prefix<<"%0"<<numDigits<<"d."<<filetype;` //where `format` is a `stringstream` However, I’m not quite sure about the best way to do this in C# and would like to know how to solve this.
2014/11/12
[ "https://Stackoverflow.com/questions/26881665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1240679/" ]
string has *PadLeft* method: ``` int n1 = 1; string t1 = n1.ToString().PadLeft(5, '0'); // This will return 00001 int n10 = 10; string t2 = n10.ToString().PadLeft(5, '0'); // This will return 00010 and so on... ```
> > ..and in this case: start digit would be 0, end digit would be 100 and > numDigits would be 5 > > > You could use [`String.Format`](http://msdn.microsoft.com/en-us/library/b1csw23d(v=vs.110).aspx) and the [decimal format/precision specifier "D"`](http://msdn.microsoft.com/en-us/library/vstudio/dwhawy9k(v=vs.100).aspx#DFormatString) and a for-loop: ``` int start = 0; int end = 100; int numDigits = 5; string name = "tail"; string extension = ".jpg"; for(int i = start; i <= end; i++) { string fileName = string.Format( "{0}{1}{2}", name, i.ToString("D" + numDigits), extension); Console.WriteLine(fileName); } ``` Outputs: ``` tail00000.jpg tail00001.jpg tail00002.jpg tail00003.jpg tail00004.jpg tail00005.jpg tail00006.jpg tail00007.jpg tail00008.jpg tail00009.jpg tail00010.jpg .... tail100.jpg ```
26,881,665
I have a certain number of files for which I need the filenames in my program. The files have a fixed naming fashion i.e. (prefix + digits).jpg. For e.g.: `head001.jpg`, `head002.jpg`, `head003.jpg` etc. etc. The number of digits, in the end, can be varying - so the program has variables to change where the file naming starts from, where it ends and how many number digits are used in the naming. For e.g: A second scenario could be - `tail00001.jpg`, `tail00002.jpg`, `tail00003.jpg` etc. until `tail00100.jpg` And in this case: start digit would be 0, end digit would be 100 and numDigits would be 5 In C++, I’ve seen this formatting being done as follows: `format <<prefix<<"%0"<<numDigits<<"d."<<filetype;` //where `format` is a `stringstream` However, I’m not quite sure about the best way to do this in C# and would like to know how to solve this.
2014/11/12
[ "https://Stackoverflow.com/questions/26881665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1240679/" ]
string has *PadLeft* method: ``` int n1 = 1; string t1 = n1.ToString().PadLeft(5, '0'); // This will return 00001 int n10 = 10; string t2 = n10.ToString().PadLeft(5, '0'); // This will return 00010 and so on... ```
You can do this using string.Format ``` var result = string.Format("{0}{1:00000}{2}", prefix, number, filetype) ``` Or you could use padleft ``` var result = prefix + number.ToString().PadLeft('0', numDigits) + "." + extension; ``` Or you can use a mix of the two :)
26,881,665
I have a certain number of files for which I need the filenames in my program. The files have a fixed naming fashion i.e. (prefix + digits).jpg. For e.g.: `head001.jpg`, `head002.jpg`, `head003.jpg` etc. etc. The number of digits, in the end, can be varying - so the program has variables to change where the file naming starts from, where it ends and how many number digits are used in the naming. For e.g: A second scenario could be - `tail00001.jpg`, `tail00002.jpg`, `tail00003.jpg` etc. until `tail00100.jpg` And in this case: start digit would be 0, end digit would be 100 and numDigits would be 5 In C++, I’ve seen this formatting being done as follows: `format <<prefix<<"%0"<<numDigits<<"d."<<filetype;` //where `format` is a `stringstream` However, I’m not quite sure about the best way to do this in C# and would like to know how to solve this.
2014/11/12
[ "https://Stackoverflow.com/questions/26881665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1240679/" ]
string has *PadLeft* method: ``` int n1 = 1; string t1 = n1.ToString().PadLeft(5, '0'); // This will return 00001 int n10 = 10; string t2 = n10.ToString().PadLeft(5, '0'); // This will return 00010 and so on... ```
**For modern .NET 5.0+** (2021 update) ``` int myint = 100; string zeroPadded = $"{myint:d8}"; // "00000100" string spacePadded = $"{myint,8}"; // " 100" ```
58,690,044
I wanted to have pound sign in sql query result as £ , but when I am executing this query, it is not displaying expected symbol: ``` select chr(169) from dual; ``` Actual result is: � Expected Result:£
2019/11/04
[ "https://Stackoverflow.com/questions/58690044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2758176/" ]
This work for me: ``` select '£' from dual; select concat('£' , 500) from dual; ``` Regards!
There is no ASCII value for £ sign that why it's not showing pound sign but if you want to show pound your need to change your `NLS_TERRITORY` setting then use below ``` select to_char(123, 'L999,999.00') from dual; ``` right now it will show $ because oracle by default setting is american $ [list of parameter for NLS\_TERRITORY](https://www.oracle.com/webfolder/community/oracle_database/4039558.html)
58,690,044
I wanted to have pound sign in sql query result as £ , but when I am executing this query, it is not displaying expected symbol: ``` select chr(169) from dual; ``` Actual result is: � Expected Result:£
2019/11/04
[ "https://Stackoverflow.com/questions/58690044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2758176/" ]
This work for me: ``` select '£' from dual; select concat('£' , 500) from dual; ``` Regards!
Try This. ``` SELECT CHAR(0163) FROM TABLE_NAME; ```
4,509,658
I am trying to decide on the best branching strategy for a web application project. Here is what I have come up with until now and I would greatly appreciate any comments and experiences. The way I see it there are two main branching strategies: "branch by release" and "branch by feature". **"Branch by release"**: Development takes place on the trunk. When the time for a release is near, a branch is made for that release. This branch is then stabilized/tested and finally a release is made. After the release, the branch is merged back into the trunk, while keeping the release branch alive for bug-fixing. Is a bug-fix applied, then it is merged into the trunk ( if the development on the trunk hasn't eclipsed the bug in other means). New features are added to the trunk and don't affect the release branch. When a new release time nears, a new release branch is created a.s.o. **"Branch by feature"**: The trunk is always the "production" trunk (the code that is live). Bugfixes are commited directly to the trunk. Features for the next release are developed in feature branches.Bugfixes are merged from time-to-time into the feature branches. When release time comes, the features branches are merged into the trunk and the cycle of life continues. Now the way I see it the big practical difference between these two strategies is that "by release" allows you to maintane different production versions of you software ( when client A has version 1 and client B version 1.5, client is the paying customer in this case). In contrast using the "by feature" strategy you can only support the current production version ( all clients are using latest version). Since in a typical *web application* all clients are using the same "latest" version (since they all access the same server), I would assume that the "by feature" approach is the most commonly used. It removes the need to merge "across the hierarchy", say when a bugfix has to be applied to all 3 release versions. So my current status is that I should go with "branch by feature". If it matters, my team is not very skilled.
2010/12/22
[ "https://Stackoverflow.com/questions/4509658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110453/" ]
If you only have one release live at any time, and you do all development in a single feature branch, then these approaches are effectively the same. If branch-by-feature to you means having a several branches on the go at once, i'd avoid it like the plague. More branches means more merging, which is a pain in itself, and more integration hell. It's far better to do continuous integration to a single codeline. If your deployment process is any more involved than branch, test, go live, then an advantage of branch-by-release is that you can have multiple release branches going at once, in different phases: one live and being bugfixed as necessary, and another one being stabilised, tested, going through acceptance, etc, while development continues on the trunk. If you have a live trunk, on the other hand, once you merge a feature branch in with a view to taking it live, you've lost your ability to do bugfixes to the current live system. The feature branch merge becomes a point of no return.
I tend to use Git for my projects, but the process I tend to follow goes like this (and should work for Subversion as well): * for each new feature, create a branch for that feature. * When everything works, merge it into the `staging` branch, and deploy it to the staging server (you do have one of those, right?) * Once we're sure the client is happy with what's on staging, we merge the staging branch into the production branch, tag it as something like `production_release_22` or `production_release_new_feature_x`, and then deploy that tag to the production server. Tags are *never*, *ever* updated - once something gets deployed, it stays that way until more changes are built, tested, and tagged - and then the new tag is deployed. By making sure that it's *tags* getting deployed and not *branches*, I keep myself (or others) from doing things like "I'll just commit this one quick change and update the server without testing it". It's worked pretty well for me so far.
4,509,658
I am trying to decide on the best branching strategy for a web application project. Here is what I have come up with until now and I would greatly appreciate any comments and experiences. The way I see it there are two main branching strategies: "branch by release" and "branch by feature". **"Branch by release"**: Development takes place on the trunk. When the time for a release is near, a branch is made for that release. This branch is then stabilized/tested and finally a release is made. After the release, the branch is merged back into the trunk, while keeping the release branch alive for bug-fixing. Is a bug-fix applied, then it is merged into the trunk ( if the development on the trunk hasn't eclipsed the bug in other means). New features are added to the trunk and don't affect the release branch. When a new release time nears, a new release branch is created a.s.o. **"Branch by feature"**: The trunk is always the "production" trunk (the code that is live). Bugfixes are commited directly to the trunk. Features for the next release are developed in feature branches.Bugfixes are merged from time-to-time into the feature branches. When release time comes, the features branches are merged into the trunk and the cycle of life continues. Now the way I see it the big practical difference between these two strategies is that "by release" allows you to maintane different production versions of you software ( when client A has version 1 and client B version 1.5, client is the paying customer in this case). In contrast using the "by feature" strategy you can only support the current production version ( all clients are using latest version). Since in a typical *web application* all clients are using the same "latest" version (since they all access the same server), I would assume that the "by feature" approach is the most commonly used. It removes the need to merge "across the hierarchy", say when a bugfix has to be applied to all 3 release versions. So my current status is that I should go with "branch by feature". If it matters, my team is not very skilled.
2010/12/22
[ "https://Stackoverflow.com/questions/4509658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110453/" ]
If you only have one release live at any time, and you do all development in a single feature branch, then these approaches are effectively the same. If branch-by-feature to you means having a several branches on the go at once, i'd avoid it like the plague. More branches means more merging, which is a pain in itself, and more integration hell. It's far better to do continuous integration to a single codeline. If your deployment process is any more involved than branch, test, go live, then an advantage of branch-by-release is that you can have multiple release branches going at once, in different phases: one live and being bugfixed as necessary, and another one being stabilised, tested, going through acceptance, etc, while development continues on the trunk. If you have a live trunk, on the other hand, once you merge a feature branch in with a view to taking it live, you've lost your ability to do bugfixes to the current live system. The feature branch merge becomes a point of no return.
***These choices are not mutually exclusive - use both.*** They solve different problems: **"Branch by release"** - release branch is used to ensure you can back to the source used to produce the current live version (or previous released versions) while the next version is in development. E.g. This is in order to make changes to the release version for bug fixes or backpatch features from the current development trunk. **"Branch by feature"** - used to keep a stable development trunk at all times, which is particularly useful for multiple developers and for experimental "maybe" features. I would use both, but you can forego one of the approaches if the problem it solves doesn't apply to you or if you have a different solution that problem. I strongly recommend using a modern DVCS like git or Mercurial. They are geared at parallel development, so they store changes differently than older systems, which makes merging much saner.
4,509,658
I am trying to decide on the best branching strategy for a web application project. Here is what I have come up with until now and I would greatly appreciate any comments and experiences. The way I see it there are two main branching strategies: "branch by release" and "branch by feature". **"Branch by release"**: Development takes place on the trunk. When the time for a release is near, a branch is made for that release. This branch is then stabilized/tested and finally a release is made. After the release, the branch is merged back into the trunk, while keeping the release branch alive for bug-fixing. Is a bug-fix applied, then it is merged into the trunk ( if the development on the trunk hasn't eclipsed the bug in other means). New features are added to the trunk and don't affect the release branch. When a new release time nears, a new release branch is created a.s.o. **"Branch by feature"**: The trunk is always the "production" trunk (the code that is live). Bugfixes are commited directly to the trunk. Features for the next release are developed in feature branches.Bugfixes are merged from time-to-time into the feature branches. When release time comes, the features branches are merged into the trunk and the cycle of life continues. Now the way I see it the big practical difference between these two strategies is that "by release" allows you to maintane different production versions of you software ( when client A has version 1 and client B version 1.5, client is the paying customer in this case). In contrast using the "by feature" strategy you can only support the current production version ( all clients are using latest version). Since in a typical *web application* all clients are using the same "latest" version (since they all access the same server), I would assume that the "by feature" approach is the most commonly used. It removes the need to merge "across the hierarchy", say when a bugfix has to be applied to all 3 release versions. So my current status is that I should go with "branch by feature". If it matters, my team is not very skilled.
2010/12/22
[ "https://Stackoverflow.com/questions/4509658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110453/" ]
If you only have one release live at any time, and you do all development in a single feature branch, then these approaches are effectively the same. If branch-by-feature to you means having a several branches on the go at once, i'd avoid it like the plague. More branches means more merging, which is a pain in itself, and more integration hell. It's far better to do continuous integration to a single codeline. If your deployment process is any more involved than branch, test, go live, then an advantage of branch-by-release is that you can have multiple release branches going at once, in different phases: one live and being bugfixed as necessary, and another one being stabilised, tested, going through acceptance, etc, while development continues on the trunk. If you have a live trunk, on the other hand, once you merge a feature branch in with a view to taking it live, you've lost your ability to do bugfixes to the current live system. The feature branch merge becomes a point of no return.
At the risk of confusing you further: you can have release branches **and** make all changes on feature branches. These things are not mutually exclusive. That being said, it sounds like you don't need parallel release families and you want to deploy often, perhaps even [continuously](http://radar.oreilly.com/2009/03/continuous-deployment-5-eas.html). So you would want to have a "stable trunk" that you can release at any time. Feature branches help to keep the trunk stable, because you only merge back to the trunk when the changes are done and have proven themselves. So I'd say that your choice is a good fit.
4,509,658
I am trying to decide on the best branching strategy for a web application project. Here is what I have come up with until now and I would greatly appreciate any comments and experiences. The way I see it there are two main branching strategies: "branch by release" and "branch by feature". **"Branch by release"**: Development takes place on the trunk. When the time for a release is near, a branch is made for that release. This branch is then stabilized/tested and finally a release is made. After the release, the branch is merged back into the trunk, while keeping the release branch alive for bug-fixing. Is a bug-fix applied, then it is merged into the trunk ( if the development on the trunk hasn't eclipsed the bug in other means). New features are added to the trunk and don't affect the release branch. When a new release time nears, a new release branch is created a.s.o. **"Branch by feature"**: The trunk is always the "production" trunk (the code that is live). Bugfixes are commited directly to the trunk. Features for the next release are developed in feature branches.Bugfixes are merged from time-to-time into the feature branches. When release time comes, the features branches are merged into the trunk and the cycle of life continues. Now the way I see it the big practical difference between these two strategies is that "by release" allows you to maintane different production versions of you software ( when client A has version 1 and client B version 1.5, client is the paying customer in this case). In contrast using the "by feature" strategy you can only support the current production version ( all clients are using latest version). Since in a typical *web application* all clients are using the same "latest" version (since they all access the same server), I would assume that the "by feature" approach is the most commonly used. It removes the need to merge "across the hierarchy", say when a bugfix has to be applied to all 3 release versions. So my current status is that I should go with "branch by feature". If it matters, my team is not very skilled.
2010/12/22
[ "https://Stackoverflow.com/questions/4509658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110453/" ]
If you only have one release live at any time, and you do all development in a single feature branch, then these approaches are effectively the same. If branch-by-feature to you means having a several branches on the go at once, i'd avoid it like the plague. More branches means more merging, which is a pain in itself, and more integration hell. It's far better to do continuous integration to a single codeline. If your deployment process is any more involved than branch, test, go live, then an advantage of branch-by-release is that you can have multiple release branches going at once, in different phases: one live and being bugfixed as necessary, and another one being stabilised, tested, going through acceptance, etc, while development continues on the trunk. If you have a live trunk, on the other hand, once you merge a feature branch in with a view to taking it live, you've lost your ability to do bugfixes to the current live system. The feature branch merge becomes a point of no return.
What kind of software are you developing? Shrink wrap? Open Source Project? If so, then go with the "branch by release" or "unstable trunk" approach. Especially if your release cycles are every six months to a year apart. But if your maintaining a web-based project that has changes going out on shorter frequencies, like once every few weeks or less, then go with the "branch by feature" or "stable trunk" approach. The problem with this approach is integrating multiple feature changes that have sweeping changes make the merge process less than fun. It just really gets difficult. But both of those work well, but what if you need both? That is, you have a project that deploys says once every couple of weeks with big feature changes, but you find that you have a number of bug fixes that you cannot wait for those feature changes to be ready. Trunk is your release branch with the "branch by feature" approach. What if you could get both releases and features their own branch? Check out this [blog entry](http://blogs.open.collab.net/svn/2007/11/branching-strat.html) by CollabNet's Bob Archer. His Agile Release strategy gives you best of both. I've used this. It's extremely flexible. Even though Bob doesn't show it in his diagram, you can have multiple release branches going at the same time. This means you could have one release branch that is ready for rollout to production, and another that is being prepared for final QA checks. But two things to consider: First, how good are your developers at merging? You cannot do the the agile release strategy approach by yourself, even if it is a small team. Everyone has to do their part and they really have to understand merging and the tools they are using to do the merge. Secondly, you are going to need a good grasp on changes that ready and those that are about to be. Release management is key to making this work like clock work. Each feature when ready will need to get assigned to a release branch and merged to it. **Whatever approach you choose, it comes down to what you are developing and the frequency of changes you are releasing for that development.**
4,509,658
I am trying to decide on the best branching strategy for a web application project. Here is what I have come up with until now and I would greatly appreciate any comments and experiences. The way I see it there are two main branching strategies: "branch by release" and "branch by feature". **"Branch by release"**: Development takes place on the trunk. When the time for a release is near, a branch is made for that release. This branch is then stabilized/tested and finally a release is made. After the release, the branch is merged back into the trunk, while keeping the release branch alive for bug-fixing. Is a bug-fix applied, then it is merged into the trunk ( if the development on the trunk hasn't eclipsed the bug in other means). New features are added to the trunk and don't affect the release branch. When a new release time nears, a new release branch is created a.s.o. **"Branch by feature"**: The trunk is always the "production" trunk (the code that is live). Bugfixes are commited directly to the trunk. Features for the next release are developed in feature branches.Bugfixes are merged from time-to-time into the feature branches. When release time comes, the features branches are merged into the trunk and the cycle of life continues. Now the way I see it the big practical difference between these two strategies is that "by release" allows you to maintane different production versions of you software ( when client A has version 1 and client B version 1.5, client is the paying customer in this case). In contrast using the "by feature" strategy you can only support the current production version ( all clients are using latest version). Since in a typical *web application* all clients are using the same "latest" version (since they all access the same server), I would assume that the "by feature" approach is the most commonly used. It removes the need to merge "across the hierarchy", say when a bugfix has to be applied to all 3 release versions. So my current status is that I should go with "branch by feature". If it matters, my team is not very skilled.
2010/12/22
[ "https://Stackoverflow.com/questions/4509658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110453/" ]
***These choices are not mutually exclusive - use both.*** They solve different problems: **"Branch by release"** - release branch is used to ensure you can back to the source used to produce the current live version (or previous released versions) while the next version is in development. E.g. This is in order to make changes to the release version for bug fixes or backpatch features from the current development trunk. **"Branch by feature"** - used to keep a stable development trunk at all times, which is particularly useful for multiple developers and for experimental "maybe" features. I would use both, but you can forego one of the approaches if the problem it solves doesn't apply to you or if you have a different solution that problem. I strongly recommend using a modern DVCS like git or Mercurial. They are geared at parallel development, so they store changes differently than older systems, which makes merging much saner.
I tend to use Git for my projects, but the process I tend to follow goes like this (and should work for Subversion as well): * for each new feature, create a branch for that feature. * When everything works, merge it into the `staging` branch, and deploy it to the staging server (you do have one of those, right?) * Once we're sure the client is happy with what's on staging, we merge the staging branch into the production branch, tag it as something like `production_release_22` or `production_release_new_feature_x`, and then deploy that tag to the production server. Tags are *never*, *ever* updated - once something gets deployed, it stays that way until more changes are built, tested, and tagged - and then the new tag is deployed. By making sure that it's *tags* getting deployed and not *branches*, I keep myself (or others) from doing things like "I'll just commit this one quick change and update the server without testing it". It's worked pretty well for me so far.
4,509,658
I am trying to decide on the best branching strategy for a web application project. Here is what I have come up with until now and I would greatly appreciate any comments and experiences. The way I see it there are two main branching strategies: "branch by release" and "branch by feature". **"Branch by release"**: Development takes place on the trunk. When the time for a release is near, a branch is made for that release. This branch is then stabilized/tested and finally a release is made. After the release, the branch is merged back into the trunk, while keeping the release branch alive for bug-fixing. Is a bug-fix applied, then it is merged into the trunk ( if the development on the trunk hasn't eclipsed the bug in other means). New features are added to the trunk and don't affect the release branch. When a new release time nears, a new release branch is created a.s.o. **"Branch by feature"**: The trunk is always the "production" trunk (the code that is live). Bugfixes are commited directly to the trunk. Features for the next release are developed in feature branches.Bugfixes are merged from time-to-time into the feature branches. When release time comes, the features branches are merged into the trunk and the cycle of life continues. Now the way I see it the big practical difference between these two strategies is that "by release" allows you to maintane different production versions of you software ( when client A has version 1 and client B version 1.5, client is the paying customer in this case). In contrast using the "by feature" strategy you can only support the current production version ( all clients are using latest version). Since in a typical *web application* all clients are using the same "latest" version (since they all access the same server), I would assume that the "by feature" approach is the most commonly used. It removes the need to merge "across the hierarchy", say when a bugfix has to be applied to all 3 release versions. So my current status is that I should go with "branch by feature". If it matters, my team is not very skilled.
2010/12/22
[ "https://Stackoverflow.com/questions/4509658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110453/" ]
At the risk of confusing you further: you can have release branches **and** make all changes on feature branches. These things are not mutually exclusive. That being said, it sounds like you don't need parallel release families and you want to deploy often, perhaps even [continuously](http://radar.oreilly.com/2009/03/continuous-deployment-5-eas.html). So you would want to have a "stable trunk" that you can release at any time. Feature branches help to keep the trunk stable, because you only merge back to the trunk when the changes are done and have proven themselves. So I'd say that your choice is a good fit.
I tend to use Git for my projects, but the process I tend to follow goes like this (and should work for Subversion as well): * for each new feature, create a branch for that feature. * When everything works, merge it into the `staging` branch, and deploy it to the staging server (you do have one of those, right?) * Once we're sure the client is happy with what's on staging, we merge the staging branch into the production branch, tag it as something like `production_release_22` or `production_release_new_feature_x`, and then deploy that tag to the production server. Tags are *never*, *ever* updated - once something gets deployed, it stays that way until more changes are built, tested, and tagged - and then the new tag is deployed. By making sure that it's *tags* getting deployed and not *branches*, I keep myself (or others) from doing things like "I'll just commit this one quick change and update the server without testing it". It's worked pretty well for me so far.
4,509,658
I am trying to decide on the best branching strategy for a web application project. Here is what I have come up with until now and I would greatly appreciate any comments and experiences. The way I see it there are two main branching strategies: "branch by release" and "branch by feature". **"Branch by release"**: Development takes place on the trunk. When the time for a release is near, a branch is made for that release. This branch is then stabilized/tested and finally a release is made. After the release, the branch is merged back into the trunk, while keeping the release branch alive for bug-fixing. Is a bug-fix applied, then it is merged into the trunk ( if the development on the trunk hasn't eclipsed the bug in other means). New features are added to the trunk and don't affect the release branch. When a new release time nears, a new release branch is created a.s.o. **"Branch by feature"**: The trunk is always the "production" trunk (the code that is live). Bugfixes are commited directly to the trunk. Features for the next release are developed in feature branches.Bugfixes are merged from time-to-time into the feature branches. When release time comes, the features branches are merged into the trunk and the cycle of life continues. Now the way I see it the big practical difference between these two strategies is that "by release" allows you to maintane different production versions of you software ( when client A has version 1 and client B version 1.5, client is the paying customer in this case). In contrast using the "by feature" strategy you can only support the current production version ( all clients are using latest version). Since in a typical *web application* all clients are using the same "latest" version (since they all access the same server), I would assume that the "by feature" approach is the most commonly used. It removes the need to merge "across the hierarchy", say when a bugfix has to be applied to all 3 release versions. So my current status is that I should go with "branch by feature". If it matters, my team is not very skilled.
2010/12/22
[ "https://Stackoverflow.com/questions/4509658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110453/" ]
What kind of software are you developing? Shrink wrap? Open Source Project? If so, then go with the "branch by release" or "unstable trunk" approach. Especially if your release cycles are every six months to a year apart. But if your maintaining a web-based project that has changes going out on shorter frequencies, like once every few weeks or less, then go with the "branch by feature" or "stable trunk" approach. The problem with this approach is integrating multiple feature changes that have sweeping changes make the merge process less than fun. It just really gets difficult. But both of those work well, but what if you need both? That is, you have a project that deploys says once every couple of weeks with big feature changes, but you find that you have a number of bug fixes that you cannot wait for those feature changes to be ready. Trunk is your release branch with the "branch by feature" approach. What if you could get both releases and features their own branch? Check out this [blog entry](http://blogs.open.collab.net/svn/2007/11/branching-strat.html) by CollabNet's Bob Archer. His Agile Release strategy gives you best of both. I've used this. It's extremely flexible. Even though Bob doesn't show it in his diagram, you can have multiple release branches going at the same time. This means you could have one release branch that is ready for rollout to production, and another that is being prepared for final QA checks. But two things to consider: First, how good are your developers at merging? You cannot do the the agile release strategy approach by yourself, even if it is a small team. Everyone has to do their part and they really have to understand merging and the tools they are using to do the merge. Secondly, you are going to need a good grasp on changes that ready and those that are about to be. Release management is key to making this work like clock work. Each feature when ready will need to get assigned to a release branch and merged to it. **Whatever approach you choose, it comes down to what you are developing and the frequency of changes you are releasing for that development.**
I tend to use Git for my projects, but the process I tend to follow goes like this (and should work for Subversion as well): * for each new feature, create a branch for that feature. * When everything works, merge it into the `staging` branch, and deploy it to the staging server (you do have one of those, right?) * Once we're sure the client is happy with what's on staging, we merge the staging branch into the production branch, tag it as something like `production_release_22` or `production_release_new_feature_x`, and then deploy that tag to the production server. Tags are *never*, *ever* updated - once something gets deployed, it stays that way until more changes are built, tested, and tagged - and then the new tag is deployed. By making sure that it's *tags* getting deployed and not *branches*, I keep myself (or others) from doing things like "I'll just commit this one quick change and update the server without testing it". It's worked pretty well for me so far.
4,509,658
I am trying to decide on the best branching strategy for a web application project. Here is what I have come up with until now and I would greatly appreciate any comments and experiences. The way I see it there are two main branching strategies: "branch by release" and "branch by feature". **"Branch by release"**: Development takes place on the trunk. When the time for a release is near, a branch is made for that release. This branch is then stabilized/tested and finally a release is made. After the release, the branch is merged back into the trunk, while keeping the release branch alive for bug-fixing. Is a bug-fix applied, then it is merged into the trunk ( if the development on the trunk hasn't eclipsed the bug in other means). New features are added to the trunk and don't affect the release branch. When a new release time nears, a new release branch is created a.s.o. **"Branch by feature"**: The trunk is always the "production" trunk (the code that is live). Bugfixes are commited directly to the trunk. Features for the next release are developed in feature branches.Bugfixes are merged from time-to-time into the feature branches. When release time comes, the features branches are merged into the trunk and the cycle of life continues. Now the way I see it the big practical difference between these two strategies is that "by release" allows you to maintane different production versions of you software ( when client A has version 1 and client B version 1.5, client is the paying customer in this case). In contrast using the "by feature" strategy you can only support the current production version ( all clients are using latest version). Since in a typical *web application* all clients are using the same "latest" version (since they all access the same server), I would assume that the "by feature" approach is the most commonly used. It removes the need to merge "across the hierarchy", say when a bugfix has to be applied to all 3 release versions. So my current status is that I should go with "branch by feature". If it matters, my team is not very skilled.
2010/12/22
[ "https://Stackoverflow.com/questions/4509658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110453/" ]
What kind of software are you developing? Shrink wrap? Open Source Project? If so, then go with the "branch by release" or "unstable trunk" approach. Especially if your release cycles are every six months to a year apart. But if your maintaining a web-based project that has changes going out on shorter frequencies, like once every few weeks or less, then go with the "branch by feature" or "stable trunk" approach. The problem with this approach is integrating multiple feature changes that have sweeping changes make the merge process less than fun. It just really gets difficult. But both of those work well, but what if you need both? That is, you have a project that deploys says once every couple of weeks with big feature changes, but you find that you have a number of bug fixes that you cannot wait for those feature changes to be ready. Trunk is your release branch with the "branch by feature" approach. What if you could get both releases and features their own branch? Check out this [blog entry](http://blogs.open.collab.net/svn/2007/11/branching-strat.html) by CollabNet's Bob Archer. His Agile Release strategy gives you best of both. I've used this. It's extremely flexible. Even though Bob doesn't show it in his diagram, you can have multiple release branches going at the same time. This means you could have one release branch that is ready for rollout to production, and another that is being prepared for final QA checks. But two things to consider: First, how good are your developers at merging? You cannot do the the agile release strategy approach by yourself, even if it is a small team. Everyone has to do their part and they really have to understand merging and the tools they are using to do the merge. Secondly, you are going to need a good grasp on changes that ready and those that are about to be. Release management is key to making this work like clock work. Each feature when ready will need to get assigned to a release branch and merged to it. **Whatever approach you choose, it comes down to what you are developing and the frequency of changes you are releasing for that development.**
***These choices are not mutually exclusive - use both.*** They solve different problems: **"Branch by release"** - release branch is used to ensure you can back to the source used to produce the current live version (or previous released versions) while the next version is in development. E.g. This is in order to make changes to the release version for bug fixes or backpatch features from the current development trunk. **"Branch by feature"** - used to keep a stable development trunk at all times, which is particularly useful for multiple developers and for experimental "maybe" features. I would use both, but you can forego one of the approaches if the problem it solves doesn't apply to you or if you have a different solution that problem. I strongly recommend using a modern DVCS like git or Mercurial. They are geared at parallel development, so they store changes differently than older systems, which makes merging much saner.
4,509,658
I am trying to decide on the best branching strategy for a web application project. Here is what I have come up with until now and I would greatly appreciate any comments and experiences. The way I see it there are two main branching strategies: "branch by release" and "branch by feature". **"Branch by release"**: Development takes place on the trunk. When the time for a release is near, a branch is made for that release. This branch is then stabilized/tested and finally a release is made. After the release, the branch is merged back into the trunk, while keeping the release branch alive for bug-fixing. Is a bug-fix applied, then it is merged into the trunk ( if the development on the trunk hasn't eclipsed the bug in other means). New features are added to the trunk and don't affect the release branch. When a new release time nears, a new release branch is created a.s.o. **"Branch by feature"**: The trunk is always the "production" trunk (the code that is live). Bugfixes are commited directly to the trunk. Features for the next release are developed in feature branches.Bugfixes are merged from time-to-time into the feature branches. When release time comes, the features branches are merged into the trunk and the cycle of life continues. Now the way I see it the big practical difference between these two strategies is that "by release" allows you to maintane different production versions of you software ( when client A has version 1 and client B version 1.5, client is the paying customer in this case). In contrast using the "by feature" strategy you can only support the current production version ( all clients are using latest version). Since in a typical *web application* all clients are using the same "latest" version (since they all access the same server), I would assume that the "by feature" approach is the most commonly used. It removes the need to merge "across the hierarchy", say when a bugfix has to be applied to all 3 release versions. So my current status is that I should go with "branch by feature". If it matters, my team is not very skilled.
2010/12/22
[ "https://Stackoverflow.com/questions/4509658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110453/" ]
What kind of software are you developing? Shrink wrap? Open Source Project? If so, then go with the "branch by release" or "unstable trunk" approach. Especially if your release cycles are every six months to a year apart. But if your maintaining a web-based project that has changes going out on shorter frequencies, like once every few weeks or less, then go with the "branch by feature" or "stable trunk" approach. The problem with this approach is integrating multiple feature changes that have sweeping changes make the merge process less than fun. It just really gets difficult. But both of those work well, but what if you need both? That is, you have a project that deploys says once every couple of weeks with big feature changes, but you find that you have a number of bug fixes that you cannot wait for those feature changes to be ready. Trunk is your release branch with the "branch by feature" approach. What if you could get both releases and features their own branch? Check out this [blog entry](http://blogs.open.collab.net/svn/2007/11/branching-strat.html) by CollabNet's Bob Archer. His Agile Release strategy gives you best of both. I've used this. It's extremely flexible. Even though Bob doesn't show it in his diagram, you can have multiple release branches going at the same time. This means you could have one release branch that is ready for rollout to production, and another that is being prepared for final QA checks. But two things to consider: First, how good are your developers at merging? You cannot do the the agile release strategy approach by yourself, even if it is a small team. Everyone has to do their part and they really have to understand merging and the tools they are using to do the merge. Secondly, you are going to need a good grasp on changes that ready and those that are about to be. Release management is key to making this work like clock work. Each feature when ready will need to get assigned to a release branch and merged to it. **Whatever approach you choose, it comes down to what you are developing and the frequency of changes you are releasing for that development.**
At the risk of confusing you further: you can have release branches **and** make all changes on feature branches. These things are not mutually exclusive. That being said, it sounds like you don't need parallel release families and you want to deploy often, perhaps even [continuously](http://radar.oreilly.com/2009/03/continuous-deployment-5-eas.html). So you would want to have a "stable trunk" that you can release at any time. Feature branches help to keep the trunk stable, because you only merge back to the trunk when the changes are done and have proven themselves. So I'd say that your choice is a good fit.
9,802,812
I know that in ASP.NET web application, changing a DLL file located in the `bin` folder causes an application recycle. But I wonder, as the subject implies, whether **any** file changes cause such behavior? Are simple text files included in this scenario? And what about sub folders to `bin` folder? And their contents? I know I can try it out myself, but more importantly, I'm looking for proper documentation for this.
2012/03/21
[ "https://Stackoverflow.com/questions/9802812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17772/" ]
First, i can not provide a link to an official documentation. But from what i've read **every** change in the bin-folder(incl. subfolders) will cause the IIS to recycle the application domain. Abrupt Application Pool Recycling 1. Any modifications in the Application’s BIN Directory 2. Making changes in any Configuration File/s, like Web.config or others ( if you have any specific config file in your application say in a directory called App\_Config). 3. Making modifications in the Source code files in APP\_CODE Directory. This maybe change in any Source code files, or adding or deleting files from this directory. 4. Making changes in the Global.asax file 5. Making Changes in the Machine.config file. 6. Making any modifications in the Web Application’s Root Directory. This means creating files/subdirectories on the fly can lead to application pool recycling. 7. Modifications for references of Web Services of App\_WebReferences directory. 8. Modifying the Security Settings of any directory in the Root directory. (Like specifying read security rights for everyone or any other specific user or user group.) Here's some reading: 1. [What causes an application pool in IIS to recycle?](https://stackoverflow.com/questions/302110/what-causes-an-application-pool-in-iis-to-recycle) 2. <http://christopherdeweese.com/blog2/post/beware-writing-to-the-bin-folder-in-iis-hosted-services> 3. [What does an IISReset do?](https://stackoverflow.com/questions/23566/what-does-an-iisreset-do) 4. <http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/add/recycling> 5. [Managing, Tuning, and Configuring Application Pools in IIS 7.0](http://technet.microsoft.com/en-us/library/cc745955.aspx) 6. <http://varunvns.wordpress.com/2011/07/04/application-pool-restarts/>
NOPE, updating a dll file in the bin folder DOES NOT cause a recycle. At least not with .NET 4.7 on IIS 10 and later First, what is a "recycle"? --------------------------- It's when IIS launches a new instance of `w3wp` process and the old one is being "politely" terminated (after finishing up on all the requests and background tasks registered with `IRegisteredObject`) What happens when you update a file in /bin? -------------------------------------------- ASP.NET does a hot-reload: it detects the update and uses the new version of the .dll for new page requests from then on. I.e. reloads the "app-domain". But this happens within the same `w3wp` process. ([source](https://learn.microsoft.com/en-us/previous-versions/t990ks23(v=vs.140)?redirectedfrom=MSDN)) I just checked this on IIS 10 windows 2016 machine: launched Task Manager and repalce the main .dll file - the `w3wp` process kept running, nothing happened.
6,549,970
How would I go about implementing the MainPage class? ``` import cgi import os import logging from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.ext import db class Greeting(db.Model): #setting up database a = db.StringProperty(multiline=True) b = db.StringProperty(multiline=True) c = db.StringProperty(multiline=True) d = db.StringProperty(multiline=True) class MainPage(webapp.RequestHandler): def get(self): ##I want to access the content of the database here which is defined in Downloader class. ##For example let the value of greeting.a be assigned to alpha variable. #Entering data to the database class Downloader(webapp.RequestHandler): def get(self): greeting=Greeting() greeting.a=self.request.GET.get('a') greeting.b=self.request.GET.get('b') greeting.c=self.request.GET.get('c') greeting.d=self.request.GET.get('d') greeting.put() ```
2011/07/01
[ "https://Stackoverflow.com/questions/6549970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730047/" ]
Here is an alternate approach using `plyr`. It directly works with the original data frame `foo` and does not require converting `NA` into a date. The code is self-explanatory and very readable. Any comments are welcome. ``` dates = seq(as.POSIXct('2006-01-01'), as.POSIXct('2009-12-01'), by = "month") count = ldply(dates, function(d) with(foo, sum((Start < d) + (d < End | is.na(End)) == 2))) data.frame(dates, count) ```
Here's a *different* way that you might find easier: ``` foo<-data.frame(name=c("Bob","Sue", "Richard", "Jane"), Start=as.POSIXct(c("2006-03-23 GMT", "2007-01-20 GMT", "2007-01-20 GMT", "2006-03-23 GMT")), End=as.POSIXct(c("2009-01-20 GMT", NA, "2006-03-23 GMT", NA))) tmp <- expand.grid(foo$name,seq.POSIXt(as.POSIXct('2006-01-01'), as.POSIXct('2009-12-01'),by="month")) colnames(tmp) <- c('name','date') foo[is.na(foo)] <- max(tmp$date) + 1 tmp1 <- merge(tmp,foo,by="name") tmp2 <- tmp1$Start <= tmp1$date & tmp1$End >= tmp1$date aggregate(tmp2,by=list(date=tmp1$date),sum) ``` My two cents here are to use `seq.*` rather than `paste`ing dates together and that `ddply` is kind of an awkward tool if you're really just taking daterange one element at a time. I used `aggregate`, but you could have used `lapply` or something like that. You could compress this into fewer lines if you really want to, but readability will suffer.
276,816
It's not obvious to me..
2008/11/10
[ "https://Stackoverflow.com/questions/276816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
If you do kill TSVNCache, you don't need to manually restart it, the shell-extension will do that next time it needs it. If you're trying to restart the shell-extension, you might achieve it by killing all Explorer.exe processes, and anything else which has ended-up with TSVN in-process. This is basically any app which has asked the shell about icons, or has used the common file/directory dialogs. You may need to use something like "Process Explorer" (sysinternals) to find which processes have the TSVN DLLs loaded.
The background process that watches your file system for SVN related files and folders is TSVNCache.exe. You can kill that process and start it again, or just reboot your machine :)
276,816
It's not obvious to me..
2008/11/10
[ "https://Stackoverflow.com/questions/276816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
If you don't see the TortoiseSVN icons anymore you can restart `TSVNCache.exe` by navigating to TortoiseSVN's `bin` directory, e.g. `C:\Program Files\TortoiseSVN\bin`, and double clicking on it. Note that if you restart it in this way it will be killed when you logout. Otherwise follow the suggestions from the other answers.
The background process that watches your file system for SVN related files and folders is TSVNCache.exe. You can kill that process and start it again, or just reboot your machine :)
276,816
It's not obvious to me..
2008/11/10
[ "https://Stackoverflow.com/questions/276816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
If you do kill TSVNCache, you don't need to manually restart it, the shell-extension will do that next time it needs it. If you're trying to restart the shell-extension, you might achieve it by killing all Explorer.exe processes, and anything else which has ended-up with TSVN in-process. This is basically any app which has asked the shell about icons, or has used the common file/directory dialogs. You may need to use something like "Process Explorer" (sysinternals) to find which processes have the TSVN DLLs loaded.
If you don't see the TortoiseSVN icons anymore you can restart `TSVNCache.exe` by navigating to TortoiseSVN's `bin` directory, e.g. `C:\Program Files\TortoiseSVN\bin`, and double clicking on it. Note that if you restart it in this way it will be killed when you logout. Otherwise follow the suggestions from the other answers.
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
Another variation of `find_elements_by_xpath(".//*")` is: ``` from selenium.webdriver.common.by import By find_elements(By.XPATH, ".//*") ```
You can't use ``` all_children_by_css = header.find_elements_by_css_selector("*") ``` You now need to use ``` all_children_by_css = header.find_elements(By.XPATH, "*') ```
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
Yes, you can achieve it by `find_elements_by_css_selector("*")` or `find_elements_by_xpath(".//*")`. However, this doesn't sound like a valid use case to find **all children** of an element. It is an expensive operation to get all direct/indirect children. Please further explain what you are trying to do. There should be a better way. ``` from selenium import webdriver driver = webdriver.Firefox() driver.get("http://www.stackoverflow.com") header = driver.find_element_by_id("header") # start from your target element, here for example, "header" all_children_by_css = header.find_elements_by_css_selector("*") all_children_by_xpath = header.find_elements_by_xpath(".//*") print 'len(all_children_by_css): ' + str(len(all_children_by_css)) print 'len(all_children_by_xpath): ' + str(len(all_children_by_xpath)) ```
Another variation of `find_elements_by_xpath(".//*")` is: ``` from selenium.webdriver.common.by import By find_elements(By.XPATH, ".//*") ```
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
You can't use ``` all_children_by_css = header.find_elements_by_css_selector("*") ``` You now need to use ``` all_children_by_css = header.find_elements(By.XPATH, "*') ```
In 2022, with `selenium==4.2.0`, @Richard's answer will need to be rewritten as: ``` from selenium.webdriver.common.by import By parentElement = driver.find_element(By.CLASS_NAME,"bar") elementList = parentElement.find_elements(By.TAG_NAME,"li") ```
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
Yes, you can use `find_elements_by_` to retrieve children elements into a list. See the python bindings here: <http://selenium-python.readthedocs.io/locating-elements.html> Example HTML: ```html <ul class="bar"> <li>one</li> <li>two</li> <li>three</li> </ul> ``` You can use the `find_elements_by_` like so: ```py parentElement = driver.find_element_by_class_name("bar") elementList = parentElement.find_elements_by_tag_name("li") ``` If you want help with a specific case, you can edit your post with the HTML you're looking to get parent and children elements from.
You can use `get_attribute` and `BeautifulSoup` ``` html_str = el.get_attribute('innerHTML') bs = BeautifulSoup(html_str, 'lxml') ```
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
Yes, you can achieve it by `find_elements_by_css_selector("*")` or `find_elements_by_xpath(".//*")`. However, this doesn't sound like a valid use case to find **all children** of an element. It is an expensive operation to get all direct/indirect children. Please further explain what you are trying to do. There should be a better way. ``` from selenium import webdriver driver = webdriver.Firefox() driver.get("http://www.stackoverflow.com") header = driver.find_element_by_id("header") # start from your target element, here for example, "header" all_children_by_css = header.find_elements_by_css_selector("*") all_children_by_xpath = header.find_elements_by_xpath(".//*") print 'len(all_children_by_css): ' + str(len(all_children_by_css)) print 'len(all_children_by_xpath): ' + str(len(all_children_by_xpath)) ```
In 2022, with `selenium==4.2.0`, @Richard's answer will need to be rewritten as: ``` from selenium.webdriver.common.by import By parentElement = driver.find_element(By.CLASS_NAME,"bar") elementList = parentElement.find_elements(By.TAG_NAME,"li") ```
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
Yes, you can achieve it by `find_elements_by_css_selector("*")` or `find_elements_by_xpath(".//*")`. However, this doesn't sound like a valid use case to find **all children** of an element. It is an expensive operation to get all direct/indirect children. Please further explain what you are trying to do. There should be a better way. ``` from selenium import webdriver driver = webdriver.Firefox() driver.get("http://www.stackoverflow.com") header = driver.find_element_by_id("header") # start from your target element, here for example, "header" all_children_by_css = header.find_elements_by_css_selector("*") all_children_by_xpath = header.find_elements_by_xpath(".//*") print 'len(all_children_by_css): ' + str(len(all_children_by_css)) print 'len(all_children_by_xpath): ' + str(len(all_children_by_xpath)) ```
Yes, you can use `find_elements_by_` to retrieve children elements into a list. See the python bindings here: <http://selenium-python.readthedocs.io/locating-elements.html> Example HTML: ```html <ul class="bar"> <li>one</li> <li>two</li> <li>three</li> </ul> ``` You can use the `find_elements_by_` like so: ```py parentElement = driver.find_element_by_class_name("bar") elementList = parentElement.find_elements_by_tag_name("li") ``` If you want help with a specific case, you can edit your post with the HTML you're looking to get parent and children elements from.
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
You can use `get_attribute` and `BeautifulSoup` ``` html_str = el.get_attribute('innerHTML') bs = BeautifulSoup(html_str, 'lxml') ```
In 2022, with `selenium==4.2.0`, @Richard's answer will need to be rewritten as: ``` from selenium.webdriver.common.by import By parentElement = driver.find_element(By.CLASS_NAME,"bar") elementList = parentElement.find_elements(By.TAG_NAME,"li") ```
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
Yes, you can use `find_elements_by_` to retrieve children elements into a list. See the python bindings here: <http://selenium-python.readthedocs.io/locating-elements.html> Example HTML: ```html <ul class="bar"> <li>one</li> <li>two</li> <li>three</li> </ul> ``` You can use the `find_elements_by_` like so: ```py parentElement = driver.find_element_by_class_name("bar") elementList = parentElement.find_elements_by_tag_name("li") ``` If you want help with a specific case, you can edit your post with the HTML you're looking to get parent and children elements from.
You can't use ``` all_children_by_css = header.find_elements_by_css_selector("*") ``` You now need to use ``` all_children_by_css = header.find_elements(By.XPATH, "*') ```
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
Yes, you can achieve it by `find_elements_by_css_selector("*")` or `find_elements_by_xpath(".//*")`. However, this doesn't sound like a valid use case to find **all children** of an element. It is an expensive operation to get all direct/indirect children. Please further explain what you are trying to do. There should be a better way. ``` from selenium import webdriver driver = webdriver.Firefox() driver.get("http://www.stackoverflow.com") header = driver.find_element_by_id("header") # start from your target element, here for example, "header" all_children_by_css = header.find_elements_by_css_selector("*") all_children_by_xpath = header.find_elements_by_xpath(".//*") print 'len(all_children_by_css): ' + str(len(all_children_by_css)) print 'len(all_children_by_xpath): ' + str(len(all_children_by_xpath)) ```
You can use `get_attribute` and `BeautifulSoup` ``` html_str = el.get_attribute('innerHTML') bs = BeautifulSoup(html_str, 'lxml') ```
24,795,198
In Selenium with Python is it possible to get all the children of a WebElement as a list?
2014/07/17
[ "https://Stackoverflow.com/questions/24795198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672428/" ]
Another variation of `find_elements_by_xpath(".//*")` is: ``` from selenium.webdriver.common.by import By find_elements(By.XPATH, ".//*") ```
You can use `get_attribute` and `BeautifulSoup` ``` html_str = el.get_attribute('innerHTML') bs = BeautifulSoup(html_str, 'lxml') ```
8,586,225
I am using same php page for different operation. So condition wise I am doing some actions Which one showing good perfomance? ``` This one if($catid){ .. some action } if($sub_catid){ .. some action } if($sub_sub_catid){ .. some action } ``` OR This one ``` if($catid){ .. some action }else{ if($sub_catid){ .. some action }else{ if($sub_sub_catid){ .. some action } } } ```
2011/12/21
[ "https://Stackoverflow.com/questions/8586225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/669388/" ]
First off, those two have very different meanings. The first one could allow every single statement to execute if all those variables were TRUE. The second one will "short-circuit" the first time it finds something TRUE. What I think you're looking for is: ``` if($catid) { .. some action } else if($sub_catid) { .. some action } else if($sub_sub_catid) { .. some action } ``` Bonus points: more readable!
Both have a good performance. An if check on a simple variable is very fast. Theoretically the second is faster, but you will hardly be able to measure the difference. Semantically however, they are not the same. If both $catid and $subcatid are set, in the first situation, both the first and the second action are executed, while in the second situation, only the first action is executed. So always be careful with 'optimizations' like this. You may make your code a nanosecond faster, but it may be less readable and it may even break!
8,586,225
I am using same php page for different operation. So condition wise I am doing some actions Which one showing good perfomance? ``` This one if($catid){ .. some action } if($sub_catid){ .. some action } if($sub_sub_catid){ .. some action } ``` OR This one ``` if($catid){ .. some action }else{ if($sub_catid){ .. some action }else{ if($sub_sub_catid){ .. some action } } } ```
2011/12/21
[ "https://Stackoverflow.com/questions/8586225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/669388/" ]
First off, those two have very different meanings. The first one could allow every single statement to execute if all those variables were TRUE. The second one will "short-circuit" the first time it finds something TRUE. What I think you're looking for is: ``` if($catid) { .. some action } else if($sub_catid) { .. some action } else if($sub_sub_catid) { .. some action } ``` Bonus points: more readable!
if your conditions cannot be true at the same time the best way is to use the switch statement ``` switch($mycondition){ case 'category': //Category statement here break; case 'sub_category': //Another Statement here break; default: //Other cases } ```
8,586,225
I am using same php page for different operation. So condition wise I am doing some actions Which one showing good perfomance? ``` This one if($catid){ .. some action } if($sub_catid){ .. some action } if($sub_sub_catid){ .. some action } ``` OR This one ``` if($catid){ .. some action }else{ if($sub_catid){ .. some action }else{ if($sub_sub_catid){ .. some action } } } ```
2011/12/21
[ "https://Stackoverflow.com/questions/8586225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/669388/" ]
Both have a good performance. An if check on a simple variable is very fast. Theoretically the second is faster, but you will hardly be able to measure the difference. Semantically however, they are not the same. If both $catid and $subcatid are set, in the first situation, both the first and the second action are executed, while in the second situation, only the first action is executed. So always be careful with 'optimizations' like this. You may make your code a nanosecond faster, but it may be less readable and it may even break!
if your conditions cannot be true at the same time the best way is to use the switch statement ``` switch($mycondition){ case 'category': //Category statement here break; case 'sub_category': //Another Statement here break; default: //Other cases } ```
12,453,794
I was trying to send email through Appcelerator Cloud Service, in my Titanium app. The code I'm using is the standart one, given at the documentation site. But the email is not being sent. ``` Cloud.Emails.send({ template: 'welcome', recipients: '*******@gmail.com' }, function (e) { if (e.success) { Titanium.API.info('Email sent successfully.'); } else { Titanium.API.info('Error:\\n' + ((e.error && e.message) || JSON.stringify(e))); } }); ``` It give the this error, 'Email template welcome is not found'. I was thinking that template is the message to be sent in email. There is no help on API about this attribute , template. Can anybody explain it to me? I'll be thankful. Thanx
2012/09/17
[ "https://Stackoverflow.com/questions/12453794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1124928/" ]
The error shows that you haven't created an email template on the ACS website yet. The following steps will help you to create email template 1. Log in to your Appcelerator App Console 2. click "Manage ACS" under the app you're working on 3. click the "Email Templates" tab 4. "Create an Email Template". also you can setup your SMTP settings as follows which worked for me. **Username: *\_*\_\_*\_*\_\_\_\_@gmail.com Password: gmail account password TLS: true/ false (both will work) SMTP Address: smtp.gmail.com Port: *587* Domain : www.gmail.com**
That error means you haven't created an email template on the ACS website yet. Log in to your [Appcelerator App Console](https://my.appcelerator.com/apps/titanium), click "Manage ACS" under the app you're working on, then click the "Email Templates" tab, and "Create an Email Template".
41,795,668
So a list from 0 to 100 is created and I apply the formula in line two to make list B. The issue is that it's rounded to an int and I have been trying how to get it out to 3 decimals. ``` A = range(0,101) B = [(x-10)/3 for x in A] ``` Ex: If A = 11 (11-10)/3 = 0.333 instead of (11-10)/3 = 0. Thanks!
2017/01/22
[ "https://Stackoverflow.com/questions/41795668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The problem is with the design of the class. The default copy constructor will create a new instance of `Foo` when passed by **value** into the free standing function named `func`. When the instance of `Foo` named `f` exits scope then the code invokes the user-provided destructor that deletes the array of doubles. This opens the code to the unfortunate situation of deleting the same array twice when the original instance of `Foo` named `f` exits scope at the end of the program. When run on my machine, the code does not produce the same output. Instead I see two output lines of `0 3 6` followed by fault indicating the double free operation. The solution is to avoid the copy by passing by reference (or by const reference): `void func(Foo const &f) { }` or to supply a valid copy constructor that makes a deep copy of the underlying array. Passing by reference is just a bandaid that avoids exercising the bug. Using `std::vector<double>` fixes the problem because the default copy constructor will perform a deep copy and avoid double deallocation. This is absolutely the best approach in this small example, but it avoids having to understand the root of the problem. Most C++ developers will learn these techniques then promptly do what they can to avoid having to write code that manually allocates and deallocates memory.
One problem is that calling func creates a bitwise copy. When that copy goes out of scope the destructor is called which deletes your array. You should change void func(Foo f){} to void func(Foo& f){}. But better yet you add a create copy constructor or add a private declaration to stop it being called unexpectedly.
41,795,668
So a list from 0 to 100 is created and I apply the formula in line two to make list B. The issue is that it's rounded to an int and I have been trying how to get it out to 3 decimals. ``` A = range(0,101) B = [(x-10)/3 for x in A] ``` Ex: If A = 11 (11-10)/3 = 0.333 instead of (11-10)/3 = 0. Thanks!
2017/01/22
[ "https://Stackoverflow.com/questions/41795668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You should probably pass the object as a reference `func(Foo& f)` or - if you do not want to modify it at all - as a constant reference `func(const Foo& f)`. This will not create or delete any objects during the function call. Aside from that, as others have already mentioned, your class should better implement the Rule of Three.
One problem is that calling func creates a bitwise copy. When that copy goes out of scope the destructor is called which deletes your array. You should change void func(Foo f){} to void func(Foo& f){}. But better yet you add a create copy constructor or add a private declaration to stop it being called unexpectedly.
41,795,668
So a list from 0 to 100 is created and I apply the formula in line two to make list B. The issue is that it's rounded to an int and I have been trying how to get it out to 3 decimals. ``` A = range(0,101) B = [(x-10)/3 for x in A] ``` Ex: If A = 11 (11-10)/3 = 0.333 instead of (11-10)/3 = 0. Thanks!
2017/01/22
[ "https://Stackoverflow.com/questions/41795668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When you pass a value to a function, it is supposed to be copied. The destructor is run on the copy and should no effect on the original object. `Foo` fails to implement a copy constructor, so compiler provides the default one which simply performs a member-wise copy of the struct. As a result, the "copy" of `Foo` inside `Func` contains the same pointer as the original, and its destructor frees the data pointed to by both. In order to be usable by idiomatic C++ code, `Foo` **must** implement at least a copy constructor and an assignment operator in addition to the destructor. The rule that these three come together is sometimes referred to as "the rule of three", and is mentioned in other answers. Here is an (untested) example of what the constructors could look like: ``` Foo::Foo(const Foo& other) { // copy constructor: construct Foo given another Foo size = other->size; d = new double[size]; std::copy(other->d, other->d + size, d); } Foo& Foo::operator=(const Foo& other) { // assignment: reinitialize Foo with another Foo if (this != &other) { delete d; size = other->size; d = new double[size]; std::copy(other->d, other->d + size, d); } return *this; } ``` Additionally, you can also modify functions like `func` to accept a reference to `Foo` or a constant reference to `Foo` to avoid unnecessary copying. Doing this alone would also happen fix the immediate problem you are having, but it would not help other issues, so you should definitely implement a proper copy constructor before doing anything else. It's a good idea to get a good book on C++ where the rule of three and other C++ pitfalls are explained. Also, look into using STL containers such as `std::vector` as members. Since they implement the rule of three themselves, your class wouldn't need to.
One problem is that calling func creates a bitwise copy. When that copy goes out of scope the destructor is called which deletes your array. You should change void func(Foo f){} to void func(Foo& f){}. But better yet you add a create copy constructor or add a private declaration to stop it being called unexpectedly.
9,460,435
Can anybody tell me how to select data from two tables, without having to use join? Something like this: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 ``` ###Clarification I have these two tables, that have the same fields. IE: `table1` contains data from 2011 and `table2` contains data in 2012. I want to get them all. ###Further clarification: The result set desired can be produced by: ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ``` and the OP wishes to see if there are alternative ways to speed this up ("I tried to use `UNION` in between those queries. but query speed took 0.1887 secs. it's kinda slow.") (@Jetoox: if this is not your intent, please edit your question and clarify).
2012/02/27
[ "https://Stackoverflow.com/questions/9460435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175915/" ]
Just put the join condition in the WHERE clause: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 WHERE t1.id = t2.t1_id ``` That is an inner join, though. UPDATE ====== Upon looking at your queries: In this particular case, there is no relation between `tbl_transactions` and `tbl_transactions_bk_2012` (i.e. joining these on person\_key is meaningless because there is no relationship between the two tables in the way that (say) tbl\_transactions and persons are related). Then, you should use the `UNION` approach. Trying to join the first query to the second using either `JOIN` or `FROM xx, yy WHERE xx.id=yy.id` is meaningless and won't give you the results you need. By the way, in the future, put your current query/attempt in your post - as you can see it will prevent you from getting answers that aren't appropriate for your question (as my first attempt was).
``` select t1.*, t2.* from table1 t1, table2 t2 where t1.fkey = t2.pkey ```
9,460,435
Can anybody tell me how to select data from two tables, without having to use join? Something like this: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 ``` ###Clarification I have these two tables, that have the same fields. IE: `table1` contains data from 2011 and `table2` contains data in 2012. I want to get them all. ###Further clarification: The result set desired can be produced by: ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ``` and the OP wishes to see if there are alternative ways to speed this up ("I tried to use `UNION` in between those queries. but query speed took 0.1887 secs. it's kinda slow.") (@Jetoox: if this is not your intent, please edit your question and clarify).
2012/02/27
[ "https://Stackoverflow.com/questions/9460435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175915/" ]
Just put the join condition in the WHERE clause: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 WHERE t1.id = t2.t1_id ``` That is an inner join, though. UPDATE ====== Upon looking at your queries: In this particular case, there is no relation between `tbl_transactions` and `tbl_transactions_bk_2012` (i.e. joining these on person\_key is meaningless because there is no relationship between the two tables in the way that (say) tbl\_transactions and persons are related). Then, you should use the `UNION` approach. Trying to join the first query to the second using either `JOIN` or `FROM xx, yy WHERE xx.id=yy.id` is meaningless and won't give you the results you need. By the way, in the future, put your current query/attempt in your post - as you can see it will prevent you from getting answers that aren't appropriate for your question (as my first attempt was).
``` select t1.* , t2.* from t1, t2 where t1.id=t2.id; ```
9,460,435
Can anybody tell me how to select data from two tables, without having to use join? Something like this: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 ``` ###Clarification I have these two tables, that have the same fields. IE: `table1` contains data from 2011 and `table2` contains data in 2012. I want to get them all. ###Further clarification: The result set desired can be produced by: ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ``` and the OP wishes to see if there are alternative ways to speed this up ("I tried to use `UNION` in between those queries. but query speed took 0.1887 secs. it's kinda slow.") (@Jetoox: if this is not your intent, please edit your question and clarify).
2012/02/27
[ "https://Stackoverflow.com/questions/9460435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175915/" ]
Just put the join condition in the WHERE clause: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 WHERE t1.id = t2.t1_id ``` That is an inner join, though. UPDATE ====== Upon looking at your queries: In this particular case, there is no relation between `tbl_transactions` and `tbl_transactions_bk_2012` (i.e. joining these on person\_key is meaningless because there is no relationship between the two tables in the way that (say) tbl\_transactions and persons are related). Then, you should use the `UNION` approach. Trying to join the first query to the second using either `JOIN` or `FROM xx, yy WHERE xx.id=yy.id` is meaningless and won't give you the results you need. By the way, in the future, put your current query/attempt in your post - as you can see it will prevent you from getting answers that aren't appropriate for your question (as my first attempt was).
You want [`UNION`](http://dev.mysql.com/doc/refman/5.0/en/union.html). ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ```
9,460,435
Can anybody tell me how to select data from two tables, without having to use join? Something like this: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 ``` ###Clarification I have these two tables, that have the same fields. IE: `table1` contains data from 2011 and `table2` contains data in 2012. I want to get them all. ###Further clarification: The result set desired can be produced by: ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ``` and the OP wishes to see if there are alternative ways to speed this up ("I tried to use `UNION` in between those queries. but query speed took 0.1887 secs. it's kinda slow.") (@Jetoox: if this is not your intent, please edit your question and clarify).
2012/02/27
[ "https://Stackoverflow.com/questions/9460435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175915/" ]
Just put the join condition in the WHERE clause: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 WHERE t1.id = t2.t1_id ``` That is an inner join, though. UPDATE ====== Upon looking at your queries: In this particular case, there is no relation between `tbl_transactions` and `tbl_transactions_bk_2012` (i.e. joining these on person\_key is meaningless because there is no relationship between the two tables in the way that (say) tbl\_transactions and persons are related). Then, you should use the `UNION` approach. Trying to join the first query to the second using either `JOIN` or `FROM xx, yy WHERE xx.id=yy.id` is meaningless and won't give you the results you need. By the way, in the future, put your current query/attempt in your post - as you can see it will prevent you from getting answers that aren't appropriate for your question (as my first attempt was).
While using the UNION query, you may also want to add indexes to any columns that you are using to join and filter which will improve performance
9,460,435
Can anybody tell me how to select data from two tables, without having to use join? Something like this: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 ``` ###Clarification I have these two tables, that have the same fields. IE: `table1` contains data from 2011 and `table2` contains data in 2012. I want to get them all. ###Further clarification: The result set desired can be produced by: ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ``` and the OP wishes to see if there are alternative ways to speed this up ("I tried to use `UNION` in between those queries. but query speed took 0.1887 secs. it's kinda slow.") (@Jetoox: if this is not your intent, please edit your question and clarify).
2012/02/27
[ "https://Stackoverflow.com/questions/9460435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175915/" ]
You want [`UNION`](http://dev.mysql.com/doc/refman/5.0/en/union.html). ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ```
``` select t1.*, t2.* from table1 t1, table2 t2 where t1.fkey = t2.pkey ```
9,460,435
Can anybody tell me how to select data from two tables, without having to use join? Something like this: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 ``` ###Clarification I have these two tables, that have the same fields. IE: `table1` contains data from 2011 and `table2` contains data in 2012. I want to get them all. ###Further clarification: The result set desired can be produced by: ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ``` and the OP wishes to see if there are alternative ways to speed this up ("I tried to use `UNION` in between those queries. but query speed took 0.1887 secs. it's kinda slow.") (@Jetoox: if this is not your intent, please edit your question and clarify).
2012/02/27
[ "https://Stackoverflow.com/questions/9460435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175915/" ]
``` select t1.*, t2.* from table1 t1, table2 t2 where t1.fkey = t2.pkey ```
While using the UNION query, you may also want to add indexes to any columns that you are using to join and filter which will improve performance
9,460,435
Can anybody tell me how to select data from two tables, without having to use join? Something like this: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 ``` ###Clarification I have these two tables, that have the same fields. IE: `table1` contains data from 2011 and `table2` contains data in 2012. I want to get them all. ###Further clarification: The result set desired can be produced by: ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ``` and the OP wishes to see if there are alternative ways to speed this up ("I tried to use `UNION` in between those queries. but query speed took 0.1887 secs. it's kinda slow.") (@Jetoox: if this is not your intent, please edit your question and clarify).
2012/02/27
[ "https://Stackoverflow.com/questions/9460435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175915/" ]
You want [`UNION`](http://dev.mysql.com/doc/refman/5.0/en/union.html). ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ```
``` select t1.* , t2.* from t1, t2 where t1.id=t2.id; ```
9,460,435
Can anybody tell me how to select data from two tables, without having to use join? Something like this: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 ``` ###Clarification I have these two tables, that have the same fields. IE: `table1` contains data from 2011 and `table2` contains data in 2012. I want to get them all. ###Further clarification: The result set desired can be produced by: ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ``` and the OP wishes to see if there are alternative ways to speed this up ("I tried to use `UNION` in between those queries. but query speed took 0.1887 secs. it's kinda slow.") (@Jetoox: if this is not your intent, please edit your question and clarify).
2012/02/27
[ "https://Stackoverflow.com/questions/9460435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175915/" ]
``` select t1.* , t2.* from t1, t2 where t1.id=t2.id; ```
While using the UNION query, you may also want to add indexes to any columns that you are using to join and filter which will improve performance
9,460,435
Can anybody tell me how to select data from two tables, without having to use join? Something like this: ``` SELECT t1.*, t2.* FROM table1 t1, table2 t2 ``` ###Clarification I have these two tables, that have the same fields. IE: `table1` contains data from 2011 and `table2` contains data in 2012. I want to get them all. ###Further clarification: The result set desired can be produced by: ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ``` and the OP wishes to see if there are alternative ways to speed this up ("I tried to use `UNION` in between those queries. but query speed took 0.1887 secs. it's kinda slow.") (@Jetoox: if this is not your intent, please edit your question and clarify).
2012/02/27
[ "https://Stackoverflow.com/questions/9460435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175915/" ]
You want [`UNION`](http://dev.mysql.com/doc/refman/5.0/en/union.html). ``` (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '') UNION (SELECT tr.full_name, tr.headlines, tr.content, tr.stamp, tr.person_key FROM tbl_transactions_bk_2012 tr JOIN persons p ON p.person_key = tr.person_key JOIN teams t ON (pp.membership_id = t.id and pp.membership_type = 'teams') WHERE t.team_key = '' ```
While using the UNION query, you may also want to add indexes to any columns that you are using to join and filter which will improve performance
8,947,582
I'm trying to enumerate all hosts in an XML document, create a db entry for each host, then add each host's users (also from the XML document) to the db that are tied to that foreign key. The message box in the code below displays each user more times than there are `<user>` elements. I expected to see "a", "b" and "c" just twice each, but the code doesn't seem to stop displaying them. ``` private void simple_test() { var xml = "<root> <main> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> </main> </root>"; var xml_reader = XmlReader.Create(new StringReader(xml)); var xpath_doc = new XPathDocument(xml_reader); var xpath_nav = xpath_doc.CreateNavigator(); XPathExpression expr; expr = xpath_nav.Compile("//host/*"); var xpni = xpath_nav.Select(expr); while(xpni.MoveNext()) { if (xpni.Current == null) continue; var nav = xpni.Current.Clone(); expr = nav.Compile("//user/*"); var xpni2 = nav.Select(expr); while (xpni2.MoveNext()) { if (xpni2.Current == null) continue; var nav2 = xpni2.Current.Clone(); nav2.SelectSingleNode("//name"); MessageBox.Show(nav2.Value); } } } ```
2012/01/20
[ "https://Stackoverflow.com/questions/8947582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/511273/" ]
How about this: ``` private void simple_test() { var xml = "<root><main><host><sub><user><name>a</name></user><user><name>b</name></user><user><name>c</name></user></sub></host><host><sub><user><name>a</name></user><user><name>b</name></user><user><name>c</name></user></sub></host></main></root>"; var doc = XDocument.Parse(xml); foreach(var name in doc.descendants("name")){ MessageBox.Show(name.Value); } } ``` I didn't test but it should work. Good Luck!
``` var xml = "<root> <main> <host> <sub> <user> <name>a</name> </user> <user> <name>b</name> </user> <user> <name>c</name> </user> </sub> </host> <host> <sub> <user> <name>a</name> </user> <user> <name>b</name> </user> <user> <name>c</name> </user> </sub> </host> </main> </root>"; var doc = XDocument.Parse(xml); foreach(string name in doc.Descendants("name")) { MessageBox.Show(name); } ``` outputs: a b c a b c
8,947,582
I'm trying to enumerate all hosts in an XML document, create a db entry for each host, then add each host's users (also from the XML document) to the db that are tied to that foreign key. The message box in the code below displays each user more times than there are `<user>` elements. I expected to see "a", "b" and "c" just twice each, but the code doesn't seem to stop displaying them. ``` private void simple_test() { var xml = "<root> <main> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> </main> </root>"; var xml_reader = XmlReader.Create(new StringReader(xml)); var xpath_doc = new XPathDocument(xml_reader); var xpath_nav = xpath_doc.CreateNavigator(); XPathExpression expr; expr = xpath_nav.Compile("//host/*"); var xpni = xpath_nav.Select(expr); while(xpni.MoveNext()) { if (xpni.Current == null) continue; var nav = xpni.Current.Clone(); expr = nav.Compile("//user/*"); var xpni2 = nav.Select(expr); while (xpni2.MoveNext()) { if (xpni2.Current == null) continue; var nav2 = xpni2.Current.Clone(); nav2.SelectSingleNode("//name"); MessageBox.Show(nav2.Value); } } } ```
2012/01/20
[ "https://Stackoverflow.com/questions/8947582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/511273/" ]
As the others have demonstrated, there are more elegant ways to achieve what you need; however, if you’re looking for bugs in your code, here are two. First: ``` var nav2 = xpni.Current.Clone(); ``` should presumably be ``` var nav2 = xpni2.Current.Clone(); ``` Second: ``` expr = nav.Compile("//user/*"); ``` This would match *any* `user` elements in your document, and not just descendants of the current `sub`. Per the [XPath Examples](http://msdn.microsoft.com/en-us/library/ms256086.aspx) on MSDN: * `//author` matches all `<author>` elements in the document. * `.//title` matches all `<title>` elements one or more levels deep in the current context. Thus, if you want to match all `user` elements that are descendants of the current `sub` *at any level*, you may use: ``` expr = nav.Compile(".//user/*"); ``` In your case, since all `user` elements are direct children, it would be more efficient to use the following snippet: ``` expr = nav.Compile("./user/*"); ``` which is equivalent to: ``` expr = nav.Compile("user/*"); ``` This avoids unnecessarily traversing the hierarchy looking for deeper-nested elements which don’t exist. **Edit**: Removed some incorrect remarks pointed out in the comments.
How about this: ``` private void simple_test() { var xml = "<root><main><host><sub><user><name>a</name></user><user><name>b</name></user><user><name>c</name></user></sub></host><host><sub><user><name>a</name></user><user><name>b</name></user><user><name>c</name></user></sub></host></main></root>"; var doc = XDocument.Parse(xml); foreach(var name in doc.descendants("name")){ MessageBox.Show(name.Value); } } ``` I didn't test but it should work. Good Luck!
8,947,582
I'm trying to enumerate all hosts in an XML document, create a db entry for each host, then add each host's users (also from the XML document) to the db that are tied to that foreign key. The message box in the code below displays each user more times than there are `<user>` elements. I expected to see "a", "b" and "c" just twice each, but the code doesn't seem to stop displaying them. ``` private void simple_test() { var xml = "<root> <main> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> </main> </root>"; var xml_reader = XmlReader.Create(new StringReader(xml)); var xpath_doc = new XPathDocument(xml_reader); var xpath_nav = xpath_doc.CreateNavigator(); XPathExpression expr; expr = xpath_nav.Compile("//host/*"); var xpni = xpath_nav.Select(expr); while(xpni.MoveNext()) { if (xpni.Current == null) continue; var nav = xpni.Current.Clone(); expr = nav.Compile("//user/*"); var xpni2 = nav.Select(expr); while (xpni2.MoveNext()) { if (xpni2.Current == null) continue; var nav2 = xpni2.Current.Clone(); nav2.SelectSingleNode("//name"); MessageBox.Show(nav2.Value); } } } ```
2012/01/20
[ "https://Stackoverflow.com/questions/8947582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/511273/" ]
How about this: ``` private void simple_test() { var xml = "<root><main><host><sub><user><name>a</name></user><user><name>b</name></user><user><name>c</name></user></sub></host><host><sub><user><name>a</name></user><user><name>b</name></user><user><name>c</name></user></sub></host></main></root>"; var doc = XDocument.Parse(xml); foreach(var name in doc.descendants("name")){ MessageBox.Show(name.Value); } } ``` I didn't test but it should work. Good Luck!
**Use**: ``` /*/*/host[$k]/sub/user/name ``` where `$k` can take a value from 1 to `count(/*/*/host)`. **XSLT - based verification**: ``` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="/"> <xsl:for-each select="/*/*/host"> <xsl:variable name="vPos" select="position()"/> <xsl:copy-of select="/*/*/host[$vPos]/sub/user/name"/> ============ </xsl:for-each> </xsl:template> </xsl:stylesheet> ``` **When this transformation is applied on the following XML document** (the provided one, slightly modified so that the names under different slots are different): ``` <root> <main> <host> <sub> <user> <name>a</name> </user> <user> <name>b</name> </user> <user> <name>c</name> </user> </sub> </host> <host> <sub> <user> <name>a2</name> </user> <user> <name>b2</name> </user> <user> <name>c2</name> </user> </sub> </host> </main> </root> ``` **the wanted elements are selected and copied to the output**. In the output between two selection results there is a string delimiter ("========") to make the individual selection results easily identifiable: ``` <name>a</name> <name>b</name> <name>c</name> ============ <name>a2</name> <name>b2</name> <name>c2</name> ============ ```
8,947,582
I'm trying to enumerate all hosts in an XML document, create a db entry for each host, then add each host's users (also from the XML document) to the db that are tied to that foreign key. The message box in the code below displays each user more times than there are `<user>` elements. I expected to see "a", "b" and "c" just twice each, but the code doesn't seem to stop displaying them. ``` private void simple_test() { var xml = "<root> <main> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> </main> </root>"; var xml_reader = XmlReader.Create(new StringReader(xml)); var xpath_doc = new XPathDocument(xml_reader); var xpath_nav = xpath_doc.CreateNavigator(); XPathExpression expr; expr = xpath_nav.Compile("//host/*"); var xpni = xpath_nav.Select(expr); while(xpni.MoveNext()) { if (xpni.Current == null) continue; var nav = xpni.Current.Clone(); expr = nav.Compile("//user/*"); var xpni2 = nav.Select(expr); while (xpni2.MoveNext()) { if (xpni2.Current == null) continue; var nav2 = xpni2.Current.Clone(); nav2.SelectSingleNode("//name"); MessageBox.Show(nav2.Value); } } } ```
2012/01/20
[ "https://Stackoverflow.com/questions/8947582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/511273/" ]
As the others have demonstrated, there are more elegant ways to achieve what you need; however, if you’re looking for bugs in your code, here are two. First: ``` var nav2 = xpni.Current.Clone(); ``` should presumably be ``` var nav2 = xpni2.Current.Clone(); ``` Second: ``` expr = nav.Compile("//user/*"); ``` This would match *any* `user` elements in your document, and not just descendants of the current `sub`. Per the [XPath Examples](http://msdn.microsoft.com/en-us/library/ms256086.aspx) on MSDN: * `//author` matches all `<author>` elements in the document. * `.//title` matches all `<title>` elements one or more levels deep in the current context. Thus, if you want to match all `user` elements that are descendants of the current `sub` *at any level*, you may use: ``` expr = nav.Compile(".//user/*"); ``` In your case, since all `user` elements are direct children, it would be more efficient to use the following snippet: ``` expr = nav.Compile("./user/*"); ``` which is equivalent to: ``` expr = nav.Compile("user/*"); ``` This avoids unnecessarily traversing the hierarchy looking for deeper-nested elements which don’t exist. **Edit**: Removed some incorrect remarks pointed out in the comments.
``` var xml = "<root> <main> <host> <sub> <user> <name>a</name> </user> <user> <name>b</name> </user> <user> <name>c</name> </user> </sub> </host> <host> <sub> <user> <name>a</name> </user> <user> <name>b</name> </user> <user> <name>c</name> </user> </sub> </host> </main> </root>"; var doc = XDocument.Parse(xml); foreach(string name in doc.Descendants("name")) { MessageBox.Show(name); } ``` outputs: a b c a b c
8,947,582
I'm trying to enumerate all hosts in an XML document, create a db entry for each host, then add each host's users (also from the XML document) to the db that are tied to that foreign key. The message box in the code below displays each user more times than there are `<user>` elements. I expected to see "a", "b" and "c" just twice each, but the code doesn't seem to stop displaying them. ``` private void simple_test() { var xml = "<root> <main> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> <host> <sub> <user> <name> a </name> </user> <user> <name> b </name> </user> <user> <name> c </name> </user> </sub> </host> </main> </root>"; var xml_reader = XmlReader.Create(new StringReader(xml)); var xpath_doc = new XPathDocument(xml_reader); var xpath_nav = xpath_doc.CreateNavigator(); XPathExpression expr; expr = xpath_nav.Compile("//host/*"); var xpni = xpath_nav.Select(expr); while(xpni.MoveNext()) { if (xpni.Current == null) continue; var nav = xpni.Current.Clone(); expr = nav.Compile("//user/*"); var xpni2 = nav.Select(expr); while (xpni2.MoveNext()) { if (xpni2.Current == null) continue; var nav2 = xpni2.Current.Clone(); nav2.SelectSingleNode("//name"); MessageBox.Show(nav2.Value); } } } ```
2012/01/20
[ "https://Stackoverflow.com/questions/8947582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/511273/" ]
As the others have demonstrated, there are more elegant ways to achieve what you need; however, if you’re looking for bugs in your code, here are two. First: ``` var nav2 = xpni.Current.Clone(); ``` should presumably be ``` var nav2 = xpni2.Current.Clone(); ``` Second: ``` expr = nav.Compile("//user/*"); ``` This would match *any* `user` elements in your document, and not just descendants of the current `sub`. Per the [XPath Examples](http://msdn.microsoft.com/en-us/library/ms256086.aspx) on MSDN: * `//author` matches all `<author>` elements in the document. * `.//title` matches all `<title>` elements one or more levels deep in the current context. Thus, if you want to match all `user` elements that are descendants of the current `sub` *at any level*, you may use: ``` expr = nav.Compile(".//user/*"); ``` In your case, since all `user` elements are direct children, it would be more efficient to use the following snippet: ``` expr = nav.Compile("./user/*"); ``` which is equivalent to: ``` expr = nav.Compile("user/*"); ``` This avoids unnecessarily traversing the hierarchy looking for deeper-nested elements which don’t exist. **Edit**: Removed some incorrect remarks pointed out in the comments.
**Use**: ``` /*/*/host[$k]/sub/user/name ``` where `$k` can take a value from 1 to `count(/*/*/host)`. **XSLT - based verification**: ``` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="/"> <xsl:for-each select="/*/*/host"> <xsl:variable name="vPos" select="position()"/> <xsl:copy-of select="/*/*/host[$vPos]/sub/user/name"/> ============ </xsl:for-each> </xsl:template> </xsl:stylesheet> ``` **When this transformation is applied on the following XML document** (the provided one, slightly modified so that the names under different slots are different): ``` <root> <main> <host> <sub> <user> <name>a</name> </user> <user> <name>b</name> </user> <user> <name>c</name> </user> </sub> </host> <host> <sub> <user> <name>a2</name> </user> <user> <name>b2</name> </user> <user> <name>c2</name> </user> </sub> </host> </main> </root> ``` **the wanted elements are selected and copied to the output**. In the output between two selection results there is a string delimiter ("========") to make the individual selection results easily identifiable: ``` <name>a</name> <name>b</name> <name>c</name> ============ <name>a2</name> <name>b2</name> <name>c2</name> ============ ```
30,533,568
Is there any way prevent angular from auto trim for fields in the whole application? I know that I can prevent it for specified field using ngTrim directive, but it doesn't look good add this directive to all text fields in the application, is there any way do it for all fields in the angular module? Here is code, if you add add spaces in the begin of input they will not appear in label: ``` <div ng-app> <div ng-controller="TodoCtrl"> {{field}} <input type="text" ng-model="field"> </div> </div> ```
2015/05/29
[ "https://Stackoverflow.com/questions/30533568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2992825/" ]
You can extend [input[text]](https://docs.angularjs.org/api/ng/input/input%5Btext%5D) directive, the code below will automatically change the value of the attribute `ngTrim` to `false`: ``` .directive('input', function($compile){ // Runs during compile return { link(scope, iElement, iAttrs) { if (iElement.attr('type') === 'text') { iAttrs.$set('ngTrim', "false"); } } }; }); ``` Reference: <https://docs.angularjs.org/api/ng/type/>$compile.directive.Attributes ```html <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Example - example-text-input-directive</title> <script src="https://docs.angularjs.org/angular.min.js"></script> </head> <body ng-app="textInputExample"> <script> angular.module('textInputExample', []) .controller('ExampleController', ['$scope', function($scope) { $scope.example = { text: 'guest' }; }]) .directive('input', function($compile){ // Runs during compile return { link(scope, iElement, iAttrs) { if (iElement.attr('type') === 'text') { iAttrs.$set('ngTrim', "false"); } } }; }); </script> <form name="myForm" ng-controller="ExampleController"> <label>Single word: <input type="text" name="input" ng-model="example.text" required> </label> <div role="alert"> <span class="error" ng-show="myForm.input.$error.required"> Required!</span> <span class="error" ng-show="myForm.input.$error.pattern"> Single word only!</span> </div> <tt>text = {{example.text}} - 3</tt><br/> <tt>text = {{example.text.length}} - 3</tt><br/> <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/> <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/> <tt>myForm.$valid = {{myForm.$valid}}</tt><br/> <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/> </form> </body> </html> ``` **EDIT:** **How it works** 1) You can bind multiple directives to the same html element and they can share the same `$scope` and `$attributes`. 2) `iAttrs.$set('ngTrim', "false");` is updating the attribute `ng-trim`. You can't do this using normal dom manipulation because the dom is already compiled (<https://docs.angularjs.org/api/ng/service/>$compile) 3) Calling `iAttrs.$set` will trigger updates on all directives, so it will override the original `ng-trim` attribute value.
Another way to extend the `input` directive (or any directive/service, for that matter) is by using a [decorator](https://docs.angularjs.org/api/auto/service/$provide#decorator): ``` app.config(function($provide) { $provide.decorator('inputDirective', function($delegate) { var directive = $delegate[0], link = directive.link; link.post = function(scope, element, attrs) { attrs.$set('ngTrim', 'false'); }; return $delegate; }); }); ``` [Working Plunker](http://plnkr.co/edit/RqMEu46pihb2UCXUpSRt?p=preview) I personally prefer this approach because it allows me to execute the directive's original code, if needed. In this particular case that isn't necessary because the `input` directive has no link function, so you can simply provide your own without worrying about breaking anything.
1,414,358
I want to set the control binding property "updatesource=Explicit" in cs file (dynamically) not in UI end. Please help me how can i do this?
2009/09/12
[ "https://Stackoverflow.com/questions/1414358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
it works :) ``` this.GetBindingExpression(SomeProperty).ParentBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit; ```
Are you creating the binding in code manually? If so you can just set it like any other property: ``` var binding = new Binding("BindingPath") { Source = myDataObject, UpdateSourceTrigger = UpdateSourceTrigger.Explicit } textBlock.SetBinding(TextBlock.TextProperty, binding); ``` [More information here](http://msdn.microsoft.com/en-us/library/ms742863.aspx).
1,414,358
I want to set the control binding property "updatesource=Explicit" in cs file (dynamically) not in UI end. Please help me how can i do this?
2009/09/12
[ "https://Stackoverflow.com/questions/1414358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
it works :) ``` this.GetBindingExpression(SomeProperty).ParentBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit; ```
I tested it and it works. :-) The code remains the same as Gimalay's. ``` BindingExpression bindingExpr = this.textBox1.GetBindingExpression(TextBox.TextProperty); bindingExpr.ParentBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit; ```
46,728,366
I have some code that I found online that fits my project perfectly. The issue is that I don't use storyboards at all. Instead of using a storyboard file to create the UIView **`(CustomCallOutView)`**, I just create a class with a subclass of UIView. Here's the code that requires a nib file but I don't want to use them. How do I achieve this? The code is below. Thank you! ``` func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { // 1 if view.annotation is MKUserLocation { // Don't proceed with custom callout return } // 2 let starbucksAnnotation = view.annotation as! StarbucksAnnotation let views = Bundle.main.loadNibNamed("CustomCalloutView", owner: nil, options: nil) let calloutView = views?[0] as! CustomCalloutView calloutView.starbucksName.text = starbucksAnnotation.name calloutView.starbucksAddress.text = starbucksAnnotation.address calloutView.starbucksPhone.text = starbucksAnnotation.phone calloutView.starbucksImage.image = starbucksAnnotation.image let button = UIButton(frame: calloutView.starbucksPhone.frame) button.addTarget(self, action: #selector(ViewController.callPhoneNumber(sender:)), for: .touchUpInside) calloutView.addSubview(button) // 3 calloutView.center = CGPoint(x: view.bounds.size.width / 2, y: -calloutView.bounds.size.height*0.52) view.addSubview(calloutView) mapView.setCenter((view.annotation?.coordinate)!, animated: true) } ```
2017/10/13
[ "https://Stackoverflow.com/questions/46728366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6406541/" ]
I am not aware whether this is possible with a Wikipedia API function. However, it can be done using quite ordinary Python code. ``` >>> from lxml import html >>> import requests ``` Fetch the page that lists all of the featured articles. ``` >>> page = requests.get('https://en.wikipedia.org/wiki/Wikipedia:Featured_articles').content ``` Parse it suitably for search purposes. ``` >>> tree = html.fromstring(page) ``` Assume that we're searching for the wikipedia article entitled 'Melbourne Castle'. ``` >>> wiki_title = 'Melbourne Castle' ``` Find any links with this title. ``` >>> links = tree.xpath('.//a[@href="/wiki/%s"]'%wiki_title.replace(' ', '_')) ``` If `links` is a non-empty list, meaning that a link to an article with the title 'Melbourne Castle' has been found, then print a suitable result, or otherwise. ``` >>> if links: ... links[0].text + ' is a featured article' ... else: ... links[0].text + ' is NOT a featured article' ... 'Melbourne Castle is a featured article' ```
I just found a way to do that.I could get all the pages in a Category using `Categorymembers` <https://www.mediawiki.org/wiki/API:Categorymembers>
46,728,366
I have some code that I found online that fits my project perfectly. The issue is that I don't use storyboards at all. Instead of using a storyboard file to create the UIView **`(CustomCallOutView)`**, I just create a class with a subclass of UIView. Here's the code that requires a nib file but I don't want to use them. How do I achieve this? The code is below. Thank you! ``` func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { // 1 if view.annotation is MKUserLocation { // Don't proceed with custom callout return } // 2 let starbucksAnnotation = view.annotation as! StarbucksAnnotation let views = Bundle.main.loadNibNamed("CustomCalloutView", owner: nil, options: nil) let calloutView = views?[0] as! CustomCalloutView calloutView.starbucksName.text = starbucksAnnotation.name calloutView.starbucksAddress.text = starbucksAnnotation.address calloutView.starbucksPhone.text = starbucksAnnotation.phone calloutView.starbucksImage.image = starbucksAnnotation.image let button = UIButton(frame: calloutView.starbucksPhone.frame) button.addTarget(self, action: #selector(ViewController.callPhoneNumber(sender:)), for: .touchUpInside) calloutView.addSubview(button) // 3 calloutView.center = CGPoint(x: view.bounds.size.width / 2, y: -calloutView.bounds.size.height*0.52) view.addSubview(calloutView) mapView.setCenter((view.annotation?.coordinate)!, animated: true) } ```
2017/10/13
[ "https://Stackoverflow.com/questions/46728366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6406541/" ]
Probably the most semantic and portable approach is checking for [Wikidata badges](https://www.wikidata.org/wiki/Help:Badges) ([example](https://www.wikidata.org/wiki/Special:ApiSandbox#action=wbgetentities&format=json&sites=enwiki&titles=Melbourne%20Castle&props=sitelinks&sitefilter=enwiki&formatversion=2)) although the repsonse format is a bit obscure. Alternatively, you can check for the featured article category via the `list=categorymembers` API module or for the featured article template via the `prop=transcludedin` module.
I just found a way to do that.I could get all the pages in a Category using `Categorymembers` <https://www.mediawiki.org/wiki/API:Categorymembers>
90,984
I'm about to start a campaign using MgT 2e and I have tons of GT material but I've read over and over again how **Behind the Claw** (for GT) differs from **OTU**. I'm not interested on moving rules from GURPS to MgT 2e, but information, so I just want to know which are the points where **GT** background is different from **OTU** (beyond the Dulinor issues). Bear in mind that I intend to play the *Golden Age* (1105-) or just after the *Fifth Frontier War*.
2016/11/29
[ "https://rpg.stackexchange.com/questions/90984", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/7885/" ]
Take an leaf from (historical) fiction ====================================== [Das Boat's convoy attack](https://www.youtube.com/watch?v=_jP-eOrv2Ok) is a good example of a submarine fight. The book is very good too. You could easily adapt this to a space opera setting. The [Master and Commander](http://www.imdb.com/title/tt0311113/) film (and book) are another good example where ship-to-ship combat. Finally, [Midway](http://www.imdb.com/title/tt0074899/) is a great film focusing on both the air and naval sides of the battle. Space opera generally tend to see space as either submarine warfare ([The Expanse](http://www.imdb.com/title/tt3230854/?ref_=fn_al_tt_1)) or glorified air plane combat ([Cowboy Bebop](http://www.imdb.com/title/tt0213338/?ref_=fn_al_tt_1), Star Wars). Of course, all of them take their inspiration for real life™. You could do that too: [Raid on the Medway](https://en.wikipedia.org/wiki/Raid_on_the_Medway) for example. So, do what these guys do: use limited information to build tension, raise the stakes, and then explode in a fast ball of fire! Repeat. Why the battle matters? ======================= The game should be about the player characters, so that is where your focus should go. Ships blowing up are good special effects that can be seen but rarely interacted with. Why are the players there? What are they trying to achieve? Once you have an answer to that, you can make combat more interesting by focusing on what the players do, not the ships. It is the hundred of small decisions in the middle of the battle that matters: Do we support ship X or attack ship Z? Do we keep firing on ship A to sink it, or do we allow it to flee? Do we move to intercept T or just fire some torpedoes? Do we try to disengage or keep close to their capital ship? How are we dealing with damage to the ship? Finally, combat takes a long time (hours/days), which is generally not modelled well by RPG systems: so use more descriptions rather than tactical info dumps. You can, of course, focus the action from time to time where critical events happen.
A quick solution can be to force a **choice from the players**. Basically it means that on the standard turn they won't be able to perfectly fill all the roles so they will have to choose which ones are filled and which ones are not. For example in your ship you can have the following roles: commander (who give bonuses to morale tests), seeker (who make the ship able to react in case of imminent danger), gunner (who attack the enemy), pilot (who makes the ship dodge), shipwright (who repairs the damages)... You can imagine the unfilled roles as under the responsibility of a random NPC who will do the job but without giving bonuses. Each turn, make your player decide which roles they want to do. The role can be more or less useful depending on the situation (in close-quarter combat the seeker becomes less useful for example), and PCs will be more or less good at each role. For some roles you may discourage, or even forbid, that two PCs fill it (by making the bonuses from the second PC less important for example). Add to that some events that will accentuate the need for all the roles, and your players will really have to choose. For example: * the rudder is damaged by a previous salve, piloting becomes very difficult (malus), but a quick repair would fix that. * fog raises, and without a seeker it becomes very difficult to aim these fires. * some members of the crew fell from the ship, without a rescuer they are in big trouble * there is a weird sound coming from the south, what is it ? Maybe it would worth that someone prepares for a counter-measure. Maybe not. * the enemy have started firing gold coins. Your pirate crew is trying to gather them and don't answer your orders anymore, unless a talented commander give them an earbashing. This solution is inspired by a homemade space-op system I played with (not as the GM).
90,984
I'm about to start a campaign using MgT 2e and I have tons of GT material but I've read over and over again how **Behind the Claw** (for GT) differs from **OTU**. I'm not interested on moving rules from GURPS to MgT 2e, but information, so I just want to know which are the points where **GT** background is different from **OTU** (beyond the Dulinor issues). Bear in mind that I intend to play the *Golden Age* (1105-) or just after the *Fifth Frontier War*.
2016/11/29
[ "https://rpg.stackexchange.com/questions/90984", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/7885/" ]
Take an leaf from (historical) fiction ====================================== [Das Boat's convoy attack](https://www.youtube.com/watch?v=_jP-eOrv2Ok) is a good example of a submarine fight. The book is very good too. You could easily adapt this to a space opera setting. The [Master and Commander](http://www.imdb.com/title/tt0311113/) film (and book) are another good example where ship-to-ship combat. Finally, [Midway](http://www.imdb.com/title/tt0074899/) is a great film focusing on both the air and naval sides of the battle. Space opera generally tend to see space as either submarine warfare ([The Expanse](http://www.imdb.com/title/tt3230854/?ref_=fn_al_tt_1)) or glorified air plane combat ([Cowboy Bebop](http://www.imdb.com/title/tt0213338/?ref_=fn_al_tt_1), Star Wars). Of course, all of them take their inspiration for real life™. You could do that too: [Raid on the Medway](https://en.wikipedia.org/wiki/Raid_on_the_Medway) for example. So, do what these guys do: use limited information to build tension, raise the stakes, and then explode in a fast ball of fire! Repeat. Why the battle matters? ======================= The game should be about the player characters, so that is where your focus should go. Ships blowing up are good special effects that can be seen but rarely interacted with. Why are the players there? What are they trying to achieve? Once you have an answer to that, you can make combat more interesting by focusing on what the players do, not the ships. It is the hundred of small decisions in the middle of the battle that matters: Do we support ship X or attack ship Z? Do we keep firing on ship A to sink it, or do we allow it to flee? Do we move to intercept T or just fire some torpedoes? Do we try to disengage or keep close to their capital ship? How are we dealing with damage to the ship? Finally, combat takes a long time (hours/days), which is generally not modelled well by RPG systems: so use more descriptions rather than tactical info dumps. You can, of course, focus the action from time to time where critical events happen.
My answer is for my experience with space battles not sea. Space battles in most games I have run tend to have terrible rules that bear little relation to how things move in space or the vast distances and ridiculous speeds. Space battles seem to me to be games of chess, with ships dancing around each other trying to get a line of fire on the enemy while avoiding having the same occur to them. As the point that a large lance weapon or broadside can be brought to bear the game is often over. Boarding in space is more fun as you have to match velocity to dock/storm the vessel or have some kind of teleporter or boarding shuttles. To keep this fluid I tend to bin most movement rules(most of the rules) in the system. And take speed as the change in velocity a ship can affect. Also rotating on the spot in space takes virtually no effort, but changing direction should be difficult. I take acceleration/speed to be in mm so a speed of 6 is 6mm/turn/turn on the table, as after a few turns of combat you can be covering large distances. So if travelling in a straight line you cover 6mm in first turn 12mm in second, 18 in third etc. So you can go very "fast" but stopping or turning becomes more difficult the faster you go. I clear as large a table as possible. Battle start far apart, space is big and I like this to be represented. I also give players 60 seconds to plan their next move; so if flows quickly. If they don't give me written instructions at the 60s mark then they continue to do what they did last turn. Think of it like a bridge on a ship where the command staff discuss tactics and plan and then pass notes to the helmsman and gunnery staff. I also have to have written down what I am going to do with the NPC ships before I look at their notes. Often for enemy ships I have a plan and contingencies and follow them so I as GM can't be accused of cheating. I find the dancing is the fun, there are very few dice roles unless you want to overdirve the engines or jury rig your ship in some silly way. The game flows as the ships close or circle each other. The roles are only needed for targeting, firing and damage. I don't know if this is what you were looking for but my players really enjoyed their space battles when run this way. Try it, see what works and what doesn't for you and tweak as needed.
90,984
I'm about to start a campaign using MgT 2e and I have tons of GT material but I've read over and over again how **Behind the Claw** (for GT) differs from **OTU**. I'm not interested on moving rules from GURPS to MgT 2e, but information, so I just want to know which are the points where **GT** background is different from **OTU** (beyond the Dulinor issues). Bear in mind that I intend to play the *Golden Age* (1105-) or just after the *Fifth Frontier War*.
2016/11/29
[ "https://rpg.stackexchange.com/questions/90984", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/7885/" ]
Take an leaf from (historical) fiction ====================================== [Das Boat's convoy attack](https://www.youtube.com/watch?v=_jP-eOrv2Ok) is a good example of a submarine fight. The book is very good too. You could easily adapt this to a space opera setting. The [Master and Commander](http://www.imdb.com/title/tt0311113/) film (and book) are another good example where ship-to-ship combat. Finally, [Midway](http://www.imdb.com/title/tt0074899/) is a great film focusing on both the air and naval sides of the battle. Space opera generally tend to see space as either submarine warfare ([The Expanse](http://www.imdb.com/title/tt3230854/?ref_=fn_al_tt_1)) or glorified air plane combat ([Cowboy Bebop](http://www.imdb.com/title/tt0213338/?ref_=fn_al_tt_1), Star Wars). Of course, all of them take their inspiration for real life™. You could do that too: [Raid on the Medway](https://en.wikipedia.org/wiki/Raid_on_the_Medway) for example. So, do what these guys do: use limited information to build tension, raise the stakes, and then explode in a fast ball of fire! Repeat. Why the battle matters? ======================= The game should be about the player characters, so that is where your focus should go. Ships blowing up are good special effects that can be seen but rarely interacted with. Why are the players there? What are they trying to achieve? Once you have an answer to that, you can make combat more interesting by focusing on what the players do, not the ships. It is the hundred of small decisions in the middle of the battle that matters: Do we support ship X or attack ship Z? Do we keep firing on ship A to sink it, or do we allow it to flee? Do we move to intercept T or just fire some torpedoes? Do we try to disengage or keep close to their capital ship? How are we dealing with damage to the ship? Finally, combat takes a long time (hours/days), which is generally not modelled well by RPG systems: so use more descriptions rather than tactical info dumps. You can, of course, focus the action from time to time where critical events happen.
What I found in sea or space battles is that players have no clue what ships look like. No matter how popular you think the ships are, some of your players will not be able to visualize them in the detail you expect. Take for example a [three master](https://www.google.de/search?q=three+master&tbm=isch&tbo=u&source=univ&sa=X&ved=0ahUKEwi4o6uVoM7QAhXkDZoKHWPRCZ8QsAQILA&biw=1433&bih=760). If the DM says something like "after the smoke of your broadside clears, you see the enemy ship has sustained heavy damage, it's foremast broken and hanging over the side", expect players to not be able to accurately describe the scene, no matter how many popular movies you have seen and you *think* they have seen. And it gets even worse with space battles, with all kind of popular fiction depicting ships differently. Make sure you have pictures or props of the ships or ideally, both. Being able to picture the scene, even if the pictures are given, is a huge boost in playability. Prepare in advance as a DM, so you have pictures of possible encounters, possible damage and other outcomes (beaches, asteroids, whatever). Rogue Trader and 40K for example has a very distinct style and that style is a big part of how it *feels*. Fighting an Ork dreadnought or a sleek Eldar frigate *feels* completely different even if you are rolling the same dice. There's pictures of both all over the net. And if you want to have a great evening, maybe you can find some Battlefleet Gothic miniatures to put in the middle of the table. Now if you and your players are unhappy with the *system* I guess you need to find a better system. Personally, I was happy with Rogue Trader, but if you are not, maybe it's just not the right system for you.
90,984
I'm about to start a campaign using MgT 2e and I have tons of GT material but I've read over and over again how **Behind the Claw** (for GT) differs from **OTU**. I'm not interested on moving rules from GURPS to MgT 2e, but information, so I just want to know which are the points where **GT** background is different from **OTU** (beyond the Dulinor issues). Bear in mind that I intend to play the *Golden Age* (1105-) or just after the *Fifth Frontier War*.
2016/11/29
[ "https://rpg.stackexchange.com/questions/90984", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/7885/" ]
Take an leaf from (historical) fiction ====================================== [Das Boat's convoy attack](https://www.youtube.com/watch?v=_jP-eOrv2Ok) is a good example of a submarine fight. The book is very good too. You could easily adapt this to a space opera setting. The [Master and Commander](http://www.imdb.com/title/tt0311113/) film (and book) are another good example where ship-to-ship combat. Finally, [Midway](http://www.imdb.com/title/tt0074899/) is a great film focusing on both the air and naval sides of the battle. Space opera generally tend to see space as either submarine warfare ([The Expanse](http://www.imdb.com/title/tt3230854/?ref_=fn_al_tt_1)) or glorified air plane combat ([Cowboy Bebop](http://www.imdb.com/title/tt0213338/?ref_=fn_al_tt_1), Star Wars). Of course, all of them take their inspiration for real life™. You could do that too: [Raid on the Medway](https://en.wikipedia.org/wiki/Raid_on_the_Medway) for example. So, do what these guys do: use limited information to build tension, raise the stakes, and then explode in a fast ball of fire! Repeat. Why the battle matters? ======================= The game should be about the player characters, so that is where your focus should go. Ships blowing up are good special effects that can be seen but rarely interacted with. Why are the players there? What are they trying to achieve? Once you have an answer to that, you can make combat more interesting by focusing on what the players do, not the ships. It is the hundred of small decisions in the middle of the battle that matters: Do we support ship X or attack ship Z? Do we keep firing on ship A to sink it, or do we allow it to flee? Do we move to intercept T or just fire some torpedoes? Do we try to disengage or keep close to their capital ship? How are we dealing with damage to the ship? Finally, combat takes a long time (hours/days), which is generally not modelled well by RPG systems: so use more descriptions rather than tactical info dumps. You can, of course, focus the action from time to time where critical events happen.
As a Rogue Trader RPG veteran, I understand your problem. RT is trying to combine two distinct gaming experiences; RPG’s and wargaming. In wargaming, the pleasure is derived from fighting the battles according to the rules with the players commanding either units or parts of the battlefield. In RPG’s, the players play their characters. It’s the combination that fails IMO. Our solution was to throw away the minutiae of ship fighting and make it a more of a RPG session. So instead of mapping out the manoeuvres, broadsides etc., change it into a story in which the players have certain parts to play. And use the crew’s rating, not the players for the ship’s rolls. Players can give a bonus but it makes no sense that for example a single player’s gunnery rating works for a ship of 100,000 crew…. So describe noticing the enemy ship on the scanners (perhaps insert a scene where the scanners go on the fritz and the tech-priest has to fix it), manoeuvring the ship into an advantageous combat position (insert scene where a rudder fails, the engines go off-line, zombies come crawling out of the ventilation ducts, the crew needs a hearty speech etc.), then describe the first salvoes and roll for damage. Describe the effect of damage on your ship and then let the players effect repairs or work around the issues. In short, eliminate tactical rounds, just play the enemy ship intelligently, and throw in scenes/challenges for the players aboard their own ship. Space combat takes forever so there is enough time to solve (small) issues before the next broadside arrives. The entire encounter should be tense and nerve-wracking and things are always breaking down at the worst moment. The players should be running around fixing things or getting the crew to work at maximum efficiency. That also offers them the chance to use their skills instead of just moving the ship and firing every round.
90,984
I'm about to start a campaign using MgT 2e and I have tons of GT material but I've read over and over again how **Behind the Claw** (for GT) differs from **OTU**. I'm not interested on moving rules from GURPS to MgT 2e, but information, so I just want to know which are the points where **GT** background is different from **OTU** (beyond the Dulinor issues). Bear in mind that I intend to play the *Golden Age* (1105-) or just after the *Fifth Frontier War*.
2016/11/29
[ "https://rpg.stackexchange.com/questions/90984", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/7885/" ]
What I found in sea or space battles is that players have no clue what ships look like. No matter how popular you think the ships are, some of your players will not be able to visualize them in the detail you expect. Take for example a [three master](https://www.google.de/search?q=three+master&tbm=isch&tbo=u&source=univ&sa=X&ved=0ahUKEwi4o6uVoM7QAhXkDZoKHWPRCZ8QsAQILA&biw=1433&bih=760). If the DM says something like "after the smoke of your broadside clears, you see the enemy ship has sustained heavy damage, it's foremast broken and hanging over the side", expect players to not be able to accurately describe the scene, no matter how many popular movies you have seen and you *think* they have seen. And it gets even worse with space battles, with all kind of popular fiction depicting ships differently. Make sure you have pictures or props of the ships or ideally, both. Being able to picture the scene, even if the pictures are given, is a huge boost in playability. Prepare in advance as a DM, so you have pictures of possible encounters, possible damage and other outcomes (beaches, asteroids, whatever). Rogue Trader and 40K for example has a very distinct style and that style is a big part of how it *feels*. Fighting an Ork dreadnought or a sleek Eldar frigate *feels* completely different even if you are rolling the same dice. There's pictures of both all over the net. And if you want to have a great evening, maybe you can find some Battlefleet Gothic miniatures to put in the middle of the table. Now if you and your players are unhappy with the *system* I guess you need to find a better system. Personally, I was happy with Rogue Trader, but if you are not, maybe it's just not the right system for you.
A quick solution can be to force a **choice from the players**. Basically it means that on the standard turn they won't be able to perfectly fill all the roles so they will have to choose which ones are filled and which ones are not. For example in your ship you can have the following roles: commander (who give bonuses to morale tests), seeker (who make the ship able to react in case of imminent danger), gunner (who attack the enemy), pilot (who makes the ship dodge), shipwright (who repairs the damages)... You can imagine the unfilled roles as under the responsibility of a random NPC who will do the job but without giving bonuses. Each turn, make your player decide which roles they want to do. The role can be more or less useful depending on the situation (in close-quarter combat the seeker becomes less useful for example), and PCs will be more or less good at each role. For some roles you may discourage, or even forbid, that two PCs fill it (by making the bonuses from the second PC less important for example). Add to that some events that will accentuate the need for all the roles, and your players will really have to choose. For example: * the rudder is damaged by a previous salve, piloting becomes very difficult (malus), but a quick repair would fix that. * fog raises, and without a seeker it becomes very difficult to aim these fires. * some members of the crew fell from the ship, without a rescuer they are in big trouble * there is a weird sound coming from the south, what is it ? Maybe it would worth that someone prepares for a counter-measure. Maybe not. * the enemy have started firing gold coins. Your pirate crew is trying to gather them and don't answer your orders anymore, unless a talented commander give them an earbashing. This solution is inspired by a homemade space-op system I played with (not as the GM).
90,984
I'm about to start a campaign using MgT 2e and I have tons of GT material but I've read over and over again how **Behind the Claw** (for GT) differs from **OTU**. I'm not interested on moving rules from GURPS to MgT 2e, but information, so I just want to know which are the points where **GT** background is different from **OTU** (beyond the Dulinor issues). Bear in mind that I intend to play the *Golden Age* (1105-) or just after the *Fifth Frontier War*.
2016/11/29
[ "https://rpg.stackexchange.com/questions/90984", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/7885/" ]
As a Rogue Trader RPG veteran, I understand your problem. RT is trying to combine two distinct gaming experiences; RPG’s and wargaming. In wargaming, the pleasure is derived from fighting the battles according to the rules with the players commanding either units or parts of the battlefield. In RPG’s, the players play their characters. It’s the combination that fails IMO. Our solution was to throw away the minutiae of ship fighting and make it a more of a RPG session. So instead of mapping out the manoeuvres, broadsides etc., change it into a story in which the players have certain parts to play. And use the crew’s rating, not the players for the ship’s rolls. Players can give a bonus but it makes no sense that for example a single player’s gunnery rating works for a ship of 100,000 crew…. So describe noticing the enemy ship on the scanners (perhaps insert a scene where the scanners go on the fritz and the tech-priest has to fix it), manoeuvring the ship into an advantageous combat position (insert scene where a rudder fails, the engines go off-line, zombies come crawling out of the ventilation ducts, the crew needs a hearty speech etc.), then describe the first salvoes and roll for damage. Describe the effect of damage on your ship and then let the players effect repairs or work around the issues. In short, eliminate tactical rounds, just play the enemy ship intelligently, and throw in scenes/challenges for the players aboard their own ship. Space combat takes forever so there is enough time to solve (small) issues before the next broadside arrives. The entire encounter should be tense and nerve-wracking and things are always breaking down at the worst moment. The players should be running around fixing things or getting the crew to work at maximum efficiency. That also offers them the chance to use their skills instead of just moving the ship and firing every round.
A quick solution can be to force a **choice from the players**. Basically it means that on the standard turn they won't be able to perfectly fill all the roles so they will have to choose which ones are filled and which ones are not. For example in your ship you can have the following roles: commander (who give bonuses to morale tests), seeker (who make the ship able to react in case of imminent danger), gunner (who attack the enemy), pilot (who makes the ship dodge), shipwright (who repairs the damages)... You can imagine the unfilled roles as under the responsibility of a random NPC who will do the job but without giving bonuses. Each turn, make your player decide which roles they want to do. The role can be more or less useful depending on the situation (in close-quarter combat the seeker becomes less useful for example), and PCs will be more or less good at each role. For some roles you may discourage, or even forbid, that two PCs fill it (by making the bonuses from the second PC less important for example). Add to that some events that will accentuate the need for all the roles, and your players will really have to choose. For example: * the rudder is damaged by a previous salve, piloting becomes very difficult (malus), but a quick repair would fix that. * fog raises, and without a seeker it becomes very difficult to aim these fires. * some members of the crew fell from the ship, without a rescuer they are in big trouble * there is a weird sound coming from the south, what is it ? Maybe it would worth that someone prepares for a counter-measure. Maybe not. * the enemy have started firing gold coins. Your pirate crew is trying to gather them and don't answer your orders anymore, unless a talented commander give them an earbashing. This solution is inspired by a homemade space-op system I played with (not as the GM).