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
3,752,019
How to get the index of a value in a vector using for_each?
<p>I have the following code (compiler: MSVC++ 10):</p> <pre><code>std::vector&lt;float&gt; data; data.push_back(1.0f); data.push_back(1.0f); data.push_back(2.0f); // lambda expression std::for_each(data.begin(), data.end(), [](int value) { // Can I get here index of the value too? }); </code></pre> <p>What I w...
3,752,089
10
0
null
2010-09-20 13:41:20.893 UTC
7
2018-08-24 08:24:18.977 UTC
2014-12-20 00:40:03.423 UTC
null
2,642,204
null
189,636
null
1
34
c++|c++11|lambda
33,209
<p>I don't think you can capture the index, but you can use an outer variable to do the indexing, capturing it into the lambda:</p> <pre><code>int j = 0; std::for_each(data.begin(), data.end(), [&amp;j](float const&amp; value) { j++; }); std::cout &lt;&lt; j &lt;&lt; std::endl; </code></pre> <p>This print...
3,450,022
Check and return duplicates array php
<p>I would like to check if my array has any duplicates and return the duplicated values in an array. I want this to be as efficient as possible.</p> <p>Example:</p> <pre><code>$array = array( 1, 2, 2, 4, 5 ); function return_dup($array); // should return 2 $array2 = array( 1, 2, 1, 2, 5 ); function return_dup($array2...
3,450,223
10
0
null
2010-08-10 14:28:10.787 UTC
6
2020-10-11 00:50:45.467 UTC
2020-10-11 00:00:42.153 UTC
null
947,370
null
450,504
null
1
50
php|arrays|duplicates
79,109
<p>this will be ~100 times faster than array_diff</p> <pre><code>$dups = array(); foreach(array_count_values($arr) as $val =&gt; $c) if($c &gt; 1) $dups[] = $val; </code></pre>
3,616,221
Search code inside a Github project
<p>Is there a way to grep for something inside a Github project's code?</p> <p>I could pull the source and grep it locally, but I was wondering if it's possible through the web interface or a 3rd-party alternative.</p> <p>Ideas?</p>
3,616,259
11
3
null
2010-09-01 08:29:54.46 UTC
80
2022-08-18 21:53:57.143 UTC
null
null
null
null
392,350
null
1
371
git|search|github
206,365
<p>Update Dec. 2021: search has <a href="https://stackoverflow.com/a/70279542/6309">been improved again</a>, with Search for an exact string, with support for substring matches and special characters, or regexps.</p> <p><a href="https://i.stack.imgur.com/A4l07.png" rel="noreferrer"><img src="https://i.stack.imgur.com/A...
3,931,156
Finding the hundred largest numbers in a file of a billion
<p>I went to an interview today and was asked this question:</p> <blockquote> <p>Suppose you have one billion integers which are unsorted in a disk file. How would you determine the largest hundred numbers?</p> </blockquote> <p>I'm not even sure where I would start on this question. What is the most efficient proce...
3,931,214
14
5
null
2010-10-14 07:56:40.513 UTC
36
2016-12-09 22:14:59.283 UTC
2016-03-10 03:56:46.047 UTC
null
603,977
null
379,071
null
1
36
algorithm|sorting
13,421
<p>Here's my initial algorithm:</p> <pre><code>create array of size 100 [0..99]. read first 100 numbers and put into array. sort array in ascending order. while more numbers in file: get next number N. if N &gt; array[0]: if N &gt; array[99]: shift array[1..99] to array[0..98]. ...
7,770,030
Preset the "save as type" field while using Application.FileDialog(msoFileDialogSaveAs) with MSAccess
<p>I searched all over for a way to do this.</p> <p>I want to open a Save As dialog box so the user can choose the location to save a file. But, <strong>I want the "Save as type" field to be preset with "comma seperated value File (*.csv)"</strong></p> <p>The problem is the "Filter" methode does not seem to work with...
7,770,786
5
5
null
2011-10-14 15:36:53.137 UTC
3
2020-06-05 15:15:42.207 UTC
2011-10-14 16:14:25.973 UTC
null
648,798
null
648,798
null
1
15
vba|ms-access-2007
49,071
<p>As stated he <code>FileDialog</code> help states <code>msoFileDialogSaveAs</code> is not supported.</p> <p>You can force a CSV extension on <code>FileName</code> when the dialog unloads;</p> <pre><code>FileName = getCSVName(FileName) ... Function getCSVName(fileName As String) As String Dim pos As Long pos =...
7,871,767
Changing image view background dynamically
<p>I have a a set of 10 imageviews in my layout. I have given them sequential id's also as</p> <pre><code>android:id="@+id/pb1" android:id="@+id/pb2" </code></pre> <p>Now I want to change background dynamically. </p> <pre><code> int totalPoi = listOfPOI.size(); int currentPoi = (j/totalPoi)*10; for (i=1;...
7,876,872
6
1
null
2011-10-24 05:57:50.62 UTC
2
2016-08-02 17:46:13.67 UTC
2011-10-24 07:30:07.08 UTC
null
243,709
null
824,546
null
1
4
android|imageview
44,084
<p>Finally I did this in the following way, </p> <p>I placed all the id's in the array as</p> <pre><code>int[] imageViews = {R.id.pb1, R.id.pb2,R.id.pb3,R.id.pb4,R.id.pb5,R.id.pb6,R.id.pb7,R.id.pb8,R.id.pb9,R.id.pb10}; </code></pre> <p>Now: </p> <pre><code>int pindex = 0; for (pindex; pindex &lt;currentPoi; pindex...
7,957,944
Search for Capital Letter in String
<p>I am trying to search a string for the last index of a capital letter. I don't mind using regular expressions, but I'm not too familiar with them.</p> <pre><code>int searchPattern = searchString.lastIndexOf(" "); String resultingString = searchString.substring(searchPattern + 1); </code></pre> <p>As you can ...
7,958,064
6
1
null
2011-10-31 18:23:53.583 UTC
0
2019-04-13 00:56:45.17 UTC
null
null
null
null
1,015,683
null
1
4
java
46,623
<p>You can write a method as follows:</p> <pre><code>public int lastIndexOfUCL(String str) { for(int i=str.length()-1; i&gt;=0; i--) { if(Character.isUpperCase(str.charAt(i))) { return i; } } return -1; } </code></pre>
8,060,170
Printing hexadecimal characters in C
<p>I'm trying to read in a line of characters, then print out the hexadecimal equivalent of the characters.</p> <p>For example, if I have a string that is <code>"0xc0 0xc0 abc123"</code>, where the first 2 characters are <code>c0</code> in hex and the remaining characters are <code>abc123</code> in ASCII, then I shoul...
8,060,195
7
1
null
2011-11-09 03:59:16.96 UTC
41
2018-11-06 19:49:23.273 UTC
2011-11-09 05:08:49.82 UTC
null
571,189
null
270,043
null
1
120
c|hex|printf
436,220
<p>You are seeing the <code>ffffff</code> because <code>char</code> is signed on your system. In C, vararg functions such as <code>printf</code> will promote all integers smaller than <code>int</code> to <code>int</code>. Since <code>char</code> is an integer (8-bit signed integer in your case), your chars are being pr...
8,240,637
Convert numbers to letters beyond the 26 character alphabet
<p>I'm creating some client side functions for a mappable spreadsheet export feature.</p> <p>I'm using jQuery to manage the sort order of the columns, but each column is ordered like an Excel spreadsheet i.e. a b c d e......x y z aa ab ac ad etc etc</p> <p>How can I generate a number as a letter? Should I define a fi...
8,241,071
8
0
null
2011-11-23 10:29:09.947 UTC
7
2022-07-18 16:41:24.16 UTC
2015-12-14 08:06:05.313 UTC
null
493,762
null
493,762
null
1
28
javascript|jquery
23,625
<p>I think you're looking for something like this</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> function colName(n) { var ordA = 'a'.charCodeAt(0); var ordZ = 'z'.charCodeAt(0); var le...
4,138,754
Getting an attribute value in xml element
<p>I have an xml string like this and I want to get attribute value of "name" in a loop for each element. How do I do that? I am using javax.xml.parsers library. </p> <pre class="lang-js prettyprint-override"><code>&lt;xml&gt; &lt;Item type="ItemHeader" name="Plan Features" id="id_1"/&gt; &lt;Item type="Deduct...
4,138,822
3
0
null
2010-11-09 21:20:18.227 UTC
6
2017-10-30 21:49:39.867 UTC
2017-10-30 21:49:39.867 UTC
null
1,021,725
null
203,018
null
1
24
java|xml
147,392
<p>I think I got it. I have to use <code>org.w3c.dom.Element</code> explicitly. I had a different Element field too.</p>
4,210,138
View() vs. PartialView()
<p>The <code>View()</code> method can load Partial Views. </p> <p>Is the difference between <code>View()</code> and <code>PartialView()</code> is that <code>View()</code> can load views and partial views and <code>PartialView()</code> can only load partial views?</p>
4,210,291
3
2
null
2010-11-17 23:08:36.88 UTC
6
2017-02-09 12:57:16.287 UTC
2010-11-17 23:26:19.81 UTC
null
23,199
null
89,605
null
1
38
asp.net-mvc
29,208
<p>It's up to a view engine to decide if they want to treat partial views different from regular views.</p> <p>For example, in the WebFormViewEngine there is no difference.</p> <p>In the new ASP.NET MVC 3 RazorViewEngine there are some differences. Only regular views will have the "_viewstart.cshtml" pages run becaus...
4,535,846
PHP: Adding prefix strings to array values
<p>What is the best way to add a specific value or values to an array? Kinda hard to explain, but this should help:</p> <pre><code>&lt;?php $myarray = array("test", "test2", "test3"); $myarray = array_addstuff($myarray, " "); var_dump($myarray); ?&gt; </code></pre> <p>Which outputs:</p> <pre><code>array(3) { [0]=&...
4,535,862
4
1
null
2010-12-26 23:25:43.757 UTC
2
2017-08-04 22:21:08.7 UTC
2017-04-28 17:56:43.11 UTC
null
5,423,014
null
345,645
null
1
23
php|arrays
42,682
<p>In the case that you're using a PHP version >= 5.3:</p> <pre><code>$array = array('a', 'b', 'c'); array_walk($array, function(&amp;$value, $key) { $value .= 'd'; } ); </code></pre>
4,547,453
Can you write virtual functions / methods in Java?
<p>Is it possible to write <em>virtual</em> methods in Java, as one would do in C++?</p> <p>Or, is there a proper Java approach which you can implement that produces similar behavior? Could I please have some examples?</p>
4,547,462
6
0
null
2010-12-28 16:17:57.587 UTC
46
2019-10-28 06:48:28.48 UTC
2015-04-11 19:10:57.55 UTC
null
445,131
null
486,483
null
1
189
java|virtual|virtual-functions
244,240
<h2>From <a href="http://en.wikipedia.org/wiki/Virtual_function" rel="noreferrer">wikipedia</a></h2> <blockquote> <p>In <strong>Java</strong>, all non-static methods are by default "<strong>virtual functions.</strong>" Only methods marked with the <strong>keyword final</strong>, which cannot be overridden, alo...
4,770,297
Convert UTC datetime string to local datetime
<p>I've never had to convert time to and from UTC. Recently had a request to have my app be timezone aware, and I've been running myself in circles. Lots of information on converting local time to UTC, which I found fairly elementary (maybe I'm doing that wrong as well), but I can not find any information on easily con...
4,771,733
16
2
null
2011-01-22 20:14:50.58 UTC
134
2022-02-09 18:44:36.91 UTC
2019-03-09 10:57:35.05 UTC
null
355,230
null
443,722
null
1
288
python|datetime|utc|localtime
510,848
<p>If you don't want to provide your own <code>tzinfo</code> objects, check out the <a href="http://niemeyer.net/python-dateutil">python-dateutil</a> library. It provides <code>tzinfo</code> implementations on top of a <a href="http://en.wikipedia.org/wiki/Tz_database">zoneinfo (Olson) database</a> such that you can r...
14,372,880
simple examples of filter function, recursive option specifically
<p>I am seeking some simple (i.e. - no maths notation, long-form reproducible code) examples for the <code>filter</code> function in R I think I have my head around the convolution method, but am stuck at generalising the recursive option. I have read and battled with various documentation, but the help is just a bit o...
14,373,503
4
2
null
2013-01-17 05:45:40.363 UTC
13
2015-12-24 10:25:51.623 UTC
2017-05-23 11:54:10.437 UTC
null
-1
null
496,803
null
1
27
r|filter|time-series
24,258
<p>In the recursive case, I think no need to expand the expression in terms of xi. The key with "recursive" is to express the right hand expression in terms of previous y's.</p> <p>I prefer thinking in terms of filter size. </p> <p>filter size =1</p> <pre><code>y1 &lt;- x1 ...
14,685,149
Creating an installer for Java desktop application
<p>I know this question has been asked many a times and all the time there is an answer which says about using an executable jar or making an .exe using launch4j or similar app.</p> <p>I may sound like a novice, which I actually am. </p> <p>I have been trying a few things with a Java project. I have successfully made...
14,686,023
8
3
null
2013-02-04 10:52:29.923 UTC
22
2022-03-16 10:09:11.057 UTC
2017-01-05 04:34:03.287 UTC
null
1,759,128
null
1,759,128
null
1
29
java|deployment|installation|desktop-application
48,498
<p>I have been using <a href="http://www.jrsoftware.org/isinfo.php">InnoSetup</a> for a long time. It has always worked very well. It can do everything you need (unpack files, put shortcuts on desktop, start menu etc) and generates installers that we are used to.</p>
35,003,153
Incorrect syntax near 'THROW'
<pre><code>IF @SQL IS NOT NULL BEGIN BEGIN TRY EXEC sp_executesql @SQL PRINT 'SUCCESS: ' + @SQL END TRY BEGIN CATCH SET @ErrorMessage = N'Error dropping constraint' + @CRLF + 'Table ' + @TableName + @CRLF + 'Script: ' + @...
35,003,196
3
0
null
2016-01-25 21:54:56.89 UTC
3
2020-08-18 11:13:16.013 UTC
2016-01-25 23:48:27.373 UTC
null
2,123,899
null
2,123,899
null
1
46
sql-server|tsql|sql-server-2014
17,116
<p>From <a href="https://msdn.microsoft.com/en-us/library/ee677615.aspx">MSDN</a>:</p> <blockquote> <p>The statement before the THROW statement must be followed by the semicolon (;) statement terminator.</p> </blockquote>
49,948,350
phpMyAdmin on MySQL 8.0
<p><strong>UPDATE</strong><br> Newer versions of phpMyAdmin solved this issue. I've successfully tested with phpMyAdmin 5.0.1</p> <hr> <p>I have installed the MySQL 8.0 server and phpMyAdmin, but when I try to access it from the browser the following errors occur:</p> <pre><code>#2054 - The server requested authenti...
50,437,307
18
2
null
2018-04-20 19:15:20.577 UTC
34
2021-09-14 10:18:17.94 UTC
2020-02-19 12:43:37.413 UTC
null
8,569,585
null
8,569,585
null
1
83
mysql|phpmyadmin|database-connection|mysql-8.0
186,948
<p>Log in to MySQL console with <strong>root</strong> user:</p> <pre><code>root@9532f0da1a2a:/# mysql -u root -pPASSWORD </code></pre> <p>and change the Authentication Plugin with the password there:</p> <pre><code>mysql&gt; ALTER USER root IDENTIFIED WITH mysql_native_password BY 'PASSWORD'; Query OK, 0 rows affected ...
50,220,854
Could not use Observable.of in RxJs 6 and Angular 6
<pre><code> import { Observable, of } from "rxjs"; // And if I try to return like this return Observable.of(this.purposes); </code></pre> <p>I am getting an error stating, Property 'of' does not exist on type 'typeof Observable'</p>
50,245,593
3
2
null
2018-05-07 19:05:01.89 UTC
9
2019-05-13 17:05:54.707 UTC
2018-08-27 09:43:20.7 UTC
null
5,490,782
null
7,962,294
null
1
64
angular|rxjs6|angular-observable
45,821
<p>Looks like cartant's comment is correct, the <a href="https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md" rel="noreferrer">RxJS upgrade guide</a> doesn't cover that method specifically but does say <em>"Classes that operate on observables have been replaced by functions"</em></p> <p>Which seems to mean all ...
59,391,984
Test Explorer (VS) shows '<Unknown project>'
<p>Everthing below is made in VS2019, using .NET Framework 4.7 and NUnit + NUnit3TestAdapter</p> <p>I created an assembly called Exitus.Tests, and added a few unit tests. However, do to some issues with Nuget, that I could not solve, I made another project called Exitus.UnitTests and removed the once file I had in the...
59,393,012
5
1
null
2019-12-18 12:24:14.817 UTC
16
2020-06-02 07:42:00.803 UTC
null
null
null
null
2,445,415
null
1
182
c#|visual-studio|nunit
17,965
<ol> <li>Close <kbd>Visual Studio</kbd>.</li> <li>Delete the <code>*.testlog</code> files in: <em>solutionfolder</em>\.vs\<em>solution name</em>\v16\TestStore\<em>number</em>.</li> </ol>
63,576,252
Android emulators are not working on macOS Big Sur 11.3+
<p>I have upgraded the mac OS to Big Sur and none of the emulators are working. It seems that all Android emulators Fails on Mac OS Big Sur Beta. I deleted the old emulators and created new ones with different HW/SW, unsuccessfully. Introduced the following issues in the android emulator.</p> <ol> <li>ffffffffb69b4dbb:...
64,072,957
14
17
null
2020-08-25 09:50:02.983 UTC
8
2021-08-11 06:16:36.103 UTC
2021-08-11 06:16:36.103 UTC
null
843,001
null
843,001
null
1
53
android-emulator|macos-big-sur
36,443
<p><strong>Update, 10-1-2020</strong></p> <p>The Android Emulator team has pushed 30.1.5 which fixes this issue in stable. The dev build, 30.2.0 does not contain this fix. It should be available &quot;soon&quot; according to the Googler's working on this.</p> <p>Another note, if you experience poor performance in your ...
34,830,964
How to limit the maximum number of running Celery tasks by name
<p>How do you limit the number of instances of a specific Celery task that can be ran simultaneously?</p> <p>I have a task that processes large files. I'm running into a problem where a user may launch several tasks, causing the server to run out of CPU and memory as it tries to process too many files at once. I want ...
52,166,342
3
0
null
2016-01-16 19:07:52.08 UTC
9
2018-09-04 12:26:48.297 UTC
null
null
null
null
247,542
null
1
17
python|celery|celery-task
8,669
<p>You have to setup extra queue and set desired concurrency level for it. From <a href="http://docs.celeryproject.org/en/latest/userguide/routing.html#id2" rel="noreferrer">Routing Tasks</a>:</p> <pre><code># Old config style CELERY_ROUTES = { 'app.tasks.limited_task': {'queue': 'limited_queue'} ...
47,843,039
How to properly convert domain entities to DTOs while considering scalability & testability
<p>I have read several articles and Stackoverflow posts for converting domain objects to DTOs and tried them out in my code. When it comes to testing and scalability I am always facing some issues. I know the following three possible solutions for converting domain objects to DTOs. Most of the time I am using Spring.</...
47,853,826
5
1
null
2017-12-16 06:05:14.163 UTC
22
2021-05-21 15:41:57.007 UTC
null
null
null
null
9,085,273
null
1
37
java|spring|spring-boot|design-patterns|junit
32,917
<blockquote> <p>Solution 1: Private method in the service layer for converting</p> </blockquote> <p>I guess <strong>Solution 1</strong> will not not work well, because your DTOs are domain-oriented and not service oriented. Thus it will be likely that they are used in different services. So a mapping method does not b...
26,094,084
ng-class condition changes, but not updating classes
<p>I have a very strange issue. I have to set an <code>active</code> class on the appropriate <code>&lt;li&gt;</code> when the <code>$scope.selectedCat == cat.id</code>. The list is generated with ng-repeat. If selectedCat is false, the 'Browse All Categories' list item (outside of ng-repeat) is set to active. <code>se...
26,094,123
5
0
null
2014-09-29 06:56:27.133 UTC
null
2019-07-20 13:19:04.74 UTC
null
null
null
null
3,009,639
null
1
31
javascript|angularjs|ng-class
43,517
<p>Replace:</p> <pre class="lang-none prettyprint-override"><code>ng-class="{'active': {{selectedCat == cat.id}}}" </code></pre> <p>With:</p> <pre class="lang-none prettyprint-override"><code>ng-class="{'active': selectedCat == cat.id}" </code></pre> <p>You never need to nest those curly braces like that, in Angula...
7,536,142
How to Model Real-World Relationships in a Graph Database (like Neo4j)?
<p>I have a general question about modeling in a graph database that I just can't seem to wrap my head around.</p> <p>How do you model this type of relationship: "Newton invented Calculus"?</p> <p>In a <a href="http://docs.neo4j.org/chunked/snapshot/graphdb-neo4j-relationships.html" rel="noreferrer">simple graph</a>,...
7,538,711
1
0
null
2011-09-24 00:30:27.633 UTC
9
2014-12-07 17:10:40.597 UTC
2014-12-07 17:10:40.597 UTC
null
169,992
null
169,992
null
1
20
nosql|neo4j|graph-databases
3,866
<p>Some of these things, such as <code>invention_date</code>, can be stored as properties on the edges as in most graph databases edges can have properties in the same way that vertexes can have properties. For example you could do something like this (code follows <a href="https://github.com/tinkerpop/blueprints" rel=...
40,746,319
Error: <rect> attribute width: Expected length, "NaN". and <text> attribute dx: Expected length, "NaN"
<p>I want to implement a bar chart in D3, but my values on the dx axis are of type Date, data type which the D3 library should accept, but it seems to give me an error like this: attribute width: Expected length, "NaN". This is my code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; ...
40,746,745
2
0
null
2016-11-22 15:56:17.783 UTC
2
2021-11-09 12:05:04.94 UTC
null
null
null
null
7,188,536
null
1
16
javascript|d3.js
41,542
<p>Right now, for the width of the rectangles and the <code>dx</code> of the texts, you're using:</p> <pre><code>xScale.range() - rectPadding </code></pre> <p>But <code>xScale.range()</code> returns an array, and <code>array - number</code> will give you a <code>NaN</code>. And you're not getting anywhere with a <cod...
38,619,691
Referring to resources named with variables in Terraform
<p>I'm trying to create a module in Terraform that can be instantiated multiple times with different variable inputs. Within the module, how do I reference resources when their names depend on an input variable? I'm trying to do it via the bracket syntax (<code>"${aws_ecs_task_definition[var.name].arn}"</code>) but I j...
38,622,882
2
0
null
2016-07-27 17:33:41.163 UTC
5
2019-01-29 22:53:01.243 UTC
null
null
null
null
53,597
null
1
28
terraform
42,745
<p>I was fundamentally misunderstanding how modules worked.</p> <p>Terraform does not support interpolation in resource names (see the <a href="https://github.com/hashicorp/terraform/issues/571" rel="noreferrer">relevant</a> <a href="https://github.com/hashicorp/terraform/issues/1976" rel="noreferrer">issues</a>), but...
38,892,021
How to clear complete cache in Varnish?
<p>I'm looking for a way to clear the cache for all domains and all URLs in Varnish.</p> <p>Currently, I would need to issue individual commands for each URLs, for example:</p> <pre><code>curl -X PURGE http://example.com/url1 curl -X PURGE http://example.com/url1 curl -X PURGE http://subdomain.example.com/ curl -X PU...
39,794,441
4
1
null
2016-08-11 09:10:28.877 UTC
4
2018-05-17 12:41:17.74 UTC
null
null
null
null
561,309
null
1
14
caching|varnish|varnish-vcl|varnish-4|clear-cache
72,199
<p>With Varnish 4.0 I ended up implementing it with the <code>ban</code> command:</p> <pre><code>sub vcl_recv { # ... # Command to clear complete cache for all URLs and all sub-domains # curl -X XCGFULLBAN http://example.com if (req.method == "XCGFULLBAN") { ban("req.http.host ~ .*"); ...
53,416,685
Docker-compose tagging and pushing
<p>I have a few docker containers that I try to sync with <code>docker-compose</code> (currently are being run by bash scripts). I'm looking for a way to tag and push them to our ec2 based dockerhub (private server).</p> <p>Using simply <code>docker</code> we did something like this (for each container):</p> <pre><co...
53,418,591
2
0
null
2018-11-21 16:36:48.56 UTC
8
2022-01-17 21:12:33.693 UTC
2018-11-23 06:20:46.463 UTC
null
9,164,010
null
7,217,896
null
1
22
docker|docker-compose
38,779
<p>I have tested this approach with Docker Hub, so you should be able to achieve what you want with the following configuration and shell session:</p> <blockquote> <p>docker-compose.yml</p> </blockquote> <pre><code>version: '3' services: build-1: build: context: ./build-1 image: user/project-1 bui...
50,021,282
Python Argparse - How can I add text to the default help message?
<p>I'm using python's argparse to handle parsing of arguments. I get a default help message structured like so:</p> <pre><code>usage: ProgramName [-h] ... Description positional arguments: ... optional arguments: -h, --help show this help message and exit ... </code></pre> <p>What I want is to add...
50,021,771
2
0
null
2018-04-25 11:35:49.083 UTC
6
2021-12-03 15:33:36.173 UTC
2021-12-03 15:33:36.173 UTC
null
8,075,540
null
3,531,416
null
1
36
python|argparse
17,893
<p>You can quite do it using <a href="https://docs.python.org/3/library/argparse.html#epilog" rel="noreferrer">epilog</a>. Here is an example below:</p> <pre><code>import argparse import textwrap parser = argparse.ArgumentParser( prog='ProgramName', formatter_class=argparse.RawDescriptionHelpFormatter, ...
36,683,951
Generate random number with jinja2
<p>I need to generate a random number between 1 and 50. Aparently the random filter needs a <a href="http://jinja.pocoo.org/docs/dev/templates/#random" rel="noreferrer">sequence</a>. How can I create a list with numbers from 1 to 50 in Jinja? </p> <pre><code>{{ [1,n,50]|random() }} </code></pre>
36,683,970
2
0
null
2016-04-18 01:04:01.69 UTC
2
2022-09-14 21:08:05.637 UTC
null
null
null
null
2,990,084
null
1
28
python-2.7|flask|jinja2
27,450
<p>Jinja2 also includes the <a href="https://jinja.palletsprojects.com/en/3.0.x/templates/#jinja-globals.range" rel="nofollow noreferrer"><code>range</code></a> function which returns a sequence of numbers from <code>start</code> to <code>end - 1</code>, so you can use it with <a href="https://jinja.palletsprojects.com...
28,236,840
Detect when slick slider initialises
<p>I'm trying to fire some code when <a href="http://kenwheeler.github.io/slick/" rel="noreferrer">slick</a> initializes. Apparently in the newest version 1.4 "callback methods have been deprecated and replaced with events."</p> <p>This doesn't work for me though:</p> <pre><code>$('.spv-slider').on('init', function(e...
29,143,460
1
0
null
2015-01-30 13:19:05.29 UTC
3
2016-06-02 06:00:25.923 UTC
2016-06-02 06:00:25.923 UTC
null
2,333,214
null
1,937,021
null
1
20
jquery|slick.js
83,509
<p>I'm not sure at which point you tried to initialize slickslider, but you have to do it <strong>after</strong> binding the <code>init</code> event.</p> <p>So write your piece of code as you did and after that initialize the slider:</p> <pre><code>$('.spv-slider').on('init', function(event, slick){ console.log("...
20,978,946
Facebook React.js: how do you render stateful components on the server?
<p>I think I'm conceptually missing something with server-side rendering using React.js</p> <p>Assume I want to create a page to display items from a server-side DB, with an input field to filter them. </p> <p>I want a page:</p> <ul> <li>that responds to a URL like <code>/items?name=foobar</code></li> <li>with a Re...
20,982,615
1
0
null
2014-01-07 18:21:06.753 UTC
18
2019-06-25 15:08:22.2 UTC
2019-06-25 15:08:22.2 UTC
null
1,033,581
null
77,804
null
1
29
reactjs|isomorphic-javascript
12,622
<p>When using server rendering, you should always pass down the same props that you used to render the component on the server. In this case, you need to pass down the same initialItems prop in order for <code>React.renderComponent</code> to pick up the server-rendered markup (by simply JSONifying the props and putting...
21,331,664
How to show tab close button in GVIM?
<p>Please let me know how to show the close button on each tab page in GVIM.</p> <p>Also, is it possible to set a warning if I am closing GVIM with multiple tab pages open?</p>
21,332,263
3
0
null
2014-01-24 11:35:59.38 UTC
19
2017-03-30 19:16:45.07 UTC
2017-03-30 19:16:45.07 UTC
null
327,074
null
3,146,151
null
1
12
button|vim|tabs|warnings|tabpage
13,679
<h3>Showing the close button</h3> <p>The <code>'tabline'</code> option can include a <code>%X</code> marker for the close tab button, but that only works for the console version of the tab line. <code>:help 'guitablabel'</code> explicitly states:</p> <blockquote> <p>Note that syntax highlighting is not used for the...
47,698,037
How can I set a height to a Dialog in Material-UI?
<p>I'm going with the Material-UI example for a <code>Dialog</code> with a custom width:</p> <pre><code>const customContentStyle = { width: '100%', maxWidth: 'none', }; // some omitted code &lt;Dialog title=&quot;Dialog With Custom Width&quot; actions={actions} modal={true} contentStyle={customContentStyl...
47,763,027
5
0
null
2017-12-07 15:08:40.507 UTC
8
2022-05-17 21:16:11.87 UTC
2021-09-18 04:46:09.643 UTC
null
9,449,426
null
5,570,050
null
1
47
reactjs|material-ui
61,317
<p>You need to <a href="https://material-ui-next.com/customization/overrides/#overriding-with-classes" rel="nofollow noreferrer">override some of the default behavior</a> of the <a href="https://material-ui-next.com/api/dialog/" rel="nofollow noreferrer">Dialog</a>. Its <code>paper</code> class implements a flexbox wi...
47,076,373
How to design a Cloud Firestore database schema
<p>Migrating from realtime database to cloud firestore needs a total redesign of the database. For this I created an example with some main design decisions. See picture and the database design in the spreadsheet below. My two questions are:</p> <p>1 - when I have a one to many relation is it also an option to store i...
47,077,449
2
0
null
2017-11-02 13:20:01.573 UTC
12
2019-03-14 01:48:10.16 UTC
2017-11-02 13:34:38.487 UTC
null
6,558,256
null
6,558,256
null
1
20
firebase|google-cloud-firestore
16,931
<p>For Question 1 there's a solution in the firestore docs: <a href="https://cloud.google.com/firestore/docs/solutions/arrays" rel="noreferrer">https://cloud.google.com/firestore/docs/solutions/arrays</a></p> <p>instead of using an array you use a map of values and set them to 'true' which allows you to query for them...
24,616,108
Web API and OData- Pass Multiple Parameters
<p>Is it possible to get OData to do the following? I would like to be able to query a REST call by passing on parameters that may not be the primary key. Can I call a REST method like --&gt; <code>GetReports(22, 2014)</code> or <code>Reports(22, 2014)</code>?</p> <pre class="lang-cs prettyprint-override"><code>[HttpGe...
24,648,416
2
0
null
2014-07-07 17:12:06.423 UTC
5
2022-09-05 12:47:24.853 UTC
2022-09-05 12:47:24.853 UTC
null
14,353,529
null
715,447
null
1
19
c#|odata|asp.net-web-api2
43,063
<p>You can define a function import named GetReports that has two parameters.</p> <p><em>(Note: the name of the function import can't be the same with entity set name)</em></p> <p>Configure your EDM model as:</p> <pre><code>var builder = new ODataConventionModelBuilder(); builder.EntitySet&lt;Report&gt;("Reports"); ...
53,335,567
Use pandas.shift() within a group
<p>I have a dataframe with panel data, let's say it's time series for 100 different objects:</p> <pre><code>object period value 1 1 24 1 2 67 ... 1 1000 56 2 1 59 2 2 46 ... 2 1000 64 3 1 54 ... 100 1 451 100 2 153 ......
53,335,744
2
0
null
2018-11-16 10:08:14.303 UTC
10
2021-02-24 10:09:24.147 UTC
null
null
null
null
9,629,391
null
1
56
python|pandas|pandas-groupby
54,033
<p>Pandas' grouped objects have a <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.shift.html" rel="noreferrer"><code>groupby.DataFrameGroupBy.shift</code></a> method, which will shift a specified column in each group <em>n</em> <code>periods</code>, just like the...
35,652,665
java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. spark Eclipse on windows 7
<p>I'm not able to run a simple <code>spark</code> job in <code>Scala IDE</code> (Maven spark project) installed on <code>Windows 7</code></p> <p>Spark core dependency has been added.</p> <pre><code>val conf = new SparkConf().setAppName("DemoDF").setMaster("local") val sc = new SparkContext(conf) val logData = sc.tex...
35,652,866
13
0
null
2016-02-26 13:12:01.55 UTC
31
2022-02-09 05:47:14.857 UTC
2017-01-30 20:56:19.43 UTC
null
147,511
null
3,985,845
null
1
111
eclipse|scala|apache-spark
153,629
<p><a href="http://teknosrc.com/spark-error-java-io-ioexception-could-not-locate-executable-null-bin-winutils-exe-hadoop-binaries/" rel="nofollow noreferrer">Here</a> is a good explanation of your problem with the solution.</p> <ol> <li><p>Download the version of winutils.exe from <a href="http://public-repo-1.hortonwo...
23,454,975
How to convert hours and minutes to minutes with moment.js?
<p>I need to convert hours and minutes in minutes values. With pure JavaScript Date object I do the following:</p> <pre><code>var d = new Date(); var minutes = d.getHours() * 60 + d.getMinutes(); </code></pre> <p>I've just switched to <a href="http://momentjs.com/">moment.js</a> and looking for better solution likes ...
23,455,023
6
0
null
2014-05-04 10:10:13.327 UTC
4
2021-11-06 14:16:06.693 UTC
null
null
null
null
1,006,884
null
1
22
javascript|date|momentjs
74,851
<p>I think your best bet is to create a <code>Duration</code> and then get the minutes using <code>asMinutes</code>. This is probably clearer when describing an interval of time.</p> <pre><code>moment.duration().asMinutes() </code></pre> <p><a href="http://momentjs.com/docs/#/durations/minutes/" rel="noreferrer">Her...
43,186,315
Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
<p>I was following the tutorial on <strong>o7planning</strong> and got stuck at step 6:</p> <p><a href="http://o7planning.org/en/10169/java-servlet-tutorial" rel="noreferrer">http://o7planning.org/en/10169/java-servlet-tutorial</a></p> <p>It's just a simple project that show <em>HelloWorld</em> but for some reason I ke...
43,186,803
2
0
null
2017-04-03 13:45:07.753 UTC
20
2019-11-13 21:16:10.17 UTC
2020-06-20 09:12:55.06 UTC
null
-1
null
7,090,655
null
1
78
java|tomcat|http-status-code-404
944,668
<p>Problem solved, I've not added the <strong>index.html</strong>. Which is point out in the <strong>web.xml</strong></p> <p><a href="https://i.stack.imgur.com/8OoEx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8OoEx.png" alt="enter image description here"></a></p> <p><strong>Note:</strong> a project may...
51,998,995
Invalid argument(s): Illegal argument in isolate message : (object is a closure - Function 'createDataList':.)
<p>I tried to fetch data from the internet with moviedb API, I followed the tutorial at <a href="https://flutter.io/cookbook/networking/fetch-data/" rel="noreferrer">https://flutter.io/cookbook/networking/fetch-data/</a></p> <p>but I'm getting the below error. </p> <blockquote> <p>Invalid argument(s): Illegal argum...
51,999,033
2
0
null
2018-08-24 06:55:04.737 UTC
6
2021-12-31 21:45:13.5 UTC
2018-08-24 08:44:58.287 UTC
null
3,187,077
null
10,268,205
null
1
48
flutter
21,596
<p><code>compute</code> can only take a top-level function, but not instance or static methods.</p> <p>Top-level functions are functions declared not inside a class and not inside another function</p> <pre><code>List&lt;DataModel&gt; createDataList(String responFroJson) { ... } class SomeClass { ... } </code></pre>...
694,344
Regular expression that matches between quotes, containing escaped quotes
<p><em>This was originally a question I wanted to ask, but while researching the details for the question I found the solution and thought it may be of interest to others.</em></p> <p>In Apache, the full request is in double quotes and any quotes inside are always escaped with a backslash:</p> <pre><code>1.2.3.4 - - ...
694,356
1
0
2009-03-29 08:59:41.65 UTC
2009-03-29 08:59:41.667 UTC
9
2009-05-12 07:03:28 UTC
2009-05-12 07:03:28 UTC
mfn
47,573
mfn
47,573
null
1
10
regex|pcre
25,302
<p>Try this:</p> <pre><code>"(?:[^\\"]+|\\.)*" </code></pre> <p>This regular expression matches a double quote character followed by a sequence of either any character other than <code>\</code> and <code>"</code> or an escaped sequence <code>\</code><em><code>α</code></em> (where <em><code>α</code></em> can be any ch...
2,363,777
iPhone: How to Pass Data Between Several Viewcontrollers in a Tabbar App
<p>I have following problem:</p> <p>I have built a tabbar application with 4 tabs. I want to pass a object/variable from the first tab controller to the third one and initialize this controller with the corresponding object. </p> <p>I've already done some research. The best way, corresponding to a clean model approac...
2,364,524
3
0
null
2010-03-02 14:30:08.733 UTC
12
2015-06-18 15:41:44.177 UTC
2013-07-19 15:29:56.387 UTC
null
426,671
null
284,444
null
1
20
iphone|objective-c|uiviewcontroller|uitabbarcontroller
26,043
<p>You need a data model object that stores the data for application. </p> <p>A data model is a customized, standalone object accessible from anywhere in the application. The data model object knows nothing about any views or view controllers. It just stores data and the logical relationships between that data. </p> ...
2,746,309
Best Fit Scheduling Algorithm
<p>I'm writing a scheduling program with a difficult programming problem. There are several events, each with multiple meeting times. I need to find an arrangement of meeting times such that each schedule contains any given event exactly once, using one of each event's multiple meeting times.</p> <p>Obviously I could ...
2,749,869
4
7
null
2010-04-30 17:06:01.617 UTC
14
2018-02-10 15:47:13.257 UTC
2010-06-06 16:36:59.253 UTC
null
279,691
null
23,335
null
1
28
algorithm|scheduling|genetic-algorithm|genetic-programming
23,697
<p>I think you should use genetic algorithm because:</p> <ul> <li>It is best suited for large problem instances.</li> <li>It yields reduced time complexity on the price of inaccurate answer(Not the ultimate best)</li> <li>You can specify constraints &amp; preferences easily by adjusting fitness punishments for not met...
2,650,374
c++ Initializing a struct with an array as a member
<p>Edited again because it originally wasn't clear that I'm trying to initialize the arrays at compile time, not at run time...</p> <hr> <p>I've got the following reduced testcase:</p> <pre><code>typedef struct TestStruct { int length; int values[]; }; TestStruct t = {3, {0, 1, 2}}; TestStruct t2 = {4, {0, ...
2,650,432
4
2
null
2010-04-16 03:21:30.48 UTC
9
2014-04-12 06:46:10.217 UTC
2010-04-16 04:25:33.227 UTC
null
83,715
null
83,715
null
1
34
c++|struct|initialization|portability
89,558
<p>c++ doesn't have the same flexible array member as last element as c99. You should use a <code>std::vector</code> if you don't know how many elements or you should specify how many if you do.</p> <p><strong>EDIT:</strong> You have said in your edit that the array is a runtime constant, so specify the size and it sh...
2,565,755
LaTeX book class: Twosided document with wrong margins
<p>I am trying to write my thesis in latex... Cannot get the layout straight though :? I'm using the following document class:</p> <pre><code>\documentclass[11pt,a4paper,twoside,openright]{book} </code></pre> <p>My problem is: on the <em>odd</em> numbered pages there is a big margin right, and a small margin left - i...
2,565,797
4
0
null
2010-04-02 08:35:37.593 UTC
21
2013-05-12 14:40:48.55 UTC
2013-05-12 14:40:48.55 UTC
null
39,974
null
210,368
null
1
46
latex|document|margins
51,599
<p>The extra space is for the margin notes. In general, to see what's going on with your layout, you can put <code>\usepackage{layout}</code> in your preamble, and then stick <code>\layout</code> in your document to get a diagram and listing of geometry settings.</p> <p>In your case, as I say, what's going in is the ...
29,283,040
How to add custom certificate authority (CA) to nodejs
<p>I'm using a CLI tool to build hybrid mobile apps which has a cool upload feature so I can test the app on a device without going through the app store (it's ionic-cli). However, in my company like so many other companies TLS requests are re-signed with the company's own custom CA certificate which I have on my machi...
47,160,447
6
0
null
2015-03-26 15:51:05.35 UTC
22
2022-03-16 17:58:56.873 UTC
null
null
null
null
1,454,406
null
1
101
node.js|npm
149,134
<p>Node.js 7.3.0 (and the LTS versions 6.10.0 and 4.8.0) added <a href="https://nodejs.org/api/cli.html#cli_node_extra_ca_certs_file" rel="noreferrer"><code>NODE_EXTRA_CA_CERTS</code></a> environment variable for you to pass the CA certificate file. It will be safer than disabling certificate verification using <code>N...
31,776,546
Why does Runtime.exec(String) work for some but not all commands?
<p>When I try to run <code>Runtime.exec(String)</code>, certain commands work, while other commands are executed but fail or do different things than in my terminal. Here is a self-contained test case that demonstrates the effect:</p> <pre><code>public class ExecTest { static void exec(String cmd) throws Exception {...
31,776,547
1
0
null
2015-08-02 21:00:56.83 UTC
17
2016-01-19 23:51:54.43 UTC
null
null
null
null
1,899,640
null
1
42
java|runtime.exec
30,411
<h3>Why do some commands fail?</h3> <p>This happens because the command passed to <code>Runtime.exec(String)</code> is not executed in a shell. The shell performs a lot of common support services for programs, and when the shell is not around to do them, the command will fail.</p> <h3>When do commands fail?</h3> <p>...
46,540,664
'No application found. Either work inside a view function or push an application context.'
<p>I'm trying to separate my Flask-SQLAlchemy models into separate files. When I try to run <code>db.create_all()</code> I get <code>No application found. Either work inside a view function or push an application context.</code></p> <p><code>shared/db.py</code>:</p> <pre><code>from flask_sqlalchemy import SQLAlchemy ...
46,541,219
1
0
null
2017-10-03 08:51:10.507 UTC
17
2019-06-18 15:48:28.527 UTC
2017-10-03 13:02:39.673 UTC
null
400,617
null
5,905,951
null
1
89
python|flask|flask-sqlalchemy
71,830
<p>Use <code>with app.app_context()</code> to push an application context when creating the tables.</p> <pre><code>app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'My connection string' db.init_app(app) with app.app_context(): db.create_all() </code></pre>
1,007,018
XSLT expression to check if variable belongs to set of elements
<p>I have code like this:</p> <pre><code> &lt;xsl:if test="$k='7' or $k = '8' or $k = '9'"&gt; </code></pre> <p>Is there any way to put this expression in a form, like, for instance SQL</p> <pre><code> k IN (7, 8, 9) </code></pre> <p>Ty :)</p>
1,007,037
2
0
null
2009-06-17 13:28:03.22 UTC
4
2018-09-14 12:55:28.78 UTC
null
null
null
null
82,660
null
1
23
xslt
44,534
<p>XSLT / XPath 1.0:</p> <pre><code>&lt;!-- a space-separated list of valid values --&gt; &lt;xsl:variable name="list" select="'7 8 9'" /&gt; &lt;xsl:if test=" contains( concat(' ', $list, ' '), concat(' ', $k, ' ') ) "&gt; &lt;xsl:value-of select="concat('Item ', $k, ' is in the list.')" /&gt; &lt;/xs...
1,111,645
Comparing Timer with DispatcherTimer
<p>what is a difference <code>between System.Windows.Forms.Timer()</code> and <code>System.Windows.Threading.DispatcherTimer()</code> ? In which cases, we should use them? any best practices ?</p>
1,111,699
2
0
null
2009-07-10 19:55:24.003 UTC
22
2019-11-04 18:24:23.933 UTC
2009-07-11 00:22:31.93 UTC
null
23,199
null
119,504
null
1
102
c#|timer
64,374
<p><code>Windows.Forms.Timer</code> uses the windows forms message loop to process timer events. It should be used when writing timing events that are being used in Windows Forms applications, and you want the timer to fire on the main UI thread.</p> <p><code>DispatcherTimer</code> is the WPF timing mechanism. It shou...
2,396,422
C# merge two objects together at runtime
<p>I have a situation where I am loading a very unnormalized record set from Excel. I pull in each row and create the objects from it one at a time. each row could contain a company and / or a client.</p> <p>My issue is that multiple rows could have the same objects, so I may have already created it. I do a compari...
2,396,483
5
2
null
2010-03-07 13:38:41.503 UTC
12
2012-11-26 15:01:23.99 UTC
2010-03-07 13:51:46.587 UTC
null
76,337
null
6,486
null
1
21
c#
18,232
<p>Reflection would work. Something like:</p> <pre><code>public static void MergeWith&lt;T&gt;(this T primary, T secondary) { foreach (var pi in typeof(T).GetProperties()) { var priValue = pi.GetGetMethod().Invoke(primary, null); var secValue = pi.GetGetMethod().Invoke(secondary, null); if (pr...
2,455,158
Find window previously opened by window.open
<p>We've got the following situation, running from a single domain:</p> <p>Page A uses <code>window.open()</code> to open a named window (a popup player). <code>window.open()</code> gives page A a reference to the window.</p> <p>User now reloads page A. The reference to the named window is lost. Using <code>window.op...
2,455,480
5
2
null
2010-03-16 14:31:23.79 UTC
9
2019-11-06 12:42:29.453 UTC
null
null
null
null
14,357
null
1
24
javascript|window.open
28,597
<p>Try this:</p> <pre><code>var playerUrl = 'http://my.player...'; var popupPlayer= window.open('', 'popupPlayer', 'width=150,height=100') ; if(popupPlayer.location.href == 'about:blank' ){ popupPlayer.location = playerUrl ; } popupPlayer.focus(); </code></pre> <p>It will open a blank window with a unique name. S...
2,354,784
__attribute__((format(printf, 1, 2))) for MSVC?
<p>With GCC, I can specify <code>__attribute__((format(printf, 1, 2)))</code> , telling the compiler that this function takes vararg parameters that are printf format specifiers. </p> <p>This is very helpful in the cases where I wrap e.g. the vsprintf function family. I can have <code>extern void log_error(const char...
2,354,807
5
0
null
2010-03-01 09:21:26.583 UTC
3
2022-09-19 16:05:56.917 UTC
null
null
null
null
126,769
null
1
30
c++|c|visual-c++
12,432
<p>While GCC checks format specifiers when -Wformat is enabled, VC++ has no such checking, even for standard functions so there is no equivalent to this <code>__attribute__</code> because there is no equivalent to -Wformat.</p> <p>I think Microsoft's emphasis on C++ (evidenced by maintaining ISO compliance for C++ whi...
2,855,015
how to make requiredfieldvalidator error message display after click submit button
<p>now, the error message will display if I move out of current textbox. I don't want to display it until I click submit button.</p>
2,855,057
6
0
null
2010-05-18 06:43:53.363 UTC
2
2020-09-11 20:19:54.377 UTC
null
null
null
null
241,297
null
1
6
asp.net|requiredfieldvalidator
62,658
<p>This isn't possible when ClientScript is enabled for your validators. And the ClientScript is by default enabled for your validators. You need to disable this by settings EnableClientScript to False in your source.</p> <p>Now in the event handler of your submit button call Page.Validate() and Page.IsValid to see if...
2,473,597
BitSet to and from integer/long
<p>If I have an integer that I'd like to perform bit manipulation on, how can I load it into a <code>java.util.BitSet</code>? How can I convert it back to an int or long? I'm not so concerned about the size of the <code>BitSet</code> -- it will always be 32 or 64 bits long. I'd just like to use the <code>set()</code...
2,473,719
6
1
null
2010-03-18 21:56:01.99 UTC
7
2021-11-27 15:13:20.113 UTC
2017-01-02 07:22:52.097 UTC
null
1,075,341
null
190,201
null
1
59
java|bit-manipulation|bitset
69,388
<p>The following code creates a bit set from a long value and vice versa:</p> <pre><code>public class Bits { public static BitSet convert(long value) { BitSet bits = new BitSet(); int index = 0; while (value != 0L) { if (value % 2L != 0) { bits.set(index); } ++index; valu...
2,633,112
Get JSF managed bean by name in any Servlet related class
<p>I'm trying to write a custom servlet (for AJAX/JSON) in which I would like to reference my <code>@ManagedBeans</code> by name. I'm hoping to map:</p> <p><code>http://host/app/myBean/myProperty</code></p> <p>to: </p> <pre><code>@ManagedBean(name="myBean") public class MyBean { public String getMyProperty(); } ...
2,633,733
6
2
null
2010-04-13 20:53:32.92 UTC
86
2020-05-04 11:44:00.087 UTC
2015-02-01 15:26:17.12 UTC
null
157,882
null
277,683
null
1
105
jsf|jakarta-ee|servlets|jsf-2|managed-bean
155,648
<p>In a servlet based artifact, such as <code>@WebServlet</code>, <code>@WebFilter</code> and <code>@WebListener</code>, you can grab a &quot;plain vanilla&quot; JSF <code>@ManagedBean @RequestScoped</code> by:</p> <pre><code>Bean bean = (Bean) request.getAttribute(&quot;beanName&quot;); </code></pre> <p>and <code>@Man...
2,385,553
How can I generate an HTML report for Junit results?
<p>Is there a way to (easily) generate a HTML report that contains the tests results ? I am currently using JUnit in addition to Selenium for testing web apps UI.</p> <p>PS: Given the project structure I am not supposed to use Ant :(</p>
2,401,679
8
2
null
2010-03-05 09:04:53.377 UTC
24
2022-03-29 11:16:57.873 UTC
2010-11-30 23:50:17.867 UTC
null
183,172
null
211,701
null
1
59
html|junit|selenium|report
157,394
<p>If you <em>could</em> use Ant then you would just use the JUnitReport task as detailed here: <a href="http://ant.apache.org/manual/Tasks/junitreport.html" rel="noreferrer">http://ant.apache.org/manual/Tasks/junitreport.html</a>, but you mentioned in your question that you're not supposed to use Ant. I believe that t...
2,935,183
Bash: infinite sleep (infinite blocking)
<p>I use <code>startx</code> to start X which will evaluate my <code>.xinitrc</code>. In my <code>.xinitrc</code> I start my window manager using <code>/usr/bin/mywm</code>. Now, if I kill my WM (in order to f.e. test some other WM), X will terminate too because the <code>.xinitrc</code> script reached EOF. So I added ...
22,100,106
11
1
null
2010-05-29 13:12:14.017 UTC
35
2022-08-09 11:53:44.893 UTC
2021-01-13 13:15:40.563 UTC
null
5,825,294
null
239,117
null
1
208
linux|bash|sleep|infinite
147,651
<p><code>sleep infinity</code> does exactly what it suggests and works without cat abuse.</p>
2,872,959
How to tell if an array is a permutation in O(n)?
<p>Input: A <em>read-only</em> array of N elements containing integer values from 1 to N (some integer values can appear more than once!). And a memory zone of a <strong>fixed</strong> size (10, 100, 1000 etc - <strong>not</strong> depending on N).</p> <p>How to tell <strong>in O(n)</strong> if the array represents a ...
2,874,631
16
6
null
2010-05-20 10:44:42.38 UTC
31
2016-10-26 16:24:57.99 UTC
2011-07-22 22:26:21.697 UTC
null
387,076
null
13,136
null
1
40
arrays|algorithm|permutation
17,191
<p>I'm very slightly skeptical that there is a solution. Your problem seems to be very close to one posed several years ago in the mathematical literature, with <a href="http://geomete.com/abdali/papers/duplmath.pdf" rel="nofollow noreferrer">a summary given here ("The Duplicate Detection Problem", S. Kamal Abdali, 200...
2,394,935
Can I underline text in an Android layout?
<p>How can I define <em>underlined</em> text in an Android layout <code>xml</code> file?</p>
2,394,939
27
1
null
2010-03-07 02:26:35.263 UTC
123
2022-04-21 15:38:10.05 UTC
2018-10-11 04:16:40.403 UTC
null
1,033,581
null
114,066
null
1
787
android|android-layout|fonts
650,416
<p>It can be achieved if you are using a <a href="http://developer.android.com/guide/topics/resources/available-resources.html#stringresources" rel="noreferrer"><strong>string resource</strong></a> xml file, which supports HTML tags like <code>&lt;b&gt;&lt;/b&gt;</code>, <code>&lt;i&gt;&lt;/i&gt;</code> and <code>&lt;u...
23,916,521
PHP push new key and value in existing object array
<p>In my study how objects and arrays work with PHP I have a new problem. Searching in existing questions didn't give myself the right "push".</p> <p>I have this for example:</p> <pre><code>$html_doc = (object) array ( "css" =&gt; array(), "js" =&gt; array() ); array_push($html_doc , "title" =&gt...
23,916,580
2
0
null
2014-05-28 15:59:14.79 UTC
6
2014-05-28 16:07:48.517 UTC
null
null
null
null
2,808,712
null
1
19
php|arrays|object|push
85,467
<p>array_push() doesn't allow you to specify keys, only values: use </p> <pre><code>$html_doc["title"] = "testtitle"; </code></pre> <p>.... except you're not working with an array anyway, because you're casting that array to an object, so use</p> <pre><code>$html_doc-&gt;title = "testtitle"; </code></pre>
45,713,593
What is the right way to send a client certificate with every request made by the resttemplate in spring?
<p>i want to consume a REST service with my spring application. To access that service i have a client certificate (self signed and in .jks format) for authorization. What is the proper way to authenticate against the rest service?</p> <p>This is my request:</p> <pre><code>public List&lt;Info&gt; getInfo() throws Res...
45,717,851
2
0
null
2017-08-16 12:29:40.153 UTC
10
2018-08-01 06:10:35.273 UTC
null
null
null
null
4,925,613
null
1
24
java|spring|x509certificate|resttemplate|client-certificates
54,933
<p>Here is example how to do this using <a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html" rel="noreferrer">RestTemplate</a> and <a href="https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/" rel="noreferrer">Apache HttpClient</a></p> <p>You ...
10,616,131
Repository pattern - Why exactly do we need Interfaces?
<p>I have read from internet I got this points which says Interfaces is used for this</p> <ul> <li>Use TDD methods </li> <li>Replace persistance engine</li> </ul> <p>But I'm not able to understand how interface will be usefull to this point <code>Replace persistance engine</code>. lets consider I'm creating a basic(w...
10,616,188
2
0
null
2012-05-16 09:54:44.897 UTC
21
2012-09-07 11:29:11.83 UTC
2012-05-17 05:25:31.557 UTC
null
1,388,948
null
1,388,948
null
1
52
c#|asp.net-mvc-3|repository-pattern
20,736
<blockquote> <p>So how interfaces come into picture ?</p> </blockquote> <p>Like this:</p> <pre><code>public interface IEmployeeRepository { Employee[] GetAll(); } </code></pre> <p>and then you could have as many implementations as you like:</p> <pre><code>public class EmployeeRepositoryEF: IEmployeeRepository...
18,659,992
How to select using WITH RECURSIVE clause
<p>I have googled and read throug some articles like <a href="http://www.postgresql.org/docs/9.1/static/queries-with.html" rel="noreferrer">this postgreSQL manual page</a> or <a href="http://gennick.com/with.html" rel="noreferrer">this blog page</a> and tried making queries myself with a moderate success (part of them...
18,660,789
1
0
null
2013-09-06 14:18:28.53 UTC
17
2013-09-06 15:07:22.597 UTC
2013-09-06 14:56:38.16 UTC
null
2,754,703
null
2,754,703
null
1
26
sql|postgresql|recursive-query
32,352
<p>First of all, let us try to simplify and clarify algorithm description given on the <a href="http://www.postgresql.org/docs/9.1/static/queries-with.html">manual page</a>. To simplify it consider only <code>union all</code> in <code>with recursive</code> clause for now (and <code>union</code> later):</p> <pre><code>...
35,605,408
Dagger 2 injection in non Activity Java class
<p>I am trying to use Dagger2 for DI, it works perfectly fine for Activity/Fragment related classes where there is a onCreate lifecycle event. Now I have a plain Java class which I want to be injected. Any ideas as to how to go about it would be appreciated. The code I have looks like this :</p> <p>BasicMoviesUsecaseC...
35,615,857
2
0
null
2016-02-24 14:51:57.917 UTC
14
2020-05-11 07:50:55.23 UTC
null
null
null
null
1,542,720
null
1
28
java|android|dependency-injection|dagger-2
16,512
<p>You should generally use constructor injection whenever possible. The call to <code>component.inject(myObject)</code> is mostly to be used for objects which you can not instantiate yourself (like activities or fragments).</p> <p>Constructor injection is basically what you already did:</p> <pre><code>private class ...
35,592,750
How does for<> syntax differ from a regular lifetime bound?
<p>Consider the following code:</p> <pre><code>trait Trait&lt;T&gt; {} fn foo&lt;'a&gt;(_b: Box&lt;dyn Trait&lt;&amp;'a usize&gt;&gt;) {} fn bar(_b: Box&lt;dyn for&lt;'a&gt; Trait&lt;&amp;'a usize&gt;&gt;) {} </code></pre> <p>Both functions <code>foo</code> and <code>bar</code> seem to accept a <code>Box&lt;Trait&lt...
35,595,491
1
0
null
2016-02-24 03:35:20.25 UTC
57
2019-09-26 15:26:43.43 UTC
2019-09-26 15:26:43.43 UTC
null
1,830,736
null
1,830,736
null
1
101
rust
9,349
<p><code>for&lt;&gt;</code> syntax is called <em>higher-ranked trait bound</em> (HRTB), and it was indeed introduced mostly because of closures.</p> <p>In short, the difference between <code>foo</code> and <code>bar</code> is that in <code>foo()</code> the lifetime for the internal <code>usize</code> reference is prov...
19,175,089
Eclipse project-wide error: Warning: The environment variable HOME is not set. The following directory will be used to store the Git
<p>Started Eclipse and got this error. How do I fix it?</p> <pre><code>Warning: The environment variable HOME is not set. The following directory will be used to store the Git user global configuration and to define the default location to store repositories: 'C:\Documents and Settings\Wizard'. If this is not correct ...
19,175,190
6
0
null
2013-10-04 06:53:32.647 UTC
9
2019-04-07 12:08:23.947 UTC
2014-07-13 13:03:18.58 UTC
null
1,287,093
null
2,576,903
null
1
31
eclipse|git|egit
111,758
<p>You need to set the JAVA_HOME variable in your system. Depends on your Operating system you can check for "How to set Environment variable?" and from that point you need to set environment variable</p> <p>Variable Name : JAVA_HOME Value : Path of Java upto bin folder</p> <ol> <li>In Windows 7, type "environment" a...
19,002,378
Applying a function to two lists?
<p>To find the row-wise correlation of two matrices X and Y, the output should have a correlation value for row 1 of X and row 1 of Y, ..., hence in total ten values (because there are ten rows):</p> <pre><code>X &lt;- matrix(rnorm(2000), nrow=10) Y &lt;- matrix(rnorm(2000), nrow=10) sapply(1:10, function(row) cor(X[...
19,002,916
1
0
null
2013-09-25 10:25:28.913 UTC
4
2018-09-21 19:50:38.287 UTC
2018-09-21 19:50:38.287 UTC
null
6,888,231
null
2,810,362
null
1
29
r|parameter-passing|apply|mapply
24,255
<p>You seem to be looking for <code>mapply</code>. Here's an example:</p> <pre><code>listA &lt;- list(matrix(rnorm(2000), nrow=10), matrix(rnorm(2000), nrow=10)) listB &lt;- list(matrix(rnorm(2000), nrow=10), matrix(rnorm(2000), nrow=10)) mapply(function(X,Y) { sapply(1:10, function(row) ...
30,035,932
How do I use this JavaScript variable in HTML?
<p>I'm trying to make a simple page that asks you for your name, and then uses name.length (JavaScript) to figure out how long your name is.</p> <p>This is my code so far:</p> <pre><code>&lt;script&gt; var name = prompt("What's your name?"); var lengthOfName = name.length &lt;/script&gt; &lt;body&gt; &lt;/body&gt; <...
30,036,015
8
2
null
2015-05-04 17:12:46.03 UTC
18
2022-09-22 11:21:57.443 UTC
2015-05-05 05:03:34.783 UTC
null
2,034,696
null
4,863,221
null
1
44
javascript|html|variables
347,399
<p>You don't "use" JavaScript variables in HTML. HTML is not a programming language, it's a markup language, it just "describes" what the page should look like.</p> <p>If you want to display a variable on the screen, this is done with JavaScript.</p> <p>First, you need somewhere for it to write to:</p> <pre><code>&...
25,557,874
Elastic beanstalk deployment taking longer than timeout period, how do I increase timeout period
<p>Elastic beanstalk deployment of a new environment for an application using the AWS website warns</p> <pre><code>Create environment operation is complete, but with command timeouts. Try increasing the timeout period </code></pre> <p>and although it eventually shows environment as green trying to connect to the url ...
25,558,805
4
0
null
2014-08-28 20:56:53.427 UTC
10
2018-02-01 21:55:15.64 UTC
null
null
null
null
1,480,018
null
1
27
amazon-web-services|amazon-elastic-beanstalk
23,934
<p>You can do this using option settings. Option settings can be specified using ebextensions.</p> <p>Create a file in your app source in a directory called <code>.ebextensions</code>. Lets say the file is <code>.ebextensions/01-increase-timeout.config</code>.</p> <p>The contents of the file should be:</p> <pre><cod...
8,849,684
WordPress, jQuery UI CSS Files?
<p>I'm trying to create a WordPress plugin, and I would like to have jQuery UI Tabs in one of my settings pages.</p> <p>I already have the scripting code set:</p> <pre><code>wp_enqueue_script('jquery'); // Enque jQuery wp_enqueue_script('jquery-ui-core'); // Enque jQuery UI Core wp_enque...
11,789,443
6
0
null
2012-01-13 11:13:19.547 UTC
4
2017-11-11 05:34:54.32 UTC
2012-08-18 20:24:19.697 UTC
null
1,376,780
null
366,664
null
1
32
jquery|jquery-ui|wordpress|jquery-ui-css-framework
45,607
<p>Sounds more like you have an issue with finding an available styling within WordPress for the jquery-ui theme.</p> <p>To answer your question. <strong>No, WordPress has no useful styles available within the platform itself.</strong> The only available css is in \wp-includes\jquery-ui-dialog.css, and that alone isn'...
8,571,754
Android Split Action Bar with Action Items on the top and bottom?
<p>Is there a way to specify some action items to the top part of the Split Action Bar while the others go to the bottom? Or is it all or nothing, whereby all the action items go to the bottom part of the split only?</p> <p><img src="https://i.stack.imgur.com/STzk0.png" alt="enter image description here"></p>
8,609,144
5
0
null
2011-12-20 06:50:27.067 UTC
27
2015-02-03 07:09:25.047 UTC
2012-05-01 20:52:53.313 UTC
null
723,980
null
723,980
null
1
57
android|android-actionbar|android-menu
42,491
<p>This is currently not possible.</p> <p>See the response directly from Android developers Reto Meier and Roman Nurik during the Android Developer Office Hours: <a href="http://youtu.be/pBmRCBP56-Q?t=55m50s" rel="noreferrer">http://youtu.be/pBmRCBP56-Q?t=55m50s</a></p>
30,681,905
Adding items to Endless Scroll RecyclerView with ProgressBar at bottom
<p>I followed Vilen's excellent answer on SO: <a href="https://stackoverflow.com/questions/27044449/put-an-indeterminate-progressbar-as-footer-in-a-recyclerview-grid/28090719#comment49412644_28090719">Put an indeterminate progressbar as footer in a RecyclerView grid</a> on how to implement an endless scroll recyclervie...
30,691,092
2
0
null
2015-06-06 10:48:17.157 UTC
33
2015-12-29 01:26:51.763 UTC
2017-05-23 12:17:50.79 UTC
null
-1
null
3,178,944
null
1
32
android|android-recyclerview|infinite-scroll
46,289
<p>The problem is that when you add new item internal <code>EndlessRecyclerOnScrollListener</code> doesn't know about it and counters breaking. As a matter of fact answer with <code>EndlessRecyclerOnScrollListener</code> has some limitations and possible problems, e.g. if you load 1 item at a time it will not work. So ...
43,556,311
Reading settings from a Azure Function
<p>I'm new to <a href="https://docs.microsoft.com/en-us/azure/azure-functions/" rel="noreferrer">Azure's function</a>... I've created a new timer function (will be fired every 30 minutes) and it has to perform a query on a URL, then push data on the buffer..</p> <p>I've done</p> <pre><code>public static void Run(TimerI...
53,171,338
6
0
null
2017-04-22 07:02:41.85 UTC
8
2022-08-22 14:41:39.713 UTC
2021-11-30 16:13:53.473 UTC
null
4,294,399
null
1,278,204
null
1
32
c#|azure|azure-functions
37,281
<p>You can use <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#environment-variables" rel="noreferrer"><code>System.Environment.GetEnvironmentVariable</code></a> like this: </p> <pre class="lang-cs prettyprint-override"><code>var value = Environment.GetEnvironmentVariable...
585,913
C++ member function virtual override and overload at the same time
<p>If I have a code like this:</p> <pre><code>struct A { virtual void f(int) {} virtual void f(void*) {} }; struct B : public A { void f(int) {} }; struct C : public B { void f(void*) {} }; int main() { C c; c.f(1); return 0; } </code></pre> <p>I get an error that says that I am trying to do an inv...
585,932
3
0
null
2009-02-25 13:04:55.48 UTC
13
2014-04-01 21:49:24.91 UTC
2009-02-25 13:47:38.777 UTC
bombardier
23,766
bombardier
23,766
null
1
30
c++|inheritance|polymorphism|virtual
10,572
<p>The short answer is "because that's how overload resolution works in C++".</p> <p>The compiler searches for functions F inside the C class, and if it finds any, it stops the search, and tries to pick a candidate among those. It only looks inside base classes if no matching functions were found in the derived class....
648,083
SQL error: misuse of aggregate
<p>SQLite version 3.4.0 What's wrong with aggregate functions? Additionally, I suspect that ORDER BY won't work as well. How to rewrite this? </p> <pre><code>sqlite&gt; SELECT p1.domain_id, p2.domain_id, COUNT(p1.domain_id) AS d1, COUNT(p2.domain_id) AS d2 ...&gt; FROM PDB as p1, Interacting_PDBs as i1, PDB as p2, ...
648,089
3
0
null
2009-03-15 16:29:40.623 UTC
8
2022-09-14 20:42:40.763 UTC
null
null
null
piobyz
78,305
null
1
31
sql|sqlite
62,747
<p>When using an aggregate function (sum / count / ... ), you also have to make use of the GROUP BY clause.</p> <p>Next to that, when you want to filter on the result of an aggregate , you cannot do that in the WHERE clause, but you have to do that in the HAVING clause.</p> <pre><code>SELECT p1.domain_id, p2.domain_i...
858,225
configSource doesn't work in system.serviceModel *or* its subsections
<p>I'm trying to split an app.config file into multiple files to make it easier to manage the differences needed for different environments. With some sections it was easy...</p> <pre class="lang-xml prettyprint-override"><code>&lt;system.diagnostics&gt; various stuff &lt;/system.diagnostics&gt; </code></pre> <p...
858,320
3
2
null
2009-05-13 14:18:29.9 UTC
9
2016-07-27 11:20:47.223 UTC
2016-07-27 11:20:47.223 UTC
null
672,891
null
5,486
null
1
35
c#|.net|winforms|wcf|configuration
16,407
<p>VS.NET's editor moans about the config, but it works.</p> <p>I have config like this...</p> <pre class="lang-xml prettyprint-override"><code>&lt;system.serviceModel&gt; &lt;behaviors configSource="config\system.servicemodel.behaviors.config" /&gt; &lt;bindings configSource="config\system.servicemodel.bindings....
34,401
Send email from Elmah?
<p>Is anyone using Elmah to send exceptions via email? I've got Elmah logging set up via SQL Server, and can view the errors page via the Elmah.axd page, but I am unable to get the email component working. The idea here is to get the email notification so we can react more quickly to exceptions. Here is my web.config (...
34,435
3
0
null
2008-08-29 14:56:47.68 UTC
33
2012-05-11 14:11:15.1 UTC
null
null
null
Mark Struzinski
1,284
null
1
90
.net|asp.net|elmah
34,114
<p>You need the ErrorMail httpModule.</p> <p>add this line inside the &lt;httpModules&gt; section</p> <pre><code>&lt;add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /&gt; </code></pre> <p>If you're using a remote SMTP server (which it looks like you are) you don't need SMTP on the server.</p>
6,733,684
Run ant from Java
<p>Is there a tutorial on how to run Ant from Java? I got some code from here: <a href="https://stackoverflow.com/questions/652053/setting-java-home-when-running-ant-from-java">Setting JAVA_HOME when running Ant from Java</a></p> <p>But haven't been able to make it work. I've been trying to find an example or tutorial...
6,733,831
1
0
null
2011-07-18 13:31:54.51 UTC
15
2013-07-26 12:35:39.937 UTC
2017-05-23 12:24:58.297 UTC
null
-1
null
198,108
null
1
15
java|ant
35,046
<blockquote> <p>Is there a tutorial on how to run Ant from Java?</p> </blockquote> <p>Part of my answer to <a href="https://stackoverflow.com/questions/6440295/is-it-possible-to-call-ant-or-nsis-script-via-java-code/6440342#6440342">this question</a> might help:</p> <blockquote> <p>See <a href="http://ant.apache....
36,645,698
Error Message: "Project build error: Non-parseable POM
<pre><code>&lt;project &gt;xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...
36,645,817
5
2
null
2016-04-15 11:17:07.263 UTC
3
2020-01-07 10:09:02.037 UTC
2016-04-15 11:38:54.077 UTC
null
3,365,750
null
6,208,815
null
1
4
java|maven
44,655
<p>You've got an end-tag <em>dependencies</em> but no start-tag <em>dependencies</em></p> <p>(missing tag should be between properties-tag and firts dependency)</p>
42,655,177
How can I delete a file only if it exists?
<p>I have a shell script and I want to add a line or two where it would remove a log file only if it exists. Currently my script simply does:</p> <pre><code>rm filename.log </code></pre> <p>However if the filename doesn't exist I get a message saying filename.log does not exist, cannot remove. This makes sense but I ...
42,655,267
4
1
null
2017-03-07 18:02:05.93 UTC
2
2018-11-30 05:35:18.147 UTC
2017-03-07 18:21:48.8 UTC
null
6,862,601
null
7,649,922
null
1
35
shell
47,057
<p>Pass the <code>-f</code> argument to <code>rm</code>, which will cause it to treat the situation where the named file does not exist as success, and will suppress any error message in that case:</p> <pre><code>rm -f -- filename.log </code></pre> <p>What you <em>literally</em> asked for would be more like:</p> <pr...
20,056,847
JPQL: The state field path cannot be resolved to a valid type
<p>I can't make this query work: </p> <pre><code>Query query = eManager.createQuery("select c FROM News c WHERE c.NEWSID = :id",News.class); return (News)query.setParameter("id", newsId).getSingleResult(); </code></pre> <p>and I got this exception: </p> <pre><code>Exception Description: Problem compiling [s...
20,057,104
3
0
null
2013-11-18 20:08:45.15 UTC
2
2017-03-31 16:56:47.307 UTC
2016-03-03 07:59:02.24 UTC
null
1,471,604
null
1,745,345
null
1
9
jpql
42,470
<p>That happens because <code>News</code> entity does not have persistent attribute named <code>NEWSID</code>. Names of the persistent attributes are case sensitive in JPQL queries and those should be written with exactly same case as they appear in entity.</p> <p>Because entity have persistent attribute named <code>n...
5,702,931
Convert integer/decimal to hex on an Arduino?
<p>How can an integer or decimal variable be converted into a hex string? I can do the opposite (convert hex to int) but I can't figure out the other way.</p> <p>This is for <code>Serial.print()</code> hex values in an array.</p>
5,703,349
3
0
null
2011-04-18 12:33:01.047 UTC
0
2014-07-01 12:23:23.377 UTC
2011-04-27 14:11:06.91 UTC
null
63,550
null
695,648
null
1
10
arduino
114,068
<p>Take a look at the Arduino String tutorial <a href="http://arduino.cc/en/Tutorial/StringConstructors">here</a>. The code below was taken from that example.</p> <pre><code>// using an int and a base (hexadecimal): stringOne = String(45, HEX); // prints "2d", which is the hexadecimal version of decimal 45: Serial...
6,306,636
Read ID3 Tags of an MP3 file
<p>I am trying to read ID3 from a mp3 file thats locally stored in the SD card.</p> <p>I want to basically fetch</p> <ol> <li>Title</li> <li>Artist</li> <li>Album</li> <li>Track Length</li> <li>Album Art</li> </ol>
6,306,735
3
0
null
2011-06-10 12:53:05.797 UTC
10
2018-06-28 22:54:38.14 UTC
2013-05-05 20:39:41.393 UTC
null
179,850
null
155,196
null
1
11
android|mp3|id3|id3-tag
23,496
<p>You can get all of this using <a href="http://developer.android.com/reference/android/media/MediaMetadataRetriever.html" rel="noreferrer">MediaMetadataRetriever</a></p> <pre><code>MediaMetadataRetriever mmr = new MediaMetadataRetriever(); mmr.setDataSource(filePath); String albumName = mmr.extractMetadata(Med...
5,690,283
Passing custom data in [UIButton addTarget]
<p>How do I add custom data while specifying a target in a <code>UIButton</code>?</p> <pre><code>id data = getSomeData(); [button addTarget:self action:@selector(buyButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; </code></pre> <p>I want the <code>buyButtonTapped</code> function to lo...
5,690,329
3
0
null
2011-04-16 23:12:57.74 UTC
10
2013-08-29 12:13:50.35 UTC
null
null
null
null
112,388
null
1
21
iphone|objective-c
23,342
<p>not possible. the action that is triggered by an UIControl can have 3 different signatures.</p> <pre><code>- (void)action - (void)action:(id)sender - (void)action:(id)sender forEvent:(UIEvent *)event </code></pre> <p>None of them allows you to send custom data. </p> <hr> <p>Depending on what you want to do you c...
6,281,461
Enum to String C++
<p>I commonly find I need to convert an enum to a string in c++</p> <p>I always end up doing:</p> <pre><code>enum Enum{ Banana, Orange, Apple } ; char * getTextForEnum( int enumVal ) { switch( enumVal ) { case Enum::Banana: return "bananas &amp; monkeys"; case Enum::Orange: return "Round and orange";...
6,281,535
3
2
null
2011-06-08 15:38:59.5 UTC
14
2020-03-07 01:58:27.76 UTC
2020-03-07 01:58:27.76 UTC
null
366,904
null
111,307
null
1
69
c++|enums
156,278
<pre><code>enum Enum{ Banana, Orange, Apple } ; static const char * EnumStrings[] = { "bananas &amp; monkeys", "Round and orange", "APPLE" }; const char * getTextForEnum( int enumVal ) { return EnumStrings[enumVal]; } </code></pre>
5,706,723
windows form .. console.writeline() where is console?
<p>I created a windows form solution and in the constructor of a class I called </p> <p><code>Console.WriteLine("constructer called")</code></p> <p>But I only got the form and not the console.. so where is the output?</p>
5,706,747
4
1
null
2011-04-18 17:44:04.307 UTC
9
2019-06-06 11:48:50.843 UTC
2014-07-08 10:41:06.763 UTC
null
1,627,730
null
106,528
null
1
67
c#|.net|winforms|console-application
111,452
<p>In project settings set application type as Console. Then you will get console window and Windows form.</p>
2,076,468
Cross-browser 'cursor:pointer'
<p>I <a href="http://www.javascriptkit.com/dhtmltutors/csscursors.shtml" rel="noreferrer">found these CSS attributes</a>, that make the cursor look like a hand:</p> <ul> <li><strong>IE</strong> - style="cursor: hand;"</li> <li><strong>NS6/ IE6</strong> - style="cursor: pointer;"</li> <li><strong>Cross Browser</strong>...
2,076,480
2
1
null
2010-01-16 06:51:10.307 UTC
3
2017-09-07 14:08:12.083 UTC
2013-10-26 07:14:43.883 UTC
null
106,224
null
11,236
null
1
28
css
47,568
<p>According to <a href="http://www.quirksmode.org/css/cursor.html" rel="noreferrer">Quirksmode</a>, the only cross-browser syntax is:</p> <pre><code>element { cursor: pointer; cursor: hand; } </code></pre> <p>They give some more information about the cursor as well:</p> <blockquote> <p>In the past the han...
2,191,890
Conditional operator in Python?
<p>do you know if Python supports some keyword or expression like in C++ to return values based on <code>if</code> condition, all in the same line (The C++ <code>if</code> expressed with the question mark <code>?</code>)</p> <pre><code>// C++ value = ( a &gt; 10 ? b : c ) </code></pre>
2,191,896
2
1
null
2010-02-03 12:44:07.98 UTC
24
2021-02-23 08:21:47.31 UTC
2010-02-03 13:34:07.813 UTC
anon
null
null
245,416
null
1
115
python|syntax
134,749
<p>From Python 2.5 onwards you can do:</p> <pre><code>value = b if a &gt; 10 else c </code></pre> <p>Previously you would have to do something like the following, although the semantics isn't identical as the short circuiting effect is lost:</p> <pre><code>value = [c, b][a &gt; 10] </code></pre> <p>There's also ano...
6,300,398
InvalidOperationException in my Lazy<> value factory
<p>I have a class containing something like the following:</p> <pre><code>public static class Config { private static Lazy&lt;ConfigSource&gt; _cfgSrc = new Lazy&lt;ConfigSource&gt;( () =&gt; { /* "ValueFactory" here... */ }, true); public static ConfigSource ConfigSource { get { r...
6,510,343
6
10
null
2011-06-09 23:19:42.087 UTC
3
2019-10-14 13:12:51.833 UTC
2011-06-09 23:20:51.397 UTC
null
431,359
null
119,549
null
1
43
c#|.net-4.0|lazy-evaluation
30,603
<p>It turned out that this error only occurred when trying to inspect the <code>Value</code> property of the <code>Lazy&lt;&gt;</code> in the Visual Studio debugger. Doing so appeared to create a deadlock because the accessing of <code>Value</code> then seemed to hang the thread for a long time until the <code>Invalid...
5,658,369
How to input a regex in string.replace?
<p>I need some help on declaring a regex. My inputs are like the following:</p> <pre class="lang-none prettyprint-override"><code>this is a paragraph with&lt;[1&gt; in between&lt;/[1&gt; and then there are cases ... where the&lt;[99&gt; number ranges from 1-100&lt;/[99&gt;. and there are many other lines in the txt fi...
5,658,439
7
0
null
2011-04-14 03:59:21.223 UTC
91
2021-08-29 21:13:47.347 UTC
2021-08-09 12:04:54.29 UTC
null
4,621,513
null
610,569
null
1
453
python|regex|string|replace
469,243
<p>This tested snippet should do it:</p> <pre class="lang-py prettyprint-override"><code>import re line = re.sub(r&quot;&lt;/?\[\d+&gt;&quot;, &quot;&quot;, line) </code></pre> <p><strong>Edit:</strong> Here's a commented version explaining how it works:</p> <pre><code>line = re.sub(r&quot;&quot;&quot; (?x) # Use fre...
5,765,186
How to add icons to Preference
<p>I'm making an app that extends the PreferenceActivity and I want to add an icon to each Preference.</p> <p>I read a similar question, and this is the answer with more reputation:</p> <p><strong>CommonsWare Say:</strong></p> <blockquote> <p>The Settings application uses a private custom PreferenceScreen subclass...
5,793,624
9
1
null
2011-04-23 15:49:49.74 UTC
14
2020-12-08 06:51:31.173 UTC
2011-11-28 04:35:40.747 UTC
null
710,274
null
710,274
null
1
28
android|icons|screen|preferences
36,976
<p>After many tests and many mistakes I could get it!</p> <p><strong>I had to do this:</strong></p> <p><strong>1 -</strong> Clone the class IconPreferenceScreen from the Android native Settings app (thanks CommonWare)</p> <p><strong>2 -</strong> Clone the layout file preference_icon.xml from the Android Settings app...
5,686,825
How to remove unused imports from Eclipse
<p>Is there any way to automatically remove all unused imports (signaled with a warning) of a project with Eclipse IDE?</p>
5,686,855
10
6
null
2011-04-16 13:33:21.657 UTC
37
2018-11-20 09:32:43.453 UTC
2014-08-24 14:27:28.547 UTC
null
560,648
null
587,884
null
1
157
eclipse
123,774
<p>I just found the way. Right click on the desired package then <code>Source</code> -> <code>Organize Imports</code>.</p> <p>Shortcut keys:</p> <ul> <li>Windows: <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>O</kbd></li> <li>Mac: <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>O</kbd></li> </ul>
5,618,925
Convert php array to Javascript
<p>How can I convert a PHP array in a format like this</p> <pre><code>Array ( [0] =&gt; 001-1234567 [1] =&gt; 1234567 [2] =&gt; 12345678 [3] =&gt; 12345678 [4] =&gt; 12345678 [5] =&gt; AP1W3242 [6] =&gt; AP7X1234 [7] =&gt; AS1234 [8] =&gt; MH9Z2324 [9] =&gt; MX1234 [10] =&gt...
5,619,163
20
1
null
2011-04-11 08:54:20.78 UTC
59
2021-09-27 05:20:11.323 UTC
2013-02-22 22:09:26.903 UTC
null
1,608,072
null
663,878
null
1
214
php|javascript|arrays
469,500
<p><strong><a href="https://stackoverflow.com/a/5619038/367456">Spudley's answer is fine</a>.</strong></p> <blockquote> <p><strong>Security Notice:</strong> <em>The following should not be necessary any longer for you</em></p> </blockquote> <p>If you don't have PHP 5.2 you can use something like this:</p> <pre><co...
39,359,465
Android 7.0 Notification Sound from File Provider Uri not playing
<p>I'm changing my app code for supporting Android 7, but in my NotificationCompat.Builder.setSound(Uri) passing the Uri from FileProvider the Notification don't play any sound, in Android 6 using the Uri.fromFile() worked properly.</p> <p>The mp3 file is in:</p> <blockquote> <p>/Animeflv/cache/.sounds/</p> </block...
39,375,749
1
1
null
2016-09-07 00:02:28.277 UTC
11
2016-09-07 17:11:29.693 UTC
null
null
null
null
4,696,393
null
1
6
java|android|android-studio|android-fileprovider|android-7.0-nougat
4,476
<p>The following is from <a href="https://commonsware.com/blog/2016/09/07/notifications-sounds-android-7p0-aggravation.html" rel="noreferrer">a blog post</a> that I just published, reproduced here because, hey, why not?</p> <hr> <p>You can put a custom ringtone on a <code>Notification</code>, via methods like <code>s...
44,247,099
Click Command Line Interfaces: Make options required if other optional option is unset
<p>When writing a command-line interface (CLI) with the Python <a href="http://click.pocoo.org/6/" rel="noreferrer">click library</a>, is it possible to define e.g. three options where the second and third one are only required if the first (optional) one was left unset?</p> <p>My use case is a log-in system which all...
44,349,292
3
0
null
2017-05-29 16:39:51.537 UTC
13
2020-05-08 17:19:38.963 UTC
2017-06-03 23:02:31.38 UTC
null
7,311,767
null
2,545,732
null
1
29
python|command-line-interface|python-click
18,815
<p>This can be done by building a custom class derived from <code>click.Option</code>, and in that class over riding the <code>click.Option.handle_parse_result()</code> method like:</p> <h3>Custom Class:</h3> <pre><code>import click class NotRequiredIf(click.Option): def __init__(self, *args, **kwargs): ...
24,942,751
Generating Android build with Gitlab CI
<p>I just installed Gitlab as repository for my projects and I want to take advantages of their Gitlab CI system. I want to automatically generate a distribution and debug Apk after each commit. I googled but I didn't find anything as a tutorial or similar cases. If someone could guide me in some way, it would be great...
39,263,422
2
1
null
2014-07-24 19:51:07.723 UTC
8
2019-04-25 12:58:16.743 UTC
null
null
null
null
1,760,526
null
1
24
android|gitlab-ci
5,539
<p>I've just written a blog post on <a href="http://www.greysonparrelli.com/post/setting-up-android-builds-in-gitlab-ci-using-shared-runners/" rel="noreferrer">how to setup Android builds in Gitlab CI using shared runners</a>.</p> <p>The quickest way would be to have a <code>.gitlab-ci.yml</code> with the following co...
24,558,916
Loop in Ruby on Rails html.erb file
<p>everybody I'm brand new with Ruby on Rails and I need to understand something. I have an instance variable (@users) and I need to loop over it inside an html.erb file a limitated number of times. I already used this:</p> <pre><code>&lt;% @users.each do |users| %&gt; &lt;%= do something %&gt; &lt;%end %&gt; </cod...
24,559,141
3
1
null
2014-07-03 16:24:30.527 UTC
5
2020-02-19 21:41:23.957 UTC
null
null
null
null
3,802,533
null
1
37
html|ruby-on-rails|ruby|loops|erb
58,556
<p>If <code>@users</code> has more elements than you want to loop over, you can use <code>first</code> or <code>slice</code>:</p> <p>Using <code>first</code></p> <pre><code>&lt;% @users.first(10).each do |users| %&gt; &lt;%= do something %&gt; &lt;% end %&gt; </code></pre> <p>Using <code>slice</code></p> <pre><co...