qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
5,727,648
I have a very large list of items (~2 millions) that I want to optimize for access speed. I iterate trough the items using an iterator (++it). Right now the code is implemented using `std:map<std::wstring, STRUCT>`. I wonder if it's worth to change std::map with a `std::deque<std::pair<std::wstring, STRUCT>>`. I ...
2011/04/20
[ "https://Stackoverflow.com/questions/5727648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572586/" ]
If you know in advance the size, then std::Vector is clearly the way to go it your objects aren't too big. ``` std::vector<Object> list; list.reserve(2000000); ``` And then fill it as usual. This is the fastest and least memory consuming approach. However, you need to be able to allocate enought continous memory. B...
Generally, if you're only doing search in this set (no insertions/deletions), you're probably better off using a sorted sequential cointainer, like deque or vector. You can then use simple binary search to find the needed elements. The advantage of using a sequential container is that it is better in terms of memory us...
5,727,648
I have a very large list of items (~2 millions) that I want to optimize for access speed. I iterate trough the items using an iterator (++it). Right now the code is implemented using `std:map<std::wstring, STRUCT>`. I wonder if it's worth to change std::map with a `std::deque<std::pair<std::wstring, STRUCT>>`. I ...
2011/04/20
[ "https://Stackoverflow.com/questions/5727648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572586/" ]
If you know in advance the size, then std::Vector is clearly the way to go it your objects aren't too big. ``` std::vector<Object> list; list.reserve(2000000); ``` And then fill it as usual. This is the fastest and least memory consuming approach. However, you need to be able to allocate enought continous memory. B...
The fastest container to iterate through is usually a `vector`, so if you want to optimize for iteration at the expense of everything else, use that. Overall app performance of course will depend how many times you iterate, and how you construct your data in the first place. For a simple test, once your map has been p...
103,645
One of my customers uses a machine running CentOS 6.4 with Gnome 2.28.2. Whenever he plugs a USB memory stick or external hard drive into the machine he gets an error pop-up that simply states `Unable to mount <filesystem name>. Not Authorized.`. We've tried devices formatted with FAT and EXT4. The only way I've found ...
2013/12/04
[ "https://unix.stackexchange.com/questions/103645", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/53768/" ]
I cannot confirm this will solve your problem, because I don't have a CentOS 6.4 server with X11. However, according to Sombrero Roja's KB: In the desktop environment, udisks system manages the automatic mounts of the device. udisks defines the policy for devices in `/usr/share/polkit-1/actions/org.freedesktop.udisks...
Since we don't have the output of your fdisk -l command, the best we can do is guess at the filesystem name. That being said, the mount command should be something similar to this: ``` mount /dev/sda1 /mnt/ ``` The default behavoir can be changed within the /etc/fstab file. For instance, setting whether the device i...
15,617,845
I have a query like below where table150k has 150k records and table3m has 3m records. On our production servers, we have to run this query for a single record at a time very frequently. This costs a lot of cpu power. ``` select t.id, t1.field1 as f1, t2.field1 as f2, t3.field1 as f3, ..., t12.field1 as f12 from table...
2013/03/25
[ "https://Stackoverflow.com/questions/15617845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
Do you have an index on `table3m(fk)`? That should fix your problem. An alternative formulation is: ``` select t.id, max(case when m.[type] = 1 then field end) as field1, max(case when m.[type] = 2 then field end) as field2, . . . max(case when m.[type] = 12 then field end) as field12 fro...
If the data in the two tables does not change frequently I follow an alternate method to create a caching table(just another table) which just holds the result of the above query.
15,617,845
I have a query like below where table150k has 150k records and table3m has 3m records. On our production servers, we have to run this query for a single record at a time very frequently. This costs a lot of cpu power. ``` select t.id, t1.field1 as f1, t2.field1 as f2, t3.field1 as f3, ..., t12.field1 as f12 from table...
2013/03/25
[ "https://Stackoverflow.com/questions/15617845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
Do you have an index on `table3m(fk)`? That should fix your problem. An alternative formulation is: ``` select t.id, max(case when m.[type] = 1 then field end) as field1, max(case when m.[type] = 2 then field end) as field2, . . . max(case when m.[type] = 12 then field end) as field12 fro...
Try this: ``` select * from table150k t inner join table3m t1 on t1.fk = t.id and t1.[type] in (1,2,3,4,5,6,7,8,9,10,11,12) where t.id = @id ```
15,617,845
I have a query like below where table150k has 150k records and table3m has 3m records. On our production servers, we have to run this query for a single record at a time very frequently. This costs a lot of cpu power. ``` select t.id, t1.field1 as f1, t2.field1 as f2, t3.field1 as f3, ..., t12.field1 as f12 from table...
2013/03/25
[ "https://Stackoverflow.com/questions/15617845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
Do you have an index on `table3m(fk)`? That should fix your problem. An alternative formulation is: ``` select t.id, max(case when m.[type] = 1 then field end) as field1, max(case when m.[type] = 2 then field end) as field2, . . . max(case when m.[type] = 12 then field end) as field12 fro...
``` select t.id, t1.type, t1.field1 from table150k as t inner join table3m as t1 on t1.fk = t.id where t.id = @id and t1.[type] in (1,2,3,4,5,6,7,8,9,10,11,12) ``` This will bring back 12 records(assuming they all exist). The advantage here is speed on the server side, disadvantage is you will have to map each reco...
28,089,708
We are having MySQL MASTER-SLAVE Replication setup and everything is working fine. Currently all load (reads/writes) are going to MASTER server. Our application is having 99% reads and 1% writes. We thought of distributing load (only reads) to both Master and Slave. So we thought of using HAProxy to distribute the lo...
2015/01/22
[ "https://Stackoverflow.com/questions/28089708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/515637/" ]
We have successfully implemented our DB architecture for a very intensive read/write application. We have one MASTER where all read/writes operations take place and 2 SLAVES (A, B) where all the reads take places. Usually, the master-slave replication assumes that reads go on slaves and all other things (reads and writ...
MySQL Proxy has capability to split read/write split. and load balance multiple mysql servers behind it. The read/write split works for the most part expect for some complex statements. > > Disclaimer: MySQL Proxy is currently an Alpha release and should not be used within production environments. > > >
28,089,708
We are having MySQL MASTER-SLAVE Replication setup and everything is working fine. Currently all load (reads/writes) are going to MASTER server. Our application is having 99% reads and 1% writes. We thought of distributing load (only reads) to both Master and Slave. So we thought of using HAProxy to distribute the lo...
2015/01/22
[ "https://Stackoverflow.com/questions/28089708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/515637/" ]
I have implemented the same for my project. I have two DB Server ( DB01, DB02 ) behind the Ha-Proxy (LB01). I hit ha-proxy assuming a DB from my application. in my application I distributed the database queries as read on 3307 and write on 3306 port. in haproxy.cfg (configuration file HAPROXY) two LISTENER as : ``` ...
We have successfully implemented our DB architecture for a very intensive read/write application. We have one MASTER where all read/writes operations take place and 2 SLAVES (A, B) where all the reads take places. Usually, the master-slave replication assumes that reads go on slaves and all other things (reads and writ...
28,089,708
We are having MySQL MASTER-SLAVE Replication setup and everything is working fine. Currently all load (reads/writes) are going to MASTER server. Our application is having 99% reads and 1% writes. We thought of distributing load (only reads) to both Master and Slave. So we thought of using HAProxy to distribute the lo...
2015/01/22
[ "https://Stackoverflow.com/questions/28089708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/515637/" ]
I have implemented the same for my project. I have two DB Server ( DB01, DB02 ) behind the Ha-Proxy (LB01). I hit ha-proxy assuming a DB from my application. in my application I distributed the database queries as read on 3307 and write on 3306 port. in haproxy.cfg (configuration file HAPROXY) two LISTENER as : ``` ...
MySQL Proxy has capability to split read/write split. and load balance multiple mysql servers behind it. The read/write split works for the most part expect for some complex statements. > > Disclaimer: MySQL Proxy is currently an Alpha release and should not be used within production environments. > > >
30,953,443
I got this error when trying install Emacs package automatically. ``` Warning (initialization): An error occurred while loading `/Users/username/.emacs.d/init.el': File error: http://melpa.org/packages/projectile-20150619.800.el, Not found To ensure normal operation, you should investigate and remove the cause of th...
2015/06/20
[ "https://Stackoverflow.com/questions/30953443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975561/" ]
You need to first refresh ELPA package archives by `M-x package-refresh-contents`, because yours are out-of-date so the package manager can't download package for you. You can also install packages from [Package Menu](http://www.gnu.org/software/emacs/manual/html_node/emacs/Package-Menu.html) (entering via `M-x list-p...
And here's my solution: * Open your browser, and enter: <http://melpa.org/> * Search package name: 'projectile' * Then download and extract the package into ~/.emacs.d/elpa
30,953,443
I got this error when trying install Emacs package automatically. ``` Warning (initialization): An error occurred while loading `/Users/username/.emacs.d/init.el': File error: http://melpa.org/packages/projectile-20150619.800.el, Not found To ensure normal operation, you should investigate and remove the cause of th...
2015/06/20
[ "https://Stackoverflow.com/questions/30953443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975561/" ]
And here's my solution: * Open your browser, and enter: <http://melpa.org/> * Search package name: 'projectile' * Then download and extract the package into ~/.emacs.d/elpa
If you use ubuntu you can also just use `apt-get install elpa-projectile` as described in [documentation](https://github.com/bbatsov/projectile).
30,953,443
I got this error when trying install Emacs package automatically. ``` Warning (initialization): An error occurred while loading `/Users/username/.emacs.d/init.el': File error: http://melpa.org/packages/projectile-20150619.800.el, Not found To ensure normal operation, you should investigate and remove the cause of th...
2015/06/20
[ "https://Stackoverflow.com/questions/30953443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975561/" ]
And here's my solution: * Open your browser, and enter: <http://melpa.org/> * Search package name: 'projectile' * Then download and extract the package into ~/.emacs.d/elpa
One reason this may be happening is that you may be trying to set up the package in your emacs.el file before setting up the melpa connection, so your package list is much smaller. Try disabling it there and refreshing the package list to see if that helps.
30,953,443
I got this error when trying install Emacs package automatically. ``` Warning (initialization): An error occurred while loading `/Users/username/.emacs.d/init.el': File error: http://melpa.org/packages/projectile-20150619.800.el, Not found To ensure normal operation, you should investigate and remove the cause of th...
2015/06/20
[ "https://Stackoverflow.com/questions/30953443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975561/" ]
You need to first refresh ELPA package archives by `M-x package-refresh-contents`, because yours are out-of-date so the package manager can't download package for you. You can also install packages from [Package Menu](http://www.gnu.org/software/emacs/manual/html_node/emacs/Package-Menu.html) (entering via `M-x list-p...
If you use ubuntu you can also just use `apt-get install elpa-projectile` as described in [documentation](https://github.com/bbatsov/projectile).
30,953,443
I got this error when trying install Emacs package automatically. ``` Warning (initialization): An error occurred while loading `/Users/username/.emacs.d/init.el': File error: http://melpa.org/packages/projectile-20150619.800.el, Not found To ensure normal operation, you should investigate and remove the cause of th...
2015/06/20
[ "https://Stackoverflow.com/questions/30953443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975561/" ]
You need to first refresh ELPA package archives by `M-x package-refresh-contents`, because yours are out-of-date so the package manager can't download package for you. You can also install packages from [Package Menu](http://www.gnu.org/software/emacs/manual/html_node/emacs/Package-Menu.html) (entering via `M-x list-p...
One reason this may be happening is that you may be trying to set up the package in your emacs.el file before setting up the melpa connection, so your package list is much smaller. Try disabling it there and refreshing the package list to see if that helps.
30,953,443
I got this error when trying install Emacs package automatically. ``` Warning (initialization): An error occurred while loading `/Users/username/.emacs.d/init.el': File error: http://melpa.org/packages/projectile-20150619.800.el, Not found To ensure normal operation, you should investigate and remove the cause of th...
2015/06/20
[ "https://Stackoverflow.com/questions/30953443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975561/" ]
If you use ubuntu you can also just use `apt-get install elpa-projectile` as described in [documentation](https://github.com/bbatsov/projectile).
One reason this may be happening is that you may be trying to set up the package in your emacs.el file before setting up the melpa connection, so your package list is much smaller. Try disabling it there and refreshing the package list to see if that helps.
17,257,629
Are there any techniques to cause a UIWebView to redraw itself? I've tried `setNeedsDisplay` and `setNeedsLayout` on the UIWebView and its UIScrollView, but neither have worked.
2013/06/23
[ "https://Stackoverflow.com/questions/17257629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/183471/" ]
Literally found the answer right after asking. The key was to tell the subviews of `UIWebView`'s `scrollView` to redraw themselves - particularly the `UIWebBrowserView`. ``` - (void) forceRedrawInWebView:(UIWebView*)webView { NSArray *views = webView.scrollView.subviews; for(int i = 0; i<views.count; i++){ ...
This save my life: ``` self.wkWebView.evaluateJavaScript("window.scrollBy(1, 1);window.scrollBy(-1, -1);", completionHandler: nil) ``` Add this line on webview did load delegate event or wkwebview did finish navigation Thanks MAN!!!!
33,510,888
I want to make my blackjack game give me a new card when i press my button Draw A Card (hit) ``` private void btnDraw_Click(object sender, EventArgs e) { Random rdn = new Random(); int YourCardOne = rdn.Next(1, 10 + 1); this.lblYourCardOne.Text = Convert.ToString(YourCardOne); ``` Th...
2015/11/03
[ "https://Stackoverflow.com/questions/33510888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5522151/" ]
If what you want is for `@membercontact` to be available in every action of every controller, you can have it defined in a method in application\_controller.rb and have that method run before every action by using the [before\_action](http://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#met...
I think you might have to be calling the @membercontact line in each controller: ``` @membercontact = Backend::Membercontact.find(params[:membercontact_id]) ``` Unless the `membercontact_id` will always be the same for a particular session (eg: if the `membercontact_id` will be the `current_user.id`) - Is this the c...
22,501,105
In my windows forms application I use Mysql to get data. (I use MySql.Data.dll) Here is my connection string: ``` server=xxx.xxx.xxx.xxx;user id=user_name;Password=userpass;database=products ``` When I want use my application on a computer, I must add computer's ip to remote mysql connection on cpanel. I want grant...
2014/03/19
[ "https://Stackoverflow.com/questions/22501105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1001261/" ]
Try giving the user a "Super User" privileges; ``` GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'%' WITH GRANT OPTION; ``` to add password into the query; ``` GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'%' identified by 'userpass'; ```
``` GRANT ALL PRIVILEGES ON *.* TO 'root'@'Hello@123' WITH GRANT OPTION; ```
27,696
I'm reading on <https://sfist.com/2021/07/27/cdc-confirms-that-viral-loads-in-vaccinated-people-with-delta-are-indistinguishable-from-unvaccinated/> ([mirror](https://web.archive.org/web/20210728234442/https://sfist.com/2021/07/27/cdc-confirms-that-viral-loads-in-vaccinated-people-with-delta-are-indistinguishable-from-...
2021/07/28
[ "https://health.stackexchange.com/questions/27696", "https://health.stackexchange.com", "https://health.stackexchange.com/users/43/" ]
We have no real scientific data released yet, but here are some things to think about. 1. Being infected, feeling sick and being contagious are three different things. 2. Certainly, many fewer of the vaccinated are getting infected, even with the delta variant. 3. Many fewer of the vaccinated are feeling sick even if ...
Note that I am no virologist but am explaining to the best of my knowledge and for practical use from a variety of reports and my own understanding from my background in Nursing and Health Informatics. I think it is worth answering because the reasoning comes up a lot with skeptical friends and family who might questio...
27,696
I'm reading on <https://sfist.com/2021/07/27/cdc-confirms-that-viral-loads-in-vaccinated-people-with-delta-are-indistinguishable-from-unvaccinated/> ([mirror](https://web.archive.org/web/20210728234442/https://sfist.com/2021/07/27/cdc-confirms-that-viral-loads-in-vaccinated-people-with-delta-are-indistinguishable-from-...
2021/07/28
[ "https://health.stackexchange.com/questions/27696", "https://health.stackexchange.com", "https://health.stackexchange.com/users/43/" ]
The White House reports ([1](https://www.whitehouse.gov/briefing-room/press-briefings/2021/08/02/press-briefing-by-white-house-covid-19-response-team-and-public-health-officials-47/)) that several studies show that those with breakthrough infections of Delta had viral loads that were similar to people who were infected...
Note that I am no virologist but am explaining to the best of my knowledge and for practical use from a variety of reports and my own understanding from my background in Nursing and Health Informatics. I think it is worth answering because the reasoning comes up a lot with skeptical friends and family who might questio...
41,275,117
I'm searching for the following event, I need the number of the characters entered into a text box in a registration screen to appear automatically next to the same text box in JavaScript or jQuery. it's a question from a beginner, thanks in advance.
2016/12/22
[ "https://Stackoverflow.com/questions/41275117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7328403/" ]
Listen for the `input` event and check the length of the textbox's value then. ```js $("#input").on("input", function() { $("#count").text(this.value.length); }); ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text" id="input"> <span id="count"...
IMHO, keypress should be the ideal event to look for character count. ``` $('#input').on('keypress', function(e) { var count = $(this).val().length; $('#span').text(count); }) ``` **Keypress vs. Keyup:** If i press and hold any character key for a few seconds, it'd enter few characters in input box and k...
66,236,896
I want to run every combination possible for every 2 independent variables (OLS regression). I have a csv where I have my data (just one dependent variable and 23 independent variables), and I've tried renaming the variables inside my database from a to z, and I called 'y' to my dependent variable (a column with name "...
2021/02/17
[ "https://Stackoverflow.com/questions/66236896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13289920/" ]
As mentioned in the comments under the question check whether you need y or Y. Having addressed that we can use any of these. There is no need to rename the columns. We use the built in `mtcars` data set as an example since no test data was provided in the question. (Please always provide that in the future.) **1) Exh...
You should specify your `text_form` as formulas: ```r KOFS05.12 <- data.frame(y = rnorm(10), a = rnorm(10), b = rnorm(10), c = rnorm(10)) all_comb <- combn(letters[1:3], 2) fmla_form <- apply(all_comb, 2, function(x) as.formula(sprintf("y ~ %s", ...
24,213,211
I need to search an input file which has the regular expression multiple times. I need to print the expression on a new line. ``` "1-BBMD-DC-FB"|4|{47|"Interval"|00:00:00|00:00:00|1}{48|"Interval"|00:00:00|00:00:00|1}{49|"Interval"|00:00:00|00:00:00|1}{52|"Interval"|00:00:00|00:00:00|1}|{1|"Interval"|"All"|0}|{52|"Int...
2014/06/13
[ "https://Stackoverflow.com/questions/24213211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3738995/" ]
You don't need to call `JSON.stringify()`, when sending ajax-request, because `$.ajax()` function expects associative array of parameters, not string. ``` function callRemoteService(requestId, sObjectId, bObjectId) { $.ajax({ url: "../../../serviceRemoteEngine.php", dataType: "json", conten...
PHP expects a post/get request to have `key=value` pairs. You're sending over a bare string, so it's just `value`. Since there's no key, PHP cannot (and will not) put anything into $\_POST, since there's no key to attach the `value` to. Try ``` data: {foo: JSON.stringify(...)} ``` and ``` echo $_POST['foo'] ``` ...
24,213,211
I need to search an input file which has the regular expression multiple times. I need to print the expression on a new line. ``` "1-BBMD-DC-FB"|4|{47|"Interval"|00:00:00|00:00:00|1}{48|"Interval"|00:00:00|00:00:00|1}{49|"Interval"|00:00:00|00:00:00|1}{52|"Interval"|00:00:00|00:00:00|1}|{1|"Interval"|"All"|0}|{52|"Int...
2014/06/13
[ "https://Stackoverflow.com/questions/24213211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3738995/" ]
PHP expects a post/get request to have `key=value` pairs. You're sending over a bare string, so it's just `value`. Since there's no key, PHP cannot (and will not) put anything into $\_POST, since there's no key to attach the `value` to. Try ``` data: {foo: JSON.stringify(...)} ``` and ``` echo $_POST['foo'] ``` ...
Your PHP for the JSON is this: ``` echo json_encode(array("msg" => "message")); ``` But you should see if adding proper JSON headers will help clear things up. Like this: ``` $json_data = json_encode(array("msg" => "message")); header('X-JSON: (' . $json_data . ')'); header('Content-type: application/x-json'); echo...
24,213,211
I need to search an input file which has the regular expression multiple times. I need to print the expression on a new line. ``` "1-BBMD-DC-FB"|4|{47|"Interval"|00:00:00|00:00:00|1}{48|"Interval"|00:00:00|00:00:00|1}{49|"Interval"|00:00:00|00:00:00|1}{52|"Interval"|00:00:00|00:00:00|1}|{1|"Interval"|"All"|0}|{52|"Int...
2014/06/13
[ "https://Stackoverflow.com/questions/24213211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3738995/" ]
You don't need to call `JSON.stringify()`, when sending ajax-request, because `$.ajax()` function expects associative array of parameters, not string. ``` function callRemoteService(requestId, sObjectId, bObjectId) { $.ajax({ url: "../../../serviceRemoteEngine.php", dataType: "json", conten...
Your PHP for the JSON is this: ``` echo json_encode(array("msg" => "message")); ``` But you should see if adding proper JSON headers will help clear things up. Like this: ``` $json_data = json_encode(array("msg" => "message")); header('X-JSON: (' . $json_data . ')'); header('Content-type: application/x-json'); echo...
46,046,286
I upgraded from .NET Core 1.1 to .NET Core 2.0 and encountered the following issue (I also upgraded a few libraries to support .net core 2.0 aswell) CS1929 'ConfigurationStoreOptions' does not contain a definition for 'UseNpgsql' and the best extension method overload 'NpgsqlDbContextOptionsExtensions.UseNpgsql(DbCont...
2017/09/05
[ "https://Stackoverflow.com/questions/46046286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/103264/" ]
**Solution:** ``` services.AddIdentityServer() .AddSigningCredential(Certificate.Get()) .AddAspNetIdentity<User>() .AddConfigurationStore(options => { options.ConfigureDbContext = builder => builder.UseNpgsql(connectionString, ...
Just encountered the same problem myself. A trawling of the IndentityServer4.EntityFramework github revealed an example [Startup.cs](https://github.com/IdentityServer/IdentityServer4.EntityFramework/blob/dev/src/Host/Startup.cs) making the use of the ConfigureDBContext property
63,414,124
I need to create a new column which is a function of two or three other columns, one of which contains some missing data (NAs). However, when I use `dplyr`'s `mutate` function, the new column contains all NAs. See the example below: ``` rand_df <- data.frame(replicate(10,sample(0:10,200,rep=TRUE))) # random df names(...
2020/08/14
[ "https://Stackoverflow.com/questions/63414124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4695600/" ]
you can use pmin(). ``` library(dplyr) rand_df <- data.frame(replicate(10,sample(0:10,200,rep=TRUE))) # random df names(rand_df) <- letters[seq(from=1, to=10)] #renaming header rand_df$c[2:20] <- NA # introducing NAs head(rand_df) #> a b c d e f g h i j #> 1 4 9 9 6 10 2 1 10 10...
Seems like you've added extra argument within your `ifelse()` function. I mean `33.5` is needless here. Also, next time, please, be sure to ask properly (according to this guide [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example))
63,414,124
I need to create a new column which is a function of two or three other columns, one of which contains some missing data (NAs). However, when I use `dplyr`'s `mutate` function, the new column contains all NAs. See the example below: ``` rand_df <- data.frame(replicate(10,sample(0:10,200,rep=TRUE))) # random df names(...
2020/08/14
[ "https://Stackoverflow.com/questions/63414124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4695600/" ]
you can use pmin(). ``` library(dplyr) rand_df <- data.frame(replicate(10,sample(0:10,200,rep=TRUE))) # random df names(rand_df) <- letters[seq(from=1, to=10)] #renaming header rand_df$c[2:20] <- NA # introducing NAs head(rand_df) #> a b c d e f g h i j #> 1 4 9 9 6 10 2 1 10 10...
The following line of code is failing because `min((c/88.42),1))` does not do the calculation based on each row, but using the entire column, so you just have same value repeated: ``` rand_df <- rand_df %>% mutate(k = 141 * min((c/88.42), 1)) ``` This is a good illustration of the behaviour: ``` rand_df %>% mutate(...
22,928,455
In my app I load image and verify I haven't too much blobs. In additional, I put all images I loaded in list box and all image have a border. Now, I want to change border color pet item according the Boolean value (true or false according numbers of blobs and their size). If my image passed the border should be green,...
2014/04/08
[ "https://Stackoverflow.com/questions/22928455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1281081/" ]
Instead of binding to imagePath (string) you can define a class: ``` public class ImageStuff { public string ImagePath {get; set;} public bool Passed {get; set;} } ``` and add instance of this to the listbox. Then, you can use a converter for your border like this: ``` <Border BorderThickness="2" Width="120" ...
You neeed to write BoolToColorConverter for this purpose. Find following converter code. ``` public sealed class BoolToColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { bool bValue = (bool)value; if (bValue) ...
22,928,455
In my app I load image and verify I haven't too much blobs. In additional, I put all images I loaded in list box and all image have a border. Now, I want to change border color pet item according the Boolean value (true or false according numbers of blobs and their size). If my image passed the border should be green,...
2014/04/08
[ "https://Stackoverflow.com/questions/22928455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1281081/" ]
You can do it without `Converter`, just add `DataTrigger` with Tag property to DataTemplate. This can affect to the performance because the Converter will work little much longer. Add this class: ``` public class MyImage { public string ImagePath { get; set; } public bool Flag {...
You neeed to write BoolToColorConverter for this purpose. Find following converter code. ``` public sealed class BoolToColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { bool bValue = (bool)value; if (bValue) ...
142,307
A few days ago, my phone ran an automatic update of Titanium backup, which used to work fine. Now when I launch it, I am stuck on its home screen. I've tried restarting my phone, nothing changed : [![screenshot](https://i.stack.imgur.com/Q9cwh.jpg)](https://i.stack.imgur.com/Q9cwh.jpg) There is no backup/restore tab...
2016/04/13
[ "https://android.stackexchange.com/questions/142307", "https://android.stackexchange.com", "https://android.stackexchange.com/users/126359/" ]
The problem is your not flashing SuperSU or deleting /system/bin/install-recovery.sh. Android has safeguards which revert to the stock recovery thru the install-recovery.sh, SuperSU by default disables this function so I'd recommend flashing it after you install TWRP. Steps 1. fastboot flash recovery twrp.img or fast...
I am still puzzled about how the recovery issue is so stubborn. However, after reading through a blog post on [root-your-android-device-without-flashing-custom-recovery](http://codecorner.galanter.net/2015/02/15/root-your-android-device-without-flashing-custom-recovery/), I understood that you can boot your phone tempo...
29,358,690
I'm a PHP Developer, I'm using this library for my Laravel 4.2 <https://github.com/asakusuma/SugarCRM-REST-API-Wrapper-Class> I wanted to retrieve data from a user. I already have an account in sugarCRM I can log in successfully here: <https://web.sugarcrm.com/user> A PHP code sample from the library I'm using: ``` ...
2015/03/31
[ "https://Stackoverflow.com/questions/29358690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You might need to change those `and`s to `or`s so that any of those conditions (`a.isdigit()`, `int(a) < 0`, etc.) being true will result in avoiding the loop.
Check upfront whether b has decimals: ``` if round(b)==b: ```
58,534,897
I am very new to MongoDB and has to work with a MongoDB based analytics API. I have model called Session ``` user: { id: Number, name: String, email: String }, ipAddress: String, device: String, createdAt: Date ``` My requirement is **Get total number of sessions in last 7 days and group it by the date.** Hope my...
2019/10/24
[ "https://Stackoverflow.com/questions/58534897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7346647/" ]
You can use **`$group`**, to group the similar records, and then **`$sum`** accumulator in $group stage to count the records. ``` let date = new Date(); date.setDate(date.getDate() - 7); db.collection("sessions").aggregate({$match:{createdAt: {$gte: date }}}, {$group:{ _id: "$_id", count: {$sum...
``` var d = new Date(); d.setDate(d.getDate()-7); db.getCollection('sessions').aggregate([ {$match: {'createdAt': {$gt: d}}} ]) ```
49,953,099
i create a subclass datagridview to override the mousewheel event to catch mouse scroll then send key UP or DOWN. i create a datatable to be bind as datasource for mydatagridview by button click ``` private void button1_Click(object sender, EventArgs e) { DataTable myDataTable = new DataTable(); ...
2018/04/21
[ "https://Stackoverflow.com/questions/49953099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2080535/" ]
as @Bozhidar mentioned that i should better handling the MouseWheel event instead or overriding it. so i've come up with the solution just in case anyone need it too. in Form\_Load add ``` MyDataGridView1.MouseWheel += new MouseEventHandler(MyDataGridView1_MouseWheel); ``` then place this anywhere inside your class...
The `SendKeys` method is not as reliable when it comes to precise timing - see the [official documentation](https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx). Try setting the "SendKeys" app setting to "SendInput" in order to force the new behavior. But you'd be better off **ha...
49,953,099
i create a subclass datagridview to override the mousewheel event to catch mouse scroll then send key UP or DOWN. i create a datatable to be bind as datasource for mydatagridview by button click ``` private void button1_Click(object sender, EventArgs e) { DataTable myDataTable = new DataTable(); ...
2018/04/21
[ "https://Stackoverflow.com/questions/49953099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2080535/" ]
as @Bozhidar mentioned that i should better handling the MouseWheel event instead or overriding it. so i've come up with the solution just in case anyone need it too. in Form\_Load add ``` MyDataGridView1.MouseWheel += new MouseEventHandler(MyDataGridView1_MouseWheel); ``` then place this anywhere inside your class...
Here's an approach that preserves the default scrolling behavior of scrolling the viewport, but not changing the row selection. It also performs much faster than the built-in mouse wheel handler when millions of rows are being handled in a virtual grid: ``` private void Form1_Load(object sender, EventArgs e) { Da...
59,819,994
I have a `TextView` in the navigation drawer of my app. When initially loading the relevant xml, the `TextView` (displaying users name and surname) runs fine without an error. However, after navigating to the next activity and returning immediately back to the previous activity the app crashes with a `NullPointerExcept...
2020/01/20
[ "https://Stackoverflow.com/questions/59819994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12281377/" ]
I would recommend against storing derived information in the `post` table. This would go against normalization best practices (and will be painful to maintain). Information about comments belong to their own table. Whenever you need to count the number of comments per post, you can either use a correlated subquery as...
There are pros and cons for both variants: * Adding another column breaks normal form. This is a problem not only in theory: Your write load on the `posts` table will increase drastically. * Calculating the post count each time does create quite a load, but is a very clean option. Both will work fine on a moderate nu...
29,442,269
I'm writing a script in BASH which basically acts like a simplified gmake & package builder. It only supports one langauge; this is by design. I do not intend to publish this script, as it is intended for local use only. I've mostly got it working right. On more complicated projects, it handled everything fine. A prob...
2015/04/04
[ "https://Stackoverflow.com/questions/29442269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376373/" ]
You would have to attach a SelectionChanged event handler like this: ``` var comboBox = new ComboBox { ... }; comboBox.SelectionChanged += comboBox_SelectionChanged; ``` The above assumes that there is a handler method like ``` private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ...
`SelectionChanged` is not a property, it is an event. You are trying to attach event handler to an event using object initializer syntax, and .NET doesn't seems to support that. Here are some related questions : * [Initializing events with initializer syntax](https://stackoverflow.com/questions/4751837/initializing-...
67,249,418
I have a list with values I like to add to combobox in my userform. The values I want are in Column A and Column Z (so values from 2 columns). I manage to add the values with the AddItem function but struggling to add a header to the dropdown (a few posts said this is not possible). As alternative I saw ListFillRange...
2021/04/25
[ "https://Stackoverflow.com/questions/67249418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13068376/" ]
> > `a few posts said this is not possible` > > > I usually do not reply to questions which do not show any efforts but this is an interesting one. I tend to **agree** with you that lot of people think that you **cannot** show headers in a `ComboBox`. **But it is possible** to show headers in a `Combobox`. Here i...
I use the following code to add headers above listboxes and comboboxes. It seems a bit like a sledgehammer to crack a nut but sometimes the nut has to be cracked, and all the other methods and tools that I have seen also fall into the category of sledgehammer. To make this as simple as possible for myself I have defin...
5,800,726
I was looking into below examples for understanding files locking on windows and linux. The program 1 is working on both windows and linux with gcc. But the second one is only working on Linux. Especially problem in winodws GCC is coming in the structure flock declaration. I dont know if I am missing any thing here. Al...
2011/04/27
[ "https://Stackoverflow.com/questions/5800726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79358/" ]
It will likely be difficult to get protabiltiy with this kind of operation using the C Runtime LIbrary. You really need to use OS specific code for this kind of thing. But, you may be able to get this to work by inspecting and understanding the underlying C Runtime Library implimentations. The source code to both the ...
I would look into [XPDEV](http://cvs.synchro.net/cgi-bin/viewcvs.cgi/src/xpdev/) specifically the file wrapper methods... they implement reasonable cross-platform locking.
18,355,965
I created an app for imaging application to start with. Now I had to build another app which uses a lot of functionalities of the previous app. I copied and pasted the first project, and changed the app Display Name, etc. in WMAppManifest.xml file. But now when I try to deploy this app, I notice that the first app is...
2013/08/21
[ "https://Stackoverflow.com/questions/18355965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2091948/" ]
You don't need to "obtain" these IDs. When you submit your app to the marketplace, they are automatically replaced by the appropriate values. When developing on your computer, just put whatever value you want. The values are located in the application manifest (WMAppManifest.xml). You can create a GUID in Visual Studi...
You need to change the product ID (it's a GUID you can generate a new one).
39,026,499
I have a problem with Tango Explorer App. I am trying to create an ADF file, but when I finish recording, I get a "Error Saving ADF." I have updated to the latest OTA, and also the latest Tango Core. Does anyone have the same problem? I have also tried doing a factory reset, but same results. It records the area fine,...
2016/08/18
[ "https://Stackoverflow.com/questions/39026499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6714842/" ]
It's solved! What I had to do is uninstall the Tango Core App updates, then use the Explorer app, and then after accepting the Area Learning permissions and saving one ADF file successfully, I updated the Tango Core, and now it works perfectly.!!!!
Had the same problem here, it seems like the august update of the tango core changes something in the permission system (at least the dialogues are different), and that breaks the possibility to export ADFs to the sd card.
54,712,085
We provisioned a solution with terraform in azure one of the steps is provisioning a function app a seperate pipelines installs the software function in the function app when i rerun terraform apply (for updating something) the software functions are removed from the azure function app Using terraform version 1.22 ...
2019/02/15
[ "https://Stackoverflow.com/questions/54712085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4929453/" ]
It looks like, your deployment uses Packages. If you deploy the App via Terraform and afterwards doing the deploying via VS a App Setting will be set: WEBSITE\_RUN\_FROM\_PACKAGE to 1. If you update the Function by Terraform, the mounting will not be to wwwroot. So, updating the function via Terraform will lead into a ...
Had similar issue, helped setting `WEBSITES_ENABLE_APP_SERVICE_STORAGE` to `false` in terraform. > > If WEBSITES\_ENABLE\_APP\_SERVICE\_STORAGE setting is unspecified or set to true, the /home/ directory will be shared across scale instances, and files written will persist across restarts. Explicitly setting WEBSITES...
54,712,085
We provisioned a solution with terraform in azure one of the steps is provisioning a function app a seperate pipelines installs the software function in the function app when i rerun terraform apply (for updating something) the software functions are removed from the azure function app Using terraform version 1.22 ...
2019/02/15
[ "https://Stackoverflow.com/questions/54712085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4929453/" ]
Unless I'm missing something, here's what's going on: 1. You deploy your infra with Terraform. Function App has `"WEBSITE_RUN_FROM_PACKAGE" = "1"` setting (as defined in your TF script). 2. You deploy the code with Azure Functions Core Tools or VSCode. It uploads your code to a Storage Account and mounts it to the FA ...
It looks like, your deployment uses Packages. If you deploy the App via Terraform and afterwards doing the deploying via VS a App Setting will be set: WEBSITE\_RUN\_FROM\_PACKAGE to 1. If you update the Function by Terraform, the mounting will not be to wwwroot. So, updating the function via Terraform will lead into a ...
54,712,085
We provisioned a solution with terraform in azure one of the steps is provisioning a function app a seperate pipelines installs the software function in the function app when i rerun terraform apply (for updating something) the software functions are removed from the azure function app Using terraform version 1.22 ...
2019/02/15
[ "https://Stackoverflow.com/questions/54712085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4929453/" ]
Unless I'm missing something, here's what's going on: 1. You deploy your infra with Terraform. Function App has `"WEBSITE_RUN_FROM_PACKAGE" = "1"` setting (as defined in your TF script). 2. You deploy the code with Azure Functions Core Tools or VSCode. It uploads your code to a Storage Account and mounts it to the FA ...
Had similar issue, helped setting `WEBSITES_ENABLE_APP_SERVICE_STORAGE` to `false` in terraform. > > If WEBSITES\_ENABLE\_APP\_SERVICE\_STORAGE setting is unspecified or set to true, the /home/ directory will be shared across scale instances, and files written will persist across restarts. Explicitly setting WEBSITES...
2,771,758
I am planning to make a online-multiplayer game with my friends. The game is a browser card game (so, players act in turns) and players could host rooms in a lobby. Flex + actionscript will be used to write for the client side. We are discussing what should be used for the server side. I suggested C#/Java and my frien...
2010/05/05
[ "https://Stackoverflow.com/questions/2771758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/263363/" ]
You might want to use `<Application_Home>/Library/Caches`. From the apple docs @ <https://developer.apple.com/iphone/prerelease/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/RuntimeEnvironment/RuntimeEnvironment.html#//apple_ref/doc/uid/TP40007072-CH2-SW12> > > Use this directory to write any appl...
You need to read this: [Creating Paths and Locating Directories](http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/LowLevelFileMgmt/Articles/StandardDirectories.html) All of it. Carefully.
30,183
I've been struggling for awhile to setup GPS on my Raspberry Pi. I have a [Hemisphere Vector H102](http://hemispheregnss.com/Products-Solutions/Marine/vector-h102e284a2-gps-compass-oem-board-31) connected through a serial connection via USB through an adapter. I've followed [this guide](https://learn.adafruit.com/adaf...
2015/05/03
[ "https://raspberrypi.stackexchange.com/questions/30183", "https://raspberrypi.stackexchange.com", "https://raspberrypi.stackexchange.com/users/24718/" ]
I faced a similar issue, the way i solved it : 1) check GPS data stream ``` cat /dev/ttyAMA0 ``` => i was able to see the NMEA stream 2) check GPS data with gpsmon ``` gpsmon /dev/ttyAMA0 ``` => it was running well using the stream 3) run dgps in debug mode ``` sudo gpsd /dev/ttyAMA0 -N -D3 -F /var/run/gpsd...
I've been stuck for a while with another type of GPS module, Quectel\_L86. I've try to read its output with ``` gpsmon /dev/ttyAMA0 ``` It never gets a lock on any GPS so I picked my existing external antenna from other project and tried again. Finally I got a lock with GPS from cold boot quite quickly. Hope thi...
30,183
I've been struggling for awhile to setup GPS on my Raspberry Pi. I have a [Hemisphere Vector H102](http://hemispheregnss.com/Products-Solutions/Marine/vector-h102e284a2-gps-compass-oem-board-31) connected through a serial connection via USB through an adapter. I've followed [this guide](https://learn.adafruit.com/adaf...
2015/05/03
[ "https://raspberrypi.stackexchange.com/questions/30183", "https://raspberrypi.stackexchange.com", "https://raspberrypi.stackexchange.com/users/24718/" ]
I had exactly the same problem: ``` cgps: GPS timeout ``` I followed the advice above, stopped the serial console etc. and kept getting the same error. Wiring should be: ``` RXT on the GPS goes to TXD on the PI TXD on the GPS goes to RXT on the PI ``` When you think about it I suppose it is really obvious but I'...
I've been stuck for a while with another type of GPS module, Quectel\_L86. I've try to read its output with ``` gpsmon /dev/ttyAMA0 ``` It never gets a lock on any GPS so I picked my existing external antenna from other project and tried again. Finally I got a lock with GPS from cold boot quite quickly. Hope thi...
30,183
I've been struggling for awhile to setup GPS on my Raspberry Pi. I have a [Hemisphere Vector H102](http://hemispheregnss.com/Products-Solutions/Marine/vector-h102e284a2-gps-compass-oem-board-31) connected through a serial connection via USB through an adapter. I've followed [this guide](https://learn.adafruit.com/adaf...
2015/05/03
[ "https://raspberrypi.stackexchange.com/questions/30183", "https://raspberrypi.stackexchange.com", "https://raspberrypi.stackexchange.com/users/24718/" ]
Note that with the raspberry pi using the Adafruit Ultimage GPS Hat I used this line: `sudo gpsd /dev/serial0 -F /var/run/gpsd.sock` instead of this one: `sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock` and it solved my issues.
I've been stuck for a while with another type of GPS module, Quectel\_L86. I've try to read its output with ``` gpsmon /dev/ttyAMA0 ``` It never gets a lock on any GPS so I picked my existing external antenna from other project and tried again. Finally I got a lock with GPS from cold boot quite quickly. Hope thi...
30,183
I've been struggling for awhile to setup GPS on my Raspberry Pi. I have a [Hemisphere Vector H102](http://hemispheregnss.com/Products-Solutions/Marine/vector-h102e284a2-gps-compass-oem-board-31) connected through a serial connection via USB through an adapter. I've followed [this guide](https://learn.adafruit.com/adaf...
2015/05/03
[ "https://raspberrypi.stackexchange.com/questions/30183", "https://raspberrypi.stackexchange.com", "https://raspberrypi.stackexchange.com/users/24718/" ]
I faced a similar issue, the way i solved it : 1) check GPS data stream ``` cat /dev/ttyAMA0 ``` => i was able to see the NMEA stream 2) check GPS data with gpsmon ``` gpsmon /dev/ttyAMA0 ``` => it was running well using the stream 3) run dgps in debug mode ``` sudo gpsd /dev/ttyAMA0 -N -D3 -F /var/run/gpsd...
I had exactly the same problem: ``` cgps: GPS timeout ``` I followed the advice above, stopped the serial console etc. and kept getting the same error. Wiring should be: ``` RXT on the GPS goes to TXD on the PI TXD on the GPS goes to RXT on the PI ``` When you think about it I suppose it is really obvious but I'...
30,183
I've been struggling for awhile to setup GPS on my Raspberry Pi. I have a [Hemisphere Vector H102](http://hemispheregnss.com/Products-Solutions/Marine/vector-h102e284a2-gps-compass-oem-board-31) connected through a serial connection via USB through an adapter. I've followed [this guide](https://learn.adafruit.com/adaf...
2015/05/03
[ "https://raspberrypi.stackexchange.com/questions/30183", "https://raspberrypi.stackexchange.com", "https://raspberrypi.stackexchange.com/users/24718/" ]
I faced a similar issue, the way i solved it : 1) check GPS data stream ``` cat /dev/ttyAMA0 ``` => i was able to see the NMEA stream 2) check GPS data with gpsmon ``` gpsmon /dev/ttyAMA0 ``` => it was running well using the stream 3) run dgps in debug mode ``` sudo gpsd /dev/ttyAMA0 -N -D3 -F /var/run/gpsd...
Note that with the raspberry pi using the Adafruit Ultimage GPS Hat I used this line: `sudo gpsd /dev/serial0 -F /var/run/gpsd.sock` instead of this one: `sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock` and it solved my issues.
30,183
I've been struggling for awhile to setup GPS on my Raspberry Pi. I have a [Hemisphere Vector H102](http://hemispheregnss.com/Products-Solutions/Marine/vector-h102e284a2-gps-compass-oem-board-31) connected through a serial connection via USB through an adapter. I've followed [this guide](https://learn.adafruit.com/adaf...
2015/05/03
[ "https://raspberrypi.stackexchange.com/questions/30183", "https://raspberrypi.stackexchange.com", "https://raspberrypi.stackexchange.com/users/24718/" ]
I had exactly the same problem: ``` cgps: GPS timeout ``` I followed the advice above, stopped the serial console etc. and kept getting the same error. Wiring should be: ``` RXT on the GPS goes to TXD on the PI TXD on the GPS goes to RXT on the PI ``` When you think about it I suppose it is really obvious but I'...
Note that with the raspberry pi using the Adafruit Ultimage GPS Hat I used this line: `sudo gpsd /dev/serial0 -F /var/run/gpsd.sock` instead of this one: `sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock` and it solved my issues.
61,430,955
My code is supposed to receive an integer and a list of integers. It returns the sum of the integers in the list EXCEPT, it ignores the unlucky number and the number immediately following the unlucky number. Im only trying to use recursion (NO ITERATION). So far my code works for the first 5 cases but has issues wit...
2020/04/25
[ "https://Stackoverflow.com/questions/61430955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13204048/" ]
You forgot to exclude the unlucky number if `len(a_list) == 1`. Use `a_list[1:]`. ``` def unlucky(unlucky_num, a_list): if a_list == []: return 0 if a_list[0] == unlucky_num: if len(a_list) > 1: return unlucky(unlucky_num, a_list[2:]) return unlucky(unlucky_num, a_list[1:])...
As Mark Meyer said, it never reaches `a_list == []`. Try: ```py def unlucky(unlucky_num, a_list): if len(a_list) == 1: if a_list[0] == unlucky_num: return 0 else: return a_list[0] if a_list[0] == unlucky_num: if len(a_list) > 1: return unlucky(unlucky...
61,430,955
My code is supposed to receive an integer and a list of integers. It returns the sum of the integers in the list EXCEPT, it ignores the unlucky number and the number immediately following the unlucky number. Im only trying to use recursion (NO ITERATION). So far my code works for the first 5 cases but has issues wit...
2020/04/25
[ "https://Stackoverflow.com/questions/61430955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13204048/" ]
You really only need two tests, which will make it easier to avoid bugs. A test for the base case, which is an empty array and a test for the unlucky number. You don't need to test for the length after the base case because you can pass an empty array back. With that the function can be written in a way that it mirrors...
As Mark Meyer said, it never reaches `a_list == []`. Try: ```py def unlucky(unlucky_num, a_list): if len(a_list) == 1: if a_list[0] == unlucky_num: return 0 else: return a_list[0] if a_list[0] == unlucky_num: if len(a_list) > 1: return unlucky(unlucky...
34,121,110
I'm having a really strange inconsistancy. I'm preparing for reading from binary files on Arduino (for a midi player, in case you were interested). If I try to combine 4 bytes on Arduino to a long, it gives me a wrong result. However, if I use the equivalent code on PC, I get the correct value. Input is: 0x12481...
2015/12/06
[ "https://Stackoverflow.com/questions/34121110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2162187/" ]
On Arduino, `int` size [is 16 bits](https://www.arduino.cc/en/Reference/Int). In this line: ``` unsigned long testint = read1<<24|read2<<16|read3<<8|read4; ``` even if the result is stored in a `unsigned long` (32 bits), the bitwise operations are done on `int`s. Change this line to: ``` unsigned long testint = ...
I would expect the result 4680 (=0x1248) on any platform where sizeof(int)=2, and I think this is the case for arduino. That's because (read1 << 24) gets implicitly converted to int (not long), so the upper two bytes get lost. Yout should convert read\* to unsigned long first
34,121,110
I'm having a really strange inconsistancy. I'm preparing for reading from binary files on Arduino (for a midi player, in case you were interested). If I try to combine 4 bytes on Arduino to a long, it gives me a wrong result. However, if I use the equivalent code on PC, I get the correct value. Input is: 0x12481...
2015/12/06
[ "https://Stackoverflow.com/questions/34121110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2162187/" ]
I would expect the result 4680 (=0x1248) on any platform where sizeof(int)=2, and I think this is the case for arduino. That's because (read1 << 24) gets implicitly converted to int (not long), so the upper two bytes get lost. Yout should convert read\* to unsigned long first
You can also use the following code: ``` uint8_t data[4]; data[0]=read4; data[1]=read3; data[2]=read2; data[3]=read1; unsigned long testint =*(unsigned long*)(&data); ```
34,121,110
I'm having a really strange inconsistancy. I'm preparing for reading from binary files on Arduino (for a midi player, in case you were interested). If I try to combine 4 bytes on Arduino to a long, it gives me a wrong result. However, if I use the equivalent code on PC, I get the correct value. Input is: 0x12481...
2015/12/06
[ "https://Stackoverflow.com/questions/34121110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2162187/" ]
I would expect the result 4680 (=0x1248) on any platform where sizeof(int)=2, and I think this is the case for arduino. That's because (read1 << 24) gets implicitly converted to int (not long), so the upper two bytes get lost. Yout should convert read\* to unsigned long first
``` Here is another way to create 4 bytes to Long value and the reverse. Includes a simple test for these functions. byte dataj[4]; //4 byte array output unsigned long testint; unsigned long testnum, temp; unsigned long prev_time, cur_time = 0; void setup() { Serial.begin(115200); Serial.println(F("********** I...
34,121,110
I'm having a really strange inconsistancy. I'm preparing for reading from binary files on Arduino (for a midi player, in case you were interested). If I try to combine 4 bytes on Arduino to a long, it gives me a wrong result. However, if I use the equivalent code on PC, I get the correct value. Input is: 0x12481...
2015/12/06
[ "https://Stackoverflow.com/questions/34121110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2162187/" ]
On Arduino, `int` size [is 16 bits](https://www.arduino.cc/en/Reference/Int). In this line: ``` unsigned long testint = read1<<24|read2<<16|read3<<8|read4; ``` even if the result is stored in a `unsigned long` (32 bits), the bitwise operations are done on `int`s. Change this line to: ``` unsigned long testint = ...
You can also use the following code: ``` uint8_t data[4]; data[0]=read4; data[1]=read3; data[2]=read2; data[3]=read1; unsigned long testint =*(unsigned long*)(&data); ```
34,121,110
I'm having a really strange inconsistancy. I'm preparing for reading from binary files on Arduino (for a midi player, in case you were interested). If I try to combine 4 bytes on Arduino to a long, it gives me a wrong result. However, if I use the equivalent code on PC, I get the correct value. Input is: 0x12481...
2015/12/06
[ "https://Stackoverflow.com/questions/34121110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2162187/" ]
On Arduino, `int` size [is 16 bits](https://www.arduino.cc/en/Reference/Int). In this line: ``` unsigned long testint = read1<<24|read2<<16|read3<<8|read4; ``` even if the result is stored in a `unsigned long` (32 bits), the bitwise operations are done on `int`s. Change this line to: ``` unsigned long testint = ...
``` Here is another way to create 4 bytes to Long value and the reverse. Includes a simple test for these functions. byte dataj[4]; //4 byte array output unsigned long testint; unsigned long testnum, temp; unsigned long prev_time, cur_time = 0; void setup() { Serial.begin(115200); Serial.println(F("********** I...
73,449,754
Consider the following abhorrent class: ```py class MapInt: __call__ = int def __sub__(self, other): return map(self, other) __add__ = map ``` One can then call `map(int, lst)` via `MapInt() - lst`, i.e. ```py assert list(MapInt() - ['1','2','3'])) == [1,2,3] # passes ``` However, additio...
2022/08/22
[ "https://Stackoverflow.com/questions/73449754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16436774/" ]
The transformation of instance methods is described in the [Python Data Model](https://docs.python.org/3/reference/datamodel.html) (emphasis mine): > > Note that the transformation from function object to instance method object happens each time the attribute is retrieved from the instance [...] **Also notice that th...
It doesn't have anything to do with the difference between "assigning" and/or "defining". You could even add functions dynamically after the creation of the class. They are all the same. This is the behavior of a [descriptor](https://docs.python.org/3/howto/descriptor.html). ```py class Function: ... def __g...
73,449,754
Consider the following abhorrent class: ```py class MapInt: __call__ = int def __sub__(self, other): return map(self, other) __add__ = map ``` One can then call `map(int, lst)` via `MapInt() - lst`, i.e. ```py assert list(MapInt() - ['1','2','3'])) == [1,2,3] # passes ``` However, additio...
2022/08/22
[ "https://Stackoverflow.com/questions/73449754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16436774/" ]
The transformation of instance methods is described in the [Python Data Model](https://docs.python.org/3/reference/datamodel.html) (emphasis mine): > > Note that the transformation from function object to instance method object happens each time the attribute is retrieved from the instance [...] **Also notice that th...
@sj95126 has already given you the answer. Here's some more insight ```py class Foo: pass def wrapped(*args, **kwds): return dir(*args, **kwds) Foo.dir = dir Foo.wrapped = wrapped f = Foo() print(f'd() : {dir()}') print(f'w() : {wrapped()}') print(f'd(f) : {dir(f)}') print(f'w(f) : {wrapped(f)}') print(...
73,449,754
Consider the following abhorrent class: ```py class MapInt: __call__ = int def __sub__(self, other): return map(self, other) __add__ = map ``` One can then call `map(int, lst)` via `MapInt() - lst`, i.e. ```py assert list(MapInt() - ['1','2','3'])) == [1,2,3] # passes ``` However, additio...
2022/08/22
[ "https://Stackoverflow.com/questions/73449754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16436774/" ]
The transformation of instance methods is described in the [Python Data Model](https://docs.python.org/3/reference/datamodel.html) (emphasis mine): > > Note that the transformation from function object to instance method object happens each time the attribute is retrieved from the instance [...] **Also notice that th...
This has to do with how python binds objects to an instance with the dot operator. When you create a class body, it contains a bunch of objects that become attributes living in the class dictionary. It does not matter how an attribute ends up in the class dictionary, the behavior will be the same. For example: ``` cla...
73,449,754
Consider the following abhorrent class: ```py class MapInt: __call__ = int def __sub__(self, other): return map(self, other) __add__ = map ``` One can then call `map(int, lst)` via `MapInt() - lst`, i.e. ```py assert list(MapInt() - ['1','2','3'])) == [1,2,3] # passes ``` However, additio...
2022/08/22
[ "https://Stackoverflow.com/questions/73449754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16436774/" ]
It doesn't have anything to do with the difference between "assigning" and/or "defining". You could even add functions dynamically after the creation of the class. They are all the same. This is the behavior of a [descriptor](https://docs.python.org/3/howto/descriptor.html). ```py class Function: ... def __g...
This has to do with how python binds objects to an instance with the dot operator. When you create a class body, it contains a bunch of objects that become attributes living in the class dictionary. It does not matter how an attribute ends up in the class dictionary, the behavior will be the same. For example: ``` cla...
73,449,754
Consider the following abhorrent class: ```py class MapInt: __call__ = int def __sub__(self, other): return map(self, other) __add__ = map ``` One can then call `map(int, lst)` via `MapInt() - lst`, i.e. ```py assert list(MapInt() - ['1','2','3'])) == [1,2,3] # passes ``` However, additio...
2022/08/22
[ "https://Stackoverflow.com/questions/73449754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16436774/" ]
@sj95126 has already given you the answer. Here's some more insight ```py class Foo: pass def wrapped(*args, **kwds): return dir(*args, **kwds) Foo.dir = dir Foo.wrapped = wrapped f = Foo() print(f'd() : {dir()}') print(f'w() : {wrapped()}') print(f'd(f) : {dir(f)}') print(f'w(f) : {wrapped(f)}') print(...
This has to do with how python binds objects to an instance with the dot operator. When you create a class body, it contains a bunch of objects that become attributes living in the class dictionary. It does not matter how an attribute ends up in the class dictionary, the behavior will be the same. For example: ``` cla...
581,120
I'm using a webservice which returns an `XmlElement` object to my C# program. I would like to read information from the `XmlElement` using Xpath. What is the best way to create an `XPathDocument` from the `XmlElement`?
2009/02/24
[ "https://Stackoverflow.com/questions/581120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60118/" ]
You can [create a navigator directly](http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.createnavigator.aspx) against the XmlElement and use your xpath from there with the navigators Select\* methods, no XPathDocument required.
If you have an `XmlElement`, can you not just use `SelectNodes()` / `SelectSingleNode()`? Also, all `XmlNode`s are `IXPathNavigable`, allowing you to get a navigator. Finally, you can use `new XmlNodeReader(element)`, and use this to create an `XPathDocument` using the overload that accepts an `XmlReader`.
73,142,442
I want to make a class extend multiple function type interfaces. This works since the function types have different signatures, `() -> Unit` and `(String) - Unit` ``` typealias A = () -> Unit typealias B = (something: String) -> Unit class Test : A, B { override fun invoke() { TODO("Not yet implemented"...
2022/07/27
[ "https://Stackoverflow.com/questions/73142442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527533/" ]
The completer does not care about parameter's names. The `fun test(a: String): String` and `fun test(b: String): String` are the same functions. When you will call `test("some")` then which function should be called? You can create dedicated interfaces: ```kotlin interface Clickable { fun click(param: String) } ...
This will never work. At the fundamental JVM level, you can't implement the same interface twice with different generics. I would not expect this to *ever* work, even with the KEEP you mention. Why do you want to extend function interfaces at all? If you just want the nice call syntax, you can have separate `operator ...
73,142,442
I want to make a class extend multiple function type interfaces. This works since the function types have different signatures, `() -> Unit` and `(String) - Unit` ``` typealias A = () -> Unit typealias B = (something: String) -> Unit class Test : A, B { override fun invoke() { TODO("Not yet implemented"...
2022/07/27
[ "https://Stackoverflow.com/questions/73142442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527533/" ]
The completer does not care about parameter's names. The `fun test(a: String): String` and `fun test(b: String): String` are the same functions. When you will call `test("some")` then which function should be called? You can create dedicated interfaces: ```kotlin interface Clickable { fun click(param: String) } ...
A typealias is just a way to give a convenient label to a specific type - it's not a type in itself, anywhere you specify that typealias, you can can just pass in a variable defined as the real type, or any other typealias you've derived from it. So `B` and `C` are the same thing. You can have two different aliases fo...
23,724,001
I'm trying to find out if a user added new music to the Music folder on the phone since app was last used. I try to do this by checking the DateModified of the Music folder (which updates correctly on the computer when adding new music to the phone): ``` async void GetModifiedDate () { BasicProperties props = awa...
2014/05/18
[ "https://Stackoverflow.com/questions/23724001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1766208/" ]
[KnownFolders.MusicLibrary](http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.knownfolders.musiclibrary) is a [virtual location](http://msdn.microsoft.com/en-us/library/windows/apps/dd758096). Therefore I think, may be a problem in getting its properties. The other problem is that `DateModified` may...
You can check the folder size instead: ``` ulong musicFolderSize = (ulong)ApplicationData.Current.LocalSettings.Values["musicFolderSize"]; BasicProperties props = await KnownFolders.MusicLibrary.GetBasicPropertiesAsync(); if (props.Size != musicFolderSize) { // ... ApplicationData.Current.LocalSettings.Value...
23,724,001
I'm trying to find out if a user added new music to the Music folder on the phone since app was last used. I try to do this by checking the DateModified of the Music folder (which updates correctly on the computer when adding new music to the phone): ``` async void GetModifiedDate () { BasicProperties props = awa...
2014/05/18
[ "https://Stackoverflow.com/questions/23724001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1766208/" ]
[KnownFolders.MusicLibrary](http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.knownfolders.musiclibrary) is a [virtual location](http://msdn.microsoft.com/en-us/library/windows/apps/dd758096). Therefore I think, may be a problem in getting its properties. The other problem is that `DateModified` may...
Adding onto Romansz's answer: The only way to guarantee that you know of a file change would be to track the files on the device and then compare if there is a change between launches. A lazier way to get all of the files would be to use `KnownFolders.MusicLibrary.GetFilesAsync(CommonFileQuery.OrderByName);` which ...
28,483,751
I am looking for a regex expression that allows `a-z`, `A-Z`, any number, spaces, but it has to disallow whitespace at the END. So far I have: ``` [a-zA-Z' ']+ ``` I'm not sure how to allow any number and trim the whitespace at the end
2015/02/12
[ "https://Stackoverflow.com/questions/28483751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/927824/" ]
That's pretty simple: ```none ^[a-zA-Z0-9 ]*[a-zA-Z0-9]$ ``` I just special-cased the last character here. This required turning `+` into `*` for the remaining characters.
how about this pattern using word boundary `\b` `\b[a-zA-Z0-9 ]+\b`
28,483,751
I am looking for a regex expression that allows `a-z`, `A-Z`, any number, spaces, but it has to disallow whitespace at the END. So far I have: ``` [a-zA-Z' ']+ ``` I'm not sure how to allow any number and trim the whitespace at the end
2015/02/12
[ "https://Stackoverflow.com/questions/28483751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/927824/" ]
You could use a negative lookahead at the start. ``` ^(?!.*\s$)[a-zA-Z\d ]+ ``` `(?!.*\s$)` asserts that there isn't a space character exists at the end. **OR** ``` ^[a-zA-Z\d ]+(?<!\s)$ ``` [DEMO](https://regex101.com/r/wU4xK1/4)
how about this pattern using word boundary `\b` `\b[a-zA-Z0-9 ]+\b`
50,103,492
how to access img tag inside a href tag to set focus to `<img>` tag? eg: ``` <a href ='#' ><img class="img1" src="abc.png"/> </a> ``` The `a .img1:focus {}` didn't work. Not able to access `<img>` inside an `<a href></a>` tag If I add class to tag, I can add focus to tag but tag & tag are of diff size & causing i...
2018/04/30
[ "https://Stackoverflow.com/questions/50103492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9721815/" ]
You need a space between `a` and `.img1` ( the way you wrote it means "`a` tag with `img1` class" ) this way : ``` a .img1:focus {} ``` This means "element with `img1` class inside `a` tag" EDIT : in the link @jdv provided in the comments of your initial answer, don't focus (pun unintended) on the accepted answer,...
try out this code ``` <a href ='#' id='link'><img class="img1" src="abc.png"/> </a> a#link .img1:focus{} ```
50,103,492
how to access img tag inside a href tag to set focus to `<img>` tag? eg: ``` <a href ='#' ><img class="img1" src="abc.png"/> </a> ``` The `a .img1:focus {}` didn't work. Not able to access `<img>` inside an `<a href></a>` tag If I add class to tag, I can add focus to tag but tag & tag are of diff size & causing i...
2018/04/30
[ "https://Stackoverflow.com/questions/50103492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9721815/" ]
You need a space between `a` and `.img1` ( the way you wrote it means "`a` tag with `img1` class" ) this way : ``` a .img1:focus {} ``` This means "element with `img1` class inside `a` tag" EDIT : in the link @jdv provided in the comments of your initial answer, don't focus (pun unintended) on the accepted answer,...
`focus` is often associated with form elements like `input field` I advise you use `hover` like this instead ```css a img:hover{ width: 500px; } ``` ```html <a><img class="img1" src="http://via.placeholder.com/350x150"/></a> ```
1,818,939
Let $f: R^2 \rightarrow R^2 $ defined by $f(x,y) = (x+y,xy).$ Claim : Inverse image of each point in $R^2$ under f has at most two elements. My Claim : Suppose $f(x,y) = (x+y,xy)= (p,q).$ We have to find suitable x and y. By solving the equations I get, $x = \dfrac {p \pm \sqrt{p^2 - 4q}}{2q}, y = p-\dfrac {p \pm ...
2016/06/08
[ "https://math.stackexchange.com/questions/1818939", "https://math.stackexchange.com", "https://math.stackexchange.com/users/125245/" ]
They don't. For example, if $p = 0, q = 1$ then $x + y = p = 0$ implies $x = -y$ but then $xy = -x^2 = q = 1$ has no solution.
Given $(p,q)\in{\mathbb R}^2$ you are interested in the set of all pairs $(x,y)$ satisfying $x+y=p$, $xy=q$. By Vieta's theorem $\{x,y\}$ then is the solution set of the quadratic equation $$t^2-pt+q=0\ .\tag{1}$$ Therefore we can say the following: If $p^2-4q>0$ then $(1)$ has two different real solutions $t\_1$, $t\_...
43,019,136
i can get magnitude of signal coming from .wav file , but how to get the phase of that signal too ,,, Here is the where i browse for .wav file and extract the signal ``` def browse_wav(self): filepath = QtGui.QFileDialog.getOpenFileName(self, 'Single File', "C:\Users\Hanna Nabil\Documents",'*.wav') f= str(f...
2017/03/25
[ "https://Stackoverflow.com/questions/43019136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7274508/" ]
The complex spectrum contains both the magnitude and phase. You get the magnitude by calculating the absolute value and you get the phase by calculating the angle. You can use [`numpy.angle()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.angle.html) to get the phase: ``` spectrum = fft(self.signal) magn...
For the answer from Lukas Lalinsky I find I have to add pi/2 for some reason to get the correct answer. Also for points: ``` N = len(t) Amplitude = 2/N * np.abs(magnitude) ```
57,974
I try to install the most recent (july 25) version of Command Line Tools (xcode44cltools\_10\_76938107a.dm), downloaded from <https://developer.apple.com/downloads/>, but are stopped with the error message "This package can only be installed on OS X 10.7 Install a version of the Command Line Tools that supports OS X 10...
2012/07/27
[ "https://apple.stackexchange.com/questions/57974", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/26015/" ]
**You can install the command line tools within XCode.** Open XCode and navigate to the preferences. > > From here you have to go to the Downloads-Section. Here you can see > the ability to install the command line tools: > > > ![enter image description here](https://i.stack.imgur.com/890iJ.png) **EDIT:** I ca...
The best way to find developer tools for your version of XCode is to click on the XCode menu, scroll down to "Open Developer Tool" then select "More Developer Tools..." which will take you to a website displaying the latest developer tools. See my screenshot: ![enter image description here](https://i.stack.imgur.com/...
35,694,876
In my code i have a `oneToMany` relation between `customer` class and `item` class. This means that, **a customer may have one or many items.** Here is the customer code: ``` @Entity @Data public class customer { @Id @GeneratedValue int id; String name; String lastname; @Embedded Addres...
2016/02/29
[ "https://Stackoverflow.com/questions/35694876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1953504/" ]
You have to use [`@JoinColumn`](https://docs.oracle.com/javaee/7/api/javax/persistence/JoinColumn.html) for association columns: ``` @OneToMany @JoinColumn(name="ITEM_ID") List<item> item; ```
some other options ``` @OneToMany(cascade=CascadeType.All, fetch=FetchType.EAGER) @JoinColumn(name="ITEM_ID") List<item> item; ``` in Item class ``` @ManyToOne(mappedBy="item") customer customer; ```
35,694,876
In my code i have a `oneToMany` relation between `customer` class and `item` class. This means that, **a customer may have one or many items.** Here is the customer code: ``` @Entity @Data public class customer { @Id @GeneratedValue int id; String name; String lastname; @Embedded Addres...
2016/02/29
[ "https://Stackoverflow.com/questions/35694876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1953504/" ]
You have to use [`@JoinColumn`](https://docs.oracle.com/javaee/7/api/javax/persistence/JoinColumn.html) for association columns: ``` @OneToMany @JoinColumn(name="ITEM_ID") List<item> item; ```
you could do this i also have `user` class and `bcr` class, one user have many bcr so below code will help you **bcr.java** ``` @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_who_enter_demand", nullable = false) public User getUserByUserWhoEnterDemand() { return this.userByUserWhoEnterDemand;...
35,694,876
In my code i have a `oneToMany` relation between `customer` class and `item` class. This means that, **a customer may have one or many items.** Here is the customer code: ``` @Entity @Data public class customer { @Id @GeneratedValue int id; String name; String lastname; @Embedded Addres...
2016/02/29
[ "https://Stackoverflow.com/questions/35694876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1953504/" ]
You have to use [`@JoinColumn`](https://docs.oracle.com/javaee/7/api/javax/persistence/JoinColumn.html) for association columns: ``` @OneToMany @JoinColumn(name="ITEM_ID") List<item> item; ```
You can't map a table column without table: ``` @Entity @Table(name = "ITEM_TABLE") public class item { ... @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name = "CUSTOMER_ID_ITEM_TABLE") private customer customer; ... } @Entity @Table(name = "CUSTOMER_TABLE") public class customer { ... @OneToMany @Column(name...
32,538,305
Let's say I have the string '2okjser823ab'. How can I remove all the numbers from the string using .translate()? I see that in Python 2.x you can do something like .translate(None, '0123456789') but if I try this in Python 3 it tells me that the method only takes one argument.
2015/09/12
[ "https://Stackoverflow.com/questions/32538305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5328275/" ]
It looks like it's a bit harder in Python 3; not sure why. Here's what you can do: ``` >>> import string >>> translation = str.maketrans(string.ascii_letters, string.ascii_letters, string.digits) >>> "2okjser823ab".translate(translation) 'okjserab' ``` You may need to expand `string.ascii_letters` with whatever els...
You may use the `strip` function : ``` strings="tycoon0123456789999" strings.strip("0123456789") ```
32,538,305
Let's say I have the string '2okjser823ab'. How can I remove all the numbers from the string using .translate()? I see that in Python 2.x you can do something like .translate(None, '0123456789') but if I try this in Python 3 it tells me that the method only takes one argument.
2015/09/12
[ "https://Stackoverflow.com/questions/32538305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5328275/" ]
It looks like it's a bit harder in Python 3; not sure why. Here's what you can do: ``` >>> import string >>> translation = str.maketrans(string.ascii_letters, string.ascii_letters, string.digits) >>> "2okjser823ab".translate(translation) 'okjserab' ``` You may need to expand `string.ascii_letters` with whatever els...
Here is the documentation for [maketrans in Python 3](https://docs.python.org/3/library/stdtypes.html), and for [string functions](https://docs.python.org/3/library/string.html). In `maketrans(x, y, z)`, each character in x is mapped to the character at the same position in y - setting up a substitution of x for y. Ch...
32,538,305
Let's say I have the string '2okjser823ab'. How can I remove all the numbers from the string using .translate()? I see that in Python 2.x you can do something like .translate(None, '0123456789') but if I try this in Python 3 it tells me that the method only takes one argument.
2015/09/12
[ "https://Stackoverflow.com/questions/32538305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5328275/" ]
Here is the documentation for [maketrans in Python 3](https://docs.python.org/3/library/stdtypes.html), and for [string functions](https://docs.python.org/3/library/string.html). In `maketrans(x, y, z)`, each character in x is mapped to the character at the same position in y - setting up a substitution of x for y. Ch...
You may use the `strip` function : ``` strings="tycoon0123456789999" strings.strip("0123456789") ```
5,907,568
HI all, I have this "search results" ListView. The search results can be of different "kinds" (different sections, call it). To separate the "kinds" I add a row with a title. (I know about the expandable list, but can't use it for other reasons). In my getView(), I check for a property, and if it's set, I change t...
2011/05/06
[ "https://Stackoverflow.com/questions/5907568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/284556/" ]
There is vmrun.exe utility that can be used to control VM. Look at: <http://www.vmware.com/support/developer/vix-api/vix110_vmrun_command.pdf>
You need to think of your VMPlayer virtualized hardware as an independent computer, running it's own independent operating on it's own hardware. That's the way virtualization works! Technically the HOST doesn't even know it's "running" the other computer, so it's not going to treat it differently. The same is true for...
9,930,662
I am counting posts by Month, by Day, or by Hour, using EF. I end up with a list DateTime/Int where there are some DateTime gaps. The gaps are in years, when counting by year, in months, when counting by month, ... Is there a way to write an extension that fills DateTime gaps by year or month, ... Or even another ...
2012/03/29
[ "https://Stackoverflow.com/questions/9930662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/577805/" ]
Without looking at your code, why don't you prepopulate your tables with all of the dates you require (i.e no gaps) with count of 0. ``` Date Count Jan2012 0 Feb2012 0 Mar2012 0 ... Dec2049 0 ``` This will guarantee that your list will not ever have gaps. You can script this generation with sql date function...
Basically what I am doing is the following: ``` // Tupple to hold data IList<Tuple<DateTime, Int32>> data = new List<Tuple<DateTime, Int32>>(); // Get data from repository (Count by year) and add to Tupple _repository.Set<Post>() .Where(x => x.Created >= start && x.Created <= end) .GroupBy(x => new { Year = x.Created...
15,541,512
I am trying to work out how to do the following in JavaScript: ``` if(strtotime($row['last_active']) < (time() -(30))) { //update... } ``` `$row['last_active']` holds a timedate from MySQL. Any ideas?
2013/03/21
[ "https://Stackoverflow.com/questions/15541512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769543/" ]
Use a library: ``` var then = new XDate('<?=$row['last_active']?>'); var now = new XDate(); days_between = now.diffDays(then); ``` <http://arshaw.com/xdate/> There's also [Moment.js](http://momentjs.com/) and [Date.js](http://code.google.com/p/datejs/). You could also, in the query... ``` SELECT last_active, D...
You Can store `$row['last_active']` in javascript variable and for time you can use javascript current time variable `date = new Date();` But be aware javascript date variable gives you client machine time not your server time.
15,541,512
I am trying to work out how to do the following in JavaScript: ``` if(strtotime($row['last_active']) < (time() -(30))) { //update... } ``` `$row['last_active']` holds a timedate from MySQL. Any ideas?
2013/03/21
[ "https://Stackoverflow.com/questions/15541512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769543/" ]
You don't need to bother you with external JS lib, I would do : PHP ``` <?php $date = strtotime($row['last_active']); ?> ``` JS ``` //Number of milliseconds since midnight Jan 1, 1970 var serverDate = <?php echo (date('U',$date) * 1000); ?> //Compare with current number of milliseconds (like above) - 30 sec...
You Can store `$row['last_active']` in javascript variable and for time you can use javascript current time variable `date = new Date();` But be aware javascript date variable gives you client machine time not your server time.
295,143
Ok, so for the past few days, i've been getting more and more interested in Peltier Modules, and i've finally decided to make a portable mini fridge with one. After MANY long hours of research, part selection, crying, and cussing, I finally came up with a circuit diagram that seemed pretty solid. That is, until I show...
2017/03/27
[ "https://electronics.stackexchange.com/questions/295143", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/143525/" ]
Wire your loads in parallel instead of in series. Make sure your temperature switch can handle the current required. **ADD A FUSE ON YOUR BATTERY DAMN!!** Batteries are excellent for starting [fires](https://www.youtube.com/watch?v=PqyUtQv1WoQ). A 12V lead acid battery will happily put out enough current to heat you...
While @peufeu has given a perfectly good answer, I'll give you my own take on it. I think you may have misunderstood your chemistry teacher's answer a bit. Your circuit as shown will basically have both fans being driven at half their rated voltage, and almost no voltage across the TEC. So you'll get the fans blowing...
17,494,786
Is there a way for a privileged Firefox OS app to detect if the WiFi is connected to a network? I am aware of <https://developer.mozilla.org/en-US/docs/WebAPI/Settings> but that API is only for certified apps. All I need to do is detect whether the phone is connected to a network or is not connected.
2013/07/05
[ "https://Stackoverflow.com/questions/17494786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554678/" ]
Try this: ``` $book_count = query("SELECT status FROM scifi_book WHERE read = $uid"); echo count($book_count); ``` Also, you need to use `print_r($book_count)` since your `$book_count` is not a string.
your query function seems to return an array, not a string. Instead of `echo $follower_count` use `print_r($follower_count)` to see what's inside the query response.
17,494,786
Is there a way for a privileged Firefox OS app to detect if the WiFi is connected to a network? I am aware of <https://developer.mozilla.org/en-US/docs/WebAPI/Settings> but that API is only for certified apps. All I need to do is detect whether the phone is connected to a network or is not connected.
2013/07/05
[ "https://Stackoverflow.com/questions/17494786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554678/" ]
Try this: ``` $book_count = query("SELECT status FROM scifi_book WHERE read = $uid"); echo count($book_count); ``` Also, you need to use `print_r($book_count)` since your `$book_count` is not a string.
Suggestion: if you only use that query for getting the count, this may be a bit better: ``` $book_count = query("SELECT count(*) FROM scifi_book WHERE read = $uid"); ```
17,494,786
Is there a way for a privileged Firefox OS app to detect if the WiFi is connected to a network? I am aware of <https://developer.mozilla.org/en-US/docs/WebAPI/Settings> but that API is only for certified apps. All I need to do is detect whether the phone is connected to a network or is not connected.
2013/07/05
[ "https://Stackoverflow.com/questions/17494786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554678/" ]
Try this: ``` $book_count = query("SELECT status FROM scifi_book WHERE read = $uid"); echo count($book_count); ``` Also, you need to use `print_r($book_count)` since your `$book_count` is not a string.
The reason you are seeing that error is because you are `echo`ing `Array` which is the returned by your `query` function. `echo` construct only works on strings, please see the documentation here: <http://www.php.net/manual/en/function.echo.php>. Had you used `print_r` or `var_dump` then you wouldn't have seen that e...
17,494,786
Is there a way for a privileged Firefox OS app to detect if the WiFi is connected to a network? I am aware of <https://developer.mozilla.org/en-US/docs/WebAPI/Settings> but that API is only for certified apps. All I need to do is detect whether the phone is connected to a network or is not connected.
2013/07/05
[ "https://Stackoverflow.com/questions/17494786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554678/" ]
Try this: ``` $book_count = query("SELECT status FROM scifi_book WHERE read = $uid"); echo count($book_count); ``` Also, you need to use `print_r($book_count)` since your `$book_count` is not a string.
``` $book_count = query("SELECT status FROM scifi_book WHERE read =".$uid); (count($book_count)); echo $book_count; ```
17,494,786
Is there a way for a privileged Firefox OS app to detect if the WiFi is connected to a network? I am aware of <https://developer.mozilla.org/en-US/docs/WebAPI/Settings> but that API is only for certified apps. All I need to do is detect whether the phone is connected to a network or is not connected.
2013/07/05
[ "https://Stackoverflow.com/questions/17494786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554678/" ]
Suggestion: if you only use that query for getting the count, this may be a bit better: ``` $book_count = query("SELECT count(*) FROM scifi_book WHERE read = $uid"); ```
your query function seems to return an array, not a string. Instead of `echo $follower_count` use `print_r($follower_count)` to see what's inside the query response.
17,494,786
Is there a way for a privileged Firefox OS app to detect if the WiFi is connected to a network? I am aware of <https://developer.mozilla.org/en-US/docs/WebAPI/Settings> but that API is only for certified apps. All I need to do is detect whether the phone is connected to a network or is not connected.
2013/07/05
[ "https://Stackoverflow.com/questions/17494786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554678/" ]
Suggestion: if you only use that query for getting the count, this may be a bit better: ``` $book_count = query("SELECT count(*) FROM scifi_book WHERE read = $uid"); ```
The reason you are seeing that error is because you are `echo`ing `Array` which is the returned by your `query` function. `echo` construct only works on strings, please see the documentation here: <http://www.php.net/manual/en/function.echo.php>. Had you used `print_r` or `var_dump` then you wouldn't have seen that e...
17,494,786
Is there a way for a privileged Firefox OS app to detect if the WiFi is connected to a network? I am aware of <https://developer.mozilla.org/en-US/docs/WebAPI/Settings> but that API is only for certified apps. All I need to do is detect whether the phone is connected to a network or is not connected.
2013/07/05
[ "https://Stackoverflow.com/questions/17494786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2554678/" ]
Suggestion: if you only use that query for getting the count, this may be a bit better: ``` $book_count = query("SELECT count(*) FROM scifi_book WHERE read = $uid"); ```
``` $book_count = query("SELECT status FROM scifi_book WHERE read =".$uid); (count($book_count)); echo $book_count; ```
55,630,151
I've a problem where all my SWIG wrappers that deals with strings crashes If I pass a wrong encoded string inside a std::string, I mean strings that contains èé and so on, characters valid for the current locale, but not UTF-8 valid. On my code side, I have solved parsing the input as wide strings and convert them to ...
2019/04/11
[ "https://Stackoverflow.com/questions/55630151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1185568/" ]
Use StaggeredGridLayoutManager! <https://developer.android.com/reference/android/support/v7/widget/StaggeredGridLayoutManager>
**Try to set your layout manager like this for recyclerview.** ``` adapter = new CustomAdapter(R.layout.layout, list, context); final StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(numberOfrows, StaggeredGridLayoutManager.HORIZONTAL); recyclerView_sk.setHasFixedSize(true); recyclerView_sk.ad...
55,630,151
I've a problem where all my SWIG wrappers that deals with strings crashes If I pass a wrong encoded string inside a std::string, I mean strings that contains èé and so on, characters valid for the current locale, but not UTF-8 valid. On my code side, I have solved parsing the input as wide strings and convert them to ...
2019/04/11
[ "https://Stackoverflow.com/questions/55630151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1185568/" ]
Use StaggeredGridLayoutManager! <https://developer.android.com/reference/android/support/v7/widget/StaggeredGridLayoutManager>
Also, you can try with this ``` mDashboardAdapter = new DashboardAdapter(getActivity(), mDashBoardList, imageId); RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 4); grid.setLayoutManager(mLayoutManager); grid.addItemDecoration(new GridSpacingItemDecora...
22,726
I know that I can significantly improve my hiking efficiency by reducing the weight of my footwear. However, I have historically had trouble with blisters while hiking. I also often do long distance hikes that require heavy packs, and I am an overweight (but fit) hiker. So I want to know, is the extra weight on your ...
2019/07/30
[ "https://outdoors.stackexchange.com/questions/22726", "https://outdoors.stackexchange.com", "https://outdoors.stackexchange.com/users/18339/" ]
Blisters are more a function of improperly fitting/not broken in footwear than the specific type, although some kinds can be worse than others. Heavier and stiffer boots take longer to break in than light running shoes for example. I would get the type of footwear that works best for the terrain and size and break the...
The most common cause for a blister to appear on your foot is due to the friction of your foot moving and rubbing inside of your shoe. The best way to avoid this happening is to ensure that you thoroughly take your time getting the right size of shoe. Whether you go with a hiking boot or trail runner is personal prefer...
22,726
I know that I can significantly improve my hiking efficiency by reducing the weight of my footwear. However, I have historically had trouble with blisters while hiking. I also often do long distance hikes that require heavy packs, and I am an overweight (but fit) hiker. So I want to know, is the extra weight on your ...
2019/07/30
[ "https://outdoors.stackexchange.com/questions/22726", "https://outdoors.stackexchange.com", "https://outdoors.stackexchange.com/users/18339/" ]
There are a lot of factors that determine when you will get blisters that it is hard to say if one is better than the other. For example, brand new hiking boots vs. brand new trail runners is a totally different question than 1 year old worn in boots vs. runners. You also need to consider (not exhaustive): * Shoe fit...
The most common cause for a blister to appear on your foot is due to the friction of your foot moving and rubbing inside of your shoe. The best way to avoid this happening is to ensure that you thoroughly take your time getting the right size of shoe. Whether you go with a hiking boot or trail runner is personal prefer...
22,726
I know that I can significantly improve my hiking efficiency by reducing the weight of my footwear. However, I have historically had trouble with blisters while hiking. I also often do long distance hikes that require heavy packs, and I am an overweight (but fit) hiker. So I want to know, is the extra weight on your ...
2019/07/30
[ "https://outdoors.stackexchange.com/questions/22726", "https://outdoors.stackexchange.com", "https://outdoors.stackexchange.com/users/18339/" ]
I also have feet which are blister sensitive, but I'm not overweight. In principle, everything that 'dampens' your steps, avoids blisters, but cost energy. So it's a tradeoff. This includes for example thick/extra socks, soles. My experiences with hiking and walking events: About shoes: * Not too long, this causes ...
The most common cause for a blister to appear on your foot is due to the friction of your foot moving and rubbing inside of your shoe. The best way to avoid this happening is to ensure that you thoroughly take your time getting the right size of shoe. Whether you go with a hiking boot or trail runner is personal prefer...
22,726
I know that I can significantly improve my hiking efficiency by reducing the weight of my footwear. However, I have historically had trouble with blisters while hiking. I also often do long distance hikes that require heavy packs, and I am an overweight (but fit) hiker. So I want to know, is the extra weight on your ...
2019/07/30
[ "https://outdoors.stackexchange.com/questions/22726", "https://outdoors.stackexchange.com", "https://outdoors.stackexchange.com/users/18339/" ]
I'm likely out of the norm, but I believe properly fitting (and thickness) socks may be even more important than the shoes with regard to blisters. I personally use Darn Tough because they are knit so that there aren't any seams per se that could cause any issues. I size them so they are somewhat snug so there can be n...
The most common cause for a blister to appear on your foot is due to the friction of your foot moving and rubbing inside of your shoe. The best way to avoid this happening is to ensure that you thoroughly take your time getting the right size of shoe. Whether you go with a hiking boot or trail runner is personal prefer...
22,726
I know that I can significantly improve my hiking efficiency by reducing the weight of my footwear. However, I have historically had trouble with blisters while hiking. I also often do long distance hikes that require heavy packs, and I am an overweight (but fit) hiker. So I want to know, is the extra weight on your ...
2019/07/30
[ "https://outdoors.stackexchange.com/questions/22726", "https://outdoors.stackexchange.com", "https://outdoors.stackexchange.com/users/18339/" ]
The most common cause for a blister to appear on your foot is due to the friction of your foot moving and rubbing inside of your shoe. The best way to avoid this happening is to ensure that you thoroughly take your time getting the right size of shoe. Whether you go with a hiking boot or trail runner is personal prefer...
Prevention is important: 1. Wear the shoes with trip socks for a few weeks before the trip. The shorter distances involved in day to day living will get your feet accustomed to your shoes. 2. There are compounds sold that will toughen skin. Rubbing alcohol is one. Salt water is one. Running shoe stores carry others. 3...