id
int64
4
73.8M
title
stringlengths
10
150
body
stringlengths
17
50.8k
accepted_answer_id
int64
7
73.8M
answer_count
int64
1
182
comment_count
int64
0
89
community_owned_date
stringlengths
23
27
creation_date
stringlengths
23
27
favorite_count
int64
0
11.6k
last_activity_date
stringlengths
23
27
last_edit_date
stringlengths
23
27
last_editor_display_name
stringlengths
2
29
last_editor_user_id
int64
-1
20M
owner_display_name
stringlengths
1
29
owner_user_id
int64
1
20M
parent_id
null
post_type_id
int64
1
1
score
int64
-146
26.6k
tags
stringlengths
1
125
view_count
int64
122
11.6M
answer_body
stringlengths
19
51k
1,324,067
How do I get str.translate to work with Unicode strings?
<p>I have the following code:</p> <pre><code>import string def translate_non_alphanumerics(to_translate, translate_to='_'): not_letters_or_digits = u'!"#%\'()*+,-./:;&lt;=&gt;?@[\]^_`{|}~' translate_table = string.maketrans(not_letters_or_digits, translate_to ...
1,324,114
7
2
null
2009-08-24 18:52:52.833 UTC
18
2019-12-12 22:30:47.99 UTC
null
null
null
null
4,766
null
1
56
python|unicode|string
34,909
<p>The Unicode version of translate requires a mapping from Unicode ordinals (which you can retrieve for a single character with <a href="https://docs.python.org/2/library/functions.html#ord" rel="noreferrer"><code>ord</code></a>) to Unicode ordinals. If you want to delete characters, you map to <code>None</code>.</p> ...
394,767
Pointer Arithmetic
<p>Does anyone have any good articles or explanations (blogs, examples) for pointer arithmetic? Figure the audience is a bunch of Java programmers learning C and C++.</p>
394,774
7
1
null
2008-12-27 07:10:39.027 UTC
38
2012-11-04 23:01:48.467 UTC
2009-02-17 20:26:14.873 UTC
starblue
49,246
ak
4,653
null
1
60
c|pointers|pointer-arithmetic
104,178
<p>First, the <a href="http://cslibrary.stanford.edu/104/" rel="noreferrer">binky</a> video may help. It's a nice video about pointers. For arithmetic, here is an example:</p> <pre><code>int * pa = NULL; int * pb = NULL; pa += 1; // pa++. behind the scenes, add sizeof(int) bytes assert((pa - pb) == 1); print_out(pa);...
346,721
LINQ for Java tool
<p>Would a LINQ for java be a useful tool? I have been working on a tool that will allow a Java object to map to a row in a database. </p> <ol> <li>Would this be useful for Java programmers? </li> <li>What features would be useful?</li> </ol>
346,735
8
2
null
2008-12-06 20:23:58.08 UTC
13
2019-08-19 20:19:17.093 UTC
2010-05-31 09:33:46.96 UTC
Milhous
63,550
Milhous
17,712
null
1
40
java|sql|mysql|linq
21,191
<p>LINQ for Java would be lovely, but the problem is the language integration.</p> <p>Java doesn't have anything as concise as lambda expressions, and they're one of the bedrocks of LINQ. I suppose they <em>could</em> layer the query expression support on top of normal Java without lambda expressions, by making the ex...
630,306
iPhone REST client
<p>Does anybody know is there any good library for iPhone SDK to call REST web service. I want to have something simple like <a href="http://github.com/adamwiggins/rest-client/tree/master" rel="noreferrer">Heroku rest client</a></p> <hr> <p>Thx everybody for help.</p> <p>My server side is on Rails so looks like Obje...
633,570
9
0
null
2009-03-10 14:00:22.54 UTC
22
2012-07-17 12:04:22.777 UTC
2012-07-17 12:04:22.777 UTC
null
50,776
Aler
76,146
null
1
22
iphone|web-services|rest
45,679
<p>In case your REST service is implemented in Ruby on Rails, the open source ObjectiveResource project is looking very promising. It has been working great for me in a relatively complex project of mine, and I've even contributed some code back to them.</p> <p><a href="http://iphoneonrails.com/" rel="nofollow norefe...
287,097
Inventory database design
<p>This is a question not really about "programming" (is not specific to any language or database), but more of design and architecture. It's also a question of the type "What the best way to do X". I hope does no cause to much "religious" controversy.</p> <p>In the past I have developed systems that in one way or ano...
287,119
12
1
null
2008-11-13 14:38:52.14 UTC
55
2016-07-01 05:58:24.667 UTC
2013-05-30 06:37:43.777 UTC
Rob
474,597
nmarmol
20,448
null
1
79
database|inventory
50,168
<p>I have seen both approaches at my current company and would definitely lean towards the first (calculating totals based on stock transactions).</p> <p>If you are only storing a total quantity in a field somewhere, you have no idea how you arrived at that number. There is no transactional history and you can end up ...
575,196
Why can a function modify some arguments as perceived by the caller, but not others?
<p>I'm trying to understand Python's approach to variable scope. In this example, why is <code>f()</code> able to alter the value of <code>x</code>, as perceived within <code>main()</code>, but not the value of <code>n</code>?</p> <pre><code>def f(n, x): n = 2 x.append(4) print('In f():', n, x) def main()...
575,337
13
2
null
2009-02-22 16:42:51.457 UTC
119
2022-09-14 15:09:28.65 UTC
2018-09-25 17:17:06.713 UTC
J.F. Sebastian
1,222,951
Monty Hindman
55,857
null
1
242
python
213,294
<p>Some answers contain the word &quot;copy&quot; in the context of a function call. I find it confusing.</p> <p><strong>Python doesn't copy <em>objects</em> you pass during a function call <em>ever</em>.</strong></p> <p>Function parameters are <em>names</em>. When you call a function, Python binds these parameters to ...
420,791
What is a good use case for static import of methods?
<p>Just got a review comment that my static import of the method was not a good idea. The static import was of a method from a DA class, which has mostly static methods. So in middle of the business logic I had a da activity that apparently seemed to belong to the current class:</p> <pre><code>import static some.packag...
421,127
16
2
null
2009-01-07 15:46:02.387 UTC
50
2021-07-29 07:21:00.49 UTC
2021-07-29 07:21:00.49 UTC
Hemal Pandya
2,049,986
Hemal Pandya
18,573
null
1
154
java|static-import
106,226
<p>This is from Sun's guide when they released the feature (emphasis in original):</p> <blockquote> <p>So when should you use static import? <strong>Very sparingly!</strong> Only use it when you'd otherwise be tempted to declare local copies of constants, or to abuse inheritance (the Constant Interface Antipattern)....
991,489
file.delete() returns false even though file.exists(), file.canRead(), file.canWrite(), file.canExecute() all return true
<p>I'm trying to delete a file, after writing something in it, with <code>FileOutputStream</code>. This is the code I use for writing:</p> <pre><code>private void writeContent(File file, String fileContent) { FileOutputStream to; try { to = new FileOutputStream(file); to.write(fileContent.getBy...
991,573
17
11
null
2009-06-13 20:51:15.397 UTC
34
2019-02-20 02:15:01.68 UTC
2017-07-14 09:44:00.163 UTC
null
360,899
null
118,485
null
1
91
java|file|fileoutputstream
182,930
<p>It was pretty odd the trick that worked. The thing is when I have previously read the content of the file, I used <code>BufferedReader</code>. After reading, I closed the buffer.</p> <p>Meanwhile I switched and now I'm reading the content using <code>FileInputStream</code>. Also after finishing reading I close the ...
388,490
How to use unicode characters in Windows command line?
<p>We have a project in Team Foundation Server (TFS) that has a non-English character (š) in it. When trying to script a few build-related things we've stumbled upon a problem - we can't pass the <strong>š</strong> letter to the command-line tools. The command prompt or what not else messes it up, and the <strong>tf.ex...
47,843,552
19
5
null
2008-12-23 09:30:59.323 UTC
183
2022-06-06 07:35:22.97 UTC
2017-12-22 09:06:01.853 UTC
null
960,875
Vilx-
41,360
null
1
346
unicode|command-line|input|windows-console
520,436
<p>My background: I use Unicode input/output in a console for years (and do it a lot daily. Moreover, I develop support tools for exactly this task). There are very few problems, as far as you understand the following facts/limitations:</p> <ul> <li><code>CMD</code> and “console” are unrelated factors. <code>CMD.exe<...
36,901
What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
<p>What do <code>*args</code> and <code>**kwargs</code> mean?</p> <pre><code>def foo(x, y, *args): def bar(x, y, **kwargs): </code></pre>
36,908
24
6
null
2008-08-31 15:04:35.35 UTC
1,264
2022-07-30 19:05:07.813 UTC
2022-04-01 01:47:59.543 UTC
null
365,102
Todd Tingen
2,572
null
1
3,111
python|syntax|parameter-passing|variadic-functions|argument-unpacking
1,140,986
<p>The <code>*args</code> and <code>**kwargs</code> is a common idiom to allow arbitrary number of arguments to functions as described in the section <a href="http://docs.python.org/3/tutorial/controlflow.html#more-on-defining-functions" rel="noreferrer">more on defining functions</a> in the Python documentation.</p> <...
373,449
What Simple Changes Made the Biggest Improvements to Your Delphi Programs
<p>I have a Delphi 2009 program that handles a lot of data and needs to be as fast as possible and not use too much memory.</p> <p>What <strong>small simple</strong> changes have you made to your Delphi code that had the biggest impact on the performance of your program by noticeably reducing execution time or memory ...
1,198,694
35
6
2009-04-21 16:10:07.32 UTC
2008-12-17 02:00:47.867 UTC
32
2015-11-29 17:46:29.19 UTC
2013-09-05 01:28:57.157 UTC
lkessler
30,176
lkessler
30,176
null
1
28
performance|delphi|memory
8,722
<p>The biggest improvement came when I started using AsyncCalls to convert single-threaded applications that used to freeze up the UI, into (sort of) multi-threaded apps.</p> <p>Although AsyncCalls can do a lot more, I've found it useful for this very simple purpose. Let's say you have a subroutine blocked like this:...
6,589,814
What is the difference between dict and collections.defaultdict?
<p>I was checking out Peter Norvig's <a href="http://norvig.com/spell-correct.html">code</a> on how to write simple spell checkers. At the beginning, he uses this code to insert words into a dictionary.</p> <pre><code>def train(features): model = collections.defaultdict(lambda: 1) for f in features: mo...
6,589,839
4
4
null
2011-07-05 23:02:10.503 UTC
12
2021-12-30 18:49:31.81 UTC
null
null
null
null
184,046
null
1
55
python|dictionary
34,440
<p>The difference is that a <code>defaultdict</code> will "default" a value if that key has not been set yet. If you didn't use a <code>defaultdict</code> you'd have to check to see if that key exists, and if it doesn't, set it to what you want.</p> <p>The lambda is defining a factory for the default value. That funct...
6,501,234
GAE: best practices for storing secret keys?
<p>Are there any non-terrible ways of storing secret keys for Google App Engine? Or, at least, less terrible than checking them into source control?</p>
6,513,473
6
1
null
2011-06-28 03:26:56.36 UTC
10
2020-05-02 15:30:34.44 UTC
2011-06-28 05:20:29.993 UTC
null
71,522
null
71,522
null
1
39
security|google-app-engine
12,548
<p>Not exactly an answer:</p> <ul> <li>If you keep keys in the model, anyone who can deploy can read the keys from the model, and deploy again to cover their tracks. While Google lets you download code (unless you disable this feature), I think it only keeps the latest copy of each numbered version.</li> <li>If you ke...
6,431,026
Generating JPA2 Metamodel from a Gradle build script
<p>I'm trying to set up a Gradle build script for a new project. That project will use JPA 2 along with <a href="http://www.querydsl.com/" rel="noreferrer">Querydsl</a>.</p> <p>On the <a href="http://source.mysema.com/static/querydsl/2.1.2/reference/html/ch02s02.html" rel="noreferrer">following page of Querydsl's refe...
6,447,481
7
0
null
2011-06-21 19:39:08.043 UTC
12
2016-04-20 15:11:20.97 UTC
null
null
null
null
226,630
null
1
21
gradle|apt|querydsl
14,766
<p>I did not test it but this should work:</p> <pre><code>repositories { mavenCentral() } apply plugin: 'java' dependencies { compile(group: 'com.mysema.querydsl', name: 'querydsl-apt', version: '1.8.4') compile(group: 'com.mysema.querydsl', name: 'querydsl-jpa', version: '1.8.4') compile(group: 'org.slf4...
6,921,105
Given a filesystem path, is there a shorter way to extract the filename without its extension?
<p>I program in WPF C#. I have e.g. the following path:</p> <pre><code>C:\Program Files\hello.txt </code></pre> <p>and I want to extract <strong><code>hello</code></strong> from it. </p> <p>The path is a <code>string</code> retrieved from a database. Currently I'm using the following code to split the path by <cod...
6,921,127
10
1
null
2011-08-03 02:45:05.387 UTC
41
2021-03-15 13:12:02.823 UTC
2020-02-04 20:12:58.597 UTC
null
150,605
null
529,310
null
1
293
c#|path|filenames|file-extension|path-manipulation
443,733
<p><a href="https://docs.microsoft.com/en-us/dotnet/api/system.io.path.getfilename" rel="noreferrer"><code>Path.GetFileName</code></a></p> <blockquote> <p>Returns the file name and extension of a file path that is represented by a read-only character span.</p> </blockquote> <hr /> <p><a href="https://docs.microsoft.com...
6,565,471
How can I exclude directories from grep -R?
<p>I want to traverse all subdirectories, except the "node_modules" directory.</p>
6,565,519
14
3
null
2011-07-03 20:48:43.077 UTC
156
2021-07-02 17:11:22.107 UTC
null
null
null
null
179,736
null
1
980
linux|unix|grep
612,114
<p><strong>SOLUTION 1 (combine <code>find</code> and <code>grep</code>)</strong></p> <p>The purpose of this solution is not to deal with <code>grep</code> performance but to show a portable solution : should also work with busybox or GNU version older than 2.5.</p> <p>Use <strong><code>find</code></strong>, for excludi...
38,113,994
Why does indexing numpy arrays with brackets and commas differ in behavior?
<p>I tend to index numpy arrays (matrices) with brackets, but I've noticed when I want to slice an array (matrix) I must use the comma notation. Why is this? For example,</p> <pre><code>&gt;&gt;&gt; x = numpy.array([[1, 2], [3, 4], [5, 6]]) &gt;&gt;&gt; x array([[1, 2], [3, 4], [5, 6]]) &gt;&gt;&gt; x[1]...
38,114,048
3
2
null
2016-06-30 04:27:53.54 UTC
18
2019-11-22 06:42:32.563 UTC
null
null
null
null
3,765,905
null
1
31
python|numpy|indexing|slice
9,314
<p>This:</p> <pre><code>x[:, 1] </code></pre> <p>means "take all indices of <code>x</code> along the first axis, but only index 1 along the second".</p> <p>This:</p> <pre><code>x[:][1] </code></pre> <p>means "take all indices of <code>x</code> along the first axis (so all of <code>x</code>), then take index 1 alon...
45,670,823
How to deal with PyCharm's "Expected type X, got Y instead"
<p>When using PyCharm, Pycharm's code style inspection gives me the warning <code>Expected type 'Union[ndarray, Iterable]', got 'float' instead</code> in the editor if I write <code>np.array(0.0)</code>. When I write <code>np.array([0.0])</code> I get no warning.</p> <p>When coding</p> <pre><code>from scipy.special i...
45,671,046
4
3
null
2017-08-14 08:55:46.41 UTC
0
2022-06-29 22:45:08.34 UTC
2019-12-04 11:41:37.803 UTC
null
12,479,481
null
4,533,188
null
1
23
python|numpy|pycharm
51,030
<p>PyCharm determines from the type-hints of the source code that the arguments you pass are incorrect.</p> <hr /> <h3>How to disable</h3> <p>Your question simplifies to one of figuring out how to disable this type checking. However, please be warned,</p> <blockquote> <p>Switching off the inspection completely is not a...
15,938,866
Alternative to Breeze.js?
<p>Is there an alternative to Breezejs that does not require .Net or Enterprise Framework Connector or database, and works with plain REST services that accept and return only JSON (no metadata)? </p>
15,939,442
4
0
null
2013-04-11 00:30:30.263 UTC
9
2015-06-30 05:56:39.267 UTC
2015-06-09 02:23:40.127 UTC
null
1,200,803
null
433,433
null
1
32
breeze
24,094
<p>We actually designed Breeze to be independent of .NET, but none of our samples show this yet. In the next week or two we will show how to connect Breeze to a generic HTTP service that returns JSON. We'd love to have your feedback on this when it comes out, as we know it will be a big part of the market.</p> <p><str...
15,684,605
Python For loop get index
<p>I am writing a simple Python for loop to prnt the current character in a string. However, I could not get the index of the character. Here is what I have, does anyone know a good way to get the current index of the character in the loop?</p> <pre><code> loopme = 'THIS IS A VERY LONG STRING WITH MANY MANY WORDS!' ...
15,684,617
2
1
null
2013-03-28 14:34:45.467 UTC
12
2013-03-28 15:14:43.707 UTC
null
null
null
null
1,817,081
null
1
60
python|loops|for-loop|indexing
122,961
<p>Use the <a href="http://docs.python.org/2/library/functions.html#enumerate" rel="noreferrer"><code>enumerate()</code> function</a> to generate the index along with the elements of the sequence you are looping over:</p> <pre><code>for index, w in enumerate(loopme): print "CURRENT WORD IS", w, "AT CHARACTER", ind...
15,899,615
What's the difference between CSS3's :root pseudo class and html?
<p>I can't seem to find much information about this.</p> <p><a href="http://coding.smashingmagazine.com/2011/03/30/how-to-use-css3-pseudo-classes/" rel="noreferrer">Smashing Magazine</a> seems to be saying that <code>html</code> and <code>:root</code> are the same thing but surely there must be a tiny difference?</p>
15,899,650
4
0
null
2013-04-09 10:34:53.543 UTC
10
2022-05-15 14:45:50.233 UTC
2019-05-22 19:51:18.953 UTC
null
9,591,441
null
914,543
null
1
80
css|css-selectors|pseudo-class
20,050
<p>From the <a href="http://www.w3.org/wiki/CSS/Selectors/pseudo-classes/:root" rel="noreferrer">W3C wiki</a>:</p> <blockquote> <p>The <code>:root</code> pseudo-class represents an element that is the root of the document. In HTML, this is always the HTML element. </p> </blockquote> <p>CSS is a general purpose styl...
10,488,112
How do I put graphics on a JPanel?
<p>I am having a problem adding graphics to a JPanel. If I change the line from panel.add(new graphics()); to frame.add(new graphics()); and do not add the JPanel to the JFrame, the black rectangle appears on the JFrame. I just cannot get the black rectangle to appear on the JPannel and was wondering if someone could h...
10,488,592
2
4
null
2012-05-07 19:44:28.567 UTC
1
2014-04-25 04:02:22.06 UTC
2012-05-07 21:56:37.803 UTC
null
418,556
null
1,344,742
null
1
6
java|swing|graphics|jframe|jpanel
41,435
<p>The custom component was 0x0 px.</p> <pre><code>import java.awt.*; import javax.swing.*; public class Catch { public class MyGraphics extends JComponent { private static final long serialVersionUID = 1L; MyGraphics() { setPreferredSize(new Dimension(500, 100)); } ...
10,294,284
Remove all special characters from a string in R?
<p>How to remove all special characters from string in R and replace them with spaces ?</p> <p>Some special characters to remove are : <code>~!@#$%^&amp;*(){}_+:&quot;&lt;&gt;?,./;'[]-=</code></p> <p>I've tried <code>regex</code> with <code>[:punct:]</code> pattern but it removes only punctuation marks.</p> <p>Question...
10,294,818
3
4
null
2012-04-24 08:24:48.693 UTC
56
2021-02-17 08:23:46.707 UTC
2021-02-17 08:23:46.707 UTC
null
783,421
null
783,421
null
1
158
regex|string|r|character
295,497
<p>You need to use <a href="http://www.regular-expressions.info/quickstart.html">regular expressions</a> to identify the unwanted characters. For the most easily readable code, you want the <a href="https://www.rdocumentation.org/packages/stringr/topics/str_replace_all"><code>str_replace_all</code></a> from the <a hre...
10,567,709
JavaScript get child element
<p>Why this does not work in firefox i try to select the category and then make subcategory visible.</p> <pre><code>&lt;script type="text/javascript"&gt; function show_sub(cat) { var cat = document.getElementById("cat"); var sub = cat.getElementsByName("sub"); sub[0].style.display='inline'; } &...
10,568,010
3
6
null
2012-05-12 22:00:49.84 UTC
11
2012-05-13 01:26:31.423 UTC
2012-05-13 01:26:31.423 UTC
null
1,085,162
null
1,085,162
null
1
37
javascript|html
169,058
<p>ULs don't have a name attribute, but you can reference the ul by tag name.</p> <p>Try replacing line 3 in your script with this:</p> <pre><code>var sub = cat.getElementsByTagName("UL"); </code></pre>
32,079,364
How can you make the Docker container use the host machine's '/etc/hosts' file?
<p>I want to make it so that the Docker container I spin up use the same <code>/etc/hosts</code> settings as on the host machine I run from. Is there a way to do this?</p> <p>I know there is an <a href="https://docs.docker.com/reference/run/#managing-etc-hosts" rel="noreferrer"><code>--add-host</code></a> option with <...
32,491,150
11
2
null
2015-08-18 17:51:27.91 UTC
17
2022-03-11 12:28:07.48 UTC
2020-09-03 17:26:03.91 UTC
null
63,550
null
3,006,145
null
1
84
docker
115,957
<p>Use <code>--network=host</code> in the <code>docker run</code> command. This tells Docker to make the container use the host's network stack. You can learn more <a href="https://docs.docker.com/engine/userguide/networking/" rel="noreferrer">here</a>.</p>
31,949,355
What "Clustered Index Scan (Clustered)" means on SQL Server execution plan?
<p>I have a query that fails to execute with "Could not allocate a new page for database 'TEMPDB' because of insufficient disk space in filegroup 'DEFAULT'". </p> <p>On the way of trouble shooting I am examining the execution plan. There are two costly steps labeled "Clustered Index Scan (Clustered)". I have a hard ti...
31,961,357
5
3
null
2015-08-11 18:28:37.327 UTC
9
2020-06-30 04:01:59.96 UTC
2015-08-11 18:42:12.45 UTC
null
3,089,523
null
3,089,523
null
1
40
sql|sql-server|sql-execution-plan
47,260
<blockquote> <p>I would appreciate any explanations to "Clustered Index Scan (Clustered)"</p> </blockquote> <p>I will try to put in the easiest manner, for better understanding you need to understand both index seek and scan.</p> <p>SO lets build the table </p> <pre><code>use tempdb GO create table scanseek (...
40,123,319
Easy way to Encrypt/Decrypt string in Android
<p>My question is how to encrypt a <strong>String</strong>:</p> <pre><code>String AndroidId; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.download_movie_activity); cancel = (Button)findViewById(R.id.img_cancle); linear= (LinearLayout...
40,175,319
5
7
null
2016-10-19 05:57:46.137 UTC
25
2021-10-09 13:50:09.417 UTC
2019-06-04 11:09:42.117 UTC
null
6,879,903
null
6,879,903
null
1
30
android|encryption
103,259
<p>You can use <a href="https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html" rel="noreferrer"><code>Cipher</code></a> for this.</p> <p>This class provides the functionality of a cryptographic cipher for encryption and decryption. It forms the core of the Java Cryptographic Extension (JCE) framework.</p>...
13,268,698
Concatenate numerical values in a string
<p>I would like to store this output in a string:</p> <pre><code>&gt; x=1:5 &gt; cat("hi",x) hi 1 2 3 4 5 </code></pre> <p>So I use <code>paste</code>, but I obtain this different result:</p> <pre><code>&gt; paste("hi",x) [1] "hi 1" "hi 2" "hi 3" "hi 4" "hi 5" </code></pre> <p>Any idea how to obtain the string:</p>...
13,268,755
3
0
null
2012-11-07 11:20:26.193 UTC
4
2016-11-09 11:12:20.437 UTC
null
null
null
null
1,263,739
null
1
39
string|r|concatenation|paste|cat
96,630
<p>You can force coercion to character for <code>x</code> by concatenating the string <code>"hi"</code> on to <code>x</code>. Then just use <code>paste()</code> with the <code>collapse</code> argument. As in</p> <pre><code>x &lt;- 1:5 paste(c("hi", x), collapse = " ") &gt; paste(c("hi", x), collapse = " ") [1] "hi 1 ...
13,399,836
Can there exist two main methods in a Java program?
<p>Can two main methods exist in a Java program?</p> <p>Only by the difference in their arguments like:</p> <pre><code>public static void main(String[] args) </code></pre> <p>and second can be</p> <pre><code>public static void main(StringSecond[] args) </code></pre> <p>If it is possible, which Method will be used as th...
13,399,868
16
1
null
2012-11-15 14:43:40 UTC
15
2021-04-18 01:37:03.34 UTC
2021-03-09 12:46:49.2 UTC
null
11,270,766
null
1,820,722
null
1
39
java|methods|arguments|program-entry-point
133,363
<p>As long as method parameters (number (or) type) are different, yes they can. It is called <a href="http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html">overloading</a>.</p> <blockquote> <p>Overloaded methods are differentiated by the number and the type of the arguments passed into the method</p> </bl...
13,756,178
Writings functions (procedures) for data.table objects
<p>In the book <em>Software for Data Analysis: Programming with R</em>, John Chambers emphasizes that functions should generally not be written for their side effect; rather, that a function should return a value without modifying any variables in its calling environment. Conversely, writing good script using data.tab...
13,756,636
2
6
null
2012-12-07 02:43:11.617 UTC
19
2012-12-07 14:18:06.937 UTC
2012-12-07 11:33:02.537 UTC
null
1,174,421
null
1,174,421
null
1
42
r|data.table
7,803
<p>Yes, the addition, modification, deletion of columns in <code>data.table</code>s is done by <code>reference</code>. In a sense, it is a <em>good</em> thing because a <code>data.table</code> usually holds a lot of data, and it would be very memory and time consuming to reassign it all every time a change to it is ma...
13,423,494
Why is overriding method parameters a violation of strict standards in PHP?
<p>I know there are a couple of similar questions here in StackOverflow like <a href="https://stackoverflow.com/questions/13220489/method-overriding-and-strict-standards">this question</a>.</p> <p>Why is overriding method parameters a violation of strict standards in PHP? For instance:</p> <pre><code>class Foo { ...
13,423,625
4
0
null
2012-11-16 19:55:09.14 UTC
15
2013-10-15 06:42:53.25 UTC
2017-05-23 12:17:39.08 UTC
null
-1
null
516,316
null
1
43
php|oop
25,883
<p>In OOP, <a href="http://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29" rel="noreferrer">SOLID</a> stands for <strong>Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion</strong>.</p> <p><a href="http://en.wikipedia.org/wiki/Liskov_substitution_principle...
13,603,882
Feature Selection and Reduction for Text Classification
<p>I am currently working on a project, a <strong>simple sentiment analyzer</strong> such that there will be <strong>2 and 3 classes</strong> in <strong>separate cases</strong>. I am using a <strong>corpus</strong> that is pretty <strong>rich</strong> in the means of <strong>unique words</strong> (around 200.000). I us...
15,461,587
5
3
null
2012-11-28 11:21:59.53 UTC
50
2021-08-22 07:47:42.093 UTC
2020-05-28 03:47:32.723 UTC
null
4,566,277
null
1,839,494
null
1
53
python|nlp|svm|sentiment-analysis|feature-extraction
31,251
<p>This is probably a bit late to the table, but...</p> <p>As Bee points out and you are already aware, the use of SVM as a classifier is wasted if you have already lost the information in the stages prior to classification. However, the process of text classification requires much more that just a couple of stages an...
13,600,319
Run one command after another, even if I suspend the first one (Ctrl-z)
<p>I know in bash I can run one command after another by separating them by semicolons, like</p> <pre><code>$ command1; command2 </code></pre> <p>Or if I only want <code>command2</code> to run only if <code>command1</code> succeeds, using <code>&amp;&amp;</code>:</p> <pre><code>$ command1 &amp;&amp; command2 </code>...
13,600,474
2
4
null
2012-11-28 07:53:57.17 UTC
28
2018-05-01 19:16:45.063 UTC
2018-05-01 19:16:45.063 UTC
null
6,862,601
null
161,801
null
1
70
bash|shell|command|signals|suspend
70,544
<p>The following should do it:</p> <pre><code>(command1; command2) </code></pre> <p>Note the added parentheses.</p>
13,688,158
When to use <p> vs. <br>
<p>What's the verdict on when you should use another <code>&lt;p&gt;...&lt;/p&gt;</code> instead of a <code>&lt;br /&gt;</code> tag? What's are the best practices for this kind of thing?</p> <p>I looked around for this question, but most of the writing seems a bit old, so I'm not sure whether opinions about this topic...
13,688,203
6
0
null
2012-12-03 17:03:58.62 UTC
9
2019-01-14 15:28:29.127 UTC
2012-12-03 20:36:11.297 UTC
null
1,311,267
null
1,311,267
null
1
74
html
107,917
<p>They serve two different functions.</p> <p><code>&lt;p&gt;</code> (paragraph) is a block element which is used to hold text. <code>&lt;br /&gt;</code> is used to force a line break within the <code>&lt;p&gt;</code> element.</p> <p><strong>Example</strong></p> <pre><code>&lt;p&gt;Suspendisse sodales odio in felis ...
20,439,788
How to stop apache permanently on mac Mavericks?
<p>I'm trying to install zend server on mac and need to uninstall the apache server that is auto included with Mavericks so that the Apache server included with Zend is used instead. Can it be prevented from running on startup or permanently removed?</p>
20,439,859
4
2
null
2013-12-07 09:30:54.603 UTC
28
2018-05-02 09:22:26.64 UTC
2014-09-16 18:31:17.693 UTC
null
364,066
null
1,914,652
null
1
45
macos|apache|osx-mavericks
61,068
<p>Try this:</p> <pre><code>sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist </code></pre> <p>This will stop a running instance of Apache, and record that it should not be restarted. It records your preference in <code>/private/var/db/launchd.db/com.apple.launchd/overrides.plist</code>.<...
20,770,562
how to get javascript return value to php variable?
<p>I have created a javascript for check the text boxes are empty. if one of text box is empty the return false. so how can i get that return value to a PHP variable ?</p>
20,770,651
3
3
null
2013-12-25 08:11:59.06 UTC
1
2013-12-25 08:28:35.177 UTC
2013-12-25 08:14:41.03 UTC
null
2,919,798
null
3,133,944
null
1
2
javascript|php|html
58,929
<p>For linking javascript with php need to use AJAX <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">http://api.jquery.com/jQuery.ajax/</a></p> <pre><code>$.ajax({ type: "POST", url: "some.php", data: { name: "John", location: "Boston" } }) .done(function( msg ) { alert( "Data Saved: " + msg ); ...
24,347,029
Python NLTK: Bigrams trigrams fourgrams
<p>I have this example and i want to know how to get this result. I have text and I tokenize it then I collect the bigram and trigram and fourgram like that </p> <pre><code>import nltk from nltk import word_tokenize from nltk.util import ngrams text = "Hi How are you? i am fine and you" token=nltk.word_tokenize(text) ...
24,347,217
4
3
null
2014-06-22 00:16:28.31 UTC
9
2019-07-17 07:03:51.79 UTC
2015-11-17 07:02:30.397 UTC
null
1,090,562
null
3,731,150
null
1
22
python|nltk|n-gram
55,582
<p>If you apply some set theory (if I'm interpreting your question correctly), you'll see that the trigrams you want are simply elements [2:5], [4:7], [6:8], etc. of the <code>token</code> list.</p> <p>You could generate them like this:</p> <pre><code>&gt;&gt;&gt; new_trigrams = [] &gt;&gt;&gt; c = 2 &gt;&gt;&gt; whi...
24,111,813
How can I animate a react.js component onclick and detect the end of the animation
<p>I want to have a react component flip over when a user clicks on the DOM element. I see some documentation about their animation mixin but it looks to be set up for "enter" and "leave" events. What is the best way to do this in response to some user input and be notified when the animation starts and completes? Curr...
34,700,273
8
3
null
2014-06-08 23:08:02.667 UTC
10
2021-12-12 01:19:26.907 UTC
null
null
null
null
83,080
null
1
49
javascript|reactjs
84,702
<p>Upon clicks you can update the state, add a class and record the <code>animationend</code> event.</p> <pre><code>class ClickMe extends React.Component { constructor(props) { super(props) this.state = { fade: false } } render() { const fade = this.state.fade return ( &lt;button r...
3,571,179
How does X11 clipboard handle multiple data formats?
<p>It probably happened to you as well - sometimes when you copy a text from some web page into your rich-text e-mail draft in your favorite webmail client, you dislike the fact that the pasted <strong>piece</strong> has a different font/size/weight.. it somehow remembers the style (often images, when selected). How is...
3,571,949
2
1
null
2010-08-26 00:08:15.54 UTC
13
2019-11-19 07:38:39.697 UTC
2010-09-08 07:05:11.433 UTC
null
300,863
null
234,248
null
1
43
text|clipboard|x11|xorg
5,295
<p>The app you copy from advertises formats (mostly identified by MIME types) it can provide. The app you paste into has to pick its preferred format and request that one from the source app.</p> <p>The reason you may not see all style info transferred is that the apps don't both support a common format that includes ...
45,293,933
"Could not find a version that satisfies the requirement opencv-python"
<p>I am struggling with Jetson TX2 board (aarch64).</p> <p>I need to install python wrapper for OpenCV.</p> <p>I can do:</p> <pre><code>$ sudo apt-get install python-opencv </code></pre> <p>But I cannot do:</p> <pre><code>$ sudo pip install opencv-python </code></pre> <p>Is this because there is no proper wheel f...
45,302,440
13
6
null
2017-07-25 04:27:04.467 UTC
10
2021-09-22 21:07:08.167 UTC
null
null
null
null
4,227,175
null
1
47
opencv|pip
172,979
<p><code>pip</code> doesn't use <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/" rel="noreferrer">http://www.lfd.uci.edu/~gohlke/pythonlibs/</a>, it downloads packages from <a href="https://pypi.python.org/pypi/opencv-python" rel="noreferrer">PyPI</a>.</p> <p>The problem is that you have an unusual architecture; <...
9,268,645
Creating a table linked to a csv file
<p>I am trying to create a table linked to a <code>*.csv</code> file using d3, but all I get is a blank webpage. Even with the example Crimea I get a blank page.<br> I would be grateful to be directed or shown a working example or a suggestion of what I am doing wrong.</p>
9,507,713
4
2
null
2012-02-13 21:56:41.56 UTC
30
2015-05-22 05:24:22.363 UTC
2014-01-08 01:31:08.593 UTC
null
1,151,269
null
1,169,210
null
1
44
javascript|d3.js|html-table
31,421
<p>If you're asking about creating an HTML table from CSV data, this is what you want:</p> <pre><code>d3.csv("data.csv", function(data) { // the columns you'd like to display var columns = ["name", "age"]; var table = d3.select("#container").append("table"), thead = table.append("thead"), ...
16,265,714
Camera pose estimation (OpenCV PnP)
<p>I am trying to get a global pose estimate from an image of four fiducials with known global positions using my webcam.</p> <p>I have checked many stackexchange questions and a few papers and I cannot seem to get a a correct solution. The position numbers I do get out are repeatable but in no way linearly proportion...
27,858,194
3
1
null
2013-04-28 17:38:13.803 UTC
12
2016-07-26 07:16:36.627 UTC
2017-05-23 12:17:05.72 UTC
null
-1
null
2,329,503
null
1
17
opencv|computational-geometry|camera-calibration|pose-estimation|extrinsic-parameters
20,863
<p>I solved this a while ago, apologies for the year delay.</p> <p>In the python OpenCV 2.1 I was using, and the newer version 3.0.0-dev, I have verified that to get the pose of the camera in the global frame you must:</p> <pre><code>_, rVec, tVec = cv2.solvePnP(objectPoints, imagePoints, cameraMatrix, distCoeffs) Rt...
16,253,215
Open and modify Word Document
<p>I want to open a word file saved in my server using "Microsoft.Office.Interop.Word". This is my code:</p> <pre><code> object missing = System.Reflection.Missing.Value; object readOnly = false; object isVisible = true; object fileName = "http://localhost:52099/modelloBusta/prova.dotx"; Microsoft.O...
16,298,284
3
5
null
2013-04-27 14:26:30.26 UTC
5
2016-09-04 00:39:55.93 UTC
2014-03-31 20:10:15.333 UTC
null
881,229
null
2,310,390
null
1
19
c#|asp.net|ms-word|ms-office
94,953
<p>You need to make sure that the Word application window actually is made visible when automating Word like that:</p> <pre><code>var applicationWord = new Microsoft.Office.Interop.Word.Application(); applicationWord.Visible = true; </code></pre>
16,052,704
How to pass dynamic value in @Url.Action?
<p>I have written following jquery in my partial view:</p> <pre><code> $.ajax({ type: "POST", url: '@Url.Action("PostActionName", "ControllerName")', data: { Id: "01" }, success: function(data) { if (data.success="true") { w...
16,052,759
3
3
null
2013-04-17 06:03:49.253 UTC
5
2018-08-24 10:50:38.357 UTC
2013-04-17 06:12:53.583 UTC
null
1,480,090
null
1,480,090
null
1
22
jquery|asp.net-mvc-4|url.action
90,051
<blockquote> <p>I have functions to fetch invoking action and controller names, but not sure how I can pass them in @Url.Action</p> </blockquote> <p>Well, you could call those functions. For example if they are extension methods to the UrlHelper class:</p> <pre><code>window.location = '@Url.Action(Url.MyFunction1...
16,296,351
How to delete an item from UICollectionView with indexpath.row
<p>I have a collection view,and I tried to delete a cell from collection view on didSelect method.I succeeded in that using the following method </p> <pre><code> [colleVIew deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]]; </code></pre> <p>But now I need to delete the item on button click from Collecti...
16,297,327
7
0
null
2013-04-30 09:19:39.407 UTC
8
2020-06-24 02:22:40.937 UTC
null
null
null
user2000452
null
null
1
23
iphone|ios|uicollectionview|uicollectionviewcell
44,718
<pre><code>-(void)remove:(int)i { [self.collectionObj performBatchUpdates:^{ [array removeObjectAtIndex:i]; NSIndexPath *indexPath =[NSIndexPath indexPathForRow:i inSection:0]; [self.collectionObj deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]]; } completion:^(BOOL finishe...
16,534,277
Can an INSERT operation result in a deadlock?
<p>Assuming:</p> <ul> <li>I am using REPEATABLE_READ or SERIALIZABLE transaction isolation (locks get retained every time I access a row)</li> <li>We are talking about multiple threads accessing multiple tables simultaneously.</li> </ul> <p>I have the following questions:</p> <ol> <li><strong>Is it possible for an <...
16,534,802
3
5
null
2013-05-14 02:42:11.527 UTC
9
2017-01-28 17:06:05.257 UTC
2017-01-28 17:06:05.257 UTC
null
2,263,517
null
14,731
null
1
28
sql|insert|deadlock
45,298
<p>Generally all modifications can cause a deadlock and selects will not (get to that later). So</p> <ol> <li>No you cannot ignore these.</li> <li>You can somewhat ignore select depending on your database and settings but the others will give you deadlocks.</li> </ol> <p>You don't even need multiple tables.</p> <p>...
16,344,756
Auto reloading python Flask app upon code changes
<p>I'm investigating how to develop a decent web app with Python. Since I don't want some high-order structures to get in my way, my choice fell on the lightweight <a href="https://flask.palletsprojects.com/en/1.1.x/" rel="noreferrer">Flask framework</a>. Time will tell if this was the right choice.</p> <p>So, now I've...
40,150,705
12
0
null
2013-05-02 18:04:10.81 UTC
84
2022-08-02 13:26:00.577 UTC
2022-01-12 21:09:44.2 UTC
null
4,294,399
null
640,694
null
1
345
python|apache|flask
267,621
<p>Run the <code>flask run</code> CLI command with <a href="https://flask.palletsprojects.com/quickstart/#debug-mode" rel="noreferrer">debug mode</a> enabled, which will automatically enable the reloader. As of Flask 2.2, you can pass <code>--app</code> and <code>--debug</code> options on the command line.</p> <pre><co...
16,177,056
Changing three.js background to transparent or other color
<p>I've been trying to change what seems to be the default background color of my canvas from black to transparent / any other color - but no luck.</p> <p>My HTML:</p> <pre><code>&lt;canvas id="canvasColor"&gt; </code></pre> <p>My CSS:</p> <pre><code>&lt;style type="text/css"&gt; #canvasColor { z-index: 998; opaci...
16,177,178
7
1
null
2013-04-23 18:53:35.56 UTC
31
2021-12-07 13:42:52.083 UTC
2013-06-13 18:40:16.507 UTC
null
2,287,470
null
1,231,561
null
1
153
css|html|canvas|html5-canvas|three.js
173,822
<p>I came across this when I started using three.js as well. It's actually a javascript issue. You currently have: </p> <pre><code>renderer.setClearColorHex( 0x000000, 1 ); </code></pre> <p>in your <code>threejs</code> init function. Change it to:</p> <pre><code>renderer.setClearColorHex( 0xffffff, 1 ); </code></pre...
28,942,758
How do I get the dimensions (nestedness) of a nested vector (NOT the size)?
<p>Consider the following declarations:</p> <pre><code>vector&lt;vector&lt;int&gt; &gt; v2d; vector&lt;vector&lt;vector&lt;string&gt;&gt; &gt; v3d; </code></pre> <p>How can I find out the "dimensionality" of the vectors in subsequent code? For example, 2 for v2d and 3 for v3d?</p>
28,943,178
2
9
null
2015-03-09 13:07:23.92 UTC
6
2015-08-06 14:45:23.79 UTC
2015-03-10 08:32:21.35 UTC
null
1,025,391
null
1,586,860
null
1
31
c++|vector
1,845
<p>Something on these lines:</p> <pre><code>template&lt;class Y&gt; struct s { enum {dims = 0}; }; template&lt;class Y&gt; struct s&lt;std::vector&lt;Y&gt;&gt; { enum {dims = s&lt;Y&gt;::dims + 1}; }; </code></pre> <p>Then for example,</p> <pre><code>std::vector&lt;std::vector&lt;double&gt; &gt; x; int n =...
58,305,567
How to set GOPRIVATE environment variable
<p>I started working on a <code>Go</code> project and it uses some private modules from Github private repos and whenever I try to run <code>go run main.go</code> it gives me a below <code>410 Gone</code> error:</p> <blockquote> <p>verifying github.com/repoURL/go-proto@v2.86.0+incompatible/go.mod: github.com/repoURL...
58,306,008
3
6
null
2019-10-09 13:42:08.55 UTC
38
2022-05-16 08:55:28.083 UTC
2020-04-07 07:49:04.04 UTC
null
5,198,756
null
4,704,510
null
1
91
go|environment-variables|go-modules
92,695
<h3>Short Answer:</h3> <pre class="lang-sh prettyprint-override"><code>go env -w GOPRIVATE=github.com/repoURL/private-repo </code></pre> <p><strong>OR</strong></p> <p>If you want to allow all private repos from your organization</p> <pre class="lang-sh prettyprint-override"><code>go env -w GOPRIVATE=github.com/&lt;OrgN...
22,403,650
Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The system cannot find the path specified
<p>I have a small MVC app that I use for practice reasons, but now I am encountering an error every time I try to debug:</p> <pre><code>Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The system cannot find the path specified. </code></pre> <p>I've googled but cannot find a s...
22,404,145
20
2
null
2014-03-14 11:24:11.247 UTC
39
2021-07-16 09:40:23.057 UTC
2016-10-25 13:42:31.263 UTC
null
4,211,135
null
3,322,193
null
1
178
c#|asp.net|.net|asp.net-mvc-4
238,711
<p>Whenever I have a NuGet error such as these I usually take these steps:</p> <ol> <li>Go to the packages folder in the Windows Explorer and delete it.</li> <li>Open Visual Studio and Go to <em>Tools</em> > <em>Library Package Manager</em> > <em>Package Manager Settings</em> and under the Package Manager item on the ...
22,342,285
summing two columns in a pandas dataframe
<p>when I use this syntax it creates a series rather than adding a column to my new dataframe <code>sum</code>.</p> <p>My code:</p> <pre><code>sum = data['variance'] = data.budget + data.actual </code></pre> <p>My dataframe <code>data</code> currently has everything except the <code>budget - actual</code> column. How d...
22,342,344
7
3
null
2014-03-12 04:51:03.453 UTC
12
2022-05-26 04:41:04.253 UTC
2022-05-07 18:08:11.807 UTC
null
18,145,256
null
3,098,818
null
1
58
python|pandas
238,224
<p>I think you've misunderstood some python syntax, the following does two assignments:</p> <pre><code>In [11]: a = b = 1 In [12]: a Out[12]: 1 In [13]: b Out[13]: 1 </code></pre> <p>So in your code it was as if you were doing:</p> <pre><code>sum = df['budget'] + df['actual']  # a Series # and df['variance'] = df[...
37,311,042
Call django urls inside javascript on click event
<p>I got a javascript onclick event inside a template, and I want to call one of my Django urls with an id parameter from it, like this :</p> <pre><code>$(document).on('click', '.alink', function () { var id = $(this).attr('id'); document.location.href =&quot;{% url 'myapp:productdetailorder' id %}&quot...
49,824,680
5
3
null
2016-05-18 22:21:02.887 UTC
7
2021-06-01 10:24:16.893 UTC
2021-02-26 18:36:10.943 UTC
null
5,682,919
null
5,682,919
null
1
11
javascript|jquery|django|location-href
38,097
<p>I think the best way to do this is to create a html <code>data-*</code> attribute with the URL rendered in a template and then use javascript to retrieve that. </p> <p>This way you avoid mixing js/django template stuff together. Also, I keep all of my JS in a separate file outside the view (which is a much better p...
17,564,608
What does the 'array name' mean in case of array of char pointers?
<p>In my code: </p> <pre><code> char *str[] = {"forgs", "do", "not", "die"}; printf("%d %d", sizeof(str), sizeof(str[0])); </code></pre> <p>I'm getting the output as <code>12 2</code>, so my doubts are: </p> <ol> <li>Why is there a difference? </li> <li>Both <code>str</code> and <code>str[0]</code> are char p...
17,564,886
4
17
null
2013-07-10 07:19:21.15 UTC
24
2014-01-01 08:54:58.53 UTC
2013-08-20 18:48:18.133 UTC
null
1,673,391
null
1,587,061
null
1
24
c|pointers|sizeof
5,795
<p>In most cases, an array name will decay to the value of the address of its first element, and with type being the same as a pointer to the element type. So, you would expect a bare <code>str</code> to have the value equal to <code>&amp;str[0]</code> with type pointer to pointer to <code>char</code>.</p> <p>However,...
18,500,611
Android: How to use "adb shell wm" to simulate other devices
<p>So I bought a Nexus 10 for development and was super excited by the prospect of being able to simulate other devices using the "adb shell wm" command, with its size, density, and overscan subcommands.</p> <p>However, I've had a few problems making this work. I'd like to see if anyone else has encountered/overcome t...
19,922,688
3
7
null
2013-08-29 00:46:47.703 UTC
13
2022-01-05 19:41:37.473 UTC
null
null
null
null
912,961
null
1
39
android|adb
65,607
<p>Okay, I think I figured out enough of this to be useful. I will attempt to answer each of the questions I raised in my original post. Then I'll share a few other things I've learned about how to use this effectively.</p> <ul> <li>Is there any way to avoid messing up the menu bar when at the home screen?</li> </ul> ...
26,175,661
Intellij git revert a commit
<p>I was using <code>Eclipse</code> and <code>Egit</code> for a long time and decided to try <code>Intellij</code>.<br/> So far so good, except one thing...<br/> I can't find an easy way to revert an old commit from my repo!!!</p> <p>In Eclipse the standard process was: <code>Go to Git Workspace -&gt; Click Show Histo...
29,964,756
4
2
null
2014-10-03 08:26:42.57 UTC
9
2017-06-13 11:37:52.343 UTC
null
null
null
null
1,499,705
null
1
57
git|intellij-idea
75,155
<p>If you go to Changelist -> Log, and there select the commit, you've got a change detail in the right panel. There you can select all and click a button (or right click -> revert selected changes).</p>
23,199,416
5 dimensional plot in r
<p>I am trying to plot a 5 dimensional plot in R. I am currently using the <code>rgl</code> package to plot my data in 4 dimensions, using 3 variables as the x,y,z, coordinates, another variable as the color. I am wondering if I can add a fifth variable using this package, like for example the size or the shape of the ...
23,199,753
1
9
null
2014-04-21 14:27:43.343 UTC
13
2018-08-09 16:14:35.227 UTC
2014-04-21 15:02:46.993 UTC
null
1,826,552
null
1,826,552
null
1
13
r|plot|rgl|multi-dimensional-scaling
6,660
<p>Here is a <code>ggplot2</code> option. I usually shy away from 3D plots as they are hard to interpret properly. I also almost never put in 5 continuous variables in the same plot as I have here...</p> <pre><code>ggplot(df, aes(x=var1, y=var2, fill=var3, color=var4, size=var5^2)) + geom_point(shape=21) + scale...
5,107,368
how to null a variable of type float
<p>My code is working if my float variable is set to 0, but I want my code to work if my variable is null. How could I do that? Here is a code snippet I wrote:</p> <pre><code>float oikonomia= (float)((float)new Float(vprosvasis7.getText().toString())); if(oikonomia==0){ </code></pre> <p>...
5,107,399
4
0
null
2011-02-24 16:20:13.123 UTC
null
2011-02-24 17:46:21.92 UTC
2011-02-24 16:35:25.657 UTC
null
519,526
null
519,526
null
1
7
java|android
45,842
<p>If you want a nullable float, then try <code>Float</code> instead of <code>float</code></p> <pre><code>Float oikonomia= new Float(vprosvasis7.getText().toString()); </code></pre> <p>But it will never be <code>null</code> that way as in your example...</p> <p><strong>EDIT</strong>: Aaaah, I'm starting to understan...
9,494,283
jquery how to get the pasted content
<p>I have a little trouble catching a pasted text into my input:</p> <pre><code> &lt;input type="text" id="myid" val="default"&gt; $('#myid').on('paste',function(){ console.log($('#myid').val()); }); </code></pre> <p>console.log shows:</p> <pre><code>default </code></pre> <p>How I <code>catch</code> the...
9,494,891
6
3
null
2012-02-29 06:03:57.457 UTC
8
2020-05-12 06:25:04.83 UTC
null
null
null
null
379,437
null
1
34
jquery|paste
45,227
<p>Because the <code>paste</code> event is triggered before the inputs value is updated, the solution is to either:</p> <ol> <li><p>Capture the data from the clipboard instead, as the clipboards data will surely be the same as the data being pasted into the input at that exact moment.</p></li> <li><p>Wait until the va...
9,335,434
What's the difference between performSelectorOnMainThread: and dispatch_async() on main queue?
<p>I was having problems modifying a view inside a thread. I tried to add a subview but it took around 6 or more seconds to display. I finally got it working, but I don't know how exactly. So I was wondering why it worked and what's the difference between the following methods:</p> <ol> <li>This worked -added the view ...
9,336,253
3
4
null
2012-02-17 21:10:14.653 UTC
21
2020-07-31 15:16:01.467 UTC
2020-07-31 15:16:01.467 UTC
null
3,841,734
null
572,978
null
1
57
objective-c|ios|multithreading|uikit|grand-central-dispatch
22,442
<p>By default, <code>-performSelectorOnMainThread:withObject:waitUntilDone:</code> only schedules the selector to run in the default run loop mode. If the run loop is in another mode (e.g. the tracking mode), it won't run until the run loop switches back to the default mode. You can get around this with the variant <co...
18,305,844
C++, best way to change a string at a particular index
<p>I want to change a C++ string at a particular index like this:</p> <pre><code>string s = "abc"; s[1] = 'a'; </code></pre> <p>Is the following code valid? Is this an acceptable way to do this?</p> <p>I didn't find any reference which says it is valid:</p> <p><a href="http://www.cplusplus.com/reference/string/str...
18,305,897
4
5
null
2013-08-19 03:03:40.25 UTC
12
2021-12-20 14:55:22.98 UTC
2013-08-19 03:10:03.84 UTC
null
445,131
null
690,639
null
1
39
c++|string
81,096
<p>Assigning a character to an <code>std::string</code> at an index will produce the correct result, for example:</p> <pre><code>#include &lt;iostream&gt; int main() { std::string s = &quot;abc&quot;; s[1] = 'a'; std::cout &lt;&lt; s; } </code></pre> <p>For those of you below doubting my IDE/library setup, ...
18,485,378
Vertically centering text within an inline-block
<p>I'm trying to create some buttons for a website using styled hyperlinks. I have managed to get the button looking how I want, bar one slight issue. I can't get the text ('Link' in the source code below) to vertically center.</p> <p>Unfortunately there may be more than one line of text as demonstrated with the secon...
18,485,534
4
0
null
2013-08-28 10:28:13.27 UTC
10
2022-06-08 00:06:18.577 UTC
2013-08-28 11:48:04.53 UTC
null
1,725,764
null
2,724,946
null
1
33
html|vertical-alignment|centering|css
42,961
<p>Wrap your text with a span (Centered), and write another empty span just before it(Centerer) like this.</p> <p><strong>HTML:</strong></p> <pre><code>&lt;a href="..." class="button"&gt; &lt;span class="Centerer"&gt;&lt;/span&gt; &lt;span class='Centered'&gt;Link&lt;/span&gt; &lt;/a&gt; </code></pre> <p><strong...
18,310,007
Add html link in anyone of ng-grid
<p>I want to add link to ng-grid. Here is my code for your reference </p> <pre><code>&lt;html ng-app="myApp"&gt; &lt;head lang="en"&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Getting Started With ngGrid Example&lt;/title&gt; &lt;link href="../../Content/ng-grid.css" rel="stylesheet" type="text/css"...
18,318,804
5
0
null
2013-08-19 09:02:31.72 UTC
16
2017-12-04 14:08:45.073 UTC
2013-08-19 10:34:57.183 UTC
null
1,616,483
null
1,616,483
null
1
19
angular-ui|ng-grid
29,648
<p><strong>Update:</strong></p> <p>It has been noted that this answer does not work with <code>ui-grid</code>. This is understandable since at the time of the answer only <code>ng-grid</code> existed; however, substituting <code>{{COL_FIELD}}</code> in place of <code>{{row.getProperty(col.field)}}</code> allows the so...
19,902,644
DIV table-cell width 100%
<p>Here is my code:</p> <pre><code>&lt;div style='display: table'&gt; &lt;div style='height:200px; width:100%; text-align: center; display: table-cell; vertical-align: middle'&gt;No result found&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Why is that the <code>width:100%</code> is not working? How can I solve it?</...
19,902,699
3
2
null
2013-11-11 09:15:01.457 UTC
2
2019-03-28 18:25:10.35 UTC
null
null
null
null
1,995,781
null
1
8
html|css
41,589
<p>Try giving <code>width: 100%</code> to parent so that the child has full width.</p> <pre><code>&lt;div style='display: table; width:100%; background:#f00;'&gt; &lt;div style='height:200px; width:100%; text-align: center; display: table-cell; vertical-align: middle'&gt;No result found&lt;/div&gt; &lt;/div&gt; </...
19,857,749
What is the reliable method to find most time consuming part of the code?
<p>Along my source code I try to capture and measure the time release of a segment in Python. How can I measure that segment pass time in a convenient way with good precision?</p>
19,857,889
1
2
null
2013-11-08 11:16:11.667 UTC
10
2014-01-31 11:31:18.893 UTC
2013-11-14 20:41:43.637 UTC
null
2,622,293
null
648,896
null
1
27
python|profiling|performance
6,357
<p>Use a <strong>profiler</strong>.</p> <p>Python's <a href="http://docs.python.org/2/library/profile.html#module-cProfile" rel="noreferrer"><code>cProfile</code></a> is included in the standard libary.</p> <p>For an even more convenient way, use the package <a href="https://pypi.python.org/pypi/profilestats/" rel="nor...
19,858,251
HTTP status code 0 - Error Domain=NSURLErrorDomain?
<p>I am working on an iOS project. </p> <p>In this application, I am downloading images from the server.</p> <p><strong>Problem:</strong></p> <p>While downloading images I am getting <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" rel="noreferrer">Request Timeout</a>. According to documentation HTTP...
19,862,540
13
3
null
2013-11-08 11:40:05.027 UTC
16
2022-03-30 07:17:47.26 UTC
2019-01-18 10:03:17.787 UTC
null
9,215,780
null
1,058,406
null
1
107
http|download|http-status-codes|nserror
371,311
<p>There is no HTTP status code 0. What you see is a 0 returned by the API/library that you are using. You will have to check the documentation for that.</p>
27,599,311
Tkinter.PhotoImage doesn't not support png image
<p>I am using Tkinter to write a GUI and want to display a png file in a <code>Tkiner.Label</code>. So I have some code like this:</p> <pre><code>self.vcode.img = PhotoImage(data=open('test.png').read(), format='png') self.vcode.config(image=self.vcode.img) </code></pre> <p>This code <strong>runs correctly on my Linu...
27,601,573
8
6
null
2014-12-22 08:49:15.743 UTC
null
2022-02-13 14:06:07.127 UTC
2019-01-15 23:33:16.58 UTC
null
355,230
null
3,745,963
null
1
5
python|linux|tkinter|tk
52,611
<p>tkinter only supports 3 file formats off the bat which are GIF, PGM, and PPM. You will either need to convert the files to .GIF then load them (Far easier, but as jonrsharpe said, nothing will work without converting the file first) or you can port your program to Python 2.7 and use the Python Imaging Library (PIL) ...
27,652,227
Add placeholder text inside UITextView in Swift?
<p>How can I add a placeholder in a <code>UITextView</code>, similar to the one you can set for <code>UITextField</code>, in <code>Swift</code>?</p>
27,652,289
44
10
null
2014-12-26 02:12:05.47 UTC
162
2022-07-21 12:06:49.5 UTC
2020-09-25 15:37:11.813 UTC
user7219949
14,016,301
null
4,392,705
null
1
393
ios|swift|uitextview|placeholder
342,100
<p><strong>Updated for Swift 4</strong></p> <p><code>UITextView</code> doesn't inherently have a placeholder property so you'd have to create and manipulate one programmatically using <code>UITextViewDelegate</code> methods. I recommend using either solution #1 or #2 below depending on the desired behavior.</p> <p><s...
15,326,792
Select column 2 to last column in R
<p>I have a data frame with multiple columns. Now, I want to get rid of the row.names column (column 1), and thus I try to select all the other columns.</p> <p>E.g., </p> <pre><code>newdata &lt;- olddata[,2:10] </code></pre> <p>is there a default symbol for the last column so I don't have to count all the columns? I...
15,326,846
4
6
null
2013-03-10 19:53:19.06 UTC
3
2021-11-22 02:32:39.17 UTC
2013-03-10 20:11:40.74 UTC
null
559,784
user2015601
null
null
1
20
r|dataframe|multiple-columns
64,300
<p>I think it's better to focus on <em>wanting to get rid of one column of data</em> and not wanting to select every other column. You can do this as @Arun suggested:</p> <pre><code>olddata[,-1] </code></pre> <p>Or:</p> <pre><code>olddata$ColNameToDelete &lt;- NULL </code></pre>
43,755,888
How to convert a boto3 Dynamo DB item to a regular dictionary in Python?
<p>In Python, when an item is retrieved from Dynamo DB using boto3, a schema like the following is obtained.</p> <pre><code>{ "ACTIVE": { "BOOL": true }, "CRC": { "N": "-1600155180" }, "ID": { "S": "bewfv43843b" }, "params": { "M": { "customer": { "S": "TEST" }, ...
46,738,251
3
5
null
2017-05-03 09:17:17.98 UTC
18
2021-06-28 14:16:43.773 UTC
null
null
null
null
5,356,688
null
1
50
python|amazon-web-services|dictionary|amazon-dynamodb|boto3
32,565
<p>In order to understand how to solve this, it's important to recognize that boto3 has two basic modes of operation: one that uses the low-level <a href="http://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#client" rel="noreferrer">Client</a> API, and one that uses higher level abstractions like <a h...
38,418,482
RecyclerView.ViewHolder unable to bind view with ButterKnife
<p>I'm using <code>ButterKnife</code> to bind my views on my <code>ViewHolder</code>. My code is below:</p> <pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.ViewHolder&gt; { private List&lt;DataObject&gt; data; public MyAdapter(List&lt;DataObject&gt; data) { this.data = dat...
38,419,000
2
3
null
2016-07-17 06:16:28.683 UTC
1
2017-01-02 11:27:52.577 UTC
2016-07-17 08:21:24.57 UTC
null
1,233,366
null
1,233,366
null
1
29
android|android-layout|data-binding|android-adapter|butterknife
17,545
<p>Make sure that if you have use <code>ButterKnife</code> library to use this way</p> <p><strong>build.gradle</strong> file of Project</p> <pre><code>buildscript { repositories { mavenCentral() } dependencies { classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' } } </code></pre> <p>Then, ap...
19,325,240
Difference between char **p,char *p[],char p[][]
<pre><code>char *p = "some string" </code></pre> <p>creates a pointer p pointing to a block containing the string.</p> <pre><code>char p[] = "some string" </code></pre> <p>creates a character array and with literals in it.</p> <p>And the first one is a constant declaration.Is it the same of two-dimensional arra...
19,325,640
3
8
null
2013-10-11 18:52:23.61 UTC
16
2022-03-29 09:31:20.43 UTC
2013-10-11 18:57:29.79 UTC
null
1,885,193
null
2,811,020
null
1
15
c
18,549
<h2>Normal Declarations (Not Function Parameters)</h2> <p><code>char **p;</code> declares a pointer to a pointer to <code>char</code>. It reserves space for the pointer. It does not reserve any space for the pointed-to pointers or any <code>char</code>.</p> <p><code>char *p[N];</code> declares an array of <em>N</em> po...
8,971,152
Is text-indent: -9999px a bad technique for replacing text with images, and what are the alternatives?
<p><a href="http://luigimontanez.com/2010/stop-using-text-indent-css-trick/" rel="noreferrer">This article</a> say we should avoid using this technique. <a href="http://aext.net/2010/02/css-text-indent-style-your-html-form/" rel="noreferrer">This one</a> says it's awesome. Is it true that Google looks inside CSS files ...
12,286,560
5
3
null
2012-01-23 11:51:19.577 UTC
12
2012-11-09 13:58:04.483 UTC
2012-01-23 12:14:09.957 UTC
null
20,578
null
376,947
null
1
26
html|css|seo|text-indent
15,053
<p>A good reason not to use the -9999px method is that the browser has to draw a 9999px box for each element that this is applied to. Obviously, that potentially creates quite a performance hit, especially if you're applying it to multiple elements.</p> <p>Alternative methods include this one (from <a href="http://www...
8,941,098
Full-width Spinner in ActionBar
<p>I'd really like my app to have a Spinner which stretches the entire length of my ActionBar, like the one in Gmail 4.0. Anyone know how to achieve this? Even if I set "match_parent" in the Spinner layout resource, it doesn't fill the entire bar. Preferably, I'd like to be able to have it fill the entire bar except fo...
9,193,240
4
3
null
2012-01-20 11:58:44.537 UTC
20
2013-05-25 20:52:02.543 UTC
2013-05-25 20:52:02.543 UTC
null
428,665
null
428,665
null
1
29
android|android-layout|android-actionbar
15,957
<p>Bit annoying that I've just done it, but here is a method of doing it using the built-in Spinner in the action bar. All you need to do is make your spinner item's main container a <code>RelativeLayout</code> and set its gravity to fillHorizontal, like so:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; ...
5,391,280
How to insert a column in a specific position in oracle without dropping and recreating the table?
<p>I have a specific scenario where i have to insert two new columns in an existing table in Oracle. I can not do the dropping and recreating the table. So can it be achieved by any means??</p>
5,392,204
4
5
null
2011-03-22 12:34:40.967 UTC
6
2021-05-18 07:35:33.483 UTC
2011-04-04 06:06:11.293 UTC
null
409,172
null
239,999
null
1
32
oracle|oracle11g
127,382
<p>Amit-</p> <p>I don't believe you can add a column anywhere but at the end of the table once the table is created. One solution might be to try this:</p> <pre><code>CREATE TABLE MY_TEMP_TABLE AS SELECT * FROM TABLE_TO_CHANGE; </code></pre> <p>Drop the table you want to add columns to:</p> <pre><code>DROP TABLE T...
5,478,848
Does Apple reject "mobile web shell" applications?
<p>I'm not sure how to word this correctly, so I'm going to be a little verbose:</p> <p>I'm tasked with building an app for my company that will just load a mobile website into a barebones browser with no address bar or anything. So basically the app will be just the same as if the user had navigated there in Safari (...
5,478,893
4
1
null
2011-03-29 20:59:02.863 UTC
11
2019-07-11 07:06:53.36 UTC
null
null
null
null
462,252
null
1
43
iphone|ipad
21,857
<p>Apple may reject your app if all it does is wrap a web site in a UIWebView. You need to have more functionality in your app than just loading a web page.</p> <p>From the <a href="https://developer.apple.com/app-store/review/guidelines/" rel="nofollow noreferrer">app review guidelines</a> for iOS:</p> <blockquote> ...
5,398,772
Firefox 4 onBeforeUnload custom message
<p>In Firefox <strong>3</strong>, I was able to write a custom confirmation popup with:</p> <pre><code>window.onbeforeunload = function() { if (someCondition) { return 'Your stream will be turned off'; } } </code></pre> <p>Now in Firefox <strong>4</strong>, it does not show my custom message. The default ...
5,398,788
4
1
null
2011-03-22 22:44:42.1 UTC
10
2015-05-20 16:40:35.367 UTC
null
null
null
null
459,987
null
1
70
javascript|firefox|firefox4
49,650
<p>From <a href="https://developer.mozilla.org/en/DOM/window.onbeforeunload" rel="noreferrer">MDN</a>:</p> <blockquote> <p>Note that in Firefox 4 and later the returned string is not displayed to the user. See Bug <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=588292" rel="noreferrer">588292</a>.</p> </blockq...
5,495,965
how can I set visible back to true in jquery
<p>I am using the following code to hide a dropdown box:</p> <pre><code> &lt;asp:DropDownList ID="test1" runat="server" DataSourceID="dsTestType" CssClass="maptest1" visible="false" DataValueField="test_code" DataTextField="test_desc" AppendDataBoundItems="true" &gt; &lt;asp:ListItem&gt;&lt;/asp:ListItem&gt; ...
5,496,021
8
0
null
2011-03-31 06:19:25.78 UTC
3
2019-05-27 03:09:09.2 UTC
2011-03-31 06:24:32.297 UTC
null
534,109
null
52,745
null
1
22
jquery
158,990
<p>Using ASP.NET's <code>visible="false"</code> property will set the <code>visibility</code> attribute where as I think when you call <code>show()</code> in jQuery it modifies the <code>display</code> attribute of the CSS style.</p> <p>So doing the latter won't rectify the former.</p> <p>You need to do this:</p> <...
5,366,285
Parse string to DateTime in C#
<p>I have <strong>date and time</strong> in a string formatted like that one:</p> <pre><code>"2011-03-21 13:26" //year-month-day hour:minute </code></pre> <p>How can I parse it to <code>System.DateTime</code>?</p> <p>I want to use functions like <code>DateTime.Parse()</code> or <code>DateTime.ParseExact()</code> if ...
5,366,311
9
3
null
2011-03-20 01:58:54.587 UTC
25
2022-09-12 07:22:32.617 UTC
2018-06-20 07:18:35.253 UTC
null
1,016,343
null
465,408
null
1
209
c#|.net|string|parsing|datetime
396,484
<p><code>DateTime.Parse()</code> will try figure out the format of the given date, and it usually does a good job. If you can guarantee dates will always be in a given format then you can use <code>ParseExact()</code>:</p> <pre><code>string s = "2011-03-21 13:26"; DateTime dt = DateTime.ParseExact(s, "yyyy-MM-dd...
5,181,401
VS 2008 breakpoint will not currently be hit. No symbols have been loaded for this document
<p>I am struggling to overcome this obstacle and I have high hopes that someone on SO can help. </p> <p><img src="https://i.stack.imgur.com/Mtk3H.png" alt="enter image description here"></p> <p>When I set a breakpoint in my <em>class library</em> project. It appears as a normal breakpoint. When I start debugging m...
7,338,377
13
1
null
2011-03-03 13:35:10.17 UTC
4
2018-01-20 10:27:25.517 UTC
2017-05-23 11:46:39.687 UTC
null
-1
null
437,301
null
1
31
vb.net|visual-studio-2008|breakpoints
23,130
<p>This may be an old question, but I wanted to answer it after I found a solution for this very problem because it was one of the most complete questions asked in regards to this topic.</p> <p><strong>Intro</strong></p> <p>My project is an ASP.NET application, but the base problem will happen on WinForms as well. T...
29,592,924
Find offset relative to parent scrolling div instead of window
<p>I have a scrolling element inside a window.</p> <p>Say a division having a class "currentContainer" with overflow auto and that division contains huge amount of text so that it is definitely large enough to be scrolling.</p> <p>Now I have to do some calculations based on how much the "currentContainer" has scrolle...
29,599,312
4
6
null
2015-04-12 18:21:37.043 UTC
2
2022-04-11 07:10:32.81 UTC
2015-04-15 00:16:45.733 UTC
null
2,686,013
null
2,357,882
null
1
27
jquery|css|scroll|overflow|scrolltop
40,852
<p>You could just subtract the offset of the parent element from the offset of the child element. Will that complicate the other things you need to do as well?</p> <pre><code>$(".getoffset").offset().top - $(".getoffset").offsetParent().offset().top </code></pre> <p><a href="http://jsfiddle.net/kmLr07oh/2/" rel="nore...
12,059,424
About MySQLdb conn.autocommit(True)
<p>I have installed python 2.7 64bit,MySQL-python-1.2.3.win-amd64-py2.7.exe.</p> <p>I use the following code to insert data :</p> <pre><code>class postcon: def POST(self): conn=MySQLdb.connect(host="localhost",user="root",passwd="mysql",db="dang",charset="utf8") cursor = conn.cursor() n ...
12,059,473
3
2
null
2012-08-21 16:42:20.11 UTC
3
2021-01-21 19:19:39.35 UTC
2012-08-21 16:47:29.373 UTC
null
263,525
null
1,609,714
null
1
11
python|mysql-python
40,969
<p>I don't know if there's a specific reason to use autocommit with GAE (assuming you are using it). Otherwise, you can just manually commit.</p> <pre><code>class postcon: def POST(self): conn=MySQLdb.connect(host="localhost",user="root",passwd="mysql",db="dang",charset="utf8") cursor = conn.curs...
12,116,413
How do I style a Qt Widget not its children with stylesheets?
<p>I have a: </p> <pre><code>class Box : public QWidget </code></pre> <p>and it has </p> <pre><code>this-&gt;setLayout(new QGridLayout(this)); </code></pre> <p>I tried doing: </p> <pre><code>this-&gt;setStyleSheet( "border-radius: 5px; " "border: 1px solid black;" "border:...
12,117,468
3
0
null
2012-08-24 20:46:15.887 UTC
11
2022-01-14 03:23:38.327 UTC
2012-08-24 21:16:37.4 UTC
null
516,813
null
516,813
null
1
13
c++|qt|widget
21,016
<p>To be more precise I could have used:</p> <pre><code>QWidget#idName { border: 1px solid grey; } </code></pre> <p>or</p> <pre><code>Box { border: 1px solid grey; } </code></pre> <p>The latter is easier, in my opinion, as it doesn't require the use of id names.</p> <p>The main problem with why these weren...
12,461,117
jQuery Mobile get current page
<p>I am using jQuery Mobile 1.1.1 and Apache Cordova 2.0.0. I want my app to exit when I press back button but only if current page have ID = feedZive. I am using following code to do it:</p> <pre><code>function onDeviceReady(){ document.addEventListener("backbutton", onBackKeyDown, false); function onBackKeyD...
12,564,089
8
0
null
2012-09-17 14:11:16.833 UTC
6
2016-02-06 19:26:19.153 UTC
2014-12-15 12:57:23.5 UTC
null
1,771,795
null
1,503,758
null
1
21
javascript|cordova|jquery-mobile
51,239
<pre><code>$(document).live('pagebeforeshow', function() { alert($.mobile.activePage.attr('id')); });​ </code></pre> <p><a href="http://jsfiddle.net/ajD6w/5/">http://jsfiddle.net/ajD6w/5/</a></p>
12,495,723
Using XPath wildcards in attributes in Selenium WebDriver
<p>I want to use Wildcards in my attributes. For example, this is my regular XPath: </p> <pre><code>//input[@id='activation:j_idt84:voId:1']` </code></pre> <p>I want to replace the <code>j_idt</code> number with a wildcard because the number is dynamic. I'm looking for something like this:</p> <pre><code>//input[@id...
12,495,992
2
0
null
2012-09-19 13:26:10.547 UTC
3
2018-07-16 20:05:08.077 UTC
2017-01-05 22:01:45.633 UTC
null
4,816,518
null
1,635,326
null
1
21
selenium|xpath
38,328
<p>Unfortunately there's no string wildcards in XPath. However you can use multiple <code>contains()</code> and <code>starts-with()</code> to filter things like this.</p> <pre><code>//input[starts-with(@id, 'activation:') and contains(@id, ':voId:1')] </code></pre> <p>Also, this answer could be useful too: <a href="h...
12,100,157
How to reuse SqlCommand parameter through every iteration?
<p>I want to implement a simple delete button for my database. The event method looks something like this:</p> <pre><code>private void btnDeleteUser_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure?", "delete users",MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { ...
12,100,248
4
0
null
2012-08-23 21:21:38.983 UTC
4
2019-11-12 15:54:33.603 UTC
2015-05-17 07:39:37.28 UTC
null
1,402,846
null
1,600,108
null
1
22
c#|sql-server|ado.net
40,022
<p><code>Parameters.AddWithValue</code> adds a new Parameter to the command. Since you're doing that in a loop with the same name, you're getting the exception <em>"Variable names must be unique"</em>.</p> <p>So you only need one parameter, add it before the loop and change only it's value in the loop.</p> <pre><code...
12,369,295
Flask SQLAlchemy display queries for debug
<p>I am developing an app with flask and SQL Alchemy. I need to display the queries executed to generate a page alongside the time each query took for debugging</p> <p>What's the best way to do it?</p>
12,369,681
9
0
null
2012-09-11 12:03:33.293 UTC
5
2022-08-02 13:56:12.453 UTC
null
null
null
null
615,110
null
1
60
sqlalchemy|flask
45,354
<p>I haven't used it myself, but it seems that Flask Debug-toolbar may help with this.</p> <p><a href="https://github.com/mgood/flask-debugtoolbar">https://github.com/mgood/flask-debugtoolbar</a></p> <p>It's a port of the django-debug-toolbar, which can be used for profiling queries. The documentation of Flask Debug-...
12,381,563
How can I stop the browser back button using JavaScript?
<p>I am doing an online quiz application in PHP. I want to restrict the user from going back in an exam.</p> <p>I have tried the following script, but it stops my timer.</p> <p>What should I do?</p> <p>The timer is stored in file <em>cdtimer.js</em>.</p> <pre class="lang-html prettyprint-override"><code>&lt;script type...
12,381,610
37
1
null
2012-09-12 05:09:11.44 UTC
110
2022-06-25 04:36:46.26 UTC
2020-12-14 22:53:13.517 UTC
null
63,550
null
1,656,134
null
1
223
javascript|browser
721,204
<p>There are numerous reasons why disabling the back button will not really work. Your best bet is to warn the user:</p> <pre><code>window.onbeforeunload = function() { return "Your work will be lost."; }; </code></pre> <p>This page does list a number of ways you <em>could</em> try to disable the back button, but non...
44,026,548
Getting TypeError: __init__() missing 1 required positional argument: 'on_delete' when trying to add parent table after child table with entries
<p>I have two classes in my sqlite database, a parent table named <code>Categorie</code> and the child table called <code>Article</code>. I created first the child table class and addes entries. So first I had this:</p> <pre><code>class Article(models.Model): titre=models.CharField(max_length=100) auteur=model...
44,026,807
12
4
null
2017-05-17 13:39:11.477 UTC
42
2022-06-04 08:34:10.783 UTC
2022-06-04 08:34:10.783 UTC
null
8,172,439
null
6,137,017
null
1
126
python|python-3.x|django|django-models|django-2.0
205,903
<p>You can change the property <code>categorie</code> of the class <code>Article</code> like this:</p> <pre><code>categorie = models.ForeignKey( 'Categorie', on_delete=models.CASCADE, ) </code></pre> <p>and the error should disappear.</p> <p>Eventually you might need another option for <code>on_delete</code>...
24,297,273
openURL not work in Action Extension
<p>I add following code:</p> <pre><code>- (IBAction)done { // Return any edited content to the host app. // This template doesn't do anything, so we just echo the passed in items. NSURL *url = [NSURL URLWithString:@"lister://today"]; [self.extensionContext openURL:url completionHandler:^(BOOL success)...
24,709,883
17
4
null
2014-06-19 01:08:19.793 UTC
40
2020-08-17 08:56:12.153 UTC
2014-06-19 15:20:30.817 UTC
null
2,446,155
null
712,823
null
1
54
ios|ios8|ios-app-extension
34,695
<p>This is by design. We don't want Custom Actions to become app launchers.</p>
24,100,602
Developing Python applications in Qt Creator
<p>I've developed a few Qt projects in C++ using Qt Creator in the past, but now I want to experiment with the Python implementation of Qt. I discovered that Qt Creator 2.8 and higher <a href="http://blog.qt.digia.com/blog/2013/07/11/qt-creator-2-8-0-released/">support Python</a>, but I haven't been able to figure out ...
24,121,860
2
6
null
2014-06-07 19:00:14.903 UTC
31
2018-09-16 19:39:08.607 UTC
null
null
null
null
217,649
null
1
48
python|qt
83,249
<p>Currently, <code>Qt Creator</code> allows you to create Python files (not projects) and run them. It also has syntax highlighting, but it lacks more complex features such as autocomplete. <br></p> <p>Running scripts requires some configuration (I used <a href="http://ceg.developpez.com/tutoriels/python/configurer-q...
3,749,200
Cannot find class in same package
<p>I am trying to compile Board.java, which is in the same package (and directory) as Hexagon.java, but I get this error:</p> <pre><code>Board.java:12: cannot find symbol symbol : class Hexagon location: class oadams_atroche.Board private Hexagon[][] tiles; </code></pre> <p>The first few lines of Board.java:</p>...
3,749,272
3
6
null
2010-09-20 06:51:59.503 UTC
4
2021-07-05 16:43:48.81 UTC
2010-09-20 07:02:22.49 UTC
null
328,764
null
328,764
null
1
26
java
39,166
<p>I'm quite sure you're compiling from within the wrong directory. <strong>You should compile from the</strong> source root-directory, and not from within the oadams_atroches directory.</p> <p>Have a look at this bash-session:</p> <pre><code>aioobe@r60:~/tmp/hex/oadams_atroche$ ls Board.java Hexagon.java aioobe@r60...
3,597,781
Dr Racket problems with SICP
<p>I'm working through SICP. Currently, in the first chapter, I'm having problems getting Racket to let me redefine "primitives". For instance, I was under the impression that I should be able to arbitrarily do <code>(define + 5)</code> and that would be fine, or redefine the <code>sqrt</code> procedure. Instead, I get...
3,598,093
3
1
null
2010-08-30 03:58:45.19 UTC
16
2017-11-28 06:07:37.853 UTC
2017-11-28 06:07:37.853 UTC
user7387082
null
null
392,119
null
1
32
lisp|scheme|racket|sicp
10,949
<p>Even if possible, such redefinitions are not something that you should do without really understanding how the system will react to this. For example, if you redefine <code>+</code>, will any other code break? The answer to that in Racket's case is "no" -- but this is because you don't really get to redefine <code...
3,473,552
c# - should I use "ref" to pass a collection (e.g. List) by reference to a method?
<p>Should I use "ref" to pass a list variable by reference to a method?</p> <p>Is the answer that "ref" is not needed (as the list would be a reference variable), however for ease in readability put the "ref" in? </p>
3,473,560
3
1
null
2010-08-13 02:52:56.597 UTC
7
2010-08-13 02:58:36.08 UTC
null
null
null
null
173,520
null
1
44
c#|methods|pass-by-reference
42,054
<p>No, don't use a ref unless you want to change what list the variable is referencing. If you want to just access the list, do it without ref.</p> <p>If you make a parameter ref, you are saying that the caller should expect that the parameter they pass in could be assigned to another object. If you aren't doing tha...
3,516,823
What's the difference between the index, cached, and staged in git?
<p>Are these the same thing? If so, why are there so many terms?!</p> <p>Also, I know there is this thing called git stash, which is a place where you can temporarily store changes to your working copy without committing them to the repo. I find this tool really useful, but again, the name is very similar to a bunch o...
3,516,845
3
3
null
2010-08-18 21:23:01.457 UTC
10
2022-08-02 04:00:04.193 UTC
null
null
null
null
62,163
null
1
54
git
9,173
<p>The index/stage/cache are the same thing - as for why so many terms, I think that index was the 'original' term, but people found it confusing, so the other terms were introduced. And I agree that it makes things a bit confusing sometimes at first.</p> <p>The <code>stash</code> facility of git is a way to store 'in...
3,616,572
How to position a div in bottom right corner of a browser?
<p>I am trying to place my div with some notes in the <strong>bottom right</strong> position of the screen which will be displayed all time.</p> <p>I used following css for it:</p> <pre><code>#foo { position: fixed; bottom: 0; right: 0; } </code></pre> <p>It works fine with Chrome 3 and Firefox 3.6 bu...
3,616,659
3
4
null
2010-09-01 09:21:33.94 UTC
16
2014-01-04 20:20:20.96 UTC
2013-08-01 18:28:58.167 UTC
null
579,405
null
178,301
null
1
90
css|cross-browser
261,541
<p>This snippet works in IE7 at least</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=utf-8 /&gt; &lt;title&gt;Test&lt;/title&gt; &lt;style&gt; #foo { position: fixed; bottom: 0; right: 0; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="foo"&gt;Hello World&lt;/...
8,507,561
What is the implementing class for IGrouping?
<p>I am trying create a WCF Data Services ServiceOperation that does grouping on the server side and then sends the data down to the client.</p> <p>When I try to call it (or even connect to the service) I get an error. It says that it can't construct an interface.</p> <p>The only interface I am using is IGrouping. ...
8,508,212
3
8
null
2011-12-14 16:01:05.333 UTC
5
2015-03-20 04:08:35.31 UTC
2011-12-14 16:13:32.073 UTC
null
16,241
null
16,241
null
1
28
c#|.net|wcf-data-services
18,758
<p>Several types in the BCL implement <code>IGrouping</code>, however they are all internal and cannot be accessed except by the <code>IGrouping</code> interface.</p> <p>But an <code>IGrouping</code> is merely an <code>IEnumerable&lt;TElement&gt;</code> with an associated key. You can easily implement an <code>IGroupi...
8,924,149
Should std::bind be compatible with boost::asio?
<p>I am trying to adapt one of the boost::asio examples to use c++11 / TR1 libraries where possible. The original code looks like this:</p> <pre><code>void start_accept() { tcp_connection::pointer new_connection = tcp_connection::create(acceptor_.get_io_service()); acceptor_.async_accept(new_connection-&gt;s...
9,536,984
1
9
null
2012-01-19 10:04:48.823 UTC
8
2012-10-26 14:53:45.69 UTC
2012-03-02 16:39:36.797 UTC
null
926,751
null
926,751
null
1
44
c++|boost|c++11|boost-asio
7,148
<p><strong>I now have a solution</strong></p> <p>The problem is that when I first tried to switch to <a href="http://en.cppreference.com/w/cpp/utility/functional/bind" rel="noreferrer"><code>std::bind</code></a> and <a href="http://en.cppreference.com/w/cpp/memory/shared_ptr" rel="noreferrer"><code>std::shared_ptr</co...
11,242,224
Junit difference between assertEquals(Double, Double) and assertEquals(double, double, delta)
<p>I had a junit test asserting two Double objects with the following:</p> <pre><code>Assert.assertEquals(Double expected, Double result); </code></pre> <p>This was was fine then I decided to change it to use the primitive double instead which turned out to be deprecated unless you also provide a delta.</p> <p>so wh...
11,242,313
6
0
null
2012-06-28 10:02:26.333 UTC
2
2021-02-28 00:07:10.42 UTC
2012-06-28 20:55:31.593 UTC
null
265,143
null
1,424,675
null
1
14
java|unit-testing|junit
49,617
<p>There is NO <a href="http://junit.sourceforge.net/javadoc/org/junit/Assert.html" rel="noreferrer">assert method in JUnit</a> with the signature</p> <pre><code>assertEquals(Double expected, Double result); </code></pre> <p>There is one, however, generic for objects:</p> <pre><code>assertEquals(Object expected, Obj...
11,282,846
Redirect One Controller to another Controller
<p>I have two controllers users &amp; movies. All, I want to do, redirect from user#something to movie#something. is it possible??</p>
11,282,852
2
0
null
2012-07-01 14:40:41.137 UTC
4
2021-09-06 13:57:45.837 UTC
null
null
null
null
1,055,090
null
1
16
ruby-on-rails|ruby|ruby-on-rails-3|ruby-on-rails-3.1
39,919
<p>Yes. Look at redirect_to. <a href="http://api.rubyonrails.org/classes/ActionController/Redirecting.html#method-i-redirect_to" rel="noreferrer">http://api.rubyonrails.org/classes/ActionController/Redirecting.html#method-i-redirect_to</a></p>