qid
int64
10
74.7M
question
stringlengths
15
26.2k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
27
28.1k
response_k
stringlengths
23
26.8k
7,135,840
I've been trying to parallelize a nested loop as shown here: <http://pastebin.com/nkictYsw> I'm comparing the execution time of a sequential version and parallelized version of this code, but the sequential version always seems to have shorter execution times with a variety of inputs? The inputs to the program are: ...
2011/08/21
[ "https://Stackoverflow.com/questions/7135840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/830854/" ]
If you want to accomplish something like this, you aren't going to be able to use `vector<foo>` to actually be in charge of the `foo` objects themselves. It looks to me like your sub-vector of `foo*`'s must be actually pointing to the memory that the `vector<foo>` is in charge of. (Thus, that's why you still see the ad...
When an object in a `vector` is removed, all the objects at larger indices in the `vector` are moved down to close up the "hole". Pointers to any of those objects become invalid. The only way to detect the situation is not to get into that situation in the first place -- don't store pointers to objects in non-`const` `...
1,191
When I run pdfLaTeX, I get very verbose output: ``` (/usr/local/texlive/2008/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie s/tikzlibrarycalc.code.tex) ... ``` Is there a script to soak up all the verbose output and allow the important stuff to pass through, like errors, overfull hboxes, and so on? Also, is...
2010/08/05
[ "https://tex.stackexchange.com/questions/1191", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/512/" ]
This is what the [silence](http://ctan.org/pkg/silence) package is intended to help with.
In order to neatly format the output, I created my own solution: [pydflatex](https://github.com/olivierverdier/pydflatex). You would compile a file with ``` pydflatex myfile.tex ``` And get an output along the lines of ![pydflatex run](https://i.stack.imgur.com/YLrxX.png) On top of giving a neat, condensed output,...
58,116,823
I don't know whether this is only a matter of style. There are at least 2 ways of handling async actions: ### subscribe after `dispatch` ```ts // action is being dispatched and subscribed this.store.dispatch(new LoadCustomer(customerId)).subscribe(); // <-- subscribe ``` In the State: ```ts @Action(LoadCustomer) l...
2019/09/26
[ "https://Stackoverflow.com/questions/58116823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2176962/" ]
I think it is somewhat a matter of style, but I'd say (from my usage of NGXS) this is most typical: On dispatch do this, and only subscribe here if there's some post-action you want to do. `this.store.dispatch(new LoadCustomer(customerId));` And in the state, the option 1 approach, to return the `Observable` to the ...
Approach number one, as there will be only one subscription and the source component/service will be able to react to it. Subscribing in `@Action` means that whenever the `@Action` handled is called then new subscription will be created.
23,595,858
I'm trying to configure a build system for Scala with SublimeText, but I am having some difficulty. I have tried both of the following: ``` { "shell_cmd": "scala", "working_dir": "${project_path:${folder}}", "selector": "source.scala" } { "cmd": ["/path/to/bin/scala", "$file_name"], "working_dir":...
2014/05/11
[ "https://Stackoverflow.com/questions/23595858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/506971/" ]
The answer that worked turned out to be very close to the second answer - apparently I'm not supposed to open up a new shell. If someone can clarify when to set `"shell": true` in the comments, that would be really helpful. ``` { "cmd": ["/path/to/bin/scala", "$file_name"], "working_dir": "${project_path:${fol...
This works for me: ``` { "cmd": ["scala", "$file"], "working_dir": "${project_path:${folder}}", "selector": "source.scala", "shell": true } ``` given you set the system PATH thing: ``` Variable: %PATH% Value: C:\Program Files (x86)\scala\bin ```
5,190,539
Is there an equivalent to `app.config` for libraries (DLLs)? If not, what is the easiest way to store configuration settings that are specific to a library? Please consider that the library might be used in different applications.
2011/03/04
[ "https://Stackoverflow.com/questions/5190539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/385387/" ]
You **can** have separate configuration file, but you'll have to read it "manually", the `ConfigurationManager.AppSettings["key"]` will read only the config of the running assembly. Assuming you're using Visual Studio as your IDE, you can right click the desired project → Add → New item → Application Configuration Fil...
Why not to use: * `[ProjectNamespace].Properties.Settings.Default.[KeyProperty]` for C# * `My.Settings.[KeyProperty]` for VB.NET You just have to update visually those properties at design-time through: `[Solution Project]->Properties->Settings`
4,001,576
The question is as follows: Give an example of a non-nilpotent linear transformation for some vector space with the following property, for every $v \in V$ there is an $n$ for which $A^n(v)=0$. I really don't know how such a matrix would exist, since you can find a basis for this vector space, let's say $v\_1,v\_2,......
2021/01/27
[ "https://math.stackexchange.com/questions/4001576", "https://math.stackexchange.com", "https://math.stackexchange.com/users/740090/" ]
Let $V$ be the space of all polynomial functions from $\Bbb R$ into $\Bbb R$ and let $A\bigl(p(x)\bigr)=p'(x)$. If $\deg p(x)=n$, then $A^{n+1}\bigl(p(x)\bigr)=0$, but $A$ is not nilpotent: for any $n\in\Bbb N$,$$A\left(x^{n+1}\right)=(n+1)!\ne0.$$
The vector space is neceessarily infinite dimensional. Consider the space of all real sequences $(x\_n)$ such that $x\_n=0$ for $n$ sufficiently large. Define $A(x\_n)=(x\_2,x\_3,..)$. If $x\_n=0$ for $n>N$ then $A^{N}(x\_n)=0$. But, for any $N$, $Ae\_{N+1} \neq 0$ so $A$ is not nilpotent. [$e\_i$ is the sequence which...
648,066
I'm designing an MCU-based electronic device and have a BOM of the major components (power regulators, MCU, serial communication ICs, etc.). Is there any piece of software out there that can convert the suggested circuit designs found within an ICs datasheet to a schematic file? I realize it's the engineer's job to de...
2022/12/29
[ "https://electronics.stackexchange.com/questions/648066", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/235938/" ]
> > Seems like a waste of time to copy over the manufacturer’s circuit schematic from PDF to a KiCad schematic file; wire by wire, and components by component. > > > You'll spend so much time doing everything else in the design process, that this time should be negligible. Invest time in learning KiCad well enough...
The schematic itself is the least of your worries. Even if it a tool existed to take a graphical schematic and translate it to a CAD one, the visual representation lacks other information essential to the design: complete part numbers, physical footprints, operating parameters (voltage, current, temperature, etc.) No...
24,576,009
I m using listfragment in my app. When the data fails to load I call setEmptyText with the failure message. This works fine on 4 inch phones but on 7 and 10 inch phones the size of the empty textview is very small and hard to read. 4 inch empty text view ![enter image description here](https://i.stack.imgur.com/UFj88...
2014/07/04
[ "https://Stackoverflow.com/questions/24576009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203565/" ]
Here is a drop in extension for ListFragment which changes the size (and color) of the empty view programmatically: ``` /** * Abstract list fragment that does customizations of the list style. */ public abstract class LoggingListFragment extends ListFragment { @Override public View onCreateView(LayoutInflater i...
1. Create different folders like res/values-sw720dp,res/values-sw600dp, res/values-v11. 2. Create dimen.xml with different font size of different screen size. 3. Use values/dimen.xml: <resources> <dimen name="normal\_font">16sp </dimen> </resources> 4.Use in your widget in your xml. android:textSize="@dimen/normal\...
41,410,490
I have been trying to center the very bottom row of blue cards. As you can see it is not: [![enter image description here](https://i.stack.imgur.com/van67.png)](https://i.stack.imgur.com/van67.png) So far I have tried `text-align`, `width: 100%;`, and `margin-left: auto; margin right: auto;` But it will just not ce...
2016/12/31
[ "https://Stackoverflow.com/questions/41410490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7128870/" ]
Add `display: inline-block;` to `.col-md-3`. <https://jsfiddle.net/q6hpqob1/> ```css .card { width: 100px; height: auto; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); transition: 0.3s; border-radius: 5px; /* 5px rounded corners */ /* margin-left: 30%; */ } /* Add rounded corners to the top left ...
for bootstrap3 the class for center is text-center ``` <div class="col-md-3 text-center"> <div class="card card-outline-primary text-xs-center"> <div class="card-block"> <blockquote class="card-blockquote"> <p><i clas...
18,065,736
I have this problem, I'm using StringReader to find specific words from a textbox, so far is working great, however I need to find a way how to check specific words in every line against a string array. The following code works: ``` string txt = txtInput.Text; string user1 = "adam"; int users = 0; int systems = 0; u...
2013/08/05
[ "https://Stackoverflow.com/questions/18065736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2615155/" ]
Why not write yourself an extension method to do this? ``` public static class StringExtensionMethods { public static bool ContainsAny(this string self, params string[] toFind) { bool found = false; foreach(var criteria in toFind) { if (self.Contains(criteria)) ...
If you want a case-insensitive search (`as400` will match `AS400`), you can do this ``` if (systemsarray.Any(x => x.Equals(txt, StringComparison.OrdinalIgnoreCase))) { //systemsarray contains txt or TXT or TxT etc... } ``` You can remove [StringComparison.OrdinalIgnoreCase](http://msdn.microsoft.com/en-us/libra...
16,646,205
As the question says how to install Github for Windows without an internet connection? If it is not possible then is there some alternative client with the following features: * Support for proxy * Offline installer I found smartgit which has an offline installer but it seems it doesn't have proxy support. If there...
2013/05/20
[ "https://Stackoverflow.com/questions/16646205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2235567/" ]
This is the answer I received from the support today (2015-06-30): > > Unfortunately we do not have a standalone installer at this time. > GitHub for Windows makes use of Microsoft's ClickOnce technology for > installation and updates. > > > We are currently working on an open source replacement for ClickOnce > ...
For the current version (as of June 2017) of GitHub Desktop (windows), you can go to <https://github-windows.s3.amazonaws.com/standalone/GitHubDesktop.exe> for the standalone, offline installer. For GitHub Desktop (beta), the team is also working to make it an offline installer hopefully by version 1.0. Currently the ...
15,503,242
I'm want to make an iphone app that has a loginViewController. is this code correct and secure? ``` -(IBAction)loginPressed:(id)sender{ NSString *usr = [[NSString alloc]init]; NSString *psw = [[NSString alloc]init]; usr = username.text; psw = password.text; NSLog(@"%@",usr); NSLog(@"%@", psw); NSString *URL = [NS...
2013/03/19
[ "https://Stackoverflow.com/questions/15503242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/651871/" ]
``` NSString *usr = [[NSString alloc]init]; NSString *psw = [[NSString alloc]init]; usr = username.text; psw = password.text; ``` This piece of code create a memory leak. You don't have to alloc a string and retrieve it from label after, just replace it by : ``` NSString* usr = username.text; NSString* psw = passwo...
If you want to save user status between application launches you probably need to set value in `NSUserDefaults`. ``` [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"UserLogged"]; ``` Than you can check this flag ``` if ([[NSUserDefaults standardUserDefaults] boolForKey:@"UserLogged"]) {} ``` Or you ca...
43,732,737
I've been racking my brain trying to fix this. I'm at a loss. I've searched and tried most of the solutions I could find but with no luck. I'm building a basic website as apart of a hobby project for myself. I'm trying to get the page content split in two; left and right. However, the left is is always sitting on top ...
2017/05/02
[ "https://Stackoverflow.com/questions/43732737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7899214/" ]
You can check this method: ``` if (!isTaskRoot()) { super.onBackPressed();//or finish() } else { Intent intent = new Intent(Main2Activity.this, MainActivity.class); startActivity(intent); finish(); } ```
``` // isTaskRoot() returns 'true' if this is the root activity, else 'false'. /* If it returns 'true' this means the current activity is the root activity of your application right now & no activity exist on the back stack, if you press back at this moment your app will be closed. ...
24,096,406
I am new to C#. I want to convert the two strings to single JSON array. I tried the following: ``` var username = "username"; var password = "XXXXXXXX"; var json_data = "result":[{"username":username,"password":password}]'; //To convert the string to Json array i tried like this MessageBox.Show(json_data); ``` It...
2014/06/07
[ "https://Stackoverflow.com/questions/24096406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3100575/" ]
You can use a JSON serialiser API. A commonly used one is the one from Newtonsoft, called [Json.NET](http://james.newtonking.com/json). Job of such an API is to convert C# objects to JSON (also known as serialisation) and convert JSON data into C# objects (deserialisation). In your example, Newtonsoft JSON API can b...
In [Javascript Object Notation](http://json.org/json-de.html) the top level is always an object. In JSON an array is not an object but it can be a value. You can unfold the grammer into this: ``` { string : [ { string : string , string : string },{ string : string , string : string } ] } ``` in your case this coul...
23,639,113
`ViewSets` have automatic methods to list, retrieve, create, update, delete, ... I would like to disable some of those, and the solution I came up with is probably not a good one, since `OPTIONS` still states those as allowed. Any idea on how to do this the right way? ```python class SampleViewSet(viewsets.ModelView...
2014/05/13
[ "https://Stackoverflow.com/questions/23639113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2089556/" ]
If you are trying to disable the PUT method from a DRF viewset, you can create a custom router: ``` from rest_framework.routers import DefaultRouter class NoPutRouter(DefaultRouter): """ Router class that disables the PUT method. """ def get_method_map(self, viewset, method_map): bound_method...
An alternative approach for Viewsets in django-rest-framework to enable/disable methods. Here is an example api/urls.py: ``` user_list = UserViewSet.as_view({ 'get': 'list' }) user_detail = UserViewSet.as_view({ 'get': 'retrieve' 'put': 'update', 'post': 'create', 'p...
110,987
When you track down and fix a regression—i.e. a bug that caused previously working code to stop working—version control makes it entirely possible to look up who committed the change that broke it. Is it worth doing this? Is it constructive to point this out to the person that made the commit? Does the nature of the m...
2011/09/27
[ "https://softwareengineering.stackexchange.com/questions/110987", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/17701/" ]
If you just approach them to tell them about a mistake they made then unless you are the best diplomat in the world its going to be difficult for it not to just sound like "Ha! - look at this mistake you made!". We are all human and criticism is difficult to take. On the other hand unless the change is completely triv...
If someone gets offended when you said him he made a mistake, it means he thinks he is the wisest on the earth and makes no mistake, and when criticized, he gets the feeling, as we said in Poland, that 'crown is falling from his head'. So you shouldn't hesitate to say that someone has made a mistake. It is normal. Eve...
59,856,861
I create a form where I check the length of a password. If length is <6 then an error message appears. This message is created by javascript. And here is the problem, the message appears with a line break after every word. I also tried it with ' ' but that doesn't work:( How do I create the message without the line br...
2020/01/22
[ "https://Stackoverflow.com/questions/59856861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10474530/" ]
You can first split the string containing your datas (`queryResult.final_Matrix[index]`) to get each parts separatly, then, for each parts, split again using `":"` and apply some math (multiply by 100) to get the percentage : ```js let input = "53-34-98:0.0045, 98-11-00:0.09856, 44-22-88:0.09875, 22-98-90:0.3245"; l...
You can loop, split according to the strings, reducing the array of tokens (those separated by comma `,`) and finally rebuild the tokens with the transformed percentage values. ```js let arr = [ { "id": "12345", "header": "<a class=\"card-link\" href=\"http://www.google.com\" target=\"_blank\"> 12345</a>- solve...
32,471,985
I am trying to build a section where we can add users with `Role_ID=2` `Role_ID` is in some other table named as `User_Details`, and is linked with current `user` table `id` as foreign key. **Here is code for my UserController.php** ``` function addUser(){ $this->set('setTab','addUser'); $this->set...
2015/09/09
[ "https://Stackoverflow.com/questions/32471985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3322344/" ]
Your code is fundamentally wrong (I think). According to what you say (the conditions in your problem statement), this should be the code: ``` public static boolean search(int[] keys, int value, int l, int r) { if(l < 0 || r >= keys.length || l>r) return false; else { Random random = new Random()...
See this part of your code, ``` else if(keys[i] > value) return search(keys, value, i - 1); //Line1 else return search(keys, value, i + 1); //Line2 ``` You are searching in the same part of the array in both case. `Line1` searches for the `value` in the array from `0` to `i - 1`. `Line2` searches f...
58,839,913
I have two dataframes, `dfa` and `dfb`: ``` dfa <- data.frame( gene_name = c("MUC16", "MUC2", "MET", "FAT1", "TERT"), id = c(1:5) ) dfb <- data.frame( gene_name = c("MUC1", "MET; BLEP", "MUC21", "FAT", "TERT"), id = c(6:10) ) ``` which look like this: ``` > dfa gene_name id 1 MUC16 1 2 MUC2 2 ...
2019/11/13
[ "https://Stackoverflow.com/questions/58839913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8876619/" ]
You can use `seperate_rows()` to split the dataframe before joining. Note that if `BLEP` existed in dfa, it would result in a duplicate, which is why distinct is used ``` dfa <- data.frame( gene_name = c("MUC16", "MUC2", "MET", "FAT1", "TERT"), id = c(1:5), stringsAsFactors = FALSE ) dfb <- data.frame( gene_n...
Here's a solution using `stringr` and `purrr`. ``` library(tidyverse) dfb %>% mutate(gene_name_list = str_split(gene_name, "; ")) %>% mutate(gene_of_interest = map_lgl(gene_name_list, some, ~ . %in% dfa$gene_name)) %>% filter(gene_of_interest == TRUE) %>% select(gene_name, id) ```
35,301,178
Long-running, high-end Excel-based applications that I developed years ago and that run beautifully in Excel 2007 and 2010 look like Amateur Hour in Excel 2013 and 2016 because `Application.ScreenUpdating = False` no longer works reliably. The screen unfreezes apparently when VBA code copies a preformatted worksheet f...
2016/02/09
[ "https://Stackoverflow.com/questions/35301178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5410232/" ]
We have been dealing with this problem now for a long time as my tools do show live animated charts which all of the sudden were completely static - we would have died for having at least a flickering animation. Initially we tried to force the animation with a forced screenupdate but that did not work. Just by pure co...
For me, only "Application.ScreenUpdating = False" did not completely cure the flickering. Calculation caused also the flickering. Adding "Application.Calculation = xlCalculationManual" solved the flickering issue. So, the code should be like: Application.ScreenUpdating = False Application.Calculation = xlCalculationMa...
793,926
The following `DataTemplate.DataTrigger` makes the age display red if it is **equal to** 30. How do I make the age display red if it is **greater than** 30? ``` <DataTemplate DataType="{x:Type local:Customer}"> <Grid x:Name="MainGrid" Style="{StaticResource customerGridMainStyle}"> <Grid.ColumnDefinitions...
2009/04/27
[ "https://Stackoverflow.com/questions/793926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
I'd recommend using an `IValueConverter` to bind to the `Foreground` element of the Age `TextBlock` and isolating the coloring logic there. ``` <TextBlock x:Name="Age" Text="{Binding Age}" Foreground="{Binding Path=Age, Converter={StaticResource AgeToColorConverter}}" /> ``` Then in the Cod...
I believe there is a simpler way of acheiving the goal by using the powers of MVVM and `INotifyPropertyChanged`. --- With the `Age` property create another property which will be a boolean called `IsAgeValid`. The `IsAgeValid` will simply be an *on demand* check which does not *technically* need an the `OnNotify` ca...
31,704,822
Question with left join. I am trying to LEFT JOIN a table that requires other tables to be joined on the initial left joined table. So.. ``` SELECT * FROM tableA LEFT JOIN tableB ON tableB.id=tableA.id JOIN tableC ON tableC.id=tableB.id ``` The problem is if I don't left join table C I get no results, and if...
2015/07/29
[ "https://Stackoverflow.com/questions/31704822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/456850/" ]
> > I don't left join table C I get no results, and if do left join I get > too many results > > > You need to determine what is your driving table and data. In this case, it seems like table A is the driving table and the join from B to C also could be a left join, meaning data from C could be returned even if n...
I think you might want this logic: ``` SELECT * FROM tableA LEFT JOIN (tableB JOIN tableC ON tableC.id = tableB.id ) ON tableB.id = tableA.id ; ``` Normally, with `LEFT JOIN` you want to chain them, but there are some exceptions.
52,425,988
I would like to download this file <https://www.omniva.ee/locations.xml> with VBA or VB6. I can do it with C# using webClient but i don't know how do it in VBA or VB6. Is it possible without IE API? Because it doesn't work for me: [![enter image description here](https://i.stack.imgur.com/XsXdC.png)](https://i.stack....
2018/09/20
[ "https://Stackoverflow.com/questions/52425988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10391525/" ]
you could try that but make a copy of the otherlist to not lose the info: ``` [row+[myotherlist.pop(0)] if row[0]=='Download' else row for row in listScheduel] ``` for example: ``` list = [['Download',1,2,3],[0,1,2,3],['Download',1,2,3],['Download',1,2,3]] otherlist = [0,1,2,3,4] l = [ row+[otherlist.pop(0)] if ro...
We can use a queue and pop its values one by one when we meet the condition. To avoid copying of data let's implement the queue as a view over `myOtherList` using an iterator (thanks to [ShadowRanger](https://stackoverflow.com/users/364696/shadowranger)). ``` queue = iter(myOtherList) for row in listSchedule: if ...
70,203,149
I want to handle foreground firebase messages. But messaging().onMessage is not triggered very first time app launched in iOS. This is working fine in Android. Exact scenario is: * First time launch app : messaging().onMessage not triggered in iOS * Close and reopen app : messaging().onMessage will trigger ``` import...
2021/12/02
[ "https://Stackoverflow.com/questions/70203149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8112970/" ]
The writerows() method expects a list of lists. A row is a list and the rows are a list of those. Two solutions, depending on what you want: ``` even_numbers = [[2, 4, 6, 8]] ``` or ``` even_numbers = [[2], [4], [6], [8]] ``` To do that latter transformation automatically, use: ``` rows = [[data] for data in ev...
According to [the documentation](https://docs.python.org/3/library/csv.html#csv.csvwriter.writerows), the `writeRows` method expects a list of row objects as a parameter. You can also see the definition [of a row object here](https://docs.python.org/3/library/csv.html#writer-objects). That is: > > A row must be an ...
51,712,220
Lets say my use-case is to print a list of posts. I have the following react component. ``` class App extends Component { constructor(props) { super(props); this.state = { loaded: !!(props.posts && props.posts.length) }; } componentDidMount() { this.state.loaded...
2018/08/06
[ "https://Stackoverflow.com/questions/51712220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4191127/" ]
The recommended solution would be to move that to `mapStateToProps`. Most of the time when you need data from your store (here it's `posts`) or data that is derived from store (here `loading`) then `mapStateToProps` is the correct place to inject that. It is usually a good idea to keep the component as dumb as possible...
2 is correct. It is better to maintain the state in Redux only. Otherwise, you have two separate states for this component!
4,368,308
I'm using SOAPUI tool to access JAX-WS web services deployed in Weblogic 10.3.2 Request: ```xml <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.pc3.polk.com/"> <soapenv:Header> <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/...
2010/12/06
[ "https://Stackoverflow.com/questions/4368308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/117802/" ]
Issue is with the Handlers. You need to add following in handler implementation ``` public Set<QName> getHeaders() { final QName securityHeader = new QName( "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", "wsse"); final HashSet headers ...
In SOAP UI Navigator, right-click your project->Show Project View->WS-Security Configurations->Outgoing WS-Security Configurations **Uncheck** Must Understand, and then send request.
21,140,349
This has been awnsered many times here and at other sites and its working, but I would like ideas to other ways to: get the ReadyState = Complete after using a navigate or post, without using DoEvents because of all of its cons. I would also note that using the DocumentComplete event woud not help here as I wont be n...
2014/01/15
[ "https://Stackoverflow.com/questions/21140349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3198440/" ]
**The solution is simple:** ``` // MAKE SURE ReadyState = Complete while (WebBrowser1.ReadyState.ToString() != "Complete") { Application.DoEvents(); } ``` // Move on to your sub-sequence code... --- Dirty and quick.. I am a VBA guys, this logic has been working ...
Here is a "quick & dirty" solution. It's not 100% foolproof but it doesn't block UI thread and it should be satisfactory to prototype WebBrowser control Automation procedures: ``` private async void testButton_Click(object sender, EventArgs e) { await Task.Factory.StartNew( () => ...
16,506,865
Hi I am trying to setup a project using [composer](http://getcomposer.org/). I am able to install [CakePHP](http://cakephp.org/) but I am getting a hard time installing [cakephp/debug\_kit](http://plugins.cakephp.org/p/52-debug_kit) on a custom direcoty. I am trying to install it on "vendor/cakephp/cakephp/app/Plugin/D...
2013/05/12
[ "https://Stackoverflow.com/questions/16506865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1260962/" ]
If you want to add all plugins to `app/Plugin` instead of defining custom path for each plugin, update your `extra` block like this: ``` "extra": { "installer-paths": { "app/Plugin/{$name}/": ["type:cakephp-plugin"] } } ```
[Composer Packages Custom Installer plugin](https://github.com/farhanwazir/cpcinstaller), you don't need to develop custom installer. Just FORK it and add your instructions in config directory under src/Installer [CPCInstaller](https://github.com/farhanwazir/cpcinstaller) will do everything for you.
304,317
Does MySQL index foreign key columns automatically?
2008/11/20
[ "https://Stackoverflow.com/questions/304317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
Apparently an index is created automatically as specified in [the link robert has posted](http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html). > > InnoDB requires indexes on foreign keys and referenced keys so that foreign key checks can be fast and not require a table scan. In the referencing...
Yes, `Innodb` provide this. You can put a foreign key name after `FOREIGN KEY` clause or leave it to let MySQL to create a name for you. MySQL automatically creates an index with the `foreign_key_name` name. ``` CONSTRAINT constraint_name FOREIGN KEY foreign_key_name (columns) REFERENCES parent_table(columns) ON DELET...
5,072,415
I have 2 different radio button fields sets `name=top` and `name=bottom`. ``` <div class="branch"> <div class="element"> <label for="top">top color:</label> <input type="radio" value="1" name="top" checked="checked">black <input type="radio" value="0" name="top">white <input type="radio" va...
2011/02/21
[ "https://Stackoverflow.com/questions/5072415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/605098/" ]
Ummm, you have a `cout << '\n';` inside that loop... so it'll print a `newline` for each time it goes through the loop.
Because of the: ``` for(;;) ``` Which stands for 'do this forever' combined with the fact that the rows and columns may never be both set to zero with cin. Try typing in zeroes for the cin input and it might end. Also write: ``` cout << endl; ``` That is just what I do because I like flushing buffers.
70,737,474
I made a simple `sqrt` struct using TMP. It goes like : ``` template <int N, int i> struct sqrt { static const int val = (i*i <= N && (i + 1)*(i + 1) > N) ? i : sqrt<N, i - 1 >::val; }; ``` but is causes error since it does not have the exit condition, so I added this : ``` template <int N> struct sqrtM<N, 0> ...
2022/01/17
[ "https://Stackoverflow.com/questions/70737474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6543053/" ]
The thing is that in TMP you can't go very deep by default. The depth is limited but the limit can be changed (see [this](https://www.ibm.com/docs/en/xl-c-and-cpp-linux/13.1.1?topic=descriptions-ftemplate-depth-qtemplatedepth-only)). The other thing is that you write your TMP code with recursion but it can be compiled ...
There is a difference between evaluation and instantiation. in ``` template <int N, int i> struct sqrt { static const int val = (i*i <= N && (i + 1)*(i + 1) > N) ? i : sqrt<N, i - 1 >::val; }; ``` it should instantiate `sqrt<N, i - 1 >` to retrieve associated `val`, even if that value won't be taken at the end....
258,396
I'm setting up a secure server for my use only to store encrypted files, but it will need to be accessed from the internet. The server itself is in a secure location with no physical access which is fine, but I'm more worried about the internet side. I'm thinking of using Ubuntu with no other software apart from open s...
2011/04/11
[ "https://serverfault.com/questions/258396", "https://serverfault.com", "https://serverfault.com/users/-1/" ]
``` iptables -A INPUT -p tcp -m state --state NEW --dport 22 -m recent --name sshattack --set iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --rcheck --seconds 60 --hitcount 4 -j LOG --log-prefix 'SSH REJECT: ' iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --nam...
Here's a basic guide to [securing Linux ssh](http://www.farinspace.com/secure-login-linux-server/). This covers setting up (and only using) Public Key Authentication, disabling root login (and seting up sudo), and using non-standard ports. Here's an [iptables guide](http://www.linuxhomenetworking.com/wiki/index.php/Qu...
22,120,859
``` #include <stdio.h> #include <stdlib.h> #include <string.h> struct fileData { char fileName[100]; int size; char type; long timestamp; }; void print(struct fileData *myFile); int main(void) { struct fileData *toUse = malloc(sizeof(toUse)); char temp[100] = {0}; ...
2014/03/01
[ "https://Stackoverflow.com/questions/22120859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2494817/" ]
1. Try scanf("%c\n", ...) so that scanf waits for a return character 2. fgets(toUse->fileName, 100, stdin); can work, toUse->fileName = "Test"; don't because "Test" is a pointer to the "Test" string, but toUse->fileName is a buffer, you can fgets in it directly 3. %lf is a long float format. Try %ld in your scanf. Then...
Because you didn't allocate enough space. `SizeOf(toUse)` = size of an address, on a 32 bit machine = 4 bytes, but clearly the size of your structure is more than 100 Bytes. So, you need to allocate the sizeof the `structure fileDate`. Change: ``` struct fileData *toUse = malloc(sizeof(toUse)); ``` to: ``` str...
4,798
How should I prepare my army when attacking someone who has 12+ battlecruisers? (Protoss/Zerg/Terran answers are more than appreciated)
2010/08/08
[ "https://gaming.stackexchange.com/questions/4798", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/2473/" ]
You shouldn't be giving him the time to get those 12+ Battlecruisers. So you should press him earlier so he doesn't get that far up the tech tree AND has the time to built that many Battlecruisers
First of all, I do not understand why people are telling you, "You should not give him that much time to build 12 Battlecruisers in the first place". That is clearly not a solution to fighting Battlecruisers. For Protoss players up against Battlecruisers, Phoenixes **CANNOT** take on Battlecruisers. Go try it, they w...
1,775,302
Some time ago i Wrote a service with a timer that make an action every n minutes. All was right. But now, I want to write a service that waits for a signal, message or something from a gui application for doing his job. I want me process to sleep pacefull (not in a infinite loop sniffing something) until my winforms a...
2009/11/21
[ "https://Stackoverflow.com/questions/1775302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/81076/" ]
You can use [Windows Communication Foundation](http://msdn.microsoft.com/en-us/netframework/aa663324.aspx) to allow your client to communicate with your service, send it requests, and register to receive progress events from existing running jobs.
You need to use interprocess communication (IPC). For C#, this usually means either .NET remoting -- on older versions of .NET -- or Windows Communication Foundation (WCF) -- on newer versions of .NET. Essentially, the client application connects to an interface implemented by the service, and can then call methods on...
79,870
I'm trying to implement ssh server under a custom Debian-based installation, which has no GUI, and yet no ssh access. How can I know whether SSH is installed, and how can I know whether the firewall actually allows it or not ?
2009/12/07
[ "https://superuser.com/questions/79870", "https://superuser.com", "https://superuser.com/users/7768/" ]
To check whether the firewall allows it (assuming you're using iptables) write `iptables -l` (with root, otherwise put `sudo` in front). As to whether the ssh-server is installed or not (assuming you're using packages) do `aptitude search openssh-server` and check the status marker next to the name. If you're outside...
1. If you have console access, `dpkg -l openssh-server` will tell you whether or not the SSH server package is installed. 2. Running `pgrep sshd` will return the process ID of the SSH daemon if it is running.
16,627
I'm having a very frustrating problem with my Joomla 1.6 site. I cannot add any new extensions through the admin interface. I have tried to upload the extension, or to use the search folder option or even the direct link. Neither of these options work, and all that happens is that the page tries to load forever until i...
2011/07/08
[ "https://webmasters.stackexchange.com/questions/16627", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/8885/" ]
There's a lot more to SEO than a Google Places listing or number of pages in a website. There are at least 200 ranking factors and they vary in importance. The site that is outranking you *probably* has better quality links then you do. Quantity of backlinks is irrelevant. Quality is what matters. Not to mention you ...
**How Google determines local ranking** 1. Local results are based primarily on [relevance, distance, and prominence](https://support.google.com/business/answer/7091?hl=en#factors). 2. Use Google Ads for local places. It's works.
52,610,246
I have Chat service in .NET Core Web API, handling chat messages through Signal R when clients are online. Also, i have mobile clients (android/apple) and i need to handle messages sent when client is in offline mode. I am aware if clients are offline/online. So, when the client is offline, i want to send message to ...
2018/10/02
[ "https://Stackoverflow.com/questions/52610246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7450326/" ]
You need To make a POST request to <https://fcm.googleapis.com/fcm/send> with the following parameters **Header** * *Authorization:* `key=YOUR_SERVER_KEY` * *Content-Type:* `Application/JSON` **Body:** ``` { "to" : "YOUR_FCM_TOKEN_WILL_BE_HERE", "collapse_key" : "type_a", "notification" : { "body" : "First N...
You can use any cloud solutions for this case, like Azure Notification Hub. You can check the [documentation](https://learn.microsoft.com/en-us/azure/notification-hubs/) and configure your app with Notification Hub. With default configuration you will be able to broadcast your notification to all registered devices. ...
3,514,321
For example, $X\_1, X\_2 \sim U[0,t]$. Does it imply that $2X\_1+X\_2 \sim U[0,3t]$?
2020/01/19
[ "https://math.stackexchange.com/questions/3514321", "https://math.stackexchange.com", "https://math.stackexchange.com/users/732644/" ]
A linear combination of uniform random variables is in general not uniformly distributed. In this case we have $Y=2X\_1+X\_2$, where $2X\_1\sim\mathrm{Unif}(0,2t)$ and $X\_2\sim\mathrm{Unif}(0,t)$. The density of $2X\_1$ is $f\_{2X\_1}(x) =\frac1{2t}\mathsf 1\_{(0,2t)}(x)$, and the density of $X\_2$ is $f\_{X\_2}(x) = ...
**If** $X\_2$ is always equal to $X\_1,$ and $X\_1\sim\operatorname{Uniform}[0,t],$ then $2X\_1+X\_2\sim\operatorname{Uniform}[0,3t].$ At the opposite extreme, if $X\_1,X\_2\sim\operatorname{Uniform}[0,t]$ and $X\_1,X\_2$ are independent, then $2X\_1+X\_2$ is **not** uniformly distributed. You haven't told use the **jo...
31,757,852
I've looked around a lot, and I understand that there's a lot of ways to detect internet explorer. My problem is this: I have an area on my HTML document, that when clicked, calls a JavaScript function that is incompatible with internet explorer of any kind. I want to detect if IE is being used, and if so, set the var...
2015/08/01
[ "https://Stackoverflow.com/questions/31757852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using UAParser <https://github.com/faisalman/ua-parser-js> ``` var a = new UAParser(); var name = a.getResult().browser.name; var version = a.getResult().browser.version; ```
If we need to check Edge please go head with this if(navigator.userAgent.indexOf("Edge") > 1 ){ ``` //do something ``` }
1,168,668
So, I have an iterative function that looks something like this. $$f(x\_n) = (x\_n + 0.08) \cdot 0.98$$ e.g. So if $n = 2$ and $x$ started at $0$, then the equation would be equal to $(((0 + 0.8) \cdot 0.98) + 0.08) \cdot 0.98$, which is $0.155232$. Is it possible to create a formula that can find the value of any i...
2015/02/28
[ "https://math.stackexchange.com/questions/1168668", "https://math.stackexchange.com", "https://math.stackexchange.com/users/219887/" ]
We have $$x\_n = 0.98 \cdot x\_{n-1} + 0.08 \cdot 0.98$$ $$x\_{n+1} = 0.98 \cdot x\_n + 0.08 \cdot 0.98$$ Subtract to get $$x\_{n+1}=1.98 \cdot x\_n-0.98 \cdot x\_{n-1}$$ You get the following characteristic polynomial $$p(x)=x^2-1.98x+0.98$$ Whose roots are $x\_1=1, \space x\_2=0.98$ So the general formula is $x\_n...
If the starting value is $t$ and the numbers $0.08,\ 0.98$ are called $a,b$ then your iteration takes $t$ into $(t+a)b.$ Working out the first few iterates we have $$t,\\ bt+ab,\\ b^2t+ab(b+1),\\ b^3t+ab(b^2+b+1).$$ If we apply the sum of a geometric series to the lengthening sequence of powers of $b$ occurring on the ...
72,104,323
I am trying to sum up values inside an object, but i am adding a Nullish coalescing operator if undefined or null then it should have zero value. But here instead of getting 10 i am getting 4 only. ```js let data = { a: 4, b: 6, c: null } console.log(data?.a ?? 0 + data?.b ?? 0 + data?.c ?? 0) ``` Any help is ...
2022/05/03
[ "https://Stackoverflow.com/questions/72104323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10829671/" ]
Just add small brackets this will do. The reason for above not running is because the `??` operator is conditional and will evaluate the first statement since there is value for `data?.a` it will not run the right part of it which is `0 + data?.b ?? 0 + data?.c ?? 0` ```js let data = { a: 4, b: 6, c: null } con...
Ideal case for [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce). * First: make an array of values with `Object.value` * Next: reduce (awesome method to master) * Optional: Use `+` operator for elegant type conversion (might not work in every case) ``` console.log...
34,791,244
I am using Retrofit 2 (2.0.0-beta3) with OkHttp client in Android application and so far everything going great. But currently I am facing issue with OkHttp Interceptor. The server I am communicating with is taking access token in body of request, so when I intercept the request to add auth token or in authenticate met...
2016/01/14
[ "https://Stackoverflow.com/questions/34791244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114956/" ]
Since this cannot be written in the comments of the previous answer by @Fabian, I am posting this one as separate answer. This answer deals with both "application/json" as well as form data. ``` import android.content.Context; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; im...
I'm using this way to verify my token ``` final OkHttpClient okHttpClient = new OkHttpClient.Builder() .connectTimeout(30, TimeUnit.SECONDS) //retrofit default 10 seconds .writeTimeout(30, TimeUnit.SECONDS) //retrofit default 10 seconds .readTimeout(30, TimeUnit.SECONDS)...
3,146,013
I've not been able to find any documentation stating the existence of an API that can be used to automate things inside of a qemu guest. For example, I would like to launch a process inside of the guest machine from the host machine. Libvirt does not appear to contain such functionality.
2010/06/30
[ "https://Stackoverflow.com/questions/3146013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29049/" ]
[Note: Automation without using any virtualization API. From my [blog post](http://db42.wordpress.com/2011/10/14/guest-automation-with-qemukvm/).] **Step 1:** By default, QEMU uses SDL to display the VGA output. So, the first step is make this interaction with QEMU through standard I/O. QEMU provides an option for th...
The [QEMU Monitor](http://en.wikibooks.org/wiki/QEMU/Monitor) can interact with guest systems to a limited extent using it's own console. This includes reading registers, controlling the mouse/keyboard, and getting screen dumps. There is a [QEMU Monitor Protocol (QMP)](http://wiki.qemu.org/QMP) that let's you pass JSON...
16,060,696
I'm working with `Visual Studio`, `ASP.net`, `HTML`, `CSS`, `C#` (for the code behind), `ADO.net` and `Javascript/Jquery`. I'm trying to make a web page with some `div` block and I want that the block never exceed the browser. Do you know : how to add a height size for `div` even if I change the resolution of my wind...
2013/04/17
[ "https://Stackoverflow.com/questions/16060696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2265252/" ]
Without further clarification of your senario, one method is to do the following: **HTML** ``` <div id="test"> My div </div> ``` **CSS** ``` html, body {height:100%;margin:0;padding:0} #test {width:100%; height: 100%;position:absolute;} ```
I've encountered screen resolution problem before and this solved my problem. * If you want your website to dynamically changing whenever your screen resolution change you can use % in your css to all your page, containers, wrappers etc. so that it will adjust on any screen resolution. (*problem: This destroys your ...
19,620
I'm coming from this question: <https://superuser.com/questions/359799/how-to-make-freebsd-box-accessible-from-internet> I want to understand this whole process of `port forwarding`. I read so many things, but am failing to understand the very basic concept of port forwarding itself. What I have: > > a freebsd ser...
2011/08/28
[ "https://unix.stackexchange.com/questions/19620", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/1358/" ]
### I'll start with the raw facts : 1. You have: `A` - your FreeBSD box, `B` - your router and `C` - some machine with Internet access. This is how it looks like: ``` .-----. .-----. .-----. | A | == | B | - - ( Internet ) - - | C | '-----' '-----' '--...
This can be done by your router. On some router this feature is called `Virtual Server` See in below part of image there are two examples of port forwarding. One is of Web and another one is of SSH. In first case any request on your WAN IP i.e. the IP of your router with port `80` will be forwarded to a LAN IP ( `192....
51,943,106
It is perfectly valid to import from a URL inside an ES6 module and as such I've been using this technique to reuse modules between microservices that sit on different hosts/ports: ``` import { authInstance } from "http://auth-microservice/js/authInstance.js" ``` I'm approaching a release cycle and have started down...
2018/08/21
[ "https://Stackoverflow.com/questions/51943106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3236706/" ]
I had to move on from this quickly so ended up just writing a skeleton of a rollup plugin. I still feel that resolving absolute paths should be a core feature of rollup. **Updated snippet** We have been using this to transpile production code for several of our apps for a considerable amount of time now. ```js const...
This plugin together with the following config works for me: <https://github.com/mjackson/rollup-plugin-url-resolve> ```js import typescript from "@rollup/plugin-typescript"; import urlResolve from "rollup-plugin-url-resolve"; export default { output: { format: "esm", }, plugins: [ typescript({ lib: ["e...
34,726,547
i'm working on ACTIVITI and need to hide this button: [![Button](https://i.stack.imgur.com/3oKrk.png)](https://i.stack.imgur.com/3oKrk.png) if no process are instantiate, i.e. if server return this (show button): [![noprocess](https://i.stack.imgur.com/FI66R.png)](https://i.stack.imgur.com/FI66R.png) instead of th...
2016/01/11
[ "https://Stackoverflow.com/questions/34726547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5740267/" ]
After some experiments, I have figured it out. Here is my solution in case someone reaches a dead end. ``` $request = new Request( 'POST', $uri, ['Content-Type' => 'text/xml; charset=UTF8'], $xml ); ```
You can do that in a below way ``` $xml_body = 'Your xml body'; $request_uri = 'your uri' $client = new Client(); $response = $client->request('POST', $request_uri, [ 'headers' => [ 'Content-Type' => 'text/xml' ], 'body' => $xml_body ]); ```
16,082,054
We have an eShop build on prestashop and we are developing new features every week. I'm writing here because I don't find the correct way to update our production environment with the changes, without having to upload all the code again or having to upload the modified files manually. Now we work like this: * Our dev...
2013/04/18
[ "https://Stackoverflow.com/questions/16082054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/600377/" ]
Here is the workflow we use, it's (I guess) pretty standard: * one git repo * preprod domain * prod domain All the development is done on branches, when it's ready to ship we merge on the master. So on the preprod we pull the branch we are working on, and on the production we only pull the master. The preprod and pro...
I think you answer is not correct as well :) Check this code if you use apache on you web server This need to be present in your .htaccess file ``` RewriteCond %{HTTP:Authorization} ^(.*) RewriteRule . - [E=HTTP_AUTHORIZATION:%1] ``` And of course you need to have .htpasswd file. Its mean any file or foldier whic...
52,857,484
Keep getting a sync error on this line of code. **implementation 'com.android.support:support.media.compat:28.0.0'** No idea what it means, and I have tried multiple times to change the library with no luck ``` dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.suppo...
2018/10/17
[ "https://Stackoverflow.com/questions/52857484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10433454/" ]
If you want only to wrap the icons without media queries you can try this ```css *{ font-family: verdana; margin: 0; } body{ background: #eee; } .wrapper{ width: 100%; max-width: 960px; margin: 0 auto; } .flex-wrapper{ display:flex; flex-wrap:wrap; flex-grow: 1 ; } ....
Here's a version that scales. ```css body { margin: 0; background: #eee; font-family: verdana; } img { max-width: 100%; display: inline-block; } .users { position: relative; box-sizi...
50,025,908
How can I convert an image to array of bytes using ImageSharp library? Can ImageSharp library also suggest/provide RotateMode and FlipMode based on EXIF Orientation?
2018/04/25
[ "https://Stackoverflow.com/questions/50025908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3648560/" ]
If you are looking to convert the raw pixels into a `byte[]` you do the following. ```cs var bytes = image.SavePixelData() ``` If you are looking to convert the encoded stream as a `byte[]` (which I suspect is what you are looking for). You do this. ```cs using (var ms = new MemoryStream()) { image.Save(ms, ima...
For those who look after 2020: SixLabors seems to like change in naming and adding abstraction layers, so... Now to get a raw byte data you do the following steps. 1. Get `MemoryGroup` of an image using `GetPixelMemoryGroup()` method. 2. Converting it into array (because `GetPixelMemoryGroup()` returns a interface) a...
11,812,142
OK, I want to get all the data from the first column of a JTable. I though the best way would be pulling it in to a `ArrayList`, so I made one. I also made an instance of a `TableModel`: ``` static DefaultTableModel model = new javax.swing.table.DefaultTableModel(); f.data.setModel(model); //f.data is the JTable pub...
2012/08/04
[ "https://Stackoverflow.com/questions/11812142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1332495/" ]
It is best if you could post [SSCCE](http://sscce.org/) that shows model initialization and its population with data. Also include details of the exception as there could be multiple sources for the problem. Here is a demo based on @CedricReichenbach correction: ``` import java.util.ArrayList; import java.util.List...
I know this answer is a bit late, but it is actually a very easy problem to solve. Your code gives an error when reading the entry because there is no entry in the table itself for the code to read. Populate the table and run your code again. The problem could have been solved earlier but from the code you posted it wa...
67,052
I would like to design a dungeon-like location, a city surrounding a keep built on a limestone hill littered with caves. Tunnels and caverns would connect certain city locations to keep dungeons but also to some natural formations, which are used as building parts, free storage space, or in some deeper cases unused, ab...
2015/08/13
[ "https://rpg.stackexchange.com/questions/67052", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/14670/" ]
Forget about floors and levels, and think in sections. ------------------------------------------------------ Split the map into manageable sections. Each section could be a large room with several entries, a corridor with some rooms and two exits, etc. Give each section a name and each exit/entrance a number. While t...
What you're describing -- a sprawling, unorganized network with no set floor structure -- doesn't really require a detailed representation of three dimensional spatial positioning, or at least not throughout the entirety of it. Think about it like this -- if you're travelling through a subway station to a different exi...
61,218,789
Get averages from a python dictionary for example if i have the next dictionary: ``` students={'Dan':(5,8,8), 'Tim':(7), 'Richard':(9,9)} ``` And i would like to print de dictionary in the next form: ``` results={'Dan':(7), 'Tim':(7), 'Richard':(9)} ``` is there any function that i can use? Im new coding in pytho...
2020/04/14
[ "https://Stackoverflow.com/questions/61218789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11048727/" ]
I'd do: ``` result = {} for k, v in students.items(): if type(v) in [float, int]: result[k] = v else: result[k] = sum(v) / len(v) ```
A pythonic solution would be to use dictionary comprehension to create the results dictionary. ``` def avg(l): return sum([l]) / len(l) results = {key: (avg(val)) for (key, val) in students.items()} ``` You need brackets around the l in sum so the tuple is treated as a list. I would further change the data str...
36,716,818
What is the *idiomatic* way to do the following string concatenation in R? Given two vectors of strings, such as the following, ``` titles <- c("A", "B") sub.titles <- c("x", "y", "z") ``` I want to produce the vector ``` full.titles <- c("A_x", "A_y", "A_z", "B_x", "B_y", "B_z") ``` Obviously, this could be don...
2016/04/19
[ "https://Stackoverflow.com/questions/36716818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5768077/" ]
``` apply(expand.grid(titles, sub.titles), 1, paste, collapse = "_") ``` `expand.grid` creates a matrix of combinations between `titles` and `sub.titles`. `apply` goes down the matrix of combinations and pastes them together.
``` full.titles <- paste0(expand.grid(titles,sub.titles)$Var1,'_', expand.grid(titles,sub.titles)$Var2) >full.titles [1] "A_x" "B_x" "A_y" "B_y" "A_z" "B_z" ```
12,603,837
So I made a game loop that uses `SDL_Delay` function to cap the `frames per second`, it look like this: ``` //While the user hasn't qui while( stateID != STATE_EXIT ) { //Start the frame timer fps.start(); //Do state event handling currentState->handle_events(); //Do state logic currentStat...
2012/09/26
[ "https://Stackoverflow.com/questions/12603837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1680034/" ]
Use the QueryPerformanceCounter / Frequency for that. ``` LARGE_INTEGER start, end, tps; //tps = ticks per second QueryPerformanceFrequency( &tps ); QueryPerformanceCounter( &start ); QueryPerformanceCounter( &end ); int usPassed = (end.QuadPart - start.QuadPart) * 1000000 / tps.QuadPart; ```
60 fame per second is just the frequency of power in US (50 in Europe, Africa and Asia are somehow mixed) and is the frequency of video refreshing for hardware comfortable reasons (It can be an integer multiple on more sophisticated monitors). It was a mandatory constrains for CRT dispaly, and it is still a comfortable...
1,491,566
In my solution [here](https://math.stackexchange.com/a/1484125/168053), it was shown that $$\omega+\omega^2+\omega^4=-\frac 12\pm\frac{\sqrt7}2\qquad\qquad (\omega=e^{i2\pi/7})$$ from which we know that $$\sin \frac{2\pi}7+\sin \frac{4\pi}7-\sin \frac{6\pi}7=\Im (\omega+\omega^2+\omega^4)=\frac{\sqrt7}2$$ This can al...
2015/10/21
[ "https://math.stackexchange.com/questions/1491566", "https://math.stackexchange.com", "https://math.stackexchange.com/users/168053/" ]
In that answer there is the following equality $$\begin{align} \sin\frac{2\pi}7+\sin\frac{4\pi}7-\sin\frac{6\pi}7 &=\Im(\omega^1+\omega^2-\omega^3)\\ &=\Im(\omega^1+\omega^2+\omega^4)\\ &=\Im(S)\\ &=\dfrac{\sqrt{7}}{2}\\ \end{align}.$$ For the real part you have $$\begin{align} -\dfrac{1}{2}&= \Re(S)\\ &=\Re(\omega^1+...
You're starting from the wrong assumption that $-\omega^3=\omega^4$, which is obviously wrong, because it would imply $\omega=-1$. The true fact is that $$ -\sin\frac{6\pi}{7}=\sin\frac{8\pi}{7} $$ but $$ \cos\frac{6\pi}{7}=\cos\frac{8\pi}{7} $$ because $$ \frac{6\pi}{7}+\frac{8\pi}{7}=2\pi $$ and $$ \sin(2\pi-\alpha)...
390,131
> > What are some examples of naturally occurring badly behaved (possibly higher) categories? > > > When working with a specific category like ${\bf Set}$ or ${\bf Cat}$, we usually understand/explain them by lauding structural properties they posess -- ${\bf Set}$ is an autological topos, ${\bf Cat}$ is Cartesian...
2021/04/14
[ "https://mathoverflow.net/questions/390131", "https://mathoverflow.net", "https://mathoverflow.net/users/92164/" ]
The category $Rel$ of sets and relations between them [fails to have finite (co)limits](https://math.stackexchange.com/questions/354779/the-category-set-seems-more-prominent-important-than-the-category-rel-why-is-th/870483#870483). So does the $(2,1)$-category $Span$ of sets and spans between them (the pushout of the ...
The category $\mathbf{Met}$ of metric spaces and [metric maps](https://en.wikipedia.org/wiki/Metric_map) is another example. There are finite limits, but no infinite products. Countable products exist at least when we use continuous maps as the morphisms instead. $\mathbf{Met}$ has no binary coproducts, and this can be...
3,458,023
I'm trying to write a GUI program grabbing specific contents from a webpage. The idea is when I hit the start button, the program should start extracting information from that page. And I want to add some code to check if connected to the Internet. If not, continue trying until connected. So I just added the followin...
2010/08/11
[ "https://Stackoverflow.com/questions/3458023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/402197/" ]
When you have an event based program, the overall flow of the program is this: ``` while the-program-is-running: wait-for-an-event service-the-event exit ``` Now, lets see what happens when service-the-event calls something with a (potentially) infinite loop: ``` while the-program-is-running: wait-for-...
Instead of `time.sleep(10)` you can call [wxApp::Yield](http://docs.wxwidgets.org/stable/wx_wxapp.html#wxappyield) and `time.sleep(1)` ten times. Beware of reentrancy problems (e.g. pressing the start button again.). The start button could be dimmed while in the event handler. But [Bryan Oakley's solution](https://st...
91,320
What other ways are there to save a human for a very long time. I know only about cryostasis. Let's say we have a spaceship traveling several hundred light years to a distant galaxy.
2017/09/08
[ "https://worldbuilding.stackexchange.com/questions/91320", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/32349/" ]
If you really want to go to a *distant* galaxy you should first realize the *nearest* (Andromeda) is about 2.5 *million* light years. If You really want to travel that far (and get there before your ship falls apart) I think the best is "just" to exploit Lorentz time contraction. Have your spaceship to travel very ne...
Cryostatis Pro: we (of september 14 of 2017) are doing this every single day, at least in first world countries. So the techonolgy already exists. Con: the frozen water expands bursting cells open thus killing the thing you want to perserve. May i introduce you to the Medical Nanobots. **tiny little robots,** nanobot...
18,372,027
I have two stored procedures which gives Daily swipe data and another gives Temporary Swipe details. I got an requirement to populate gridview, Based on the date the temporary card details must get displayed in between Daily swipe data. Please anyone give me idea how to populate two result sets into gridview Iam using...
2013/08/22
[ "https://Stackoverflow.com/questions/18372027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2595238/" ]
Lets assume we consume this ResultSet which has two DataTables "Agent" and "RealEstateProperty". The task is to display, what properties belongs to which agent, in a GridView. ![enter image description here](https://i.stack.imgur.com/FfVzS.png) There are different ways to accomplish this task- **Method 1: Bind DataT...
``` 1.Call your Second stored procedure within first stored procedure. 2.Pass your outcome to dataset. 3.From dataset u can fetch it using ds.table[0],ds.table[1],etc.. ```
36,933,755
* A Activity is SingleTask * B Activity and C Activity is Standard, A -> B -> C, Then press Home, re-press the application icon, Why B,C destroy? Why B destroyed firstly, C destroyed later? ``` <activity android:name=".Main1Activity" android:launchMode="singleTask"> <intent-filter> <action android...
2016/04/29
[ "https://Stackoverflow.com/questions/36933755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6270615/" ]
in short "singleTask" activity allows other activities to be a part of its task...so when ever you re-open the app again, the Activity a is shown because as of now activity b,c are part of its task... the activity b is deleted first because, it started before the Activity c.
Check your manifest file and ensure that Activity B and C are not set to "noHistory=true." If they are, remove that line and it should fix your issue. Activity B and C should not be destroyed simply because Activity A is SingleTask. Having a SingleTask activity simply means it has to be at the bottom of the activity ...
4,054,254
I have written a program which sends more than 15 queries to Google in each iteration, total iterations is about 50. For testing I have to run this program several times. However, by doing that, after several times, Google blocks me. is there any ways so I can fool google maybe by adding delays between each iteration? ...
2010/10/29
[ "https://Stackoverflow.com/questions/4054254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/313245/" ]
Best to use: ``` from numpy import random from time import sleep sleeptime = random.uniform(2, 4) print("sleeping for:", sleeptime, "seconds") sleep(sleeptime) print("sleeping is over") ``` as a start and slowly decreasy range to see what works best (fastest).
Also you can try to use few proxy servers for prevent ban by IP adress. urllib support proxies by special constructor parameter, httplib can use proxy too
20,778,991
I am having a `table view` with custom cells. Each custom cell is having `scroll view` in which images are added in series. Images are of quite large size. Other than images, some other datas are also present in each cell. I am saving the images to `db` before reloading table view.The issue is as the tableview `reloadd...
2013/12/26
[ "https://Stackoverflow.com/questions/20778991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1093483/" ]
How about using [`re.split`](http://docs.python.org/2/library/re.html#re.split)? ``` 'London, ENG, United Kingdom or Melbourne, VIC, Australia or Palo Alto, CA USA' >>> list(map(str.strip, re.split(',|or', x))) ['London', 'ENG', 'United Kingdom', 'Melbourne', 'VIC', 'Australia', 'Palo Alto', 'CA USA'] >>> list(map(str...
Okay, i found my answer myself, its fairly simple: ``` r'\w+, \w+, \w+' ``` But to respect @falsetru's efforts i'll accept his answer.. Thankyou @falsetru
36,686,392
I have a game that when I land on a place, which is a coordinate,it checks it and replaces that coordinate with an object sort out thing. I'm struggling to do it please can any of you help me. Please can any of you help me.THANKS :) t
2016/04/18
[ "https://Stackoverflow.com/questions/36686392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6187907/" ]
To solve this issue: I searched for libmysqlclient.so.20 (the version number at the end may differ) ``` find /. -name "libmysqlclient.so.20" ``` My ouput was ``` /./usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 ``` I then copied that file into the root directory of my package ``` cp /usr/lib/x86_64-linux-gnu/lib...
How did you install MySQLdb? <http://mysql-python.sourceforge.net/FAQ.html> says: > > ImportError: No module named \_mysql > If you see this, it's likely you did some wrong when installing MySQLdb; re-read (or read) README. \_mysql is the low-level C module that interfaces with the MySQL client library. > > > In...
2,971
When going to Latvia, I like to eat some small snacks in the bakeries called [Martina Bekereja](http://www.bekereja.lv/). I think there are several of them in Latvia, or even in the whole Baltic. Because I really like them, I would like to have a map with all of them. I tried to find them on the homepage, but unfortuna...
2011/10/23
[ "https://travel.stackexchange.com/questions/2971", "https://travel.stackexchange.com", "https://travel.stackexchange.com/users/693/" ]
I tried translating the site with Bing Translate, but because it's Flash it won't translate. However I did the menu words one at a time, and Vietas means Site - locations, I think. That page just has a number of words with a number after each. If you click on a word, you get a phone number and what are obviously openin...
I don't speak Latvian, but my girlfriend is Latvian. I'll make her an account later, but for now, here's what she says: If you go to the "Vietas" tab it gives you a list of street names and numbers of their sites. All the sites are located in Rīga. So, for example, Marijas 19 means : Marijas Street 19, Rīga. Copy-past...
114,231
Ever since I updated to iOS 7 in June, I have been having issues using the camera on my phone in apps other than the default Camera app. Regardless of settings, using my camera in any non-Apple app (such as Instagram or Tumblr) will result in that particular app crashing immediately. I have tried everything to remedy t...
2013/12/17
[ "https://apple.stackexchange.com/questions/114231", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/27349/" ]
* With the system I've updated, will the buyer be asked for his apple ID and will that replace mine? When they first use the system and create a User ID etc, they will be asked for an Apple ID (which is not entirely mandatory) and it will have no knowledge of you as the previous owner, nor will it care what ID is used...
I would say first restore it and then sell it. You dont need to give you apple id. Also for updates, you don't need Apple id. If nobody buy it, I know a website that buy these MacBooks. I sold mine with damaged logic board for $220. You could try it. Here is the site address <http://www.computerstar.ca/sell-macbook-ma...
486,178
I already knew the basic meaning of pipeline indicating a series of tubes for transporting gas, oil, or water. But I found the word 'pipeline' written with a different nuance especially when aritcles describe tech companies' strategy. Here are the examples. > > 1. Blizzard: we have the strongest multi-year **pipelin...
2019/02/19
[ "https://english.stackexchange.com/questions/486178", "https://english.stackexchange.com", "https://english.stackexchange.com/users/291380/" ]
One suggestion that means a person who "*adapts easily*" is one who is "**flexible**". <https://www.thefreedictionary.com/flexible>
Without knowing more about your mom and her situation, it's only a guess as to what will fit here: ***Easygoing*** - A person who is usually relaxed and in good humor - even when those around them may not be. Someone who "rolls with the punches". <https://en.oxforddictionaries.com/definition/easy-going> ***Resourcef...
44,964,363
i am reading excel file using apache poi 3.16 here is my code ``` try { String excelPath = "C:\\Users\\wecme\\Desktop\\AccountStatement.xls"; FileInputStream fileInputStream = new FileInputStream(new File(excelPath)); // Create Workbook instance holding .xls file ...
2017/07/07
[ "https://Stackoverflow.com/questions/44964363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7791891/" ]
You're creating a `XSSFWorkbook` which is only suitable for working on xlsx files, i.e. the new xml based office format. Your file extension (xls) however suggests that this is the older Microsoft Office (2003 I guess) format. In order to fix the error you need to convert the file to xlsx format or you need to work wit...
According to the code where the Exception is thrown (see: <https://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java?view=markup#l286>) And also the name of the package (openxml4j) it is required that the files are in an openxml compatible format. (i.e. xlsx) In your case the...
10,355,767
SQLalchemy gives me the following warning when I use a Numeric column with an SQLite database engine. > > SAWarning: Dialect sqlite+pysqlite does *not* support Decimal objects natively > > > I'm trying to figure out the best way to have `pkgPrice = Column(Numeric(12,2))` in SQLalchemy while still using SQLite. T...
2012/04/27
[ "https://Stackoverflow.com/questions/10355767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1098059/" ]
Since it looks like you're using decimals for currency values, I'd suggest that you do the safe thing and store the value of currency in its lowest denomination, e.g. 1610 cents instead of 16.10 dollars. Then you can just use an Integer column type. It might not be the answer you were expecting, but it solves your pro...
Here is a solution inspired by both @van and @JosefAssad. ``` class SqliteDecimal(TypeDecorator): # This TypeDecorator use Sqlalchemy Integer as impl. It converts Decimals # from Python to Integers which is later stored in Sqlite database. impl = Integer def __init__(self, scale): # It takes a...
88,093
I'm leaving my current position as a Software Developer in two months, to get started with my bachelors degree, but my Team Leader is not giving me any work to do. I also had a talk with him, about a week ago, where he gave me some tasks, but I already finished those (and told him that). He also said he would figure so...
2017/03/29
[ "https://workplace.stackexchange.com/questions/88093", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/61565/" ]
**Your team lead may be making the sensible call in giving you nothing to do.** I have been in your team lead's position, and sometimes your doing nothing may be the most productive thing for the team. Starting to work in an area you are not familiar with is likely to need some input from other team members in terms o...
> > I did ask for work, but like I said, there is nothing to do for me, which wouldn't need schooling. > > > This point is realy bothering me , have you thought about the fact your lead knows his job , and asked you to "school" some stuff because you don't yet have the required level to help on the next tasks ? I ...
27,771,324
I am using googles official oauth2client.client to access the google plus api. I have a refresh token (that does not expire) stored in a database, and need to recreate the temporary "Credentials" (access token) from that. But I could not find a way to do this with to official library supplied by google. So I hacked a...
2015/01/04
[ "https://Stackoverflow.com/questions/27771324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153574/" ]
I use: [oauth2client.client.GoogleCredentials](http://oauth2client.readthedocs.io/en/latest/source/oauth2client.client.html#oauth2client.client.GoogleCredentials) ``` cred = oauth2client.client.GoogleCredentials(access_token,client_id,client_secret, refresh_token,expires_a...
I recommend this method. ``` from oauth2client import client, GOOGLE_TOKEN_URI CLIENT_ID = "client_id" CLIENT_SECRET = "client_secret" REFRESH_TOKEN = "refresh_token" credentials = client.OAuth2Credentials( access_token = None, client_id = CLIENT_ID, client_secret = CLIENT_SECRET, refresh_token = ...
66,167,878
After updating my flutter project when I was going to run the application in the android studio, I got the following error. ``` e: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\fluttertoast-7.1.5\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (16, 16): Rede...
2021/02/12
[ "https://Stackoverflow.com/questions/66167878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10595169/" ]
This was happened due to a pub cache conflict. The problem was fixed after executing the following command in the terminal. 1. dart pub cache repair 2. dart pub get 3. dart pub upgrade
I got the same error. Tried updating `compileSdkVersion`. Didn't work for me. This solved my problem. 1. pubspec.yaml -->> pub upgrade 2. Change `fluttertoast` version to latest 3. Pub get 4. Run...
25,443,258
I want to calculate the difference between a start time and an end time. In `HH:mm` format. I receive a negative value when, for example, the start time is `22.00` and the end time is `1.00` the next day. How do I let the program know the end time is on the next day? My script: ``` public void setBeginTijd() { ...
2014/08/22
[ "https://Stackoverflow.com/questions/25443258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3374335/" ]
As already mentioned by some people, it is important to also know day, month and year of each event to calculate periods for events that are not on the same day. I modified your method the way I think it could help you: ``` public void setBeginTijd() { String dateStart = "22.08.2014 22:00"; String dat...
Here is the correct math for time difference in hours & minutes. Stripping of the decimal fraction is happening automatically when you operate on int/long values. ``` long diff = d2.getTime() - d1.getTime(); long diffHours = diff / 1000 / 60 / 60; long diffMinutes = diff / 1000 / 60 - diffHours * 60; ```
8,301,490
``` when i try to run my Application it gives me following error: Compilation error The file /app/models/setting.java could not be compiled. Error raised is : The type Setting is already defined ``` * I do have only one file "Setting.java", which is in the models directory * the file is named "Setting.java" and not ...
2011/11/28
[ "https://Stackoverflow.com/questions/8301490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070022/" ]
This error happens when you rename the class file that you try to compile. Simply re run the play frame work after you refract the class name. This will fix the issue.
Did you have a `settings.java` and replaced it with `Settings.java`? Anyway, try `play clean`. If that doesn't work, check very carefully that you don't have any problematic invisible characters in your file.
64,666,682
so my problem is that I'm trying to write a program that uses a switch case to tell a function which case to do. I tried to include an or statement into the switch cases so that I could have a range of values for each case but it seems to be presenting me with an error. Is there a fix to this problem using the switch c...
2020/11/03
[ "https://Stackoverflow.com/questions/64666682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14567401/" ]
``` case healthratio>0 || healthratio<=10 ``` This is not valid in standard C, some compilers allows the use of [case ranges](https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html), i.e. `gcc` and `clang`: ``` case 0 ... 10: printf("%d.\n",healthratio); break; ``` But if you can not use them then you are for...
According to the C Standard (6.8.4.2 The switch statement) > > 3 **The expression of each case label shall be an integer constant > expression** and no two of the case constant expressions in the same > switch statement shall have the same value after conversion. There may > be at most one default label in a switch s...
67,540,057
My bootstrap model is not hidden by default. I want it to show up only when I click a link. I am a novice in web development. **tst.html** ``` <!DOCTYPE html> <html lang="english"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=de...
2021/05/14
[ "https://Stackoverflow.com/questions/67540057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11483786/" ]
Just a couple of issues you class must be `modal fade` not `modal-fade` and your target attribute modal `data-toggle` not `data-toggel` ```html <!DOCTYPE html> <html lang="english"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=dev...
This is working now, you might be missing some right piece of code. Please check below code ```html <!DOCTYPE html> <html lang="english"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Testing</t...
48,816,636
I am little bit new to the programming. I am learning Python, version 3.6. ``` print("1.+ \n2.-\n3.*\n4./") choice = int(input()) if choice == 1: sum = 0 print("How many numbers you want to sum?") numb = int(input()) for i in range(numb): a = int(input(str(i+1)+". number ")) sum+=a ...
2018/02/15
[ "https://Stackoverflow.com/questions/48816636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8881970/" ]
You can also use the \*args or \*kargs in order to subtract more than two numbers. If you define \*args keyword in a function then it will help you to take as many variables you want.
There are two methods to solve this: **Method-1** Using the logic for subtraction a-b-c-… = ((a-b)-c)-… ``` def subt1(*numbers): # defining a function subt1 and using a non-keyword argument *numbers so that variable number of arguments can be provided by user. All these arguments will be stored as a tuple. ...
61,307,490
I am considering using the Singelton Design Pattern and create a Singelton of my Main class. While I was searching, I found some comments that this is rather bad programming practice, especially since the declaration of a static method does not do justice to object-oriented programming. Do you have any suggestions for ...
2020/04/19
[ "https://Stackoverflow.com/questions/61307490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11096084/" ]
budget is a group of limits to certain values that affect site performance Open angular.json file and find budgets keyword and increase value ``` "budgets": [ { "type": "initial", "maximumWarning": "4mb", <=== "maximumError": "5mb" }, { "type": "anyComponentStyle", "maximumWarni...
Even though you can just bump up your limits, it's probably not what you want to do. The limits are there for a reason. You should try to avoid exceeding them in the first place if possible. For me, the problem was I was importing my theme file (which was quite large) into my components' SCSS files. ``` @import "src/...
43,104,209
I am creating a google map that is populated with markers based upon information from my database. I have followed the [tutorial](https://developers.google.com/maps/documentation/javascript/mysql-to-maps#checking-that-xml-output-works) provided from Google in this first step. The map works fine, however since some of ...
2017/03/29
[ "https://Stackoverflow.com/questions/43104209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7788248/" ]
Use optional binding to ensure the values are non-nil strings and that they can be converted to `Int`. ``` if let str1 = data[0]["total1"] as? String, let str2 = data[0]["total2"] as? String { if let int1 = Int(str1), let int2 = Int(str2) { let sum = int1 + int2 } else { // One or more of the t...
Since the underlying objects are `NSString`, you can also do: ``` if let num1 = (data[0]["total1"] as? NSString)?.intValue, let num2 = (data[0]["total2"] as? NSString)?.intValue { let sum = num1 + num2 } ``` As @rmaddy pointed out in the comments, if a value is not an integer (such as `"hello"`), it will conv...
16,325,271
Using LINQ, can I write a statement that will return an IEnumerable of the indexes of items. Very simple instance: ``` {1,2,4,5,3} ``` would just return ``` {0,1,2,3,4} ``` and ``` {1,2,4,5,3}.Where(num => num == 4) ``` would return ``` {2} ``` It isn't exact code, but it should get the idea across.
2013/05/01
[ "https://Stackoverflow.com/questions/16325271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1116831/" ]
``` IEnumerable<int> seq = new[] { 1, 2, 4, 5, 3 }; // The indexes of all elements. var indexes = Enumerable.Range(0, seq.Count()); // The index of the left-most element with value 4. // NOTE: Will return seq.Count() if the element doesn't exist. var index = seq.TakeWhile(x => x != 4).Count(); // The indexes of all ...
This should do it. Not sure how efficient it is though.. ``` List<int> list = new List<int>() { 1, 2, 3, 4, 5 }; var indexes = list.Select(item => list.IndexOf(item)); var index = list.Where(item => item == 4).Select(item => list.IndexOf(item)); ```
8,901
Has anyone else noticed the content of this post no longer shows? <https://civicrm.org/blogs/colemanw/create-your-own-tokens-fun-and-profit> I'm trying to write a token to use the contribution note as a smarty variable but would like to review the tutorial. ..
2016/01/15
[ "https://civicrm.stackexchange.com/questions/8901", "https://civicrm.stackexchange.com", "https://civicrm.stackexchange.com/users/73/" ]
Andrew West's comment seems to be correct. There are two different things happening here - or three, depending on how you look at it. The most important is "Permission Denied". I just visited your site, and confirmed you're running Drupal as your website software. Go to this page: www.mcuw.org/admin/people/permissions...
You need to contact your hosting company to resolve. United Way has vendors (OneEach Technologies, etc.) that provide website/hosting/civicrm packages to many UW affiliates that manage the backend configuration of your website. You do not have the permissions to make the changes needed to fix this. Your hosting compa...
73,298,614
I have two 2D arrays like these: ``` mix = [[1,'Blue'],[2,'Black'],[3,'Black'],[4,'Red']] possibilities = [[1,'Black'],[1,'Red'],[1,'Blue'],[1,'Yellow'], [2,'Green'],[2,'Black'], [3,'Black'],[3,'Pink'], [4,'White'],[4,'Blue'],[4,'Yellow'], [5,'Purple'],[5,'Blue'] ] ``` I ...
2022/08/09
[ "https://Stackoverflow.com/questions/73298614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19641211/" ]
There are a number of ways of solving this. The simple way is to loop through the lists, but that's not very pythonic. You can remove the inner loop using a containment check: ``` bad_guess = [] correct_guess = [] for item in mix: if item in possibilities: correct_guess.append(item) else: bad_g...
``` mix = {1:'Blue' , 2:'Black' , 3:'Black' , 4:'Red'} possibilities = [[1,'Black'],[1,'Red'],[1,'Blue'],[1,'Yellow'], [2,'Green'],[2,'Black'], [3,'Black'],[3,'Pink'], [4,'White'],[4,'Blue'],[4,'Yellow'], [5,'Purple'],[5,'Blue'] ] for poss in possibilities: if (mix[poss[0]] = poss[1]) & (p...
15,601
I have a selection of paths in illustrator (cs6). I want to select all the paths and free transform them to something like a 3rd of the size. The problem is when I shrink them down, the stroke on the paths stays the same. So originally some had 1pt and 2pt stroke, bit when I free transform all the paths to a 3rd of th...
2013/02/02
[ "https://graphicdesign.stackexchange.com/questions/15601", "https://graphicdesign.stackexchange.com", "https://graphicdesign.stackexchange.com/users/9693/" ]
Using the Scale tool, tick the check box which says "Scale strokes and effects" before scaling. That reduces your strokes proportionally.
Another way to get there is under the General Preferences settings: ![General Preferences settings](https://i.stack.imgur.com/ipe4E.png)
500,144
Hello and how you doing today? I just came across a problem which need to use Stokes theorem. The problems says: Evaluate the surface integral $$ \int\_{S}\nabla\times\vec{F}\cdot{\rm d}\vec{S} $$ where F(x,y,z)=$(y^2)i$ + $(2xy)j$+$(xz^2)k$ and S is the surface of the paraboloid $z= x^2+y^2$ bounded by the planes ...
2013/09/21
[ "https://math.stackexchange.com/questions/500144", "https://math.stackexchange.com", "https://math.stackexchange.com/users/39213/" ]
Set $m=(a+b+c)/3$, $A=a-m$, $B=b-m$, $C=c-m$ and $x=y+m$. Then your equation becomes $$ (y-A)^3 + (y-B)^3 + (y-C)^3 = 0 $$ and, since $A+B+C=0$, your expansion applies to give $$ y^3+(A^2+B^2+C^2)-\frac{A^3+B^3+C^3}{3}=0 $$ which is a suppressed cubic, whose discriminant is $$ \frac{1}{4}\biggl(-\frac{A^3+B^3+C^3}{3}\b...
Let's substitute the variable: $x=y+\frac{(a+b+c)}{3}$ The equation will now look like $$3y^3+(2a^2-2ab-2ac+2b^2-2bc+2c^2)y+\frac{(a+b-2c)(a-3b+c)(b-2a+c)}{9}=0$$ Now we apply Cardano's method. $$Q=\left(\frac{2a^2-2ab-2ac+2b^2-2bc+2c^2}{3}\right)^3+\left(\frac{\frac{(a+b-2c)(a-3b+c)(b-2a+c)}{9}}{2}\right)^2=\frac...
12,602,759
I have a persistent dictionary (string -> string map) that I write to a NAND filesystem as a log file. My binary format is: ``` 1 byte - key size <key size> bytes - key without the terminating nul-character 2 bytes - value size and flags <value size> bytes - value without terminating nul-character ``` Usually, I wri...
2012/09/26
[ "https://Stackoverflow.com/questions/12602759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/131326/" ]
Being PHP loosely typed, it can't do like `{$this -> callback}()`; you have to store it in a temp variable or to use `call_user_func()` either. EDIT - consider something like this: ``` class Lambdas { protected $double; protected $triple; public function __construct($double, $triple) { $t...
Dirty and dangerous, but you might succeed using eval.. ``` class foo { private $call_back_1 = null; private $call_back_2 = null; function __construct($func1, $func2) { $this->call_back_1 = func1; $this->call_back_2 = func2; } function provokeCallBacks() { eval($this->call_back_1); ...
3,189,938
I'm trying to write a custom SQL query that will create a list of the most recent Posts AND comments and I'm having trouble visualizing how i can do this. I can pull the latest comments by date DESC and i can pull the latest posts by date DESC but how do I make a feed / query to show them both? Here is my comment SQ...
2010/07/06
[ "https://Stackoverflow.com/questions/3189938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/157503/" ]
To get a list based solely on the most recent timestamp from two tables, you need to use a UNION: ``` SELECT wc.comment_date AS dt FROM WP_COMMENTS wc UNION ALL SELECT wp.post_date AS dt FROM WP_POSTS wp ORDER BY dt ``` ...where `dt` is the column alias for the column that holds the date value for records in eit...
No special mySql necessary, just use the [query\_posts](http://codex.wordpress.org/Function_Reference/query_posts) loop and the [get\_comments](http://codex.wordpress.org/Function_Reference/get_comments) function in the loop. ``` <?php query_posts('posts_per_page=10'); while (have_posts()) : the_post(); ?> <div>...
31,674,182
I am trying to change the width and height of a DIV dynamically using variables in javascript. My code below is not working for me. ``` div_canvas.setAttribute('style', "width: '+w_resized+'px"); div_canvas.setAttribute('style', "height: '+h_resized+'px"); ``` Where w\_resized and h\_resized are variables.
2015/07/28
[ "https://Stackoverflow.com/questions/31674182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4650787/" ]
Using setAttribute will override the previously provided values.... you can use the style property like ``` div_canvas.style.width = w_resized + 'px'; div_canvas.style.height = h_resized + 'px'; ```
Return the width property: ``` object.style.width ``` Set the width property: ``` object.style.width="auto|length|%|initial|inherit" ``` same for height
63,157
Looking at the `algorithm` tag in SO, I noticed that there are 6452 questions reported: ![alt text](https://i.stack.imgur.com/G9x9h.png) Yet going to the tag info page, at the same time it found 6455 of them ![alt text](https://i.stack.imgur.com/HsCbu.png) Earlier this morning this was true for `Delphi`: 5799 again...
2010/09/02
[ "https://meta.stackexchange.com/questions/63157", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/-1/" ]
This may happen from time to time. We have lots of caching that may kick at different spots. At the moment the counts are in-sync for the `algorithm` tag, so this was due to caching.
These numbers are cached, which explain why they're different. However, I'm surprised that they're not relying on the same cache, so it's still a bug.
28
I assume English.SE is not the right place to ask how to nicely translate a Chinese phrase into English, but is Chinese.SE the right place?
2011/12/14
[ "https://chinese.meta.stackexchange.com/questions/28", "https://chinese.meta.stackexchange.com", "https://chinese.meta.stackexchange.com/users/58/" ]
I would say its a valid question if its a phrase that could be quite ambiguous or difficult to translate. Like, if it is a translation that can benefit the community beyond the equivalent of an online translator
I like translating. I get so much help from the R programming site and I would like to contribute where I can. I was quite active in the Chinese Baidu Zhidao site as an English to Chinese translator for a while, and I also translated a bit in the Yahoo Answers US site.
10,031,455
I sometimes see Perl code like this: ``` my ( $variable ) = blah.... ``` What is the point of putting parentheses around a single variable? I thought parentheses were only used when declaring multiple variables, like: ``` my ( $var1, $var2, $var3 ) = blah... ```
2012/04/05
[ "https://Stackoverflow.com/questions/10031455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/511609/" ]
The parentheses create a list context which affects how the right hand side of the assignment is evaluated. Compare ``` my $x = grep { /s/ } qw(apples bananas cherries); print $x; ``` with ``` my ($x) = grep { /s/ } qw(apples bananas cherries); print $x; ``` You will often use this construction when [you just w...
You are confusing two different things. First off, when using `my` to declare several variables, you need to use parentheses: ``` my $foo, $bar; ``` Does not work, as it is considered to be two different statements: ``` my $foo; $bar; ``` So you need parentheses to group together the argument into an argument l...
453,922
So I want to do some logging and therefor, want to put a date in front of a bash script's output. The problem is that is has multiple lines of output. I am able to only put the date before the whole output. But then I have a line without a date in the logs. Of course I can assume the date from the line above is the sam...
2012/07/26
[ "https://superuser.com/questions/453922", "https://superuser.com", "https://superuser.com/users/148175/" ]
According to a [similar question on Stack Overflow](https://stackoverflow.com/questions/21564/is-there-a-unix-utility-to-prepend-timestamps-to-lines-of-text), there are 2 great options. awk ([Answer](https://stackoverflow.com/questions/21564/is-there-a-unix-utility-to-prepend-timestamps-to-lines-of-text)) ------------...
You can use `awk` ``` ./script.sh | awk '{ print d,$1}' "d=$(date "+%F %T")" ``` `awk` takes an input stream and modifies it's output. This script is saying "print d followed by the original output", then then populates `d` with the date.
49,810,906
Here is my code below ``` <td v-for="config in configs" v-if="config"> <input type="number" v-model="config.score" v-on:keyup="computeTestScores(allocation, $event)"> </td> <td><span class="subtotal"></span></td>` ``` how do i compute the ***subtotal***? Secondly, if the values of any input changes, i want to ...
2018/04/13
[ "https://Stackoverflow.com/questions/49810906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5102083/" ]
You should not try to compute the sum with v-for. V-for is meant for presentation. Instead add a computed value that calculates the subtotal. Inside the computed you should loop through the array, calculate the sum and return it. The computed property also calculates the new value automatically if any of the inputs ch...
You may sum the values of your array with the `reduce` function. The total will update automatically if any score changes. ``` <td><span class="subtotal">{{ configs.reduce((a, c) => a + parseInt(c.score), 0) }}</span></td> ```
6,257,628
I want to create web pages with dynamic content. I have an HTML page, and I want to call a lua script from it 1. How do I invoke the lua script? `<script type="text/application" >`? `<script type="text/lua" >`? 2. Retrieve data from it? Can I do something like: ```js int xx = 0; <script type=text/lua> xx = 123...
2011/06/06
[ "https://Stackoverflow.com/questions/6257628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/86184/" ]
Most of the CGI and Lua I have played with involve generating the web page and inserting the dynamic bits, rather than calling a script from a web page. So more like option C from your original question. Any HTML 4 or 5 elements you want to have could easily be added into the generated web page. Here are some places y...
If you want to run a script from a browser, consider using javascript instead. It is very similar to Lua, and unlike Lua it's interpreted by most browsers.
38,539,417
I currently have an Angular Directive that validates a password and confirm password field as matching. It works to a point, it does throw an error when the passwords do not match. However, it doesn't throw the error until you have entered data in both fields. How can I make it so the error for mismatched passwords is ...
2016/07/23
[ "https://Stackoverflow.com/questions/38539417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5831695/" ]
This is what worked for me (ugly and hackish): HTML: ``` <h1>Password Verification</h1> <form name="pw" ng-controller="pw"> <p> <label for="password">New Password <input type="password" name="user_password" ng-model="user_password" ng-required="confirm_password && !user-password" password-verify="confirm_paswor...
While the above answers are correct, there is a very simple solution for this situation: You can use a `ng-class` directive to set a class different from angularjs built-in class (`ng-invalid`) and add a simple style for it in your css. DO NOT FORGET to add `!important` to your style because angularjs overrides it ;)
2,732,373
In propositional logic, how should the sentence "neither A nor B" be converted into a Well Formed Formula? Is it $\sim(A \lor B)$ or should it be $\sim(A \land B)$? Can it be interrupted both ways? I need a little help understanding this.
2018/04/11
[ "https://math.stackexchange.com/questions/2732373", "https://math.stackexchange.com", "https://math.stackexchange.com/users/551328/" ]
Let $G$ be the Galois group $G=Gal(K/\Bbb{Q})$. We know that elements of $G$ permute the roots $\{\pm\alpha,\pm\beta\}$. Furthermore, 1) because $K=\Bbb{Q}(\alpha,\beta)$ knowing the images of $\alpha$ and $\beta$ determines an automorphism uniquely, 2) because $f(x)$ is known to be irreducible the permutation action i...
Note, $G = Z\_4$ iff $b(a^2-4b)$ is a square, but $b(a^2 -4b) = (b \delta)^2$ for $\delta = \alpha/\beta - \beta/\alpha$.
132,981
In my story, one of the main characters (Joe) has been born with a somewhat superpower: Any person near him will have elevated neurotransmitter levels. If their brain is releasing happy neurotransmitters, then they will feel even more happy when in Joe's vicinity. If they are sad, they will verge on depression when the...
2018/12/15
[ "https://worldbuilding.stackexchange.com/questions/132981", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/53812/" ]
A rather short-time effect would be that people would not be able to function anymore. Neurotransmitters don't just dissappear the second we stop feeling happy or sad. They're chemicals that still course through the body, especially if a great amount of them was set free. More importantly, our bodies are designed to r...
> > If they are friends of Joe, will they be addicted to his presence? > > > This is complicated. The first thing you have to take into account is that the happy people around Joe will have an unbalanced amount of some neurotransmitters related to the feeling of content, joy or whatever. I am not a doctor, but to...
347,615
I have an application which takes an integer as input and based on the input calls static methods of different classes. Every time a new number is added, we need to add another case and call a different static method of a different class. There are now 50 cases in the switch and every time I need to add another case, I...
2017/04/23
[ "https://softwareengineering.stackexchange.com/questions/347615", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/188637/" ]
A map of strategy objects alone, which is initialized in some function of your code, where you have several lines of code looking like ``` myMap.Add(1,new Strategy1()); myMap.Add(2,new Strategy2()); myMap.Add(3,new Strategy3()); ``` requires you and your colleagues to implement the functions/strategie...
I am strongly in favor of the strategy outlined in [the answer by @DocBrown](https://softwareengineering.stackexchange.com/a/347616/116460). I am going to suggest an improvement to the answer. The calls ``` myMap.Add(1,new Strategy1()); myMap.Add(2,new Strategy2()); myMap.Add(3,new Strategy3()); ``` can be dist...
3,553,779
How do I dismiss the keyboard when a button is pressed?
2010/08/24
[ "https://Stackoverflow.com/questions/3553779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/454665/" ]
you can also use this code on button click event ``` getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); ```
Kotlin: ======= To dismiss the keyboard, call `clearFocus()` on the respective element when the button is clicked. Example: ``` mSearchView.clearFocus() ```
67,290,697
After upgrading Xcode to 12.5 and iOS to 14.5, I can't run the iOS app on a real device nor in the simulator. After running `npm run ios`, I get this message: ``` The following build commands failed: CompileC .../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper-Folly.build/Objects-normal/x...
2021/04/27
[ "https://Stackoverflow.com/questions/67290697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4064710/" ]
There is an open RN issue here: <https://github.com/facebook/react-native/issues/31179> For me commenting out `Flipper` in the `Podfile`, `pod install`, and rebuild worked as a temp solution. ```rb # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should dis...
just comment out the flipper line in a pod and in Xcode also if you are not using it, hope this will fix in future updates. ``` # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. # use_flipper!({ 'Flipper' => '0.79.1'}) # post_install do |installer| # r...