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
1,478,697
I frequently see python code similar to ``` for line in open(filename): do_something(line) ``` When does filename get closed with this code? Would it be better to write ``` with open(filename) as f: for line in f.readlines(): do_something(line) ```
2009/09/25
[ "https://Stackoverflow.com/questions/1478697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
`filename` would be closed when it falls out of scope. That normally would be the end of the method. Yes, it's better to use `with`. > > Once you have a file object, you perform all file I/O by calling methods of this object. [...] When you are done with the file, you should finish by calling the `close` method on t...
Drop `.readlines()`. It is redundant and undesirable for large files (due to memory consumption). The variant with `'with'` block always closes file. ``` with open(filename) as file_: for line in file_: do_something(line) ``` When file will be closed in the bare `'for'`-loop variant depends on Python im...
1,478,697
I frequently see python code similar to ``` for line in open(filename): do_something(line) ``` When does filename get closed with this code? Would it be better to write ``` with open(filename) as f: for line in f.readlines(): do_something(line) ```
2009/09/25
[ "https://Stackoverflow.com/questions/1478697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
Drop `.readlines()`. It is redundant and undesirable for large files (due to memory consumption). The variant with `'with'` block always closes file. ``` with open(filename) as file_: for line in file_: do_something(line) ``` When file will be closed in the bare `'for'`-loop variant depends on Python im...
python is garbage-collected - cpython has reference counting and a backup cycle detecting garbage collector. File objects close their file handle when the are deleted/finalized. Thus the file will be eventually closed, and in cpython will closed as soon as the for loop finishes.
16,574,731
This was a question on my assignment: Which of the following is not an acceptable way of indicating comments? Why? * /\*\* comment \*/ * /\* comment \*/ * // comment * // comment comment * /\*comment comment \*/ In all honestly, they all look fine to me. But I was thinking that it could be /\*\* comment \*/ becaus...
2013/05/15
[ "https://Stackoverflow.com/questions/16574731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2383999/" ]
The first bullet: ``` /** comment */ ``` This type of comment is for documentation. Source: <http://journals.ecs.soton.ac.uk/java/tutorial/getStarted/application/comments.html> Just pointing this out since it's different from the other types of comments. You could be right about the multi-line comment though.
You should put this in a java file and compile each one then see which one gives you the error. You don't have to reason about it to guess the answer.
16,574,731
This was a question on my assignment: Which of the following is not an acceptable way of indicating comments? Why? * /\*\* comment \*/ * /\* comment \*/ * // comment * // comment comment * /\*comment comment \*/ In all honestly, they all look fine to me. But I was thinking that it could be /\*\* comment \*/ becaus...
2013/05/15
[ "https://Stackoverflow.com/questions/16574731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2383999/" ]
The Java language specification states that there are two kinds of comments, "//" and "/\* ... \*/". <http://docs.oracle.com/javase/specs/jls/se5.0/html/lexical.html#3.7> It is a trick question. But since /\*\* ... \*/ is used by JavaDoc tools to create JavaDocs, I would say the first choice is not an acceptable answ...
You should put this in a java file and compile each one then see which one gives you the error. You don't have to reason about it to guess the answer.
16,574,731
This was a question on my assignment: Which of the following is not an acceptable way of indicating comments? Why? * /\*\* comment \*/ * /\* comment \*/ * // comment * // comment comment * /\*comment comment \*/ In all honestly, they all look fine to me. But I was thinking that it could be /\*\* comment \*/ becaus...
2013/05/15
[ "https://Stackoverflow.com/questions/16574731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2383999/" ]
In terms of grammar, none of the above ways of indicating comments is not acceptable. However, to make other people easier to understand your code, then I would suggest to follow some of the major coding styles. For example, the [Oracle coding style](http://www.oracle.com/technetwork/java/javase/documentation/codeconv...
You should put this in a java file and compile each one then see which one gives you the error. You don't have to reason about it to guess the answer.
16,574,731
This was a question on my assignment: Which of the following is not an acceptable way of indicating comments? Why? * /\*\* comment \*/ * /\* comment \*/ * // comment * // comment comment * /\*comment comment \*/ In all honestly, they all look fine to me. But I was thinking that it could be /\*\* comment \*/ becaus...
2013/05/15
[ "https://Stackoverflow.com/questions/16574731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2383999/" ]
In terms of grammar, none of the above ways of indicating comments is not acceptable. However, to make other people easier to understand your code, then I would suggest to follow some of the major coding styles. For example, the [Oracle coding style](http://www.oracle.com/technetwork/java/javase/documentation/codeconv...
The first bullet: ``` /** comment */ ``` This type of comment is for documentation. Source: <http://journals.ecs.soton.ac.uk/java/tutorial/getStarted/application/comments.html> Just pointing this out since it's different from the other types of comments. You could be right about the multi-line comment though.
16,574,731
This was a question on my assignment: Which of the following is not an acceptable way of indicating comments? Why? * /\*\* comment \*/ * /\* comment \*/ * // comment * // comment comment * /\*comment comment \*/ In all honestly, they all look fine to me. But I was thinking that it could be /\*\* comment \*/ becaus...
2013/05/15
[ "https://Stackoverflow.com/questions/16574731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2383999/" ]
In terms of grammar, none of the above ways of indicating comments is not acceptable. However, to make other people easier to understand your code, then I would suggest to follow some of the major coding styles. For example, the [Oracle coding style](http://www.oracle.com/technetwork/java/javase/documentation/codeconv...
The Java language specification states that there are two kinds of comments, "//" and "/\* ... \*/". <http://docs.oracle.com/javase/specs/jls/se5.0/html/lexical.html#3.7> It is a trick question. But since /\*\* ... \*/ is used by JavaDoc tools to create JavaDocs, I would say the first choice is not an acceptable answ...
57,446,117
I have a table like this: ``` email (primary-key) | first_contact_date | last_contact_date | due_date | status ``` The user can upload an excel spreadsheet - from a different application - into the table. The excel contains: ``` email | first_contact_date | last_contact_date ``` Once loaded, the user can alter ...
2019/08/10
[ "https://Stackoverflow.com/questions/57446117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2028316/" ]
Try it with the `new` keyword, like follows: ``` let hours = (new Date(date)).getHours();. ``` Contrary to popular belief, the `new` keyword is more than just sugar: it means that to prototype is bounded to `this.__proto__`, instead of just returned as an object that is called while evaluation. In this case, `.getH...
The date that reaches your function is not an instance of Date; as you can see in the logs it's a stringified representation of it, that's why the method is not available, and also why you have to 'reconstruct' it, as suggested by Geza Kerecsenyi. --- > > Remember that your data is traversing the Internet from your ...
70,365,973
I am having column of datatype xml in my database. sample value shown below. ``` <Responses> <Response> <task></task> </Response> <Response> <task></task> </Response> <Response> <task></task> </Response> </Responses> ``` So from the above xml I need to extract each node and need to sa...
2021/12/15
[ "https://Stackoverflow.com/questions/70365973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4705981/" ]
try using the xml column, query. you will need to cast a string column to xml then use query. see ([SQL Server - returning xml child nodes for xml column](https://stackoverflow.com/questions/12690689/sql-server-returning-xml-child-nodes-for-xml-column)) ``` declare @tmp as table (ID UNIQUEIDENTIFIER, CreatedDate DATET...
Try following : ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.IO; namespace ConsoleApplication7 { class Program { static void Main(string[] args) { string xml = @"<Responses> ...
70,365,973
I am having column of datatype xml in my database. sample value shown below. ``` <Responses> <Response> <task></task> </Response> <Response> <task></task> </Response> <Response> <task></task> </Response> </Responses> ``` So from the above xml I need to extract each node and need to sa...
2021/12/15
[ "https://Stackoverflow.com/questions/70365973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4705981/" ]
You can use the following SQL XQuery solution: `.query` will give you a whole XML node, rather than `.value` which only gives you a single inner value. ```sql SELECT x.task.query('.') task FROM @tmp t CROSS APPLY t.XmlData.nodes('Responses/Response/task') x(task); ``` [db<>fiddle](https://dbfiddle.uk/?rdbms=sqlserv...
Try following : ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.IO; namespace ConsoleApplication7 { class Program { static void Main(string[] args) { string xml = @"<Responses> ...
19,078,613
**Problem Description** I wanted to ask about how to use a list Exbando Objects in knockout.js,am using Rob Conrey's Massive and all returned results are dynamic, that's fine with me it suits my needs but when it comes to sending results to knockout i just don't know what to do with it. **Goal** Access object proper...
2013/09/29
[ "https://Stackoverflow.com/questions/19078613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1801549/" ]
It looks like the problem is because you are trying to set the value of your ko.observableArray to a json array. Not sure that this will work. Typically this is how I would do it: ``` function ProductListViewModel() { // Data var self = this; self.Products = ko.observableArray([]); $.getJSON("/Home/GetPro...
As in your JSON I see the sequence of `Key` and `Value`, so you have to specify the filed name which knockout has to query for to get the relative value and put it on the screen. So change `<strong data-bind="text: Name">` to `<strong data-bind="text: Key">` and this *should* work for you.
19,078,613
**Problem Description** I wanted to ask about how to use a list Exbando Objects in knockout.js,am using Rob Conrey's Massive and all returned results are dynamic, that's fine with me it suits my needs but when it comes to sending results to knockout i just don't know what to do with it. **Goal** Access object proper...
2013/09/29
[ "https://Stackoverflow.com/questions/19078613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1801549/" ]
An `ExpandoObject` generally speaking is for all intents and purposes, a dictionary. When serialized as JSON here, it is treated as a dictionary and becomes a collection of key/value pairs (not all serializers behave this way, but the one you're using does). It is not an object you can access members by name, you'll ha...
As in your JSON I see the sequence of `Key` and `Value`, so you have to specify the filed name which knockout has to query for to get the relative value and put it on the screen. So change `<strong data-bind="text: Name">` to `<strong data-bind="text: Key">` and this *should* work for you.
19,078,613
**Problem Description** I wanted to ask about how to use a list Exbando Objects in knockout.js,am using Rob Conrey's Massive and all returned results are dynamic, that's fine with me it suits my needs but when it comes to sending results to knockout i just don't know what to do with it. **Goal** Access object proper...
2013/09/29
[ "https://Stackoverflow.com/questions/19078613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1801549/" ]
An `ExpandoObject` generally speaking is for all intents and purposes, a dictionary. When serialized as JSON here, it is treated as a dictionary and becomes a collection of key/value pairs (not all serializers behave this way, but the one you're using does). It is not an object you can access members by name, you'll ha...
It looks like the problem is because you are trying to set the value of your ko.observableArray to a json array. Not sure that this will work. Typically this is how I would do it: ``` function ProductListViewModel() { // Data var self = this; self.Products = ko.observableArray([]); $.getJSON("/Home/GetPro...
40,153,971
I have a lot of satellite data that is consists of two-dimension. (I convert H5 to 2d array data that not include latitude information I made Lat/Lon information data additionally.) I know real Lat/Lon coordination and **grid coordination** in one data. **How can I partially read 2d satellite file in Python?** "nu...
2016/10/20
[ "https://Stackoverflow.com/questions/40153971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5121617/" ]
You can't do what you've described - the best you can do is to create a new Enum that uses the same set of values. You will then need to cast to the "real" enum whenever you use it. You could use T4 templates or similar to generate the attributed enum for you - it would be much safer that way as it would be very easy ...
You can do something like this, but it will be tedious. The idea is to use your project settings to allow the change when you import the enum in a new project. First, you will need 2 attributes: ``` // This one is to indicate the format of the keys in your settings public class EnumAttribute : Attribute { publ...
40,153,971
I have a lot of satellite data that is consists of two-dimension. (I convert H5 to 2d array data that not include latitude information I made Lat/Lon information data additionally.) I know real Lat/Lon coordination and **grid coordination** in one data. **How can I partially read 2d satellite file in Python?** "nu...
2016/10/20
[ "https://Stackoverflow.com/questions/40153971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5121617/" ]
Attributes are compile-time additions (metadata) to code. You can not modify them when using the compiled code assembly. (Or perhaps you could if you are a diehard low-level IL wizard, but I certainly am not...) If your `enum` values require modification or parameters at various places, then you should consider oth...
You can do something like this, but it will be tedious. The idea is to use your project settings to allow the change when you import the enum in a new project. First, you will need 2 attributes: ``` // This one is to indicate the format of the keys in your settings public class EnumAttribute : Attribute { publ...
40,153,971
I have a lot of satellite data that is consists of two-dimension. (I convert H5 to 2d array data that not include latitude information I made Lat/Lon information data additionally.) I know real Lat/Lon coordination and **grid coordination** in one data. **How can I partially read 2d satellite file in Python?** "nu...
2016/10/20
[ "https://Stackoverflow.com/questions/40153971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5121617/" ]
You can't do what you've described - the best you can do is to create a new Enum that uses the same set of values. You will then need to cast to the "real" enum whenever you use it. You could use T4 templates or similar to generate the attributed enum for you - it would be much safer that way as it would be very easy ...
Attributes are compile-time additions (metadata) to code. You can not modify them when using the compiled code assembly. (Or perhaps you could if you are a diehard low-level IL wizard, but I certainly am not...) If your `enum` values require modification or parameters at various places, then you should consider oth...
59,017,326
I am fighting with SFINAE trying to have many functions that requires just to have access to the type T with operator `[]`. So far I have the following code that compiles and works fine with Visual Studio 2017: ``` #include <iostream> #include <sstream> #include <string> #include <vector> #include <list> #include <arr...
2019/11/24
[ "https://Stackoverflow.com/questions/59017326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1165590/" ]
> > How to combine both SFINAE conditions checking for array & pointer and random access operator into one check? I > > > The simplest way that come in my mind is check if you can write `c[0u]` ``` template <typename T> auto DoIt(T& c) -> decltype( c[0u], void() ) {} ``` Not a perfect solution: works with types...
When you have a bunch of conditional SFINAE that you want to apply, I usually try to split them up in smaller helper structs. In yoyur example it would look something like this. ``` template <typename T, typename U = void> struct random_access : std::false_type {}; template <typename T> struct random_access<T, std::...
3,519,859
If $d\_1$ and $d\_2$ are topologically equivalent metrics show that $d=max\{2d\_1,d\_2\}$ is topologically equivalent to both $d\_1$ and $d\_2$ I can show one direction$(\tau \_1\subseteq\tau )$ by choosing $\delta=min\{r\_1,r\_2\}$, but to prove other direction $(\tau \subseteq\tau \_1)$, how should I choose $\delta...
2020/01/23
[ "https://math.stackexchange.com/questions/3519859", "https://math.stackexchange.com", "https://math.stackexchange.com/users/568605/" ]
If you assume that $x \ll 1$, you can develop using the binomial expansion to get, as @InterstellarProbe wrote $$y = \sum\_{k=1}^n\dbinom{n}{k}(-1)^{k+1}x^{k-1}$$ Now, using series reversion, you could get $$x=t+\frac{(n-2)}{3} t^2+\frac{(n-2) (5 n-7)}{36} t^3+\frac{(n-2)(17 n^2-44 n+29)}{270} t^4+\cdots$$ where $$t=-\...
Let's try to turn this into a polynomial equation. By the Binomial Theorem: $$(1-x)^n = \sum\_{k=0}^n\dbinom{n}{k}(-1)^kx^k$$ Simplifying: $$\dfrac{1-(1-x)^n}{x} = \sum\_{k=1}^n\dbinom{n}{k}(-1)^{k+1}x^{k-1}$$ Thus: $$y = \sum\_{k=1}^n\dbinom{n}{k}(-1)^{k+1}x^{k-1}$$ For $n>5$, this is a polynomial of degree $5$ or...
9,270,490
I'm encountering some major performance problems with simple SQL queries generated by the Entity Framework (4.2) running against SQL Server 2008 R2. In some situations (but not all), EF uses the following syntax: ``` exec sp_executesql 'DYNAMIC-SQL-QUERY-HERE', @param1... ``` In other situations is simply executes ...
2012/02/14
[ "https://Stackoverflow.com/questions/9270490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1100905/" ]
At this point I would recommend: --- Set the optimize for ad hoc workloads setting to true. ``` EXEC sp_configure 'show advanced', 1; GO RECONFIGURE WITH OVERRIDE; GO EXEC sp_configure 'optimize for ad hoc', 1; GO RECONFIGURE WITH OVERRIDE GO EXEC sp_configure 'show advanced', 0; GO RECONFIGURE WITH OVERRIDE; GO ``...
**tl;dr** `update statistics` --- We had a `delete` query with one parameter (the primary key) that took ~7 seconds to complete when called through EF and `sp_executesql`. Running the query manually, with the parameter embedded in the first argument to `sp_executesql` made the query run quickly (~0.2 seconds). Addin...
6,180,051
What's the best way to send a `POST` request with `NSURLConnection`. I see how the facebook-ios-sdk does it: <https://github.com/facebook/facebook-ios-sdk/blob/master/src/FBRequest.m#L298-304> <https://github.com/facebook/facebook-ios-sdk/blob/master/src/FBRequest.m#L109-165> But, that seems like a lot of code. Is ...
2011/05/30
[ "https://Stackoverflow.com/questions/6180051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/242933/" ]
Facebook's code is as complicated as it is because they're sending the data with a `multipart/form-data` content type. You are free to use a simpler content type, like `application/octet-stream` for raw binary data.
You can try <http://getsharekit.com/>. Using this you can share in many social networks. Also you can share in a specific network also. If you refer to the documents there you can see how to send the images from a URL.
46,010,496
I have 2 DateTimes, I need to calculate the difference between them in hours **in decimal format**. The hard part is making sure the result is storing the value to 2 decimal places. ``` $datetime1 = new DateTime("2017-09-01 23:00:00"); $datetime2 = new DateTime(); $difference = $datetime2->diff($datetime1); ``` But ...
2017/09/02
[ "https://Stackoverflow.com/questions/46010496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8337916/" ]
`DateTime::diff` returns [`DaterInterval`](http://php.net/manual/en/class.dateinterval.php) that has a whole number for each individual time related property. The `days` property does not account for increments less than a day, as they are accumulated to and removed from the lesser properties and then is rounded down....
2 decimal places: ``` $datetime1 = new DateTime("2017-09-01 23:00:00"); $datetime2 = new DateTime(); $epoch1 = $datetime1->getTimestamp(); $epoch2 = $datetime2->getTimestamp(); $diff = $epoch1 - $epoch2; echo number_format( $diff / 3600, '2' ); ```
35,841,196
I'm trying to build a simple game in Java. Ran into the problem of the JTextPanel not updating until after the game loop terminates, which of course, isn't a good experience for the player. I'm unfamiliar with multithreading but trying to figure it out. I can run separate code now in multiple threads, but I can't get...
2016/03/07
[ "https://Stackoverflow.com/questions/35841196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1450008/" ]
if you use code quality management tool like sonarcube you will see that catched exceptions must be rethrown or logged with LOG.error. I recommend you and your team to use [sonarqube](http://www.sonarqube.org/)
In most cases, the log level in a catch block should be error. But the level of log: error, warn or info is not related to the location of it in code (catch block), but the relevance of the information. I think the use of exceptions may be misused in your project. But it is difficult to judge without knowing the conte...
56,399,830
I cannot import javax.servlet even though I have already added the package in my gradle dependencies. Here's my gradle dependency: ``` dependencies { providedCompile group: 'javax.servlet', name: 'javax.servlet-api', ... ... } ``` I've also tried: ``` dependencies { compile "javax.servlet:servlet-...
2019/05/31
[ "https://Stackoverflow.com/questions/56399830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8285512/" ]
You really should only open files with Append Data. [Difference between FILE\_WRITE\_DATA and FILE\_APPEND\_DATA](https://stackoverflow.com/questions/20093571/difference-between-file-write-data-and-file-append-data). `echo` and other methods cannot append data with only Append Data access(There are other complicated...
Figured it out, at least for PowerShell/.NET. The .NET `FileStream` object offers a constructor which takes a `FileSystemRights` enum parameter, which lets you explicitly limit the underlying `CreateFile` call not to require `Generic Write`. ``` > (1..3) | %{ > Write-Host $_ > $f = New-Object -TypeName 'IO.FileStr...
1,340,613
In Excel, I have a table where I want to list all unique values from a column in a different a row of a different sheet. Here is an example of the data I have: [![Example of Table](https://i.stack.imgur.com/086kU.png)](https://i.stack.imgur.com/086kU.png) I want to fill in cells in the other sheet so that it gives al...
2018/07/16
[ "https://superuser.com/questions/1340613", "https://superuser.com", "https://superuser.com/users/885788/" ]
Check this [article](https://www.spreadsheetweb.com/get-unique-items-from-list/) that explains to get *unique* values from a list. Differently, it creates a vertical list however, formula will work as horizontal as well. However; you should add | characters by yourself, I mean by using another formula. Unique list for...
If I understand your goal correctly, try this: 1. Copy the fruit column & paste it somewhere else (away from the rest of the data). 2. Select the data you just copied and use Data->Remove Duplicates. This will remove any duplicates. 3. Select the data that's left, Copy, and click on the leftmost cell of where ...
8,956,006
I am using javascript. I wanted to ask how can i pass variable link to the .load() function of javascript. ``` var current_link = location.href; $('#alerts_div').load(current_link '#alerts_div');//to pass div content in page load ``` But this is not working? can anyone help please?
2012/01/21
[ "https://Stackoverflow.com/questions/8956006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1015882/" ]
Why don't you use ListView instead? ``` LayoutInflater inflater = inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); for(String[] episode : episodes) { View view = inflater.inflate(R.layout.episode_list_item, null); mTitle = (TextView) view.findViewById(R....
I am assuming you have a few `TextView`s in your `LinearLayout`. One point is they can't have the same `id`s. So suppose you have 4 `TextView` , then give each different `id`s, say `tv1`, `tv2` etc. Now in your `onCreate` method, initialize all these textViews as: > > `myTextView1= (TextView)findViewByid(R.id.tv1);`...
8,956,006
I am using javascript. I wanted to ask how can i pass variable link to the .load() function of javascript. ``` var current_link = location.href; $('#alerts_div').load(current_link '#alerts_div');//to pass div content in page load ``` But this is not working? can anyone help please?
2012/01/21
[ "https://Stackoverflow.com/questions/8956006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1015882/" ]
I am assuming you have a few `TextView`s in your `LinearLayout`. One point is they can't have the same `id`s. So suppose you have 4 `TextView` , then give each different `id`s, say `tv1`, `tv2` etc. Now in your `onCreate` method, initialize all these textViews as: > > `myTextView1= (TextView)findViewByid(R.id.tv1);`...
Change the lines ``` inflater.inflate(R.layout.episode_list_item, listView); eTitle = (TextView) findViewById(R.id.episode_list_item_title); ``` into lines: ``` eTitle =inflater.inflate(R.layout.episode_list_item, listView, false); listView.addChild(eTitle ); ``` The one-line construct of `View eTitle =inflater....
8,956,006
I am using javascript. I wanted to ask how can i pass variable link to the .load() function of javascript. ``` var current_link = location.href; $('#alerts_div').load(current_link '#alerts_div');//to pass div content in page load ``` But this is not working? can anyone help please?
2012/01/21
[ "https://Stackoverflow.com/questions/8956006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1015882/" ]
I am assuming you have a few `TextView`s in your `LinearLayout`. One point is they can't have the same `id`s. So suppose you have 4 `TextView` , then give each different `id`s, say `tv1`, `tv2` etc. Now in your `onCreate` method, initialize all these textViews as: > > `myTextView1= (TextView)findViewByid(R.id.tv1);`...
I believe you're forgetting to capture the view that's being inflated and then looking WITHIN that view for the new control. Here's your original code: ``` inflater.inflate(R.layout.episode_list_item, listView); eTitle = (TextView) findViewById(R.id.episode_list_item_title); ``` I think Your code should look more l...
8,956,006
I am using javascript. I wanted to ask how can i pass variable link to the .load() function of javascript. ``` var current_link = location.href; $('#alerts_div').load(current_link '#alerts_div');//to pass div content in page load ``` But this is not working? can anyone help please?
2012/01/21
[ "https://Stackoverflow.com/questions/8956006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1015882/" ]
Why don't you use ListView instead? ``` LayoutInflater inflater = inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); for(String[] episode : episodes) { View view = inflater.inflate(R.layout.episode_list_item, null); mTitle = (TextView) view.findViewById(R....
Change the lines ``` inflater.inflate(R.layout.episode_list_item, listView); eTitle = (TextView) findViewById(R.id.episode_list_item_title); ``` into lines: ``` eTitle =inflater.inflate(R.layout.episode_list_item, listView, false); listView.addChild(eTitle ); ``` The one-line construct of `View eTitle =inflater....
8,956,006
I am using javascript. I wanted to ask how can i pass variable link to the .load() function of javascript. ``` var current_link = location.href; $('#alerts_div').load(current_link '#alerts_div');//to pass div content in page load ``` But this is not working? can anyone help please?
2012/01/21
[ "https://Stackoverflow.com/questions/8956006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1015882/" ]
Why don't you use ListView instead? ``` LayoutInflater inflater = inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); for(String[] episode : episodes) { View view = inflater.inflate(R.layout.episode_list_item, null); mTitle = (TextView) view.findViewById(R....
I believe you're forgetting to capture the view that's being inflated and then looking WITHIN that view for the new control. Here's your original code: ``` inflater.inflate(R.layout.episode_list_item, listView); eTitle = (TextView) findViewById(R.id.episode_list_item_title); ``` I think Your code should look more l...
976,365
I have an homework question but I'm having hard time to understand the context. Here is the question: > > 3. Assume that you are using 3-digit number system with base r = 4 (and n = 3). Assume also that you are using four’s complement scheme > to represent signed integers and for subtraction operation. > > > a. S...
2014/10/16
[ "https://math.stackexchange.com/questions/976365", "https://math.stackexchange.com", "https://math.stackexchange.com/users/27091/" ]
Based on wiki's entry on [Method of complements](http://en.wikipedia.org/wiki/Method_of_complements). * The **radix complement** of an n digit number $y$ in radix $b$ is $b^n-y$. * The **diminished radix complement** is $( b^n - 1 )-y$. * The **two's complement** refers to the radix complement of a number in base $2$...
This is the idea of the $r$'s complement scheme. Namely, say we have some base $r$ in which we have $n$-digit numbers. Normally these numbers would be identified with $[0,r^n-1]$, e.g. $r=2,n=4$ gives you numbers > > 0000 to 1111 > > > which are (in base 10) equal to $[0,31]=[0,r^n-1]$. But, when we use $r$'s c...
35,293,460
I want to create a `factory` that always returns the `json` object retrieved from a webservice: ``` angular.module('test').factory('myService', myService); myService.$inject = ['$http']; function myService($http) { var urlBase; return { getContent: function(id) { return $http.get(urlBase)...
2016/02/09
[ "https://Stackoverflow.com/questions/35293460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1194415/" ]
You can't return the result of an asynchronous function. Your `return response.data;` statement is just exiting the promise `.then()` callback. You should modify your function like so: ``` getContent: function(id) { return $http.get(urlBase); } ``` And then call it like this: ``` MyService.getContent().then(funct...
That is because you are returning a promise that has already been resolve and not the promise instance. Just returning ``` $http.get(urlBase) ``` from your getContent function should do the trick :)
6,034,467
Web Developer here and need some advice on how to achieve what must be a common requirement in Windows Forms. I have a windows client app that calls a business object in a separate project to perform some long running tasks. Difference to other examples is that the process live in another class library i.e. Business....
2011/05/17
[ "https://Stackoverflow.com/questions/6034467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62282/" ]
You're looking for the [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) class. To execute a time-consuming operation in the background, create a `BackgroundWorker` and listen for events that report the progress of your operation and signal when your operation is f...
> > I can run the process on the UI thread > passsing in the instance of the > textbox and calling > Application.DoEvents() when I log to > the textbox from within the task. > > > Yes, you could also pass in an instance of ILoggingINnterface that you have used to put in the code to write to the text box FROM W...
6,034,467
Web Developer here and need some advice on how to achieve what must be a common requirement in Windows Forms. I have a windows client app that calls a business object in a separate project to perform some long running tasks. Difference to other examples is that the process live in another class library i.e. Business....
2011/05/17
[ "https://Stackoverflow.com/questions/6034467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62282/" ]
You're looking for the [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) class. To execute a time-consuming operation in the background, create a `BackgroundWorker` and listen for events that report the progress of your operation and signal when your operation is f...
Yeah, avoid `Application.DoEvents()`. To marshall the call back onto the UI thread, call `this.Invoke(YourDelegate)`
6,034,467
Web Developer here and need some advice on how to achieve what must be a common requirement in Windows Forms. I have a windows client app that calls a business object in a separate project to perform some long running tasks. Difference to other examples is that the process live in another class library i.e. Business....
2011/05/17
[ "https://Stackoverflow.com/questions/6034467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62282/" ]
You're looking for the [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) class. To execute a time-consuming operation in the background, create a `BackgroundWorker` and listen for events that report the progress of your operation and signal when your operation is f...
To access UI elements from a different thread, you can use control.Invoke to call a delegate on the owning thread. I used this at one point to create a live log screen which was updated from a timer while a different worker thread was running. Heres a simplified version: ``` public class DifferentClassLibrary { pu...
14,892,148
I have created one listview of some names,what i need is when i will click selected row it will go to that page only,on click on different row it will move to the same class but different content.I think it will move by question id.could anybody help me how to pass the question id Or any other method to do this.. here...
2013/02/15
[ "https://Stackoverflow.com/questions/14892148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can try something like this - ``` private OnItemClickListener mlist = new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { if(Some condition) { Intent i= new Intent(YourActivity.this,ActivityOne.class); ...
Here I've given an example assuming you have user list and clicking on item you want to show user profile... In List\_Act activity... ``` public View getView(int position, View convertView, ViewGroup parent) { convertView = mInflater.inflate(R.layout.rowitem,parent,false); convertView.setTag(UserId); } priv...
45,085,143
I have a simple OmniFaces 1.8.3 view-scoped bean **successfully deployed** on WebSphere 7 (7.0.50) along with OpenWebBeans 1.2.8 (and Mojarra 2.1.27 BTW): ``` import java.io.Serializable; import java.util.List; import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.inject.Named; import org.omnifac...
2017/07/13
[ "https://Stackoverflow.com/questions/45085143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/396732/" ]
Try this ```html private headers = new Headers({'Content-Type': 'application/json;'}); update(formModel): Promise<ShortFormModel> { let options: RequestOptions = new RequestOptions(); options.headers = this.headers; return this.http .post(this.preCheckUrl, JSON.stringify(formModel), options) .toP...
I feel very silly but the root cause was because I did not disable ``` InMemoryWebApiModule.forRoot(InMemoryDataService) ``` that I was using for dev before services were ready. The solution I went with is pretty much out of angular's tutorial: short-form.component ``` onSubmit(shortForm: any) { if (!shortForm...
33,118,889
I am trying to implement Google Analytics (GA) in my iOS apps. I have two different targets that have different tracking-ids for GA. GA requires a `GoogleService-Info.plist` (cannot be renamed) file to be placed in the root of the app folder structure. This file contains the tracking-id. However, since I have two diffe...
2015/10/14
[ "https://Stackoverflow.com/questions/33118889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/511299/" ]
**The script:** ``` PLIST_FILE="CustomGoogleService-Info.plist" PLIST_PATH="${PROJECT_DIR}/path/To/Plist/Here/${PLIST_FILE}" cp "${PLIST_PATH}" "${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/GoogleService-Info.plist" ``` Instructions: * Add this script to the end of your `Build Phases` * Change name `CustomGoo...
I did correctly all along, however `Destination` should be set to `Wrapper` and subpath empty. No need to have them in the target either. This one explained the Destination options: [xcode copy files build phase - what do the destination options mean exactly?](https://stackoverflow.com/questions/19156490/xcode-copy-f...
9,220,340
Im looking for a very general method of providing an alternative site to a Javascript heavy site (a link going to the old static site). My current implementation is: ``` //<Some JS/HTML> $(document).ready(function() { //<Some JS Code> $('#error').attr('style','display: none;'); }); //<Some html> <div id="erro...
2012/02/09
[ "https://Stackoverflow.com/questions/9220340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1130968/" ]
You can use mainly CSS with a JS helper for this. Put this JS code as close to the top of the document as you dare, preferibly after the charset declaration. You will need to include jQuery before this line or you can use standard JS (`document.getElementByID('html-tag').className='js';`, this assumes you've given the...
A simple solution would be to detect all incompatible browsers and show the message to upgrade their browser or to redirect to non js site, something like: ``` for IE5 and 6 if ($.browser.msie && $.browser.version <= 6){ //show my message here } ```
55,962,891
is there a way to refer to a specific column relative to a specific data frame in python like there is in R (data.frame$data)?
2019/05/03
[ "https://Stackoverflow.com/questions/55962891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11445124/" ]
Usually with `[]` => `data.frame["data"]` Or for object like with `.` => `data.frame.data`
You can generally use pandas to mimic R. You can use [] as below. my\_column = df['columnName']
391,104
I have some trouble with proper understanding of $H\_0^1(0,1)$ space. Consider the following space $$H\_D = \{u\in H^1(0,1): u(0) = u(1) = 0\}.$$ What can we say about the connection between $H\_D$ and $H^1\_0(0,1)$. Is $H\_D$ in $H^1\_0(0,1)$? In literature stays, that functions in $H\_0^1(0,l)$ are interpreted as $$'...
2013/05/14
[ "https://math.stackexchange.com/questions/391104", "https://math.stackexchange.com", "https://math.stackexchange.com/users/42857/" ]
Do you know anything about the [trace operator](http://en.wikipedia.org/wiki/Trace_%28Sobolev_space%29)? There is a theorem that says that if $U$ is a bounded domain and $\partial U$ is $C^1$ and $u \in W^{1,p}$, then $$ u \in W\_0^{1,p}(U) \iff Tu=0 \text{ on } \partial U, $$ where $T$ is the trace operator. You want...
In one-dimensions, Sobolev functions have a well-defined continuous representative. Therefore, they are well-defined at every point of their domain.
11,326,405
I'm using Django for our project. And I have created a form using Django forms. In one of the form i need to check a variable and based on the value of the variable i need to add or remove an element. I'm passing this variable to the form when the object is initialized. ie `form=MyForm(flag)` And in the forms class i...
2012/07/04
[ "https://Stackoverflow.com/questions/11326405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/513101/" ]
The `class` statement is an executable statement that: 1. creates a namespaces 2. execute, sequentially, all code at the top-level of the class statement block 3. call the appropriate metaclass (defaulting to `type`) with the classname, namespace, and list of parent classes 4. bind the newly created `class` object to ...
``` print MyInfoForm.myFlag ``` how abou this?
11,326,405
I'm using Django for our project. And I have created a form using Django forms. In one of the form i need to check a variable and based on the value of the variable i need to add or remove an element. I'm passing this variable to the form when the object is initialized. ie `form=MyForm(flag)` And in the forms class i...
2012/07/04
[ "https://Stackoverflow.com/questions/11326405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/513101/" ]
The `class` statement is an executable statement that: 1. creates a namespaces 2. execute, sequentially, all code at the top-level of the class statement block 3. call the appropriate metaclass (defaulting to `type`) with the classname, namespace, and list of parent classes 4. bind the newly created `class` object to ...
This depends... should the scope of flag be the class, or the instance of the class? If the scope should be the instance (this is what it seems like from your first try), then you access it by doing: ``` instance = MyInfoForm(flag) ... instance.flag ``` If, on the other hand, the variable flag belongs to the class ...
31,179,134
I have tried: ``` wx.ToolTip.Enable(False) wx.ToolTip_Enable(False) ``` and ``` wx.ToolTip.Enable(flag=False) ``` none of theses instructions are rejected and yet none of them work I'm using `Linux Mint 17` `wx.python 2.8.12.1 (gtk2-unicode)` `python 2.7`
2015/07/02
[ "https://Stackoverflow.com/questions/31179134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4637585/" ]
you need to echo the variable: ``` $scope.var = "<? echo $var; ?>" ``` or in a shorter way: ``` $scope.var = "<?=$var; ?>" ``` technicly both are the same.
I would suggest exposing a public API from your PHP application and then calling it using the [$http](https://docs.angularjs.org/api/ng/service/$http) service in angular-js. ``` $http.get('APIURL', {cache: true}) .success(function(data){...}) .error(function(data){}); ```
32,920,574
This should be something really simple but I just can't get it. I want to pass a particular field value to controller function through onclick by form submit. ``` <form action="<?php echo base_url();>data/pass" method="post"> <select name="name1" id="name1" onclick="" class="m-wrap" > <option sel...
2015/10/03
[ "https://Stackoverflow.com/questions/32920574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4899166/" ]
change your code like this ``` <form action="<?php echo base_url();?>data/pass" method="post"> <select name="name1" id="name1" onchange="this.form.submit()" class="m-wrap" > <option selected="selected" disabled="disabled">Select</option> <option value="1">by year</option> </select> ...
``` <form id="form-id" method="post"> <select name="name1" id="name1" class="m-wrap" > <option selected="selected" disabled="disabled">Select</option> <option value="1">by year</option> </select> <button type="submit" >Onclick</button> ...
2,090,654
I am attempting to setup a sample dynamic web project in Eclipse using Java EE, Spring and Maven (using Nexus repository manager). I was wondering if anybody knows the "best practice" directory structure that I should setup for an enterprise web app in Eclipse? Should I just stick with the default structure that is set...
2010/01/19
[ "https://Stackoverflow.com/questions/2090654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/253664/" ]
If you use Maven, I'd warmly recommend to just follow **Maven's convention**. This is the "best practice" in Maven's world (and I don't see any good reasons to not do so, not following this advice will lead to more work). One easy way to create a webapp project is to use the maven-archetype-webapp: ``` mvn archetype:...
If you're using Maven, it's best to follow [their convention](http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html). If you're using Spring, you don't need an EAR. A WAR will do just fine. A WAR file has a definite standard that you must follow. As long as you can generate a...
1,054,383
For several months, I have been successfully connected to the net via a static IP with my machine that is running ubuntu (16.04.3). I recently had to reinstall the OS, and now on the same machine, the system is ignoring my DNS settings. The DNS server hasn't changed, nor has the machine's static IP address changed. Fur...
2018/07/12
[ "https://askubuntu.com/questions/1054383", "https://askubuntu.com", "https://askubuntu.com/users/849049/" ]
Gnome3 disables the touchpad while typing by default. You can disable that feature using the gnome tweak tool. The entry for the touchpad is under *Keyboard & Mouse* in the tool. To get the tool either install it via `sudo apt install gnome-tweak-tool` in the terminal or search for `Gnome Tweaks` in the Ubuntu softwa...
Open a terminal and type this command: ``` gsettings set org.gnome.desktop.peripherals.touchpad "disable-while-typing" false ``` To disable again type: ``` gsettings set org.gnome.desktop.peripherals.touchpad "disable-while-typing" true ``` If you like a short form (alias), I suggest the following. The next 3 lin...
52,548,552
I am trying to run Selenium using python, and I was successful in starting the browser and entering user name and password, but I was not able to run xpath for login button. ``` Python Script import selenium from selenium import webdriver from selenium.webdriver.common.by import By ...
2018/09/28
[ "https://Stackoverflow.com/questions/52548552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8117146/" ]
The problem is not with your project, but with the PC you are trying to build it on. Maybe you have disabled updates, because apparently you still have Windows 10 Anniversary Update (14393) which is very old (current version is April 2018 Update (17134). To build apps with Fall Creators Update SDK (which is the first t...
Go to Solution explorer and double tap the properties [![enter image description here](https://i.stack.imgur.com/67F2W.png)](https://i.stack.imgur.com/67F2W.png) Then please select application options and select minimum build version based on your current OS build version. It works for me. [![enter image description...
6,007,463
In CreateFile() has DesiredAccess Like GENERIC\_READ, GENERIC\_WRITE, FILE\_READ\_ATTRIBUTES, etc. My question is what is the minimum/exact permissions needed to solely delete a file in the system? Thanks
2011/05/15
[ "https://Stackoverflow.com/questions/6007463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324827/" ]
If you just want to delete a file, use the [`DeleteFile`](http://msdn.microsoft.com/en-us/library/aa363915%28v=vs.85%29.aspx) function. It's documentation details what permissions you need, and a few things you should know, like: > > If you request delete permission at the time you create a file, you can delete or r...
You only need `DELETE` access, I believe. It's not a file access right, it's a standard access right. It's not easily found that these standard access rights are allowed, but the [MSDN page](http://msdn.microsoft.com/en-us/library/gg258116%28v=vs.85%29.aspx) on file access rights states: > > The valid access rights ...
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
``` DECLARE @cid INT, @o INT, @t NVARCHAR(255), @c NVARCHAR(MAX), @sql NVARCHAR(MAX); SELECT @cid = 10, @t = N'dbo.CTABLE', @o = OBJECT_ID(@t); SELECT @c = STRING_AGG(QUOTENAME(name), ',') FROM sys.columns WHERE [object_id] = @o AND is_identity = 0; SET @sql = '...
Try specifying the columns: ``` INSERT INTO CTABLE (col2, col3, col4) SELECT col2, col3, col4 FROM #t ``` Seems like it might be thinking you are trying to insert into the PK field since you are not explicitly defining the columns to insert into. If Identity insert is off and you specify the non-pk columns then you...
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
Try this: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid ALTER TABLE #t DROP COLUMN CID INSERT CTABLE --Notice that INTO is removed here. SELECT top(1) * FROM #t DROP TABLE #t ``` Test Script(Tested in SQL 2005): ``` CREATE TABLE #TestIDNT ( ID INT IDENTITY(1,1) PRIMARY KEY, TITLE VARCHAR(20) ) INSER...
If using SQL Server Management Studio and your problems you have too many fields to type them all out except the identity column, then right click on the table and click "Script table as" / "Select To" / "New Query Window". This will provide a list of fields that you can copy & paste into your own query and then just...
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
Try this: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid ALTER TABLE #t DROP COLUMN CID INSERT CTABLE --Notice that INTO is removed here. SELECT top(1) * FROM #t DROP TABLE #t ``` Test Script(Tested in SQL 2005): ``` CREATE TABLE #TestIDNT ( ID INT IDENTITY(1,1) PRIMARY KEY, TITLE VARCHAR(20) ) INSER...
Here's an example to dynamically build a list of columns - excluding the primary key columns - and execute the INSERT ``` declare @tablename nvarchar(100), @column nvarchar(100), @cid int, @sql nvarchar(max) set @tablename = N'ctable' set @cid = 1 set @sql = N'' declare example cursor for select column_name from i...
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
Here's an example to dynamically build a list of columns - excluding the primary key columns - and execute the INSERT ``` declare @tablename nvarchar(100), @column nvarchar(100), @cid int, @sql nvarchar(max) set @tablename = N'ctable' set @cid = 1 set @sql = N'' declare example cursor for select column_name from i...
Try invoking the INSERT statement with EXEC: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid ALTER TABLE #t DROP COLUMN CID EXEC('INSERT INTO CTABLE SELECT top(1) * FROM #t') DROP TABLE #t ```
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
``` DECLARE @cid INT, @o INT, @t NVARCHAR(255), @c NVARCHAR(MAX), @sql NVARCHAR(MAX); SELECT @cid = 10, @t = N'dbo.CTABLE', @o = OBJECT_ID(@t); SELECT @c = STRING_AGG(QUOTENAME(name), ',') FROM sys.columns WHERE [object_id] = @o AND is_identity = 0; SET @sql = '...
Try invoking the INSERT statement with EXEC: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid ALTER TABLE #t DROP COLUMN CID EXEC('INSERT INTO CTABLE SELECT top(1) * FROM #t') DROP TABLE #t ```
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
If using SQL Server Management Studio and your problems you have too many fields to type them all out except the identity column, then right click on the table and click "Script table as" / "Select To" / "New Query Window". This will provide a list of fields that you can copy & paste into your own query and then just...
You can't do this: ``` INSERT INTO CTABLE SELECT top(1) * FROM #t ``` Because the column listings aren't the same. You've dropped the PK column from #t, so you have 1 less column in #t than in CTABLE. This is the equivalent of the following: ``` INSERT INTO CTABLE(pk, col1, col2, col3, ...) select top(1) col1, co...
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
Here's an example to dynamically build a list of columns - excluding the primary key columns - and execute the INSERT ``` declare @tablename nvarchar(100), @column nvarchar(100), @cid int, @sql nvarchar(max) set @tablename = N'ctable' set @cid = 1 set @sql = N'' declare example cursor for select column_name from i...
You can't do this: ``` INSERT INTO CTABLE SELECT top(1) * FROM #t ``` Because the column listings aren't the same. You've dropped the PK column from #t, so you have 1 less column in #t than in CTABLE. This is the equivalent of the following: ``` INSERT INTO CTABLE(pk, col1, col2, col3, ...) select top(1) col1, co...
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
If using SQL Server Management Studio and your problems you have too many fields to type them all out except the identity column, then right click on the table and click "Script table as" / "Select To" / "New Query Window". This will provide a list of fields that you can copy & paste into your own query and then just...
Try invoking the INSERT statement with EXEC: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid ALTER TABLE #t DROP COLUMN CID EXEC('INSERT INTO CTABLE SELECT top(1) * FROM #t') DROP TABLE #t ```
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
Try this: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid ALTER TABLE #t DROP COLUMN CID INSERT CTABLE --Notice that INTO is removed here. SELECT top(1) * FROM #t DROP TABLE #t ``` Test Script(Tested in SQL 2005): ``` CREATE TABLE #TestIDNT ( ID INT IDENTITY(1,1) PRIMARY KEY, TITLE VARCHAR(20) ) INSER...
You can't do this: ``` INSERT INTO CTABLE SELECT top(1) * FROM #t ``` Because the column listings aren't the same. You've dropped the PK column from #t, so you have 1 less column in #t than in CTABLE. This is the equivalent of the following: ``` INSERT INTO CTABLE(pk, col1, col2, col3, ...) select top(1) col1, co...
6,949,864
My code: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid --get data, put into a temp table ALTER TABLE #t DROP COLUMN CID -- remove primary key column CID INSERT INTO CTABLE SELECT * FROM #t -- insert record to table DROP TABLE #t -- drop temp table ``` The error is: ```...
2011/08/04
[ "https://Stackoverflow.com/questions/6949864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/807463/" ]
Try this: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid ALTER TABLE #t DROP COLUMN CID INSERT CTABLE --Notice that INTO is removed here. SELECT top(1) * FROM #t DROP TABLE #t ``` Test Script(Tested in SQL 2005): ``` CREATE TABLE #TestIDNT ( ID INT IDENTITY(1,1) PRIMARY KEY, TITLE VARCHAR(20) ) INSER...
Try invoking the INSERT statement with EXEC: ``` SELECT * INTO #t FROM CTABLE WHERE CID = @cid ALTER TABLE #t DROP COLUMN CID EXEC('INSERT INTO CTABLE SELECT top(1) * FROM #t') DROP TABLE #t ```
19,707,436
I'm having trouble getting path substitution working correctly. I have a bunch of source files in `SOURCES`: ``` @echo $(SOURCES) foo.c bar.cpp bah.cxx ``` And I want a list of object files: ``` # Imaginary only because nothing works @echo $(OBJECTS) foo.o bar.o bah.o ``` I'm trying to build the list of `OBJECTS`...
2013/10/31
[ "https://Stackoverflow.com/questions/19707436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608639/" ]
Tom's answer is correct. Etan's will work too. A shorter solution would be: ``` $(addsuffix .o,$(basename $(SOURCES)) ```
If you have a filter-like function you can use that. Otherwise you can do it in stages: ``` SOURCES := foo.c bar.cpp bah.cxx O := $(SOURCES) $(info $(O)) O := $(patsubst %.c,%.o,$(O)) $(info $(O)) O := $(patsubst %.cpp,%.o,$(O)) $(info $(O)) O := $(patsubst %.cxx,%.o,$(O)) $(info $(O)) ``` The problem with your fir...
19,707,436
I'm having trouble getting path substitution working correctly. I have a bunch of source files in `SOURCES`: ``` @echo $(SOURCES) foo.c bar.cpp bah.cxx ``` And I want a list of object files: ``` # Imaginary only because nothing works @echo $(OBJECTS) foo.o bar.o bah.o ``` I'm trying to build the list of `OBJECTS`...
2013/10/31
[ "https://Stackoverflow.com/questions/19707436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608639/" ]
Tom's answer is correct. Etan's will work too. A shorter solution would be: ``` $(addsuffix .o,$(basename $(SOURCES)) ```
First, I don't think patsubst is portable. It is a GNU make feature. I think one answer to your question is nested subsitutions, like: ``` $(patsubst %c,%.o,$(patsubst %.cc,%.o,$(patsubst .....))) ```
32,925,134
I have an array like the one below: ``` $products = array(); $products["Archery"] = array( "name" => "Archery", "img" => "img/wire/100-Archery.jpg", "desc" => "Archer aiming to shoot", "prices" => array($price1,$price3), "paypal" => $paypal2, "sizes" => array($size1, $size2) ); $products["Arti...
2015/10/03
[ "https://Stackoverflow.com/questions/32925134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3842381/" ]
array yp\_next ( string $domain , string $map , string $key ) Returns the next key-value pair in the named map after the specified key. <http://php.net/manual/en/function.yp-next.php>
Sounds like what you need is javascript. It will be able to do the switch the products on the client side, so you can store the variable from a for loop and when the button is clicked, you can call a function to switch it to the next one
32,925,134
I have an array like the one below: ``` $products = array(); $products["Archery"] = array( "name" => "Archery", "img" => "img/wire/100-Archery.jpg", "desc" => "Archer aiming to shoot", "prices" => array($price1,$price3), "paypal" => $paypal2, "sizes" => array($size1, $size2) ); $products["Arti...
2015/10/03
[ "https://Stackoverflow.com/questions/32925134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3842381/" ]
array yp\_next ( string $domain , string $map , string $key ) Returns the next key-value pair in the named map after the specified key. <http://php.net/manual/en/function.yp-next.php>
You cannot do next() and prev() on an associative array. What you need is another array structure, like this: ``` $products = array(); $products[0] = array( "name" => "Archery", "img" => "img/wire/100-Archery.jpg", "desc" => "Archer aiming to shoot", "prices" => array($price1,$price3), "paypal" =>...
32,925,134
I have an array like the one below: ``` $products = array(); $products["Archery"] = array( "name" => "Archery", "img" => "img/wire/100-Archery.jpg", "desc" => "Archer aiming to shoot", "prices" => array($price1,$price3), "paypal" => $paypal2, "sizes" => array($size1, $size2) ); $products["Arti...
2015/10/03
[ "https://Stackoverflow.com/questions/32925134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3842381/" ]
You could traverse the array to find the current key, and then go one element more. A tested example: ``` $current_page = 'Artist'; // as an example $prev = $next = false; // the keys you're trying to find $last = false; // store the value of the last iteration in case the next element matches // flag if we've foun...
Sounds like what you need is javascript. It will be able to do the switch the products on the client side, so you can store the variable from a for loop and when the button is clicked, you can call a function to switch it to the next one
32,925,134
I have an array like the one below: ``` $products = array(); $products["Archery"] = array( "name" => "Archery", "img" => "img/wire/100-Archery.jpg", "desc" => "Archer aiming to shoot", "prices" => array($price1,$price3), "paypal" => $paypal2, "sizes" => array($size1, $size2) ); $products["Arti...
2015/10/03
[ "https://Stackoverflow.com/questions/32925134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3842381/" ]
Based on your array data you can use the following function. I used the array\_keys() function to make an array with only the keys of the initial array and all the work is done using the new array. ``` function custom_array_pagination($data = array()) { $current_page = 'Baseball-Bat-Swing'; //$current_page = $...
Sounds like what you need is javascript. It will be able to do the switch the products on the client side, so you can store the variable from a for loop and when the button is clicked, you can call a function to switch it to the next one
32,925,134
I have an array like the one below: ``` $products = array(); $products["Archery"] = array( "name" => "Archery", "img" => "img/wire/100-Archery.jpg", "desc" => "Archer aiming to shoot", "prices" => array($price1,$price3), "paypal" => $paypal2, "sizes" => array($size1, $size2) ); $products["Arti...
2015/10/03
[ "https://Stackoverflow.com/questions/32925134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3842381/" ]
You could traverse the array to find the current key, and then go one element more. A tested example: ``` $current_page = 'Artist'; // as an example $prev = $next = false; // the keys you're trying to find $last = false; // store the value of the last iteration in case the next element matches // flag if we've foun...
You cannot do next() and prev() on an associative array. What you need is another array structure, like this: ``` $products = array(); $products[0] = array( "name" => "Archery", "img" => "img/wire/100-Archery.jpg", "desc" => "Archer aiming to shoot", "prices" => array($price1,$price3), "paypal" =>...
32,925,134
I have an array like the one below: ``` $products = array(); $products["Archery"] = array( "name" => "Archery", "img" => "img/wire/100-Archery.jpg", "desc" => "Archer aiming to shoot", "prices" => array($price1,$price3), "paypal" => $paypal2, "sizes" => array($size1, $size2) ); $products["Arti...
2015/10/03
[ "https://Stackoverflow.com/questions/32925134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3842381/" ]
Based on your array data you can use the following function. I used the array\_keys() function to make an array with only the keys of the initial array and all the work is done using the new array. ``` function custom_array_pagination($data = array()) { $current_page = 'Baseball-Bat-Swing'; //$current_page = $...
You cannot do next() and prev() on an associative array. What you need is another array structure, like this: ``` $products = array(); $products[0] = array( "name" => "Archery", "img" => "img/wire/100-Archery.jpg", "desc" => "Archer aiming to shoot", "prices" => array($price1,$price3), "paypal" =>...
160,542
In a U-shaped tube, water and oil are separated by a movable membrane. What is the ratio of the heights $\frac{h1}{h2}$ (density of the oil $ρ\_{oil}$ = 0.92 $\frac{g}{cm^3}$)? ![enter image description here](https://i.stack.imgur.com/XnNYD.png) I tried solving by saying that the pressure at the membrane should be t...
2015/01/20
[ "https://physics.stackexchange.com/questions/160542", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/65843/" ]
Your friend is correct in that the net force on the membrane should be zero. And the force from each side of the membrane is the pressure times the area. The area of the membrane is the same on each side. It is not the case that one side of the membrane is of size $D$ and the other side is of size $d$. So his formula ...
$P\_1 =\gamma\_{water} \cdot h\_1$ $P\_2= \gamma\_{oil} \cdot h\_2$ $\gamma\_{water} \cdot h\_1 \cdot A = \gamma\_{oil} \cdot h\_2 \cdot A$ $\gamma\_{water} \cdot h\_1 = \gamma\_{oil} \cdot h\_2 $ $\frac{\gamma\_{water} \cdot h\_1} {\gamma\_{oil} \cdot h\_2} = 1$ $\frac{h\_1} {h\_2} = \frac{\gamma\_{oil}} {\gamma\...
13,526,280
I have a function in my object. I want to access this function's variable from another function.Can anyone help me? Here is my sample code. Any help would be greatly appreciated. Thanks. ``` var drops= { hoverClass: "hoverme", greedy: true, accept: "#mini", drop: function(event,ui){ var dr...
2012/11/23
[ "https://Stackoverflow.com/questions/13526280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755495/" ]
Create a common scope for both functions (function wrapper will do), and create a variable in the same scope, like so: ``` (function () { var x = 5, f1 = function(){ console.log(x); }, f2 = function(){ console.log(x); }; })(); ```
You cannot. Variables are scoped to the function in which they are declared. If you want to access a variable from two different functions you can declare it outside of both functions and access it from within them. For example: ``` var sharedVariable = 'something'; function a() { sharedVariable = 'a'; } function...
13,526,280
I have a function in my object. I want to access this function's variable from another function.Can anyone help me? Here is my sample code. Any help would be greatly appreciated. Thanks. ``` var drops= { hoverClass: "hoverme", greedy: true, accept: "#mini", drop: function(event,ui){ var dr...
2012/11/23
[ "https://Stackoverflow.com/questions/13526280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755495/" ]
Create a common scope for both functions (function wrapper will do), and create a variable in the same scope, like so: ``` (function () { var x = 5, f1 = function(){ console.log(x); }, f2 = function(){ console.log(x); }; })(); ```
To make a variable calculated in function A visible in function B, you have three choices: 1. make it a global, 2. make it an object property, or 3. pass it as a parameter when calling B from A. ``` function A() { var rand_num = calculate_random_number(); B(rand_num); } function B(r)...
17,105,624
I was wondering if it is possible to change CSS with a link. What I'm trying to do is I want to change the `display:none` so it shows the page and hides another so it looks like your going to another page but it's already been loaded. Is it possible? If it's possible with JavaScript or jQuery, how do I put it in HTML?...
2013/06/14
[ "https://Stackoverflow.com/questions/17105624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2485292/" ]
You could use `:target` pseudo-class I think. You could something like this: ``` <a href="#books">Show books</a> <a href="#tv">Show TV</a> <section id="books"></section> <section id="tv"></section> ``` And CSS: ``` section { display: none; } *:target { display: block; } ``` There are a few good examples on...
If you can use jQuery then you could do a very simple click event like below... `<a id="some_link" href="#">click here</a>` ``` $('#some_link').click(function(event){ event.preventDefault(); $('#page_two').show(); $('#page_one').hide(); }); ``` The prevent default is there to stop the link reloading ...
17,105,624
I was wondering if it is possible to change CSS with a link. What I'm trying to do is I want to change the `display:none` so it shows the page and hides another so it looks like your going to another page but it's already been loaded. Is it possible? If it's possible with JavaScript or jQuery, how do I put it in HTML?...
2013/06/14
[ "https://Stackoverflow.com/questions/17105624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2485292/" ]
You could use `:target` pseudo-class I think. You could something like this: ``` <a href="#books">Show books</a> <a href="#tv">Show TV</a> <section id="books"></section> <section id="tv"></section> ``` And CSS: ``` section { display: none; } *:target { display: block; } ``` There are a few good examples on...
You can easily change visibility with jQuery. To hide an element you can use [`hide()`](http://api.jquery.com/hide/). To make an element visible you can use [`show()`](http://api.jquery.com/show/). Or you can use [`toggle()`](http://api.jquery.com/toggle/) which simply toggles the visibility. If you have to change mo...
17,105,624
I was wondering if it is possible to change CSS with a link. What I'm trying to do is I want to change the `display:none` so it shows the page and hides another so it looks like your going to another page but it's already been loaded. Is it possible? If it's possible with JavaScript or jQuery, how do I put it in HTML?...
2013/06/14
[ "https://Stackoverflow.com/questions/17105624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2485292/" ]
You could use `:target` pseudo-class I think. You could something like this: ``` <a href="#books">Show books</a> <a href="#tv">Show TV</a> <section id="books"></section> <section id="tv"></section> ``` And CSS: ``` section { display: none; } *:target { display: block; } ``` There are a few good examples on...
In fact, despite the comments saying otherwise, there *are* ways of doing what you want in pure CSS. The best trick relies on having hidden radio buttons, and having the label for the radio button as the button that the user clicks. This could be styled as a button or a tab, or however else you want to present it. In...
17,105,624
I was wondering if it is possible to change CSS with a link. What I'm trying to do is I want to change the `display:none` so it shows the page and hides another so it looks like your going to another page but it's already been loaded. Is it possible? If it's possible with JavaScript or jQuery, how do I put it in HTML?...
2013/06/14
[ "https://Stackoverflow.com/questions/17105624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2485292/" ]
If you can use jQuery then you could do a very simple click event like below... `<a id="some_link" href="#">click here</a>` ``` $('#some_link').click(function(event){ event.preventDefault(); $('#page_two').show(); $('#page_one').hide(); }); ``` The prevent default is there to stop the link reloading ...
You can easily change visibility with jQuery. To hide an element you can use [`hide()`](http://api.jquery.com/hide/). To make an element visible you can use [`show()`](http://api.jquery.com/show/). Or you can use [`toggle()`](http://api.jquery.com/toggle/) which simply toggles the visibility. If you have to change mo...
17,105,624
I was wondering if it is possible to change CSS with a link. What I'm trying to do is I want to change the `display:none` so it shows the page and hides another so it looks like your going to another page but it's already been loaded. Is it possible? If it's possible with JavaScript or jQuery, how do I put it in HTML?...
2013/06/14
[ "https://Stackoverflow.com/questions/17105624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2485292/" ]
If you can use jQuery then you could do a very simple click event like below... `<a id="some_link" href="#">click here</a>` ``` $('#some_link').click(function(event){ event.preventDefault(); $('#page_two').show(); $('#page_one').hide(); }); ``` The prevent default is there to stop the link reloading ...
In fact, despite the comments saying otherwise, there *are* ways of doing what you want in pure CSS. The best trick relies on having hidden radio buttons, and having the label for the radio button as the button that the user clicks. This could be styled as a button or a tab, or however else you want to present it. In...
17,105,624
I was wondering if it is possible to change CSS with a link. What I'm trying to do is I want to change the `display:none` so it shows the page and hides another so it looks like your going to another page but it's already been loaded. Is it possible? If it's possible with JavaScript or jQuery, how do I put it in HTML?...
2013/06/14
[ "https://Stackoverflow.com/questions/17105624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2485292/" ]
You can easily change visibility with jQuery. To hide an element you can use [`hide()`](http://api.jquery.com/hide/). To make an element visible you can use [`show()`](http://api.jquery.com/show/). Or you can use [`toggle()`](http://api.jquery.com/toggle/) which simply toggles the visibility. If you have to change mo...
In fact, despite the comments saying otherwise, there *are* ways of doing what you want in pure CSS. The best trick relies on having hidden radio buttons, and having the label for the radio button as the button that the user clicks. This could be styled as a button or a tab, or however else you want to present it. In...
72,447,284
I'm trying to write some python to listen to signals. Using dbus-monitor, as shown below, I can filter the signals I want. ``` dbus-monitor "type='signal',sender='org.kde.KWin',path='/ColorCorrect',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'" signal time=1653997355.732016 sender=:1.4 -> de...
2022/05/31
[ "https://Stackoverflow.com/questions/72447284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18704408/" ]
Try this In your student model ``` public function state() { return $this->belongsTo(State::class, 'state_id'); } ``` now you can fetch student details with the state ``` public function show($id) { $student = Student::with('state')->find($id); //for access the state name //$student->state->state_...
Maybe this helps you: Students.php ``` <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class Student extends Model { use HasFactory; protected $fillable = ["id", "name", "state_id"]; public function state() { retur...
72,447,284
I'm trying to write some python to listen to signals. Using dbus-monitor, as shown below, I can filter the signals I want. ``` dbus-monitor "type='signal',sender='org.kde.KWin',path='/ColorCorrect',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'" signal time=1653997355.732016 sender=:1.4 -> de...
2022/05/31
[ "https://Stackoverflow.com/questions/72447284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18704408/" ]
Student Modal ``` <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Student extends Model { public function state() { return $this->belongsTo( State::class ); } } ``` Get Students With State ``` $students = Student::query()->with( 'state' )->get() ``` Search Students...
Maybe this helps you: Students.php ``` <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class Student extends Model { use HasFactory; protected $fillable = ["id", "name", "state_id"]; public function state() { retur...
72,447,284
I'm trying to write some python to listen to signals. Using dbus-monitor, as shown below, I can filter the signals I want. ``` dbus-monitor "type='signal',sender='org.kde.KWin',path='/ColorCorrect',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'" signal time=1653997355.732016 sender=:1.4 -> de...
2022/05/31
[ "https://Stackoverflow.com/questions/72447284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18704408/" ]
Student Modal ``` <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Student extends Model { public function state() { return $this->belongsTo( State::class ); } } ``` Get Students With State ``` $students = Student::query()->with( 'state' )->get() ``` Search Students...
Try this In your student model ``` public function state() { return $this->belongsTo(State::class, 'state_id'); } ``` now you can fetch student details with the state ``` public function show($id) { $student = Student::with('state')->find($id); //for access the state name //$student->state->state_...
1,812,249
Are there any storage optimized [Sparse Matrix](http://en.wikipedia.org/wiki/Sparse_matrix) implementations in C#?
2009/11/28
[ "https://Stackoverflow.com/questions/1812249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147141/" ]
There is [Math.NET](http://www.mathdotnet.com/). It has some Spare Matrix [implementations](http://nmath.sourceforge.net/doc/numerics/MathNet.Numerics.LinearAlgebra.Sparse.html). (link is to the old Math.NET site. There is no longer an online version of the documentation).
If you are looking for high performance sparse matrix implementation check out [NMath](http://www.centerspace.net) from CenterSpace software. Here's a partial list of functionality cut from [here](http://www.centerspace.net/products/nmath/) on CenterSpace's website. * Full-featured structured sparse matrix classes, ...
14,977,613
Using python boto, how can I modify Http Headers? In my S3 bucket I have a file with name "shop" and since I upload it without file extension, I have to manually set the Http Header: ContentType = text/html I want to use a python script using boto to set this header for all files that require this. However I cannot f...
2013/02/20
[ "https://Stackoverflow.com/questions/14977613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/857848/" ]
``` import boto from boto.s3.connection import S3Connection from boto.s3.key import Key ak = " ... key" sk = " ... key" bucketname = " ... " c = S3Connection(ak, sk) def setcontenttype(): c = S3Connection(ak, sk) bucket = c.get_bucket(bucketname) keys = bucket.get_all_keys() for key in keys: ...
``` s3_conn = S3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) bucket = s3_conn.get_bucket(s3_bucket_name) keys = bucket.list() for key in keys: key = bucket.get_key(key.name) metadata = key.metadata metadata['Content-Type'] = "text/html" key.copy(s3_bucket_name, key, metadata=metadata, preserv...
56,642,468
I'm using `Reactive Forms` and I want to convert the value of `formGroup` into Model class object. Please give me some solutions for it. and also I want to send only `password` fields not `confirmPasword`. I also mentioned my model class . Service.ts ``` objRegisterModel: RegisterModel = new RegisterModel(); construc...
2019/06/18
[ "https://Stackoverflow.com/questions/56642468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8923126/" ]
As simple as this: ``` objRegisterModel: RegisterModel = this.formModel.value ``` **vote up** the answers that helped you the most! If these answers were helpful to you
First and foremost, instead of using a Class for defining `RegisterModel`, I would recommend you to use an Interface instead. ``` export interface RegisterModel { Active: number; Address: string; Amt: number; CityID: number; Country: string; EmailID: string; FullName: string; ID: number; PhoneNo: str...
56,642,468
I'm using `Reactive Forms` and I want to convert the value of `formGroup` into Model class object. Please give me some solutions for it. and also I want to send only `password` fields not `confirmPasword`. I also mentioned my model class . Service.ts ``` objRegisterModel: RegisterModel = new RegisterModel(); construc...
2019/06/18
[ "https://Stackoverflow.com/questions/56642468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8923126/" ]
As simple as this: ``` objRegisterModel: RegisterModel = this.formModel.value ``` **vote up** the answers that helped you the most! If these answers were helpful to you
Well, your model class don't have all the fields as in form. I consider it as your mistake, you should add all fields in the model then make and use some mapping function like ``` mapping(group: FormGroup){ Object.keys(group.control).forEach(key =>{ const abstractControl = group.get(key); if(abstractControl && abstrac...
15,899
I am often the driver for friends and family whenever we travel, whether short or long distances. This is mostly due to the fact that I have the best track record, reflexes, judgement, etc. on the road and am generally happy to do it. I am not against passengers making/answering phone calls while I am driving, but I do...
2018/06/26
[ "https://interpersonal.stackexchange.com/questions/15899", "https://interpersonal.stackexchange.com", "https://interpersonal.stackexchange.com/users/5253/" ]
"How can I get my passengers to see things my way, and keep their phone calls short?" Since you've already asked them to keep it short, after the call goes on for five minutes, carefully exit the highway and pull over the car. Then just wait quietly for them to finish, maybe even get out and talk a short walk. This ac...
I worked once in a small room with a bunch of other people. Needless to say, phone calls were a huge distraction to the others in the room. I decided that I wouldn't say anything about it. However, I would (unless it was their boss), make it hard for them to continue with a personal call in such a small space. Witho...
15,899
I am often the driver for friends and family whenever we travel, whether short or long distances. This is mostly due to the fact that I have the best track record, reflexes, judgement, etc. on the road and am generally happy to do it. I am not against passengers making/answering phone calls while I am driving, but I do...
2018/06/26
[ "https://interpersonal.stackexchange.com/questions/15899", "https://interpersonal.stackexchange.com", "https://interpersonal.stackexchange.com/users/5253/" ]
**What's rude is subjective, so focus on the fact that it is a distraction to you.** Everyone can agree that it's very important that the driver focuses on driving! (whereas many people become upset when you accuse them of being rude - as you have already experienced to some degree.) So frame your request as a safety ...
I worked once in a small room with a bunch of other people. Needless to say, phone calls were a huge distraction to the others in the room. I decided that I wouldn't say anything about it. However, I would (unless it was their boss), make it hard for them to continue with a personal call in such a small space. Witho...
15,899
I am often the driver for friends and family whenever we travel, whether short or long distances. This is mostly due to the fact that I have the best track record, reflexes, judgement, etc. on the road and am generally happy to do it. I am not against passengers making/answering phone calls while I am driving, but I do...
2018/06/26
[ "https://interpersonal.stackexchange.com/questions/15899", "https://interpersonal.stackexchange.com", "https://interpersonal.stackexchange.com/users/5253/" ]
You are in control in this situation. You're doing them a favor by driving, so you have some say in what happens in the car. As such, set the ground rules before they have a chance to pickup the phone. If this issue is serious enough that you're bringing it to IPS, I'm going to assume this happens fairly often and you...
I worked once in a small room with a bunch of other people. Needless to say, phone calls were a huge distraction to the others in the room. I decided that I wouldn't say anything about it. However, I would (unless it was their boss), make it hard for them to continue with a personal call in such a small space. Witho...
18,141,042
Problem: > > Write 0b11001001 in decimal. > > > I tried the following: > > 110010012 = 1 + 8 + 64 + 128 = 201 > > > but the answer is –55. Where am I going wrong?
2013/08/09
[ "https://Stackoverflow.com/questions/18141042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2460890/" ]
Your answer is *correct* providing that the *underlying data type* is **unsigned byte**. If the type is a **signed byte**, then it is of range [-128..127]. You've got 201 which is *out of range* [0..127], so 201 should be interpreted as a *negative value*. In order to find out a corresponging negative value you should ...
I'm assuming this is a homework problem or test question? If a string of bits represents an integer, it can be interpreted as either signed (in which case the value can be positive, zero, or negative) or unsigned (in which case it's only positive or zero.) In this instance, you provided the correct answer for an unsig...
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
material-ui's select component uses the mouseDown event to trigger the popover menu to appear. If you use `fireEvent.mouseDown` that should trigger the popover and then you can click your selection within the listbox that appears. see example below. ``` import React from "react"; import { render, fireEvent, within } f...
Using Material UI 5.10.3, this is how to simulate a click on the `Select` component, and to subsequently grab/verify the item values, and to click one of them to trigger the underlying change event: ``` import { fireEvent, render, screen, within } from '@testing-library/react'; import { MenuItem, Select } from '@mui/m...
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
This turns out to be super complicated when you are using Material-UI's `Select` with `native={false}` (which is the default). This is because the rendered input doesn't even have a `<select>` HTML element, but is instead a mix of divs, a hidden input, and some svgs. Then, when you click on the select, a presentation l...
This is what worked for me while using MUI 5. ``` userEvent.click(screen.getByLabelText(/^foo/i)); userEvent.click(screen.getByRole('option', {name: /^bar/i})); ```
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
### Using `*ByLabelText()` #### Component ```js // demo.js import * as React from "react"; import Box from "@mui/material/Box"; import InputLabel from "@mui/material/InputLabel"; import MenuItem from "@mui/material/MenuItem"; import FormControl from "@mui/material/FormControl"; import Select from "@mui/material/Selec...
This is what worked for me while using MUI 5. ``` userEvent.click(screen.getByLabelText(/^foo/i)); userEvent.click(screen.getByRole('option', {name: /^bar/i})); ```
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
Using Material UI 5.10.3, this is how to simulate a click on the `Select` component, and to subsequently grab/verify the item values, and to click one of them to trigger the underlying change event: ``` import { fireEvent, render, screen, within } from '@testing-library/react'; import { MenuItem, Select } from '@mui/m...
This is what worked for me while using MUI 5. ``` userEvent.click(screen.getByLabelText(/^foo/i)); userEvent.click(screen.getByRole('option', {name: /^bar/i})); ```
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
material-ui's select component uses the mouseDown event to trigger the popover menu to appear. If you use `fireEvent.mouseDown` that should trigger the popover and then you can click your selection within the listbox that appears. see example below. ``` import React from "react"; import { render, fireEvent, within } f...
I have done with multiple Select in one page, try this one: ``` import { render, fireEvent, within } from '@testing-library/react' it('Should trigger select-xxx methiod', () => { const { getByTestId, getByRole: getByRoleParent } = component const element = getByTestId('select-xxx'); const { getByRole } = withi...
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
Here is a working example for MUI TextField with Select option. Sandbox: <https://codesandbox.io/s/stupefied-chandrasekhar-vq2x0?file=/src/__tests__/TextSelect.test.tsx:0-1668> Textfield: ``` import { TextField, MenuItem, InputAdornment } from "@material-ui/core"; import { useState } from "react"; export const samp...
For people who have multiple Selects, make sure to add the `name` prop ``` <SelectDropdown name="date_range" ... > ... </SelectDropdown> <SelectDropdown name="company" ... > ... </SelectD...
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
Here is a working example for MUI TextField with Select option. Sandbox: <https://codesandbox.io/s/stupefied-chandrasekhar-vq2x0?file=/src/__tests__/TextSelect.test.tsx:0-1668> Textfield: ``` import { TextField, MenuItem, InputAdornment } from "@material-ui/core"; import { useState } from "react"; export const samp...
Using Material UI 5.10.3, this is how to simulate a click on the `Select` component, and to subsequently grab/verify the item values, and to click one of them to trigger the underlying change event: ``` import { fireEvent, render, screen, within } from '@testing-library/react'; import { MenuItem, Select } from '@mui/m...
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
This turns out to be super complicated when you are using Material-UI's `Select` with `native={false}` (which is the default). This is because the rendered input doesn't even have a `<select>` HTML element, but is instead a mix of divs, a hidden input, and some svgs. Then, when you click on the select, a presentation l...
Here is a working example for MUI TextField with Select option. Sandbox: <https://codesandbox.io/s/stupefied-chandrasekhar-vq2x0?file=/src/__tests__/TextSelect.test.tsx:0-1668> Textfield: ``` import { TextField, MenuItem, InputAdornment } from "@material-ui/core"; import { useState } from "react"; export const samp...
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
Using Material UI 5.10.3, this is how to simulate a click on the `Select` component, and to subsequently grab/verify the item values, and to click one of them to trigger the underlying change event: ``` import { fireEvent, render, screen, within } from '@testing-library/react'; import { MenuItem, Select } from '@mui/m...
``` import * as React from "react"; import ReactDOM from 'react-dom'; import * as TestUtils from 'react-dom/test-utils'; import { } from "mocha"; import Select from "@material-ui/core/Select"; import MenuItem from "@material-ui/core/MenuItem"; let container; beforeEach(() => { container = document.createElement(...
55,184,079
I'm trying to compile a python file into an APK using buildozer. After installing all dependencies (including SDK and NDK) and running `buildozer android deploy run`, I get the following error: ``` /home/caliph/.buildozer/android/platform/android-sdk Exception in thread "main" java.lang.NoClassDefFoundError: javax/xm...
2019/03/15
[ "https://Stackoverflow.com/questions/55184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11195319/" ]
This turns out to be super complicated when you are using Material-UI's `Select` with `native={false}` (which is the default). This is because the rendered input doesn't even have a `<select>` HTML element, but is instead a mix of divs, a hidden input, and some svgs. Then, when you click on the select, a presentation l...
I have done with multiple Select in one page, try this one: ``` import { render, fireEvent, within } from '@testing-library/react' it('Should trigger select-xxx methiod', () => { const { getByTestId, getByRole: getByRoleParent } = component const element = getByTestId('select-xxx'); const { getByRole } = withi...
42,469,945
I have two input boxes on my form. One is a dropdown select and the other is the textbox. I need to update the textbox value depending on what is chosen on the select box. For example, if I choose "1" on select box, the textbox value should have "299.00" and if I choose "2", the textbox value should be "399.0" Can yo...
2017/02/26
[ "https://Stackoverflow.com/questions/42469945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7415564/" ]
To get int value from user user: ``` int a; scanf("%d",&a); ``` scanf uses different specifiers: %d integer %f Float %d double %c char
The \* tells scanf to read in but ignore the input. Take a look at <http://www.cplusplus.com/reference/cstdio/scanf/> . why it always prints 67 you might need to step through a debugger to see what the int is initialized with and how that changes.
42,469,945
I have two input boxes on my form. One is a dropdown select and the other is the textbox. I need to update the textbox value depending on what is chosen on the select box. For example, if I choose "1" on select box, the textbox value should have "299.00" and if I choose "2", the textbox value should be "399.0" Can yo...
2017/02/26
[ "https://Stackoverflow.com/questions/42469945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7415564/" ]
To get int value from user user: ``` int a; scanf("%d",&a); ``` scanf uses different specifiers: %d integer %f Float %d double %c char
In the above program, the `scanf()` reads but does not assign the value due to the `*` format specifier. As a result, whatever is the value of a (which is not initialized) is produced as output by `printf()`. In this case, 67 is the garbage value.
42,469,945
I have two input boxes on my form. One is a dropdown select and the other is the textbox. I need to update the textbox value depending on what is chosen on the select box. For example, if I choose "1" on select box, the textbox value should have "299.00" and if I choose "2", the textbox value should be "399.0" Can yo...
2017/02/26
[ "https://Stackoverflow.com/questions/42469945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7415564/" ]
To get int value from user user: ``` int a; scanf("%d",&a); ``` scanf uses different specifiers: %d integer %f Float %d double %c char
Use correct format specifiers for their respective data types ``` float %f double %lf int %d or %i unsigned int %u char %c char * %s long int %ld long long int %lld ```
42,469,945
I have two input boxes on my form. One is a dropdown select and the other is the textbox. I need to update the textbox value depending on what is chosen on the select box. For example, if I choose "1" on select box, the textbox value should have "299.00" and if I choose "2", the textbox value should be "399.0" Can yo...
2017/02/26
[ "https://Stackoverflow.com/questions/42469945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7415564/" ]
In the above program, the `scanf()` reads but does not assign the value due to the `*` format specifier. As a result, whatever is the value of a (which is not initialized) is produced as output by `printf()`. In this case, 67 is the garbage value.
The \* tells scanf to read in but ignore the input. Take a look at <http://www.cplusplus.com/reference/cstdio/scanf/> . why it always prints 67 you might need to step through a debugger to see what the int is initialized with and how that changes.