qid
int64
1
74.7M
question
stringlengths
0
70k
date
stringlengths
10
10
metadata
sequence
response
stringlengths
0
115k
18,846,876
I have a project in WPF with XAML: ``` <Window.Resources> <CollectionViewSource x:Key="cvs" Source="{Binding}"> <CollectionViewSource.GroupDescriptions> <PropertyGroupDescription PropertyName="Group"/> </CollectionViewSource.GroupDescriptions> </CollectionViewSource> </Window.Resources> <Grid > <DataGrid Name="datagrid1" ItemsSource="{Binding Source={StaticResource cvs}}" > </DataGrid> </Grid> ``` And the `.cs` file as following: ``` public partial class MainWindow : Window { public DataTable dt; public MainWindow() { InitializeComponent(); dt = new DataTable(); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Age", typeof(int)); dt.Columns.Add("Group", typeof(int)); dt.Rows.Add(new object[3] { "Mary", 22, 1 }); dt.Rows.Add(new object[3] { "Peter", 24, 3 }); dt.Rows.Add(new object[3] { "Rose", 17, 1 }); dt.Rows.Add(new object[3] { "John", 19, 2 }); dt.Rows.Add(new object[3] { "Steven", 20, 1 }); dt.Rows.Add(new object[3] { "Tom", 20, 3 }); datagrid1.ItemsSource = dt.AsDataView(); //DataContext = dt.AsDataView(); } } ``` I just want to move the code `datagrid1.ItemsSource = dt.AsDataView();` to XAML.
2013/09/17
[ "https://Stackoverflow.com/questions/18846876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2787052/" ]
you can cast DataTable to generic collection using DataTable.AsEnumerable() and give this as Source to CollectionViewSource. like- IEnumerable YourType> vr = YourDataTable.AsEnumerable(); CollectionViewSource x:Key="cvs" Source="{Binding vr}">
16,853
When you bow down completely to the floor on Yom Kippur many people place something on the ground so that they are not bowing directly on the ground. 1. Why? What is the halachic basis for this? 2. If bowing directly on the floor without anything placed in between is indeed [assur](http://meta.judaism.stackexchange.com/a/591), why do we do it? 3. Should it be under my head? under my knees? both? somewhere else? 4. How bad is it if I didn't do it - is it a rabbinic infraction or is it akin to idol worship? Partly addressed [here](https://judaism.stackexchange.com/a/2920/1552)
2012/06/05
[ "https://judaism.stackexchange.com/questions/16853", "https://judaism.stackexchange.com", "https://judaism.stackexchange.com/users/-1/" ]
[Vayikra 26:1](http://www.chabad.org/library/bible_cdo/aid/9927/showrashi/true#v1) says: > > You shall not make idols for yourselves, nor shall you set up a statue or a monument for yourselves. **And in your land you shall not place a pavement stone on which to prostrate yourselves**, for I am the Lord, your God. > > > This teaches us (See [Chinuch, Mitvah 349](http://hebrewbooks.org/pdfpager.aspx?req=34302&pgnum=221)) that one is not allowed to prostrate oneself on stone outside the Beit HaMikdash (since it says "in your land"). The Rabbis extended this prohibition to even forbid bowing on one's knees (without prostrating oneself) on stone. The Rambam says that this is because this was the way non-Jews would worship their gods. They would place decorated stones before their gods and use them to bow to their gods. The Chinuch (I think) adds that it is possible that it may appear that one is worshiping the stone itself, since it is set aside and decorated, etc. However, the Chinuch says, if one were to prostrate oneself on a carpet (even a nice one), we aren't worried that one will turn it into a god, since it will (relative to the rock) quickly wear out. Rashi [(Megilla 22B)](http://hebrewbooks.org/shas.aspx?mesechta=11&daf=22b&format=pdf) indicates that the issue is not to bow the way they bowed in the Beit Hamikdash (it appears that he hold it is forbidden to build a Beit HaKnesset with a stone floor - I'm not sure if that's right) --- [Halachically Speaking Volume 5, Issue 14](http://www.thehalacha.com/attach/Volume5/Issue14.pdf) discusses this at length, and says *"All sources say a separation is required between ones face and the ground not a separation between the knees and the ground."* but continues *"Some say falling on one’s knees alone is going in the ways of the non-Jews and one should avoid this."*. According to that perhaps one should put something between his face and knees as well. --- [Chabad custom is](http://hebrewbooks.org/pdfpager.aspx?req=30510&pgnum=152) not to worry about this if the floor is made out of wood.
19,737
Current Situation ----------------- My boyfriend of 5 months is currently living with me in my aparment. He moved in about 2.5 months ago, because he was kicked out by his roommate with a 2 week notice and completely out of the blue and since then, he has been living with me. We are both 24 and employed. I work a full time job while he works 15 hours a week but he is also still attending university. If the reason of why he was kicked out is in any way important please say so and I will update this question. But since it is a long story I will skip this part for now. I made sure to be clear on what I wanted when he moved in. I told him he could live with me for as long as he liked, but I would prefer it if he would eventually get his own place since our relationship is still very new (I just don't think you should move together after just 3 months). He agreed but also said he would be fine with staying at my place permanently. (To which i did not respond, since I already told him what i preferred) Problems -------- We have not set any boundaries or rules on living together, since I thought this was only a temporary situation. And maybe it still is, but I do not know if he decided to just stay and ignore my preference or simply thinks that I got used to him living with me. There are now slowly things arising like: * him taking a shower when I need to get ready for work, while he has a day off (I came late to work because of that) * loud music when I need some peace and quiet * no more time alone in my apartment * a lot of laundry, dirty dishes, .. And I do not know how to approach him about these things, since A) I do not want to suggest that he has to move out and B) he thinks he can stay because I am talking about long-term commitments. I am not sure if A and B are in conflict to each other, but what I basically want is I don't want to "force" him to move out, nor do I want to invite him permanently into my place. Goal ---- I want to keep a healthy relationship with him and eradicate the negative feelings I get when the problems from above arise. I want to find a non-suggestive way of reminding him that I would still sort of prefer if he got his own place, without sounding like I want him to move out. And if he decided to stay, that there are things that need to change. Summary ------- I guess he does not see the need of having to move out at all. If I was him I couldn't see a reason either. He lives rent-free, close to university, in a quiet area. Except for the weekends and evenings, he basically has a whole apartment to himself. I am looking for an approach that won't hurt his feelings or suggest him to move out, but just to make him aware that there is a problem that needs solving. How do I correctly start up a conversation about this? What can I say or do so he knows he is free to stay with me forever if that is his wish (though it is not mine), but then we have to set up some rules? And just for clearance: I would **prefer** it if he moved out. That means if he **wants** to stay with me I would accept that. But if he has no preference of staying/ moving then I would like for him to move out. **UPDATE** Thanks for all the answers and comments, I see now that I will have to talk about this with him openly if I want my issues solved properly. As an addition, I will try to start a conversation about our current living situation and ask him if he is happy with everything so far. I have not considered the possibility that maybe he also has issues that he does not speak up about since he is basically only a guest.
2018/11/05
[ "https://interpersonal.stackexchange.com/questions/19737", "https://interpersonal.stackexchange.com", "https://interpersonal.stackexchange.com/users/21449/" ]
You should talk to him like you would to regular roommate. Sometimes people think they can get away with "regular stuff" because there is something more involved. As almost all people will tell you: communication is the base of any healthy relationship. You are fairly early in your relationship so not only you need to get to know each other but you also get to work with each other on things that don't work for you (like loud music). * You should set and communicate boundaries you wish to have. Tell him that because of your job you need to have bathroom unoccupied before you leave to work. And that it's your need not wish. * Your wish is that he would take dirty dishes to kitchen and put them in the sink. Explain why it's bothers you and why you want it your way. * Make a list of things you would like him to do or not do. Maybe he could prepare such list for you too. * Propose "alone time" for each other. You need time to process all that is happening between two of you alone, or with friends (if he don't have them it's a good opportunity for him to seek it while looking for a new hobby) * Think if the reason he was kicked out by his ex-roommate should be a red flag for you. * **An obvious red flag** temporary things tend to become permanent. And in your case it's in his best interest if it became permanent. No rent (check your bills how they spiked up), close to university (so as long as he's studying he don't need to pay for transport). In your both best interest is that you live apart from some time so you can find things to bond over with rather then going straight to problems of everyday living together.
65,490,377
Let's say I have an unordered\_map: ``` std::unordered_map<Key, BigObject> big_objects; ``` where `BigObject` is like: ``` struct BigObject { BigObject(P1, P2, P3); // <--- expensive /*...*/ }; ``` and I have a `Key` `k`, and a set of arguments for `BigObject`s constructor `P1` `p1`, `P2` `p2` and `P3` `p3`. If `big_objects` already contains `k` I want to do nothing. If `big_objects` does not contain `K` I want to construct and insert `BigObject(p1,p2,p3)` Is it possible to do this with a single lookup on `big_objects`? ie Will `emplace` or `try_emplace` construct `BigObject` if the key is already present? **Update** After some testing it seems like `emplace` does construct `BigObject` but `try_emplace` doesn't ? ie ``` big_objects[k] = BigObject(p1,p2,p3) // insert k, k now present... big_objects.emplace(k, p1, p2, p3); // does construct a BigObject big_objects.try_emplace(k, p1, p2, p3); // does not construct a BigObject ``` Is this correct?
2020/12/29
[ "https://Stackoverflow.com/questions/65490377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1131467/" ]
Yes, it is correct, this is the reason why `try_emplace` exists, it doesn't touch its arguments if the key is already present. [Cppreference `try_emplace`](https://en.cppreference.com/w/cpp/container/map/try_emplace) > > Unlike insert or emplace, these functions do not move from rvalue arguments if the insertion does not happen, which makes it easy to manipulate maps whose values are move-only types, such as std::map<std::string, std::unique\_ptr>. In addition, try\_emplace treats the key and the arguments to the mapped\_type separately, unlike emplace, which requires the arguments to construct a value\_type (that is, a std::pair) > > > As a bonus point, you do not have to use the ugly `std::piecewise_construct` tag to pass both the key and the value constructor arguments ( unless you want to inplace construct the key too).
40,058,274
I have a String in this format ``` {value=very big +$5},{value=super big +$10},{value=extra big +$15} ``` **How to convert them into 2 Arrays in such format?** For example: ``` $name=["very big","super big","extra big"]; $price=["5","10","15"]; // OR $price=[5,10,15]; ``` I can do that by using **explode()** if the string format is in a simpler format. However, this format is too complicated. Anyone knows how to do that ?
2016/10/15
[ "https://Stackoverflow.com/questions/40058274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6521417/" ]
use [explode](http://php.net/manual/en/function.explode.php) with `',' ,'=' ,'+$'` ``` $string = "{value=very big +$5},{value=super big +$10},{value=extra big +$15}"; $temp_array = (explode(",",$string)); foreach($temp_array as $val) { $temp_array = (explode("=",$val)); $temp_string = $temp_array[1]; $temp_string = str_replace("}","",$temp_string); $temp_array = (explode("+$",$temp_string)); $name[] = $temp_array[0]; $price[] = $temp_array[1]; } ``` **[DEMO](https://3v4l.org/84HeM)**
32,760,120
I am using the MP Movie Player for playing a live channel feed, i am also adding a tap gesture on a view, for hiding and unhiding of a collection view, this view is then added on the player view. ```html player.shouldAutoplay=YES; player.controlStyle=MPMovieControlStyleDefault; viewVideo.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); [viewVideo addSubview:player.view]; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)]; tapGesture.delegate=self; CGRect aViewFrame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); aView = [[UIView alloc] initWithFrame:aViewFrame]; [aView addGestureRecognizer:tapGesture]; [player.view setUserInteractionEnabled:YES]; [player.view addSubview:aView]; ``` Now the problem i am facing is that when the tap gesture is disabled, then i can use this control state buttons such as (full screen and the pause, play), but if i keep the tap gesture enabled on the player view, then i cannot use this control state bar. Is there a way i can put bring the control state bar in front so that i can use this functions. And also what is the fixed height of this control state, Please specify dimensions for landscape and portrait both. [![enter image description here](https://i.stack.imgur.com/GGXdW.png)](https://i.stack.imgur.com/GGXdW.png)
2015/09/24
[ "https://Stackoverflow.com/questions/32760120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5155369/" ]
As far as i understand you are not using the main view for the video, So the thing you can do is you can reduce the height of the view on which you are adding the tap gesture, in your case it will be “aView.” The reduced height should be the height of the control state bar. There maybe different values of this bar in landscape and portrait orientation.
10,576,448
Background ---------- Maintain readable XSL source code while generating HTML without excessive breaks that introduce spaces between sentences and their terminating punctuation. From [Rethinking XSLT](http://www.wilmott.ca/rxslt/rxslt.html): > > White space in XSLT stylesheets is especially problematic because it serves two purposes: (1) for formatting the XSLT stylesheet itself; and (2) for specifying where whitespace should go in the output of XSLT-processed XML data. > > > Problem ------- An XSL template contains the following code: ``` <xsl:if test="@min-time &lt; @max-time"> for <xsl:value-of select="@min-time" /> to <xsl:value-of select="@max-time" /> minutes </xsl:if> <xsl:if test="@setting"> on <xsl:value-of select="@setting" /> heat </xsl:if> . ``` This, for example, generates the following output (with whitespace exactly as shown): ``` for 2 to 3 minutes . ``` All major browsers produce: ``` for 2 to 3 minutes . ``` Nearly flawless, except for the space between the word `minutes` and the punctuation. The desired output is: ``` for 2 to 3 minutes. ``` It might be possible to eliminate the space by removing the indentation and newlines within the XSL template, but that means having ugly XSL source code. Workaround ---------- Initially the desired output was wrapped in a variable and then written out as follows: ``` <xsl:value-of select="normalize-space($step)" />. ``` This worked until I tried to wrap `<span>` elements into the variable. The `<span>` elements never appeared within the generated HTML code. Nor is the following code correct: ``` <xsl:copy-of select="normalize-space($step)" />. ``` Technical Details ----------------- The stylesheet already uses: ``` <xsl:strip-space elements="*" /> <xsl:output indent="no" ... /> ``` Related ------- * [Storing html tags within an xsl variable](https://stackoverflow.com/questions/9907302/storing-html-tags-within-an-xsl-varable) Question -------- How do you tell the XSLT processor to eliminate that space? Thank you!
2012/05/14
[ "https://Stackoverflow.com/questions/10576448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59087/" ]
Instead of using `copy-of` you can apply the identity template with an additional template that trims the spaces from the text nodes. You only create one variable like in your first workaround. You call: ``` <li><xsl:apply-templates select="$step" mode="nospace" />.</li> ``` The templates: ``` <xsl:template match="text()" mode="nospace" priority="1" > <xsl:value-of select="normalize-space(.)" /> </xsl:template> <xsl:template match="node() | @*" mode="nospace"> <xsl:copy> <xsl:apply-templates select="node() | @*" mode="nospace" /> </xsl:copy> </xsl:template> ```
25,197,583
I'm writing a very simple GUI tool for a command line app. It only has 2 buttons. **Connect** and **Quit**. In `applicationDidFinishLaunching` I run the following ``` NSPipe *pipe = [[NSPipe alloc] init]; writer = [pipe fileHandleForWriting]; NSTask *runTask = [[[NSTask alloc] init] autorelease]; NSString *exefile = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"vpngui"]; [runTask setLaunchPath: exefile]; NSString *exeDir = [[NSBundle mainBundle] resourcePath]; NSArray *pargs; pargs = [NSArray arrayWithObjects: exeDir, nil]; [runTask setArguments: pargs]; [runTask setStandardInput:pipe]; [runTask launch]; ``` Then when the **Connect** button is clicked the following line of code is run ``` writer writeData:[@"Connect" dataUsingEncoding:NSUTF8StringEncoding]]; ``` and for the **Quit** button ``` writer writeData:[@"Quit" dataUsingEncoding:NSUTF8StringEncoding]]; ``` Somehow the command line app never gets the Connect and Quit commands
2014/08/08
[ "https://Stackoverflow.com/questions/25197583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1411626/" ]
This is a question that is discussed very much in the community. I heard that maybe Akka 3 will have better support for typesafe actors, but that is some time down the road. In the mean time you could use [TypedActors](http://doc.akka.io/docs/akka/2.3.4/scala/typed-actors.html), though the general suggestion is to use them at the boundaries of your application. A nice approach that does not give you any typesafety, but makes the contract of an actor more visible, is to define the messages an actor can receive in their companion object. This way each time you want to send a message to an actor you choose from the message its companion object defines. This of course works best if you have specific messages for each actor. If you change the implementation you could remove the old message and add a new one, so that everyone who wanted to use the old implementation would get compiler errors. Lastly there was [a nice pattern](https://github.com/muuki88/akka-architecture) last week on the mailing list. He creates traits to define the contracts for the actors and their consumers, but you still need to take care that the consumer mix in the correct trait. In my experience, the best way to make sure everything works is an extensive test suite which will test each actor for itself, but also the communication between specific actors.
40,495,880
I am starting a REST service, using Swagger Codegen. I need to have different responses for different parameters. Example: `<baseURL>/path` can use `?filter1=` or `?filter2=`, and these parameters should produce different response messages. I want my OpenAPI YAML file to document these two query params separately. Is this possible?
2016/11/08
[ "https://Stackoverflow.com/questions/40495880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4765492/" ]
It is not supported in the 2.0 spec, and not in 3.0 either. Here are the corresponding proposals in the OpenAPI Specification repository: [Accommodate legacy APIs by allowing query parameters in the path](https://github.com/OAI/OpenAPI-Specification/issues/123) [Querystring in Path Specification](https://github.com/OAI/OpenAPI-Specification/issues/164)
8,944,525
I'm trying to create a subset of a data frame and when I do so, R switches the formatting of the date column. Any idea why or how to fix this? ``` > head(spyPr2) Date Open High Low Close Volume Adj.Close 1 12/30/2011 126.02 126.33 125.50 125.50 95599000 125.50 2 12/29/2011 125.24 126.25 124.86 126.12 123507200 126.12 3 12/28/2011 126.51 126.53 124.73 124.83 119107100 124.83 4 12/27/2011 126.17 126.82 126.06 126.49 86075700 126.49 5 12/23/2011 125.67 126.43 125.41 126.39 92187200 126.39 6 12/22/2011 124.63 125.40 124.23 125.27 119465400 125.27 > spyPr2$Date <- as.Date(spyPr2$Date, format = "%m/%d/%Y") > head(spyPr2) Date Open High Low Close Volume Adj.Close 1 2011-12-30 126.02 126.33 125.50 125.50 95599000 125.50 2 2011-12-29 125.24 126.25 124.86 126.12 123507200 126.12 3 2011-12-28 126.51 126.53 124.73 124.83 119107100 124.83 4 2011-12-27 126.17 126.82 126.06 126.49 86075700 126.49 5 2011-12-23 125.67 126.43 125.41 126.39 92187200 126.39 6 2011-12-22 124.63 125.40 124.23 125.27 119465400 125.27 > spyPr2 <- data.frame(cbind(spyPr2$Date, spyPr2$Close, spyPr2$Adj.Close)) > str(spyPr2) 'data.frame': 1638 obs. of 3 variables: $ X1: num 15338 15337 15336 15335 15331 ... $ X2: num 126 126 125 126 126 ... $ X3: num 126 126 125 126 126 ... > head(spyPr2) X1 X2 X3 1 15338 125.50 125.50 2 15337 126.12 126.12 3 15336 124.83 124.83 4 15335 126.49 126.49 5 15331 126.39 126.39 6 15330 125.27 125.27 ``` UPDATE: ``` > spyPr2 <- data.frame(cbind(spyPr2["Date"], spyPr2$Close, spyPr2$Adj.Close)) Error in `[.data.frame`(spyPr2, "Date") : undefined columns selected > spyPr2 <- data.frame(cbind(spyPr2[,"Date"], spyPr2$Close, spyPr2$Adj.Close)) Error in `[.data.frame`(spyPr2, , "Date") : undefined columns selected ``` UPDATE 2: ``` structure(list(Date = structure(c(15338, 15337, 15336, 15335, 15331, 15330), class = "Date"), Open = c(126.02, 125.24, 126.51, 126.17, 125.67, 124.63), High = c(126.33, 126.25, 126.53, 126.82, 126.43, 125.4), Low = c(125.5, 124.86, 124.73, 126.06, 125.41, 124.23), Close = c(125.5, 126.12, 124.83, 126.49, 126.39, 125.27 ), Volume = c(95599000L, 123507200L, 119107100L, 86075700L, 92187200L, 119465400L), Adj.Close = c(125.5, 126.12, 124.83, 126.49, 126.39, 125.27)), .Names = c("Date", "Open", "High", "Low", "Close", "Volume", "Adj.Close"), row.names = c(NA, -6L), class = "data.frame") ```
2012/01/20
[ "https://Stackoverflow.com/questions/8944525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/914308/" ]
Obvious answer is **don't do subsetting like that**! Use the appropriate tools. What is wrong with ``` spyPr2.new <- spyPr2[, c("Date", "Close", "Adj.Close")] ``` ? To explain the behaviour you are seeing, you need to understand what `$` returns and how `cbind()` works. `cbind()` is one of those oddities in R wherein method dispatch is not done via the usual method but is instead handled via special code buried in the internals of R. This is all the R code behind `cbind()`: ``` > cbind function (..., deparse.level = 1) .Internal(cbind(deparse.level, ...)) <bytecode: 0x24fa0c0> <environment: namespace:base> ``` Not much help, eh? There are methods for data frames and `"ts"` objects however: ``` > methods(cbind) [1] cbind.data.frame cbind.ts* Non-visible functions are asterisked ``` Before I do the reveal, also note what `$` returns (`dat2` is your 6 lines of data after converting `Date` to a `"Date"` object): ``` > str(dat2$Date) Date[1:6], format: "2011-12-30" "2011-12-29" "2011-12-28" "2011-12-27" ... ``` This is a `"Date"` object, which is a special vector really. ``` > class(dat2$Date) [1] "Date" ``` The key thing is that it is **not** a data frame. So when you use `cbind()`, the internal code is seeing three vectors and the internal code creates a matrix. ``` > (c1 <- cbind(dat2$Date, dat2$Close, dat2$Adj.Close)) [,1] [,2] [,3] [1,] 15338 125.50 125.50 [2,] 15337 126.12 126.12 [3,] 15336 124.83 124.83 [4,] 15335 126.49 126.49 [5,] 15331 126.39 126.39 [6,] 15330 125.27 125.27 > class(c1) [1] "matrix" ``` There can only be numeric or character matrices in R so the `Date` object is converted to a numeric vector: ``` > as.numeric(dat2$Date) [1] 15338 15337 15336 15335 15331 15330 ``` to allow `cbind()` to produce a numeric matrix. You can force the use of the data frame method by calling it explicitly and it does know how to handle `"Date"` objects and so doesn't do any conversion: ``` > cbind.data.frame(dat2$Date, dat2$Close, dat2$Adj.Close) dat2$Date dat2$Close dat2$Adj.Close 1 2011-12-30 125.50 125.50 2 2011-12-29 126.12 126.12 3 2011-12-28 124.83 124.83 4 2011-12-27 126.49 126.49 5 2011-12-23 126.39 126.39 6 2011-12-22 125.27 125.27 ``` However, all the explanation aside, you are trying to do the subsetting in a very complex manner. `[` as a subset function works just fine: ``` > dat2[, c("Date", "Close", "Adj.Close")] Date Close Adj.Close 1 2011-12-30 125.50 125.50 2 2011-12-29 126.12 126.12 3 2011-12-28 124.83 124.83 4 2011-12-27 126.49 126.49 5 2011-12-23 126.39 126.39 6 2011-12-22 125.27 125.27 ``` `subset()` is also an option but not needed here: ``` > subset(dat2, select = c("Date", "Close", "Adj.Close")) Date Close Adj.Close 1 2011-12-30 125.50 125.50 2 2011-12-29 126.12 126.12 3 2011-12-28 124.83 124.83 4 2011-12-27 126.49 126.49 5 2011-12-23 126.39 126.39 6 2011-12-22 125.27 125.27 ```
16,324,051
im really new to eclipse and I am creating buttons for the first time. I think I have the basic idea but its not working. Anything that you can add on any part of my code is really helpful. Help! here is my code: ``` import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class MovingBox extends Applet { Thread thread; Dimension dim; Image img; Graphics g; Color red = null; Color blue = null; Font fnt16P = null; public void init() { resize(800,500); Button b_Up = new Button("Up"); b_Up.setSize(100, 25); b_Up.setLocation(450,450+ 90); b_Up.setBackground(red); b_Up.setForeground(blue); b_Up.setFont(fnt16P); b_Up.setVisible(true); b_Up.addActionListener((ActionListener) this); add(b_Up); } public void paint(Graphics gfx) { g.setColor(Color.green); g.fillRect(0,0,800,500); } public void actionPerformed(ActionEvent event) { int value, total;; Object cause = event.getSource(); if (cause == b_Up) ( ) } } ```
2013/05/01
[ "https://Stackoverflow.com/questions/16324051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2340442/" ]
"Model" doesn't have "VertexBuffer". "ModelMesh" doesn't have "VertexBuffer" either. But, I found out that "ModelMeshPart" does indeed have "VertexBuffer". I'm doing data extraction from a .fbx for the first time as well. Any model we include in a project will have to be stored in a ModelMeshPart. That's not so bad. The whole mesh in the .fbx can be considered one part.
70,910,119
On [this sandbox](https://codesandbox.io/s/so-question-sp5dv?file=/src/components/GameBlock.tsx), I've recreated the classic sliding-puzzle game. On my `GameBlock` component, I'm using a combination of css `transform: translate(x,y)` and `transition: transform` in order to animate the sliding game-pieces: ``` const StyledGameBlock = styled.div<{ index: number; isNextToSpace: boolean; backgroundColor: string; }>` position: absolute; display: flex; justify-content: center; align-items: center; width: ${BLOCK_SIZE}px; height: ${BLOCK_SIZE}px; background-color: ${({ backgroundColor }) => backgroundColor}; ${({ isNextToSpace }) => isNextToSpace && "cursor: pointer"}; ${({ index }) => css` transform: translate( ${getX(index) * BLOCK_SIZE}px, ${getY(index) * BLOCK_SIZE}px ); `} transition: transform 400ms; `; ``` Basically, I'm using the block's current index on the board in order to calculate it's `x` and `y` values which change the `transform: translate` value of the block when it's being moved. While this does manage to trigger a smooth transition when sliding the block to the top, to the right and to the left - for some reason, sliding the block from top to bottom doesn't transition smoothly. Any ideas what's causing this exception?
2022/01/29
[ "https://Stackoverflow.com/questions/70910119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10185326/" ]
[`Document.querySelector()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) can be used to select the child element: ```js var dropdown = document.getElementById("fixed-drop").querySelector('.dropdown-btn'); dropdown.addEventListener('click', function() { console.log('Clicked'); }); ``` ```html <div id="fixed-drop"> <button type="button" class="dropdown-btn">Show</button> </div> ```
68,159,760
I have the data frame that I would like to subset based on the `Id==8210`. As there is no 'betweenesscentrality' for `Id==8210`, how can have the `bar_8221` filled with NA? I tried `ifelse` but is not working. Any suggestions? Sample code: ``` bar_8221 <- subset(x3n, x3n$Id== "8221") ``` Sample data: ``` x3n<-structure(list(Id = c(110, 3110, 210, 3130, 310, 1110, 5140, 8210, 9360, 9990, 3310, 8110, 8219, 3210, 7241, 3240, 3320, 3611, 3710, 8212), betweenesscentrality = c(0.102339, 0.395224, 0.048246, 0.128168, 0.052632, 0.615497, 0, 0.074561, 0.219298, 0.052632, 0.140351, 0.018519, 0.018519, 0.173977, 0.176901, 0.064327, 0.024366, 0, 0.04386, 0.074561)), row.names = c(NA, -20L), class = c("tbl_df", "tbl", "data.frame")) ``` Possible outputs for `bar_8221` without `8221` [![enter image description here](https://i.stack.imgur.com/BYA62.png)](https://i.stack.imgur.com/BYA62.png)
2021/06/28
[ "https://Stackoverflow.com/questions/68159760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11418708/" ]
You might transform ``` void method() { if (...) { classA* a = new classA; a->f1(); a->f2(); // ... } else if (...) { classB* b = new classB; b->f1(); b->f2(); // ... } } ``` into ``` template <class T> void common(T* t) { t->f1(); t->f2(); // ... } void method() { if (...) { classA* a = new classA; common(a); } else if(...) { classB* b = new classB; common(b); } } ```
21,177,941
I have a `Canvas` that overrides `PointerMoved` event do some stuff if the user "paints" on it. Now I'm trying to move this `Canvas` inside a `ScrollViewer` to add Zoom and Scroll effects which works perfectly. ``` <ScrollViewer x:Name="MainScrollViewer" Grid.Column="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" ZoomMode="Enabled" MinZoomFactor="0.5" MaxZoomFactor="2.0" > <Canvas x:Name="MainCanvas" Background="#000000" HorizontalAlignment="Left" VerticalAlignment="Top" PointerMoved="MainCanvas_PointerMoved" /> </ScrollViewer> ``` However, the `ScrollViewer` captures all the Pointer move Events and this caused the main paint procedure not working anymore. Any idea on how to fix this?
2014/01/17
[ "https://Stackoverflow.com/questions/21177941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/395573/" ]
> > Drawing with touch while still allowing zooming/panning - this is currently not supported in XAML. You will need to turn OFF zooming/panning in order to be able to draw with Pointer events and it is not possible to obtain system zooming and panning behaviors simultaneously with custom manipulations. You can however try to use Manipulation events by setting ManipulationMode=All and handle two finger scrolling and pinch zoom using Scale and Translate values manually. > > > See more at: [Touch based drawing app with a Canvas inside a ScrollViewer](http://social.msdn.microsoft.com/Forums/windowsapps/en-US/2a2e0ddc-e700-4eaf-b223-daa9f8fd9219/touch-based-drawing-app-with-a-canvas-inside-a-scrollviewer?forum=winappswithcsharp) I didn't work with canvas and scrollview but I think which I found will help you :)
46,826,665
Using TeamCity in combiniation with git. Currently, TeamCity is set up with "`master`" as the default branch. Typically, development takes place on another branch (e.g. "`dev`") - TeamCity is set to watch for changes on "`dev`" and build automatically. If `DEADBEEF-SOME-SHA` has been built & tagged by TeamCity as build 1.2.3.4 on "`dev`" and we fast-forward merge that git SHA1 to "`master`", TeamCity still performs a build - so we end up with `DEADBEEF-SOME-SHA` being tagged as both 1.2.3.4 and 1.2.3.5. As I understand it, making "`dev`" the default branch would prevent this. Is there another way to prevent TeamCity performing a build if a build has already succeeded for that same SHA1? Note if we push directly to `master` (and that SHA1 doesn't exist on other branches / hasn't been built) I'd still like to see a build. **I'd like to achieve this entirely in TeamCity if possible - no additional scripts/writing of files etc etc**.
2017/10/19
[ "https://Stackoverflow.com/questions/46826665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/855208/" ]
You can query builds for a particular SHA1... but you [have to know your previous buildID for that](https://stackoverflow.com/a/45784720/6309). So what I would do is: * write in a dedicated folder (accessible by all agents) the sha1 built at the end of each job * only triggers a new job if that sha1 file is not already present.
14,460,078
I am trying to create a simple function that takes two dates of format int\*int\*int and return if the first one is older than the second or not. ``` fun is_older (date1: (int*int*int), date2: (int*int*int)) = val in_days1 = (#1 (date1) * 365) + (#2 (date1) * 30) + #3 date1; val in_days2 = (#1 (date2) * 365) + (#2 (date2) * 30) + #3 date1; if in_days1 < in_days2 then true else false ``` I get this error: > > hwk\_1.sml:1.53 Error: syntax error: inserting EQUALOP > > > uncaught exception Compile [Compile: "syntax error"] > > > raised at: ../compiler/Parse/main/smlfile.sml:15.24-15.46 > > > ../compiler/TopLevel/interact/evalloop.sml:44.55 > > > ../compiler/TopLevel/interact/evalloop.sml:296.17-296.20 > > > Can anyone help please?
2013/01/22
[ "https://Stackoverflow.com/questions/14460078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868270/" ]
In addition to what has already been mentioned, you also ought to use pattern matching to decompose that 3-tuple. Doing this, you can also throw away the type annotations, as it is now clear that this is a 3-tuple (both for the reader, but more importantly also the type system). ``` fun is_older ((y1, m1, d1), (y2, m2, d2)) = let val days1 = y1 * 365 + m1 * 30 + d1 val days2 = y2 * 365 + m2 * 30 + d2 in days1 < days2 end ``` However you could do this a bit smarter. If you have multiple functions working with dates, you could create a nice little helper function `toDays`. In the below example i have just included inside the `isOlder` function, but you could put it at top level or inside a `local`-declaration if you wan't to hide it away ``` fun isOlder (date1, date2) = let fun toDays (y, m, d) = y * 365 + m * 30 + d in toDays date1 < toDays date2 end ```
18,410,150
I have a background image that is getting set an opacity 0.3, then when hovering, getting set to 0.8, as seen in the css code. The image code. ``` <td background="images/1a.png" class="logo" width="160" height="160"> <div class="ch-info"> <h3><br>Add New Deal</h3> </div> </td> ``` The css code. ``` .ch-info { letter-spacing: 2px; font-size: 20px; /* margin: 0 30px; padding: 45px 0 0 0;*/ height: 140px; font-family: 'Open Sans', Arial, sans-serif; -webkit-text-stroke: 1px black; color: #d3d3d3; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; vertical-align:middle; text-align:center; } .logo { opacity:0.3; filter:alpha(opacity=30); /* For IE8 and earlier */ background-repeat:no-repeat; background-position:center; } .logo:hover { opacity:0.8; filter:alpha(opacity=80); /* For IE8 and earlier */ background-repeat:no-repeat; background-position:center; } ``` The text and the background do the hovering effect, I want the text to stay solid, and the background to hover at a 0.8 when the mouse is over the background and the Text to stay Solid regardless if the background is hovered or not.
2013/08/23
[ "https://Stackoverflow.com/questions/18410150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644224/" ]
As I stated in the comments, children inherit opacity from their parent. The `.ch-info` class inherits its opacity from `.logo`, so you cannot have the immediate parent be `.logo`. That being said, just have a `<div class="logo"></div>` before `.ch-info` that uses `position: absolute;`, is the same height as either the `<td>` or `.ch-info`, and has the desired background... However, you would have to use `position:relative;` on `.ch-info` so the `z-index` does not become a problem. ***DEMO: <http://jsfiddle.net/dirtyd77/mSg97/3/>*** **HTML:** ``` <table> <tr> <td width="160" height="160"> <div class="logo" style="background:blue;"></div> <div class="ch-info"> <h3>Add New Deal</h3> </div> </td> </tr> <tr> <td width="160" height="160"> <div class="logo" style="background:red;"></div> <div class="ch-info"> <h3>Add New Deal</h3> </div> </td> </tr> <tr> <td width="160" height="160"> <div class="logo" style="background:orange;"></div> <div class="ch-info"> <h3>Add New Deal</h3> </div> </td> </tr> ``` **CSS:** ``` .logo { width:160px; height:160px; position:absolute; opacity:0.3; filter:alpha(opacity=30); /* For IE8 and earlier */ background-repeat:no-repeat; background-position:center; } .logo:hover { opacity:0.8; filter:alpha(opacity=80); /* For IE8 and earlier */ } .ch-info { letter-spacing: 2px; font-size: 20px; /* margin: 0 30px; padding: 45px 0 0 0;*/ font-family: 'Open Sans', Arial, sans-serif; -webkit-text-stroke: 1px black; color: #d3d3d3; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; vertical-align:middle; text-align:center; position:relative; } ``` Let me know if you have any questions. --- ***EDIT:*** However, this situation seems better suited for jQuery. I have provided an example below. ***DEMO: <http://jsfiddle.net/dirtyd77/mSg97/4/>***
462,852
I have a question. If a normed function, that is to say $$ \int\_{-\infty}^{\infty}|f(x)|^2dx<\infty~~~\text{(summable square function)}$$ then, $$\underset{\begin{array}{c} x\rightarrow+\infty\\ x\rightarrow-\infty \end{array}}{lim}f(x)=0$$ It is true, why? thanks
2013/08/08
[ "https://math.stackexchange.com/questions/462852", "https://math.stackexchange.com", "https://math.stackexchange.com/users/86749/" ]
It isn't true, even if we restrict the function to be continuous. For example, take the function that forms the top part of a triangle of width $1/n^2$ at each integer and goes up to its peak, $1$, at the integer. Then it is easy to see the integral converges to a value less than $\pi^2/3$ but $$\lim\_{x\to\pm\infty}f(x)=\text{DNE}.$$
65,143,749
I have a Google sheet that has a roster of people. I want the sheet to automatically color code people on the roster tab that are also present on a second tab that lists people who have dietary restrictions. I thought that conditional formatting would be the way to go, but I can't get the formula to work. I also can seem to get the conditional formatting formula to be relative based on the row. This is the formula that I have so far. A5 is the first cell that contains the person's ID number. The ID numbers are listed in column A on the "Dietary Restrictions" sheet. ``` =NOT(ISNA(VLOOKUP(A5,'Ghost Students'!A:H,1,FALSE))) ```
2020/12/04
[ "https://Stackoverflow.com/questions/65143749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14670845/" ]
You want to highlight values from `A5:A` in one sheet (let's call it `Roster`) if they are present in column `A` from another sheet (`Dietary restrictions`). Since conditional formatting formulas cannot reference other sheets, you have to use [INDIRECT](https://support.google.com/docs/answer/3093377?hl=en) in order to reference that. You can then use [MATCH](https://support.google.com/docs/answer/3093378?hl=en) to check if the value is present. Your formula could be like this: ``` =MATCH($A5,INDIRECT("'Dietary restrictions'!A2:A"),0) ``` ### Output: > > Sheet `Roster`: > > > [![enter image description here](https://i.stack.imgur.com/2AXzi.png)](https://i.stack.imgur.com/2AXzi.png) > > Sheet `Dietary restrictions`: > > > [![enter image description here](https://i.stack.imgur.com/YF3RR.png)](https://i.stack.imgur.com/YF3RR.png)
907,350
I'm running AMANDA with an LTO-6 drive spooling off a local RAID array. The backups are beginning to take longer than the eight hour backup window. Are there any config options to cut some time off the backups (The disks are spiking near 100% utilization for minutes at a time so the upgrade would likely involve a faster RAID array. Possibly more RAM). Other than disks, I don't think the hardware is bottlenecking; CPU utilization is 30% and under, RUNQ is 8 or under (16 core system) and disk swap use is 60Kb and under. [![enter image description here](https://i.stack.imgur.com/zyP9p.png)](https://i.stack.imgur.com/zyP9p.png) Here is my config. I'm not sure the netusage parameter does anything since these are all local files to the drive. Any obvious config changes to speed things up? Would `inparallel` help with more RAM? ``` inparallel 6 dumporder "sssS" taperalgo first displayunit "m" netusage 600 Kbps dumpcycle 1 week s runtapes 1 runspercycle 1 tapecycle 17 tapes ```
2018/04/12
[ "https://serverfault.com/questions/907350", "https://serverfault.com", "https://serverfault.com/users/151174/" ]
Thank you for your question regarding Amanda. While backing up data to Tapes, it is always recommended not to use the software compression. Most Tape drives have hardware compression available and this normally provides good compression ratio at fast rates. Enabling both software and hardware compression would delay your backups significantly. If you have any other questions, feel free to let us know. Zmanda Support
16,529,263
I am trying to make a basic randomizer that can match things. Sort of like a date(Romance) picker, but different situation. I want the product to look like this: (User Input A1) (User Input A2) (User Input A3) (User Input B1) (User Input B2) (User Input B3) Where an A input randomly matches a B input, but A never matches an A, and A doesn't randomize. So it looks like this: A1 - (B#) A2 - (B#) A3 - (B#) Problem is, I suck at JS. I take some classes on Codecademy, being HTML / CSS / jQuery. I keep trying different things, but they keep failing. Can someone help me? --- HTML: ``` <!DOCTYPE html> <html> <head> <link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script> <meta charset=utf-8 /> </head> <body> <ul> People <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> </ul> <hr /> <ul> Jobs <li><input></input></li> <li><input></input></li> <li><input></input></li> <li><input></input></li> <li><input></input></li> <li><input></input></li> <li><input></input></li> <li><input></input></li> <li><input></input></li> </ul> </body> </html> ``` --- JS: --- ``` $(document).ready(function () { $('#jobs').find('li').shuffle(); var mynewlist = ''; $('#people').find('li').each(function (index) { var jb = $('#jobs').find('li').eq(index); mynewlist += '<li>Person:' + $(this).text() + ' Job:' + jb.text() + '</li>'; }); $(mynewlist).appendTo('#newList'); }); ``` --- <http://jsbin.com/ijotok/1> This is what I have. ***I want the inputs to randomize, but it doesn't work.*** --- This is my first post. Sorry if it breaks the rules or anything, but I told my boss I'd get this done 2 weeks ago.
2013/05/13
[ "https://Stackoverflow.com/questions/16529263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2378987/" ]
This should do the trick: ``` $ svn log -v . -r 101 | awk '$1~/^[AMD]$/{for(i=2;i<=NF;i++)print $i}' /branches/1.0/ssac/codes/filename1.java /branches/1.0/ssac/extn/filename2.java /branches/1.0/ssac/extn/filename3.java /branches/1.0/ssac/extn/filenmae4.java /branches/1.0/ssac/extn/filename5.java /branches/1.0/vclpcc/filename6.java ```
35,076,342
I want to edit some stuff on my website. I'm using a child theme and I plan to change some CSS and do some structural changes. I know the CSS is easy to change, as I only need to call the names of the classes or IDs and give the new values. But, if I want to change things around in html, do I need to copy the whole code? Will I lose every change when the theme updates (as in: i copied and pasted the *older version* and now I need to copy and paste the *new version*)? I don't know much about the names of things and how to describe them properly.
2016/01/29
[ "https://Stackoverflow.com/questions/35076342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2686304/" ]
Make copies of the theme files in the parent theme you want to modify - such as index.php, category.php, etc - and move those to the child theme and edit them. The copies in the child theme will be used by WordPress rather than the same-named files in the parent. This includes file in folders, i.e. `/css/style.css`, so duplicate the file structure in the child theme, if needed. The child theme will continue to use those files, even if/when the parent theme get updated. And that also means your child theme edits won't disappear, unless there are major structural/functional changes to the parent theme. One exception to child theme file usage is `functions.php`: > > Unlike style.css, the functions.php of a child theme does not override > its counterpart from the parent. Instead, it is loaded in addition to > the parent’s functions.php. (Specifically, it is loaded right before > the parent’s file.) > > > See <http://codex.wordpress.org/Child_Themes>
7,841
I am young researcher/developer coming from different (non-robotic) background and I did some research on camera localisation and I came to the point, where I can say that I am lost and I would need some of your help. I have discovered that there is a lot of SLAM algorithms which are used for robots etc. As far as I know they are all in unknown environments. But my situation is different. My problems and idea at the same time is: 1. I will be placed in an known room/indoor environment (dimensions would be known) 2. I would like to use handheld camera 3. I can use predefined landmarks if they would help. In my case, I can put some " unique stickers" on the walls at predefined positions if that would help in any way for faster localisation. 4. I would like to get my camera position (with its orientation etc) in realtime(30 Hz or faster). For beginning I would like to ask which SLAM algorithm is the right one for my situation or where to start. Or do you have any other suggestions how to get real time camera positions inside of the known room/environment. It must be really fast and must allow fast camera movements. Camera would be on person and not on robot. thank you in advance.
2015/08/09
[ "https://robotics.stackexchange.com/questions/7841", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/10317/" ]
I've found the answer: a minus sign is needed here: `gyro_y_scaled = - (self.result_list[5] / self.gyro_scale)`. Explanation: `gyro_y_scaled` is the velocity in rad/sec. If you check the code, especially lines 29-31 on [this page](http://blog.bitify.co.uk/2013/11/reading-data-from-mpu-6050-on-raspberry.html), you can see, there is a minus sign before `math.degrees(radians)`, but my implementation has no minus sign before `math.degrees(math.atan2(acc_x_scaled, self.dist(acc_y_scaled,acc_z_scaled)))`. In addition, `self.gyro_y_angle -= gyro_y_scaled * dt`, there is also minus sign instead of plus. To sum up, the velocity and the angles, mentioned above, had "opposite" values and this is why the filters didn't work.
149,037
I have been learning Java. And still after a prolonged time I don't know **why the name of the folder is "bin"** where one find all the tools for java? Is there is any logical reason behind that? I have also noticed the same in .Net framework also.
2012/05/17
[ "https://softwareengineering.stackexchange.com/questions/149037", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/54209/" ]
`bin` is short for binary. It generally refers to the built applications (also know as binaries) that do something for a specific system. To quote from [ChrisF's answer on Stack Overflow](https://stackoverflow.com/questions/3224606/bin-directory-and-path): > > You usually put all the binary files for a program in the bin directory. This would be the executable itself and any dlls (dynamic link libraries) that the program uses. > > >
1,000,254
I made a program using VB and I lost the source code but I have the exe file. How can I extract the code from the exe file?
2009/06/16
[ "https://Stackoverflow.com/questions/1000254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Assuming your exe is a .NET assembly (you tagged the question as VB.NET), you can reverse engineer your exe using tools such as [Reflector](http://www.red-gate.com/products/reflector/).
14,665,275
I'm working on an application that needs to use session id information. My session is stored in cookies. The problem I have is that my session is not immediately available to the controller when a user comes to the site for the first time. I think I may be missing something about how sessions are initialized in Rails. But I'm positve about the fact that the session is not loaded because this is the output of `session.inspect`: ``` #<Rack::Session::Abstract::SessionHash:0x15cb970 not yet loaded> ``` Here is how to reproduce the problem with `Rails 3.2.11` and `ruby 1.9.3`: Create a new application with a `test` controller: ``` rails new my_app cd my_app/ rails g controller test rm app/assets/javascripts/test.js.coffee touch app/views/test/index.html.erb ``` Try to get the session id in that controller: ``` class TestController < ApplicationController def index puts session[:session_id] puts session.inspect end end ``` Add the needed routes: ``` MyApp::Application.routes.draw do resources :test end ``` Then access the application and see what it does: ``` rails server ``` got to: `http://localhost:3000/test` That is the output in the console: ``` #<Rack::Session::Abstract::SessionHash:0x3fd10f50eea0 not yet loaded> ``` Then again `http://localhost:3000/test` and this time we have a session: ``` 400706c0b3d95a5a1e56521e455075ac {"session_id"=>"400706c0b3d95a5a1e56521e455075ac", "_csrf_token"=>"Euaign8Ptpj/o/8/ucBFMgxGtiH7goKxkxeGctumyGQ="} ```
2013/02/02
[ "https://Stackoverflow.com/questions/14665275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1691515/" ]
I found a way to force initialization of the session. Accessing the session apparently does not force initialization but writing into the session does. What I do in my controller is this now: ``` class MyController < ApplicationController protect_from_forgery def index session["init"] = true do_stuff end end ``` Still I'm not sure if this should be considered normal behavior in Rails. It doesn't look right to me having to write into the session to force initialization. Reading should be enough.
18,774,821
I have a HTML form with button: ``` <form action="/" method="post" id="MyForm"> <input type="hidden" name="Field1" value="Value1" /> <input type="hidden" name="Field2" value="Value2" /> <input type="submit" name="name" value="submit" /> </form> ``` I have event handler for submit attached to Window: ``` window.onsubmit = function() { alert("Submit happening!"); }; ``` This event handler fires properly if I click "Submit" button. However events never works when submit is triggered programmatically from javascript: ``` $("#MyForm")[0].submit(); ``` How to catch submit event handler when it was initiated by Javascript, not by User click? I tried to subscribe for Form event using Jquery or AddEventListener - does not work.
2013/09/12
[ "https://Stackoverflow.com/questions/18774821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/508797/" ]
That's because you shouldn't just use the `submit` function, but `trigger` the submit like: ``` $("#MyForm").trigger('submit'); ```
46,708,486
I am using Google Endpoints Framework with Python (<https://cloud.google.com/endpoints/docs/frameworks/python/get-started-frameworks-python>) and have been building REST APIs with it. I am able to return JSON object (dictionaries) in the response like: ``` { "items":[ { "id": "brand_1_id", "name": "Brand 1" }, { "id": "brand_2_id", "name": "Brand 2" } ] } ``` However, I am not able to return a JSON array (list) as response like: [ { "id": "brand\_1\_id", "name": "Brand 1" }, { "id": "brand\_2\_id", "name": "Brand 2" } ] Following are the code snippets I have been using to return the response **Following are the classes created to send a response:** ``` class BrandResponse(messages.Message): id=messages.StringField(1, required=True) brandName = messages.StringField(2, required=True) brandEmail=messages.StringField(3, required=True) brandPhone=messages.StringField(4,required=True) brandAddress=messages.StringField(5,required=True) brandCity=messages.StringField(6,required=True) brandState=messages.StringField(7,required=True) brandCountry=messages.StringField(8,required=True) brandPostalCode=messages.StringField(9,required=True) class MultipleBrandResponse(messages.Message): items=messages.MessageField(BrandResponse,1,repeated=True) ``` **Following is the method that processes the request:** ``` @endpoints.method( MULTIPLE_BRAND_PAGINATED_CONTAINER, MultipleBrandResponse, path='brand', http_method='GET', name='Get Brands', audiences=firebaseAudience ) def getBrands(self,request): brandResponse=[] query = BrandDB.query() brands = query.fetch(request.limit, offset=request.start) for brand in brands: brandResponse.append(BrandResponse( id=brand.key.urlsafe(), brandName=brand.name, brandAddress=brand.address, brandCity=brand.city, brandState=brand.state, brandCountry=brand.country, brandPostalCode=brand.postalCode, brandPhone=brand.phone, brandEmail=brand.email)) print("Brand count: "+str(brandResponse.count)) if len(brandResponse) == 0: raise endpoints.NotFoundException("No brands") return MultipleBrandResponse(items=brandResponse) ``` Any idea how to return JSON array directly rather than wrapping in side a key inside a JSON object.
2017/10/12
[ "https://Stackoverflow.com/questions/46708486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1161911/" ]
Just create a listener and assign it to your views like you would any other attribute. ``` OnClickListener l = new OnClickListener(){ public void onClick(View v){ // TODO whatever... } } for(i=0 ; i < optionCubesTextviews.length; i++) { optionCubesTextviews[i].setTag(i); optionCubesTextviews[i].setOnClickListener(l); } ```
5,556,754
I'm trying to learn objective-c and am having a hard time coming from (java / C#). Does anyone have sample code that explains how the inner workings of objective-c work? I found a couple tutorials (below) but I'd like to start working through some examples that are a little more complex than "hello world". <http://cocoadevcentral.com/d/learn_objectivec/> <http://www.otierney.net/objective-c.html> <http://mobileappmastery.com/objective-c-tutorial/>
2011/04/05
[ "https://Stackoverflow.com/questions/5556754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/382906/" ]
Ray Wenderlich has some very good tutorials. His [Simple iPhone App Tutotial](http://www.raywenderlich.com/1797/how-to-create-a-simple-iphone-app-tutorial-part-1) is in 3 parts. If you follow it step by step, it will give you a great overview on how an iOS app works. Once you complete it, you can follow is more complex tutorials. Good luck.
22,857,387
I have two tables. One contains articles with an `Article_ID`. The other contains `Image_URL`, `Article_ID`, `height` and `width` (multiple images per article). I would like to produce a list of individual articles, along with the `Image_URL` of the image with the largest `height` associated with that article. I currently have: ``` SELECT Image_URL, Article_Images.Article_ID, height, width FROM Article_Images INNER JOIN `Articles` ON `Articles`.Article_ID = Article_Images.Article_ID GROUP BY Article_ID ORDER BY height ``` But this doesn't appear to be giving me the largest `height` image of each Sample Records: **Articles** Article\_ID | Article\_Name --- 1 'Welcome to London' 2 'Things to do in London' --- **Article\_Images** Image\_ID | Article\_ID | Image\_URL | height | width --- 1 | 1 | img1.jpg | 300 | 600 2 | 1 | img2.jpg | 200 | 200 3 | 2 | img12.jpg | 100 | 200 ---
2014/04/04
[ "https://Stackoverflow.com/questions/22857387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3463248/" ]
``` SELECT a.*, b.* FROM Articles a INNER JOIN Article_Images b ON a.Article_ID = b.Article_ID INNER JOIN ( SELECT Article_ID, MAX(height * width) Largest_Image FROM Article_Images GROUP BY Article_ID ) c ON b.Article_ID = c.Article_ID WHERE (b.height * b.width) = c.Largest_Image ``` but this will lead to confusion as to `5x7 = 7x5`. * [SQLFiddle Demo](http://sqlfiddle.com/#!2/947190/1) **Based on the largest height value,** ``` SELECT a.*, b.* FROM Articles a INNER JOIN Article_Images b ON a.Article_ID = b.Article_ID INNER JOIN ( SELECT Article_ID, MAX(height) height FROM Article_Images GROUP BY Article_ID ) c ON b.Article_ID = c.Article_ID AND b.height = c.height ``` * [SQLFiddle Demo](http://sqlfiddle.com/#!2/947190/2)
651,892
I'm new to Altium. I have a question about libraries in Altium. If I draw a passive component such as a capacitor in the schematic library of Altium, after all packages of capacitors like 0402, 0603, 1206, and so on separately draw their footprint in PCB Library. Is it suitable to add all footprints into a component symbol in the schematic library of Altium?
2023/01/29
[ "https://electronics.stackexchange.com/questions/651892", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/299280/" ]
It's up to you. If you want each component in the library to represent a specific component with one or two possible part numbers and suppliers then it doesn't make sense to have multiple footprints. If you just want a generic capacitor symbol and you'll figure out the BOM part number and suppliers some other time, then your method involves less up-front work (and more work later). Similarly, you can create different symbols for each *value* (as well as package) of capacitor or resistor or just have a generic 0402 or whatever. At the extreme you can create a 3D STEP model with value markings for (say) each 0603 resistor and tie that to the component package and value. Some suppliers such as JLC may make a subset of their available components available as an Altium library, which simplifies ordering PCBA from that one supplier.
4,643,057
I have $13$ balls. $6$ red , $4$ blue , $3$ yellow. I want to arrange in a line such that the right side and the left side do not have blue balls. ( balls in the same color are not distinct ). I tried to calculate the options without any terms or conditions which is 13! divided by $6!4!3!$. ( ! is factorial ) and then subtract the options that contain having blue ball on the right side and the left side which is : ($4$ choose $2$ for the blue balls on each side) multiply by ( $11!$ divided by $(6!2!3!)$ which are the remaining $11$ balls left). but I'm not getting the right answer. What am I doing wrong in the process?
2023/02/20
[ "https://math.stackexchange.com/questions/4643057", "https://math.stackexchange.com", "https://math.stackexchange.com/users/1151156/" ]
You write: > > and then subtract the options that contain having blue ball on the right side and the left side > > > But what you need is to subtract off the number of arrangements that have a blue ball on the left *or* right side. You multiply by $\binom{4}{2}$, I guess to pick which blue balls go on the side? But you don't need this factor since they're indistinguishable. As soon as you say B goes on the left side, all you need is to specify the other 12 balls. Instead I would break it into 3 steps: * Find the number of arrangements where B is on the left * Find the number of arrangements where B is on the right * Subtract the number of arrangements where B is on both sides, to avoid double counting
3,531,393
I want to be able to loop over a list and return a single row where all the list elements have matched. e.g. lest say my list of id's is 1,2,3 I want to write an SQL statment that will do the following (without breaking). SELECT id1 FROM TBL WHERE 0=0 AND id2 = 1 AND id2 = 2 AND id2 = 3 Is this possible? Thanks in advance
2010/08/20
[ "https://Stackoverflow.com/questions/3531393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/426402/" ]
Do you mean that you want all `id1` records for which there is a matching `id2=1` and a matching `id2=2` and a matching `id2=3`? ``` WITH tbl As ( SELECT 1 AS id1, 1 AS id2 UNION ALL SELECT 1 AS id1, 2 AS id2 UNION ALL SELECT 1 AS id1, 3 AS id2 UNION ALL SELECT 1 AS id1, 4 AS id2 UNION ALL SELECT 2 AS id1, 1 AS id2 UNION ALL SELECT 2 AS id1, 2 AS id2 UNION ALL SELECT 3 AS id1, 1 AS id2 UNION ALL SELECT 3 AS id1, 2 AS id2 UNION ALL SELECT 3 AS id1, 3 AS id2 ) SELECT id1 FROM tbl WHERE id2 IN (1,2,3) GROUP BY id1 HAVING COUNT(DISTINCT id2) = 3 ``` Returns ``` id1 ----------- 1 3 ``` Is that what you need?
69,120,718
I have been trying to implement an api to integrate with live meeting to face recognize. Not sure if Ms teams allows access to the live video.
2021/09/09
[ "https://Stackoverflow.com/questions/69120718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16871128/" ]
`max_connections=65536` is unreasonably, perhaps dangerously, high. Lower it to 100. If 90000 connections are *active* at once, MySQL will meltdown. It is better to avoid too many connections than to let them stumble over each other. (Consider what would happen if you let 10000 people into a grocery store *at the same time*. Traffic would be so clogged up that people might take an hour to buy just one item.) If your IoT action is a quick connect-insert-disconnect, that should take very few milliseconds. If the connections came in *very* smoothly and take 10ms *elapsed* each, they could handle 90K per minute with only `max_connections=15`. Benchmarks have shown that MySQL gets bottlenecked at not much more than the number of CPU cores that you have. So, by limiting the number of *current active* connections to `max_connections=100` should be a safe compromise. Set `back_log` to a higher number, maybe 1000. (I do not have a feel for what a good number is.) The idea is that *delaying* the connection is better than letting it in, only to be stalled. I am confident that MySQL can handle 90K IoT inserts per minute, but only if you take the advice here. You mentioned "connection pooling". The 100 and 1000 should be moved back into the pooling layer. Or get rid of the layer. (It is hard to say which would be better.)
68,694,097
As far as I know, type generics happens in the following code: ```java public class Test { public void a(List<Object> list) { } public void a(List<String> list){ } public void a(List<Integer> list){ } } ``` when the compiler compiles the code, the generic types will be erased so all the signatures are exactly same, which looks as follows: ```java public class Test { public void a(List list) { } public void a(List list){ } public void a(List list){ } } ``` If this is the logic, then: ```java List<Object> objList = new ArrayList<>(); List<String> strList = new ArrayList<>(); objList = strList; ``` is actually: ``` List objList = new ArrayList<>(); List strList = new ArrayList<>(); objList = strList; ``` which is OK because both of the two lists are same type. However, In the above code, `objList = strList` will result an error. Not quite sure what is the real logic. And what is more, the difference between `List<?>`, List(without any braces) and `List< Object>`
2021/08/07
[ "https://Stackoverflow.com/questions/68694097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4545405/" ]
To complement [@Giorgi Tsiklauri's answer](https://stackoverflow.com/a/68694372/9304999), For the class below: ```java class Box<T> { T t; T getT() { return t; } void setT(T t) { this.t = t; } } ``` because of type erasure, compiler compiles the class to: ```java class Box { Object t; Object getT() { return t; } void setT(Object t) { this.t = t; } } ``` So, when you instantiate the `Box<T>` generic class with type argument `Integer` as follows: ```java Box<Integer> box = new Box<Integer>(); box.setT(10); Integer t = box.getT(); ``` the compiler knows that the `Box<T>` is instantiated with `Integer` because, at compile time, it sees that `Box<Integer>`. So, type casts are inserted by compiler. So the code above is compiled into: ```java Box box = new Box(); box.setT(10); Integer t = (Integer) box.getT(); // compiler inserts type casts in lieu of us! ``` No matter how you instantiate the generic, the compiler doesn't create additional class files. If what actually happens at type erasure is replacement(replaces `T` with type argument such as `Integer`), the compiler have to create additional classes for `Box` for `Integer`, `Box` for `Double` etc — But that's not what actually happens at type erasure: > > Replace all type parameters in generic types with their bounds or `Object` if the type parameters are unbounded. — [The Java™ Tutorials](https://docs.oracle.com/javase/tutorial/java/generics/erasure.html) > > > > > Insert type casts if necessary to preserve type safety. — [The Java™ Tutorials](https://docs.oracle.com/javase/tutorial/java/generics/erasure.html) > > > > > Type erasure ensures that no new classes are created for parameterized types; consequently, generics incur no runtime overhead. — [The Java™ Tutorials](https://docs.oracle.com/javase/tutorial/java/generics/erasure.html) > > >
37,223,456
I've two content provider based apps A and B. Both have their own content providers and are setup for reading data from A and B and vice versa. Everything works fine when the other app is in background. But couldn't find another content provider if the app is killed or not present in background. For example, App B wants to read data from App A. 'B' can read data from 'A' successfully when 'A' is running in background, but gave fatal error (Match uri not found) if 'A' is not running in background. Any thoughts ? [EDIT] I'm getting the same issue as [this post](https://stackoverflow.com/questions/36883193/android-contentresolver-query-sometimes-not-starting-contentprovider-process). I've this in both apps' manifest: ``` <provider android:name="MyContentProvider" android:authorities="com.example.${applicationId}-provider" android:enabled="true" android:exported="true" android:grantUriPermissions="true"> </provider> ``` This the error I'm getting: > > Writing exception to parcel > java.lang.IllegalArgumentException: Unsupported URI(Query): content://com.example.appA-provider/appA > at com.example.provider.MyContentProvider.query(MyContentProvider.java:142) > at android.content.ContentProvider.query(ContentProvider.java:1007) > at android.content.ContentProvider$Transport.query(ContentProvider.java:218) > at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112) > at android.os.Binder.execTransact(Binder.java:461) > > > Note: This only happens when another app is not in background, otherwise it works as expected (can read each other's data fine). [EDIT 2] Here's code for MyContentProvider: ``` package com.example.provider; import android.content.ContentProvider; import android.content.ContentValues; import android.content.UriMatcher; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; public class MyContentProvider extends ContentProvider { private static DatabaseHelper dbHelper; private static final int ALL_ENTRIES = 1; private static final int SINGLE_ENTRY = 2; private String mAuthority = BuildConfig.APPLICATION_ID; private static UriMatcher uriMatcher; public Uri CONTENT_URI= null; static { uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); } public MyContentProvider() {} public void init(String packageName, String authority) { if (authority == null) { setAuthority(packageName, true); } else { setAuthority(authority, false); } uriMatcher.addURI(getAuthority(), TABLE_NAME, ALL_ENTRIES); uriMatcher.addURI(getAuthority(), TABLE_NAME + "/#", SINGLE_ENTRY); CONTENT_URI = Uri.parse("content://" + getAuthority() + "/" + TABLE_NAME); } private void setAuthority(String packageName, boolean isPackageName) { if (isPackageName) { mAuthority = packageName + ".myprovider"; } else { mAuthority = packageName; } } public String getAuthority() { return mAuthority; } public Uri getContentUri() { return CONTENT_URI; } @Override public boolean onCreate() { dbHelper = new DatabaseHelper(getContext()); return false; } //Return the MIME type corresponding to a content URI @Override public String getType(Uri uri) { if (uri == null) { throw new IllegalArgumentException("Content uri is null: " + uri); } if (uriMatcher == null) { throw new IllegalArgumentException("Unsupported Match URI: " + uri); } switch (uriMatcher.match(uri)) { case ALL_ENTRIES: return "vnd.android.cursor.dir/vnd." + getAuthority() + "." + TABLE_NAME; case SINGLE_ENTRY: return "vnd.android.cursor.item/vnd." + getAuthority() + "." + TABLE_NAME; default: throw new IllegalArgumentException("Unsupported URI: " + uri); } } @Override public Uri insert(Uri uri, ContentValues values) { Uri _uri = null; long id = 0; SQLiteDatabase db = dbHelper.getWritableDatabase(); switch (uriMatcher.match(uri)) { case ALL_ENTRIES: case SINGLE_ENTRY: id = db.insert(TABLE_NAME, null, values); getContext().getContentResolver().notifyChange(uri, null); _uri = Uri.parse(CONTENT_URI + "/" + id); break; default: throw new IllegalArgumentException("Unsupported URI (insert): " + uri); } return _uri; } @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteDatabase db = dbHelper.getWritableDatabase(); SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder(); Cursor cursor = null; String id = null; switch (uriMatcher.match(uri)) { case ALL_ENTRIES: queryBuilder.setTables(TABLE_NAME); cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder); break; case SINGLE_ENTRY: queryBuilder.setTables(TABLE_NAME); id = uri.getPathSegments().get(1); if (id != null && !id.isEmpty()) { queryBuilder.appendWhere(TABLE_NAME + "=" + id); } cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder); break; default: throw new IllegalArgumentException("Unsupported URI(Query): " + uri); } return cursor; } } ```
2016/05/14
[ "https://Stackoverflow.com/questions/37223456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/911359/" ]
Here you go. Important points:- 1) Have set a class of "tab" to the `li` elements instead of the anchor elements. 2) The `mouseover` event listeners are set for all "tab"-classed elements in the JS code, making your HTML neater. 3) Used `event.target` to pass the reference to the element on which the mouse hovered to `step()` 4) Would recommend adding another event listener for `mouseout` to reset the background color change for the li elements. [Link to JSFiddle](https://jsfiddle.net/34tbw2eh/3/) Full Code => ``` <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> img { margin: 10px; width: 270px; float: left; opacity: 0.4; } ul { list-style-type: none; background-color: rgb(0, 0, 0); margin: 0; padding: 0; overflow: hidden; } li { float: left; } li a { display: block; padding: 12px; text-decoration: none; color: white; cursor: pointer; } div a img:hover { opacity: 1.0; width: 290px; margin: 5px 0 0 0; } #mid { overflow: hidden; margin: 40px auto; width: 1170px; } </style> </head> <body> <ul> <li class="tab"><a href="som.html">Shadow of Mordor</a> </li> <li class="tab"><a href="tr.html">Tomb Raider</a> </li> <li class="tab"><a href="ac.html">Assassin's Creed</a> </li> <li class="tab"><a href="bf4.html">Battlefield 4</a> </li> </ul> <div id="mid"> <div> <a href="http://worldversus.com/img/assassins-creed.jpg"> <img src="images/ac/1.jpg"> </a> </div> <div> <a href="http://www.mediastinger.com/wp-content/uploads/2013/10/Assassins-Creed-Black-Flag-after-credits-hq.jpg"> <img src="images/ac/2.jpg"> </a> </div> <div> <a href="http://egmr.net/wp-content/gallery/18-nov-2014-review-ac-unity/assass-unity.jpg?24e25d"> <img src="images/ac/3.jpg"> </a> </div> <div> <a href="https://images-eds-ssl.xboxlive.com/image?url=8Oaj9Ryq1G1_p3lLnXlsaZgGzAie6Mnu24_PawYuDYIoH77pJ.X5Z.MqQPibUVTc0FCED4ph6ouevcPKpUexEae42sK1L4abdr36cYbFg4G4ofQlf6Ap41qwSQE4bCej.ENDwdWBb6xDzigKhhH0qYvtoqHqiprHkhGpbyYtNJE3oju9YrHyPXal_7gB.XZvNrsFG5dcIRXfUV33KDFrPeFl379b5KBjp2MNGhf.7LU-&format=jpg"> <img src="images/ac/4.jpg"> </a> </div> </div> <div id="mid"> <div> <a href="http://hq-oboi.ru/photo/assasins_krid_1920x1080.jpg"> <img src="images/ac/5.jpg"> </a> </div> <div> <a href="http://www.imgbase.info/images/safe-wallpapers/video_games/assassins_creed_2/4247_video_games_assasins_creed.jpg"> <img src="images/ac/6.jpg"> </a> </div> <div> <a href="http://wallpoper.com/images/00/45/05/97/assassins-creed-11_00450597.jpg"> <img src="images/ac/7.jpg"> </a> </div> <div> <a href="https://images-eds-ssl.xboxlive.com/image?url=8Oaj9Ryq1G1_p3lLnXlsaZgGzAie6Mnu24_PawYuDYIoH77pJ.X5Z.MqQPibUVTcsPTaZHCOi.gQ4NDogeo4.TqXBFvO.nSfIzhmc_YrTHs0al36bdFgkybp_1BaryxmOBZ4OnePryCoo0dAUhCvuKYPS17rz27TOZ6fKbVR9T9cW6h_VpeaE3eGtS8JmETueVQdOrvbOyLjTTbxjs_FKOhnSrdWbfQ2uFgJamJ929Y-&format=jpg"> <img src="images/ac/8.jpg"> </a> </div> </div> <script src="scripts/main.js"></script> <script type="text/javascript"> function step(delta, element) { console.log("step() called"); var from = [0, 0, 0], to = [180, 120, 120]; element.style.backgroundColor = 'rgb(' + parseInt(from[0] + delta * (to[0] - from[0])) + ',' + parseInt(from[1] + delta * (to[1] - from[1])) + ',' + parseInt(from[2] + delta * (to[2] - from[2])) + ')'; } function smooth(event) { console.log("smooth() called"); var duration = 200; var start = new Date(); var id = setInterval(change, 1); function change() { var timePassed = new Date() - start; var progress = timePassed / duration; if (progress > 1) progress = 1; var delta = progress; step(delta, event.target); if (progress == 1) clearInterval(id); } } var tabAnchorTags = document.getElementsByClassName("tab"); for (var i = 0; i < tabAnchorTags.length; i++) { tabAnchorTags[i].addEventListener("mouseover", smooth, false); } </script> </body> </html> ```
28,677,898
I can successfully assign scripts to images in Google spreadsheets. My problem is with parameter passing. I have this script to write the current time on a cell. ``` function Time(cell){ var d = new Date(); var timeAsString = d.getHours() + ":" + d.getMinutes() + "/" + d.getSeconds(); SpreadsheetApp.getActiveSheet().getRange(cell).setValue(timeAsString); }; ``` I need a bunch of buttons to do this with diferent cells, so I wish to specify which cell the time goes to by parameter. Many tx.
2015/02/23
[ "https://Stackoverflow.com/questions/28677898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4597600/" ]
Sorry, but this really doesn't solve my problem. I don't want user input. The idea is to have a button associated to each cell. The user just presses a button and the cell is filled with a timestamp. If the user must input the cell name, it's ruined. Current solution works but it's ugly: ``` function Time(cell){ var d = new Date(); var timeAsString = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(); SpreadsheetApp.getActiveSheet().getRange(cell).setValue(timeAsString); }; function TimeB12(){Time('B12')}; function TimeB13(){Time('B13')}; // about 500 more cells... ``` I then associate script TimeB12 to button next to cell B12, and so on.
396,143
I am currently thinking about open-sourcing a project of mine and am in the process of preparing the source code and project structure to be released to the public. Now I got one question: how should I handle the signature key for my assemblies? Should I create a new key for the open-source version and publish it along with the other files to the SVN repository? Should I leave the key out and everyone who wants to compile the code should generate his own key? How do you handle this? I feel a little bit uncomfortable with releasing a signature key to the public.
2008/12/28
[ "https://Stackoverflow.com/questions/396143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19246/" ]
For [Protocol Buffers](https://github.com/google/protobuf), I release the key. Yes, that means people can't actually trust that it's the original binary - but it makes life significantly easier for anyone who wants to modify the code a bit, rebuild it, and still be able to use it from another signed assembly. If anyone really wants a version of Protocol Buffers which they can trust to be definitely the legitimate one built with the code from GitHub, they can easily build it themselves from the source that they trust. I can certainly see it from both sides though. I think if I were writing an Open Source project which revolved around *security* that might be a different matter.
3,852,494
I have a window that shows customer infomation. when the window loads, I call `LoadCustomer()` method from the constructor which loads the customer information from the database asynchorously, which sets the `CurrentCustomer` property. and then the UI is updated because it is bound to the `CurrentCustomer`. ``` private void LoadCustomer(Guid customerID) { var customerContext = new CustomerContext(); var customerQuery = customerContext.GetCustomersQuery() .Where(e => e.CustomerID == customerID); customerContext.Load(customerQuery, loadOperation => { CurrentCustomer = loadOperation.Entities.SingleOrDefault(); }, null); } ``` The senior programmer has told me that it's better to put this logic inside CurrentCustomer's get accessor, because then * the calls to the database will use lazy loading, and * the refactoring would be easier. Is it good practice to put async database calls inside property's get accessor?
2010/10/04
[ "https://Stackoverflow.com/questions/3852494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/312462/" ]
**Generally, it's not.** Usually if getting something would involves doing something else expensive as well, you should use a full getter method just for this purpose: ``` public object GetSomething() { } // accessing code var value = obj.GetSomething(); ``` This signifies that getting that something isn't free... Compare to: ``` var value = obj.Something; ``` This looks more like a normal value assignment hiding the dangerous async call going on behind the scene which, IMO is a bad idea. **But as with everything else... *it depends* on other parts in the whole architecture as well.** If the whole purpose of the object is to abstract away lots of asynchronous calls using property (such as the case with Linq2Sql or Entity Framework entities) then that's fine because you must be aware that you're dealing with calls that are not (or close to) free from the context of the code. ... It depends on the context of the code. If whenever you are accessing this property, you are sure you'll be reminded of the expensive call, then I think it is fine. But if that isn't the case, then you should make it more explicit by turning it into a full-blown method instead of a property.
382,535
We have an SPItemEventReceiver compiled into its own assembly. We are using STSDev to package up a SharePoint solution with this EventReceiver as a feature. I am not assigning the SPItemEventReceiver to a specific ListTemplateId within the elements.xml, but am instead linking a ReceiverAssembly in the feature.xml and programmaticaly assigning the SPItemEventReceiver to multiple SPList items. ``` public override void FeatureActivated(SPFeatureReceiverProperties properties) { foreach (SPWeb web in site.AllWebs) { SPListCollection webListCollection = web.Lists; foreach (SPList myList in webListCollection) { if (myList.Title == "Lab Reports") { SPEventReceiverDefinitionCollection receivers = myList.EventReceivers; SPEventReceiverDefinition receiver = receivers.Add(); receiver.Name = "PostUpdateLabReport"; receiver.Assembly = "LabReportEventHandlers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1111111111111"; receiver.Class = "LabReportEventHandlers.LabReportsHandler"; receiver.Type = SPEventReceiverType.ItemUpdated; receiver.Update(); break; } } web.Dispose(); } } ``` I am using FeatureDeactivating to do the reverse of the above code, removing the EventReceiver from the lists. **Question:** How should I handle the future event where LabReportEventHandlers is updated and the version changes? These are the options I can think of: 1. Deactivate / Reactivate feature -- I would wrap the updated dll back into the SharePoint solution file, change my code above to reflect the new version, and use stsadmin to upgrade the solution. I would then deactivate/ reactivate the feature. 2. Add Assembly redirection to the web.config. 3. Don't bump the LabReportEventHandlers version number. Is there something in changing the solution version that will help me? I think there are problems with the 3 options: 1. After deactivation of the feature, someone could update an item before I can reactiave. 2. I would not want to edit the web.config by hand, so I would use the sharepoint API instead. Where would I run that code? 3. This is just plain wrong, but easy.
2008/12/19
[ "https://Stackoverflow.com/questions/382535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1048/" ]
Maybe you can encapsulate the logic that is prone to change into a separate assembly, that is referenced and used by your event handler. This way, the event handler itself won't change have to change, you would only deploy the updated "logic" assembly to the GAC or bin directory(ies) appropriately. HTH, jt
57,225,678
I have `ActivityGame` which has `TextView` that contains a par number. In that same `Activity` I have a `RecyclerView` and that `RecyclerView`, of course, contains multiple items. Those items have different par numbers. For example, the Par number in `ActivityGame` is 3, now in `RecyclerView` items, let's say I have 1 item which has par number of 3, second has 2 and third has 4. If an item's par number is the same as `ActivityGame`'s par number, then that items par numbers background should turn to grey. If item's par number is more than par number in the `ActivityGame`, then item's par number background should change to purple. And finally, if its smaller than `ActivityGame`'s par number, the item's par number background should change to blue. Here is something I tried to do in the adapter, in order to make this work: ``` @Override public void onBindViewHolder(@NonNull GameViewHolder holder, int position) { holder.mTextPar.setText(currentItem.getText2()); /** If persons par number is smaller than course par number, then change persons par number background to blue **/ if (Integer.parseInt(holder.mTextPar.getText().toString()) < Integer.parseInt(ActivityGame.mHoleNm.getText().toString())) { holder.mTextPar.setBackgroundColor(Color.parseColor("#255eba")); notifyDataSetChanged(); } } ``` This is what I thought would work, but it didn't, when I try to open `ActivityGame` where all this happens, my app crashes instantly. I assume that `onBindViewHolder` is the correct place to make this happen, but I obviously have a wrong method. If you have a better idea where or how should I handle this, please share it. Thanks in advance.
2019/07/26
[ "https://Stackoverflow.com/questions/57225678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11811714/" ]
On a web page you'll need to use `&nbsp;` for extra spaces. So something like: ``` echo ucfirst(date_i18n( 'j F &\n\b\s\p;&\n\b\s\p;&\n\b\s\p; H:i', $ts->getTimeStamp()-(60*60*4))); ```
1,208,519
Let $A$ be a matrix in $\mathbb C^{n×n}$, let $λ$ be an eigenvalue of $A$ with eigenvector $x$. Why is there some $y \in \mathbb C^n$ such that $adj(A−λI)=x{y^\*}$?
2015/03/27
[ "https://math.stackexchange.com/questions/1208519", "https://math.stackexchange.com", "https://math.stackexchange.com/users/226781/" ]
$$\begin{align} \int\_0^a \int\_0^x (x^2+y^2)^{1/2} dy dx &= \int\_{0}^{\pi /4} \int\_0^{a/\cos \phi} \rho^2 d\rho d\phi\\ &= \frac{a^3}{3}\int\_{0}^{\pi /4} \sec^3(\phi) d\phi \end{align}$$ which can be evaluated in closed form with some effort.
160,654
I need to SUM Time of this Interval and Group by 30 and 30 minutes. ``` CREATE TABLE foo AS SELECT date_start::timestamp, date_end::timestamp, agent FROM ( VALUES ('2017-01-06 06:52','2017-01-06 06:52',164), ('2017-01-06 06:56','2017-01-06 07:25',164), ('2017-01-06 06:56','2017-01-06 07:05',169), ('2017-01-06 06:56','2017-01-06 10:29',142), ('2017-01-06 06:57','2017-01-06 07:23',116) ) AS t(date_start,date_end,agent); ``` like this example: need to group by 30 and 30 minutes and sum real dates. ``` period | sum_times --------------------------------- 06:30:00 - 07:00:00 | 00:12:36 07:00:00 - 07:30:00 | 01:24:15 07:30:00 - 08:00:00 | 0:30:00 08:00:00 - 08:30:00 | 0:30:00 08:30:00 - 09:00:00 | 0:30:00 09:00:00 - 09:30:00 | 0:30:00 09:30:00 - 10:00:00 | 0:30:00 10:00:00 - 10:30:00 | 0:29:40 ``` Sql code: ``` WITH min_max_time AS ( SELECT MIN(datahora_ini::timestamp(0) ), MAX(datahora_fim::timestamp(0) ) FROM callcenter.agente_login WHERE datahora_ini >= '2017-01-06 00:00:00' AND datahora_ini <= '2017-01-06 23:59:59' ), periods(time) AS ( SELECT generate_series(min, max, '30 minutes'::interval) FROM min_max_time ), w_agentes_logados AS ( SELECT CONCAT(to_char((time),'YYYYMMDD'), to_char(to_timestamp(floor((extract('epoch' from time) / 1800 )) * 1800) AT TIME ZONE 'UTC','HH24MI') ) as id_chamadas_receptiva, SUM(CASE WHEN datahora_ini::timestamp(0) <= time AND datahora_fim::timestamp(0) >= time THEN EXTRACT(EPOCH FROM (datahora_fim - datahora_ini)) else 0 end) as quantidade FROM callcenter.agente_login, periods GROUP BY time ) SELECT * FROM w_agentes_logados ``` expected result, but it's wrong it's not returning the real result. ``` time_id | qty (seconds) ---------------------------------- 201701060630 | 9 201701060700 | 103418 201701060730 | 112410 201701060800 | 137369 201701060830 | 279747 201701060900 | 370753 201701060930 | 372496 ```
2017/01/11
[ "https://dba.stackexchange.com/questions/160654", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/50749/" ]
I've got a ton of questions here, 1. Are these all the same day? 2. What should happen if there is no overlap in time? Let's also focus on this table from the times of 6:30-7:00 ``` date_start | date_end | overlap ---------------------+---------------------+---------- 2017-01-06 06:52:00 | 2017-01-06 06:52:00 | 2017-01-06 06:56:00 | 2017-01-06 07:25:00 | 00:04:00 2017-01-06 06:56:00 | 2017-01-06 07:05:00 | 00:04:00 2017-01-06 06:56:00 | 2017-01-06 10:29:00 | 00:04:00 2017-01-06 06:57:00 | 2017-01-06 07:23:00 | 00:03:00 ``` So how do you get this in your ideal result set? ``` 06:30:00 - 07:00:00 | 00:12:36 ``` **Please, value our time...** When you create sample data, it's important for you to be sure you're not misleading us. I'm sure it's an innocent mistake, but double check next time. Moreover, this should set you down the right path to get this job done.. ``` SELECT tsrange, sum( UPPER(tsrange*tsrange(date_start,date_end)) - LOWER(tsrange*tsrange(date_start,date_end)) ) FROM foo JOIN ( SELECT tsrange(ts::timestamp, ts+'30 minutes'::interval) AS tsrange FROM generate_series( '2017-01-06'::timestamp, '2017-01-17'::timestamp, '30 minutes'::interval ) AS t(ts) ) AS t(tsrange) ON tsrange && tsrange(date_start,date_end) GROUP BY tsrange ORDER BY tsrange ; ``` Let's break it down, here we generate the times in 30 minute intervals as a [timestamp range](https://www.postgresql.org/docs/9.3/static/rangetypes.html).. ``` JOIN ( SELECT tsrange(ts::timestamp, ts+'30 minutes'::interval) AS tsrange FROM generate_series( '2017-01-06'::timestamp, '2017-01-17'::timestamp, '30 minutes'::interval ) AS t(ts) ) AS t(tsrange) ON tsrange && tsrange(date_start,date_end) ``` Then we join this set on an overlap test. The only other clever unintuitive thing is this, ``` sum( UPPER(tsrange*tsrange(date_start,date_end)) - LOWER(tsrange*tsrange(date_start,date_end)) ) ``` In my opinion `tsrange - tsrange` should return an interval (or a cast should be provided). One isn't. So we have to do what's done above. This provides us the duration of the overlap that we previously detected with `&&`. We can `sum(interval)` and produce the result set you want.. ``` tsrange | sum -----------------------------------------------+---------- ["2017-01-06 06:30:00","2017-01-06 07:00:00") | 00:15:00 ["2017-01-06 07:00:00","2017-01-06 07:30:00") | 01:23:00 ["2017-01-06 07:30:00","2017-01-06 08:00:00") | 00:30:00 ["2017-01-06 08:00:00","2017-01-06 08:30:00") | 00:30:00 ["2017-01-06 08:30:00","2017-01-06 09:00:00") | 00:30:00 ["2017-01-06 09:00:00","2017-01-06 09:30:00") | 00:30:00 ["2017-01-06 09:30:00","2017-01-06 10:00:00") | 00:30:00 ["2017-01-06 10:00:00","2017-01-06 10:30:00") | 00:29:00 (8 rows) ```
7,474,738
It gives me to "Copy embed HTML" code: ``` <object style="height: 390px; width: 640px"><param name="movie" value="https://www.youtube.com/v/picasacid?version=3"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><embed src="https://www.youtube.com/v/picasacid?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390"></object> ``` but when I put it on my blog it says "Movie not loaded...".
2011/09/19
[ "https://Stackoverflow.com/questions/7474738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/953123/" ]
Google+ videos are stored as Picasa videos. They are served in a way that does not allow for easy embedding. It would be easier for you to upload them to YouTube and embed using the YouTube code. If you must use the Google+ version you can't use the player code in your Google+ feed because the video stream URL expires every 11 hours. I did it in my website by periodically retrieving the video's RSS feed ``` https://picasaweb.google.com/data/feed/tiny/user/<<the video poster's userid>>/photoid/<<the video's id>> ``` and extracting the `<media:content url="<<video source url>>">`. You can easily achieve this using the Google Picasa Api. I make an AJAX call to get the stream URLs on each user's visit but I have very few visitors. You get a URL for each video format. You use these URLs to replace the URLs from the embed code you can get from inspecting the Google+ player. ``` <embed width="800" height="600" flashvars="fs=1&amp;hl=en&amp;autoplay=1&amp;ps=picasaweb&amp;fmt_list=<<your fmt_list>>&amp;fmt_stream_map=<<your fmt_stream_map>>&amp;playerapiid=uniquePlayerId&amp;video_id=picasacid&amp;t=1&amp;vq=large&amp;auth_timeout=86400000000" wmode="opaque" scale="noScale" bgcolor="#fff" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" src="//www.youtube.com/get_player?enablejsapi=1&amp;vq=hd720"> ``` The URLs are passed to the player in the embed's `flashvar` attribute. You need to replace the video formats list parameter: `fmt_list` and the stream URLs list : `fmt_stream_map`. Keep in mind that the contents of the flashvar attributes are urlencoded and the contents of the `fmt_list` and `fmt_stream_map`, which you send inside the `flashvar` attribute, are also urlencoded so the `fmt_list` and `fmt_stream_map` end up doubly urlencoded. I hope I was explicit enough.
117,909
I once disconnected from a server using a command. I don't remember what the command was and i need that command to setup something for my server. Does anyone know what's the command for disconnect/quit from server
2013/05/21
[ "https://gaming.stackexchange.com/questions/117909", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/31290/" ]
This is a problem caused by Mac OS X's [GateKeeper](http://support.apple.com/kb/HT5290) setting. ================================================================================================ > > Gatekeeper is a new feature in Mountain Lion and OS X Lion v10.7.5 that builds on OS X's existing malware checks to help protect your Mac from malware and misbehaving apps downloaded from the Internet. > > > [This article](http://support.apple.com/kb/ht3662) is related to what you are experiencing. [This solution](http://www.minecraftforum.net/topic/649868-mac-support-101/#app) from minecraft.net seems to work for most people: > > If you see a warning on Lion and above reading "Minecraft" is damaged and can't be opened. You should move it to the trash.", you have to set Gatekeeper to allow Minecraft as it is not yet certified as coming from a known developer. > > > There are two ways: > > > * in System Preferences > Security & Privacy: > > Set "Allow Applications Downloaded From" to 'Anywhere'. > > You have to click the lock on the bottom to make changes. Once you start up `minecraft.app` , you can change it back to 'Mac App Store and identified developers'. > * A different way is to right-click `minecraft.app` and click open. You will be asked for confirmation. > > > --- **If the above doesn't work, try this first:** This will allow your minecraft.app to run: ``` chmod +x ~/Desktop/Minecraft.app/Contents/MacOS/JavaApplicationStub ```
37,208
[![enter image description here](https://i.stack.imgur.com/wr8bh.jpg)](https://i.stack.imgur.com/wr8bh.jpg) About six weeks ago, I threw a bunch of petals from my mom's bougainvillea plant, into this bucket of dirt and these started growing.
2018/02/16
[ "https://gardening.stackexchange.com/questions/37208", "https://gardening.stackexchange.com", "https://gardening.stackexchange.com/users/20811/" ]
Propagating bouganvillea from seed is very challenging, and it certainly won't happen with chucking a few petals into dirt. As it says in the comments you're growing weeds. The usual methods are by taking cuttings or by air layering. <http://www.abc.net.au/gardening/stories/s1103412.htm>
9,358
I've just ordered my first mac and as an impatient hobby photographer I've already been reading up a lot on Aperture and iPhoto. I've seen the iPhoto '11 presentation and was very impressed with the usability and cool features. But I know that I will need Aperture eventually to work on my photos as I like to tweak a lot of things. I currently work with Adobe Lightroom and while I like its advanced stuff, I don't like the basics much such as the organizing, sorting, etc. What I saw in the iPhoto demo certainly looked a lot better. I'm still reading up on aperture but I think (this is only a guesstimate) that it will be less enjoyable and less *easy* to sort/browse/organize your photo's in it than iPhoto. I don't mind using something dumbed down, consumer grade to do this basic stuff, but I do like something more pro to do the actual editing. **So my question is..** What's the workflow that other hobby/pro photographers here use to organize/edit their photos? Do everything in aperture? Start in aperture and export to iPhoto? Start in iPhoto and switch to aperture to edit individual photo's?
2011/03/01
[ "https://apple.stackexchange.com/questions/9358", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/4021/" ]
You should consider Aperture to be a replacement for iPhoto. When you switch to Aperture, you will import your iPhoto DB of photos into Aperture and work with your photos exclusively in Aperture. The features that you are used to in iPhoto will be available in Aperture. Aperture still have a [30-day free trial](http://www.apple.com/aperture/trial) available from Apple. What you can do is make a backup of your iphoto library (because backup are good, right), import the photos into Aperture and give it a try. Over the next 30 days, when you import new photos, import them into both Aperture and iPhoto. This way, if you don't like Aperture, you still have an up-to-date iPhoto library. If you are going to switch to Aperture, then you can delete your iPhoto library to get back that space. I am a terrible photographer and I don't mind Aperture's way of organizing v. iPhoto. Trying to keep two applications in sync with photos, however, is not an ideal solution for long-term use, IMO.
6,221,359
What is difference in between the b.Height and b.Width properties and the b.HorizontalResolution and b.VerticalResolution in C#? ``` Bitmap b = new Bitmap(@"foo.bmp"); ``` For my sample, Height = 65, Width = 375, HorizontalResolution = VerticalResolution = 150.01239 . [MSDN](http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx) says height and width are in pixels, but the HorizontalResolution and the VerticalResolution are pixel per inch. So, does that mean that is the dpi at which this image was scanned from a scanner for example? Or is this something else? The context of the question is the following: I would like to scan a signature and show in it on an asp.net page as an image in a form. The form is a standard government form with clearly defined space for the siganture. What considerations should I take into account when I scan the image so that it displays without any fuzziness when I see it in the browser and when I print the web-page. What I don't understand is if all image formats store (a) the pixel size of the image (height/width) that the browser will display/resize in the image tag and (b) some other dpi equivalent that the printer will use to print? If not what determines the image size on a printed paper?
2011/06/02
[ "https://Stackoverflow.com/questions/6221359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84940/" ]
The dots-per-inch property is important when you want to make sure that an image is displayed on an output device with the same physical size as when it was created. The best example is an image you create with Microsoft Paint. While you work on it, you use your monitor. Which typically has a resolution of 96 pixels per inch. So a 960 x 960 image will display as (roughly) a 10 x 10 inch image on your monitor. Now you print it. Printers are high resolution devices, 600 dots per inch is pretty normal. Which means that your 960 x 960 pixel image will be printed as a 960 / 600 = 1.6 x 1.6 inch image on paper. Your nice design turned into a postage stamp. Clearly that's not desirable, the image needs to be rescaled to look similar on paper as it does on the monitor. The dots-per-inch property of the image lets you do this. The Image.Horizontal/VerticalResolution properties tell you 96, the printer's Graphics.DpiX/Y tell you 600, you know you have to rescale by 600/96 to get the same size image. Do note that there's a side-effect. Every one pixel you drew in Microsoft Paint is turned into a 6 x 6 blob on paper due to the rescaling. The pixels on the paper are very small though so the image is likely to look the same. As long as the image has smooth transitions, like a photo. What does not work well is text, especially the anti-aliased kind. Which is otherwise why screen-shots look so much poorer compared to a report that was generated for a printer.
51,401,028
What would be the most semantic tag to display the **text** contents of the following image grid? I going to implement it in either flexbox or css-grid and I'm searching a better way than just wrap the keywords in div-tags. [![image grid](https://i.stack.imgur.com/fjUUJ.jpg)](https://i.stack.imgur.com/fjUUJ.jpg) Here's my current code (used flexbox) ``` <div class="d-flex flex-wrap gridcontainer"> <div class="gridimage"> <img src="placeholders/img16.jpg" /> </div> <div class="gridkeyword"> <p class="gridkeyword__keyword">Process-Oriented</p> </div> <div class="gridkeyword"> <p class="gridkeyword__keyword">Valence</p> </div> <div class="gridimage"> <img src="placeholders/img12.jpg" /> </div> <div class="gridkeyword"> <p class="gridkeyword__keyword">Quality</p> </div> <div class="gridimage"> <img src="placeholders/img18.jpg" /> </div> ```
2018/07/18
[ "https://Stackoverflow.com/questions/51401028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7832048/" ]
**Blockchain** and **IPFS** are based on similar concepts of decentralized networks, but that's where their similarities end. While blockchain shares a ledger with its nodes, IPFS is a peer to peer file-sharing system that hashes files (similar to the way blockchain hashes transactions), and then allows users to search for files based on those hashes. IPFS and Blockchain are very different, and in fact you can use IPFS to store files while the hashes are kept on the blockchain. It would be like comparing Stack Overflow to Facebook. Both are websites living on the internet, but they accomplish very different tasks for their users.
152,602
For a frontend, i would like to implement MFA (with TOTP). I may be searching for the wrong keywords but i couldn't find the proper way to implement securely this solution. I was searching for a diagram flow for example such as: 1. Request: POST to /login with credentials in JSON, Response 302 to /mfa 2. Request: GET /mfa , Response /mfa 3. Request: POST with credentials again and mfa code , Response 302 to / 4. Request: GET to /, response 302 to / (user logged in) Is there any RFC describing (<https://www.rfc-editor.org/rfc/rfc6238>) in details the implementation of such protocol or its up to the user to sniff other website's ssl to reverse engineer how they did it (which i did for github etc..). Just searching for the correct way to implement it, may be an already working framework? should i use cookies or is it fine to re-request the user and login along with the mfr code ( i noticed github at STEP 3 use `authenticity_token=<base64token>&otp=<123456>` ) Thanks a lot for your help PS; already made solution like login with google are not possible, i need to use my own user's db
2017/02/28
[ "https://security.stackexchange.com/questions/152602", "https://security.stackexchange.com", "https://security.stackexchange.com/users/140675/" ]
You might want to check out PrivacyIDEA and their product and code - they have a working implementation in python, and I think you could use their API for one or both authentication rounds. <https://www.privacyidea.org/> It isn't without a few rough edges here and there (you certainly do not want to let this loose on your user DB without some testing), but might provide you either a service you can use while you research, or a concrete implementation you can base your own off of
27,828
I am a student at Smith College trying to make a Google Docs presentation visible to anyone in the world with a link. However, the options that surface when I click Share only let me share within Smith College. This document is also shared with some other students at Smith College. ![The options that surface when I click Share only let me share within Smith College.](https://i.stack.imgur.com/jn3JZ.png) Why can't I share this presentation with the rest of the world? In fact, I can't even publish it on the web to everyone. ![enter image description here](https://i.stack.imgur.com/cBOn9.png)
2012/06/09
[ "https://webapps.stackexchange.com/questions/27828", "https://webapps.stackexchange.com", "https://webapps.stackexchange.com/users/16571/" ]
It's because you don't have permissions to do so. The administrator of the Google Apps account has disabled this ability. There is a setting in the admin that scopes out the permissions and share abilities. They've [selected the option that restricts other users](http://support.google.com/a/bin/answer.py?hl=en&answer=60781) from being able to see or edit the document unless they are within the organisation, in this case, the school. > > Users **cannot share** documents outside this organization > > > In order to be able to share from Google Docs, you will need to have the administrator's account change the settings permission to allow you to do so.
722,966
One of our servers has a access\_log which is nearly 5GB in size - there is currently no log rotation so I enabled it yesterday for httpd The contents of /etc/logrotate.d/httpd is ``` /var/log/*.log { weekly missingok notifempty sharedscripts delaycompress postrotate /sbin/service httpd reload > /dev/null 2>/dev/null || true endscript } ``` When logrotate runs it generates an error: ``` Anacron job 'cron.daily' on /etc/cron.daily/logrotate: error: found error in /var/log/*.log , skipping ``` I cannot see what the error might be as these all look like valid parameters - any idea what is the issue?
2015/09/17
[ "https://serverfault.com/questions/722966", "https://serverfault.com", "https://serverfault.com/users/142823/" ]
This is caused because of your `/var/log/*.log` which will create a duplicate entry that conflicts with the logs defined in one or more of the other files in `/etc/logrotate.d/` for example `dracut`, `syslog` and others. You can test this by running `logrotate` on the command line, this is the output I get if I use your httpd file on my CentOS 6.7 system ``` logrotate /etc/logrotate.conf error: httpd:1 duplicate log entry for /var/log/dracut.log error: found error in /var/log/*.log , skipping other irrelevant output skipped. ``` I don't know how you have configured your httpd but the defaults for CentOS would be to write logs to `/var/log/httpd/` so a common configuration for /etc/logrotate.d/httpd config would be ``` /var/log/httpd/*log { missingok notifempty sharedscripts delaycompress postrotate /sbin/service httpd reload > /dev/null 2>/dev/null || true endscript ``` If you have changed the default logging location for httpd, perhaps it would be easier to put it back as it was and then use the common config above. If you can't then you're going to have to list the individual log files that you want rotating (which may be more work than you want) ``` /var/log/access_log /var/log/error_log /var/log/vhost1_access_log and so on... { missingok notifempty sharedscripts delaycompress postrotate /sbin/service httpd reload > /dev/null 2>/dev/null || true endscript ```
55,142,820
I have a table containing multiple columns one of which is a jsonb object. I want to create a new column from one of the json variables, but the update command appends to the bottom of the table. I have: ``` time info id some_json 12 bla {"id":"123","more_info":"bla bla"} 13 bla {"id":"124","more_info":"bla bla"} ``` I need: ``` time info id some_json 12 bla 123 {"id":"123","more_info":"bla bla"} 13 bla 124 {"id":"124","more_info":"bla bla"} ``` I get: ``` time info id some_json 12 bla {"id":"123","more_info":"bla bla"} 13 bla {"id":"124","more_info":"bla bla"} 123 124 ``` When I use `insert_into my_table(id) select some_json ->> 'id' from my_table;` What is the correct way to do this? I'm a SQL beginner and plenty of commands sound like they would be the right for the job (update, insert, select into, alter).
2019/03/13
[ "https://Stackoverflow.com/questions/55142820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8932190/" ]
**In windows:** Press Windows (or Windows+R) and then type “cmd”: Run the Command Prompt in normal mode. 1. `cd C:\Users\user\Desktop\UserDjangoProject> pip install virtualenv` 2. For Create a venv run this `virtualenv -p python3 venv` 3. Activate virtualenv `venv\Scripts\activate` 4. It will look like this `(venv) C:\Users\user\Desktop\UserDjangoProject>` 5. Then run `pip install -r requirements.txt` 6. Run the django project run this`./manage.py runserver`
21,060,891
As title said, I have current location, and want to know the bearing in degree from my current location to other location. I have read [this post](https://stackoverflow.com/questions/4331794/how-can-i-draw-an-arrow-showing-the-driving-direction-in-mapview/4332278#4332278), is the value return by location.getBearing() my answer? **Let say it simply: from the picture, I expect the value of 45 degree.** ![foo](https://i.stack.imgur.com/C5Qob.png)
2014/01/11
[ "https://Stackoverflow.com/questions/21060891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3143433/" ]
I was having trouble doing this and managed to figure it out converting the C? approach to working out the bearing degree. **I worked this out using 4 coordinate points** Start Latitude Start Longitude End Latitude End Longitude Here's the code: ``` protected double bearing(double startLat, double startLng, double endLat, double endLng){ double latitude1 = Math.toRadians(startLat); double latitude2 = Math.toRadians(endLat); double longDiff= Math.toRadians(endLng - startLng); double y= Math.sin(longDiff)*Math.cos(latitude2); double x=Math.cos(latitude1)*Math.sin(latitude2)-Math.sin(latitude1)*Math.cos(latitude2)*Math.cos(longDiff); return (Math.toDegrees(Math.atan2(y, x))+360)%360; } ``` Just change the variable names were needed. Output bearing to a TextView Hope it helped!
83,521
i am building my own distro (which i am almost done) but one thing left is the name of it. since i am not sure what to name it im leaving the "ubuntu" there i know i will have to change the following files * /etc/lsb-release * /etc/issue to my own name and version and code name. am i missing other files? (on my site it shows it's an ubuntu version - i read the tm etc... but i want the name of my distro to be there) thanks
2011/11/28
[ "https://askubuntu.com/questions/83521", "https://askubuntu.com", "https://askubuntu.com/users/34907/" ]
Here's my two cents about this: You can try to change the name of the distribution but be **careful**, if you change something wrong, you might encounter problems while installing or later when you will use it. But if your **absolutely** need to change it here's what you can try: The two you provided are correct (you can also update /etc/issue.net just to be sure). The other thing you can do is this: Open the ISO (ISO Master) file and go to the folder called .disk. In there is a file called info. The release name is there and can be changed. [view this post.](https://askubuntu.com/questions/43942/how-to-change-ubiquity-release-name) This should change the name of your distribution. If that does not work, you can change the following files: *NOTE: the location might change depending the version you are using and file might be not found as well* * /boot/grub/grub.cfg * /etc/grub.d/00\_header * /etc/grub.d/05\_debian\_theme * /usr/share/yelp/ (all files & all sub folders) * /var/run/motd * /etc/motd * /etc/update-motd.d/10-help-text * /lib/init/rw/motd * /etc/gdm/failsafeXinit * /etc/samba/smb.conf * /usr/share/gnome-about/gnome-version.xml * /usr/share/pyshared/usbcreator/install.py * /usr/bin/grub-mkrescue * /usr/lib/grub/i386-pc/config.h * /usr/sbin/grub-install.real * /usr/sbin/grub-mkconfig * /usr/sbin/grub-mknetdir * /usr/sbin/grub-reboot * /usr/sbin/grub-set-default good luck!
15,648,938
I am noob using per so I need some help. For example, I have aminoacids sequance in file. That sequance is in one line. So I need that in one line should be 60 aminoacids. How I could do that using perl?
2013/03/26
[ "https://Stackoverflow.com/questions/15648938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2167473/" ]
The .edmx file is just an XML file under the covers. If worse comes to worst, you can always edit it directly in a text editor if you are careful. Look for Associations and AssociationSets that match the constraint you are interested in and remove those tags. Then save the file and reopen in Visual Studio. Note that if you do this, I would recommend making a backup of the file first, in case you make a mistake somewhere, then you can revert back.
12,736,001
i'm using the greyscale jquery plugin to grayscale images on the fly (by Andrew Pryde). The effetc works like a charm : <http://www.reflexion-graphic.com/projets/forum/jquery/greyscale/1-test-jquery-greyScale-html5.html> But i try to add another jquery function : Show information over image on rollover. The function works alone but with the plugin i have a css issue. Images are not floating anymore : <http://www.reflexion-graphic.com/projets/forum/jquery/greyscale/3-test-jquery-hover-greyScale-html5.html> Could you help me to find what is wrong in the css ? source code (css, html, jquery are easy to find in the example). Thank you very much !
2012/10/04
[ "https://Stackoverflow.com/questions/12736001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1424290/" ]
It's because you've wrapped the images with captions inside block elements, which span the entire width of their containers. `float` applies to the grayscaled images, not to their parent elements, so even though all the images are floated, they are no longer siblings of each other; they are siblings of the hover wrappers. The images are still floated, but they are alone inside their containers (the wrappers), and the wrappers are not floated. You can add hover captions without any JS: simply add the caption as another element inside each `.gsWrapper` element, and style it to show on hover. Stripped-down example: ``` <div class="gsWrapper"> <img class="img_mosaique_cat_projets noir_blanc" src="img/sj-concelles/220x168.jpg" alt="titre projets"> <canvas class="gsCanvas" height="168" width="220" style="left: 0px; position: absolute; top: 0px;"></canvas> <div class="hide-hover">test content for hover</div> </div> ``` And the styling: ``` .hide-hover { position: absolute; } .gsWrapper:not(:hover) .hide-hover { display: none; } ``` This way you do not have to worry about adjusting all your other styling and JS to accommodate for wrappers around some of the images. Other demos: using jQuery slideToggle effect to hide/show the captions: <http://jsbin.com/idugaw/3/edit> using pure CSS for a slideToggle effect: <http://jsbin.com/idugaw/4/edit>
48,750,581
``` <tr id="LO_header_row" class="lo_row> <td class="LO_header" data-assoc="TITLE"> <a href="Modules.php?modname=Scheduling/Courses.php&subject_id=001&page=1&LO_direction=1&LO_search=&LO_sort=TITLE">Course 12345</a> </td> </tr> <tr id="LOy_row1" class="lo_row> <td class="LO_field"> <a href="Modules.php?modname=Scheduling/Courses.php&include_top=&subject_id=001">Course 12345</a> </td> </tr> ``` Hi all. I'm using webdriver IO and I'm trying to navigate to the 2nd link using a selector via clicking. I don't really have much options here besides using something like $('a=Course 12345').click(); in order to navigate to the page. But obviously that returns 2 options. I was wondering what the best way to click the page is? Lots of other stuff on the page share the same classes / ID's (since it is list output) I was trying something like $('.LO\_field [a=Course 12345]') but clearly that doesn't work. Any help? Open to alternative suggestions!
2018/02/12
[ "https://Stackoverflow.com/questions/48750581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9350622/" ]
From [`eslint-plugin-import`](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md) > > **When there is only a single export from a module, prefer using default export over named export.** > > > ``` class HomePage extends Component { //.... } export default HomePage ``` In another file : ``` import HomePage from './Hello'; ``` Check here [`codesandbox`](https://codesandbox.io/s/9y0w3knm8w)
22,694,058
I was told if you need to share between controllers you should use a service. I have controller A, which is a list of news websites, and controller B which is a list of articles on the sites from controller A. Controller B contains the list of articles and an iframe to display the articles. But when you click on controller A it should fade out the iframe and fade in the list. In order to accomplish this I give Controller B's scope to a service that is injected into both controller A and controller B. My question is whether or not it's okay to do that. Basically, I do this: ``` app.factory("sharedService", function () { var $scope = null; return { SetScope: function (scope) { $scope = scope; }, ControllerB_Action: function () { $scope.doSomething(); } }; }); app.controller("controllerA", ["$scope", "sharedService", function ($scope, sharedService) { $scope.onaction = function () { sharedService.ControllerB_Action(); } }]); app.controller("controllerB", ["$scope", "sharedService", function ($scope, sharedService) { sharedService.SetScope($scope); }]); ```
2014/03/27
[ "https://Stackoverflow.com/questions/22694058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1873073/" ]
To use `beforeSend` and `complete` settings of ajax. **[Documentation](https://api.jquery.com/jQuery.ajax/)** Try this: ``` $.ajax({ type:'GET', data:fields, url:'new/addcomm.php', beforeSend: function() { $('#working').show(); }, complete: function() { $('#working').hide(); }, success:function(feedback){ reload(); // alert (feedback); } }); ```
14,113,255
I was trying to get the key hash from my Android app. Facebook SDK 3.0 gave the following code: ``` keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64 ``` When I run this it first says `binary:no error`; It then asks for the password which I enter as `android`. Upon pressing enter it returns blank where I expect the pass code. I used the solution mentioned [here](https://stackoverflow.com/questions/4347924/key-hash-for-facebook-android-sdk); this did give me a key hash but when I use that none of the sessions are opening. My java keytool is stored in : ``` C:\Program Files\Java\jre7\bin ``` And OpenSSL is stored in : ``` F:\openssl\bin ``` I am giving the correct file paths when I run it in MD in Windows. Kindly help me figure this out!
2013/01/01
[ "https://Stackoverflow.com/questions/14113255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1941375/" ]
Here's a simple example that creates a server and a client that connects to that server. Remember that what you send has to be a buffer (strings are automatically converted to buffers). The client and server works independently of eachother, so can be put in the same app or on totally different computers. **Server (server.js):** ``` const net = require("net"); // Create a simple server var server = net.createServer(function (conn) { console.log("Server: Client connected"); // If connection is closed conn.on("end", function() { console.log('Server: Client disconnected'); // Close the server server.close(); // End the process process.exit(0); }); // Handle data from client conn.on("data", function(data) { data = JSON.parse(data); console.log("Response from client: %s", data.response); }); // Let's response with a hello message conn.write( JSON.stringify( { response: "Hey there client!" } ) ); }); // Listen for connections server.listen(61337, "localhost", function () { console.log("Server: Listening"); }); ``` **Client (client.js):** ``` const net = require("net"); // Create a socket (client) that connects to the server var socket = new net.Socket(); socket.connect(61337, "localhost", function () { console.log("Client: Connected to server"); }); // Let's handle the data we get from the server socket.on("data", function (data) { data = JSON.parse(data); console.log("Response from server: %s", data.response); // Respond back socket.write(JSON.stringify({ response: "Hey there server!" })); // Close the connection socket.end(); }); ``` The `conn` and `socket` objects both implement the [`Stream`](http://nodejs.org/api/stream.html#stream_stream) interface.
58,554
I've got a script that makes a terrain object and paints it with textures, but I'm having an issue. When I attempt to place game objects (such as the simple water object that unity provides), I use a Raycast to determine the correct height to place the game object, but that just ensures that it is correctly placed at that particular point. How would I go about flattening the terrain under the game object so that it doesn't go into the terrain or hang out into thin air in the case of hills?
2013/07/03
[ "https://gamedev.stackexchange.com/questions/58554", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/4959/" ]
As I said in my comment, you'll want to find all the vertices that make up the triangles under your game object and set their y value to the same value. I'll expand my comment with more detailed steps. I'm not too familiar with Unity, so I don't know the best tools to use for the job, but I believe I can get you started down the right path. **Brute force method:** 1. Cast a grid of rays straight down from your game object. The grid should be tight enough to ensure it won't miss any triangles on the terrain surface. 2. For each ray that hits something, you can get the triangle in the terrain mesh with the following: ``` RaycastHit hit; if (!Physics.Raycast(camera.ScreenPointToRay(Input.mousePosition), out hit)) return; MeshCollider meshCollider = hit.collider as MeshCollider; if (meshCollider == null || meshCollider.sharedMesh == null) return; Mesh mesh = meshCollider.sharedMesh; Vector3[] vertices = mesh.vertices; int[] triangles = mesh.triangles; Vector3 p0 = vertices[triangles[hit.triangleIndex * 3 + 0]]; Vector3 p1 = vertices[triangles[hit.triangleIndex * 3 + 1]]; Vector3 p2 = vertices[triangles[hit.triangleIndex * 3 + 2]]; ``` 3. p0, p1 and p2 are all the positions of the three vertices that make up the triangle that's been hit. You want to adjust each of those vertices positions to have the same `y` value. You can either collect all the vertices, then set them all to an average `y` value, or you can use the initial picked `y` value you found when placing your game object. **Optimizations:** * Instead of just casting a grid of rays, you can sweep a collider down from the game object and collect the contact points of the collisions between the game object collider and the terrain collision mesh. Then for each of those contact points, perform the steps above for getting the vertices you want to move. * Create your terrain in such a way that each vertex's `x` and `z` values are aligned to a grid, and only varies in its `y` value. Now you can easily get the bounds of your game object and change all the y values of the vertices within those bounds. That last optimization is really an alternative method that would likely be easy to implement and fairly effective.
2,926,554
Suppose I have a string that contains '¿'. How would I find all those unicode characters? Should I test for their code? How would I do that? I want to detect it to avoid sax parser exception which I am getting it while parsing the xml saved as a clob in oracle 10g database. Exception javax.servlet.ServletException: org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
2010/05/28
[ "https://Stackoverflow.com/questions/2926554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/352397/" ]
Yes, this is fairly easy to do :) * Create an activity with the WebView in it and the appropriate settings. * In the TextView, allow the links to fire an intent instead. * Make that intent one that opens the activity with the WebView in it * In that intent object, do `myIntent.putExtra()` and add the URL as an extra * In the WebView-containing activity, use savedInstanceState.getExtras() to retrieve the URL and load it in the WebView You can get more information about intents and how to use them here: <http://developer.android.com/guide/topics/intents/intents-filters.html> You can also [have a look here for the Notepad Tutorial](http://developer.android.com/resources/tutorials/notepad/index.html) application that contains some very basic examples of intents working.
479,432
I was recently introduced to the topic of causal inference in statistics and I am currently learning about the importance of the backdoor criterion (BDC), as applied to the following DAG. Interest lies in assessing the causal effect of the treatment $X$ upon the outcome $Y$. It is easily established that the sets of variables $\lbrace U\_1, U\_3\rbrace$, $\lbrace U\_2, U\_3\rbrace$ and $\lbrace U\_1, U\_2, U\_3\rbrace$ both satisfy the requirements of the BDC. My confusion lies in understanding how a causal effect is modeled. Often I have seen references to OLS regression and regression with inverse probability weighting (IPW). However, I have seen very little in the way of literature describing how these can be applied to a situation such as that described in the DAG below, what conditioning on variables (or sets of variables) means in a regression model and indeed how to establish which of the three sets of variables given above should be conditioned on. A concise explanation of the above concepts as applied to an example DAG, such as the one I have given would be very much appreciated. [![enter image description here](https://i.stack.imgur.com/VkU87.png)](https://i.stack.imgur.com/VkU87.png)
2020/07/28
[ "https://stats.stackexchange.com/questions/479432", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/211178/" ]
Just to add to the excellent answers by Adrian and Noah, there is the residual question of: > > how to establish which of the three sets of variables given above should be conditioned on. > > > Fist let's recap how the backdoor criterion is applied to this particular DAG, which I'm reposting here: [![enter image description here](https://i.stack.imgur.com/VkU87.png)](https://i.stack.imgur.com/VkU87.png) Usually we are interested in the "average causal effect" (ACE) which is the expected increase of $Y$ for a unit change in $X$. This means that we must allow all causal paths between $X \rightarrow Y$ to remain open but we must block any backdoor paths from $Y \rightarrow X$ What makes this DAG quite intriguing is that $U\_3$ appears to be a confounder for $X \rightarrow Y$ but is also a collider (having 2 direct causes, $U\_1$ and $U\_2$). So a simplistic approach would be to say that we need to condition on it to block the backdoor path $Y \leftarrow U\_3 \rightarrow X$) but then we don't want to condition on it, because that will open up the backdoor path $Y \leftarrow U\_2 \rightarrow U\_3 \leftarrow U\_1 \rightarrow X$. This is easily resolved by blocking that path by additionally conditioining on either $U\_2$ or $U\_1$, or indeed both. Thus we have arrived at the 3 candidate adjustment sets $\lbrace U\_1, U\_3\rbrace$, $\lbrace U\_2, U\_3\rbrace$ and $\lbrace U\_1, U\_2, U\_3\rbrace$. All 3 sets will give us an unbiased estimate of the causal effect, so how do we choose between them ? We could reject the larger set $\lbrace U\_1, U\_2, U\_3\rbrace$ on two grounds. First model parsimony. Second $U\_2$ and $U\_3$ are correlated and this correlation could be very high leading to instabilty in the estimation procedure that is used to fit the model. If they are not highly corrrelated then we might still consider this set, but with the additional considerations as below: * we choose the set which gives us the most precise estimate of the causal effect - in a multivariable regression model this would be the estimate with the smallest standard error. * $\lbrace U\_2, U\_3\rbrace$ will yield the most precise estimate because conditional on them, $U\_1$ is an instrument and therefore should not be adjusted for. Adjusting for $U\_2$ would reduce the residual variance of $Y$ more than adjusting for $U\_1$ would. Thanks to Noah for pointing this out in the comments. Here is a monte carlo simulation in R of this DAG that demonstrates this: ``` set.seed(15) nsim <- 1000 se_1 <- numeric(nsim) se_2 <- numeric(nsim) N <- 500 for(i in 1:nsim) { # simulate the DAG U1 <- rnorm(N, 10, 2) U2 <- -U1 + rnorm(N, 10, 2) U3 <- U1 + U2 + rnorm(N, 10, 2) X <- U1 + U3 + rnorm(N, 10, 2) Y <- X + U3 + U2 + rnorm(N, 10, 2) # extract standard error for U1 coefs_1 <- lm(Y ~ X + U3 + U1) %>% summary() %>% coef() se_1[i] <- coefs_1[6] # extract standard error for U2 coefs_2 <- lm(Y ~ X + U3 + U2) %>% summary() %>% coef() se_2[i] <- coefs_2[6] } ggplot(df, aes( x = SE, group = U, color = U)) + geom_histogram(aes(y = ..density..), alpha = 0.7, position = "identity", bins = 30) + geom_density() ``` [![enter image description here](https://i.stack.imgur.com/QFyJv.png)](https://i.stack.imgur.com/QFyJv.png) As we can see, conditioning on $U\_2$ gives consistently lower standard errors than conditioning on $U\_1$
22,664,533
I am calling a controller in spring mvc with form data. Before saving, I check if the id is a certain range. If the id is not within the range, I need to show a message on the same page saying `The id selected is out of Range, please select another id within range`. I found samples on internet where I can redirect to failure jsp in case anything goes wrong. But how to do it in my case? ``` @RequestMapping(value = "/sendMessage") public String sendMessage(@ModelAttribute("message") Message message, final HttpServletRequest request) { boolean check = userLoginService.checkForRange(message.getUserLogin()); if(!check){ return ""; //What Should I do here?????? } } ```
2014/03/26
[ "https://Stackoverflow.com/questions/22664533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3323380/" ]
A simple approach would be to add your error message as a model attribute. ``` @RequestMapping(value = "/sendMessage") public String sendMessage(@ModelAttribute("message") Message message, final HttpServletRequest request, Model model) { boolean check = userLoginService.checkForRange(message.getUserLogin()); if(!check){ model.addAttribute("error", "The id selected is out of Range, please select another id within range"); return "yourFormViewName"; } } ``` Then your jsp can display the "error" attribute if it exists. ``` <c:if test="${not empty error}"> Error: ${error} </c:if> ``` Edit ---- Here's a rough, untested implementation of validation over ajax. JQuery assumed. Add a request mapping for the ajax to hit: ``` @RequestMapping("/validate") @ResponseBody public String validateRange(@RequestParam("id") String id) { boolean check = //[validate the id]; if(!check){ return "The id selected is out of Range, please select another id within range"; } } ``` Intercept the form submission on the client side and validate: ``` $(".myForm").submit(function(event) { var success = true; $.ajax({ url: "/validate", type: "GET", async: false, //block until we get a response data: { id : $("#idInput").val() }, success: function(error) { if (error) { $("#errorContainer").html(error); success = false; } } }); return success; }); ```
5,004,590
Thanks for the previous assistance everyone!. I have a query regarding RegExp in Perl My issue is.. I know, when matching you can write m// or // or ## (must include m or s if you use this). What is causing me the confusion is a book example on escaping characters I have. I believe most people escape lots of characters, as a sure fire way of the program working without missing a metacharacter something ie: \@ when looking to match @ say in an email address. Here's my issue and I know what this script does: ``` $date= "15/12/99" $date=~ s#(\d+)/(\d+)/(\d+)#$1/$2/$3#; << why are no forward slashes escaped?? print($date); ``` Yet the later example I have, shows it rewritten, as (which i also understand and they're escaped) ``` $date =~ s/()(\d+)\/(\d+)\/(d+)/$2\/$1\/$3; <<<<which is escaping the forward slashes. ``` I know the slashes or hashes are programmer preference and their use. What I don't understand is why the second example, escapes the slashes, yet the first doesn't - I have tried and they work both ways. No escaping slashes with hashes? What's even MORE confusing is, looking at yet another book example I also have earlier to this one, using hashes again, they too escape the @ symbol. `if ($address =~ m#\@#) { print("That's an email address"); }` or something similar So what do you escape from what you don't using hashes or slashes? I know you have to escape metacharacters to match them but I'm confused.
2011/02/15
[ "https://Stackoverflow.com/questions/5004590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/564458/" ]
When you build a regexp, you define a character as a delimiter for your regexp i.e. doing `//` or `##`. If you need to use that character inside your regexp, you will need to escape it so that the regexp engine does not see it as the end of the regexp. If you build your regexp between forward slashes `/`, you will need to escape the forward slashes contained in your regexp, hence the escaping in your second example. Of course, the same rule apply with any character you use as a regexp delimiter, not just forward slashes.
23,014,449
I want to compile a program with gcc with link time optimization for an ARM processor. When I compile without LTO, the system gets compiled. When I enable LTO (with -flto), I get the following assembler-error: > > Error: invalid literal constant: pool needs to be closer > > > Looking around the web I found out that this has something to do with the constants in my system, which are placed in a special section called .rodata, which is called a constant pool and is placed right after the .text section in my system. It seems that when compiling with LTO because of inlining and other optimizations this .rodata section gets too far away from the instructions, so that the addressing of the constants is not possible anymore. Is it possible to place the constants right after the function that uses them? Or is it possible to use another addressing mode so the .rodata section can still be addressed? Thanks.
2014/04/11
[ "https://Stackoverflow.com/questions/23014449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3035952/" ]
This is an assembler message, not a linker message, so this happens before sections are generated. The assembler has a pseudo instruction for loading constants into registers: ``` ldr r0, =0x12345678 ``` this is expanded into ``` ldr r0, [constant_12345678, r15] ... bx lr constant_12345678: dw 0x12345678 ``` The constant pool usually follows the return instruction. With function inlining, the function can get long enough that the return instruction is too far away; unfortunately, the compiler has no idea of the distance between memory addresses, and the assembler has no idea of control flow other than "flow does not pass beyond the return instruction, so it is safe to emit the constant pool here". Unfortunately, there is no good solution at the moment. You could try an `asm` block containing ``` b 1f .ltorg 1: ``` This will force-emit the constant pool at this point, at the cost of an extra branch instruction. It may be possible to instruct the assembler to omit the branch if the constant pool is empty, but I cannot test that at the moment, so this is probably not valid: ``` .if (2f - 1f) .b 2f .endif 1: .ltorg 2: ```
28,680,538
What I want to happen: I want to save the current value to a char holder variable. So that, if the current value != holder value it should print move left but when the current value is equal to holder value it should move forward. Problem: The char value holder outputs the same with other statements. What suppose to be the problem? Just based on the direction when it loops. ``` public void reconstructPath(Node node) { while (node.parent != null) { //DIRECTIONS: L - Left, R - Right, U - up, D - Down int nextX, nextY; char direction = 0; char current = 0; nextX = node.parent.x; nextY = node.parent.y; if(nextX == node.x) { if(nextY > node.y){ direction = 'D'; } else{ direction = 'U'; } }else if(nextY == node.y){ if(nextX > node.x){ direction = 'R'; }else{ direction = 'L'; if(direction != 'L'){ System.out.println("move forward"); }else{ char holder = direction; System.out.println("move up"); } } } System.out.printf("Traceback: (%d, %d) go %c\n", node.x, node.y, direction); node = node.parent; } } ``` **Output:** ``` move L // first L should be left. Traceback: (4, 1) go L move L // this should move forward instead of left. Traceback: (3, 1) go L move L Traceback: (2, 1) go L ```
2015/02/23
[ "https://Stackoverflow.com/questions/28680538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4580820/" ]
consider these two consecutive lines: ``` direction = 'L'; if(direction != 'L') ``` Are you missing a close brace after the first one?
46,087,311
I would like to ask a question about Pandas groupby. I am using ipython notebook (python3). For example, there is a dataframe like this. ``` df1 = pd.DataFrame( { "Score" : ["A", "B", "C", "A", "B", "A"] ,"Class": ["Physics", "Science", "Chemistry", "Biology", "History", "English"] } ) ``` Then, I want to groupby with Score. ``` df1.groupby("Score") ``` I need a output file of this and I tried ``` df1.groupby("Score").to_csv("Score.txt",sep="\t") ``` but this does not work. Does anyone know how to make output file?
2017/09/07
[ "https://Stackoverflow.com/questions/46087311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7479634/" ]
What you're asking makes no sense. You may not realize it though. `groupby` creates a staging area for which to perform aggregation or transformations across groups of data. Like, if we wanted to count the number of observations for each group, that'd be an aggregation. Because you thought that you could output as some table, I'm going to guess that you thought `groupby` actually grouped the rows together. That isn't bad interpretation of the term if you had never seen it used before, even if it is incorrect. The way to do that would be to sort using the method `sort_values`. ``` df1.sort_values('Score') Class Score 0 Physics A 3 Biology A 5 English A 1 Science B 4 History B 2 Chemistry C ``` If Score were something else that wasn't already ordered lexicographically, we could use the `categorical` type to handle it for us. ``` score = df1.Score.astype('category', categories=list('ABCDF'), ordered=True) df1.assign(Score=score).sort_values('Score') Class Score 0 Physics A 3 Biology A 5 English A 1 Science B 4 History B 2 Chemistry C ``` Finally, you output the data to the file as you expected ``` df1.sort_values('Score').to_csv("Score.txt", sep="\t") ```
61,221
Yesterday I bought a new laptop with 4GB RAM. When I installed Ubuntu 11.10 (beta) it is showing 1.5GiB (2GB-512MB graphics) ignoring the 2GB. `uname -a`: ``` Linux js 3.0.0-11-generic-pae #17-Ubuntu SMP Fri Sep 9 19:38:01 UTC 2011 i686 athlon i386 GNU/Linux ``` `dmidecode`: ``` # dmidecode 2.9 SMBIOS 2.7 present. Handle 0x0016, DMI type 16, 23 bytes Physical Memory Array Location: System Board Or Motherboard Use: System Memory Error Correction Type: None Maximum Capacity: 8 GB Error Information Handle: Not Provided Number Of Devices: 2 Handle 0x0018, DMI type 17, 34 bytes Memory Device Array Handle: 0x0016 Error Information Handle: Not Provided Total Width: 64 bits Data Width: 64 bits Size: 2048 MB Form Factor: DIMM Set: None Locator: A1_DIMM0 Bank Locator: A1_BANK0 Type: <OUT OF SPEC> Type Detail: Synchronous Speed: 1333 MHz (0.8 ns) Manufacturer: Samsung Serial Number: 7943CECA Asset Tag: A1_AssetTagNum0 Part Number: M471B5773DH0-CH9 Handle 0x001A, DMI type 17, 34 bytes Memory Device Array Handle: 0x0016 Error Information Handle: Not Provided Total Width: 64 bits Data Width: 64 bits Size: 2048 MB Form Factor: DIMM Set: None Locator: A1_DIMM1 Bank Locator: A1_BANK1 Type: <OUT OF SPEC> Type Detail: Synchronous Speed: 1333 MHz (0.8 ns) Manufacturer: Undefined Serial Number: 00000002 Asset Tag: A1_AssetTagNum1 Part Number: V01D3S82GB26826813 ``` Update ------ When I revisited SHOP salesguy replaced RAM, now everything works fine. The problem is Defective RAM (unknown brand) included on laptop upgrade (came with 2GB).
2011/09/13
[ "https://askubuntu.com/questions/61221", "https://askubuntu.com", "https://askubuntu.com/users/24919/" ]
Check in the BIOS if it recognizes those 4GB, if not, then you have to check if they are right in the memory slot, and check if those memories are indeed 4GB in total (could be just one or two memory cards). If BIOS recognize 4 GB then.. are you using a 32 or 64 bit version of Ubuntu, if you want to use a large amount of memory in your computer use a 64 bit operating system.
466,847
I'm confused as to what a 5.5 VDC rating on super capacitor implies. Is this with respect to 5.5 VDC tolerance, impedance, or feedthrough? You can find the product details at: <https://www.mouser.com/ProductDetail/80-FC0H105ZFTBR44-SS> Thanks.
2019/11/11
[ "https://electronics.stackexchange.com/questions/466847", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/235995/" ]
From the question below: > > A diode is put in parallel with a relay coil (with opposite polarity) > to prevent damage to other components when the relay is turned off. > > > This is called a flyback diode. See also [How to choose a flyback diode for a relay?](https://electronics.stackexchange.com/questions/110574/how-to-choose-a-flyback-diode-for-a-relay) See also the comment of Kevin White (in my own words): * The diode prevents current spikes * The problem happens during turn-off
1,563,910
``` $test = 'love'; $eff = end(explode('ov',$test)); ``` I can't figure it out; oddly enough, this doesn't get a complain: ``` $test = 'love'; $eff = current(explode('ov',$test)); ``` The error I'm getting is: Strict: Only variables should be passed by reference
2009/10/14
[ "https://Stackoverflow.com/questions/1563910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115025/" ]
`end` changes the array's internal pointer by moving it to the end of the array. Thus, the parameter must be mutable (that is, a reference to an array) for that operation to be useful. This is why you receive the warning. `current` doesn't touch the array at all; it only looks at the array. Thus, the parameter does not need to be mutable (thus can be passed by value) and the operation doesn't give you a warning.
50,884,199
I am parsing some files using vim and would like to change the format of the following code. Original format: ``` vmm_note(log, "TEST_DIR - BEGIN"); ``` Desired format: ``` uvm_info("Test_seq", "TEST_DIR - BEGIN",UVM_LOW); ``` When this code is only one line, the following regex is functioning. ``` %s/vmm_note(log,\(.*\));/uvm_info("Test_seq",\1,UVM_LOW);/gc ``` However, when the code consists of multiple lines, my regex can match the pattern but in the replacement, group `\1` contains nothing. Original format: ``` vmm_note(log, $psprintf("INFO: setting debug port to watch %0s", (req_info.debug_which==4'd0) ? "MC" : "LZHI")); ``` Regex: ``` %s/vmm_note(log,\(\_.\)\{-};/uvm_info("Test_seq",\1,UVM_LOW);/g ``` Result: ``` uvm_info("Test_seq",),UVM_LOW); ``` I wonder why the capture group doesn't contain anything in it? Thanks in advance for the help!
2018/06/16
[ "https://Stackoverflow.com/questions/50884199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7887073/" ]
You were close, instead of `\(\_.\)\{-};` use `\(\_.\{-}\);` to include the desired text in the capturing group. So the multi-line substitution becomes: ``` %s/vmm_note(log,\(\_.\{-}\);/umv_info("Test_seq",\1,UVM_LOW);/g ``` Sample input: ``` vmm_note(log, $psprintf("INFO: setting debug port to watch %0s", (req_info.debug_which==4'd0) ? "MC" : "LZHI")); ``` output: ``` umv_info("Test_seq", $psprintf("INFO: setting debug port to watch %0s", (req_info.debug_which==4'd0) ? "MC" : "LZHI"),UVM_LOW); ```
25,253,425
I have basic coding experience. In my Wordpress install, some of my pages have a blank white space under the footer that I would like to remove. I have tried several solutions but to no avail. The problem is persistent on chrome, Firefox, IE etc. I'm not really sure of the cause, but the size of the white space changes depending on computer/browser/resolution. As I am working in Wordpress I have access to custom CSS and source theme files, however, I would prefer to solve this problem with custom CSS. I would like a footer that sticks to the bottom of the browser window with no whitespace below it. **Q. Please provide me with code/solution that will remove the white spaces below the footer on my website (preferably custom CSS method).** You can find an example of the white space on my [website here](http://goo.gl/7JS1Di). (try viewing on a browser resolution higher than 1280x800) Solutions i've tried: 1. `#footer {overflow: hidden;}` didn't work 2. Putting `html, body, parentDiv, childDiv, section, footer { height : 100%; }` in my css but that didn't work 3. `#copyright { padding-bottom: 20px;}` "#copyright" is under the footer so this did reduce the whitespace to a point where it seemed it weren't present, but on taller browser windows the white space reappeared.
2014/08/11
[ "https://Stackoverflow.com/questions/25253425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3931292/" ]
You have whitespace under the footer because the content is not sufficient to push it past the bottom of the monitor at higher resolutions. I'd recommend using the **[Sticky Footer](http://ryanfait.com/sticky-footer/)** to handle this. It allows the minimum height of the body to be that of the browser, regardless of how little content is in the page. The sticky footer solution requires some specific HTML to be included, and some basic CSS. Here's a **[Fiddle](http://jsfiddle.net/timmah/jc3qLw7x/)** of [Ryan Fiat](http://ryanfait.com/)'s sticky footer in action using the code from his example. The code goes like this: **HTML:** ``` <body> <div class="wrapper"> <p>Your website content here.</p> <div class="push"></div> </div> <div class="footer"> <p>Footer content here</p> </div> </body> ``` **CSS:** ``` * { margin: 0; } html, body { height: 100%; background-color:#eaeaea; } .wrapper { min-height: 100%; height: auto !important; height: 100%; margin: 0 auto -155px; /* the bottom margin is the negative value of the footer's height */ border:solid 1px red; } .footer, .push { height: 155px; /* '.push' must be the same height as 'footer' */ } .footer { border:solid 1px blue; } ``` Looking at your markup, you can use your existing `div class="clear"></div>` as your `.push` div, then you only need to add the `div class="wrapper">` around your content.
36,511,375
I am working in ClojureScript and would like to serialize a massive EDN data structure (in particular: a large map) in the form of a text file (in the same way that JS objects are stored as `.json` files). Performance concerns are not an issue. Is this possible, and if so, is there considered a standard/best practice way to do this?
2016/04/09
[ "https://Stackoverflow.com/questions/36511375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1770201/" ]
Yes. Use `pr-str` or `clojure.pprint/pprint` to write EDN and use `clojure.edn/read-string` to ingest EDN. In ClojureScript you may face the same challenges as Javascript in accessing the filesystem from a browser. For example to save a file from the browser things can be a little tricky: ``` (defn save-file [filename t s] (if js/Blob (let [b (js/Blob. #js [s] #js {:type t})] (if js/window.navigator.msSaveBlob (js/window.navigator.msSaveBlob b filename) (let [link (js/document.createElement "a")] (aset link "download" filename) (if js/window.webkitURL (aset link "href" (js/window.webkitURL.createObjectURL b)) (do (aset link "href" (js/window.URL.createObjectURL b)) (aset link "onclick" (fn destroy-clicked [e] (.removeChild (.-body js/document) (.-target e)))) (aset link "style" "display" "none") (.appendChild (.-body js/document) link))) (.click link)))) (log/error "Browser does not support Blob"))) ``` So it depends on the context of how you access the files, but so long as you can get/put strings, it's as easy as pr-str and edn/read-string.
691,011
I am running Centos 8. I have used various instructional documents, such as the below: <https://www.cyberciti.biz/faq/how-to-sudo-without-password-on-centos-linux/> in an attempt to be able to ssh to an account, and then get to root without having to use a password. I am accessing my machine via passwordless ssh with a key that requires a passphrase. Once I have logged in, with my account, I want to be able to sudo to root without a password. Is that even possible? What I have done is logged in as root (Which DOES require my account password) and then: ``` visudo ``` And added this line here for the account for "Keith". ``` keithchegwin ALL=(ALL) NOPASSWD:ALL ``` Now, for "good measure" I have started sshd again, and logged back in as `keithchegwin` fully expecting to be able to do: ``` su root ``` With no password, but it still asks for a password for the account I am logged in as. I want it to stop! What am I doing wrong? Thanks. I did see his other question here, but that refers to running a specific script or program, not accessing an account with no password so I do not think this is a duplicate: [How to run a specific program as root without a password prompt?](https://unix.stackexchange.com/questions/18830/how-to-run-a-specific-program-as-root-without-a-password-prompt)
2022/02/17
[ "https://unix.stackexchange.com/questions/691011", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/514807/" ]
`sudo` and `su` are two different commands, and do different things. `su` on its own won't do passwordless. With your setup, you could do something like `sudo su` and it won't ask for a password. Or, more simply `sudo -i` or `sudo -s`.
36,403,579
I want to download Xamarin for visual studio 2015 ! I clicked download button but it didn't run. What should I do? I am taking a major in Software Engineering **from china**. ![enter image description here](https://i.stack.imgur.com/Aa7H1.png)
2016/04/04
[ "https://Stackoverflow.com/questions/36403579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6155895/" ]
A few things can be happening: * China blocked your access to such content. It is not new that the chinese government blocks legit content from their users if it does not suit them. Are you being blocked? To find out, open the link with Google Chrome, press F12, change to the Networks tab, and try to download. The output should let you know. * Your input is incorrect. Admitedly, the page validation is terrible. They try to validate your name, as if there were a list of names that people should use ... If no request is sent to their servers, it is because you are failing the validation. Check your name, email and company fields. This is what I used: + Name: John Doe + Email: johndoe@mailinator.com + Company: none + Check all 3 checkboxes (set to true) You can use this information **as is** to try and download xamarin, *it worked for me*. I hope this helps you!
51,290,137
I'm writing a testing application in C# using Selenium and ChromeDriver. I have a web page that loads the contents of several tables using AJAX, and my test wants to see a specific string loaded somewhere into one of those tables. I can see the string on my screen when I do the test manually with the same parameters, but Selenium doesn't see it. The test waits for jQuery to start and then finish, then queries the text value of the table to see if anything matches the test string. Here's the problem: When it queries the table's text value, via the innerHTML, innerText, textContent and value attributes, or the .Text property of the element, it doesn't see the text that was loaded via AJAX. It sees the original table which is just the headers. So it looks like either Selenium didn't grab the latest value from the page, AJAX wasn't done before Selenium grabbed it, or something else is wrong. How can I debug this or write my query more correctly? For my initial debugging effort, I've first verified that the correct table has been selected, and that jQuery did in fact start and finish, then set up logging like so, and all of these lines produce similar output with the initial headers-only version of the table: ``` log.Trace(".Text: {0}", selectedElement.Text); log.Trace("attr innerHTML: {0}", selectedElement.GetAttribute("innerHTML")); log.Trace("attr innerText: {0}", selectedElement.GetAttribute("innerText")); log.Trace("attr textContent: {0}", selectedElement.GetAttribute("textContent")); log.Trace("attr value: {0}", selectedElement.GetAttribute("value")); ``` The code waits for jQuery to start and then finish via this (slightly simplified from the actual implementation which compares against an object's ToString and works great elsewhere): ``` string js = "return !!window.jQuery && window.jQuery.active == 0"; waiter.Until(_ => ((IJavaScriptExecutor)_).ExecuteScript(js) .ToString().Trim().ToUpper().Equals("FALSE")); waiter.Until(_ => ((IJavaScriptExecutor)_).ExecuteScript(js) .ToString().Trim().ToUpper().Equals("TRUE")); ``` The only thing I can think of right now is that maybe the AJAX for that specific table hasn't processed but jQuery came back as finished? That possibility doesn't make much sense, but I don't know how to test it to be sure. I would prefer not to modify the site itself, but keep all of the test-related pieces in the C# test suite, if at all possible. edit: I can see the values by inspecting the elements in Chrome - the textContent property in the Inspector is correct - but Selenium simply doesn't pick it up with my current code. I'm having no trouble selecting the table itself since Selenium picks up its unique header text every time. Since it's been asked, here is a sanitized version of the table in question, which is buried deeply into the page, and has a unique ID which I'm using to select it along the lines of By.CssSelector("#thetable"): ``` <table id='thetable'> <colgroup> ... 5x <col> tags ... </colgroup> <thead> <tr> ... 5x <th> tags ... </tr> <tr> ... 5x <th> tags ... </tr> <tr><th colspan='5'...> ...</tr> </thead> <tbody> <tr> ... 5x <td> tags, one of which includes the text I look for ... </tr> ... </tbody> </table> ``` The previously-mentioned properties & attributes of the table element itself only give me the text from the thead section.
2018/07/11
[ "https://Stackoverflow.com/questions/51290137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/691749/" ]
That's far from a solution, but I would recommend to add such dependency as a submodule as well, and add the dependency in Cargo as `path`. With that your own project will need to have a submodule update recursive to work. But everything else should work as expected. I hope that they add such feature soon in cargo.
57,764,290
I decided that I wanted to take on a python project to help hone my skills, so I decided to make a python calculator. I was able to get everything up and running, but I am currently running into a problem when I try to multiply or divide through the main function. Right now I have figured out that which ever one comes first it will make the other one do what it is intended to do. For example.. When i try to divide but the multi function is above the div function my divide will turn out multiplied... I know that there might be some easy way to solve this, but i can't seem to see it! So any help would be much appreciated! Also any other suggestions to improve my code are welcome! ''' ``` import sys test = [10, 20] def add(*arg): result = 0 for x in arg[0]: result += x print(result) def sub(*arg): arg = arg[0] result = arg[0] for x in arg[1:]: result -= x print(result) def multi(*arg): arg = arg[0] result = arg[0] for x in arg[1:]: result *= x print(result) def div(*arg): arg = arg[0] result = arg[0] for x in arg[1:]: result /= x print(result) def main(): while True: math_tool = input('What would you like to do: ').lower() if math_tool == 'exit': sys.exit() else: math_choice = \ list(map(int, input('What would you like to' + f' {math_tool}: ').split(','))) if math_tool == 'add': add(math_choice) elif math_tool == 'sub': sub(math_choice) elif math_tool == 'div' or 'divide': div(math_choice) elif math_tool == 'multi' or 'multiply': multi(math_choice) else: print('error') # print(math_choice, ' Type:', type(math_choice[0])) main() ``` '''
2019/09/03
[ "https://Stackoverflow.com/questions/57764290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10936274/" ]
You missed a condition just add a condition in `or` you have to check `math_tool` is equal to the string otherwise condition is always true. ``` elif math_tool == 'div' or math_tool == 'divide': div(math_choice) elif math_tool == 'multi' or math_tool == 'multiply': multi(math_choice) ```
25,422,145
I am trying to display the value of #response from the code below into the input field. I am not sure how that can be done. If I use ``` <div id="response"></div> ``` that will display the result but I like to display it in the input field. I tried this, ``` <input type="text" id="response"/>. ``` This did not display the result Any idea how that could be done. Thanks in advance. ``` <script> $(document).ready(function() { $("#productID").change(function() { //alert($('#productID option:selected').val()); var pId = $('#productID').val(); $.get('updateProduct', { productID: pId.trim() //using trim to get rid of any extra invisible character from pId }, function(responseText) { $('#response').text(responseText); }); }); }); </script> ``` $('#response').val(responseText); --> If this contains two values then is there a way to retrieve those values separately? what I would like to do is display values separately into two separate input field. ``` $('#response').val(responseText); ``` This could contain values such as, Product Description, Product comments, Product type. Those values are coming from the servlet. After receiving those values they will be displayed into three separate input field. At the moment if I do the following, ``` <input type="text" id="response"/> ``` This will display all three values in the same input field.
2014/08/21
[ "https://Stackoverflow.com/questions/25422145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2095312/" ]
`input` element values are set using [jQuery's `val()` method](http://api.jquery.com/val/), not `text()`. Change: ``` $('#response').text(responseText); ``` To: ``` $('#response').val(responseText); ``` [**JSFiddle demo**](http://jsfiddle.net/n01cuh8g/).
63,924,741
I am trying to remove multiple lines from a file where the lines begin with a specified string. I've tried using a list as below but the lines are written to the file the number of times equal to the items in the list. Some of the lines are removed some are not I'm pretty sure that it is due to not reading the next line at the correct time ``` trunklog = open('TrunkCleanedDaily.csv', 'r') fh = open("TCDailyFinal.csv", "w") firstletter = ['Queue,Completed', 'Outbound,', 'Red_Team_DM,', 'Sunshine,', 'Agent,','Disposition,', 'Unknown,'] while True: line = trunklog.readline() if not line: break; for i in firstletter: if line.startswith(i): print('del ' + line, end='') # line = trunklog.readline() else: fh.write(line) print('keep ' + line,end='') line = trunklog.readline() ``` Any help setting me straight about this is appreciated. Some of the content I am trying to remove: ``` Queue,Completed,Abandons,Exits,Unique,Completed %,Not Completed %,Total Calls, Green_Team_AMOne,93,0,0,0,100.00%,0.00%,8.04%, Green_Team_DM,11,0,0,0,100.00%,0.00%,0.95%, Green_Team_IVR,19,0,0,0,100.00%,0.00%,1.64%, Outbound,846,131,0,0,86.59%,13.41%,84.44%, Red_Team_AMOne,45,0,0,0,100.00%,0.00%,3.89%, Red_Team_DM,3,0,0,0,100.00%,0.00%,0.26%, Red_Team_IVR,5,0,0,0,100.00%,0.00%,0.43%, Sunshine,4,0,0,0,100.00%,0.00%,0.35%, Queue,Total Call Time,Average Call Time,Average Hold Time,Call Time %,None, Green_Team_AMOne,32:29:06,20:57,00:10,42.92%,None, Green_Team_DM,2:41:35,14:41,00:16,3.56%,None, Green_Team_IVR,1:47:12,05:38,00:19,2.36%,None, ```
2020/09/16
[ "https://Stackoverflow.com/questions/63924741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7742692/" ]
Each time you run your program, addresses in the program or on the stack may be randomized by *address space layout randomization*. Thus, addresses that you see in one run of the program may not be valid in a second run of the same program. Do not hardcode memory addresses for variables in C or C++ programs. They are not guaranteed to be stable. The `&` operator is the only safe way to get the address of an object in C.
2,728,603
For a first-order language with equality, no functions, and no relations, suppose we have a formula in this language $\alpha$ with a single free variable $x$. Consider a structure $\mathcal{A}$ in our language and consider a set $D = \{t \in |\mathcal{A}|: \mathcal{A} \vDash \alpha [s(x|t)]\}$ where $s(x|t)$ is an assignment function fixing $x$ to be $t$. I would like to show that $D$ is either the entire domain of $\mathcal{A}$, which we denote $|\mathcal{A}|$ or $\emptyset$. Here is what I have: I'm trying to inductively build my formula $\varphi$ and am not sure what all of the base and inductive cases are. Here's what I have so far (recall that $\varphi$ must have one and only one free variable): Base case a) $\varphi$ is $x=x$; can be shown by seeing that for all assignment functions, where each assignment function assigns $x$ to a different element of the domain of $\mathcal{A}$, we have $a=a$. Thus $D = |\mathcal{A}|$ Base case b) $\forall x ( x=y)$; not going to go into how to show this base case, but I know how Base case c) $\exists x (x = y)$; same deal that I wont go into how to show this base case here, but I know how Assuming the hypothesis that $D= $ either $|\mathcal{A}|$ or $\emptyset$: Inductive step 1:$\varphi\_1 \rightarrow \varphi\_2$ where $\varphi\_1$ and $\varphi\_2$ have the same free variable. Not going to go into details, but know how to show this Ind step 2: $\neg \varphi$ (not going into details) So I think I'm missing a couple of base cases for the quantifiers and would like to know what they are. Also are the rest of my cases right?
2018/04/09
[ "https://math.stackexchange.com/questions/2728603", "https://math.stackexchange.com", "https://math.stackexchange.com/users/296190/" ]
If we replace the indefinite integral with a definite one so as to keep one point (say, $(1, 0)$) fixed as we vary the exponent, then there's no jump at all. For all $s \neq 0$, define $$f\_s(x) := \int\_1^x\, t^{s-1}\, dt = \frac{x^s - 1}{s}.$$ Then by l'Hopital, $$\lim\_{s \to 0} f\_s(x) = \left . \frac{d}{ds} x^s \right|\_{s = 0} = \left . \frac{d}{ds} e^{s \ln x} \right|\_{s = 0} = \ln x.$$
8,502,967
I have a View with visibility set to `GONE` in the layout xml and that may be set to `VISIBLE` programmatically in the Fragment. When going back to this Fragment with the Back button, the View's visibility is always set to `GONE`, even if it was set to `VISIBLE` before leaving it. How can I keep the state of my fragment (only onResume() is called when going back to the fragment)? Thanks **XML** ``` ... <LinearLayout android:id="@+id/sub_bio_container" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:visibility="gone" /> .... ``` **Activity** ``` public class MyFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ... LinearLayout sub_bio_container = (LinearLayout) findViewById(R.id.sub_bio_container); if(<some condition>){ sub_bio_container.setVisibility(VIEW.VISIBLE); } .... } ```
2011/12/14
[ "https://Stackoverflow.com/questions/8502967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/326849/" ]
Well an idea would be: set the view in xml as `VISIBLE` and when you use it in app (via inflate or by findviewbyid()) set it to `GONE`. Like this it will be visible in on resume, and you can control it's visibility from code. A second idea would be: Keep track in on resume if the view was hidden or not, and set that view's visibility in onResume().
40,003,713
I'm trying to create a row in an output table that would calculate percentage of total items: ``` Something like this: ITEM | COUNT | PERCENTAGE item 1 | 4 | 80 item 2 | 1 | 20 ``` I can easily get a table with rows of ITEM and COUNT, but I can't figure out how to get total (5 in this case) as a number so I can calculate percentage in column %. ``` someTable | where name == "Some Name" | summarize COUNT = count() by ITEM = tostring( customDimensions.["SomePar"]) | project ITEM, COUNT, PERCENTAGE = (C/?)*100 ``` Any ideas? Thank you.
2016/10/12
[ "https://Stackoverflow.com/questions/40003713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4548109/" ]
It's a bit messy to create a query like that. I've done it bases on the customEvents table in AI. So take a look and see if you can adapt it to your specific situation. You have to create a table that contains the total count of records, you then have to join this table. Since you can join only on a common column you need a column that has always the same value. I choose appName for that. So the whole query looks like: ``` let totalEvents = customEvents // | where name contains "Opened form" | summarize count() by appName | project appName, count_ ; customEvents // | where name contains "Opened form" | join kind=leftouter totalEvents on appName | summarize count() by name, count_ | project name, totalCount = count_ , itemCount = count_1, percentage = (todouble(count_1) * 100 / todouble(count_)) ``` If you need a filter you have to apply it to both tables. This outputs: [![enter image description here](https://i.stack.imgur.com/37qQp.png)](https://i.stack.imgur.com/37qQp.png)
24,597,431
Just started to learn a Meteor and stuck with a silly problem. I have a collection "Images" and i trying to get one random image from her. But in the browser's console it's says that "Cannot read property 'url' of undefined", but if type a db's "findOne" method in the console there is a record that i wanted. A client code: ``` Template.main.helpers({ img: function () { return Images.findOne({rand: {$gte: Math.random()}}).url; } }); ``` Collection: ``` Images = Meteor.Collection('images'); ``` On a server's side i've got simple fixtures for initial tests ``` if(Images.find().count() === 0){ Images.insert({url: "http://domain.com/test1.jpg", rand: Math.random()}); Images.insert({url: "http://domain.com/test2.jpg", rand: Math.random()}); Images.insert({url: "http://domain.com/test3.jpg", rand: Math.random()}); } ``` And simple template: ``` <head> <title>Test</title> </head> <body> {{> main}} </body> <template name="main"> {{img}} </template> ``` P.S. I'm working under the Win 8.
2014/07/06
[ "https://Stackoverflow.com/questions/24597431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/643369/" ]
Depends on what `Pointer` actually is. Case 1: ``` namespace itk { template <class T, int X> struct Image { typedef int Pointer; }; } ``` This is called a "member typedef". Case 2: ``` namespace itk { template <class T, int X> struct Image { struct Pointer { }; }; } ``` This is called a "nested class". Case 3: ``` namespace itk { template <class T, int X> struct Image { static int const Pointer = 0; }; } ``` This is obviously not a type at all but just a static member variable.
1,677,110
Is it possible to somehow auto-format when saving XML files in Eclipse? I know it's [possible to do it](https://stackoverflow.com/questions/234594/eclipse-can-you-format-code-on-save) for Java files, but I would like it to happen for XML files as well. Specifically, I'm using and loving the auto format feature for XML files while developing for Android, as Android is quite heavy on using XML files.
2009/11/04
[ "https://Stackoverflow.com/questions/1677110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47680/" ]
I'm going to answer my own question using my own article about the fix that's about to be rolled out to ADT: <http://www.androidpolice.com/2010/11/09/for-android-developers-next-version-of-eclipse-adt-to-include-auto-formatting-of-xml/> **Update**: since r14, ADT can now finally do this. <http://tools.android.com/recent/xmlformatter>
531,075
My convolutional network seems to work well in learning the features. However, the accuracy of the validation set is increasing very slowly with respect to the learning rate as also illustrated in the figure below: [![enter image description here](https://i.stack.imgur.com/2hiNX.png)](https://i.stack.imgur.com/2hiNX.png) The loss of both training and validation sets are shown in the figure below: [![enter image description here](https://i.stack.imgur.com/hFsrJ.png)](https://i.stack.imgur.com/hFsrJ.png) If I decrease the learning rate, the validation accuracy will stay around 25% and it will not increase. Is there any method to speed up the validation accuracy increment while decreasing the rate of learning?
2021/06/17
[ "https://stats.stackexchange.com/questions/531075", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/325247/" ]
Thanks for all the comments. First, I looked at this problem as overfitting and spend so much time on methods to solve this such as regularization and augmentation. Finally, after trying different methods, I couldn't improve the validation accuracy. Thus, I went through the data. I found a bug in my data preparation which was resulting in similar tensors being generated under different labels. I generated the correct data and the problem was solved to some extent (The validation accuracy increased around 60%). Then finally I improved the validation accuracy to 90% by the technique that @Jonathan mentioned in his comment: adding more "conv2d + maxpool" layers.
1,366,780
The Hermite-Gauss functions ($t\mapsto H\_m(t)e^{-t^2/2}$) are known to be an orthonormal basis for $L^2(\mathbb{R})$, *a fortiori* linearly dense in $L^2(\mathbb{R})$, and all are in the Schwartz space (and hence in $L^p(\mathbb{R})$). These functions play an extremely important role in $L^2$ theory, Fourier transform theory, quantum mechanics, and elsewhere. I've never seen it mentioned whether or not the Hermite-Gauss functions are linearly dense in $L^1(\mathbb{R})$ - and, more generally, $L^p(\mathbb{R})$. It seems like a reasonable question to ask but Googling has not led me to an answer one way or another. My guess is that they are, in fact, not linearly dense in $L^p(\mathbb{R})$ except for $p=2$, but I don't have any clue as to how to prove that. Can anyone point me to this result or maybe give a clue as to why it is or isn't true?
2015/07/19
[ "https://math.stackexchange.com/questions/1366780", "https://math.stackexchange.com", "https://math.stackexchange.com/users/22551/" ]
The functions $g\_m(t) = H\_m(t)\,e^{-t^2/2} $ just give an ortho*gonal* base of $L^2(\mathbb{R})$, since: $$ \int\_{-\infty}^{+\infty} f\_m(t)^2\,dt = 2^m m! \sqrt{\pi}. $$ An ortho*normal* base is given by: $$ f\_m(x) = \frac{1}{\sqrt{2^n n! \sqrt{\pi}}}\,H\_m(x)\, e^{-x^2/2}. $$ We may notice that if $m$ is odd then $\int\_\mathbb{R}f\_m(x)\,dx = 0$, while: $$ \int\_{\mathbb{R}} f\_{2n}(x)\,dx = \frac{(2n)!}{n!}\sqrt{2\pi}\frac{1}{\sqrt{4^n (2n)! \sqrt{\pi}}}=\sqrt{\frac{2\sqrt{\pi}}{4^n}\binom{2n}{n}}\approx \sqrt{2}\cdot n^{-1/4}.$$ Moreover, we have $\left|\,f\_m(x)\,\right|\leq\frac{1}{2}$ for every $m$ and every $x$, and $f\_m$ is essentially zero outside $\left[-\frac{\pi}{2}\sqrt{m},\frac{\pi}{2}\sqrt{m}\right]$. So we know the behaviour of our base with respect to $L^1,L^2,L^\infty$. By interpolation or other techniques, it is not difficult to check that linear combinations of $f\_n$s cannot be dense in $L^1$. For instance, we may consider the function $g(x)=\frac{1}{\sqrt{x}}\cdot\mathbb{1}\_{(0,1)}(x)$ that belongs to $L^1\setminus L^2$. Every $f\_n$ has a rather large support, so if we compute: $$ a\_n = \int\_{0}^{1} g(x)\,f\_n(x)\,dx $$ we have that: $$ g\_N(x)=\sum\_{n=0}^{N} a\_n\,f\_n(x) $$ is a not-so-bad approximation of $g(x)$ over $[0,1]$, but it has a long tail, such that $g\_N(x)$ does not converge to $g(x)$ in $L^1(\mathbb{R})$. To make this argument visually appealing, this is the situation for $N=10$: $\hspace0.5in$![enter image description here](https://i.stack.imgur.com/JroYY.png) This non-density argument is even more convincing (at least to me) if we notice that every $g\_N$ is an entire function (of order 2) while $g$ is a compact-supported function with a branch-like singularity in a right neighbourhood of the origin. So the fact that $L^2$ and the Schwarz space are mapped into theirselves by the Fourier transform is really crucial for proving the density of the span of the "Hermite base".
45,203,763
I'm using [the code](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/calib3d/camera_calibration) provided by opencv for camera calibration. I've edited the settings file to contain my own directories, and it looks like this: ``` <?xml version="1.0"?> <opencv_storage> <images> "20170720_024951.jpg" "20170720_025001.jpg" "20170720_025014.jpg" "20170720_025023.jpg" "20170720_025034.jpg" "20170720_025048.jpg" "20170720_025103.jpg" "20170720_025115.jpg" "20170720_025124.jpg" "20170720_025133.jpg" "20170720_025147.jpg" "20170720_025155.jpg" "20170720_025211.jpg" </images> ``` I am providing the full image path, but getting this error: > > Invalid input detected. Application stopping. > > > here is the part of the code at which I'm getting the error: ``` Settings s; const string inputSettingsFile = "C:/Users/user/Documents/Visual Studio 2013/Projects/calibration/x.xml"; FileStorage fs(inputSettingsFile, FileStorage::READ); // Read the settings if (!fs.isOpened()) { cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << endl; return -1; } fs["Settings"] >> s; fs.release(); // close Settings file //! [file_read] //FileStorage fout("settings.yml", FileStorage::WRITE); // write config as YAML //fout << "Settings" << s; if (!s.goodInput) { cout << "Invalid input detected. Application stopping. " << endl; return -1; } ``` the origin file provided by oencv didn't contain "" around the attributes(paths of the images) so I have tried first to insert the path of the images **in the XML file** without **using double quotations** "path/image.jpg" -> path/image, but the following exception was raised: > > OpenCV Error: Parsing error (C:/Users/user/Documents/Visual Studio > 2013/Projects/calebration/x.xml(1): Attribute value should > be put into single or double quotes) in icvXMLParseTag, file > C:\builds\master\_PackSlave-win64-vc12-shared\opencv\modules\core\src\persistence.cpp, > line 2157 > > > and after adding "" as suggested by someone, the exception disappear but still stuck at the first error (which is telling *as I suppose* that the format of the xml file is not correct)
2017/07/20
[ "https://Stackoverflow.com/questions/45203763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6483138/" ]
There is no problem with mutually recursive structures in different files. The main problem here is that the circular inclusions don't work. It's easy to solve this, however, because neither header must include the other at all. If you skip the `typedef`, you can do this: ``` // In a.h struct a { struct b *ptr; }; ``` and ``` // In b.h struct b { struct a *ptr; }; ``` Alternatively ------------- If you want to use the typedef, you'll just have to skip using it inside the structure definitions. ``` // In a.h struct a { // Have to use 'struct b' instead of 'b' because we can't guarantee // that the typedef for b is visible yet. struct b *ptr; }; typedef struct a a; ``` and ``` // In b.h struct b { // Have to use 'struct a' instead of 'a' because we can't guarantee // that the typedef for a is visible yet. struct a *ptr; }; typedef struct b b; ```
41,215,867
I have the following code with a simple working Vue.js application. But the vue.js devtools is not responding. It was working well a few days ago, now it's not working anymore what could possibly be going wrong? when I go to <https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd>, it says it is already added. ``` <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="https://unpkg.com/vue@2.1.6/dist/vue.js"></script> <title>Document</title> </head> <body> <div class="container"> <div id="application"> <input type="text" v-model="message"> <p>The value of the input is: {{ message }}</p> </div> </div> <script> let data = { message: 'Hello World' } new Vue({ el: '#application', data: data }) </script> </body> </html> ```
2016/12/19
[ "https://Stackoverflow.com/questions/41215867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/520733/" ]
One alternative is to set up a local web server, as the OP [already stated](https://stackoverflow.com/a/41215913/1404279). The other - which IMHO is faster and less harassing - is letting the extension have access to file URLs, which is disabled by default. Simply go to `chrome://extensions` and leave the "**Allow access to file URLs**" box checked for Vue.js devtools. Sources: <https://github.com/vuejs/vue-devtools#common-problems-and-how-to-fix>
3,642,382
I need to make an upload tool where in the Word document will be converted to HTML format for saving to database. Any idea?
2010/09/04
[ "https://Stackoverflow.com/questions/3642382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/182332/" ]
I've written one (see the [Doc to HTML Converter](http://www.modeltext.com/word/index.aspx)). To implement it, I downloaded the [PIAs](http://msdn.microsoft.com/en-us/library/aax7sdch.aspx) for Word, which let me open a document using Word, and control the format in which Word then re-saves the document. Alternatively (instead of doing it yourself) there are tools like mine (and others, more famous) which you can use (some of which don't even use Word).
917,281
The media is gushing about the snap package for Visual Studio Code, and how wonderful it is (apparently has a plug in that cures gout ;-). So I thought I'd give it a whirl. I dutifully typed: ``` $ sudo snap install --classic vscode error: cannot install "vscode": snap not found ``` Where the articles all too early? Has vscode not yet landed in snap?
2017/05/21
[ "https://askubuntu.com/questions/917281", "https://askubuntu.com", "https://askubuntu.com/users/691451/" ]
Visual Studio Code should show up in Ubuntu Software application if you search for "vscode" or it can be installed from the terminal by running the command `sudo snap install code --classic` A snap in classic confinement behaves as a traditionally packaged application with full access to the system, and Visual Studio Code extensions are installed into the user's home directory. Visual Studio Code is not an full=featured IDE. For this reason it is not possible to create a project in Visual Studio Code, like it is in Visual Studio. On the other hand it is possible to run Python, C, C++, JavaScript, PHP, Java, R and some other programming language code blocks directly in Visual Studio Code using the Code Runner extension. It is also possible to run HTML code in an external web browser using the open in browser extension. Visual Studio Code is a lot smaller than Microsoft Visual Studio, however many Visual Studio extensions can also be installed in Visual Studio Code by selecting *View* -> *Extensions* and then search for the extension that you want to install.
3,608,422
I am trying to show the definiteness of a matrix constrained to a subspace: $$Q=\begin{bmatrix} 0 & 1&1 \\ 1 & 0 & 1 \\ 1 & 1 & 0 \end{bmatrix}$$ constrained to the subspace: $$U=\bigg\{\begin{bmatrix} x \\ y\\z \end{bmatrix}\bigg|x+y+z=0\bigg\}$$ I considered the following: Def $u=\begin{bmatrix} x \\ y\\z \end{bmatrix}$, then $$u^{'}Qu=2xy+2xz+2yz$$ Consider $$2xy+2xz+2yz \hspace{4mm}\text{s.t.} \hspace{4mm}x+y+z=0$$ Then Since $$2xy+2xz+2yz=2xy+2xz+2yz+2z^2-2z^2=2z(x+y+z)+2xy-2z^2$$ by the constraint this reduces to the equivalent problem: $$2xy-2z^2 \hspace{4mm}\text{s.t.} \hspace{4mm}x+y+z=0$$ Consider the case of positive semidefiniteness $$2xy-2z^2 \ge 0 \hspace{4mm}\text{s.t.} \hspace{4mm}x+y+z=0$$ By the constraint $z^2=x^2+y^2+2xy$ then: $$xy\ge x^2+y^2+2xy, \forall u\in U$$ equivalently : $$-xy\ge x^2+y^2, \forall u\in U$$ Let $u=\begin{bmatrix} -2 \\ 4\\-2\end{bmatrix}$ note: $$8 \ngeq 20$$ So cannot be positive definite. Is my logic correct before I try to show that it is negative definite.
2020/04/03
[ "https://math.stackexchange.com/questions/3608422", "https://math.stackexchange.com", "https://math.stackexchange.com/users/724366/" ]
Your solution so far is correct, but I think that there are easier ways to proceed. The observation in [Malkoun’s answer](https://math.stackexchange.com/a/3608437/265466) leads to the simplest solution, but if you don’t notice that $Q$ can be rewritten in that convenient form, there’s another way that I think is simpler than yours. Choose a convenient basis for $U$, say, $(1,-1,0)^T$ and $(1,0,-1)^T$. Relative to this basis, the restriction of $Q$ to $U$ has the matrix $$Q' = \begin{bmatrix}1&-1&0\\1&0&-1\end{bmatrix} \begin{bmatrix}0&1&1\\1&0&1\\1&1&0\end{bmatrix} \begin{bmatrix}1&1\\-1&0\\0&-1\end{bmatrix} = \begin{bmatrix}-2&-1\\-1&-2\end{bmatrix}.$$ Test this matrix for definiteness.
60,428
In my novel there's a diplomatic accident that will deteriorate relationships of two European countries: Germany and Spain. How would e-commerce be affected in case of an embargo between those 2 countries (I'm thinking of Amazon, but also other e-commerce sites)? Would it be possible for someone to sell an item in Germany and buy it in Spain, for example? Are there real examples of problems of this kind? (There is no longer the EU "we know" in the novel; only 3 countries left after 20 years of Referendum for Countrexit)
2016/11/04
[ "https://worldbuilding.stackexchange.com/questions/60428", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/4995/" ]
Nope. ----- Not all geniuses would govern well - you are correct. There is always a posibility of selfishness or self-preferece. That doesn't mean that geniuses will never rule effectively. **A) Intelligence and Leadership are not Strongly Correlated** -------------------------------------------------------------- While some intelligent people may abuse power, there is no strong, widely proven correlation between intelligence and corruption or abuse. Furthermore, a group of intelligent people would probably peer-review each other - straining out all selfish or unwise decisions. Finally, if elected democratically, these people may have some sense of morality - people generally like morals in leaders. They may not be perfect, but as intelligent people, they will be far from bad at their jobs, and they will consider the needs of others, as everyone does. B) "Dystopian" is Different from "Bad" -------------------------------------- Even if intelligence is correlated with corruption, although it isn't, there is no reason to call a poorly governed society a dystopia. Dystopias involve total, pervasive lack of goodness, morality, or habitability. If a government neglects the majority of people, then those people may freely find a new government, make a new one, start an anarchy and overthrow the geniuses, or continue with their normal lives while disagreeing with those in power. That is not the same thing as "everything is bad".
8,363,790
I am doing this: ``` <form action="processform.php" type="post"> <input type="text" name="sample"> <input type="text" name="how"> <input type="checkbox" name="fields" value="fields">Something</input> </form> ``` When the submit button is hit, this is what shows in the address bar of the process page: ``` https://www.domain.com/processform.php?sample=&how=&fields= ```
2011/12/02
[ "https://Stackoverflow.com/questions/8363790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/441049/" ]
Change to `<form method="post" />`
267,536
This is a follow-up from this [question](https://movies.stackexchange.com/questions/118433/how-did-voyager-know-the-pilot-was-a-he) over on Movies/TV Stack Exchange. In [my answer to that question](https://movies.stackexchange.com/a/118434/18230), I speculate that it's not a stretch to imagine that sensors sophisticated enough to be capable of detecting *life signs* (which itself is just a convenient plot device anyway) are also capable of detecting biological sex of those life signs. Now of course, not all species have the same concept of biological sex, which has been shown in canon. So the sensors are only going to be able to make a best guess, based on some sort of probability determination, which could also include failing to make a determination whatsoever. I feel like I remember hearing dialog reminiscent of "I'm detecting male life signs", or "I'm detecting female life signs", etc in the past. But it's possible I'm just confusing it with species life signs ("Human" vs "Klingon" life signs, etc). Prior to [Vis à Vis](https://en.wikipedia.org/wiki/Vis_%C3%A0_Vis_(Star_Trek:_Voyager)), has it been established in canon that sensors can distinguish, or at least guess at, the biological sex of a life sign? Even an example post that episode would be useful, if we could infer that the technology would have existed in Voyager's time. Supplementary information from sources like the Technical Manuals would also be acceptable.
2022/09/08
[ "https://scifi.stackexchange.com/questions/267536", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/73478/" ]
In a word, yes. We've seen at least one other occasion when the sensors are used to pick out a particular *gender* > > **JANEWAY:** *On screen.* > > > **KIM:** *Showing one life sign, **adult Kazon male**. He's in critical condition.* > > > **JANEWAY:** *Janeway to Sickbay. Prepare to receive an emergency transport.* > > > [VOY: Basics, Part 1](http://www.chakoteya.net/Voyager/222.htm) > > > As to the capacity of the sensors, we're told in the [TNG Technical Manual](https://memory-alpha.fandom.com/wiki/Star_Trek:_The_Next_Generation_Technical_Manual) that they can ascertain the 'gross' structure of a bioform. I'd assume that if you're particularly close that it's possible that an adult male or female is sufficiently different to allow them to be distinguished. > > **Remote lifeform analysis.** A sophisticated array of charged cluster > quark resonance scanners provide detailed biological data across > orbital distances. When used in conjunction with optical and chemical > analysis sensors, **the lifeform analysis software is typically able to > extrapolate a bioform's gross structure** and deduce the basic chemical > composition. > > > Additionally, we have multiple instances within the Extended Universe novels where the sensors have picked out a particular individual by their sex > > "O’Brien looked at Sloan for confirmation. The lean, fair-haired man checked his console, then nodded at O’Brien. **“One life sign, Cardassian female.** The ship’s clean" > > > [ST - Mirror Universe: Rise Like Lions](https://memory-beta.fandom.com/wiki/Rise_Like_Lions) > > > and > > It’d been more than five years, but Miles O’Brien worked the Defiant’s console like he hadn’t missed a day. “In the chamber adjacent to you, I’m reading nine Bajorans, three Cardassians, and **two humans—one child, one adult female** —but I can’t get a lock on them. There’s some kind of force field around them preventing transport.” > > > [Strange New Worlds (2016)](https://memory-beta.fandom.com/wiki/Strange_New_Worlds_2016) > > > --- That all being said, we also have a couple of instances where someone has been detected by sensors and it's then *assumed* by the crew that they're male, for example in *VOY: Vis à Vis*, but also in *TNG: Lower Decks.* > > **TAURIK:** *Bio readings indicate that passenger's humanoid. Attempting life form identification.* > > > **LAFORGE:** *No one told you to do that, Ensign. Let's just get **him** aboard safely. There, that should do it.* > > > [TNG: Lower Decks](http://www.chakoteya.net/NextGen/267.htm) > > > In this case Geordi is making an assumption about the identity of the occupant but doesn't have proof-positive that it's who he thinks it is. You need to refer to them as *something*, and it's as good one way as the other.
26,885,665
it is such that I must have built such that when kommmer into articles that sends up the database +1 each time you load the page, I have done like this: ``` int id = Convert.ToInt32(Request.QueryString["Id"]); string viewSet = "1"; SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "UPDATE Artikler SET viewSet = @viewSet++1 WHERE Id = @id;"; cmd.Parameters.AddWithValue("@Id", id); cmd.Parameters.AddWithValue("@viewSet", viewSet); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); ``` **comes nothing into the database**
2014/11/12
[ "https://Stackoverflow.com/questions/26885665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4190980/" ]
Let's break this down piece by piece. First of all the command is commented out so it won't run until you remove the starting `#` ``` chkCount=`ps -aef | grep -i "File_Transfer.sh"|grep -v grep| wc -l` ``` The output of the command `ps -aef | grep -i "File_Transfer.sh"|grep -v grep| wc -l` will be stored in the variable `chkCount`. `grep -i "File_Transfer.sh"` looks for lines containing "File\_Transfer.sh" but grep will ignore the case of the string. That means that grep will match "File\_Transfer.sh", "File\_TRANSFER.SH", or any other combination. `grep -v grep` will match any line that DOESN'T contain the word `grep`. `-v` inverts the match. The purpose of this is to eliminate the command you issued. In other words `ps` will list a process called `File_Transer.sh` and it will list your command `ps -aef | grep -i "File_Transfer.sh"|grep -v grep| wc -l`. `grep -v` will ignore `ps -aef | grep -i "File_Transfer.sh"|grep -v grep| wc -l` and just match any process matching `File_Transfer.sh` Lastly, `wc -l` will count the number of lines fed into `wc`. So the result will be the number of processes running that matches "File\_Transfer.sh"
44,710,489
I would like to know if it is possible to loop through a list of values in SimpleTemplateEngine groovy. For example: ``` def values = [ "1", "2", "3" ] def engine = new groovy.text.SimpleTemplateEngine() def text = '''\ ??? ''' def template = engine.createTemplate(text).make(values) println template.toString() ``` How can I get: ``` 1 2 3 ``` by changing the variable `text`?
2017/06/22
[ "https://Stackoverflow.com/questions/44710489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/161012/" ]
Did you mean? ``` def values = [ "1", "2", "3" ] def engine = new groovy.text.SimpleTemplateEngine() def text = ''' ${values.each { println it} } ''' println engine.createTemplate(text).make([values: values]) ```
195,005
Context ======= I'm trying to use [AMC](http://home.gna.org/auto-qcm/) to produce an exam with code in it. However, the use of [verbatim code inside the questions is beyond the scope of the package](http://project.auto-multiple-choice.net/projects/auto-multiple-choice/wiki/Verbatim_inside_questions). They suggest to declare boxes and used them inside each question. But, I found problematic to create a `\newbox` per question and insert it by hand. Thus, I searched for a solution on how to create and insert boxes automatically (following [this question](https://tex.stackexchange.com/questions/73120/savebox-equivalent-of-csname) and [this answer](https://tex.stackexchange.com/a/46477/7561)). Problem ======= But now, I'm stuck with the expansion of the macros. As the macro I'm using inserts always the last created box. As it seems that the AMC package post processes all the elements (questions) in the `\onecopy` macro, and it expands my macro `\insertbox` then. However, I need to insert the expanded version of the macro in every element, in order to insert the expanded name of the box I created. Thus, how can I expand the definition of the box and insert it in each question? I tried to store the `\savebox` definition in another macro an insert it after, using `\edef` but that doesn't work either. I will like to redefine `\insertbox` in such a way that is expanded with the name of the temporal box I created, instead of being expanded until the call of `\onecopy`. Code ==== ``` \documentclass{article} \usepackage[box]{automultiplechoice} \usepackage{listings} % a simple wrapper to create boxes automatically \makeatletter \newcounter{myboxcounter} \newenvironment{mybox}{% \addtocounter{myboxcounter}{1}% \expandafter\newsavebox\csname foobox\roman{myboxcounter}\endcsname \global\expandafter\setbox\csname foobox\roman{myboxcounter}\endcsname\hbox\bgroup\color@setgroup\ignorespaces }{% \color@endgroup\egroup } % first try % \newcommand{\insertbox}{\expandafter\usebox\csname\name\endcsname} % second one \newcommand{\insertbox}{\edef\name{foobox\roman{myboxcounter}}\edef\x{\expandafter\usebox\csname\name\endcsname}\x} \makeatother \begin{document} %%% preparation of the groups \begin{mybox} \begin{lstlisting}[language=C++] int a = 10; a = a + 10; \end{lstlisting} \end{mybox} \element{code}{ \begin{question}{code 1} Which is the result of \texttt{a}? \insertbox \begin{choices} \correctchoice{10} \wrongchoice{20} \wrongchoice{0} \wrongchoice{30} \end{choices} \end{question} } \begin{mybox} \begin{lstlisting}[language=C++] int a = 10; a = a++; \end{lstlisting} \end{mybox} \element{code}{ \begin{question}{code 2} Which is the result of \texttt{a}? \insertbox \begin{choices} \correctchoice{10} \wrongchoice{11} \wrongchoice{12} \wrongchoice{0} \end{choices} \end{question} } %%% copies \onecopy{1}{ \insertgroup{code} } \end{document} ``` As you can see in the image below, both inserted codes belong to the last box created. As the macro seems to expand later, instead of when called in the `\element` macro. ![enter image description here](https://i.stack.imgur.com/MojIc.jpg)
2014/08/05
[ "https://tex.stackexchange.com/questions/195005", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/7561/" ]
I suspect the shadowing uses PDF features, which are not available in PostScript. From the documentations, [`pgf-blur`](http://mirrors.ctan.org/graphics/pgf/contrib/pgf-blur/pgf-blur.pdf): > > This effect can be achieved in TikZ/PGF with the circular drop shadow > key, > > > And from the [PGF manual](http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf): > > In addition to the general `shadow` option, there exist special options > like `circular shadow`. These can only (sensibly) be used with a special > kind of path (for `circular shadow`, a circle) and, thus, they are not > as general. The advantage is, however, that they are more visually > pleasing since these shadows blend smoothly with the background. Note > that these special shadows use fadings, which few printers will > support. > > > Export the image as PDF and pdfTeX can include it directly without the need to run a converter for the down-graded PostScript file (the conversion is actually done by ghostscript).
169,934
So I recently did my PhD project approval which is the process where I agree my objectives with my supervisor and present a short overview to a review panel. All that went well and my project has been approved and I can finally make a start on the work I need to do. I'm feeling a bit swamped and unsure about how to proceed tackling the objectives we need to achieve and this has left me feeling quite overwhelmed and overworked. My supervisor sent me a one line email last week basically saying "do objective 1 now" but I wanted to spend some time with them discussing the theory and devising a suitable way to do this objective. I know it's all about independent work but I feel I could benefit from a short meeting just to straighten up my work plan and ensure we're both on the same page. To clarify, the problem isn't that I don't understand the theory- I just need to clarify what my workplan should look like. Would I be dumb if I asked for a sit down to talk through the objectives and clarify what I should be working on? I feel very out of my depth
2021/06/14
[ "https://academia.stackexchange.com/questions/169934", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/134761/" ]
No, it would not be dumb: it is absolutely crucial for you and your supervisor to have clear expectations about each other, as early as possible. It is well-known that the majority of problems during a PhD result from miscommunications between student and supervisor. So send your supervisor an email as soon as possible, saying something to the effect of (note: check transitionsynthesis' comment below this post): "I apologize if this is burdensome, but I sincerely feel like I need to have a short meeting with you in this early phase to help clarify my workplan, because I've been struggling with it recently". I'm very confident that your supervisor will be 100% fine (unless they are the kind of people who abandon their students from day one, in which case you should not have selected them as supervisors in the first place). I also strongly recommend you to read as soon as possible the book "How to get a PhD: A Handbook for Students and their Supervisors" by Estelle Phillips, which will be of great help to you.
25,519,222
I need to set all elements with a specific class to have a certain background-color. Here is my code: ``` /*var elements = $(".km-flat"); var elements1 = $(".km-view"); var elements2 = $(".km-navbar"); var elements3 = $(".km-content"); elements.style.background-color = "red"; elements1.style.background-color = "red"; elements2.style.background-color = "red"; elements3.style.background-color = "red";*/ var myElements = document.querySelectorAll(".km-content"); for (var i = 0; i < myElements.length; i++) { myElements[i].style.background-color = "red"; } ``` As you can see my first attempt was no good and is commented out. My second attempt is saying `Uncaught ReferenceError: Invalid left-hand side in assignment javascript`. What syntax should I be using? Thanks.
2014/08/27
[ "https://Stackoverflow.com/questions/25519222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3935156/" ]
You cannot use `-`, say like bellow ``` myElements[i].style.backgroundColor = "red"; ``` OR ``` myElements[i].style["background-color"] = "red"; ``` **NOTE:-** If you will go through the comments bellow, you'll get to know the second way gives some problem in FF.