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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
255,852 | Parallel Programming and C++ | <p>I've been writing a lot recently about Parallel computing and programming and I do notice that there are a lot of patterns that come up when it comes to parallel computing. Noting that Microsoft already has released a library along with the Microsoft Visual C++ 2010 Community Technical Preview (named Parallel Patter... | 255,937 | 4 | 2 | null | 2008-11-01 17:51:12.793 UTC | 13 | 2017-10-12 02:48:28.397 UTC | null | null | null | Dean Michael | 11,274 | null | 1 | 8 | c++|design-patterns|parallel-processing|idioms | 6,217 | <p>Patterns:</p>
<ul>
<li><p>Produce/Consumer</p>
<ul>
<li>One Thread produces data</li>
<li>One Thread consumes the data</li>
</ul></li>
<li><p>Loop parallelism</p>
<ul>
<li>If you can show that each loop is independent<br>
each iteration can be done in a sperate thread</li>
</ul></li>
<li><p>Re-Draw Thread</p>
<u... |
1,204,553 | Are there any good libraries for solving cubic splines in C++? | <p>I'm looking for a good C++ library to give me functions to solve for large cubic splines (on the order of 1000 points) anyone know one?</p> | 1,204,576 | 4 | 1 | null | 2009-07-30 05:07:22.88 UTC | 14 | 2019-11-01 07:00:12.277 UTC | 2012-01-24 05:38:39.907 UTC | null | 44,729 | null | 134,046 | null | 1 | 22 | c++|spline | 50,457 | <p>Try the Cubic B-Spline library:</p>
<ul>
<li><a href="https://github.com/NCAR/bspline" rel="noreferrer">https://github.com/NCAR/bspline</a></li>
</ul>
<p>and ALGLIB:</p>
<ul>
<li><a href="http://www.alglib.net/interpolation/spline3.php" rel="noreferrer">http://www.alglib.net/interpolation/spline3.php</a></li>
</u... |
878,348 | Where do I configure log4j in a JUnit test class? | <p>Looking at the last JUnit test case I wrote, I called log4j's BasicConfigurator.configure() method inside the class constructor. That worked fine for running just that single class from Eclipse's "run as JUnit test case" command. But I realize it's incorrect: I'm pretty sure our main test suite runs all of these c... | 878,362 | 4 | 1 | null | 2009-05-18 15:37:09.807 UTC | 17 | 2018-05-16 15:12:15.643 UTC | 2009-05-18 16:21:26.77 UTC | null | 20,774 | null | 18,103 | null | 1 | 91 | java|logging|junit|log4j | 109,433 | <p>The <code>LogManager</code> class determines which log4j config to use in a <a href="https://github.com/apache/log4j/blob/trunk/src/main/java/org/apache/log4j/LogManager.java#L81" rel="noreferrer">static block</a> which runs when the class is loaded. There are three options intended for end-users:</p>
<ol>
<li>If ... |
20,738,953 | Remove Blank option from Select Option with AngularJS | <p>I am new to AngularJS. I searched a lot, but it does not solve my problem.</p>
<p>I am getting a blank option for the first time in select box.</p>
<p>Here is my HTML code</p>
<pre><code><div ng-app="MyApp1">
<div ng-controller="MyController">
<input type="text" ng-model="feed.name" pla... | 20,738,971 | 12 | 0 | null | 2013-12-23 07:33:04.547 UTC | 13 | 2019-10-24 21:56:41.903 UTC | 2018-07-22 17:33:01.54 UTC | null | 5,535,245 | null | 2,189,617 | null | 1 | 81 | angularjs|angularjs-select | 145,404 | <p>For reference : <a href="https://stackoverflow.com/a/12654812/2353403">Why does angularjs include an empty option in select</a>?</p>
<blockquote>
<p>The empty <code>option</code> is generated when a value referenced by <code>ng-model</code> doesn't exist in a set of options passed to <code>ng-options</code>. This ha... |
20,470,626 | python script for RaspberryPi to connect wifi automatically | <p>I want to operate a WiFi dongle with RaspberryPi, (it's like a CPU without built-in WiFi). I need to write a python script which automatically scan for WiFi networks and a connection need to be automatically established with known SSID and password.</p>
<p>This mean that I need to provide the password for the WiFi ... | 54,320,536 | 4 | 2 | null | 2013-12-09 12:24:53.733 UTC | 8 | 2022-08-22 17:52:09.65 UTC | 2013-12-09 13:01:20.26 UTC | null | 1,134,742 | null | 3,077,250 | null | 1 | 10 | python|wifi|raspberry-pi | 46,612 | <p>Thank you all for your answers i made simple solution like below </p>
<pre><code>def wifiscan():
allSSID = Cell.all('wlan0')
print allSSID # prints all available WIFI SSIDs
myssid= 'Cell(ssid=vivekHome)' # vivekHome is my wifi name
for i in range(len(allSSID )):
if str(allSSID [i]) == myssid:... |
32,534,602 | JavaScript - Built in Function to Delete Multiple Keys in an Object? | <p>In JavaScript, I can delete an object's key with</p>
<p><code>delete myObject[myKey];</code></p>
<p>Is there an efficient way to delete multiple keys using one line? Something that looks like:</p>
<p><code>multiDelete myObject[keyOne, keyTwo, keyThree];</code></p> | 32,535,117 | 9 | 2 | null | 2015-09-12 02:34:57.647 UTC | 8 | 2022-09-23 20:13:59.983 UTC | 2022-09-23 20:13:59.983 UTC | null | 1,016,004 | user4596113 | null | null | 1 | 42 | javascript | 46,582 | <p>Here's a one-liner similar to what you're requesting.</p>
<pre><code>var obj = {a: 1, b: 2, c: 3, d: 4, e: 5 };
['c', 'e'].forEach(e => delete obj[e]);
// obj is now {a:1, b:2, d:4}
</code></pre> |
32,423,348 | Angular - POST uploaded file | <p>I'm using <a href="https://angular.io/" rel="noreferrer">Angular</a>, <a href="https://www.typescriptlang.org/" rel="noreferrer">TypeScript</a> to send a file, along with JSON Data to a server.</p>
<p>Below is my code:</p>
<pre><code>import {Component, View, NgFor, FORM_DIRECTIVES, FormBuilder, ControlGroup} from ... | 35,519,607 | 5 | 4 | null | 2015-09-06 12:04:44.437 UTC | 37 | 2018-02-25 08:21:24.413 UTC | 2018-02-25 08:16:09.043 UTC | null | 1,429,387 | null | 2,971,571 | null | 1 | 64 | angular|typescript|file-upload|angular2-http | 132,125 | <p>Look at my code, but be aware. I use async/await, because latest Chrome beta can read any es6 code, which gets by TypeScript with compilation. So, you must replace asyns/await by <code>.then()</code>.</p>
<p>Input change handler:</p>
<pre><code>/**
* @param fileInput
*/
public psdTemplateSelectionHandler (fileIn... |
54,734,538 | OpenCV Assertion failed: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) | <p>I have found the following code on <a href="https://medium.com/@ageitgey/how-to-break-a-captcha-system-in-15-minutes-with-machine-learning-dbebb035a710" rel="noreferrer">this website</a>:</p>
<pre><code>import os
import os.path
import cv2
import glob
import imutils
CAPTCHA_IMAGE_FOLDER = "generated_captcha_images"
... | 54,734,716 | 7 | 5 | null | 2019-02-17 15:06:29.313 UTC | 3 | 2022-08-23 07:49:32.603 UTC | 2022-08-23 07:49:32.603 UTC | null | 6,885,902 | null | 8,306,666 | null | 1 | 17 | python|opencv|contour | 47,660 | <p>This is doing the wrong thing:</p>
<pre class="lang-py prettyprint-override"><code>contours = contours[0] if imutils.is_cv2() else contours[1]
</code></pre>
<p><code>imutils.is_cv2()</code> is returning <code>False</code> even though it should return <code>True</code>. If you don't mind to remove this dependency, ... |
39,327,028 | Can a C++ function be declared such that the return value cannot be ignored? | <p>I'm trying to determine whether a C++ function can be declared in such a way that the return value cannot be ignored (ideally detected at compile time). I tried to declare a class with a <code>private</code> (or in C++11, <code>delete</code>d) <code>operator void()</code> to try to catch the implicit conversion to v... | 39,341,050 | 4 | 5 | null | 2016-09-05 08:58:05.783 UTC | 5 | 2020-08-23 12:32:35.353 UTC | 2016-09-05 17:59:38.1 UTC | null | 893 | null | 893 | null | 1 | 32 | c++|return-value|void | 4,264 | <p>To summarize from other answers & comments, basically you have 3 choices:</p>
<ol>
<li>Get C++17 to be able to use <code>[[nodiscard]]</code></li>
<li>In g++ (also clang++), use compiler extensions like <code>__wur</code> (defined
as <code>__attribute__ ((__warn_unused_result__))</code>), or the more portable ... |
20,142,002 | java.util.MissingResourceException: Can't find bundle for base name 'property_file name', locale en_US | <p>I am trying to create a utility class <code>ReadPropertyUtil.java</code> for reading data from property file. While my class is located under a util directory , my <code>skyscrapper.properties</code> file is placed in some other directory.</p>
<p>But , when i try to access the properties using <code>[ResourceBundle... | 20,142,626 | 12 | 0 | null | 2013-11-22 10:01:21.94 UTC | 5 | 2022-08-11 05:11:10.043 UTC | null | null | null | null | 1,471,314 | null | 1 | 44 | java|properties|resourcebundle | 225,786 | <p>Try with the <strong>fully qualified name</strong> for the resource:<br/></p>
<pre><code>private static final String FILENAME = "resources/skyscrapper";
</code></pre> |
20,052,769 | get first and last element in array | <p>hey there i have this array:</p>
<pre><code>array(1) {
["dump"]=>
string(38) "["24.0",24.1,24.2,24.3,24.4,24.5,24.6]"
}
</code></pre>
<p>my question:</p>
<p>how to get the first and the last element out from this array, so i will have:</p>
<pre><code>$firstEle = "24.0";
</code></pre>
<p>and</p>
<pre><co... | 20,052,835 | 6 | 1 | null | 2013-11-18 16:29:12.587 UTC | 11 | 2019-08-06 19:10:22.49 UTC | null | null | null | null | 2,999,787 | null | 1 | 49 | php|arrays|indexing | 96,224 | <p><a href="http://us1.php.net/reset" rel="noreferrer"><code>reset()</code></a> and <a href="http://us2.php.net/end" rel="noreferrer"><code>end()</code></a> does exactly this.</p>
<p>From the manual:</p>
<blockquote>
<p><a href="http://us1.php.net/reset" rel="noreferrer"><strong><code>reset()</code></strong></a>: Retur... |
7,032,965 | How do I figure out and change which version of Java Maven is using to execute? | <p>When running our Maven build, a member of my team gets a NoSuchMethodError in one of the dependant plug-ins when executing. However, when we run <code>java -version</code> from her command line, it indicates Java 1.6.0_26. The error obviously seems to be screaming that Maven is using Java 5.</p>
<p>How do I figure ... | 7,033,062 | 3 | 2 | null | 2011-08-11 21:17:33.91 UTC | 8 | 2022-02-26 13:25:01.437 UTC | 2022-02-26 13:25:01.437 UTC | null | 6,083,675 | null | 292 | null | 1 | 95 | java|maven | 89,082 | <p><code>mvn -version</code> will output which java it's using. If JAVA_HOME is set to a valid JDK directory and Maven is using something else, then most likely someone has tampered with the way that Maven starts up.</p> |
24,310,696 | UIColor not working with RGBA values | <p>I am trying to change the text colour in a UITextField using the following code (RGBA value) however it just appears white, or clear, I'm not too sure as the background is white itself. </p>
<pre><code>passwordTextField.textColor = UIColor(red: CGFloat(202.0), green: CGFloat(228.0), blue: CGFloat(230.0), alpha: CGF... | 24,310,767 | 6 | 1 | null | 2014-06-19 15:40:29.96 UTC | 3 | 2019-11-29 07:51:16.007 UTC | 2017-05-22 07:36:43.027 UTC | null | 6,214,222 | null | 2,875,074 | null | 1 | 30 | ios|swift|uicolor | 20,757 | <p>RGB values for UIColor are between 0 and 1 (see <a href="https://developer.apple.com/library/ios/documentation/uikit/reference/UIColor_Class/Reference/Reference.html#//apple_ref/occ/clm/UIColor/colorWithRed%3agreen%3ablue%3aalpha%3a">the documentation</a> "specified as a value from 0.0 to 1.0")</p>
<p>You need to d... |
1,957,290 | calculate the number of html checkbox checked using jquery | <p>how can i calculate the number of checkboxes that a user has checked using jquery?</p>
<p>what i want to do is limiting the number of checking for checkboxes in a form to 10 for example and when a user exceeds this range display a warning message.</p> | 1,957,296 | 4 | 1 | null | 2009-12-24 08:00:05.073 UTC | 5 | 2015-05-05 08:33:15.607 UTC | null | null | null | null | 107,887 | null | 1 | 25 | jquery|html|forms|checkbox | 56,954 | <p>There are multiple methods to do that:</p>
<p><strong>Method 1:</strong></p>
<pre><code>alert($('.checkbox_class_here:checked').size());
</code></pre>
<p><strong>Method 2:</strong></p>
<pre><code>alert($('input[name=checkbox_name]').attr('checked'));
</code></pre>
<p><strong>Method: 3</strong></p>
<pre><code>a... |
49,522,619 | The result of subscribe is not used | <p>I've upgraded to Android Studio 3.1 today, which seems to have added a few more lint checks. One of these lint checks is for one-shot RxJava2 <code>subscribe()</code> calls that are not stored in a variable. For example, getting a list of all players from my Room database:</p>
<pre><code>Single.just(db)
... | 49,523,600 | 8 | 4 | null | 2018-03-27 21:22:34.037 UTC | 31 | 2020-05-18 20:36:20.803 UTC | 2019-05-08 07:59:30.173 UTC | null | 469,080 | null | 469,080 | null | 1 | 153 | android|android-studio|rx-java2|lint|android-studio-3.1 | 57,538 | <p>The IDE does not know what potential effects your subscription can have when it's not disposed, so it treats it as potentially unsafe. For example, your <code>Single</code> may contain a network call, which could cause a memory leak if your <code>Activity</code> is abandoned during its execution. </p>
<p>A convenie... |
26,023,886 | Unknown type name 'UIImage' | <p>I've upgraded XCode from 5.1.1 to XCode 6.0.1 recently. Now everytime I want to define a new UIImage object I get this error:</p>
<pre>Unknown type name 'UIImage'</pre>
<p>Code:<br>
1. Create a new project<br>
2. Add <code>Image View</code> control to the storyboard<br>
3. Reference the <code>Image View</code> by ... | 26,690,066 | 3 | 2 | null | 2014-09-24 18:26:00.707 UTC | 12 | 2014-11-01 14:10:18.62 UTC | 2014-09-26 11:11:21.07 UTC | null | 2,198,253 | null | 2,198,253 | null | 1 | 38 | xcode5|xcode6 | 26,706 | <p>I also had the same problem and fixed it using</p>
<pre><code>#import <UIKit/UIKit.h>
</code></pre>
<p>However, I dug around some more and compared a project made in XCode 6 compared to Xcode 5, and I noticed that Xcode 6 did not create a prefix header file. The prefix header file is implicitly imported into... |
7,051,743 | Extending or including - what is better in Twig? | <p>Why Twig documentation recommends to use extending rather than including? Symfony 2 documentation says because "In Symfony2, we like to think about this problem differently: a template can be decorated by another one." but nothing more. It's just author's whim or something more? Thanks for help.</p> | 7,162,701 | 5 | 0 | null | 2011-08-13 16:25:13.117 UTC | 14 | 2016-01-20 18:10:51.107 UTC | 2012-08-05 09:09:31.133 UTC | null | 569,101 | null | 893,222 | null | 1 | 31 | php|symfony|twig|template-engine | 18,734 | <p><strong>When to use inheritance:</strong></p>
<p>You have 50 pages sharing the same layout - you create a layout.twig as a parent, and each page extends that layout.twig. So the parent is the generic and the child is the specific.</p>
<p><strong>When to use include:</strong></p>
<p>Out of the 50 pages, there are ... |
7,373,853 | Warning: session_start() [function.session-start]: Cannot send session cache limiter | <p>I have a problem with Session_start() here :</p>
<p><strong>Warning</strong>: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\pages\home.php:4) in <strong>C:\xampp\htdocs\charts\home-chart.php</strong> on line <strong>2</strong></... | 7,373,904 | 9 | 5 | null | 2011-09-10 18:49:26.813 UTC | 1 | 2018-05-07 23:52:16.2 UTC | 2014-01-12 17:35:27.07 UTC | null | 2,153,274 | null | 723,066 | null | 1 | 7 | php|session | 54,770 | <p>If you even have blank lines before the <code><?php</code> tag, then you can't set headers. Your start of file, with line numbers, should look like this:</p>
<pre><code>1. <?php
2. session_start();
3. header('Cache-control: private');
</code></pre>
<p>The message says "headers sent at line 2", so you're outp... |
13,847,963 | Akka Kill vs. Stop vs. Poison Pill? | <p>Newbie question of Akka - I'm reading over Akka Essentials, could someone please explain the difference between Akka Stop/Poison Pill vs. Kill ? The book offers just a small explaination "Kill is synchronous vs. Poison pill is asynchronous." But in what way? Does the calling actor thread lock during this time? Are t... | 13,848,350 | 4 | 3 | null | 2012-12-12 20:22:11.24 UTC | 76 | 2020-04-30 00:32:21.373 UTC | null | null | null | null | 1,243,034 | null | 1 | 223 | scala|akka | 58,938 | <p>Both <code>stop</code> and <code>PoisonPill</code> will terminate the actor and stop the message queue. They will cause the actor to cease processing messages, send a stop call to all its children, wait for them to terminate, then call its <code>postStop</code> hook. All further messages are sent to the dead lette... |
30,172,605 | How do I get into a Docker container's shell? | <p>I'm getting started working with Docker. I'm using the WordPress base image and docker-compose.</p>
<p>I'm trying to ssh into one of the containers to inspect the files/directories that were created during the initial build. I tried to run <code>docker-compose run containername ls -la</code>, but that didn't do any... | 30,173,220 | 30 | 6 | null | 2015-05-11 16:12:30.83 UTC | 491 | 2022-09-11 10:08:44.06 UTC | 2019-02-03 16:25:40.59 UTC | null | 1,663,462 | null | 48,523 | null | 1 | 1,781 | docker|docker-container | 1,720,975 | <p><code>docker attach</code> will let you connect to your Docker container, but this isn't really the same thing as <code>ssh</code>. If your container is running a webserver, for example, <code>docker attach</code> will probably connect you to the <em>stdout</em> of the web server process. It won't necessarily give... |
9,390,134 | Rsync cronjob that will only run if rsync isn't already running | <p>I have checked for a solution here but cannot seem to find one. I am dealing with a very slow wan connection about 300kb/sec. For my downloads I am using a remote box, and then I am downloading them to my house. I am trying to run a cronjob that will rsync two directories on my remote and local server every hour. ... | 9,390,183 | 5 | 1 | null | 2012-02-22 06:30:42.56 UTC | 9 | 2020-10-14 17:02:43.537 UTC | null | null | null | null | 1,225,088 | null | 1 | 22 | cron|rsync | 21,747 | <p>Via the script you can create a "lock" file. If the file exists, the cronjob should skip the run ; else it should proceed. Once the script completes, it should delete the lock file.</p>
<pre>
if [ -e /home/myhomedir/rsyncjob.lock ]
then
echo "Rsync job already running...exiting"
exit
fi
touch /home/myhomedir/r... |
9,170,670 | How do I set textarea scroll bar to bottom as a default? | <p>I have a textarea that is being dynamically reloaded as user input is being sent in. It refreshes itself every couple seconds. When the amount of text in this textarea exceeds the size of the textarea, a scroll bar appears. However the scroll bar isn't really usable because if you start scrolling down, a couple seco... | 9,170,709 | 5 | 1 | null | 2012-02-07 03:37:25.493 UTC | 25 | 2022-07-21 12:25:37.21 UTC | null | null | null | null | 1,190,419 | null | 1 | 114 | javascript|css|scroll|textarea | 114,758 | <p>pretty simple, in vanilla javascript:</p>
<pre><code>var textarea = document.getElementById('textarea_id');
textarea.scrollTop = textarea.scrollHeight;
</code></pre> |
19,719,397 | Qt Slots and C++11 lambda | <p>I have a QAction item that I initialize like follows:</p>
<pre><code>QAction* action = foo->addAction(tr("Some Action"));
connect(action, SIGNAL(triggered()), this, SLOT(onSomeAction()));
</code></pre>
<p>And then onSomeAction looks something like:</p>
<pre><code>void MyClass::onSomeAction()
{
QAction* cal... | 19,721,153 | 3 | 2 | null | 2013-11-01 01:21:49.583 UTC | 26 | 2019-09-24 11:49:49.47 UTC | 2013-11-01 20:55:38.067 UTC | null | 1,329,652 | null | 552,613 | null | 1 | 60 | c++|qt|c++11 | 48,009 | <p>The simple answer is: you can't. Or, rather, you don't want (or need!) to use <code>sender()</code>. Simply capture and use <code>action</code>.</p>
<pre><code>// Important!
// vvvv
connect(action, &QAction::triggered, this, [action, this]() {
... |
19,432,913 | Select info from table where row has max date | <p>My table looks something like this:</p>
<pre><code>group date cash checks
1 1/1/2013 0 0
2 1/1/2013 0 800
1 1/3/2013 0 700
3 1/1/2013 0 600
1 1/2/2013 0 400
3 1/5/2013 0 200
</code></pre>
<p>-- Do not need cash just demons... | 19,433,107 | 4 | 3 | null | 2013-10-17 17:01:34.013 UTC | 29 | 2020-01-28 23:51:14.97 UTC | 2013-10-17 17:10:34.42 UTC | null | 255,562 | null | 714,254 | null | 1 | 86 | sql|sql-server-2005|greatest-n-per-group | 510,799 | <pre><code>SELECT group,MAX(date) as max_date
FROM table
WHERE checks>0
GROUP BY group
</code></pre>
<p>That works to get the max date..join it back to your data to get the other columns:</p>
<pre><code>Select group,max_date,checks
from table t
inner join
(SELECT group,MAX(date) as max_date
FROM table
WHERE check... |
34,078,354 | How to disable landscape mode in React Native Android dev mode? | <p>I am new to android environment. I know iOS can be done in Xcode to disable device orientation. How can I disable landscape mode or any orientation mode in React Native Android?</p>
<p>Thanks.</p> | 34,086,828 | 9 | 3 | null | 2015-12-03 23:37:41.24 UTC | 12 | 2021-05-14 13:19:01.513 UTC | 2017-04-02 16:14:59.297 UTC | null | 1,206,613 | null | 108,524 | null | 1 | 87 | android|react-native | 56,197 | <p>Add <code>android:screenOrientation="portrait"</code> to the <code>activity</code> section in <code>android/app/src/main/AndroidManifest.xml</code> file, so that it end up looking like this:</p>
<pre><code><activity
android:name=".Activity"
android:label="Activity"
android:screenOrientation="portrait... |
24,868,226 | How do you mute an embedded Youtube player? | <p>I'm experimenting with the Youtube player but I can't get it to mute by default.</p>
<pre><code>function onPlayerReady() {
player.playVideo();
// Mute?!
player.mute();
player.setVolume(0);
}
</code></pre>
<p>How do I mute it from the start?</p>
<p><strong><a href="http://jsfiddle.net/Jonathan_Iron... | 24,869,361 | 4 | 4 | null | 2014-07-21 14:54:26.187 UTC | 6 | 2016-08-16 09:40:33.9 UTC | 2015-09-07 12:24:43.473 UTC | null | 2,407,212 | null | 2,407,212 | null | 1 | 22 | javascript|youtube|youtube-api | 82,486 | <p>Turns out <code>player.mute()</code> works fine. It only needed the parameter <code>enablejsapi=1</code>. Initial test in the fiddle didn't work because the player initiation had an error. The following works.</p>
<p>HTML:</p>
<pre><code><iframe id="ytplayer" type="text/html" src="https://www.youtube-nocookie.c... |
44,998,051 | Cannot create an instance of class ViewModel | <p>I am trying to write a sample app using Android architecture components and but even after trying for days I could not get it to work. It gives me the above exception.</p>
<p>Lifecycle owner:-</p>
<pre><code>public class MainActivity extends LifecycleActivity {
public void onCreate(Bundle savedInstanceState)
... | 44,998,087 | 34 | 1 | null | 2017-07-09 15:30:39.017 UTC | 13 | 2022-08-20 17:27:30.717 UTC | null | null | null | null | 4,581,287 | null | 1 | 122 | android|mvvm|android-architecture-components | 116,932 | <p>Make your constructor <code>public</code>.</p> |
279,729 | How to wait until all child processes called by fork() complete? | <p>I am forking a number of processes and I want to measure how long it takes to complete the whole task, that is when all processes forked are completed. Please advise how to make the parent process wait until all child processes are terminated? I want to make sure that I stop the timer at the right moment.</p>
<p>He... | 279,761 | 5 | 1 | null | 2008-11-11 01:11:39.53 UTC | 12 | 2017-04-30 03:45:18.307 UTC | 2017-04-30 03:26:49.43 UTC | null | 1,033,581 | Kamil Zadora | 3,515 | null | 1 | 19 | c++|linux|gcc|parallel-processing | 72,755 | <p>I'd move everything after the line "else //parent" down, outside the for loop. After the loop of forks, do another for loop with waitpid, then stop the clock and do the rest:</p>
<pre><code>for (int i = 0; i < pidCount; ++i) {
int status;
while (-1 == waitpid(pids[i], &status, 0));
if (!WIFEXITED... |
474,316 | HashTables in Cocoa | <p>HashTables/HashMaps are one of the most (if not <em>the</em> most) useful of data-structures in existence. As such, one of the first things I investigated when starting to learn programming in Cocoa was how to create, populate, and read data from a hashtable.</p>
<p>To my surprise: all the documentation I've been ... | 474,366 | 5 | 4 | null | 2009-01-23 20:09:25.353 UTC | 9 | 2019-10-17 10:07:16.167 UTC | 2009-01-23 21:14:08.953 UTC | Ryan Delucchi | 9,931 | Ryan Delucchi | 9,931 | null | 1 | 28 | objective-c|cocoa|macos|hashtable | 34,199 | <p><a href="https://developer.apple.com/documentation/foundation/nsdictionary?language=objc" rel="nofollow noreferrer">NSDictionary</a> and <a href="https://developer.apple.com/documentation/foundation/nsmutabledictionary?language=objc" rel="nofollow noreferrer">NSMutableDictionary</a>?</p>
<p>And here's a simple exam... |
280,658 | Can I detect animated gifs using php and gd? | <p>I'm currently running into some issues resizing images using GD.</p>
<p>Everything works fine until i want to resize an animated gif, which delivers the first frame on a black background.</p>
<p>I've tried using <code>getimagesize</code> but that only gives me dimensions and nothing to distinguish between just any... | 280,705 | 6 | 1 | null | 2008-11-11 11:32:33.757 UTC | 15 | 2018-03-13 18:45:36.04 UTC | 2008-11-11 11:56:50.54 UTC | Mitch Wheat | 16,076 | Kris | 18,565 | null | 1 | 47 | php|gd | 23,246 | <p>There is a brief snippet of code in the PHP manual page of the <code>imagecreatefromgif()</code> function that should be what you need:</p>
<p><a href="https://php.net/manual/en/function.imagecreatefromgif.php#59787" rel="nofollow noreferrer"><code>imagecreatefromgif</code> comment #59787 by ZeBadger</a></p> |
752,373 | Is it safe to rely on condition evaluation order in if statements? | <p>Is it bad practice to use the following format when <code>my_var</code> can be None?</p>
<pre><code>if my_var and 'something' in my_var:
#do something
</code></pre>
<p><em>The issue is that <code>'something' in my_var</code> will throw a TypeError if my_var is None.</em></p>
<p>Or should I use:</p>
<pre><cod... | 752,390 | 6 | 0 | null | 2009-04-15 15:57:19.04 UTC | 15 | 2011-11-21 13:08:45.143 UTC | null | null | null | null | 64,206 | null | 1 | 87 | python|if-statement | 34,231 | <p>It's safe to depend on the order of conditionals (<a href="http://docs.python.org/library/stdtypes.html#boolean-operations-and-or-not" rel="noreferrer">Python reference here</a>), specifically because of the problem you point out - it's very useful to be able to short-circuit evaluation that could cause problems in ... |
473,478 | How to do JSLint in Vim | <p>I spend my days in vim, currently writing a lot of JavaScript. I've been trying to find a way to integrate JSLint or something similar into vim to improve my coding. Has anyone managed to do something like this?</p>
<p>I tried this: <a href="http://mikecantelon.com/story/javascript-syntax-checking-vim" rel="nofollow... | 496,086 | 6 | 0 | null | 2009-01-23 16:10:29.47 UTC | 110 | 2022-04-06 09:19:01.71 UTC | 2022-04-06 09:19:01.71 UTC | uidzer0 | 5,446,749 | uidzer0 | 40,843 | null | 1 | 121 | javascript|vim|lint | 40,943 | <p>You can follow the intructions from <a href="http://wiki.whatwg.org/wiki/IDE" rel="noreferrer">JSLint web-service + VIM integration</a> or do what I did:</p>
<p>Download <a href="http://jslint.webvm.net/mylintrun.js" rel="noreferrer">http://jslint.webvm.net/mylintrun.js</a> and <a href="http://www.jslint.com/fulljs... |
30,972,252 | How do I delete my Google Cloud Platform Account? | <p>I have 2 cloud accounts and only need one, how do I delete or cancel my account so I do not have to pay for the one?</p> | 30,992,122 | 8 | 4 | null | 2015-06-22 04:45:35.673 UTC | 9 | 2022-04-18 16:25:26.993 UTC | null | null | null | null | 4,855,065 | null | 1 | 31 | google-cloud-platform | 73,670 | <p>By "account", I assume that you mean "Google Cloud Platform project", because a "Google Cloud Platform Account" is the same as a Google account, assuming you're referring to user credentials. You don't pay for such an account; you only pay for the resources you use, which are attached to a project.</p>
<p>You can e... |
39,298,474 | Java thread executing remainder operation in a loop blocks all other threads | <p>The following code snippet executes two threads, one is a simple timer logging every second, the second is an infinite loop that executes a remainder operation:</p>
<pre><code>public class TestBlockingThread {
private static final Logger LOGGER = LoggerFactory.getLogger(TestBlockingThread.class);
public st... | 39,298,768 | 4 | 27 | null | 2016-09-02 18:10:27.753 UTC | 47 | 2016-09-08 15:55:57.963 UTC | 2016-09-07 07:07:07.507 UTC | null | 545,127 | null | 492,936 | null | 1 | 126 | java|multithreading | 8,688 | <p>After all the explanations here (thanks to <a href="https://stackoverflow.com/users/57695/peter-lawrey">Peter Lawrey</a>) we found that the main source of this pause is that safepoint inside the loop is reached rather rarely so it takes a long time to stop all threads for JIT-compiled code replacement. </p>
<p... |
17,887,265 | how to #include third party libraries | <p>I have built and installed a library called <a href="http://wiki.openhome.org/wiki/OhNet" rel="noreferrer">OhNet</a>. After <code>make install</code> the corresponding header files of the framework have been installed under <code>usr/local/include/ohNet</code>. Now I want to use the Library in my C++ project (i am u... | 17,887,552 | 2 | 4 | null | 2013-07-26 17:15:38.36 UTC | 10 | 2017-02-27 21:49:17.59 UTC | 2017-02-27 21:49:17.59 UTC | null | 311,966 | null | 1,291,235 | null | 1 | 10 | c++|build|include|libraries|include-path | 24,277 | <ol>
<li>Use the <code>-I</code> compiler option to point to the 3rd party libraries directory (<code>-I/usr/local/include/ohNet</code>)</li>
<li>Use <code>#include "[whatever you need from oHNet].h"</code> in your header files and compilation units as needed (<strong>Note:</strong> you might need to put relative prefi... |
17,807,929 | JavaScript get href onclick | <p>I am trying to return the <code>href</code> attribute of a link using JavaScript when the user clicks on it. I want the URL the link is linking to displayed in an alert instead of loading the page.</p>
<p>I have the following code so far:</p>
<pre><code>function doalert(){
alert(document.getElementById("link")... | 17,808,032 | 2 | 0 | null | 2013-07-23 10:43:36.55 UTC | 4 | 2013-07-23 10:51:21.653 UTC | null | null | null | null | 506,399 | null | 1 | 15 | javascript|html | 100,822 | <p>Seems to be the order of your code, try this</p>
<pre><code><script>
function doalert(obj) {
alert(obj.getAttribute("href"));
return false;
}
</script>
<a href="http://www.example.com/" id="link" onclick="doalert(this); return false;">Link</a>
</code></pre>
<p><a hre... |
46,658,847 | Crypto Currency MySQL Datatypes ? | <h2>The infamous question about datatypes when storing money values in an SQL database.</h2>
<p>However in these trying times, we now have currencies that have worth up to 18 decimal places (thank you ETH).</p>
<p>This now reraises the classic argument.</p>
<p><strong>IDEAS</strong></p>
<p><strong>Option 1</strong> <co... | 48,555,882 | 1 | 3 | null | 2017-10-10 04:55:08.397 UTC | 6 | 2018-02-01 05:24:48.67 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 1,849,429 | null | 1 | 28 | mysql|sql|currency|sqldatatypes | 7,923 | <p>There's a clear best option out of the three you suggested (plus one from the comments).</p>
<p><strong>BIGINT</strong> — uses just 8 bytes, but the largest <code>BIGINT</code> only has 19 decimal digits; if you divide by 10<sup>18</sup>, the largest value you can represent is 9.22, which isn't enough range.</p>
<... |
2,105,979 | For interfaces with one implementation how can I just directly go to that implementation? | <p>I often have to debug Java code which was written so that there is an interface and exactly one implementation of that interface.</p>
<p>For instance there would be an interface Foo with exactly one implementation called <code>FooImpl</code>. In the following code if I Ctrl-click on <code>doThings</code> it'll jump ... | 2,106,233 | 5 | 3 | null | 2010-01-20 23:59:16.217 UTC | 13 | 2022-09-09 09:18:57.91 UTC | 2022-09-09 09:18:57.91 UTC | null | 452,775 | null | 124,696 | null | 1 | 41 | java|eclipse|keyboard-shortcuts | 35,276 | <p>The <a href="http://eclipse-tools.sourceforge.net/implementors/" rel="noreferrer">Implementors</a> plugin does pretty much exactly what you ask for. If there is only one implementation it will open it directly, otherwise it will let you choose.</p> |
1,438,141 | how to get list of port which are in use on the server | <p>How to get list of ports which are in use on the server?</p> | 1,438,160 | 5 | 0 | null | 2009-09-17 11:03:31.02 UTC | 10 | 2018-07-13 09:00:09.31 UTC | 2017-06-14 09:58:55.293 UTC | null | 1,285,055 | null | 136,161 | null | 1 | 47 | networking|port|windows-server-2003 | 201,647 | <p>Open up a command prompt then type...</p>
<pre><code>netstat -a
</code></pre> |
1,470,939 | string encryption/decryption | <p>I am interested if it's possible to do string encryption/decryption using Excel Visual Basic and some cryptographic service provider.</p>
<p>I have found a walk-through <a href="http://msdn.microsoft.com/en-us/library/ms172831.aspx" rel="nofollow noreferrer">Encrypting and Decrypting Strings in Visual Basic</a>, but... | 1,471,093 | 6 | 0 | null | 2009-09-24 10:53:47.657 UTC | 8 | 2020-07-05 16:45:16.677 UTC | 2020-07-05 16:45:16.677 UTC | null | 8,422,953 | null | 11,256 | null | 1 | 14 | excel|vba|string|encryption | 93,050 | <p>The link you provide shows how to perform string encryption and decryption using VB.NET, and thus, using the .NET Framework.</p>
<p>Currently, Microsoft Office products cannot yet use the <a href="http://en.wikipedia.org/wiki/Visual_Studio_Tools_for_Applications" rel="nofollow noreferrer">Visual Studio Tools for Ap... |
1,411,089 | How to stop GHC from generating intermediate files? | <p>When compiling a haskell source file via <code>ghc --make foo.hs</code> GHC always leaves behind a variety of intermediate files other than <code>foo.exe</code>. These are <code>foo.hi</code> and <code>foo.o</code>.</p>
<p>I often end up having to delete the .hi and .o files to avoid cluttering up the folders.</p>
... | 1,411,994 | 6 | 0 | null | 2009-09-11 14:08:07.64 UTC | 3 | 2021-09-13 17:19:54.827 UTC | null | null | null | unknown | null | null | 1 | 40 | haskell|ghc | 7,675 | <p>I've gone through the GHC docs a bit, and there doesn't seem to be a built-in way to remove the temporary files automatically -- after all, GHC needs those intermediate files to build the final executable, and their presence speeds up overall compilation when GHC knows it doesn't have to recompile a module.</p>
<p>... |
1,984,464 | Make private methods final? | <p>Is it beneficial to make private methods final? Would that improve performance?</p>
<p>I think "private final" doesn't make much sense, because a private method cannot be overridden. So the method lookup should be efficient as when using final.</p>
<p>And would it be better to make a private helper method static (... | 1,985,183 | 6 | 1 | null | 2009-12-31 08:01:20.22 UTC | 8 | 2012-11-29 11:15:24.537 UTC | null | null | null | null | 238,134 | null | 1 | 51 | java|final | 18,238 | <p>Adding <code>final</code> to methods does not improve performance with Sun HotSpot. Where <code>final</code> could be added, HotSpot will notice that the method is never overridden and so treat it the same.</p>
<p>In Java <code>private</code> methods are non-virtual. You can't override them, even using nested class... |
1,468,007 | AtomicInteger lazySet vs. set | <p>What is the difference between the <code>lazySet</code> and <code>set</code> methods of <code>AtomicInteger</code>? The <a href="http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicInteger.html#lazySet-int-" rel="noreferrer">documentation</a> doesn't have much to say about <code>lazySet</code>... | 1,468,020 | 6 | 1 | null | 2009-09-23 19:07:23.407 UTC | 49 | 2020-06-13 18:52:28.457 UTC | 2014-09-03 17:34:25.1 UTC | null | 285,873 | null | 72,437 | null | 1 | 127 | java|concurrency|atomic | 33,011 | <p>Cited straight from <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6275329" rel="noreferrer">"JDK-6275329: Add lazySet methods to atomic classes"</a>:</p>
<blockquote>
<p>As probably the last little JSR166 follow-up for Mustang,
we added a "lazySet" method to the Atomic classes
(AtomicInteger, At... |
1,966,010 | What does this mean? "Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM" | <p>T_PAAMAYIM_NEKUDOTAYIM sounds really exotic, but most certainly absolutely nonsense to me. I traced it all down to this lines of code:</p>
<pre><code><?php
Class Context {
protected $config;
public function getConfig($key) { // Here's the problem somewhere...
$cnf = $this->config;
return $cnf... | 1,966,020 | 8 | 1 | null | 2009-12-27 14:02:50.36 UTC | 11 | 2020-09-29 11:58:31.843 UTC | null | null | null | null | 221,023 | null | 1 | 65 | php | 112,808 | <p>T_PAAMAYIM_NEKUDOTAYIM is the double colon scope resolution thingy PHP uses - ::</p>
<p>Quick glance at your code, I think this line:</p>
<pre><code>return $cnf::getConfig($key);
</code></pre>
<p>should be</p>
<pre><code>return $cnf->getConfig($key);
</code></pre>
<p>The first is the way to call a method sta... |
2,067,472 | What is JSONP, and why was it created? | <p>I understand JSON, but not JSONP. <a href="http://en.wikipedia.org/wiki/JSON" rel="noreferrer">Wikipedia's document on JSON</a> is (was) the top search result for JSONP. It says this:</p>
<blockquote>
<p>JSONP or "JSON with padding" is a JSON extension wherein a prefix is specified as an input argument of the cal... | 2,067,584 | 10 | 4 | null | 2010-01-14 20:53:48.287 UTC | 925 | 2022-09-21 10:49:49.997 UTC | 2019-02-27 14:26:58.997 UTC | null | 123,671 | null | 48,082 | null | 1 | 2,376 | javascript|json|jsonp|terminology | 572,221 | <p>It's actually not too complicated...</p>
<p>Say you're on domain <strong><code>example.com</code></strong>, and you want to make a request to domain <strong><code>example.net</code></strong>. To do so, you need to <strong>cross domain</strong> boundaries, a <strong>no-no</strong> in most of browserland. </p>
<p>Th... |
1,586,882 | How do I convert a byte array to a long in Java? | <p>I am reading 8 bytes of data in from a hardware device. I need to convert them into a numeric value. I think I want to convert them to a long as that should fit 8 bytes. I am not very familiar with Java and low level data type operations. I seem to have two problems (apart from the fact there is almost no documen... | 1,586,894 | 11 | 4 | null | 2009-10-19 03:55:30.55 UTC | 3 | 2021-10-16 08:11:21.87 UTC | 2021-05-04 21:29:33.23 UTC | null | 423,105 | null | 78,428 | null | 1 | 7 | java | 41,563 | <p>For the endianness, test with some numbers you know, and then you will be using a byte shifting to move them into the long.</p>
<p>You may find this to be a starting point.
<a href="http://www.janeg.ca/scjp/oper/shift.html" rel="nofollow noreferrer">http://www.janeg.ca/scjp/oper/shift.html</a></p>
<p>The difficult... |
2,177,116 | Absolute DIV height 100% | <p>I have been working on this for the past couple of hours, and searching the web and stackoverflow hasn't been much support. How do I make <code>#gradient</code> and <code>#holes</code> fill the entire page?</p>
<p>I have used the Inspect Element feature in Safari, and when I highlight the body element it does not f... | 2,177,518 | 11 | 5 | null | 2010-02-01 13:59:01.887 UTC | 7 | 2019-06-11 13:06:19.693 UTC | 2019-06-11 13:06:19.693 UTC | null | 4,751,173 | null | 147,091 | null | 1 | 24 | css|html|height|absolute | 58,557 | <p>Well it looks to me that your element with all the content is floated. If it is then its not going to expand the body unless it is cleared. </p> |
1,735,550 | Find the minimum number in an array with recursion? | <pre><code>int i = 0;
int min = x[i];
while ( i < n ){
if ( x[i] < min ){
min = x[i];
}
i++;
}
return min;
</code></pre>
<p>I've written the iterative form to find the min number of an array. But I'd like to write a function that with recursion. Please help!</p> | 1,735,557 | 12 | 4 | null | 2009-11-14 20:49:09.267 UTC | null | 2022-06-07 07:18:12.9 UTC | 2009-11-14 20:55:36.43 UTC | null | 8,976 | null | 133,466 | null | 1 | 3 | c|recursion | 47,326 | <p>Because this sounds like homework, here's a hint: The minimum value in an array is either the first element, or the minimum number in the <em>rest</em> of the array, whichever is smaller.</p> |
33,940,015 | How to choose the Redux state shape for an app with list/detail views and pagination? | <p>Imagine I have a number of entries(say, users) in my database. I also have two routes, one for list, other for detail(where you can edit the entry). Now I'm struggling with how to approach the data structure. </p>
<p>I'm thinking of two approaches and a kinda combination of both.</p>
<h2>Shared data set</h2>
<ul>... | 33,946,576 | 2 | 3 | null | 2015-11-26 13:31:37.18 UTC | 40 | 2020-08-14 12:27:07.003 UTC | 2016-05-15 11:05:19.143 UTC | null | 301,596 | null | 301,596 | null | 1 | 66 | javascript|redux|ngrx | 14,474 | <p>Please consult <a href="https://github.com/reactjs/redux/tree/master/examples/real-world" rel="noreferrer">“real world” example</a> from Redux repo.<br>
It shows the solution to exactly this problem.</p>
<p>Your state shape should look like this:</p>
<pre><code>{
entities: {
users: {
1: { id: 1, name: ... |
17,684,921 | sort json object in javascript | <p>For example with have this code:</p>
<pre><code>var json = {
"user1" : {
"id" : 3
},
"user2" : {
"id" : 6
},
"user3" : {
"id" : 1
}
}
</code></pre>
<p>How can I sort this json to be like this -</p>
<pre><code>var json = {
"user3" : {
"id" : 1
},
... | 17,685,499 | 4 | 5 | null | 2013-07-16 19:03:47.613 UTC | 23 | 2018-10-13 09:59:20.863 UTC | 2014-09-25 23:32:38.437 UTC | null | 749,725 | null | 1,703,140 | null | 1 | 56 | javascript|json|sorting | 169,702 | <p>First off, that's <strong>not</strong> JSON. It's a JavaScript object literal. JSON is a <em>string representation</em> of data, that just so happens to very closely resemble JavaScript syntax.</p>
<p>Second, you have an object. They are unsorted. The order of the elements cannot be guaranteed. If you want gua... |
17,685,674 | Nginx proxy_pass with $remote_addr | <p>I'm trying to include $remote_addr or $http_remote_addr on my proxy_pass without success.</p>
<p>The rewrite rule works</p>
<pre><code>location ^~ /freegeoip/ {
rewrite ^ http://freegeoip.net/json/$remote_addr last;
}
</code></pre>
<p>The proxy_pass without the $remote_addr works, but freegeoip does not read ... | 22,259,088 | 7 | 2 | null | 2013-07-16 19:48:30.137 UTC | 14 | 2022-04-26 13:15:37.27 UTC | null | null | null | null | 1,052,498 | null | 1 | 62 | nginx|proxypass | 91,859 | <p>If the proxy_pass statement has no variables in it, then it will use the "gethostbyaddr" system call during start-up or reload and will cache that value permanently.</p>
<p>if there are any variables, such as using either of the following:</p>
<pre><code>set $originaddr http://origin.example.com;
proxy_pass $origi... |
17,853,898 | The name 'InitializeComponent' does not exist in the current context. Cannot get any help on net searches | <p>Hi I am getting an error of <code>InitializeComponent</code> in my <code>app.xaml.cs</code> page I have checked the net and everything but no solution works. Please help.</p>
<p><a href="https://stackoverflow.com/questions/6925584/the-name-initializecomponent-does-not-exist-in-the-current-context">InitializeCompone... | 19,873,833 | 10 | 0 | null | 2013-07-25 09:19:41.08 UTC | 6 | 2018-11-22 18:10:49.367 UTC | 2017-09-07 13:17:32.257 UTC | null | 6,113,711 | null | 2,598,085 | null | 1 | 38 | c#|.net|windows-phone-7|windows-phone-8 | 94,510 | <p><strong>There are two potential causes of this</strong>.</p>
<ol>
<li><p>The most common is the <strong>x:Class</strong> doesn't match up with the MainPage.xaml namespace. Make sure that x:Class in MainPage.xaml has the correct namespace.</p></li>
<li><p>The second most common cause of this problem is that the "Bui... |
17,707,961 | No connection could be made because the target machine actively refused it (PHP / WAMP) | <p>Note: <strong>I realise this could be seen as a duplicate but i have looked at the other responses and they didn't fix the problem for me.</strong></p>
<hr>
<p>I have recently installed Zend Studio and Zend Server with the mysql plugin on Windows 7.</p>
<p>I am not a qualified server administrator but neither am ... | 33,981,831 | 11 | 3 | null | 2013-07-17 18:54:17.553 UTC | 4 | 2021-06-04 18:14:07.497 UTC | 2019-12-23 12:05:40.897 UTC | null | 2,377,343 | null | 2,144,796 | null | 1 | 21 | mysql|zend-server | 130,366 | <ol>
<li>Go to C:\wamp\bin\mysql\mysql[your-version]\data </li>
<li>Copy and save "ib_logfile0" and "ib_logfile1" anywhere else. </li>
<li>delete "ib_logfile0" and ib_logfile1</li>
</ol>
<p>Did the trick for me. hope it works for you too.</p>
<p>Its working fine.
But we will have to stop apache and mysql, We need to ... |
6,496,433 | Multiple Sinatra apps using rack-mount | <p>I have a question regarding using rack-mount with Sinatra. I've got two classic-style Sinatra apps. Let's call one App defined in app.rb and the other API defined in api.rb.</p>
<p>I would like it so that api.rb handles all routes beginning with '/api' and app.rb handles all other requests including the root ('/').... | 6,496,677 | 4 | 0 | null | 2011-06-27 17:13:52.1 UTC | 9 | 2013-04-11 21:26:09.977 UTC | 2011-06-28 13:01:04.103 UTC | null | 613,444 | null | 613,444 | null | 1 | 17 | ruby|sinatra | 11,344 | <p>I think you'll prefer Rack::URLMap - it will probably look something like this:</p>
<pre><code>run Rack::URLMap.new("/" => App.new,
"/api" => Api.new)
</code></pre>
<p>That should go in your <code>config.ru</code> file.</p> |
18,577,860 | Creating app which opens a custom file extension | <p>Want to create an android application, which opens a custom-build file extension (for example, I want to open .abcd files)</p>
<p>It is something like Adobe Reader that opens .pdf files, or Photo Viewer that opens .jpg files</p>
<p><em>Specific conditions:</em><br>
1. The .abcd file should be outside / external fr... | 18,578,704 | 2 | 6 | null | 2013-09-02 16:59:10.62 UTC | 9 | 2019-05-03 20:51:12.16 UTC | 2013-09-02 16:59:54.04 UTC | null | 620,444 | null | 2,695,256 | null | 1 | 19 | android|file | 13,394 | <p>I think you need to do that type of customization via <code>intent-filter</code> something like:</p>
<pre><code><intent-filter android:icon="your_drawable-resource"
android:label="your_string_resource"
android:priority="integer">
<action android:name="android.intent.actio... |
34,958,886 | Gradle Could not find method compile() for arguments | <p>i have a hello world full screen android studio 1.5.1 app that i added a gradle/eclipse-mars subproject to. no other files were modified except for adding include ':javalib' to settings.gradle. adding a <a href="https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:project_jar_dependencies" rel="no... | 34,965,185 | 5 | 8 | null | 2016-01-23 02:16:37.333 UTC | 4 | 2021-07-17 14:26:13.987 UTC | 2017-05-23 10:31:31.273 UTC | null | -1 | null | 51,292 | null | 1 | 14 | android|gradle|android-gradle-plugin|subproject | 82,011 | <p>You already have </p>
<pre><code>compile project(':javalib')
</code></pre>
<p>in your <code>:app</code> project, you don't have to also inject the dependency from your root build.gradle. If you still want to do it from the root <code>build.gradle</code>, the correct way to do it is:</p>
<pre><code>configure(':ap... |
57,673,026 | 'require' and 'process' is not defined in ESlint. problem with node? | <p>I had an error in my pipeline in <code>GitLab</code>. I changed the settings in <code>.eslint.json</code> using information from StackOverflow. But I still have problem.</p>
<p>My <code>.eslint.json</code> looks like:</p>
<pre><code>{
"extends": "eslint:recommended",
"rules": {
"semi": ["warn", "never"],
... | 57,690,631 | 2 | 3 | null | 2019-08-27 10:46:24.79 UTC | 4 | 2020-09-30 06:53:19.31 UTC | 2020-05-22 16:25:15.623 UTC | null | 1,441,857 | null | 11,647,728 | null | 1 | 35 | node.js|eslint | 23,676 | <p>Rename <code>.eslint.json</code> to <code>.eslintrc.json</code> or make sure that <code>eslintConfig</code> is specified in your package.json</p>
<p><a href="https://eslint.org/docs/user-guide/configuring" rel="nofollow noreferrer">https://eslint.org/docs/user-guide/configuring</a></p>
<p>Also make sure that <code... |
542,312 | ASP.NET Access to the temp directory is denied | <p>I'm experiencing this problem today on many different servers. </p>
<p><strong>System.UnauthorizedAccessException: Access to the temp directory is denied.</strong></p>
<p>The servers were not touched recently. The only thing that comes in my mind is a windows update breaking something.. Any idea? </p>
<p>This hap... | 542,343 | 7 | 0 | null | 2009-02-12 17:02:22.813 UTC | 3 | 2017-02-16 13:34:35.44 UTC | null | null | null | Luca Martinetti | 2,250,286 | null | 1 | 15 | c#|asp.net|exception | 51,026 | <p>Have you checked the permissions on the temp folder? In these cases, the easiest and quickest solution is usually to re-run the <em>aspnet_regiis -i</em> command to re-install the asp.net framework which also resets the permissions on the required folders. Failing that, try using <a href="http://technet.microsoft.... |
498,343 | Putting a password to a user in PhpMyAdmin in Wamp | <p>How do you change the password for the root user in phpMyAdmin on WAMP server? because I'm locked out of phpMyAdmin, after changing the password incorrectly.</p> | 498,392 | 7 | 0 | null | 2009-01-31 05:35:12.76 UTC | 6 | 2015-01-23 11:51:57.127 UTC | 2009-10-15 08:00:04.607 UTC | Rogue | 44,386 | Rogue | 44,386 | null | 1 | 22 | phpmyadmin|wampserver | 144,727 | <p>my config.inc.php file in the phpmyadmin folder.
Change username and password to the one you have set for your database.</p>
<pre><code> <?php
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECUR... |
739,682 | How to add percent sign to NSString | <p>I want to have a percentage sign in my string after a digit. Something like this: 75%.</p>
<p>How can I have this done? I tried:</p>
<pre><code>[NSString stringWithFormat:@"%d\%", someDigit];
</code></pre>
<p>But it didn't work for me.</p> | 739,707 | 7 | 0 | null | 2009-04-11 07:33:57.037 UTC | 58 | 2017-06-07 16:41:36.067 UTC | 2016-04-22 19:55:59.727 UTC | null | 10,468 | null | 77,449 | null | 1 | 464 | objective-c|nsstring|string-literals | 135,735 | <p>The code for percent sign in <code>NSString</code> format is <code>%%</code>. This is also true for <code>NSLog()</code> and <code>printf()</code> formats.</p> |
171,785 | How do you organize Python modules? | <p>When it comes to organizing python modules, my Mac OS X system is a mess. I've packages lying around everywhere on my hdd and no particular system to organize them.</p>
<p>How do you keep everything manageable?</p> | 173,715 | 8 | 0 | null | 2008-10-05 10:09:28.113 UTC | 19 | 2013-04-11 06:28:56.453 UTC | 2013-04-11 06:28:56.453 UTC | user1131435 | null | ak | 20,672 | null | 1 | 14 | python|module | 6,862 | <p>My advice:</p>
<ul>
<li>Read <a href="http://docs.python.org/install/index.html" rel="noreferrer">Installing Python Modules</a>.</li>
<li>Read <a href="http://docs.python.org/distutils/index.html" rel="noreferrer">Distributing Python Modules</a>.</li>
<li>Start using easy_install from <a href="http://peak.telecommu... |
754,512 | MySQL: How do I find out which tables reference a specific table? | <p>I want to drop a table but it is referenced by one or more other tables. How can I find out which tables are referencing this table without having to look at each of the tables in the database one by one?</p> | 754,582 | 8 | 1 | null | 2009-04-16 02:19:58.17 UTC | 11 | 2022-01-11 19:08:10.213 UTC | null | null | null | seppy | null | null | 1 | 44 | mysql|foreign-keys | 34,639 | <pre class="lang-sql prettyprint-override"><code>SELECT TABLE_NAME
FROM information_schema.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = 'your_schema_name'
AND REFERENCED_TABLE_NAME = 'your_table_name';
</code></pre>
<p>This works.</p> |
728,205 | WPF ListView: Attaching a double-click (on an item) event | <p>I have the following <code>ListView</code>:</p>
<pre><code><ListView Name="TrackListView">
<ListView.View>
<GridView>
<GridViewColumn Header="Title" Width="100"
HeaderTemplate="{StaticResource BlueHeader}"
Display... | 728,248 | 8 | 0 | null | 2009-04-08 01:40:55.05 UTC | 24 | 2022-06-24 18:06:25.33 UTC | 2018-01-23 07:44:01.447 UTC | null | 336,648 | null | 44,084 | null | 1 | 87 | c#|wpf|xaml | 103,015 | <p>Found the solution from here: <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3d0eaa54-09a9-4c51-8677-8e90577e7bac/" rel="noreferrer">http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3d0eaa54-09a9-4c51-8677-8e90577e7bac/</a></p>
<hr>
<p>XAML:</p>
<pre><code><UserControl.Resources>
... |
604,484 | Linker errors between multiple projects in Visual C++ | <p>I have a solution with multiple projects. I have a "main" project, which acts as a menu and from there, the user can access any of the other projects. On this main project, I get linker errors for every function called. How do I avoid these linker errors? I set the project dependencies already in the "Project Depend... | 604,506 | 9 | 0 | null | 2009-03-02 23:25:28.177 UTC | 1 | 2018-11-09 02:30:55.863 UTC | 2009-03-03 00:13:41.68 UTC | rlbond | 72,631 | rlbond | 72,631 | null | 1 | 11 | visual-studio|visual-c++|projects-and-solutions | 46,152 | <p>Without knowing any other detail about your solution it is hard to tell, however Rebuild All, might be helpful. This situation can sometimes occur when there are mixed object files for different architectures.</p>
<p>You might also want to consider using "References" instead of "Dependencies"</p>
<p><strong>EDIT:<... |
547,542 | How can I manipulate MySQL fulltext search relevance to make one field more 'valuable' than another? | <p>Suppose I have two columns, keywords and content. I have a fulltext index across both. I want a row with foo in the keywords to have more relevance than a row with foo in the content. What do I need to do to cause MySQL to weight the matches in keywords higher than those in content? </p>
<p>I'm using the "match aga... | 547,840 | 9 | 0 | null | 2009-02-13 20:26:32.86 UTC | 36 | 2019-02-26 15:06:46.147 UTC | 2009-02-17 12:16:34.927 UTC | Buzz | 13,113 | Buzz | 13,113 | null | 1 | 45 | mysql|search|indexing|full-text-search|relevance | 27,032 | <p>Actually, using a case statement to make a pair of flags might be a better solution:</p>
<pre><code>select
...
, case when keyword like '%' + @input + '%' then 1 else 0 end as keywordmatch
, case when content like '%' + @input + '%' then 1 else 0 end as contentmatch
-- or whatever check you use for the matching
fr... |
800,368 | Declaring an object before initializing it in c++ | <p>Is it possible to declare a variable in c++ without instantiating it? I want to do something like this:</p>
<pre><code>Animal a;
if( happyDay() )
a( "puppies" ); //constructor call
else
a( "toads" );
</code></pre>
<p>Basially, I just want to declare a outside of the conditional so it gets the right scope.... | 800,384 | 10 | 3 | null | 2009-04-29 00:16:51.633 UTC | 13 | 2021-01-25 00:59:11.897 UTC | 2013-03-13 11:48:24.107 UTC | null | 1,488,917 | null | 81,658 | null | 1 | 82 | c++|scope|declaration|instantiation | 59,058 | <p>You can't do this directly in C++ since the object is constructed when you define it with the default constructor.</p>
<p>You could, however, run a parameterized constructor to begin with:</p>
<pre><code>Animal a(getAppropriateString());
</code></pre>
<p>Or you could actually use something like the <code>?: opera... |
794,663 | .NET convert number to string representation (1 to one, 2 to two, etc...) | <p>Is there a built in method in .NET to convert a number to the string representation of the number? For example, 1 becomes one, 2 becomes two, etc.</p> | 794,831 | 11 | 1 | null | 2009-04-27 18:24:26.98 UTC | 7 | 2015-05-08 19:04:49.77 UTC | null | null | null | null | 86,191 | null | 1 | 31 | .net | 25,924 | <p>I've always been a fan of the recursive method</p>
<pre><code> public static string NumberToText( int n)
{
if ( n < 0 )
return "Minus " + NumberToText(-n);
else if ( n == 0 )
return "";
else if ( n <= 19 )
return new string[] {"One", "Two", "Three", "Four", "Five", "Six", "Seven"... |
710,957 | How might I get the script filename from within that script? | <p>I'm pretty sure the answer is no, but thought I'd ask anyway.</p>
<p>If my site references a scripted named "whatever.js", is it possible to get "whatever.js" from within that script? Like:</p>
<pre><code>var scriptName = ???
if (typeof jQuery !== "function") {
throw new Error(
"jQuery's script needs ... | 710,996 | 12 | 7 | null | 2009-04-02 18:16:58.293 UTC | 10 | 2020-12-22 16:24:43.98 UTC | 2009-04-02 18:35:15.27 UTC | Shog9 | 811 | Chris | 11,574 | null | 1 | 59 | javascript|html | 51,047 | <pre><code>var scripts = document.getElementsByTagName('script');
var lastScript = scripts[scripts.length-1];
var scriptName = lastScript.src;
alert("loading: " + scriptName);
</code></pre>
<p>Tested in: FF 3.0.8, Chrome 1.0.154.53, IE6</p>
<hr />
<h3>See also: <a href="https://stackoverflow.com/questions/403... |
56,692 | Random weighted choice | <p>Consider the class below that represents a Broker:</p>
<pre><code>public class Broker
{
public string Name = string.Empty;
public int Weight = 0;
public Broker(string n, int w)
{
this.Name = n;
this.Weight = w;
}
}
</code></pre>
<p>I'd like to randomly select a Broker from an a... | 56,735 | 12 | 3 | null | 2008-09-11 14:34:11.053 UTC | 28 | 2022-06-10 03:30:10.577 UTC | null | null | null | LD2008 | 2,868 | null | 1 | 65 | c#|algorithm|random | 48,069 | <p>Your algorithm is nearly correct. However, the test should be <code><</code> instead of <code><=</code>:</p>
<pre><code>if (randomNumber < broker.Weight)
</code></pre>
<p>This is because 0 is inclusive in the random number while <code>totalWeight</code> is exclusive. In other words, a broker with weight 0... |
30,058 | How can I launch the Google Maps iPhone application from within my own native application? | <p>The <a href="http://developer.apple.com/documentation/AppleApplications/Reference/SafariWebContent/UsingiPhoneApplications/chapter_6_section_4.html" rel="nofollow noreferrer">Apple Developer Documentation</a> (link is dead now) explains that if you place a link in a web page and then click it whilst using Mobile Saf... | 30,079 | 16 | 1 | null | 2008-08-27 13:15:40.493 UTC | 50 | 2019-04-07 12:07:38.073 UTC | 2017-09-18 11:18:24.107 UTC | Paul | 1,000,551 | DavidM | 2,183 | null | 1 | 70 | ios|objective-c|google-maps | 98,718 | <p>For iOS 5.1.1 and lower, use the <code>openURL</code> method of <code>UIApplication</code>. It will perform the normal iPhone magical URL reinterpretation. so</p>
<pre><code>[someUIApplication openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=London"]]
</code></pre>
<p>should invoke the Google maps app.... |
29,104 | Requirements Gathering | <p>How do you go about the requirements gathering phase? Does anyone have a good set of guidelines or tips to follow? What are some good questions to ask the stakeholders? </p>
<p>I am currently working on a new project and there are a lot of unknowns. I am in the process of coming up with a list of questions to ask t... | 29,118 | 20 | 0 | null | 2008-08-26 22:31:13.007 UTC | 35 | 2017-03-10 17:28:12.23 UTC | 2017-03-10 17:28:12.23 UTC | gary | 4,099,593 | Aros | 1,375 | null | 1 | 29 | requirements-management | 22,762 | <p>You're almost certainly missing something. A lot of things, probably. Don't worry, it's ok. Even if you remembered everything and covered all the bases stakeholders aren't going to be able to give you very good, clear requirements without any point of reference. The best way to do this sort of thing is to get wh... |
425,044 | How to estimate a programming task if you have no experience in it | <p>I am having a difficult time with management asking for estimates on programming tasks that are using third-party controls that I have no prior experience with.</p>
<p>I definitely understand why they would want the estimates, but I feel as though any estimate I give will either be a) too short and make me look bad... | 425,063 | 22 | 1 | null | 2009-01-08 17:02:05.82 UTC | 62 | 2014-02-02 15:18:16.12 UTC | 2014-02-02 14:54:33.803 UTC | eJames | 63,550 | Jon Erickson | 1,950 | null | 1 | 105 | estimation | 19,826 | <p>The best answer you can give is to ask for time to knock up a quick prototype to allow you to give a more accurate estimate. Without <em>some</em> experience with a tool or a problem, any estimate you give is essentially meaningless.</p>
<p>As an aside, there is very rarely a problem with giving too long an estimat... |
198,431 | How do you compare two version Strings in Java? | <p>Is there a standard idiom for comparing version numbers? I can't just use a straight String compareTo because I don't know yet what the maximum number of point releases there will be. I need to compare the versions and have the following hold true:</p>
<pre><code>1.0 < 1.1
1.0.1 < 1.1
1.9 < 1.10
</code><... | 198,442 | 32 | 4 | null | 2008-10-13 17:54:41.37 UTC | 62 | 2022-03-02 09:07:46.483 UTC | 2008-10-13 21:16:59.933 UTC | Andrew | 826 | Bill the Lizard | 1,288 | null | 1 | 199 | java|comparison|versioning | 144,806 | <p>Tokenize the strings with the dot as delimiter and then compare the integer translation side by side, beginning from the left.</p> |
6,535,405 | What is the attribute property="og:title" inside meta tag? | <p>I have this extract of website source code:</p>
<pre><code><meta content="This is a basic text" property="og:title" />
</code></pre>
<p>What does this <strong>property attribute</strong> stand for, and what is its purpose?</p> | 6,535,427 | 4 | 0 | null | 2011-06-30 13:21:39.443 UTC | 36 | 2017-02-24 04:25:34.79 UTC | 2017-02-24 04:25:34.79 UTC | null | 402,884 | null | 505,762 | null | 1 | 176 | html|facebook|properties|meta-tags | 222,750 | <p><code>og:title</code> is one of the open graph meta tags. <code>og:...</code> properties define objects in a social graph. They are used for example by Facebook.</p>
<p><code>og:title</code> stands for the title of your object as it should appear within the graph (see here for more <a href="http://ogp.me/" rel="nor... |
6,388,812 | How to validate uploaded file in ASP.NET MVC? | <p>I have a Create action that takes an entity object and a HttpPostedFileBase image. The image does not belong to the entity model.</p>
<p>I can save the entity object in the database and the file in disk, but I am not sure how to validate these business rules:</p>
<ul>
<li>Image is required</li>
<li>Content type mu... | 6,388,927 | 5 | 0 | null | 2011-06-17 16:29:47.33 UTC | 48 | 2018-10-25 18:00:49.49 UTC | 2013-02-11 20:23:37.643 UTC | null | 638,990 | user386167 | null | null | 1 | 70 | asp.net-mvc|security | 75,246 | <p>A custom validation attribute is one way to go:</p>
<pre><code>public class ValidateFileAttribute : RequiredAttribute
{
public override bool IsValid(object value)
{
var file = value as HttpPostedFileBase;
if (file == null)
{
return false;
}
if (file.Conte... |
6,588,856 | Conversion from null to int possible? | <p>I know that when I read the answer to this I will see that I have overlooked something
that was under my eyes. But I have spent the last 30 minutes trying to figure it out myself
with no result.</p>
<p>So, I was writing a program in Java 6 and discovered some (for me) strange feature.
In order to try and isolate it... | 6,588,993 | 6 | 0 | null | 2011-07-05 21:05:08.793 UTC | 14 | 2017-04-16 18:46:20.78 UTC | 2011-07-05 21:43:39.273 UTC | null | 815,409 | null | 815,409 | null | 1 | 60 | java | 94,744 | <p>Let's look at the line:</p>
<pre><code>return y == null ? null : y.intValue();
</code></pre>
<p>In a <code>? :</code> statement, both sides of the <code>:</code> must have the same type. In this case, Java is going to make it have the type <code>Integer</code>. An <code>Integer</code> can be <code>null</code>, so ... |
41,336,301 | Typescript cannot find name window or document | <p>For either case:</p>
<pre><code>document.getElementById('body');
// or
window.document.getElementById('body');
</code></pre>
<p>I get <code>error TS2304: Cannot find name 'window'.</code></p>
<p>Am I missing something in <code>tsconfig.json</code> for a definition file I should install?</p>
<p>I get the message ... | 41,336,998 | 3 | 2 | null | 2016-12-26 21:09:38.197 UTC | 4 | 2022-02-22 18:15:00.86 UTC | 2017-03-29 16:33:38.913 UTC | null | 3,989,609 | null | 3,989,609 | null | 1 | 101 | javascript|typescript|typescript2.0 | 69,557 | <p>It seems that the problem is caused by targeting <code>ES2016</code>.<br>
Are you targeting that for a reason? If you target <code>es6</code> the error will probably go away.</p>
<p>Another option is to specify the libraries for the compiler to use:</p>
<pre><code>tsc -t ES2016 --lib "ES2016","DOM" ./your_file.ts
... |
15,911,014 | Watching a values in a service from a controller | <p>I have created a service to isolate the business logic and am injecting it in to the controllers that need the information. What I want to ultimately do is have the controllers be able to watch the values in the service so that I don't have to do broadcast/on notification or a complex message passing solution to hav... | 15,911,810 | 1 | 1 | null | 2013-04-09 19:40:09.287 UTC | 8 | 2014-07-08 08:49:00.223 UTC | null | null | null | null | 1,392,862 | null | 1 | 18 | angularjs | 32,963 | <p>You were already doing it right. i.e pushing the service into a scope variable and then observing the service as part of the scope variable.</p>
<p>Here is the working solution for you :</p>
<p><a href="http://plnkr.co/edit/SgA0ztPVPxTkA0wfS1HU?p=preview">http://plnkr.co/edit/SgA0ztPVPxTkA0wfS1HU?p=preview</a></p>... |
15,737,974 | How do I compare two variables containing strings in JavaScript? | <p>I want compare two variables, that are strings, but I am getting an error.</p>
<pre class="lang-js prettyprint-override"><code><script>
var to_check=$(this).val();
var cur_string=$("#0").text();
var to_chk = "that";
var cur_str= "that";
if(to_chk==cur_str){
alert("both are equal")... | 15,741,261 | 4 | 10 | null | 2013-04-01 05:15:19.693 UTC | 5 | 2019-03-03 18:11:31.233 UTC | 2017-05-31 06:50:28.937 UTC | null | 5,076,266 | null | 2,229,448 | null | 1 | 19 | javascript | 200,701 | <p><code>===</code> is not necessary. You know both values are strings so you dont need to compare types.</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 prettyprint-override"><code>function do_check()
{... |
15,697,830 | margin: auto is not centering | <p>In the following style from the website: <a href="http://6.470.scripts.mit.edu/css_exercises/exercise4.html" rel="noreferrer">http://6.470.scripts.mit.edu/css_exercises/exercise4.html</a></p>
<pre><code><style type="text/css">
#sponsors {
margin:auto;
margin-top:50px;
overflow: hi... | 15,697,890 | 10 | 2 | null | 2013-03-29 05:25:23.507 UTC | 2 | 2022-01-02 15:59:18.39 UTC | 2013-03-29 06:01:20.6 UTC | null | 184,842 | null | 1,851,931 | null | 1 | 22 | css | 73,769 | <p>Define <code>width</code> or <code>margin</code> on your <code>#sponsors</code> ID</p>
<p>as like this</p>
<pre><code>#sponsors{
margin:0 auto; // left margin is auto, right margin is auto , top and bottom margin is 0 set
width:1000px; // define your width according to your design
}
</code></pre>
<p>More about <... |
15,761,094 | DOM: why is this a memory leak? | <p>Consider this quote from <a href="https://developer.mozilla.org/en-US/docs/JavaScript/A_re-introduction_to_JavaScript#Memory_leaks" rel="noreferrer">the Mozilla Docs on JavaScript memory leaks</a>:</p>
<blockquote>
<pre><code>function addHandler() {
var el = document.getElementById('el');
el.onclick = functi... | 15,761,640 | 4 | 13 | 2013-05-08 05:00:49.743 UTC | 2013-04-02 09:53:13.6 UTC | 10 | 2018-05-17 01:01:25.987 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 2,096,191 | null | 1 | 30 | javascript|internet-explorer|memory-leaks|garbage-collection|circular-reference | 3,784 | <p>There are two concepts that will help you understand this example.</p>
<p><strong>1) Closures</strong></p>
<p>The definition of a closure is that <em><a href="http://crockford.com/javascript/private.html" rel="nofollow noreferrer">Every inner function enjoys access to its parent's function variables and parameters... |
50,258,960 | How to apply LabelEncoder for a specific column in Pandas dataframe | <p>I have a dataset loaded by dataframe where the class label needs to be encoded using <code>LabelEncoder</code> from scikit-learn. The column <code>label</code> is the class label column which has the following classes:</p>
<pre><code>[‘Standing’, ‘Walking’, ‘Running’, ‘null’]
</code></pre>
<p>To perform label enco... | 50,259,157 | 3 | 3 | null | 2018-05-09 17:26:12.237 UTC | 4 | 2021-10-01 10:08:58.137 UTC | 2020-04-28 07:41:47.24 UTC | null | 5,840,973 | null | 6,810,148 | null | 1 | 30 | python|python-3.x|machine-learning|scikit-learn|label-encoding | 43,710 | <p>You can try as following:</p>
<pre><code>le = preprocessing.LabelEncoder()
df['label'] = le.fit_transform(df.label.values)
</code></pre>
<p>Or following would work too:</p>
<pre><code>df['label'] = le.fit_transform(df['label'])
</code></pre>
<p>It will replace original <code>label</code> values in dataframe with... |
40,018,111 | Magento 2 goes terribly slow (Developer mode) | <p>Recently I started developing magento 2 projects.</p>
<p>First I tried on Windows with xampp and it was a mess... every refresh page was a nightmare, about 30-40sec to load the page. I read about it, that Windows system files is so slow working with magento because the large structure it has, and the article almmos... | 43,973,521 | 14 | 6 | null | 2016-10-13 10:10:08.243 UTC | 9 | 2020-04-03 19:28:37.227 UTC | 2016-10-17 14:29:16.063 UTC | null | 3,936,931 | null | 3,936,931 | null | 1 | 21 | php|magento|vagrant|e-commerce|magento2 | 17,321 | <p>I tried everything and the only thing it works is the virtual machine that provides bitnami. <a href="https://bitnami.com/stack/magento/virtual-machine" rel="nofollow noreferrer">https://bitnami.com/stack/magento/virtual-machine</a></p>
<p>Seriously, I don't know what has this vm, but goes really fast. I tried crea... |
56,624,895 | Android jetpack navigation component result from dialog | <p>So far I'm successfully able to navigate to dialogs and back using only navigation component. The problem is that, I have to do some stuff in dialog and return result to the fragment where dialog was called from.</p>
<p>One way is to use shared viewmodel. But for that I have to use .of(activity) which leaves my app... | 60,430,485 | 3 | 8 | null | 2019-06-17 04:52:13.85 UTC | 11 | 2020-07-28 14:47:30.73 UTC | 2019-11-05 13:38:58.713 UTC | null | 1,000,551 | null | 1,218,970 | null | 1 | 21 | android|android-jetpack|android-architecture-navigation | 11,050 | <p>In Navigation 2.3.0-alpha02 and higher, NavBackStackEntry gives access to a SavedStateHandle. A SavedStateHandle is a key-value map that can be used to store and retrieve data. These values persist through process death, including configuration changes, and remain available through the same object. By using the give... |
22,447,651 | Copying mysql databases from one computer to another | <p>I want to copy my mysql database from my computer to another computer. How can I do this?</p> | 22,447,694 | 7 | 3 | null | 2014-03-17 05:39:23.383 UTC | 13 | 2022-08-25 01:06:17.25 UTC | 2016-04-26 14:19:33.527 UTC | null | 2,959 | null | 3,427,626 | null | 1 | 23 | mysql|copy | 96,110 | <p><strong>How to copy Mysql database from one Computer to another / backup database using mysqldump</strong></p>
<ol>
<li><p>We can transfer a MySQL database from one PC to another PC using
mysqldump command.</p>
</li>
<li><p>We have to create dump file of database to transfer database from
one PC to another PC.</p>
<... |
13,254,189 | Writing debuggers | <p>I am very dissatisfied at how little info is available on writing Windows debuggers.</p>
<p>Most of the code I have was made by a long process of trial and error, the documentation obviously "thinks" most of the topics are too trivial while explaining in much detail obvious and useless things.</p>
<p>I found 2 art... | 14,585,096 | 2 | 3 | null | 2012-11-06 15:27:50.473 UTC | 9 | 2013-01-30 08:39:00.727 UTC | 2013-01-30 08:39:00.727 UTC | null | 815,724 | null | 78,054 | null | 1 | 10 | c++|windows|debugging | 2,862 | <p>This is indeed some information available.</p>
<p>DEBUG_EVENT (and the rest of the Debug API) is officially described in MSDN here: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms679308%28v=vs.85%29.aspx">http://msdn.microsoft.com/en-us/library/windows/desktop/ms679308(v=vs.85).aspx</a></p>
<p>... |
13,721,758 | How to search replace with regex and keep case as original in javascript | <p>Here is my problem. I have a string with mixed case in it. I want to search regardless of case and then replace the matches with some characters either side of the matches.</p>
<p>For example:</p>
<pre><code>var s1 = "abC...ABc..aBC....abc...ABC";
var s2 = s.replace(/some clever regex for abc/g, "#"+original abc... | 13,721,786 | 3 | 0 | null | 2012-12-05 11:01:36.217 UTC | 10 | 2022-04-11 17:12:28.34 UTC | null | null | null | null | 1,180,438 | null | 1 | 23 | javascript|regex | 14,578 | <p>This can be done using a callback function for regex replace.</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 prettyprint-override"><code>var s1 = "abC...ABc..aBC....abc...ABC";
var s2 = s1.replace(/a... |
13,261,602 | RadioGroup.setEnabled(false) doesn't work as expected | <p>I have used <code>setEnabled(false)</code> to set it unable, but it doesn't work and after this method, the value of <code>RadioGroup.isEnabled()</code> is false. The value was changed.</p>
<p>The code is from Android Programming Guide.</p>
<p>PS: The <code>Spinner</code> component use the <code>setEnabled(false)<... | 13,262,317 | 3 | 0 | null | 2012-11-07 00:34:15.967 UTC | 6 | 2021-05-26 20:22:37.853 UTC | 2020-04-22 09:21:10.163 UTC | null | 3,641,812 | null | 1,803,669 | null | 1 | 36 | android|android-widget | 21,758 | <p>Iterate and disable each button belonging to the radio group via a loop, for example:</p>
<pre><code>for (int i = 0; i < testRadioGroup.getChildCount(); i++) {
testRadioGroup.getChildAt(i).setEnabled(false);
}
</code></pre> |
13,422,743 | Convert a time span in seconds to formatted time in shell | <p>I have a variable of $i which is seconds in a shell script, and I am trying to convert it to 24 HOUR HH:MM:SS. Is this possible in shell?</p> | 13,422,982 | 7 | 0 | null | 2012-11-16 18:59:53.25 UTC | 8 | 2018-02-13 15:02:25.187 UTC | 2017-05-04 03:26:20.69 UTC | null | 45,375 | null | 377,269 | null | 1 | 39 | linux|shell|timespan|date-formatting | 54,634 | <p>Here's a fun hacky way to do exactly what you are looking for =)</p>
<pre><code>date -u -d @${i} +"%T"
</code></pre>
<p><strong>Explanation:</strong></p>
<ul>
<li>The <code>date</code> utility allows you to specify a time, from string, in seconds since 1970-01-01 00:00:00 UTC, and output it in whatever format you... |
13,568,337 | No warning or error (or runtime failure) when contravariance leads to ambiguity | <p>First, remember that a .NET <code>String</code> is both <code>IConvertible</code> and <code>ICloneable</code>.</p>
<p>Now, consider the following quite simple code:</p>
<pre><code>//contravariance "in"
interface ICanEat<in T> where T : class
{
void Eat(T food);
}
class HungryWolf : ICanEat<ICloneable&g... | 14,184,540 | 4 | 13 | null | 2012-11-26 15:51:34.567 UTC | 16 | 2013-02-18 05:31:07.46 UTC | 2012-12-05 08:53:29.62 UTC | null | 1,336,654 | null | 1,336,654 | null | 1 | 43 | c#|.net|undefined-behavior|contravariance|ambiguity | 1,077 | <p>I believe the compiler does the better thing in VB.NET with the warning, but I still don't think that is going far enough. Unfortunately, the "right thing" probably either requires disallowing something that is potentially useful(implementing the same interface with two covariant or contravariant generic type parame... |
13,654,401 | Why transform normals with the transpose of the inverse of the modelview matrix? | <p>I am working on some shaders, and I need to transform normals. </p>
<p>I read in few tutorials the way you transform normals is you <em>multiply them with the transpose of the inverse of the modelview matrix</em>. But I can't find explanation of why is that so, and what is the logic behind that?</p> | 13,654,662 | 5 | 0 | null | 2012-11-30 22:59:08.893 UTC | 34 | 2021-11-30 08:20:44.543 UTC | 2021-11-30 08:20:44.543 UTC | null | 1,907,004 | null | 1,796,942 | null | 1 | 58 | opengl|glsl|game-engine|game-physics | 39,019 | <p>Take a look at this tutorial:</p>
<p><a href="https://paroj.github.io/gltut/Illumination/Tut09%20Normal%20Transformation.html" rel="noreferrer">https://paroj.github.io/gltut/Illumination/Tut09%20Normal%20Transformation.html</a></p>
<p>You can imagine that when the surface of a sphere stretches (so the sphere is sc... |
13,511,203 | Why can't I assign a *Struct to an *Interface? | <p>I'm just working through the <a href="http://tour.golang.org/">Go tour</a>, and I'm confused about pointers and interfaces. Why doesn't this Go code compile?</p>
<pre><code>package main
type Interface interface {}
type Struct struct {}
func main() {
var ps *Struct
var pi *Interface
pi = ps
_, _ ... | 13,511,853 | 4 | 3 | null | 2012-11-22 10:55:50.997 UTC | 50 | 2020-01-11 10:38:59.377 UTC | null | null | null | null | 4,728 | null | 1 | 160 | go | 72,073 | <p>When you have a struct implementing an interface, a pointer to that struct implements automatically that interface too. That's why you never have <code>*SomeInterface</code> in the prototype of functions, as this wouldn't add anything to <code>SomeInterface</code>, and you don't need such a type in variable declarat... |
39,802,164 | Asp.net MVC - How to hash password | <p>How do I hash an users input(password) to database and then later read the hashed password during login? </p>
<p>I believe the solution is to hash the password upon register, where the password is saved as hashed inside db. Later upon Login, it should un-hash and compare its password with users password-input.
But... | 39,802,195 | 3 | 5 | null | 2016-10-01 01:31:40.24 UTC | 4 | 2019-07-23 07:51:27.773 UTC | 2016-10-01 01:32:52.23 UTC | null | 6,026,036 | null | 6,026,036 | null | 1 | 7 | c#|asp.net-mvc|entity-framework|hash | 45,331 | <p>You should never need to unhash a password. A <a href="https://en.wikipedia.org/wiki/Cryptographic_hash_function" rel="noreferrer">cryptographic hash function</a> is supposed to be a one-way operation. </p>
<p>(And that's precisely why it is called <em>hashing</em> and not <em>encrypting</em>. If unhashing passwo... |
39,621,880 | Is there an alternative for .bashrc for /bin/sh? | <p>I need a script which is run on startup of <code>/bin/sh</code>, similar to <code>.bashrc</code> for <code>/bin/bash</code>. Is there any way to do this?</p>
<p><strong>EDIT:</strong></p>
<p>I tried both <code>/etc/profile</code> and <code>~/.profile</code>, I wrote <code>echo 'hello world'</code> to both files. N... | 39,622,593 | 2 | 5 | null | 2016-09-21 16:27:36.95 UTC | 9 | 2016-09-21 17:24:41.287 UTC | 2016-09-21 16:46:29.187 UTC | null | 14,122 | null | 2,339,620 | null | 1 | 21 | linux|shell|sh | 17,874 | <p>In Arch, <code>/bin/sh</code> is a symlink to <code>/bin/bash</code>, which has quite a few rules about startup scripts, with special cases when called <code>sh</code> :</p>
<blockquote>
<p>If bash is invoked with the name sh, it tries to mimic the startup
behavior of historical versions of sh as closely as po... |
20,529,234 | How to select/reduce a list of dictionaries in Flask/Jinja | <p>I have a Jinja template with a list of dictionaries. Order matters. I'd like to reduce the list or lookup values based on the keys/values of the dictionaries. Here's an example:</p>
<pre><code>{%
set ordered_dicts = [
{
'id': 'foo',
'name': 'My name is Foo'
},
{
... | 24,187,114 | 6 | 2 | null | 2013-12-11 20:26:28.457 UTC | 6 | 2018-08-05 06:57:38.903 UTC | 2013-12-12 02:12:15.41 UTC | null | 174,676 | null | 174,676 | null | 1 | 21 | python|flask|jinja2 | 39,882 | <p>I've just backported <code>equalto</code> like this:</p>
<pre><code>app.jinja_env.tests['equalto'] = lambda value, other : value == other
</code></pre>
<p>After that <a href="http://jinja.pocoo.org/docs/templates/#equalto">this example from 2.8 docs</a> works:</p>
<pre><code>{{ users|selectattr("email", "equalto"... |
3,857,485 | iphone 4 sdk : detect return from background mode | <p>How can I detect that an app has just returned from "background mode"? I mean, I don't want my app to fetch data (each 60 sec) when the user press the "home button". But, I'd like to make some "special" update the first time the app is in foreground mode.</p>
<p>How can I detect these two events:</p>
<ol>
<li>app ... | 3,857,559 | 2 | 0 | null | 2010-10-04 17:10:24.067 UTC | 13 | 2017-11-26 03:44:35.76 UTC | 2012-08-14 13:33:41.287 UTC | null | 1,487,063 | null | 446,576 | null | 1 | 26 | ios4|background-foreground | 19,051 | <p>Here's how to listen for such events:</p>
<pre><code>// Register for notification when the app shuts down
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myFunc) name:UIApplicationWillTerminateNotification object:nil];
// On iOS 4.0+ only, listen for background notification
if(&UIAppl... |
3,888,569 | expected specifier-qualifier-list before | <p>I have this struct type definition:</p>
<pre><code>typedef struct {
char *key;
long canTag;
long canSet;
long allowMultiple;
confType *next;
} confType;
</code></pre>
<p>When compiling, gcc throws this error:</p>
<pre><code>conf.c:6: error: expected specifier-qualifier-list before ‘confType’
<... | 3,888,583 | 2 | 4 | null | 2010-10-08 07:40:58.957 UTC | 4 | 2010-10-08 07:52:48.493 UTC | null | null | null | null | 330,644 | null | 1 | 27 | c | 84,599 | <p>You used confType before you declared it. (for next). Instead, try this:</p>
<pre><code>typedef struct confType {
char *key;
long canTag;
long canSet;
long allowMultiple;
struct confType *next;
} confType;
</code></pre> |
3,591,867 | How to get the last n items in a PHP array as another array? | <p>How to I get an array of the last n items of another array in PHP?</p> | 3,591,872 | 2 | 0 | null | 2010-08-28 18:10:21.793 UTC | 4 | 2016-03-14 12:31:07.367 UTC | null | null | null | null | 263,929 | null | 1 | 45 | php|arrays | 24,005 | <p><code>$n</code> is equal to the number of items you want off the end.</p>
<pre><code>$arr = array_slice($old_arr, -$n);
</code></pre> |
28,473,710 | How to scroll to element with Selenium WebDriver | <p>How do I get Selenium WebDriver to scroll to a particular element to get it on the screen. I have tried a lot of different options but have had no luck.
Does this not work in the C# bindings?</p>
<p>I can make it jump to a particular location ex</p>
<pre><code>((IJavaScriptExecutor)Driver).ExecuteScript("window... | 31,241,093 | 11 | 5 | null | 2015-02-12 09:25:43.76 UTC | 5 | 2022-05-18 20:48:03.897 UTC | 2020-08-29 19:58:24.03 UTC | null | 5,231,607 | null | 2,583,014 | null | 1 | 29 | c#|selenium|selenium-webdriver|selenium-chromedriver | 116,631 | <p>Its little older question, but I believe that there is better solution than suggested above.</p>
<p>Here is original answer: <a href="https://stackoverflow.com/a/26461431/1221512">https://stackoverflow.com/a/26461431/1221512</a></p>
<p>You should use Actions class to perform scrolling to element.</p>
<pre><code>v... |
9,469,264 | C++ "cin" only reads the first word | <pre><code>#include<iostream.h>
#include<conio.h>
class String
{
char str[100];
public:
void input()
{
cout<<"Enter string :";
cin>>str;
}
void display()
{
cout<<str;
}
};
int main()
{
String s;
s.input();
s.display()... | 9,469,338 | 5 | 2 | null | 2012-02-27 17:21:13.077 UTC | 1 | 2020-03-02 15:31:20.933 UTC | 2020-03-02 15:31:20.933 UTC | null | 4,342,498 | null | 1,221,631 | null | 1 | 6 | c++|string | 44,910 | <p>Using <code>>></code> on a stream reads one word at a time. To read a whole line into a <code>char</code> array:</p>
<pre><code>cin.getline(str, sizeof str);
</code></pre>
<p>Of course, once you've learnt how to implement a string, you should use <code>std::string</code> and read it as</p>
<pre><code>getlin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.