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,206,275 | Creating messages (ie drafts) in Gmail with IMAP/SMTP? | <p>I've done quite a bit of inbox manipulation with Gmail via IMAP functions in PHP, but one thing I haven't found is a way to create messages. I'm not sure if IMAP or SMTP is required, but I would like to use PHP to create a new message (specifically a draft) that is stored in my inbox with everything ready to hit sen... | 1,206,465 | 1 | 0 | null | 2009-07-30 12:27:55.18 UTC | 11 | 2009-07-30 13:29:15.793 UTC | null | null | null | null | 143,455 | null | 1 | 12 | php|smtp|gmail|imap | 5,848 | <p>You might want to look at <a href="http://php.net/imap_mail_compose" rel="noreferrer"><code>imap_mail_compose()</code></a></p>
<p><strong>Edit</strong>
This doesn't create the message on the server. You need to use imap_append() also.</p>
<p><strong>Further Edit</strong>
This seems to work ok:</p>
<pre><code><... |
49,291,057 | Difference between flatMap and compactMap in Swift | <p>It seems like in <strong>Swift 4.1</strong> <code>flatMap</code> is deprecated. However there is a new method in <strong>Swift 4.1</strong> <code>compactMap</code> which is doing the same thing?
With <code>flatMap</code> you can transform each object in a collection, then remove any items that were nil.
<br>
<stro... | 52,367,951 | 3 | 0 | null | 2018-03-15 03:21:25.783 UTC | 6 | 2022-08-24 18:31:03.9 UTC | 2018-08-29 18:23:51.733 UTC | null | 1,032,372 | null | 4,142,753 | null | 1 | 30 | swift|swift4|swift4.1 | 13,850 | <p>The Swift standard library defines 3 overloads for <code>flatMap</code> function:</p>
<pre><code>Sequence.flatMap<S>(_: (Element) -> S) -> [S.Element]
Optional.flatMap<U>(_: (Wrapped) -> U?) -> U?
Sequence.flatMap<U>(_: (Element) -> U?) -> [U]
</code></pre>
<p>The last overl... |
32,602,644 | Difference between ASP.NET WebHooks and Signal-R | <p>What is the difference between the newly release <a href="http://blogs.msdn.com/b/webdev/archive/2015/09/15/sending-webhooks-with-asp-net-webhooks-preview.aspx">ASP.NET WebHooks</a> and Signal-R? What are the advantages or disadvantages? What are the use cases for each technology?</p> | 32,621,664 | 2 | 0 | null | 2015-09-16 07:46:54.453 UTC | 16 | 2016-02-28 20:57:04.783 UTC | 2016-02-28 20:57:04.783 UTC | null | 1,215,507 | null | 1,212,017 | null | 1 | 57 | asp.net|signalr|webhooks|asp.net-webhooks | 13,880 | <p>SignalR is for notification within an ASP.NET app using <strong>WebSockets</strong>. You can exchange event notifications through WebSockets, however it requires a constant network connection. </p>
<p><strong>WebHooks</strong> are for event notification across other web applications and other external services. (... |
33,186,123 | npm install errors on vagrant/homestead/windows: EPROTO: protocol error, symlink | <p>I'm building my first project in Laravel and trying to use Elixir, using homestead on Windows 8.1. I've hit the known npm/vagrant issue of too-long-path-names:
<a href="https://harvsworld.com/2015/how-to-fix-npm-install-errors-on-vagrant-on-windows-because-the-paths-are-too-long/" rel="noreferrer">https://harvsworl... | 33,188,475 | 6 | 0 | null | 2015-10-17 11:32:43.647 UTC | 13 | 2020-09-02 23:02:01.243 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 4,418,293 | null | 1 | 25 | laravel|npm|symlink|homestead | 20,826 | <p>I have been trying to figure out this problem for weeks. Here is what I did to make it work without using my host environment:</p>
<p>I updated node to the latest version in homestead according to nodesource.com:</p>
<pre><code>sudo apt-get install --yes nodejs
curl --silent --location https://deb.nodesource.com/s... |
41,239,781 | Conversion failed when converting the varchar value to data type int - but I'm not converting anything | <p>I am trying to write a stored procedure that takes two parameters: table name and record ID. </p>
<p>It must return a record with a specified ID (<code>@FormID</code>) from the table with the specified name (<code>@TableName</code>). </p>
<p>I get this error: </p>
<blockquote>
<p>Conversion failed when converti... | 41,239,853 | 3 | 0 | null | 2016-12-20 10:11:53.34 UTC | null | 2016-12-20 10:45:42.21 UTC | null | null | null | user6269864 | null | null | 1 | 6 | sql|sql-server | 51,006 | <p>Try:</p>
<pre><code>SELECT @sql = 'SELECT * FROM ' + @ActualTableName + ' WHERE [FormID] = ' + CONVERT(NVARCHAR,@FormID) + ';'
</code></pre>
<p>SQL is trying to convert all of the strings you're attempting to concatenate into <code>INT</code> values because <code>@FormID</code> is an <code>INT</code> and you're u... |
41,623,515 | Received "ValueError: Found wrong number (0) of constraints for ..." during Django migration | <p>While using Django 1.7 migrations, I came across a migration that worked in development, but not in production:</p>
<p><code>ValueError: Found wrong number (0) of constraints for table_name(a, b, c, d)</code></p>
<p>This is caused by an <code>AlterUniqueTogether</code> rule:</p>
<pre><code> migrations.AlterUniq... | 41,623,516 | 9 | 0 | null | 2017-01-12 21:44:04.693 UTC | 2 | 2022-09-22 06:13:12.007 UTC | 2017-01-12 22:12:20.847 UTC | null | 2,077,386 | null | 2,077,386 | null | 1 | 35 | django|django-migrations | 18,765 | <p>(Postgres and MySQL Answer)</p>
<p>If you look at your actual table (use <code>\d table_name</code>) and look at the indexes, you'll find an entry for your unique constraint. This is what Django is trying to find and drop. But it can't find an exact match.</p>
<p>For example,</p>
<pre><code>"table_name_...6cf2a... |
33,789,586 | Disable Prev Control on first slide and disable Next control on last slide | <p>using Slick and looking for a way to have the prev control disabled and hidden until the user clicks the next arrow. Similarly I want the Next control to become disabled and hidden once the user reaches the last slide. </p>
<p>A good illustration of what I'm trying to accomplish is <a href="http://www.asla.org/sust... | 33,790,040 | 9 | 0 | null | 2015-11-18 20:19:15.103 UTC | 5 | 2020-10-09 08:25:16.747 UTC | 2015-11-18 20:21:36.203 UTC | null | 887,539 | null | 2,938,557 | null | 1 | 16 | javascript|jquery|slick.js | 53,454 | <h3>Solution</h3>
<p>You can add the css <code>pointer-events: none</code> to your button. That css property disable all event on an element. So something like that.</p>
<pre><code>// Slick stuff
...
onAfterChange: function(slide, index) {
if(index === 4) {
$('.slick-next').css('pointer-events',... |
23,235,200 | How to matches anything except space and new line? | <p>I have a string, I just want to match string for any character except for space and new line. What must be regular expression for this?</p>
<p>I know regular expressions for anything but space i.e. <code>[^ ]+</code> and regular expression for anything but new line <code>[^\n]+</code> (I'm on Windows). I am not abl... | 23,235,232 | 3 | 0 | null | 2014-04-23 05:08:10.617 UTC | 3 | 2021-06-05 04:48:56.167 UTC | 2014-04-23 05:26:50.31 UTC | null | 1,673,391 | null | 1,643,128 | null | 1 | 28 | python|regex | 41,022 | <p>You can add the space character to your character class to be excluded.</p>
<pre><code>^[^\n ]*$
</code></pre>
<p>Regular expression</p>
<pre><code>^ # the beginning of the string
[^\n ]* # any character except: '\n' (newline), ' ' (0 or more times)
$ # before an optional \n, and ... |
21,475,828 | Creating WSDL file for SOAP server | <p>I am new to the whole web service thing so I will try to explain my problem as much as I can understand it so far. </p>
<p>I created Soap server in PHP:</p>
<pre><code>try {
$server = new SOAPServer(
'webservice.wsdl',
array(
'uri' => 'http://example.com/soap/server.php'
... | 21,547,188 | 1 | 0 | null | 2014-01-31 08:55:30.487 UTC | 1 | 2016-08-01 14:27:51.693 UTC | 2016-08-01 14:27:51.693 UTC | null | 4,662,836 | null | 2,111,274 | null | 1 | 11 | php|web-services|soap|wsdl | 42,496 | <p><strong>Solved</strong></p>
<p>A simple library called PhpWsdl did the trick.</p>
<p><a href="https://code.google.com/p/php-wsdl-creator/" rel="noreferrer">https://code.google.com/p/php-wsdl-creator/</a></p> |
19,100,536 | What is the use of __iomem in linux while writing device drivers? | <p>I have seen that <code>__iomem</code> is used to store the return type of <code>ioremap()</code>, but I have used <code>u32</code> in ARM architecture for it and it works well.</p>
<p>So what difference does <code>__iomem</code> make here? And in which circumstances should I use it exactly?</p> | 19,102,506 | 1 | 0 | null | 2013-09-30 17:46:54.707 UTC | 11 | 2018-11-21 15:38:28.87 UTC | 2015-03-08 04:14:07.003 UTC | null | 610,505 | null | 2,711,374 | null | 1 | 27 | linux|memory-management|linux-kernel|linux-device-driver | 22,345 | <p>Lots of type casts are going to just "work well". However, this is not very strict. Nothing stops you from casting a <code>u32</code> to a <code>u32 *</code> and dereference it, but this is not following the kernel API and is prone to errors.</p>
<p><code>__iomem</code> is a cookie used by <a href="http://en.wikipe... |
18,160,953 | Disable latex symbol conversion in vim | <p>The vim editor on my Kubuntu 13.04 laptop seems to have some
advance feature for latex edting, i.e. it can convert latex
symbols to unicode chars on the fly and hide the source code when the cursor
is not on the line.</p>
<p>This may be a great function to some people, but I find it
a bit annoying. I am not sure ... | 18,161,073 | 1 | 0 | null | 2013-08-10 10:20:04.397 UTC | 8 | 2013-08-10 10:40:25.257 UTC | null | null | null | null | 562,222 | null | 1 | 22 | vim|latex | 6,187 | <p>This functionality is provided by Vim's "conceal" feature.</p>
<p>Vim's TeX plugin takes advantage of "conceal" if you have set <a href="http://vimdoc.sourceforge.net/htmldoc/options.html#%27conceallevel%27"><code>'conceallevel'</code></a> to 2. See <a href="http://vimdoc.sourceforge.net/htmldoc/syntax.html#ft-tex-... |
26,536,572 | NSTextField, Change text in Swift | <p>I can't seem to be able to change the text Label in a Mac app that I am trying to make.
I am using swift. Here is the code I am using:</p>
<pre><code>@IBOutlet var sumlab: NSTextField!
sumlab.text = "\(result.sum)" // result.sum is the result of a function I made
// I also tried this:
sumlab.text("\(result.sum)... | 26,537,804 | 1 | 0 | null | 2014-10-23 20:11:55.85 UTC | 11 | 2015-01-05 20:38:18.58 UTC | 2015-01-05 20:38:18.58 UTC | null | 8,047 | null | 4,175,399 | null | 1 | 32 | swift|nstextfield | 24,835 | <p>NSTextField is different from a UITextField. It doesn't have a <code>text</code> property. It does however inherit from NSControl which has a stringValue property.</p>
<pre><code>sumlab.stringValue = "\(result.sum)"
</code></pre> |
42,876,278 | When to use multiindexing vs. xarray in pandas | <p>The <a href="http://pandas.pydata.org/pandas-docs/stable/reshaping.html" rel="noreferrer">pandas pivot tables documentation</a> seems to recomend dealing with more than two dimensions of data by using multiindexing: </p>
<pre><code>In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: import pandas.util.... | 45,172,361 | 1 | 0 | null | 2017-03-18 15:35:03.623 UTC | 11 | 2020-07-08 17:09:29.773 UTC | null | null | null | null | 3,474,956 | null | 1 | 22 | python|pandas|data-structures|multi-index|xarray | 6,024 | <p>There does seem to be a transition to xarray for doing work on multi-dimensional arrays. Pandas will be depreciating the support for the 3D Panels data structure and in the <a href="https://pandas.pydata.org/pandas-docs/stable/dsintro.html#deprecate-panel" rel="noreferrer">documentation even suggest using xarray for... |
44,934,641 | GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications | <p>I am working on python project with opencv on Ubuntu OS</p>
<pre><code>import numpy as np
import cv2
img = cv2.imread("LillyBellea.png", 1)
img = cv2.imwrite("LillyBellea.jpeg", img)
cv2.imshow("original", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
</code></pre>
<p>when i am running this program then i am gettin... | 45,223,897 | 2 | 0 | null | 2017-07-05 19:38:01.027 UTC | 10 | 2020-11-06 11:16:04.147 UTC | 2017-07-06 05:48:07.333 UTC | null | 4,884,334 | null | 4,884,334 | null | 1 | 23 | python|linux|opencv|ubuntu | 22,442 | <p>This fixed the issue for me:</p>
<pre><code>export GIO_EXTRA_MODULES=/usr/lib/x86_64-linux-gnu/gio/modules/
</code></pre>
<p>See: <a href="https://github.com/conda-forge/glib-feedstock/issues/19" rel="noreferrer">https://github.com/conda-forge/glib-feedstock/issues/19</a> for more info.</p> |
27,423,485 | Java check if Checkbox is checked | <p>I use:</p>
<pre><code> CheckboxGroup cg = new CheckboxGroup();
Checkbox c1 = new Checkbox("A", false, cg);
Checkbox c2 = new Checkbox("B", false, cg);
Checkbox c3 = new Checkbox("C", true, cg);
</code></pre>
<p>To create a group of three checkboxes. Now, I want to check which one of them is checked.... | 27,423,526 | 6 | 2 | null | 2014-12-11 12:58:16.877 UTC | 1 | 2019-12-29 04:56:07.507 UTC | 2014-12-11 14:41:15.663 UTC | user3265784 | null | user3265784 | null | null | 1 | 8 | java|checkbox|awt | 84,065 | <p>Use getState()</p>
<pre><code>boolean checked = c1.getState();
if(c1.getState()) {
//c1 is checked
} else if (c2.getState()) {
//
}
</code></pre>
<p><strong>OR</strong></p>
<pre><code>Checkbox cb = cg.getSelectedCheckbox();
if(null != cb) {
//not checked
} else {
System.out.println(cb.getLabel() + " is ch... |
44,612,400 | How to pass the index value of a ngFor loop into the component? | <p>I have a ngFor loop in my code.
and inside this ngFor loop I have a div, on clicking this div I want to pass the index value to the type script file.</p>
<p>I am new to Anglular 2 any help will be appreciated.</p>
<p>Eg:</p>
<pre><code>`<div *ngFor="let y of characters;let i = index">
<div (click)="p... | 44,612,438 | 1 | 1 | null | 2017-06-18 06:38:36.573 UTC | 5 | 2019-03-27 21:33:15.093 UTC | null | null | null | null | 8,178,094 | null | 1 | 9 | angular|typescript|angular2-services | 43,892 | <pre><code><div *ngFor="let y of characters;let i = index">
<div (click)="passIndexValue(i)">
</div>
<div>`
passIndexValue(index){
console.log(index);//clicked index
}
</code></pre>
<p>You could also pass the value to the component like so (assuming below use of @Input)</p>
<pre><... |
9,129,214 | CakePHP 2.0 with Twitter Bootstrap | <p>Is there a way to configure CakePHP for it to work well with Twitter Bootstrap?
I realize this question has already been asked <a href="https://stackoverflow.com/questions/8049715/cakephp-with-bootstrap-from-twitter">here</a>, but the answer wasn't really complete.</p>
<p>There are also quite a few tutorials out th... | 9,507,651 | 11 | 0 | null | 2012-02-03 13:14:16.087 UTC | 12 | 2014-07-11 06:19:47.34 UTC | 2017-05-23 12:34:01.78 UTC | null | -1 | null | 988,302 | null | 1 | 23 | cakephp|cakephp-2.0|twitter-bootstrap | 22,595 | <p>Assuming that the css file is included in your layout in your view for forms you can use the follwoing:</p>
<pre><code><?php echo $this->Form->create('User', array(
'inputDefaults' => array(
'div' => 'control-group',
'label' => array('class' => 'control-label'),
'between' => '<... |
9,243,816 | How to build Google's protobuf in Windows using MinGW? | <p>I'm using Codeblocks as my IDE with MingGW.
I'm trying to use google protocol buffers,
but I'm having trouble building the protobuf.</p>
<p>The readme file for protobuf says:</p>
<blockquote>
<p>If you are using Cygwin or MinGW,
follow the Unix installation instructions, above.</p>
</blockquote>
<p>The Uni... | 9,244,456 | 4 | 0 | null | 2012-02-11 20:33:00.75 UTC | 9 | 2022-08-09 06:30:19.803 UTC | 2015-09-14 06:45:59.16 UTC | null | 506,624 | null | 1,162,522 | null | 1 | 23 | c++|mingw|protocol-buffers | 23,741 | <p>Here's what worked for me:</p>
<ol>
<li><p>You need to install MSYS with mingw. This is a minimal unix-like shell environment that lets you configure/make most unix packages. Read the mingw docs on how to install that (either with mingw-get or the GUI installer).</p></li>
<li><p>Once you have installed MSYS, you sh... |
9,241,922 | Easy 'create table from view' syntax in mysql? | <p>I want to create a table that's a cache of results from a view. Is there an easy way to automatically define the table from the view's definition, or will I have to cobble it together from <code>show create table view</code>?</p> | 9,241,946 | 2 | 0 | null | 2012-02-11 16:39:32.14 UTC | 9 | 2015-06-04 22:25:19.017 UTC | null | null | null | null | 151,841 | null | 1 | 42 | mysql|syntax | 36,456 | <p>You can do <code>CREATE TABLE SELECT</code> from the view to build it. That should duplicate the view's structure as a new table containing all the view's rows. Here's the <a href="http://dev.mysql.com/doc/refman/5.0/en/create-table-select.html">MySQL syntax reference</a> for this statement.</p>
<pre><code>CREATE ... |
9,132,772 | Lazy loading in node.js | <p>I was wondering if using <code>require()</code> in node.js was the equivalent to lazy loading?</p>
<p>For example if I had a function that required a specific node.js package that wasn't needed anywhere else in my code am I best to use <code>require()</code> inside of that function to include the needed package onl... | 9,139,419 | 2 | 0 | null | 2012-02-03 17:25:21.413 UTC | 10 | 2019-05-07 12:51:23.917 UTC | 2012-02-04 03:23:09.38 UTC | null | 930,675 | null | 930,675 | null | 1 | 50 | node.js | 28,640 | <p><code>require()</code> is on-demand loading. Once a module has been loaded it won't be reloaded if the require() call is run again. By putting it inside a function instead of your top level module code, you can delay its loading or potentially avoid it if you never actually invoke that function. However, <code>requi... |
9,602,022 | Chrome extension - retrieving global variable from webpage | <p>I am working on an extension for Chrome. I wish parse the content of the "original" Gmail message (the currently viewed message).</p>
<p>I tried to utilize the jQuery.load() as follows</p>
<pre><code>$(windows).load(function() { alert(GLOBALS); });
</code></pre>
<p>and place it at the content script, but it does ... | 9,636,008 | 5 | 0 | null | 2012-03-07 13:01:48.887 UTC | 56 | 2019-05-29 17:05:27.43 UTC | 2018-01-20 21:00:24.263 UTC | null | 555,121 | null | 1,184,717 | null | 1 | 54 | javascript|html|dom|google-chrome-extension | 47,152 | <p><a href="https://developer.chrome.com/extensions/content_scripts" rel="noreferrer">Content scripts</a> run in an isolated environment. To get access to the any global properties (of the page's <code>window</code>), you have to either inject a new <code><script></code> element, or use event listeners for passin... |
9,643,603 | Modifying the color of an android drawable | <p>I would like to be able to use the same drawable to represent both:</p>
<p><img src="https://i.stack.imgur.com/81xak.png" alt="Blue icon"> and <img src="https://i.stack.imgur.com/nQ1ez.png" alt="Red icon"> </p>
<p>as the same drawable, and re-color the drawable based on some programmatic values, so that the end us... | 9,855,270 | 6 | 0 | null | 2012-03-10 03:07:50.043 UTC | 40 | 2017-12-15 03:58:08.917 UTC | 2017-11-11 01:14:22.657 UTC | null | 3,681,880 | null | 697,151 | null | 1 | 67 | android|themes|drawable | 70,234 | <p>So after a lot of trial and error, reading different articles, and most importantly, going through the API Demos (ColorFilters.java -- found in com.example.android.apis.graphics) I found the solution.</p>
<p>For solid images, I have found it is best to use the color filter PorterDuff.Mode.SRC_ATOP because it will o... |
22,440,430 | Accessing Android Studio properties window? | <p>I have recently started using Android Studio and cannot work out how to access the properties window.</p>
<p>The following screenshot was taken from Google and shows <strong><em>exactly</em></strong> what I'm trying to access denoted by the red rectangle around the properties window.</p>
<p><img src="https://i.sta... | 22,740,482 | 7 | 1 | null | 2014-03-16 17:43:38.387 UTC | 3 | 2020-10-13 21:35:34.4 UTC | 2016-04-15 21:30:57.813 UTC | null | 1,352,057 | null | 1,352,057 | null | 1 | 31 | android|ide|android-studio | 71,392 | <p><a href="https://i.stack.imgur.com/IwRtj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IwRtj.png" alt="enter image description here"></a>Switch to design view. Click "Design" tab at bottom-left work area.</p> |
7,222,332 | R will plot but won't draw abline | <pre><code>> head(returnee)
[1] 1.3936536 -0.6730667 2.3584725 2.3477308 3.2841443 1.3168157
> head(vixee)
[1] 14.75 15.45 17.59 17.74 17.75 18.35
> class(returnee)
[1] "numeric"
> class(vixee)
[1] "numeric"
> plot(returnee, vixee)
> abline(lm(returnee ~ vixee))
</code></pre>
<p>When I run this,... | 7,222,413 | 2 | 0 | null | 2011-08-28 16:48:53.773 UTC | 2 | 2011-08-30 04:56:31.1 UTC | 2011-08-30 04:56:31.1 UTC | null | 709,619 | null | 914,308 | null | 1 | 19 | r|plot | 61,085 | <p>It should be <code>abline(lm(vixee ~ returnee))</code> to match the coordinates of the plot.</p> |
19,255,289 | for loop object names iterate | <p>I am working on a project where I have to do a lot of repeating and life would be a lot easier if i could address multiple objects in a for loop. To elleborate my question i have come up with a (silly) example</p>
<p>For instance if have done this to create my data:</p>
<pre><code>for (i in 1:10)
{
assign(paste(... | 19,255,608 | 2 | 1 | null | 2013-10-08 18:17:08.097 UTC | 3 | 2013-10-08 18:46:21.277 UTC | 2013-10-08 18:41:42.253 UTC | null | 1,968 | null | 2,859,748 | null | 1 | 6 | r | 46,244 | <p>The direct solution to your question would be to use <code>get</code> with <code>paste</code></p>
<pre><code>for(i in 1:10)
{
Object = get(paste0("Season", i))
Object[1] = 0
assign(paste0("Season", i), Object)
}
</code></pre>
<p><strong>But don't do this</strong>. </p>
<p>It's a horrible use of R. A... |
19,204,048 | Returning JsonObject using @ResponseBody in SpringMVC | <p>I am using the new Java API (JSR 353) for JSON in a SpringMVC project.</p>
<p>The idea is to generate some piece of Json data and have it returned to the client. The controller I have look somewhat like this:</p>
<pre><code>@RequestMapping("/test")
@ResponseBody
public JsonObject test() {
JsonObject result... | 19,205,116 | 2 | 1 | null | 2013-10-06 00:16:05.94 UTC | 7 | 2016-12-09 19:02:46.883 UTC | 2013-10-06 00:28:19.937 UTC | null | 371,082 | null | 371,082 | null | 1 | 17 | java|json|spring-mvc | 79,020 | <p>The answer is pretty simple when you realize there is no special <code>HandlerMethodReturnValueHandler</code> for the new JSR 353 API. Instead, in this case, the <code>RequestResponseBodyMethodProcessor</code> (for <code>@ResponseBody</code>) uses a <code>MappingJackson2HttpMessageConverter</code> to serialize the r... |
58,579,774 | Convert an existing Flutter Kotlin project to Flutter Java project | <p>I created a Flutter project using default values, which are Kotlin for Android and Swift for iOS. Halfway through the project I needed to integrate a 3rd party Android SDK that requires Java. Can I convert a Flutter project to Java for Android after creation?</p>
<p>I know I will need yo use Platform Channels to in... | 58,602,076 | 7 | 2 | null | 2019-10-27 13:20:32.107 UTC | 5 | 2021-01-21 16:53:31.51 UTC | null | null | null | null | 2,268,140 | null | 1 | 31 | java|android|kotlin|flutter | 15,706 | <p>I had the same problem, for me this solution works. </p>
<ol>
<li>Move folder com.example.test_app (any name you have) from android/app/src/main/kotlin -> android/app/src/main/java</li>
<li><p>Replace MainActivity.kt with Java version, or copy down here</p>
<pre><code>package com.example.test_app;
import androidx... |
17,688,232 | Does Vim load plugins after loading vimrc? | <p>I'm trying to override the highlight set in a plugin. The plugin does this: </p>
<pre><code>highlight! link WordUnderTheCursor Underlined
</code></pre>
<p>Firstly, I'm not aware that <code>!</code> added to <code>highlight</code> does anything. But that's irrelevant. </p>
<p>Doing stuff like this in the vimrc<... | 17,688,716 | 2 | 0 | null | 2013-07-16 22:45:21.703 UTC | 9 | 2019-03-25 05:45:42.727 UTC | 2019-03-25 05:45:42.727 UTC | null | 2,566,838 | null | 340,947 | null | 1 | 24 | vim | 8,369 | <p>Yes. vimrc is loaded before plugins.</p>
<p>If you look at <a href="http://vimdoc.sourceforge.net/htmldoc/starting.html#initialization"><code>:h initialization</code></a> you will find that step 3 is load vimrc and step 4 is load plugins.</p>
<p>You can also see that vimrc is loaded before plugins by looking at th... |
35,744,901 | How to change the active configuration profile in gcloud? | <p>I have created a new configuration profile using command: </p>
<pre><code>gcloud init
</code></pre>
<p>and now I don't know how to switch to old configuration profile without override it. </p>
<p>Using <code>gcloud config</code> I can't switch to another configuration only set a property of the current configura... | 35,750,001 | 2 | 2 | null | 2016-03-02 10:43:49.523 UTC | 16 | 2020-02-23 19:04:10.793 UTC | 2016-03-02 22:32:26.497 UTC | null | 372,128 | null | 2,270,262 | null | 1 | 63 | google-compute-engine|gcloud|gcloud-cli | 36,402 | <p>You can see your configurations (created via gcloud init) via</p>
<pre><code>gcloud config configurations list
</code></pre>
<p>You can switch to a different configuration via</p>
<pre><code>gcloud config configurations activate MY_OLD_CONFIG
</code></pre>
<p>Once activated you can</p>
<pre><code>gcloud config ... |
35,552,874 | Get first letter of a string from column | <p>I'm fighting with pandas and for now I'm loosing. I have source table similar to this:</p>
<pre><code>import pandas as pd
a=pd.Series([123,22,32,453,45,453,56])
b=pd.Series([234,4353,355,453,345,453,56])
df=pd.concat([a, b], axis=1)
df.columns=['First', 'Second']
</code></pre>
<p>I would like to add new column to... | 35,552,899 | 2 | 2 | null | 2016-02-22 11:50:18.617 UTC | 17 | 2019-04-05 10:11:34.79 UTC | null | null | null | null | 5,528,782 | null | 1 | 71 | python|pandas | 167,283 | <p>Cast the <code>dtype</code> of the col to <code>str</code> and you can perform vectorised slicing calling <code>str</code>:</p>
<pre><code>In [29]:
df['new_col'] = df['First'].astype(str).str[0]
df
Out[29]:
First Second new_col
0 123 234 1
1 22 4353 2
2 32 355 3
3 453... |
21,237,495 | Create Custom Big Notifications | <p>I wanted to create a Notification including some controls. Since text and controls are small with default notification size (64dp), i wanted have it larger than default size.<br>
It is possible to create larger notifications, and I think it is possible to have a custom layout, too, but I don't know how.</p>
<p>To b... | 21,283,668 | 2 | 2 | null | 2014-01-20 15:14:09.38 UTC | 19 | 2019-10-31 11:57:45.743 UTC | null | null | null | null | 1,798,304 | null | 1 | 23 | android|android-layout|android-notifications | 39,659 | <p><strong>Update due to API changes:</strong> </p>
<p>From API 24 on, the <code>Notification.Builder</code> contains a <a href="https://developer.android.com/reference/android/app/Notification.Builder.html#setCustomBigContentView(android.widget.RemoteViews)">setCustomBigContentView(RemoteViews)</a>-method. Also the ... |
41,071,976 | I am confused about using static method in Multithreading java? | <p>something about static:</p>
<ul>
<li>instances of class share static method</li>
</ul>
<p>the similar questions:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/2671496/java-when-to-use-static-methods">Java: when to use static methods</a></li>
<li><a href="https://stackoverflow.com/questions/413898/what... | 41,072,067 | 4 | 1 | null | 2016-12-10 03:52:32.86 UTC | 9 | 2021-12-03 17:03:28.217 UTC | 2017-05-23 10:29:50.883 UTC | null | -1 | null | 6,707,607 | null | 1 | 27 | java|multithreading|static|static-methods | 34,907 | <blockquote>
<p>I am confusing about:</p>
<p>static method just have only one memory block? if i use static method
in multithreading, will it block?</p>
</blockquote>
<p>The <code>static</code> keyword in Java simply means "without regard or knowledge of any particular instance of an object."</p>
<p>An insta... |
1,620,072 | In Django, how to clear all the memcached keys and values? | <p>I don't want to restart the memcached server!</p> | 1,620,084 | 3 | 2 | null | 2009-10-25 05:11:27.95 UTC | 12 | 2020-04-29 09:26:17.07 UTC | null | null | null | null | 179,736 | null | 1 | 21 | python|django|caching|memcached | 13,218 | <pre><code>from django.core.cache import cache
cache._cache.flush_all()
</code></pre>
<p>Also see this ticket, it has a patch (that I haven't tested) to flush any type of cache backend: <a href="http://code.djangoproject.com/ticket/11503" rel="noreferrer">http://code.djangoproject.com/ticket/11503</a></p> |
1,468,111 | How do I jump to the matching tag, when editing HTML in Emacs? | <p>Suppose I'm editing a very long and messy HTML file. With my cursor at an open tag, is there a way to jump to its closing tag?</p> | 1,468,142 | 3 | 0 | null | 2009-09-23 19:30:57.787 UTC | 10 | 2016-03-24 21:26:03.773 UTC | 2012-02-26 07:08:05.607 UTC | null | 20,972 | null | 21,456 | null | 1 | 39 | html|emacs | 11,060 | <p>Assuming you're using nxml-mode:</p>
<pre><code>C-M-n runs the command nxml-forward-element, which is an interactive
compiled Lisp function in `nxml-mode.el'.
It is bound to C-M-n.
(nxml-forward-element &optional ARG)
Move forward over one element.
With ARG, do it that many times.
Negative ARG means move bac... |
1,357,798 | How to center cell contents of a LaTeX table whose columns have fixed widths? | <p>Consider the following piece of LaTeX code:</p>
<pre><code>\begin{tabular}{p{1in}p{1in}}
A & B\\
C & D\\
\end{tabular}
</code></pre>
<p>How can I make the contents of each cell aligned in the center of the cell rather than the left?
Note that I want to make sure that the widths of my columns are fixed, s... | 1,358,166 | 3 | 1 | null | 2009-08-31 14:41:27.597 UTC | 24 | 2022-05-26 12:54:14.727 UTC | 2016-12-31 22:48:58.7 UTC | null | 4,370,109 | null | 130,224 | null | 1 | 72 | alignment|latex|tabular | 173,230 | <p><code>\usepackage{array}</code> in the preamble</p>
<p>then this:</p>
<pre><code>\begin{tabular}{| >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} |}
</code></pre>
<p>note that the "m" for fixed with column is provided by the array package, and will give you vertical centering (if yo... |
8,616,146 | eventlisteners using hibernate 4.0 with spring 3.1.0.release? | <p>These jars are both new released and have the latest solutions for Java EE applications. But I have a problem on specifiying hibernate listeners in hibernate.cfg.xml. </p>
<p>Before spring 3.1.0, <code>LocalSessionFactroyBean</code> was holding an attribute that keeps eventlisteners. But with 3.1.0.release there is... | 9,011,451 | 4 | 1 | null | 2011-12-23 12:35:34.463 UTC | 11 | 2019-06-26 18:54:44.773 UTC | 2019-06-26 18:54:44.773 UTC | null | 1,281,433 | null | 706,589 | null | 1 | 20 | java|event-listener|spring-3|hibernate-4.x | 30,721 | <p>I had the same frustrating problem. Hibernate 4 appears to have fundamentally changed the way you register for events and the Spring group has not yet caught up. Here's my annotation-based solution using an init method to register a listener:</p>
<pre><code>@Component
public class HibernateEventWiring {
@Aut... |
8,683,922 | How can I pass my context variables to a javascript file in Django? | <p>This question must be obvious but I can't figure it out.</p>
<p>In a template, I link to a js file in my media directory. From that file, I would like to access a context variable like <code>{{my_chart}}</code>.</p>
<p>But is the syntax different?? Thank you!!</p> | 8,684,032 | 4 | 1 | null | 2011-12-30 20:45:38.553 UTC | 16 | 2021-06-14 20:31:07.997 UTC | 2021-06-14 07:39:07.62 UTC | null | 7,451,109 | null | 963,936 | null | 1 | 38 | javascript|django|templates | 40,069 | <p>I don't think it's possible this way. If you want to access some data provided by the view, you have to pass it to the js function.</p>
<p>Example</p>
<p>js file:</p>
<pre><code>my_cool_js_function(some_param){
// do some cool stuff
}
</code></pre>
<p>view</p>
<pre><code>// some html code
my_cool_js_functi... |
887,189 | Fuzzy Date Time Picker Control in C# .NET? | <p>I am implementing a Fuzzy Date control in C# for a winforms application. The Fuzzy Date should be able to take fuzzy values like</p>
<ul>
<li>Last June</li>
<li>2 Hours ago</li>
<li>2 Months ago</li>
<li>Last week</li>
<li>Yesterday </li>
<li>Last year</li>
</ul>
<p>and the like </p>
<p>Are there any sample imple... | 894,365 | 4 | 2 | null | 2009-05-20 10:27:23.89 UTC | 9 | 2016-06-29 12:12:44.007 UTC | 2017-05-23 11:52:28.823 UTC | null | -1 | null | 64,497 | null | 1 | 9 | c#|winforms|datetime|user-controls|fuzzy | 7,465 | <p>The parsing is quite easy. It can be implemented as bunch of regexps and some date calculations.</p>
<p>The sample below can be easily extended to suit your needs.
I've roughly tested it and it works at least for the following strings:</p>
<ul>
<li>next month, next year,</li>
<li>next 4 months, next 3 days</li>
<l... |
39,990,788 | Achieve "npm run x" behavior without a "scripts" entry? | <p>To run a node command within the "context" of your installed <code>node_modules</code>, you can make an entry in the <code>scripts</code> field of <code>package.json</code>. Eg:</p>
<pre><code>...
"scripts": {
"test": "mocha --recursive test/**/*.js --compilers js:babel-register"
}
...
</code></pre>
<p>an... | 39,991,116 | 3 | 1 | null | 2016-10-12 04:56:49.627 UTC | 9 | 2016-12-19 19:16:18.377 UTC | 2016-12-19 19:16:18.377 UTC | null | 769,871 | null | 438,615 | null | 1 | 32 | javascript|node.js|npm|command-line-interface | 8,145 | <p><sup>Note: This answer addresses the OP's specific use case: calling the CLIs of <em>dependent packages in the context of a given project</em>; it is <em>not</em> about making CLIs <em>globally available</em> - see bottom for a discussion.</sup> </p>
<p><strong>tl;dr:</strong></p>
<p><strong>On <em>Unix</em>-like... |
23,725,040 | How do i solve this error? Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead | <p>I get stuck on the following:</p>
<p>Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/xtremeso/public_html/mp3/includes/class/_class_mysql.php on line 116</p>
<pre><code> function safesql( $source )
{
if ($this->db_id) re... | 23,725,057 | 2 | 2 | null | 2014-05-18 17:48:48.95 UTC | 0 | 2014-05-18 18:01:46.233 UTC | null | null | null | null | 3,473,927 | null | 1 | 3 | php|mysql|sql|string|escaping | 40,236 | <p>the error message clearly said it .</p>
<p>change this</p>
<pre><code> else return mysql_escape_string($source); // you are using mysql here
</code></pre>
<p>to</p>
<pre><code> else return mysqli_real_escape_string($source); //will be mysqli
</code></pre>
<p>OBS: you should switch to PDO or MYSQLI as MYSQL <cod... |
32,360,687 | Connect to Docker MySQL container from localhost? | <p>I have a docker mysql image running, following is what the docker-compose.yml file looks like:</p>
<pre><code>db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
- "3306:3306"
</code></pre>
<p>This works fine.</p>
<p>My question is: How can I connect to t... | 32,361,238 | 8 | 3 | null | 2015-09-02 18:34:18.94 UTC | 18 | 2021-01-07 07:22:15.477 UTC | 2015-09-04 22:34:54.073 UTC | null | 507,151 | null | 507,151 | null | 1 | 89 | mysql|macos|docker|docker-compose | 123,478 | <h1>Using <code>docker-compose up</code></h1>
<p>Since you published port <code>3306</code> on your <strong>docker host</strong>, from that host itself you would connect to <code>127.0.0.1:3306</code>. </p>
<h1>Using <code>docker-compose run</code></h1>
<p>In that case the port mapping section of the <code>docker-co... |
36,500,968 | OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=350m; | <p>When I'mtrying to open Intellij IDE using command line in linux like this <code>./phpstorm.sh</code> both android studio and PHPStorm I always got this message : </p>
<blockquote>
<p>OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=350m;
support was removed in 8.0</p>
</blockquote>
<p>and I was wo... | 36,501,309 | 4 | 3 | null | 2016-04-08 13:33:24.893 UTC | 2 | 2022-06-13 09:09:49.253 UTC | 2017-05-23 11:51:35.887 UTC | null | -1 | null | 2,652,524 | null | 1 | 11 | java|linux|intellij-idea | 112,206 | <p>This is only a warning saying the option has been ignored - so it should not cause any issues.</p>
<p>The JVM options should be located in {IntelliJ folder}/bin/idea64.exe.vmoptions (on windows - probably something similar on linux). You can edit that file and delete the maxpermsize option.</p> |
31,453,681 | Mongo update array element (.NET driver 2.0) | <p>EDIT:
Not looking for the javascript way of doing this. I am looking for the MongoDB C# 2.0 driver way of doing this (I know it might not be possible; but I hope somebody knows a solution).</p>
<p>I am trying to update the value of an item embedded in an array on the primary document in my mongodb.</p>
<p>I am loo... | 33,720,549 | 3 | 7 | null | 2015-07-16 12:05:44.463 UTC | 8 | 2018-05-28 17:15:02.28 UTC | 2015-07-16 12:14:41.857 UTC | null | 1,387,545 | null | 1,387,545 | null | 1 | 27 | c#|.net|mongodb | 27,158 | <p>Took me a while to figure this out as it doesn't appear to be mentioned in any of the official documentation (or anywhere else). I did however find <a href="https://jira.mongodb.org/browse/CSHARP-531">this</a> on their issue tracker, which explains how to use the positional operator <code>$</code> with the C# 2.0 dr... |
69,855,485 | React hooks: Why do several useState setters in an async function cause several rerenders? | <p>This following onClick callback function will cause 1 re-render:</p>
<pre class="lang-js prettyprint-override"><code>const handleClickSync = () => {
// Order of setters doesn't matter - React lumps all state changes together
// The result is one single re-rendering
setValue("two");
setIsConditio... | 69,855,770 | 3 | 2 | null | 2021-11-05 15:15:58.883 UTC | 10 | 2022-08-31 16:32:14.323 UTC | null | null | null | null | 3,210,677 | null | 1 | 30 | javascript|reactjs|react-hooks | 4,218 | <p>In react 17, if code execution starts inside of react (eg, an <code>onClick</code> listener or a <code>useEffect</code>), then react can be sure that after you've done all your state-setting, execution will return to react and it can continue from there. So for these cases, it can let code execution continue, wait f... |
57,419,127 | Flutter - How create Container with width match parent? | <p>I use this simple widget in my Flutter app:</p>
<pre><code> FlatButton(
child: Column(
children: <Widget>[
Image.asset(assets, height: 40, width: 40),
Text('Title'),
//my color line
Container(
height: 5,
width: ?,
... | 57,421,620 | 4 | 2 | null | 2019-08-08 18:59:09.07 UTC | 2 | 2020-09-23 10:23:52.27 UTC | null | null | null | null | 631,843 | null | 1 | 40 | flutter|dart | 61,670 | <p>Use <a href="https://api.flutter.dev/flutter/widgets/IntrinsicWidth-class.html" rel="noreferrer">IntrinsicWidth</a></p>
<pre><code> FlatButton(
child: IntrinsicWidth(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widg... |
7,419,194 | What is the best way of adding a greater than 0 validator on the client-side using MVC and data annotation? | <p>I'd like to be able to only allow a form to submit if the value in a certain field is greater than 0. I thought maybe the Mvc Range attribute would allow me to enter only 1 value to signify only a greater than test, but no luck there as it insists on Minimum AND Maximum values.</p>
<p>Any ideas how this can be ach... | 7,419,330 | 4 | 1 | null | 2011-09-14 15:47:27.517 UTC | 5 | 2022-03-04 16:26:45.58 UTC | null | null | null | null | 306,098 | null | 1 | 128 | asp.net-mvc|unobtrusive-validation | 119,784 | <p>You can't store a number bigger than what your underlying data type could hold so that fact that the Range attribute requires a max value is a very good thing. Remember that <code>∞</code> doesn't exist in the real world, so the following should work:</p>
<pre><code>[Range(1, int.MaxValue, ErrorMessage = "Please en... |
7,907,067 | Difference between Action(arg) and Action.Invoke(arg) | <pre><code>static void Main()
{
Action<string> myAction = SomeMethod;
myAction("Hello World");
myAction.Invoke("Hello World");
}
static void SomeMethod(string someString)
{
Console.WriteLine(someString);
}
</code></pre>
<p>The output for the above is:</p>
<pre><code>Hello World
Hello World
</c... | 7,907,079 | 1 | 0 | null | 2011-10-26 18:19:57.437 UTC | 4 | 2011-10-26 18:20:53.557 UTC | null | null | null | null | 321,035 | null | 1 | 38 | c# | 8,192 | <p>All delegate types have a compiler-generated <code>Invoke</code> method.<br>
C# allows you to call the delegate itself as a shortcut to calling this method.</p>
<p>They both compile to the same IL:</p>
<h3>C#:</h3>
<pre><code>Action<string> x = Console.WriteLine;
x("1");
x.Invoke("2");
</code></pre>
<h3>IL... |
1,543,652 | Python gzip: is there a way to decompress from a string? | <p>I've read this <a href="https://stackoverflow.com/questions/1313845/if-i-have-the-contents-of-a-zipfile-in-a-python-string-can-i-decompress-it-witho">SO post</a> around the problem to no avail.</p>
<p>I am trying to decompress a .gz file coming from an URL.</p>
<pre><code>url_file_handle=StringIO( gz_data )
gzip_f... | 1,543,665 | 4 | 3 | null | 2009-10-09 13:09:12.133 UTC | 6 | 2020-11-03 08:37:25.767 UTC | 2017-05-23 12:32:13.693 UTC | Roger Pate | -1 | null | 171,461 | null | 1 | 36 | python|gzip | 53,158 | <p><code>gzip.open</code> is a shorthand for opening a file, what you want is <code>gzip.GzipFile</code> which you can pass a fileobj</p>
<pre><code>open(filename, mode='rb', compresslevel=9)
#Shorthand for GzipFile(filename, mode, compresslevel).
</code></pre>
<p>vs</p>
<pre><code>class GzipFile
__init__(sel... |
2,046,741 | The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly | <p>I am getting repeated errors about the ReadOnly property on performance counters whenever I try to debug a .NET windows service app. This app works fine on x86 windows vista, or x86 windows 2003. It's just stopped working on my new 64bit dev machine. </p>
<p>I've run the relevant InstallUtil invocations on 64bit an... | 2,081,976 | 4 | 2 | null | 2010-01-12 04:35:22.043 UTC | 9 | 2019-01-05 05:58:27.347 UTC | 2010-01-15 01:30:00.43 UTC | null | 101,260 | null | 101,260 | null | 1 | 40 | .net|windows-7|.net-3.5|performancecounter | 44,506 | <p>This is due to the performance counter (or category) <a href="http://rengberg.blogspot.com/2007/05/requested-performance-counter-is-not.html" rel="noreferrer">not existing</a>,
but with a horrible error message.</p>
<p>Take a look in perfmon for the counter, it should be missing on the relevant machines.</p>
<p>... |
10,332,546 | Truncate a float and a double in java | <p>I want to truncate a float and a double value in java.</p>
<p>Following are my requirements:
1. if i have 12.49688f, it should be printed as 12.49 without rounding off
2. if it is 12.456 in double, it should be printed as 12.45 without rounding off
3. In any case if the value is like 12.0, it should be printed ... | 10,332,818 | 6 | 2 | null | 2012-04-26 11:33:33.157 UTC | 5 | 2017-08-18 09:45:37.307 UTC | 2012-05-15 13:21:40.183 UTC | null | 44,390 | null | 1,211,036 | null | 1 | 13 | java|floating-point|double|truncate | 58,120 | <p>try this out-</p>
<pre><code>DecimalFormat df = new DecimalFormat("##.##");
df.setRoundingMode(RoundingMode.DOWN);
System.out.println(df.format(12.49688f));
System.out.println(df.format(12.456));
System.out.println(df.format(12.0));
</code></pre>
<p>Here, we are using decimal formatter for formating. The roundmode... |
10,766,900 | Is there a REPL for C programming? | <p>I am on osx. I found this
<a href="http://neugierig.org/software/c-repl/" rel="noreferrer">http://neugierig.org/software/c-repl/</a>
but the links on that page for code seem to be broken.</p> | 10,766,935 | 3 | 2 | null | 2012-05-26 14:02:31.977 UTC | 25 | 2020-07-17 15:37:10.553 UTC | null | null | null | null | 70,551 | null | 1 | 55 | c|read-eval-print-loop | 27,940 | <p>Seems like the code of <em>c-repl</em> can now be found at a <a href="https://github.com/martine/c-repl" rel="noreferrer">Github repository</a>. It seems to be a dead project, though (last commit was 3 years ago), so I'd suggest looking into alternatives as well:</p>
<ul>
<li>CINT <a href="https://web.archive.org/we... |
72,843,016 | "if" statement syntax differences between C and C++ | <pre class="lang-cpp prettyprint-override"><code>if (1) int a = 2;
</code></pre>
<p>This line of code is valid C++ code (it compiles at the very least) yet invalid C code (doesn't compile). I know there are differences between the languages but this one was unexpected.</p>
<p>I always thought the grammar was</p>
<pre><... | 72,843,033 | 4 | 9 | null | 2022-07-02 23:17:27.42 UTC | 8 | 2022-08-01 06:41:41.92 UTC | 2022-07-26 18:45:21.167 UTC | null | 5,784,757 | null | 9,513,499 | null | 1 | 93 | c++|c|language-lawyer|cross-language | 7,927 | <p>This is a subtle and important difference between C and C++. In C++ <em>any</em> statement may be a <em>declaration-statement</em>. In C, there is no such thing as a <em>declaration-statement</em>; instead, a <em>declaration</em> can appear instead of a <em>statement</em> within any <em>compound-statement</em>.</p... |
26,158,916 | Filter by regex example | <p>Could anyone provide an example of a regex filter for the Google Chrome Developer toolbar?</p>
<p>I especially need exclusion. I've tried many regexes, but somehow they don't seem to work:</p>
<p><img src="https://i.stack.imgur.com/u9Ipx.png" alt="enter image description here"></p> | 34,276,348 | 4 | 1 | null | 2014-10-02 10:27:26.957 UTC | 16 | 2020-03-10 14:38:00.557 UTC | 2018-07-26 21:35:17.733 UTC | null | 3,359,687 | null | 1,731,095 | null | 1 | 86 | regex|google-chrome-devtools | 32,231 | <p>It turned out that Google Chrome actually didn't support this until early 2015, <a href="https://code.google.com/p/chromium/issues/detail?can=2&q=375633&colspec=ID%20Pri%20M%20Iteration%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified&id=375633" rel="noreferrer">see Google Code issue</a>. W... |
7,632,126 | Maximum size of HashSet, Vector, LinkedList | <p>What is the maximum size of <code>HashSet</code>, <code>Vector</code>, <code>LinkedList</code>? I know that <code>ArrayList</code> can store more than 3277000 numbers.</p>
<p>However the size of list depends on the memory (heap) size. If it reaches maximum the JDK throws an <code>OutOfMemoryError</code>.</p>
<p>Bu... | 7,632,240 | 5 | 0 | null | 2011-10-03 07:25:47.833 UTC | 17 | 2020-06-26 08:47:41.037 UTC | 2011-10-22 09:42:42.383 UTC | null | 40,342 | null | 827,583 | null | 1 | 31 | java|collections | 52,032 | <p>There is no specified maximum size of these structures.</p>
<p>The actual practical size limit is probably somewhere in the region of <code>Integer.MAX_VALUE</code> (i.e. 2147483647, roughly 2 billion elements), as that's the maximum size of an array in Java.</p>
<ul>
<li>A <code>HashSet</code> uses a <code>HashMa... |
7,266,596 | Why avoid subtyping? | <p>I have seen many people in the Scala community advise on avoiding subtyping "like a plague". What are the various reasons against the use of subtyping? What are the alternatives?</p> | 8,352,969 | 8 | 0 | null | 2011-09-01 06:03:33.627 UTC | 25 | 2014-09-01 19:52:54.563 UTC | null | null | null | null | 192,247 | null | 1 | 35 | oop|scala|programming-languages|functional-programming | 4,411 | <p>Types determine the granularity of composition, i.e. of extensibility.</p>
<p>For example, an interface, e.g. Comparable, that combines (thus conflates) equality and relational operators. Thus it is impossible to compose on just one of the equality or relational interface.</p>
<p>In general, the <a href="https://s... |
7,668,047 | How can I get jQuery DataTables to sort on hidden value, but search on displayed value? | <p>I have a simple DataTables grid which contains date columns. I have provided two values for the date in my JSON data set, one for display and one specifically designed so that DataTables can sort it. My web application allows users to choose a bunch of different date formats, so it needs to be flexible.</p>
<p>This... | 19,783,592 | 9 | 4 | null | 2011-10-05 21:37:13.98 UTC | 9 | 2019-09-18 06:32:09.117 UTC | 2011-10-05 22:05:29.89 UTC | null | 5,651 | null | 5,651 | null | 1 | 42 | jquery|jquery-plugins|datatables | 53,414 | <p>This is an old post, but hopefully this will help someone else that comes here.</p>
<p>In a more recent version of DataTables, <code>bUseRendered</code> and <code>fnRender</code> are deprecated.</p>
<p><a href="http://datatables.net/reference/option/columns.render"><code>mRender</code></a> is the new way of doing ... |
7,253,803 | How to get everything after last slash in a URL? | <p>How can I extract whatever follows the last slash in a URL in Python? For example, these URLs should return the following:</p>
<pre><code>URL: http://www.test.com/TEST1
returns: TEST1
URL: http://www.test.com/page/TEST2
returns: TEST2
URL: http://www.test.com/page/page/12345
returns: 12345
</code></pre>
<p>I've ... | 7,253,830 | 14 | 5 | null | 2011-08-31 07:23:22.423 UTC | 31 | 2022-01-09 07:22:29.37 UTC | 2015-12-21 04:01:41.327 UTC | null | 5,299,236 | null | 348,496 | null | 1 | 148 | python|parsing|url | 151,548 | <p>You don't need fancy things, just see <a href="http://docs.python.org/py3k/library/stdtypes.html#str.rsplit" rel="noreferrer">the string methods in the standard library</a> and you can easily split your url between 'filename' part and the rest:</p>
<pre><code>url.rsplit('/', 1)
</code></pre>
<p>So you can get the ... |
14,053,885 | Integer Partition (algorithm and recursion) | <p>Finding how many combinations of a sum number (the variable <strong>n</strong> in code). For ex.:</p>
<blockquote>
<p>3 = 1+1+1 = 2+1 = 3 => ANS is 3</p>
<p>5 = 5 = 4+1 = 3+2 = 3+1+1 = 2+2+1 = 2+1+1+1 = 1+1+1+1+1 => ANS is 7</p>
</blockquote>
<p>In the following example, <strong>m</strong> is the max number an... | 18,367,427 | 4 | 5 | null | 2012-12-27 11:23:48.433 UTC | 10 | 2021-05-05 05:42:14.81 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 1,778,681 | null | 1 | 25 | algorithm|recursion|integer-partition | 23,305 | <p>Consider all ways of resulting <code>n</code> by adding some numbers less than or equal to <code>m</code>. As you said, we call this <code>p(n,m)</code>. For example, p(7,3)=8 because there are 8 ways to make 7 out of numbers less than 3 as listed below: (For simplicity we can assume that always we add numbers in or... |
13,819,734 | Unable to get a generic ResponseEntity<T> where T is a generic class "SomeClass<SomeGenericType>" | <p>Please help me to get a <code>ResponseEntity<T></code> where <code>T</code> is itself a generic type. As I see it of now, this is not supported nowdays by spring RestTemplate. I'm using Spring MVC version 3.1.2</p>
<p>Here is my code, that I want to use:
Code:</p>
<pre><code>ResponseEntity<CisResponse<... | 13,820,584 | 1 | 0 | null | 2012-12-11 11:47:31.977 UTC | 8 | 2015-08-18 12:55:43.27 UTC | 2012-12-11 12:49:59.273 UTC | null | 315,306 | null | 1,476,774 | null | 1 | 30 | java|spring|rest|generics|spring-mvc | 20,490 | <p>This was <a href="https://jira.springsource.org/browse/SPR-7023">a known issue</a>. Now it's fixed with the introduction of <code>ParameterizedTypeReference</code>, which is a parameterized type that you explicitely <strong>inherit</strong> to supply type information at runtime. This is called a <em>super-type token... |
14,241,900 | Should an Angular service have state? | <p>Recently some co-workers and I were having a discussion as to whether or not AngularJS services should have state or not. We came up with some arguments for and against it and I wanted to get additional thoughts and feedback on the subject. In my searching I found <a href="https://groups.google.com/forum/#!msg/angul... | 14,243,586 | 4 | 0 | null | 2013-01-09 16:35:11.357 UTC | 3 | 2014-12-17 07:57:56.827 UTC | null | null | null | null | 379,122 | null | 1 | 30 | service|angularjs|state | 13,724 | <p>In AngularJS, services <a href="http://code.angularjs.org/1.2.16/docs/guide/services" rel="nofollow noreferrer">are passed in via factory function</a>. And basically they are objects that can contain some state (e.g. for caching or storing data needed for performing their actions).</p>
<p>One good solution that can... |
13,811,889 | Cannot find libcrypto in Ubuntu | <p>I want to try one program which have makefile on it but when I put <code>make</code> in the shell the error was:</p>
<pre><code> g++ -g -DaUNIX -I../../acroname/aInclude -I../../acroname/aSource -Wl,-rpath,. unix_aLaserDemo_Data/aLaserDemo.o unix_aLaserDemo_Data/acpLaser.o -lpthread -lcrypto -lssl -o ../../ac... | 14,364,669 | 2 | 7 | null | 2012-12-11 00:50:28.93 UTC | 8 | 2016-11-14 06:53:30.18 UTC | 2012-12-11 01:01:19.893 UTC | null | 15,168 | null | 1,811,267 | null | 1 | 51 | c|gcc|ubuntu | 146,630 | <p>I solved this on 12.10 by installing libssl-dev.</p>
<pre><code>sudo apt-get install libssl-dev
</code></pre> |
13,895,390 | What does the ic_launcher-web.png in my project root do? | <p>Unbelievably enough, I couldn't find an answer when Googling for this very basic question!</p>
<p>I noticed that since I upgraded from Eclipse Helios to Eclipse Juno and updated the Android SDK, Eclipse places a file called ic_launcher-web.png in the project root whenever I create a new Android project. The file is... | 13,895,404 | 4 | 0 | null | 2012-12-15 19:24:48.78 UTC | 3 | 2019-05-24 16:22:07.907 UTC | null | null | null | null | 930,640 | null | 1 | 81 | android|eclipse|icons|project | 26,244 | <p>It's for the Play Store, which accepts 512x512 high-resolution icons:</p>
<blockquote>
<ul>
<li>High Resolution Application Icon (Required):
<ul>
<li>Use: In various locations in Google Play.</li>
<li>Specs: 512x512, 32-bit PNG with alpha; Max size of 1024KB.</li>
</ul></li>
</ul>
<p><a href="... |
29,058,323 | How to move to previous caret position in Android Studio | <p>How can one move to previous caret position(s) in android studio?
It was possible in Eclipse.</p> | 36,601,757 | 14 | 2 | null | 2015-03-15 07:33:11.597 UTC | 12 | 2022-02-05 06:02:25.76 UTC | 2021-01-12 15:48:25.393 UTC | null | 5,925,259 | null | 305,135 | null | 1 | 104 | android|android-studio|keyboard-shortcuts | 34,231 | <p>Use <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Left</kbd> and <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Right</kbd></p>
<p>For Mac, use <kbd>Command</kbd> + <kbd>Option</kbd> + <kbd>Left</kbd> and <kbd>Command</kbd> + <kbd>Option</kbd> + <kbd>Right</kbd></p>
<p>If these don't work for you, it is possible that these key... |
43,787,006 | TypeError: Attempted to assign to readonly property - when typing in a text field | <p>I recently updated my Angular from 1.5.x to 1.6.4 and now, when I go to a form, I get the below error message whenever I try to type something up in the form/textbox:</p>
<pre><code>TypeError: Attempted to assign to readonly property.
</code></pre>
<p>This is my controller:</p>
<pre><code>mainApp.controller('newP... | 43,787,170 | 1 | 1 | null | 2017-05-04 15:23:37.947 UTC | 0 | 2017-05-04 15:31:17.76 UTC | null | null | null | null | 1,539,640 | null | 1 | 8 | javascript|angularjs | 39,392 | <p>Try this...</p>
<p>you have initialized <code>$scope.post = '';</code> as a string. But that should be <code>$scope.post = {};</code> an object.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js pretty... |
29,943,075 | Scrapy pipeline to export csv file in the right format | <p>I made the improvement according to the suggestion from alexce below. What I need is like the picture below. However each row/line should be one review: with date, rating, review text and link.</p>
<p>I need to let item processor process each review of every page.<br>
Currently TakeFirst() only takes the first revi... | 29,971,406 | 2 | 12 | null | 2015-04-29 11:58:36.383 UTC | 15 | 2016-03-19 19:32:15.807 UTC | 2016-03-19 19:32:15.807 UTC | null | -1 | null | 4,345,535 | null | 1 | 18 | python|csv|scrapy|pipeline | 25,433 | <p>I started from scratch and the following spider should be run with</p>
<p><code>scrapy crawl amazon -t csv -o Amazon.csv --loglevel=INFO</code></p>
<p>so that opening the CSV-File with a spreadsheet shows for me</p>
<p><img src="https://i.stack.imgur.com/p76Oq.png" alt="enter image description here"></p>
<p>Hope... |
9,405,610 | How to change navbar collapse threshold using Twitter bootstrap-responsive? | <p>I'm using Twitter Bootstrap 2.0.1 in a Rails 3.1.2 project, implemented with bootstrap-sass. I'm loading both the <code>bootstrap.css</code> and the <code>bootstrap-responsive.css</code> files, as well as the <code>bootstrap-collapse.js</code> Javascript.</p>
<p>I have a fluid layout with a navbar similar to the <a... | 9,405,698 | 14 | 1 | null | 2012-02-23 00:56:38.9 UTC | 26 | 2019-03-15 18:46:36.513 UTC | 2012-02-25 01:42:20.347 UTC | null | 550,712 | null | 550,712 | null | 1 | 94 | css|ruby-on-rails-3|twitter-bootstrap | 113,530 | <p>You are looking for line 239 of <code>bootstrap-responsive.css</code></p>
<pre class="lang-css prettyprint-override"><code>@media (max-width: 979px) {...}
</code></pre>
<p>Where the <code>max-width</code> value triggers the responsive nav. Change it to 550px or so and it should resize fine.</p> |
32,718,870 | How to get All input of POST in Laravel | <p>I am using Laravel 5 and trying to get all input of POST variable in controller like this-</p>
<pre><code>public function add_question()
{
return Request::all();
}
</code></pre>
<p>So, I am getting this errors-</p>
<p><a href="https://i.stack.imgur.com/VNGJk.png" rel="noreferrer"><img src="https://i.stack.img... | 32,719,142 | 8 | 3 | null | 2015-09-22 13:56:51.293 UTC | 8 | 2021-03-30 11:48:31.39 UTC | 2020-03-05 09:22:59.02 UTC | null | 2,193,439 | null | 2,193,439 | null | 1 | 70 | php|laravel|laravel-5 | 216,464 | <p>Try this :</p>
<pre><code>use Illuminate\Support\Facades\Request;
public function add_question(Request $request)
{
return $request->all();
}
</code></pre> |
32,683,599 | R ifelse to replace values in a column | <p>I have a column in my dataframe as follows: </p>
<pre><code>Private
Private
Private
?
Private
</code></pre>
<p>I want to replace this " ?" with Private. I have a solution as follows:</p>
<pre><code># Only replacing ? with Private
df$var <- ifelse(df$var == " ?", " Private", df$var)
</code></pre>
<p>However ... | 32,684,389 | 3 | 3 | null | 2015-09-20 19:48:58.487 UTC | 6 | 2018-12-05 08:02:30.007 UTC | null | null | null | null | 4,056,023 | null | 1 | 8 | r | 51,937 | <p>This should work, using the working example:</p>
<pre><code>var <- c("Private", "Private", "?", "Private")
df <- data.frame(var)
df$var[which(df$var == "?")] = "Private"
</code></pre>
<p>Then this will replace the values of "?" with "Private"</p>
<p>The reason your replacement isn't working (I think) is as ... |
19,317,493 | PHP preg_replace: Case insensitive match with case sensitive replacement | <p>I'm using preg_replace in PHP to find and replace specific words in a string, like this:</p>
<pre><code>$subject = "Apple apple";
print preg_replace('/\bapple\b/i', 'pear', $subject);
</code></pre>
<p>Which gives the result 'pear pear'.</p>
<p>What I'd like to be able to do is to match a word in a case insensitiv... | 19,317,811 | 4 | 2 | null | 2013-10-11 11:52:31.337 UTC | 7 | 2021-11-25 15:19:49.567 UTC | 2013-10-11 12:00:45.833 UTC | null | 1,647,085 | null | 1,647,085 | null | 1 | 29 | php|regex|preg-replace | 28,806 | <p>I have in mind this implementation for common case:</p>
<pre><code>$data = 'this is appLe and ApPle';
$search = 'apple';
$replace = 'pear';
$data = preg_replace_callback('/\b'.$search.'\b/i', function($matches) use ($replace)
{
$i=0;
return join('', array_map(function($char) use ($matches, &$i)
{
... |
19,488,658 | Get last day of Month | <p>For getting last date of month I have written this function</p>
<pre><code>/**
* @param month integer value of month
* @param year integer value of month
* @return last day of month in MM/dd/YYYY format
*/
private static String getDate(int month, int year) {
Calendar calendar = Calendar.getInstance();
/... | 19,488,731 | 9 | 3 | null | 2013-10-21 07:38:07.127 UTC | 3 | 2018-03-28 10:15:30.307 UTC | null | null | null | null | 1,568,380 | null | 1 | 24 | java|date|calendar | 49,488 | <p>Change <code>YYYY</code> to <code>yyyy</code> </p>
<pre><code>DateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy");
</code></pre>
<p><code>YYYY</code> is wrong <code>dateformat</code></p> |
34,252,640 | What is the purpose of the ConcurrencyStamp column in the AspNetUsers table in the new ASP.NET MVC 6 identity? | <p>What is the purpose of the <code>ConcurrencyStamp</code> column in the <code>AspNetUsers</code> table in the new ASP.NET MVC 6 identity?</p>
<p>This is the database schema of the <code>AspNetUsers</code> table:</p>
<p><a href="https://i.stack.imgur.com/Zr319.png" rel="noreferrer"><img src="https://i.stack.imgur.co... | 39,001,084 | 4 | 4 | null | 2015-12-13 15:18:46.257 UTC | 16 | 2021-04-27 09:58:30.72 UTC | null | null | null | null | 1,862,812 | null | 1 | 91 | asp.net-mvc|concurrency|database-schema|identity|asp.net-core-mvc | 41,418 | <p>As the name state, it's used to prevent concurrency update conflict.</p>
<p>For example, there's a <code>UserA</code> named Peter in the database
2 admins open the editor page of <code>UserA</code>, want to update this user.</p>
<ol>
<li><code>Admin_1</code> opened the page, and saw user called Peter.</li>
<li><code... |
45,006,727 | Split a list into sublists based on a condition with Stream api | <p>I have a specific question. There are some similar questions but these are either with Python, not with Java, or the requirements are different even if the question sounds similar. </p>
<p>I have a list of values.</p>
<pre><code>List1 = {10, -2, 23, 5, -11, 287, 5, -99}
</code></pre>
<p>At the end of the day, I w... | 45,007,405 | 8 | 3 | null | 2017-07-10 08:03:33.483 UTC | 5 | 2020-06-25 12:12:05.803 UTC | null | null | null | null | 5,873,039 | null | 1 | 30 | java|java-stream | 40,237 | <p>If you want to do it in a single Stream operation, you need a custom collector:</p>
<pre><code>List<Integer> list = Arrays.asList(10, -2, 23, 5, -11, 287, 5, -99);
List<List<Integer>> result = list.stream().collect(
() -> Arrays.asList(new ArrayList<>(), new ArrayList<>()),
... |
35,310,078 | How to write to a file in .NET Core? | <p>I want to use the Bluetooth LE functions in .NET Core (specifically, BluetoothLEAdvertisementWatcher) to write a scanner which logs information to a file. This is to run as a desktop application and preferably as a command line app.</p>
<p>Constructors like System.IO.StreamWriter(string) are not available, apparent... | 35,400,949 | 7 | 3 | null | 2016-02-10 08:27:25.197 UTC | 9 | 2022-05-18 19:04:49.267 UTC | 2016-02-12 07:53:54.903 UTC | null | 80,309 | null | 80,309 | null | 1 | 60 | c#|.net|bluetooth|coreclr | 84,016 | <p>This code is the skeleton I was looking for when I posed the question. It uses only facilities available in .NET Core.</p>
<pre><code>var watcher = new BluetoothLEAdvertisementWatcher();
var logPath = System.IO.Path.GetTempFileName();
var logFile = System.IO.File.Create(logPath);
var logWriter = new System.IO.Stre... |
1,071,407 | How to set multiple selections in ASP.NET ListBox? | <p>I can't find a way to select multiple items in an ASP.NET ListBox in the code behind? Is this something needs to be done in Javascript?</p> | 1,071,426 | 5 | 0 | null | 2009-07-01 21:09:27.853 UTC | null | 2017-08-02 08:10:45.493 UTC | null | null | null | null | 129,001 | null | 1 | 9 | asp.net|listbox | 41,068 | <p>this is the VB code to do so...</p>
<pre><code>myListBox.SelectionMode = Multiple
For each i as listBoxItem in myListBox.Items
if i.Value = WantedValue Then
i.Selected = true
end if
Next
</code></pre> |
104,520 | WPF Validation for the whole form | <p>I have been seriously disappointed with WPF validation system. Anyway! How can I validate the complete form by clicking the "button"? </p>
<p>For some reason everything in WPF is soo complicated! I can do the validation in 1 line of code in ASP.NET which requires like 10-20 lines of code in WPF!!</p>
<p>I can do t... | 182,330 | 5 | 0 | null | 2008-09-19 18:54:18.467 UTC | 12 | 2014-01-13 15:43:18.697 UTC | 2014-01-13 15:43:18.697 UTC | null | 743 | azamsharp | 3,797 | null | 1 | 15 | wpf|validation | 29,823 | <p>A WPF application should disable the button to submit a form iff the entered data is not valid. You can achieve this by implementing the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.idataerrorinfo.aspx" rel="noreferrer">IDataErrorInfo</a> interface on your business object, using Bindings wi... |
385,335 | How to use PHP for large projects? | <p>The question has been asked: <a href="https://stackoverflow.com/questions/385203/no-php-for-large-projects-why-not">No PHP for large projects? Why not?</a> It's a recurring theme and PHP developers--with some cause--are forced to <a href="https://stackoverflow.com/questions/309300/defend-php-convince-me-it-isnt-hor... | 385,353 | 5 | 0 | null | 2008-12-22 01:37:44.897 UTC | 21 | 2020-02-15 07:18:09.453 UTC | 2017-05-23 10:28:07.11 UTC | Rich B | -1 | cletus | 18,393 | null | 1 | 25 | php | 6,430 | <p>For the most part, the problems with php are not so much with the language. The problems come from the coupling of a low barrier of entry and the lack of any infrastructure to avoid common programming problems or security problems. Its a language that, by itself, is pretty quick-and-dirty. Nevertheless, it still has... |
1,079,985 | NLS_LANG setting for JDBC thin driver? | <p>I am using the thin Oracle JDBC driver ver 10.2.0 (ojdbc14.jar). I would like to configure its NLS_LANG setting manually. Is there a way?</p>
<p>Currently it fetches this setting from the VM variable user.language (which is set automatically by setting the current locale, or on startup from the system environment).... | 1,306,042 | 5 | 0 | null | 2009-07-03 16:06:54.227 UTC | 9 | 2012-10-03 08:12:30.64 UTC | 2012-03-07 11:09:15.277 UTC | null | 21,234 | null | 31,155 | null | 1 | 27 | oracle|jdbc|nls|ora-12705 | 71,477 | <p>The NLS_LANG settings are derived from the java.util.Locale . Therefore, you will need to make a call similar to this before connecting:</p>
<pre><code>Locale.setDefault(Locale.<your locale here>);
</code></pre> |
176,931 | How can I get MSBUILD to evaluate and print the full path when given a relative path? | <p>How can I get MSBuild to evaluate and print in a <code><Message /></code> task an absolute path given a relative path?</p>
<p><strong>Property Group</strong></p>
<pre><code><Source_Dir>..\..\..\Public\Server\</Source_Dir>
<Program_Dir>c:\Program Files (x86)\Program\</Program_Dir>
</co... | 1,251,198 | 5 | 3 | null | 2008-10-07 01:45:44.087 UTC | 10 | 2012-09-02 15:10:40.1 UTC | 2010-08-12 05:26:56.78 UTC | null | 11,635 | spoon16 | 3,957 | null | 1 | 61 | msbuild|relative-path|absolute-path | 37,966 | <p><strong>In MSBuild 4.0</strong>, the easiest way is the following:</p>
<pre><code>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\your\path'))
</code></pre>
<p>This method works even if the script is <code><Import></code>ed into another script; the path is relative to the file containing the abo... |
148,074 | Is the sorting algorithm used by .NET's `Array.Sort()` method a stable algorithm? | <p>Is the sorting algorithm used by .NET's <code>Array.Sort()</code> method a <a href="http://en.wikipedia.org/wiki/Stable_sort#Classification" rel="noreferrer">stable</a> algorithm?</p> | 148,081 | 5 | 4 | null | 2008-09-29 09:22:39.183 UTC | 6 | 2014-06-12 09:38:09.563 UTC | 2009-07-06 16:46:16.59 UTC | null | 5,640 | Pop Catalin | 4,685 | null | 1 | 71 | c#|.net | 25,142 | <p>From <a href="http://msdn.microsoft.com/en-us/library/6tf1f0bc.aspx" rel="noreferrer">MSDN</a>:</p>
<blockquote>
<p>This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.</p>
... |
1,058,433 | Exporting result of select statement to CSV format in DB2 | <p>Is there any way by which we can export the result of a select statment to CSV file, just like in MySQL.</p>
<p>MySQL Command;</p>
<pre><code>SELECT col1,col2,coln into OUTFILE 'result.csv'
FIELDS TERMINATED BY ',' FROM testtable t;
</code></pre> | 1,059,588 | 6 | 0 | null | 2009-06-29 13:49:35.737 UTC | 11 | 2019-11-11 09:42:35.693 UTC | 2019-11-09 19:06:51.373 UTC | null | 456,274 | null | 94,813 | null | 1 | 27 | csv|db2|export | 143,934 | <p>You can run this command from the DB2 command line processor (CLP) or from inside a SQL application by calling the <code>ADMIN_CMD</code> stored procedure</p>
<pre><code>EXPORT TO result.csv OF DEL MODIFIED BY NOCHARDEL
SELECT col1, col2, coln FROM testtable;
</code></pre>
<p>There are lots of options for <code>I... |
555,705 | Character Translation using Python (like the tr command) | <p>Is there a way to do character translation / transliteration (kind of like the <a href="https://perldoc.perl.org/functions/tr" rel="nofollow noreferrer"><code>tr</code></a> command) using <strong>Python</strong>?</p>
<p>Some examples in Perl would be:</p>
<pre class="lang-perl prettyprint-override"><code>my $string ... | 555,724 | 6 | 3 | null | 2009-02-17 06:33:06.78 UTC | 3 | 2021-09-10 19:58:57.133 UTC | 2021-09-10 14:11:49.023 UTC | null | 967,621 | hhafez | 42,303 | null | 1 | 54 | python|perl|tr|transliteration | 35,945 | <p>See <a href="http://docs.python.org/library/stdtypes.html#str.translate" rel="noreferrer"><code>string.translate</code></a></p>
<pre><code>import string
"abc".translate(string.maketrans("abc", "def")) # => "def"
</code></pre>
<p>Note the doc's comments about subtleties in t... |
31,057,746 | What's the default color for placeholder text in UITextField? | <p>Does anyone know what color a <code>UITextField</code>'s placeholder text is, by default? I'm trying to set a <code>UITextView</code>'s text to the same color. I've read elsewhere that it is <code>UIColor.lightGrayColor()</code> but it is actually a little lighter.</p> | 43,346,157 | 13 | 3 | null | 2015-06-25 18:12:48.243 UTC | 19 | 2019-10-19 08:30:40.243 UTC | 2015-06-25 18:36:57.19 UTC | null | 3,633,534 | null | 4,996,707 | null | 1 | 70 | ios|uitextfield|uicolor | 37,991 | <p>You can get this colour from inspecting the <code>attributedPlaceholder</code> from the <code>UITextField</code>. </p>
<p>The default seems to be: <code>NSColor = "UIExtendedSRGBColorSpace 0 0 0.0980392 0.22";</code></p>
<p>You could add an extension (or category) on <code>UIColor</code>:</p>
<pre><code>extension... |
32,398,314 | Android data binding - 'No resource identifier found for attribute' | <p>My layout file:</p>
<pre><code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="m... | 32,406,200 | 5 | 6 | null | 2015-09-04 12:39:30.73 UTC | 1 | 2021-03-07 08:34:27.46 UTC | 2015-09-04 13:00:04.46 UTC | null | 1,100,249 | null | 1,100,249 | null | 1 | 38 | android|data-binding | 11,441 | <p>You must use the data binding syntax. It should be:</p>
<pre><code><TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
app:fontName='@{"Roboto-Regular.ttf"}'
android:layout_height="wrap_content"/>
</code></pre> |
17,765,265 | Difference between Intent.ACTION_GET_CONTENT and Intent.ACTION_PICK | <p>I'm trying to let the user choose any image that they want on their device to use as a wallpaper in this wallpaper application I'm building. For some reason when I write:</p>
<pre><code>Intent myIntent = new Intent(Intent.ACTION_PICK);
myIntent.setType("image/*");
startActivityForResult(myIntent, 100);
</code></pre... | 17,765,424 | 3 | 0 | null | 2013-07-20 18:19:44.227 UTC | 22 | 2016-04-29 13:51:50.487 UTC | 2016-04-29 13:51:50.487 UTC | null | 140,752 | null | 1,193,321 | null | 1 | 74 | java|android|android-intent|android-camera-intent | 50,914 | <p>Your first <code>Intent</code> is invalid. The <a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_PICK" rel="noreferrer">protocol for <code>ACTION_PICK</code></a> requires you to supply a <code>Uri</code> indicating the collection you are picking from. </p>
<blockquote>
<p>What is ... |
47,042,483 | How to build and distribute a Python/Cython package that depends on third party libFoo.so | <p>I've written a Python module that depends on some C extensions. Those C extensions depend in turn on several compiled C libraries. I'd like to be able to distribute this module bundled with all the dependencies.</p>
<p>I've put together a minimal example (<a href="https://github.com/AppliedBiomath/cython-example" r... | 47,182,945 | 3 | 3 | null | 2017-10-31 18:41:52.89 UTC | 9 | 2017-11-10 22:34:17.36 UTC | null | null | null | null | 577,666 | null | 1 | 24 | python|setuptools|python-extensions|python-packaging | 8,674 | <p>As you probably know, the recommended way of distributing a Python module with compiled components is to use the <a href="https://pypi.python.org/pypi/wheel" rel="noreferrer">wheel format</a>. There doesn't appear to be any standard cross-platform way of bundling third-party native libraries into a wheel. However, t... |
11,968,210 | Powershell Get-WmiObject Access is denied | <p>I have a Powershell script containing the following line: </p>
<pre><code>$package = Get-WmiObject -Class Win32_Product -ComputerName $TargetServer -Filter ("Name='{0}'" -f $ApplicationName)
</code></pre>
<p>I followed the steps on this answer in order to enable Powershell Remoting between the servers: <a href="ht... | 12,092,961 | 5 | 4 | null | 2012-08-15 11:05:41.507 UTC | 2 | 2022-08-04 00:21:44.25 UTC | 2017-05-23 12:29:32.687 UTC | null | -1 | null | 41,169 | null | 1 | 2 | powershell|tfs | 40,488 | <p>I needed to pass credentials to the Get-WmiObject cmdlet.</p>
<p>I found the answer here:<a href="http://powershellmasters.blogspot.co.uk/2009/04/powershell-and-remote-wmi.html" rel="nofollow">Powershell Masters</a></p> |
46,977,267 | com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex - Android Studio 3.0 stable | <p>I made:</p>
<ul>
<li>In "Settings"->"Android SDK"->"SDK Tools" Google Play services is checked and installed v.46</li>
<li>Removed folder /.gradle</li>
<li>"Clean Project"</li>
<li>"Rebuild Project</li>
</ul>
<p>Error is:</p>
<pre><code>Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexM... | 59,004,954 | 9 | 9 | null | 2017-10-27 14:20:53.887 UTC | 7 | 2021-01-16 17:04:31.567 UTC | 2019-12-14 19:34:39.5 UTC | null | 6,936,929 | null | 8,002,684 | null | 1 | 39 | android|gradle|merge|dex|android-studio-3.0 | 68,189 | <p>I think it was due to Android Studio's latest version (at that time).
I tried it after a long time then the issue gone.</p> |
2,031,577 | Can memory be cleaned up? | <p>I am working in Delphi 5 (with FastMM installed) on a Win32 project, and have recently been trying to drastically reduce the memory usage in this application. So far, I have cut the usage nearly in half, but noticed something when working on a separate task. When I minimized the application, the memory usage shrun... | 2,033,393 | 7 | 4 | null | 2010-01-08 23:44:41.547 UTC | 21 | 2014-02-08 15:26:45.213 UTC | 2010-04-07 22:44:03.217 UTC | null | 34,504 | null | 34,504 | null | 1 | 30 | delphi|garbage-collection|memory-management | 10,008 | <p>This is what we use in <a href="http://17slon.com/gp/gp/dsiwin32.htm" rel="noreferrer">DSiWin32</a>:</p>
<pre><code>procedure DSiTrimWorkingSet;
var
hProcess: THandle;
begin
hProcess := OpenProcess(PROCESS_SET_QUOTA, false, GetCurrentProcessId);
try
SetProcessWorkingSetSize(hProcess, $FFFFFFFF, $FFFFFFFF)... |
1,573,548 | How does Python know where the end of a function is? | <p>I'm just learning python and confused when a "def" of a function ends?</p>
<p>I see code samples like:</p>
<pre><code>def myfunc(a=4,b=6):
sum = a + b
return sum
myfunc()
</code></pre>
<p>I know it doesn't end because of the return (because I've seen if statements... if FOO than return BAR, else return F... | 1,573,555 | 8 | 6 | null | 2009-10-15 16:32:53.44 UTC | 14 | 2022-08-13 13:38:38.863 UTC | 2022-08-13 13:38:38.863 UTC | null | 523,612 | null | 110,797 | null | 1 | 53 | python|syntax|indentation | 183,587 | <p>In Python whitespace is significant. The function ends when the indentation becomes smaller (less).</p>
<pre><code>def f():
pass # first line
pass # second line
pass # <-- less indentation, not part of function f.
</code></pre>
<p>Note that one-line functions can be written without indentation, on one l... |
1,525,672 | Determine a table's primary key using TSQL | <p>I'd like to determine the primary key of a table using TSQL (stored procedure or system table is fine). Is there such a mechanism in SQL Server (2005 or 2008)?</p> | 1,525,708 | 10 | 0 | null | 2009-10-06 13:42:03.66 UTC | 10 | 2020-11-13 22:26:20.737 UTC | 2009-10-06 14:47:37.957 UTC | null | 135,152 | null | 100,142 | null | 1 | 56 | sql|sql-server|tsql|primary-key | 61,867 | <p>This should get you started:</p>
<pre><code>SELECT
*
FROM
INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
JOIN
INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu
ON tc.CONSTRAINT_NAME = ccu.Constraint_name
WHERE
tc.TABLE_NAME = 'TableName' AND
tc.CONSTRAINT_TYPE = 'Primary Key'
</code></pr... |
2,268,417 | Expire a view-cache in Django? | <p>The <code>@cache_page decorator</code> is awesome. But for my blog I would like to keep a page in cache until someone comments on a post. This sounds like a great idea as people rarely comment so keeping the pages in memcached while nobody comments would be great. I'm thinking that someone must have had this problem... | 2,363,690 | 15 | 0 | null | 2010-02-15 19:33:39.64 UTC | 19 | 2021-07-08 06:14:43.1 UTC | 2016-07-22 22:54:38.293 UTC | null | 1,245,190 | null | 109,472 | null | 1 | 59 | python|django|caching | 24,072 | <p><em>This solution works for django versions before 1.7</em></p>
<p>Here's a solution I wrote to do just what you're talking about on some of my own projects:</p>
<pre><code>def expire_view_cache(view_name, args=[], namespace=None, key_prefix=None):
"""
This function allows you to invalidate any view-level ... |
18,090,481 | how to replace characters in hive? | <p>I have a string column <code>description</code> in a hive table which may contain tab characters <code>'\t'</code>, these characters are however messing some views when connecting hive to an external application.
is there a simple way to get rid of all tab characters in that column?. I could run a simple python prog... | 18,098,996 | 5 | 0 | null | 2013-08-06 21:05:47.02 UTC | 7 | 2018-09-13 14:05:18.593 UTC | 2013-08-06 21:15:19.783 UTC | null | 2,540,455 | null | 1,745,713 | null | 1 | 31 | hadoop|hive | 186,019 | <p><code>regexp_replace</code> UDF performs my task. Below is the definition and usage from apache Wiki.</p>
<pre><code>regexp_replace(string INITIAL_STRING, string PATTERN, string REPLACEMENT):
</code></pre>
<p>This returns the string resulting from replacing all substrings in <code>INITIAL_STRING</code>
that match ... |
17,997,228 | What is a dangling pointer? | <p>I know this is pretty common question, but still new for me!</p>
<p>I don't understand concept of dangling pointer, was googling around, and writing test methods to find one.</p>
<p>I just wonder is this a dangling pointer? As whatever example I found was returning something, here I'm trying something similar!</p>... | 17,997,314 | 7 | 7 | null | 2013-08-01 14:45:21.163 UTC | 32 | 2020-08-10 14:19:48.067 UTC | 2018-11-13 19:43:21.72 UTC | null | 4,618,308 | null | 1,337,514 | null | 1 | 66 | c++|pointers|dangling-pointer | 88,349 | <p>A dangling pointer is a pointer that points to invalid data or to data which is not valid anymore, for example:</p>
<pre><code>Class *object = new Class();
Class *object2 = object;
delete object;
object = nullptr;
// now object2 points to something which is not valid anymore
</code></pre>
<p>This can occur even i... |
17,812,566 | Count words and spaces in string C# | <p>I want to count words and spaces in my string. String looks like this:</p>
<pre><code>Command do something ptuf(123) and bo(1).ctq[5] v:0,
</code></pre>
<p>I have something like this so far</p>
<pre><code>int count = 0;
string mystring = "Command do something ptuf(123) and bo(1).ctq[5] v:0,";
foreach(char c in my... | 17,812,655 | 10 | 4 | null | 2013-07-23 14:07:09.493 UTC | 3 | 2021-06-22 08:22:35.057 UTC | null | null | null | null | 2,592,968 | null | 1 | 12 | c#|winforms|visual-studio-2010 | 58,778 | <pre><code>int countSpaces = mystring.Count(Char.IsWhiteSpace); // 6
int countWords = mystring.Split().Length; // 7
</code></pre>
<p>Note that both use <a href="http://msdn.microsoft.com/en-us/library/t809ektx.aspx" rel="noreferrer"><code>Char.IsWhiteSpace</code></a> which assumes other characters than <code>" "</code... |
6,810,581 | How to center the text in a JLabel? | <p>despite many tries I can't get the result that I would like to see - text centered within the JLabel and the JLabel somewhat centered in the BorderLayout. I said "somewhat" because there should be also another label "status" in the bottom-right corner of the window. Here the bit of code responsible for that: </p>
<... | 6,810,590 | 3 | 1 | null | 2011-07-25 00:00:37.593 UTC | 8 | 2018-05-03 18:10:51.607 UTC | 2015-06-15 09:36:05.477 UTC | null | 4,112,664 | null | 852,892 | null | 1 | 48 | java|swing|user-interface|jlabel|htmltext | 178,000 | <pre><code>String text = "In early March, the city of Topeka, Kansas," + "<br>" +
"temporarily changed its name to Google..." + "<br>" + "<br>" +
"...in an attempt to capture a spot" + "<br>" +
"in Google's new broadband/fiber-optics project." + "<br&... |
6,594,649 | How to split string into paragraphs using first comma? | <p>I have string: <code>@address = "10 Madison Avenue, New York, NY - (212) 538-1884"</code>
What's the best way to split it like this?</p>
<pre><code><p>10 Madison Avenue,</p>
<p>New York, NY - (212) 538-1884</p>
</code></pre> | 6,594,749 | 4 | 0 | null | 2011-07-06 10:02:44.56 UTC | 5 | 2018-02-21 12:55:58.897 UTC | 2018-02-21 12:55:58.897 UTC | null | 480,410 | null | 480,410 | null | 1 | 36 | ruby-on-rails|ruby|string|split | 16,245 | <p>String#split has a second argument, the maximum number of fields returned in the result array:
<a href="http://ruby-doc.org/core/classes/String.html#M001165">http://ruby-doc.org/core/classes/String.html#M001165</a></p>
<p><code>@address.split(",", 2)</code> will return an array with two strings, split at the first ... |
35,907,642 | Custom header to HttpClient request | <p>How do I add a custom header to a <code>HttpClient</code> request? I am using <code>PostAsJsonAsync</code> method to post the JSON. The custom header that I would need to be added is </p>
<pre><code>"X-Version: 1"
</code></pre>
<p>This is what I have done so far:</p>
<pre><code>using (var client = new HttpClient... | 43,780,538 | 8 | 3 | null | 2016-03-10 04:32:18.777 UTC | 23 | 2022-08-26 07:56:37.003 UTC | 2020-07-16 14:16:07.003 UTC | null | 271,200 | null | 2,556,858 | null | 1 | 206 | c#|asp.net|http-headers|dotnet-httpclient | 289,848 | <pre><code>var request = new HttpRequestMessage {
RequestUri = new Uri("[your request url string]"),
Method = HttpMethod.Post,
Headers = {
{ "X-Version", "1" } // HERE IS HOW TO ADD HEADERS,
{ HttpRequestHeader.Authorization.ToString(), "[your authorization token]" },
{ HttpRequestHe... |
52,277,629 | Remove Gutenberg CSS | <p>I have Gutenberg plugin installed in WordPress v4.9.8 and am trying to remove the CSS that comes with it so I can supply my own.</p>
<p>This is the sheet that gets included: </p>
<pre><code><link rel='stylesheet' id='wp-block-library-css' href='/wp-content/plugins/gutenberg/build/block-library/style.css?ver=15... | 52,280,110 | 11 | 8 | null | 2018-09-11 13:55:16.243 UTC | 5 | 2022-01-14 09:48:03.263 UTC | 2019-05-29 05:46:21.597 UTC | null | 2,674,937 | null | 874,691 | null | 1 | 32 | css|wordpress|wordpress-gutenberg | 34,032 | <p>I'm adding this as a more complete answer than my comment:</p>
<p>You need to remove the <code>-css</code> when trying to dequeue the script. That's added to the HTML markup and not the actual tag for the css file.</p>
<p>If you search the code (the location of the enqueue may change as Gutenberg gets rolled into ... |
18,294,726 | Calling order of link function in nested and repeated angularjs directives | <p>I'm fairly new to Javascript programming and I have only touched upon AngularJS. In order to evaluate it I decided to write a simple note application. The model is really simple, a list of notes where each note has a label, a text and a list of tags. However I ran into problem passing data between isolated scopes of... | 18,491,502 | 2 | 1 | null | 2013-08-18 00:55:59.473 UTC | 10 | 2013-08-28 14:59:27.053 UTC | null | null | null | null | 1,158,228 | null | 1 | 10 | angularjs|angularjs-directive|angularjs-scope|angularjs-ng-repeat | 6,343 | <p>Quoting Josh D. Miller who had kindly responded to a similar question I had : </p>
<p>" Just a couple of technical notes. Assume that you have this markup:</p>
<pre><code><div directive1>
<div directive2>
<!-- ... -->
</div>
</div>
</code></pre>
<p>Now AngularJS will create t... |
15,557,450 | Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON' Possible Connection String Issue? | <p>I'm attempting to deploy my first MVC application and I keep running into issues revolving around connecting to my sql server database. My current problem is that when I try to publish the site, I'm greeted with: SqlException (0x80131904): Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. What I'm not sure of ho... | 15,557,494 | 3 | 0 | null | 2013-03-21 20:29:44.677 UTC | 1 | 2022-05-31 17:46:02.913 UTC | null | null | null | null | 1,815,527 | null | 1 | 6 | iis|asp.net-mvc-4|ef-code-first|sql-server-2012|web-deployment | 39,432 | <p>If you intend to use integrated security you need to turn <a href="http://msdn.microsoft.com/en-us/library/72wdk8cc%28v=vs.71%29.aspx" rel="noreferrer">impersonation</a> on:</p>
<pre><code><identity impersonate="true" />
</code></pre>
<p>Otherwise add username and password to the <a href="http://connectionst... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.