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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5,615,436 | When the soft keyboard appears, it makes my EditText field lose focus | <p>I've got a few EditText fields in a ListView. When I tap on one of the EditText fields, the keyboard slides into view (as it should), but the EditText field I tapped loses focus. I've tried using various InputMethodManager methods to make the keyboard start out in view (in order to get around the problem rather th... | 22,470,233 | 11 | 3 | null | 2011-04-10 23:28:26.19 UTC | 29 | 2020-11-15 10:23:59.96 UTC | null | null | null | null | 539,680 | null | 1 | 60 | android|android-emulator|android-edittext | 40,093 | <p>Here is how I did it. The <code>onFocusChangeListener()</code> is called several times when you touch a <code>EditText</code> to type text into it. The sequence is:</p>
<ol>
<li>If focus was on a different view, then that view loses focus</li>
<li>The target gains focus</li>
<li>Soft keyboard pops up.</li>
<li>Th... |
23,296,282 | What rules does Pandas use to generate a view vs a copy? | <p>I'm confused about the rules Pandas uses when deciding that a selection from a dataframe is a copy of the original dataframe, or a view on the original.</p>
<p>If I have, for example,</p>
<pre><code>df = pd.DataFrame(np.random.randn(8,8), columns=list('ABCDEFGH'), index=range(1,9))
</code></pre>
<p>I understand t... | 23,296,545 | 2 | 0 | null | 2014-04-25 14:44:07.503 UTC | 91 | 2021-10-07 06:17:59.407 UTC | 2020-01-30 02:00:32.777 UTC | null | 656,912 | null | 656,912 | null | 1 | 169 | python|pandas|dataframe|indexing|chained-assignment | 56,136 | <p>Here's the rules, subsequent override:</p>
<ul>
<li><p>All operations generate a copy</p></li>
<li><p>If <code>inplace=True</code> is provided, it will modify in-place; only some operations support this</p></li>
<li><p>An indexer that sets, e.g. <code>.loc/.iloc/.iat/.at</code> will set inplace.</p></li>
<li><p>An ... |
30,805,337 | Play's execution contexts vs scala global | <p>How does the execution context from</p>
<pre><code>import scala.concurrent.ExecutionContext.Implicits.global
</code></pre>
<p>differ from Play's execution contexts:</p>
<pre><code>import play.core.Execution.Implicits.{internalContext, defaultContext}
</code></pre> | 30,806,548 | 3 | 0 | null | 2015-06-12 14:20:17.113 UTC | 15 | 2022-04-30 00:59:15.223 UTC | 2017-10-24 17:44:33.057 UTC | null | 1,255,181 | null | 722,180 | null | 1 | 35 | scala|playframework | 9,248 | <p>They are very different.</p>
<p>In Play 2.3.x and prior, <code>play.core.Execution.Implicits.internalContext</code> is a <code>ForkJoinPool</code> with fixed constraints on size, used internally by Play. You should never use it for your application code. From the docs:</p>
<blockquote>
<p>Play Internal Thread Po... |
35,016,795 | Get root password for Google Cloud Engine VM | <p>I just finished installing cPanel in a CentOS VM in Google Cloud Engine and cPanel said the default username is root and the default password is the server's root password.</p>
<pre><code>2016-01-26 12:02:52 958 ( INFO): 3. Enter the word root in the Username text box
2016-01-26 12:02:52 958 ( INFO):
2016-01-26 ... | 35,017,164 | 4 | 0 | null | 2016-01-26 14:55:09.667 UTC | 22 | 2020-12-26 23:40:29.8 UTC | 2018-10-18 10:10:36.32 UTC | null | 5,146,783 | null | 5,146,783 | null | 1 | 74 | google-app-engine|google-cloud-platform | 172,167 | <p>Figured it out. The VM's in cloud engine don't come with a root password setup by default so you'll first need to change the password using</p>
<blockquote>
<p>sudo passwd</p>
</blockquote>
<p>If you do everything correctly, it should do something like this:</p>
<pre><code>user@server[~]# sudo passwd
Changing p... |
32,780,726 | How to access DOM elements in electron? | <p>I am trying to add functionality to a button in <code>index.html</code> file is as follows:
I have a button element in <code>index.html</code></p>
<pre><code><button id="auth-button">Authorize</button>
</code></pre>
<p>In <code>main.js</code> of the app, I have</p>
<pre><code>require('crash-reporter')... | 32,781,187 | 4 | 2 | null | 2015-09-25 11:02:09.71 UTC | 19 | 2022-01-27 13:47:16.68 UTC | 2016-04-03 16:19:27.127 UTC | null | 396,043 | null | 3,079,419 | null | 1 | 88 | javascript|dom|electron | 90,128 | <p>DOM can <em>not</em> be accessed in the main process, only in the renderer that it belongs to.</p>
<p>There is an <code>ipc</code> module, available on <a href="http://electron.atom.io/docs/v0.37.8/api/ipc-main/">main process</a> as well as the <a href="http://electron.atom.io/docs/v0.37.8/api/ipc-renderer/">render... |
11,087,787 | How do I convert a given number into time format HH:MM:SS in VBA? | <p>I received a list of numbers in Custom format (Type: 000000) that represent military time. It always contain 6 digits, and leading zeros are used when necessary. For example:</p>
<ul>
<li>123456 becomes 12:34:56 (pm) </li>
<li>000321 becomes 00:03:21 (am) </li>
<li>142321 becomes 14:23:21 (pm)</li>
</ul>
<p>How... | 11,088,253 | 3 | 4 | null | 2012-06-18 17:16:33.973 UTC | null | 2015-09-16 18:49:24.023 UTC | 2012-06-18 17:39:45.653 UTC | null | 867,420 | null | 867,420 | null | 1 | 1 | excel|vba|datetime | 80,014 | <p>assuming its a real integer,and not text:</p>
<p><code>=TIME(INT(A1/10000),INT(MOD(A1,10000)/100),MOD(A1,100))</code></p>
<p>if it is text, then use</p>
<p><code>=TIME(VALUE(LEFT(A1,2)),VALUE(MID(A1,3,2)),VALUE(RIGHT(A1,2)))</code></p>
<p>format the result however you want.</p>
<p>As a VBA Function: Integer:</p... |
9,581,268 | How can I redirect a php page to another php page? | <blockquote>
<p><strong>Possible Duplicate:</strong><br />
<a href="https://stackoverflow.com/questions/4864522/how-to-redirect-users-to-another-page">How to redirect users to another page?</a></p>
</blockquote>
<p>I'm a beginner in the programming field....I want to redirect a php page to another one..How is it possi... | 9,581,301 | 7 | 0 | null | 2012-03-06 09:50:24.027 UTC | 2 | 2020-12-19 19:56:35.707 UTC | 2020-12-19 19:56:35.707 UTC | null | 1,783,163 | null | 1,251,770 | null | 1 | 8 | php | 115,748 | <pre><code><?php
header("Location: your url");
exit;
?>
</code></pre> |
9,303,711 | How do I make ctest run a program with valgrind without dart? | <p>I want to write a CMakeLists.txt so that I can run my tests normally or with valgrind. I have seen much on integrating ctest with valgrind but all with the assumption that you want to set up a server to submit test results to a dart dashboard. I just want to run the tests on my machine and see the results on the com... | 9,843,594 | 4 | 0 | null | 2012-02-16 00:15:58.21 UTC | 10 | 2020-02-29 11:51:16.91 UTC | null | null | null | null | 679,354 | null | 1 | 28 | cmake|valgrind | 15,798 | <p>I use valgrind for my memory check. To configure valgrind, I define the following variables in my build system:</p>
<pre><code>find_program( MEMORYCHECK_COMMAND valgrind )
set( MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" )
</code></pre>
<p>Also, in there is my valgrind suppression file:</... |
9,547,160 | How to measure time of a statement in scala console? | <p>I'm using Scala to measure performance of regex engine of java. The regexp below executes in around 3 seconds but yet I'm not able to measure it using System.currentTimeMillis. (the last expression returns 0)</p>
<pre><code>scala> val b = System.currentTimeMillis; val v = new Regex("(x+)+y").findAllIn("x"*25); b... | 9,547,446 | 6 | 0 | null | 2012-03-03 15:12:34.17 UTC | 16 | 2014-10-10 08:34:29.687 UTC | 2012-03-03 15:46:34.883 UTC | null | 209,605 | null | 80,869 | null | 1 | 32 | regex|scala | 27,389 | <p>The unexplained duration comes from the REPL calling <code>toString</code> on the iterator returned from <code>findAllIn</code>. This in turn calls <a href="https://github.com/scala/scala/blob/master/src/library/scala/util/matching/Regex.scala#L512" rel="noreferrer"><code>Regex.MatchIterator#hasNext</code></a>, whic... |
9,110,478 | How to find the hash of branch in Git? | <p>Given a local / remote branch name, how could I get the hash of the commit that this branch points to?</p> | 9,110,527 | 4 | 0 | null | 2012-02-02 10:12:05.853 UTC | 13 | 2022-05-07 12:17:11.777 UTC | null | null | null | null | 247,243 | null | 1 | 124 | git | 96,506 | <p>The command <a href="https://git-scm.com/docs/git-rev-parse" rel="noreferrer"><code>git rev-parse</code></a> is your friend, e.g.:</p>
<pre><code>$ git rev-parse development
17f2303133734f4b9a9aacfe52209e04ec11aff4
</code></pre>
<p>... or for a remote-tracking branch:</p>
<pre><code>$ git rev-parse origin/master
... |
30,831,037 | Situations where Cell or RefCell is the best choice | <p>When would you be required to use <a href="http://doc.rust-lang.org/std/cell/index.html" rel="noreferrer">Cell or RefCell</a>? It seems like there are many other type choices that would be suitable in place of these, and the documentation warns that using <code>RefCell</code> is a bit of a "last resort".</p>
<p>Is ... | 30,831,983 | 3 | 2 | null | 2015-06-14 15:16:13.313 UTC | 5 | 2018-12-18 17:50:55.79 UTC | 2018-12-18 17:50:55.79 UTC | null | 493,729 | null | 97,964 | null | 1 | 32 | rust|interior-mutability | 11,660 | <p>It is not entirely correct to ask when <code>Cell</code> or <code>RefCell</code> should be used over <code>Box</code> and <code>Rc</code> because these types solve different problems. Indeed, more often than not <code>RefCell</code> is used <em>together</em> with <code>Rc</code> in order to provide mutability with s... |
22,667,104 | How to populate javascript variable with JSON from ViewBag? | <p>I have this Index action:</p>
<pre><code>public ActionResult Index()
{
var repo = (YammerClient) TempData["Repo"];
var msgCol = repo.GetMessages();
ViewBag.User = repo.GetUserInfo();
return View(msgCol.messages);
}
</code></pre>
<p>GetMessages returns a list of POCO messages and GetUserInfo ret... | 22,667,395 | 4 | 1 | null | 2014-03-26 16:18:59.07 UTC | 7 | 2020-08-24 20:45:34.823 UTC | 2015-03-31 20:49:29.183 UTC | null | 209,259 | null | 105,937 | null | 1 | 27 | javascript|asp.net|asp.net-mvc|json|viewbag | 47,713 | <p>In View you can do something like this </p>
<pre><code>@{
var jss = new System.Web.Script.Serialization.JavaScriptSerializer();
var userInfoJson = jss.Serialize(ViewBag.User);
}
</code></pre>
<p>in javascript you can use it as </p>
<pre><code><script>
//use Json.parse to convert string... |
7,242,226 | Get members of Active Directory Group and check if they are enabled or disabled | <p>What is the fastest way to get a list of all members/users in a given AD group and determine whether or not a user is enabled (or disabled)?</p>
<p>We are potentially talking about 20K users, so I would like to avoid hitting the AD for each individual user.</p> | 7,242,782 | 2 | 1 | null | 2011-08-30 11:08:37.03 UTC | 12 | 2011-08-30 16:30:09.947 UTC | null | null | null | null | 154,991 | null | 1 | 27 | c#|active-directory | 72,861 | <p>If you're on .NET 3.5 and up, you should check out the <code>System.DirectoryServices.AccountManagement</code> (S.DS.AM) namespace. Read all about it here:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/magazine/cc135979.aspx">Managing Directory Security Principals in the .NET Framework 3.5</a></li>
<li><a h... |
31,265,245 | Extracting 3D coordinates given 2D image points, depth map and camera calibration matrices | <p>I have a set of <code>2D image</code> keypoints that are outputted from the <code>OpenCV FAST</code> corner detection function. Using an <code>Asus Xtion I</code> also have a time-synchronised depth map with all camera calibration parameters known. Using this information I would like to extract a set of <code>3D</co... | 31,266,627 | 1 | 4 | null | 2015-07-07 09:49:45.513 UTC | 11 | 2020-07-08 13:25:39.013 UTC | 2015-07-07 09:59:18.433 UTC | null | 648,889 | null | 648,889 | null | 1 | 13 | c++|opencv|3d|asus-xtion | 23,570 | <p>Nicolas Burrus has created a great tutorial for Depth Sensors like Kinect.</p>
<p><a href="http://nicolas.burrus.name/index.php/Research/KinectCalibration" rel="noreferrer">http://nicolas.burrus.name/index.php/Research/KinectCalibration</a></p>
<p>I'll copy & paste the most important parts:</p>
<blockquote>
<p>M... |
13,730,484 | SELECT multiple rows from single column into single row | <p>I want to write an SQL Server query that will retrieve data from the following example tables:</p>
<pre><code>Table: Person
ID Name
-- ----
1 Bill
2 Bob
3 Jim
Table: Skill
ID SkillName
-- -----
1 Carpentry
2 Telepathy
3 Navigation
4 Opera
5 Karate... | 13,731,188 | 3 | 5 | null | 2012-12-05 18:59:57.023 UTC | 3 | 2013-07-30 09:45:00.843 UTC | 2012-12-05 19:43:49.237 UTC | null | 895,755 | null | 895,755 | null | 1 | 2 | sql|sql-server | 47,506 | <p>You would use <code>FOR XML PATH</code> for this:</p>
<pre><code>select p.name,
Stuff((SELECT ', ' + s.skillName
FROM skilllink l
left join skill s
on l.skillid = s.id
where p.id = l.personid
FOR XML PATH('')),1,1,'') Skills
from person p
</code></pre>
<p>See <a h... |
35,502,450 | lodash _.find all matches | <p>I have simple function to return me object which meets my criteria.</p>
<p>Code looks like:</p>
<pre><code> var res = _.find($state.get(), function(i) {
var match = i.name.match(re);
return match &&
(!i.restrict || i.restrict($rootScope.user));
});
</code></pre>
<p>How ... | 35,502,881 | 3 | 1 | null | 2016-02-19 10:02:21.33 UTC | 4 | 2019-06-24 09:06:24.707 UTC | 2019-06-24 09:06:24.707 UTC | null | 2,584,910 | null | 2,584,910 | null | 1 | 63 | javascript|lodash | 79,959 | <p>Just use <code>_.filter</code> - it returns all matched items.</p>
<p><a href="https://lodash.com/docs/4.17.4#filter" rel="noreferrer">_.filter</a></p>
<blockquote>
<p>Iterates over elements of collection, returning an array of all elements predicate returns truthy for. The predicate is invoked with three argume... |
1,969,049 | C# P/Invoke: Marshalling structures containing function pointers | <p>Sorry for the verbose introduction that follows. I need insight from someone knowing P/Invoke internals better than I do.</p>
<p>Here is how I'm marshalling structures containing function pointers from C to C#. I would like to know whether it's the cleanest and/or most efficient way of doing it.</p>
<p>I'm interfaci... | 1,971,454 | 3 | 0 | null | 2009-12-28 11:32:02.017 UTC | 10 | 2010-01-18 18:14:11.48 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 216,063 | null | 1 | 16 | c#|pinvoke|marshalling|structure|function-pointers | 10,819 | <p>I don't know that answer to your question 1. I'd expect that <code>Marshal.PtrToStructure()</code> is implemented in terms of the other Marshal primitives, so it would be more efficient to just use the single <code>Marshal.GetDelegateForFunctionPointer</code>. But that's just a guess - worth what you paid for it.<... |
1,998,771 | In oracle, how do I change my session to display UTF8? | <p>I can't figure out Oracle's encryptic syntax for the life of me. This is Oracle 10g</p>
<p>My session's NLS_LANGUAGE is currently defaulting to AMERICAN.
I need to be able to display UTF8 characters.</p>
<p>Below are some of my attempts, all incorrect:</p>
<pre><code>ALTER SESSION SET NLS_LANGUAGE='UTF8'
ALTER S... | 2,000,243 | 3 | 2 | null | 2010-01-04 10:44:24.44 UTC | 5 | 2015-02-15 22:26:02.717 UTC | 2010-01-06 09:26:22.723 UTC | null | 20,938 | null | 39,529 | null | 1 | 18 | oracle|utf-8 | 120,357 | <p>The character set is part of the locale, which is determined by the value of <code>NLS_LANG</code>. As <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28298/ch3globenv.htm#i1006330" rel="noreferrer" title="Globalization Support Guide">the documentation makes clear</a> this is <em>an operating syst... |
1,450,582 | Classical Vs prototypal inheritance | <p>After reading about both, I just have curiosity, how programming community uses this?
In what situation which?</p> | 1,450,598 | 3 | 0 | null | 2009-09-20 08:21:21.363 UTC | 15 | 2013-11-08 23:13:02.423 UTC | null | null | null | null | 147,695 | null | 1 | 20 | javascript|oop | 8,582 | <p>Prototype-based inheritance is more flexible. Any existing object can become a class from which additional objects will be spawned. This is handy where your objects offer several sets of services and/or they undergo a lot of state transformation before your program arrives at the point where the inheritance is neede... |
2,013,793 | Web Services vs EJB vs RMI, advantages and disadvantages? | <p>My web server would be overloaded quickly if all the work were done there. I'm going to stand up a second server behind it, to process data.</p>
<p>What's the advantage of EJB over RMI, or vice versa? </p>
<p>What about web services (SOAP, REST)?</p> | 2,293,422 | 3 | 0 | 2010-01-06 15:03:32.197 UTC | 2010-01-06 15:03:32.197 UTC | 48 | 2015-11-28 19:09:22.073 UTC | null | null | null | null | 182,690 | null | 1 | 57 | java|web-services|ejb|distributed|rmi | 71,528 | <p>EJBs are built on top of RMI. Both imply Java clients and beans. If your clients need to be written in something else (e.g., .NET, PHP, etc.) go with web services or something else that speaks a platform-agnostic wire protocol, like HTTP or XML over HTTP or SOAP.</p>
<p>If you choose RMI, you don't need a Java EE... |
1,919,982 | RegEx: Smallest possible match or nongreedy match | <p>How do I tell RegEx (.NET version) to get the smallest valid match instead of the largest?</p> | 1,919,995 | 3 | 0 | null | 2009-12-17 07:12:16.96 UTC | 25 | 2020-06-09 19:52:21.917 UTC | 2020-02-07 13:01:25.133 UTC | null | 1,243,762 | null | 5,274 | null | 1 | 156 | .net|regex|regex-greedy|non-greedy | 102,741 | <p>For a regular expression like <code>.*</code> or <code>.+</code>, append a question mark (<code>.*?</code> or <code>.+?</code>) to match as few characters as possible. To optionally match a section <code>(?:blah)?</code> but without matching unless absolutely necessary, use something like <code>(?:blah){0,1}?</code>... |
8,952,819 | How to choose between Factory method pattern and Abstract factory pattern | <p>I know similar questions were asked before. I've been reading a lot about this during the last couple of days and I think I can now understand the differences in terms of design and code flow. What bothers me it's that it seems like both pattern can solve the very same set of problems without a real reason to choose... | 8,960,529 | 2 | 1 | null | 2012-01-21 12:05:36.103 UTC | 11 | 2013-12-04 08:19:19.26 UTC | 2013-04-18 18:29:24.063 UTC | null | 661,933 | user1047100 | null | null | 1 | 15 | c#|design-patterns|factory-pattern | 5,989 | <p>First, 2 quotes from the GoF design patterns book:</p>
<blockquote>
<p>"Abstract Factory is often implemented with factory methods."</p>
<p>"Factory Methods are often called by template methods."</p>
</blockquote>
<p>So it's not a question of choosing between Factory Methods and Abstract Factorie... |
19,774,778 | When is it necessary to use the flag -stdlib=libstdc++? | <p>When is it necessary to use use the flag <code>-stdlib=libstdc++</code> for the compiler and linker when compiling with gcc?</p>
<p>Does the compiler automatically use libstdc++? </p>
<p>I am using gcc4.8.2 on Ubuntu 13.10 and I would like to use the c++11 standard. I already pass <code>-std=c++11</code> to the c... | 19,774,902 | 3 | 1 | null | 2013-11-04 18:43:51.987 UTC | 25 | 2021-12-07 22:24:54.79 UTC | 2020-01-21 18:47:31.02 UTC | null | 2,565,958 | null | 2,120,821 | null | 1 | 79 | c++|gcc|c++11|std|libstdc++ | 110,590 | <p><strong>On Linux</strong>: In general, all commonly available linux distributions will use libstdc++ by default, and all modern versions of GCC come with a libstdc++ that supports C++11. If you want to compile c++11 code here, use one of:</p>
<ul>
<li><code>g++ -std=c++11 input.cxx -o a.out</code> (usually GNU compi... |
716,748 | Reverse IP Domain Check? | <p>There is a website which you can query with a domain and it will return a list of all the websites hosted on that IP. I remember there being a method in C# that was something like ReturnAddresses or something of that sort. Does anyone have any idea how this is done? Quering a hostname or IP and having returned a lis... | 716,753 | 4 | 0 | null | 2009-04-04 08:08:43.997 UTC | 10 | 2022-05-07 19:35:29.893 UTC | 2012-07-29 00:34:07.437 UTC | Alnitak | 41,071 | Arnold Boshae | null | null | 1 | 12 | c#|dns | 22,131 | <p>After reading the comments, bobince is definitely right and these 2 should be used in tandem with each other. For best results you should use the reverse DNS lookup here as well as to use the passive DNS replication.</p>
<pre><code>string IpAddressString = "208.5.42.49"; //eggheadcafe
try
{
IPAddress hostIPAd... |
1,157,814 | How to access original activity's views from spawned background service | <p>I have an activity called A, and on the selection of menu item 0, it spawns service B, which starts a runnable C in a new thread. I have a TextView in activity A, which I want to access in thread C. </p>
<p>I've tried making the TextView a public static field, but that generates the following error:</p>
<pre><co... | 1,158,269 | 4 | 0 | null | 2009-07-21 07:52:45.863 UTC | 12 | 2012-05-15 21:52:38.613 UTC | null | null | null | null | 122,961 | null | 1 | 29 | android|user-interface|pass-by-reference|textview | 36,531 | <p>You have to update widgets from the GUI thread, aka 'the thread that created the view hierarchy'. The standard way to do this is via <a href="http://developer.android.com/reference/android/os/Handler.html" rel="nofollow noreferrer"><code>Handler</code></a>s and an example of how to use handlers can be found in the <... |
48,128,471 | Insert array values into database in laravel | <p>I have 8 different questions that are coming from the database randomly.</p>
<p>Now I want to insert the <code>question_id</code>, <code>user_id</code> and <code>en_answer</code> into <code>en_answers</code> table. </p>
<p>Data was inserted, but here is some error like - the first one is, it's inserting only one-r... | 48,128,541 | 2 | 2 | null | 2018-01-06 14:43:53.44 UTC | 5 | 2021-12-30 09:16:36.04 UTC | 2020-02-16 12:18:02.08 UTC | null | 7,014,431 | null | 7,014,431 | null | 1 | 12 | php|mysql|arrays|laravel|multidimensional-array | 64,590 | <p>You're inserting into DB just one answer, the last one. Also, you can prepare the data and insert all the answers with just one query:</p>
<pre><code>public function store(Request $request)
{
for ($i = 1; $i < count($request->en_answer); $i++) {
$answers[] = [
'user_id' => Sentinel:... |
30,521,224 | Javascript convert PascalCase to underscore_case/snake_case | <p>How can I convert <code>PascalCase</code> string into <code>underscore_case/snake_case</code> string? I need to convert dots into underscores as well.</p>
<p>eg. convert</p>
<pre><code>TypeOfData.AlphaBeta
</code></pre>
<p>into</p>
<pre><code>type_of_data_alpha_beta
</code></pre> | 30,521,308 | 11 | 1 | null | 2015-05-29 04:37:53.073 UTC | 11 | 2022-07-20 07:46:19.207 UTC | 2021-08-23 05:43:31.657 UTC | null | 4,480,993 | null | 4,646,070 | null | 1 | 85 | javascript|string|case-conversion | 61,407 | <p>You could try the below steps.</p>
<ul>
<li><p>Capture all the uppercase letters and also match the preceding optional dot character.</p></li>
<li><p>Then convert the captured uppercase letters to lowercase and then return back to replace function with an <code>_</code> as preceding character. This will be achieved... |
20,515,554 | Colorize Voronoi Diagram | <p>I'm trying to colorize a Voronoi Diagram created using <a href="http://docs.scipy.org/doc/scipy-dev/reference/generated/scipy.spatial.Voronoi.html" rel="noreferrer"><code>scipy.spatial.Voronoi</code></a>. Here's my code:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Vor... | 20,678,647 | 3 | 1 | null | 2013-12-11 09:39:56.817 UTC | 40 | 2019-07-17 10:49:00.677 UTC | 2016-06-27 12:45:25.05 UTC | null | -1 | null | 1,025,391 | null | 1 | 68 | python|matplotlib|scipy|visualization|voronoi | 39,695 | <p>The Voronoi data structure contains all the necessary information to construct positions for the "points at infinity". Qhull also reports them simply as <code>-1</code> indices, so Scipy doesn't compute them for you.</p>
<p><a href="https://gist.github.com/pv/8036995">https://gist.github.com/pv/8036995</a></p>
<p>... |
20,609,118 | HttpClient with BaseAddress | <p>I have a problem calling a <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.webhttpbinding%28v=vs.110%29.aspx" rel="noreferrer">webHttpBinding</a> WCF end point using <a href="http://msdn.microsoft.com/en-us/library/system.net.http.httpclient%28v=vs.110%29.aspx" rel="noreferrer">HttpClient</a> an... | 20,609,275 | 1 | 1 | null | 2013-12-16 10:54:23.487 UTC | 2 | 2013-12-26 21:26:37.867 UTC | 2013-12-26 21:26:37.867 UTC | null | 6,819 | null | 713,228 | null | 1 | 40 | c#|.net|wcf|dotnet-httpclient|webhttpbinding | 29,763 | <p>In the <code>BaseAddress</code>, just include the final slash: <code>https://localhost:44302/AndonService.svc/</code>. If you don't, the final part of the path is discarded, because it's not considered to be a "directory".</p>
<p>This sample code illustrates the difference:</p>
<pre><code>// No final slash
var bas... |
46,727,850 | Navigation is blocked error in Chrome 61+ on Android | <p>I'm building a login page that, upon submitting and validation of the user credentials, opens up a native mobile application. Up till last week, I had this working cross mobile OS by using a custom scheme URI, something like:</p>
<pre><code>function onLoginCallback() {
const redirectUri = 'customscheme:/action?... | 58,145,987 | 2 | 1 | null | 2017-10-13 10:30:55.8 UTC | 2 | 2020-11-02 15:59:03.44 UTC | 2018-03-13 08:32:47.177 UTC | null | 466,761 | null | 466,761 | null | 1 | 37 | javascript|android|google-chrome|redirect|appauth | 7,138 | <p>We ended up implementing our login and registration forms with a <a href="https://en.wikipedia.org/wiki/Post/Redirect/Get" rel="nofollow noreferrer">classic post-redirect-get</a> pattern.</p>
<p>The server responds with a <code>302</code> to the custom URI scheme. Because in this setup there's no asynchronous execu... |
32,233,489 | Does bootstrap have builtin padding and margin classes? | <p>Does Bootstrap have built-in padding and margin classes like <code>pad-10</code>, <code>mar-left-10</code> or I have to add my own custom classes? For example, similar to the ones <a href="http://seantheme.com/color-admin-v1.8/admin/html/helper_css.html" rel="noreferrer">here</a> at padding and margin tabs.</p> | 43,359,968 | 11 | 3 | null | 2015-08-26 17:56:47.997 UTC | 19 | 2022-08-03 09:03:36.577 UTC | 2018-02-09 17:10:38.34 UTC | null | 2,074,605 | null | 1,430,517 | null | 1 | 79 | css|twitter-bootstrap|margin|padding | 261,733 | <p>There are built in classes, namely:</p>
<pre><code>.padding-xs { padding: .25em; }
.padding-sm { padding: .5em; }
.padding-md { padding: 1em; }
.padding-lg { padding: 1.5em; }
.padding-xl { padding: 3em; }
.padding-x-xs { padding: .25em 0; }
.padding-x-sm { padding: .5em 0; }
.padding-x-md { padding: 1em 0; }
.pad... |
25,070,176 | Hyperlink changes from # to %20-%20 when clicked in Excel | <p>I've got a hyperlink in an Excel 2013 sheet that links to an internal website. When I right click and select "edit hyperlink", I see this in the address bar (which is correct):</p>
<p><code>https://myserver.company.com/home/default.html#article?id=1203291003</code></p>
<p>However, when I left click, middle click,... | 25,070,314 | 15 | 3 | null | 2014-07-31 22:47:30.307 UTC | 3 | 2019-08-06 14:41:03.283 UTC | 2016-08-23 19:33:50.733 UTC | null | 2,370,483 | null | 1,330,428 | null | 1 | 39 | excel | 86,111 | <p>This is a <a href="http://support.microsoft.com/kb/202261" rel="noreferrer">known issue</a> with MS Excel. Basically, the hash/pound (<em><code>#</code></em>) sign is a valid character to use in a file name but is <strong>not accepted in hyperlinks in Office documents</strong>. The conversion to <code>%20-%20</code>... |
31,610,869 | Null Conditional Operators | <p>C# 6.0 has just been released and has a new nice little feature that I'd really like to use in JavaScript. They're called <a href="https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6#null-conditional-operators">Null-conditional operators</a>. These use a <code>?.</code> or <code>?[]</code> syntax.<... | 47,538,150 | 4 | 11 | null | 2015-07-24 12:44:46.53 UTC | 6 | 2021-11-17 03:37:36.94 UTC | 2017-11-28 18:38:56.55 UTC | null | 1,159,478 | null | 21,061 | null | 1 | 70 | javascript | 22,841 | <p>Called "<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining" rel="nofollow noreferrer">optional chaining</a>", it's currently a <a href="https://github.com/tc39/proposal-optional-chaining" rel="nofollow noreferrer" title="TC39 proposal in Stage 3">TC39 pro... |
39,049,188 | How to add Strings on X Axis in iOS-charts? | <p>With the new release i had some troubles to create some graphs the previous code was:</p>
<pre><code>func setChart(dataPoints: [String], values: [Double]) {
var dataEntries: [BarChartDataEntry] = []
for i in 0..<dataPoints.count {
let dataEntry = BarChartDataEntry(value: values[i], xIndex: i)
... | 39,149,070 | 6 | 4 | null | 2016-08-20 00:00:09.303 UTC | 18 | 2020-02-26 09:26:12.153 UTC | 2016-12-13 12:17:35.353 UTC | null | 5,426,687 | null | 6,736,783 | null | 1 | 28 | ios|swift|ios-charts | 30,855 | <p>I found the solution, maybe another one can solve this problem in a better way, without create a new class, well this is what I found:</p>
<p>First you nedd to create a new class, which will be your formatter class and add the IAxisValueFormater interface, then you use the method stringForValue to customize the new... |
7,367,449 | Google API : How to authenticate without redirection? | <p>We want to use Google Doc API to generate Document (In our own business account) when our end users do some actions on our site.</p>
<p>The problem is that we've tried to implement the OAuth 2.0 protocol, as suggested in the v3.0 protocol documentation. The apiClient::authentication method do a redirection. This is... | 7,477,112 | 3 | 2 | null | 2011-09-09 21:09:01.93 UTC | 9 | 2018-12-14 14:52:10.44 UTC | 2013-12-29 02:12:07.063 UTC | null | 881,229 | null | 613,365 | null | 1 | 14 | oauth|oauth-2.0|google-docs-api | 26,109 | <p>What you describe is not how 3-legged OAuth was designed to be used.</p>
<p>3-legged OAuth is all about <em>delegated</em> authentication where a user (who knows his password) can grant limited and revokable resource access to application. That application never sees the user's password. There is a bunch of work in... |
7,374,562 | How do I add a .click() event to an image? | <p>I have a script that places an image based on a mouse click thanks to <a href="https://stackoverflow.com/users/701879/jose-faeti">Jose Faeti</a>. Now I need help adding a .click() event to the code below so that when a user clicks the image it performs the function shown in the script.</p>
<pre><code><img src="h... | 7,374,620 | 4 | 1 | null | 2011-09-10 20:39:41.943 UTC | 6 | 2022-03-24 17:08:45.353 UTC | 2017-05-23 12:34:29.25 UTC | null | -1 | null | 766,789 | null | 1 | 30 | javascript|events|mouseevent | 252,551 | <p>First of all, this line</p>
<pre><code><img src="http://soulsnatcher.bplaced.net/LDRYh.jpg" alt="unfinished bingo card" />.click()
</code></pre>
<p>You're mixing HTML and JavaScript. It doesn't work like that. Get rid of the <code>.click()</code> there.</p>
<p>If you read the JavaScript you've got there, <c... |
7,459,818 | How to get the position of a key within an array | <p>Ok, so I need to grab the position of 'blah' within this array (position will not always be the same). For example:</p>
<pre><code>$array = (
'a' => $some_content,
'b' => $more_content,
'c' => array($content),
'blah' => array($stuff),
'd' => $info,
'e' => $more_info,
);
</... | 7,459,823 | 4 | 0 | null | 2011-09-18 06:15:03.707 UTC | 6 | 2011-09-18 07:40:00.447 UTC | null | null | null | null | 304,853 | null | 1 | 43 | php|arrays|array-key | 62,818 | <pre><code>$i = array_search('blah', array_keys($array));
</code></pre> |
24,108,014 | ASP.NET MVC 5 Form Validation | <p>I am new to ASP.NET MVC and using version 5. I created a form that is in the layout, and I cannot cannot get it to show validation errors on the view. It will post to the action correctly, and if the model is valid, it will execute. If the model is invalid I will get the following error. </p>
<p>I am hoping someone... | 24,108,304 | 1 | 1 | null | 2014-06-08 16:02:35.933 UTC | 2 | 2014-06-08 17:31:57.093 UTC | null | null | null | null | 53,388 | null | 1 | 8 | c#|asp.net|asp.net-mvc|validation|asp.net-mvc-5 | 44,546 | <p>There is one error in your code, I didn't notice first. In the get method you are using - </p>
<pre><code>return View();
</code></pre>
<p>Which means your view does not allow parameter but when there is an error you are using - </p>
<pre><code>return View(lead);
</code></pre>
<p>In this case MVC is looking for t... |
2,256,012 | Unit testing paperclip uploads with Rspec (Rails) | <p>Total Rspec noob here. Writing my first tests tonight. </p>
<p>I've got a model called Image. Using paperclip I attach a file called photo. Standard stuff. I've run the paperclip generator and everything works fine in production and test modes. </p>
<p>Now I have a spec file called image.rb and it looks like... | 2,257,948 | 4 | 0 | null | 2010-02-13 00:35:54.433 UTC | 12 | 2014-07-25 16:33:05.283 UTC | null | null | null | null | 227,863 | null | 1 | 24 | ruby-on-rails|unit-testing|rspec|paperclip | 26,891 | <p>This should work with Rails 2.X:</p>
<pre><code>Image.new :photo => File.new(RAILS_ROOT + '/spec/fixtures/images/rails.png')
</code></pre>
<p>As of Rails 3, <code>RAILS_ROOT</code> is no longer used, instead you should use <code>Rails.root</code>.</p>
<p>This should work with Rails 3:</p>
<pre><code>Image.new... |
1,953,239 | Search an Oracle database for tables with specific column names? | <p>We have a large Oracle database with many tables. Is there a way I can query or search to find if there are any tables with certain column names?</p>
<p>IE show me all tables that have the columns: <code>id, fname, lname, address</code></p>
<p>Detail I forgot to add: I need to be able to search through different ... | 1,953,311 | 4 | 0 | null | 2009-12-23 14:54:43.077 UTC | 48 | 2016-03-15 07:52:29.05 UTC | 2015-09-11 20:27:29.22 UTC | null | 332,936 | null | 168,646 | null | 1 | 122 | sql|oracle | 328,726 | <p>To find all tables with a particular column:</p>
<pre><code>select owner, table_name from all_tab_columns where column_name = 'ID';
</code></pre>
<p>To find tables that have any or all of the 4 columns:</p>
<pre><code>select owner, table_name, column_name
from all_tab_columns
where column_name in ('ID', 'FNAME', ... |
43,022,843 | Nvidia NVML Driver/library version mismatch | <p>When I run <code>nvidia-smi</code>, I get the following message:</p>
<blockquote>
<p>Failed to initialize NVML: Driver/library version mismatch</p>
</blockquote>
<p>An hour ago I received the same message and uninstalled my CUDA library and I was able to run <code>nvidia-smi</code>, getting the following result:</p>... | 43,023,000 | 19 | 6 | null | 2017-03-25 22:47:00.43 UTC | 113 | 2022-04-23 01:03:47.083 UTC | 2022-04-22 23:50:42.163 UTC | null | 63,550 | null | 4,189,580 | null | 1 | 468 | cuda|driver|gpu|nvidia | 522,150 | <p>Surprise surprise, rebooting solved the issue (I thought I had already tried that).</p>
<p>The solution <a href="https://stackoverflow.com/questions/43022843/nvidia-nvml-driver-library-version-mismatch#comment73133147_43022843">Robert Crovella mentioned</a> in the comments may also be useful to someone else, since i... |
42,769,106 | Can I turn off the Node.js server process associated with Visual Studio 2017? | <p>I'm working on an ASP.NET application in Visual Studio 2017, and I'm noticing a <em>"Node.js: Server-side JavaScript"</em> process running at 1.3 GB to 1.8 GB of memory. My <a href="https://en.wikipedia.org/wiki/Internet_Information_Services" rel="nofollow noreferrer">IIS</a> worker process is the normal s... | 42,972,043 | 9 | 15 | null | 2017-03-13 16:49:17.283 UTC | 41 | 2022-09-16 11:40:50.92 UTC | 2022-09-16 11:10:20.423 UTC | null | 63,550 | null | 324,516 | null | 1 | 142 | node.js|asp.net-mvc|visual-studio-2017 | 35,511 | <p>In menu <em>Tools</em> → <em>Options</em> → <em>Text Editor</em> → <em>JavaScript/TypeScript</em> → <em>Language Service...</em>:</p>
<p>Uncheck 'Enable the new JavaScript language service'.</p>
<p>Restart Visual Studio</p>
<p>This appears to prevent the Node.js process from starting.</p> |
10,290,156 | awaiting on an observable | <p>So in the sad days of C# 4.0, I created the following "WorkflowExecutor" class that allowed asynchronous workflows in the GUI thread by hacking into IEnumerable's "yield return" continuations to wait for observables. So the following code would, at button1Click, just start a simple workflow that updates the text, w... | 10,290,943 | 2 | 2 | null | 2012-04-24 00:24:53.883 UTC | 16 | 2012-05-24 17:08:21.807 UTC | 2012-04-24 00:49:16.297 UTC | null | 171,121 | null | 171,121 | null | 1 | 26 | c#|system.reactive|async-await|.net-4.5|c#-5.0 | 19,652 | <p>As you noticed, Task is very much a one-time use thing, as opposed to Observable's "stream of events". A good way of thinking of this (IMHO) is the 2x2 chart on the <a href="http://blogs.msdn.com/b/rxteam/archive/2012/03/12/reactive-extensions-v2-0-beta-available-now.aspx" rel="noreferrer">Rx team's post about 2.0 ... |
10,431,579 | Permanently configuring LLDB (in Xcode 4.3.2) not to stop on signals | <p>I'm trying to get LLDB (running in Xcode 4.3.2 with an OS X application) to not stop on certain signals. If I enter</p>
<p><code>process handle SIGUSR2 -n true -p true -s false</code></p>
<p>on the debugging console it works fine and LLDB no longer stops on SIGUSR2.</p>
<p>However, if I put</p>
<p><code>command ... | 10,456,557 | 1 | 2 | null | 2012-05-03 12:40:19.013 UTC | 24 | 2020-09-22 11:09:05.89 UTC | 2020-09-22 11:09:05.89 UTC | null | 1,498,329 | null | 407,713 | null | 1 | 44 | xcode|macos|signals|lldb | 12,543 | <p>In case anyone else ever has this question, I finally solved it by adding a breakpoint in <code>NSApplicationMain()</code> (for plain C programs, <code>main()</code> would of course work as well). </p>
<p>I set the breakpoint action to <code>process handle SIGUSR2 -n true -p true -s false</code>, and enabled the "A... |
7,057,450 | Why does python use unconventional triple-quotation marks for comments? | <p>Why didn't python just use the traditional style of comments like C/C++/Java uses:</p>
<pre><code>/**
* Comment lines
* More comment lines
*/
// line comments
// line comments
//
</code></pre>
<p>Is there a specific reason for this or is it just arbitrary?</p> | 7,057,488 | 5 | 6 | null | 2011-08-14 14:44:02.973 UTC | 18 | 2019-10-04 20:57:17.177 UTC | 2017-11-22 00:24:10.827 UTC | null | 475,229 | null | 814,849 | null | 1 | 39 | python|coding-style|comments | 64,937 | <p>Python doesn't use triple quotation marks for comments. Comments use the hash (a.k.a. pound) character:</p>
<pre><code># this is a comment
</code></pre>
<p>The triple quote thing is a <a href="http://www.python.org/dev/peps/pep-0257/" rel="noreferrer">doc string</a>, and, unlike a comment, is actually available as... |
13,866,850 | SQL Server - calculate elapsed time between two datetime stamps in HH:MM:SS format | <p>I have a SQL Server table that has a "Time" column. The table is a log table the houses status messages and timestamps for each message. The log table is inserted into via a batch file. There is an ID column that groups rows together. Each time the batch file runs it initializes the ID and writes records. What I... | 13,867,489 | 8 | 1 | null | 2012-12-13 19:18:52.033 UTC | 1 | 2017-11-17 09:18:38.603 UTC | null | null | null | null | 368,259 | null | 1 | 18 | sql-server-2008|datetime|elapsedtime | 124,316 | <p>SQL Server doesn't support the SQL standard interval data type. Your best bet is to calculate the difference in seconds, and use a function to format the result. The native function CONVERT() might appear to work fine <em>as long as your interval is less than 24 hours</em>. But CONVERT() isn't a good solution for th... |
13,858,665 | Disable DPI awareness for WPF application | <p>Good day!</p>
<p>I've been working on a WPF app for some time now (as a learning experience and oh boy it was a learning experience) and it's finally ready for release. Release means installing it on my HTPC where it will be used to browse my movie collection.</p>
<p>I designed it on my PC which runs 1920*1080 but... | 13,858,985 | 9 | 0 | null | 2012-12-13 11:15:09.58 UTC | 12 | 2022-02-09 13:44:06.94 UTC | 2012-12-15 14:39:42.073 UTC | null | 106,224 | null | 1,173,937 | null | 1 | 29 | wpf|scaling|dpi | 34,856 | <h2>DPIAwareness</h2>
<p>Just some ideas (not tried):</p>
<p>Are you running on XP? That option might not work on that platform.</p>
<ul>
<li><a href="http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/5e60a54d-baf5-46e3-9eac-a959f2a0fba1/" rel="noreferrer">http://social.msdn.microsoft.com/Forums/en-US/v... |
13,960,556 | Interpreting eclipse .classpath file. What does 'kind="con"' and 'exported="true"' mean? | <p>This is the eclipse <code>.classpath</code> file of the eclipse plugin program that I downloaded. </p>
<p>I think that <code>kind="src"</code> and <code>kind="output"</code> is pretty straight forward, as they means the where the source java files and compiled class files are located. </p>
<p>The <code>kind="lib"<... | 13,960,981 | 2 | 0 | null | 2012-12-19 20:22:47.687 UTC | 11 | 2017-12-02 07:37:13.86 UTC | 2015-02-20 14:40:16.583 UTC | null | 342,473 | null | 260,127 | null | 1 | 35 | java|eclipse|eclipse-plugin|classpath | 22,975 | <p>1) In <code>kind="con"</code>, the <code>con</code> stands for container, which is interpreted by eclipse as a <a href="http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/IClasspathContainer.html">classpath container</a>. As described in that link:</p>
<blockq... |
14,063,327 | How to disable the "Expect: 100 continue" header in HttpWebRequest for a single request? | <p><code>HttpWebRequest</code> automatically appends an <code>Expect: 100-continue</code> header for POST requests. Various sources around the internet suggest that this can be disabled as follows:</p>
<pre><code>System.Net.ServicePointManager.Expect100Continue = false;
</code></pre>
<p>However, I'm writing a library... | 14,063,329 | 3 | 1 | null | 2012-12-28 01:06:39.633 UTC | 8 | 2022-02-01 21:36:25.137 UTC | 2017-02-24 18:17:49.74 UTC | null | 33,080 | null | 33,080 | null | 1 | 47 | c#|.net|httpwebrequest | 44,482 | <p>The <code>HttpWebRequest</code> class has a property called <code>ServicePoint</code> which can be used to change this setting for a specific request. For example:</p>
<pre><code>var req = (HttpWebRequest) WebRequest.Create(...);
req.ServicePoint.Expect100Continue = false;
</code></pre> |
28,873,323 | Removing attributes of columns in data.frames on multilevel lists in R | <p>How do I remove the attributes of the following columns of data.frames on a nested list in R on the fly? </p>
<pre><code>List of 1
$ 0021400001:List of 19
$ GameSummary :'data.frame': 1 obs. of 13 variables:
$ GAME_DATE_EST : Factor w/ 1 level "2014-11-09T00:00:00": 1
- at... | 40,406,334 | 8 | 4 | null | 2015-03-05 08:36:45.11 UTC | 2 | 2021-10-30 05:35:08.213 UTC | null | null | null | null | 1,452,365 | null | 1 | 20 | r|list | 42,085 | <p>This is perhaps too late to answer on this thread, but I wanted to share.</p>
<p>Two solutions :
1. function stripAttributes from merTools package.</p>
<ol start="2">
<li><p>to remove the attribute ATT from variable VAR in your data-frame MyData:</p>
<pre><code>attr(MyData$VAR, "ATT") <- NULL
</code></pre></li... |
29,993,599 | How to do git push in Visual Studio Code? | <p>There is a "Push" menu item, but when I click on it, nothing happens except for a subtle progressing bar showing up and never finished. From Visual Studio Code's Docs page, I found this line: "Credential management is not handled by VSCode for now," and that page links to a GitHub page on credential helper, which is... | 30,085,424 | 5 | 7 | null | 2015-05-01 19:18:26.257 UTC | 11 | 2019-01-17 20:16:50.893 UTC | 2015-05-01 20:19:40.433 UTC | null | 1,079,354 | null | 272,258 | null | 1 | 44 | git|visual-studio-code | 67,251 | <p>If you are in windows use this line in your git bash:</p>
<blockquote>
<p>git config --global credential.helper wincred</p>
</blockquote>
<p>Next time git will remember your password. Thats all, the VSCode will work fine ;)</p>
<p>Bye Bytes !</p> |
9,080,431 | How execute bash script line by line? | <p>If I enter <a href="http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html" rel="noreferrer">bash -x</a> option, it will show all the line. But the script will execute normaly.</p>
<p>How can I execute line by line? Than I can see if it do the correct thing, or I abort and fix the bug. The same effect is put... | 9,080,645 | 5 | 1 | null | 2012-01-31 13:38:29.417 UTC | 48 | 2021-01-08 21:00:22.337 UTC | null | null | null | null | 632,472 | null | 1 | 120 | bash | 99,200 | <p>You don't need to put a read in everyline, just add a trap like the following into your bash script, it has the effect you want, eg.</p>
<pre><code>#!/usr/bin/env bash
set -x
trap read debug
< YOUR CODE HERE >
</code></pre>
<p>Works, just tested it with bash v4.2.8 and v3.2.25.</p>
<hr>
<p><strong>IMPROVE... |
24,798,666 | How to Print the output of a function using console.log (Javascript) | <p>The following code is meant print the namestring with a name. however, it's not correct.</p>
<pre><code>var nameString = function (name) {
return "Hi, I am" + " " + name.
}
nameString("Amir")
console.log(nameString)
</code></pre>
<p>What am I not implementing/doing wrong that stops it from displaying the stri... | 24,798,809 | 6 | 3 | null | 2014-07-17 08:37:23.383 UTC | 1 | 2021-10-12 23:00:57.04 UTC | null | null | null | null | 3,848,245 | null | 1 | 4 | javascript | 62,175 | <p>First mistake in your code is in the line</p>
<pre><code> return "Hi, I am" + " " + name.
</code></pre>
<p>remove fullstop or just concatenate it as below</p>
<pre><code> return "Hi, I am" + " " + name+"."
</code></pre>
<p>and then write</p>
<pre><code>console.log(nameString("Amir"));
</code></pre>
<p>check it... |
34,980,251 | How to print multiple lines of text with Python | <p>If I wanted to print multiple lines of text in Python without typing <code>print('')</code> for every line, is there a way to do that?</p>
<p>I'm using this for ASCII art.</p>
<p>(Python 3.5.1)</p> | 34,980,283 | 5 | 3 | null | 2016-01-24 19:17:53.08 UTC | 23 | 2021-11-11 13:05:38.007 UTC | 2021-02-07 05:37:25.237 UTC | null | 63,550 | null | 5,833,159 | null | 1 | 54 | python|python-3.x | 259,556 | <p>You can use <em>triple</em> quotes (single ' or double "):</p>
<pre><code>a = """
text
text
text
"""
print(a)
</code></pre> |
214,734 | Some x86 ASM Reference/Tutorials? | <p>I'm trying to find some references in regards to x86 Assembly languages. Tutorials/Examples to help my understanding.
-Thanks</p> | 214,737 | 5 | 0 | null | 2008-10-18 08:00:36.747 UTC | 17 | 2015-10-08 19:46:58.77 UTC | 2012-05-02 12:22:28.013 UTC | null | 192,221 | Dacto | 22,582 | null | 1 | 35 | reference|x86|assembly | 27,646 | <ul>
<li><a href="http://download.savannah.gnu.org/releases/pgubook/ProgrammingGroundUp-1-0-booksize.pdf" rel="noreferrer">Programming from the Ground Up</a> (free book, highly recommended)</li>
<li><a href="http://en.wikibooks.org/wiki/X86_Assembly" rel="noreferrer">x86 Assembly</a> (wikibooks.org)</li>
<li><a href="h... |
1,085,083 | Regular expressions in C: examples? | <p>I'm after some simple examples and best practices of how to use regular expressions in ANSI C. <code>man regex.h</code> does not provide that much help.</p> | 1,085,120 | 5 | 2 | null | 2009-07-05 23:38:03.557 UTC | 93 | 2022-05-02 12:43:25.233 UTC | 2012-12-25 06:10:56.94 UTC | null | 739,331 | null | 50,305 | null | 1 | 197 | c|regex | 404,507 | <p>Regular expressions actually aren't part of ANSI C. It sounds like you might be talking about the POSIX regular expression library, which comes with most (all?) *nixes. Here's an example of using POSIX regexes in C (based on <a href="http://web.archive.org/web/20160308115653/http://peope.net/old/regex.html" rel="nor... |
1,031,175 | Rails - Easy way to display all fields in view | <p>OK I'm sure I'm missing something here, but please forgive me I'm new to Rails. </p>
<p>Is there some way in Rails to display all the fields for an object rather than specifying each? </p>
<p>In my show.html template rather than going </p>
<pre><code><p>Name: <%=h @user.full_name %></p>
<p>... | 1,031,271 | 6 | 0 | null | 2009-06-23 07:50:25.21 UTC | 13 | 2016-07-13 14:44:04.12 UTC | null | null | null | null | 127,411 | null | 1 | 13 | ruby-on-rails|view | 11,998 | <p>Something like</p>
<pre><code><% for attribute in @user.attributes.keys %>
<p><%= attribute.humanize %> <%= @user.attributes[attribute].to_s %></p>
<% end %>
</code></pre>
<p>could do the trick.</p>
<p>Matt</p> |
961,878 | Moving from Visual Sourcesafe to Mercurial | <p>What's the best way to move a Visual Sourcesafe repository to Mercurial (I'm interested in retaining all history)?</p> | 961,918 | 6 | 0 | null | 2009-06-07 13:22:01.85 UTC | 11 | 2017-06-20 09:40:48.333 UTC | 2012-03-30 12:24:27.683 UTC | null | 110,204 | null | 118,058 | null | 1 | 19 | mercurial|migration|dvcs|visual-sourcesafe | 5,119 | <p>While I haven't made that particular conversion, I have gone from VSS to SVN using (IIRC) <a href="http://www.pumacode.org/projects/vss2svn" rel="noreferrer">this script</a>. You'll probably want to look into tailor and do a search for vss2hg. Also keep in mind that it may make sense to go through an intermediate ... |
1,285,986 | Flags enum & bitwise operations vs. “string of bits” | <p>A fellow developer suggested we store a selection of days of the week as 7-character string of 1’s and 0’s, i.e. “1000100” for Monday and Friday. I preferred (and strongly suggested) a solution with a Flags enum and bitwise operations, I think it's a cleaner way of doing this, and it should be easier to understand f... | 1,286,472 | 6 | 4 | null | 2009-08-17 02:58:11.03 UTC | 21 | 2013-05-06 16:55:08.19 UTC | 2013-03-15 15:28:07.19 UTC | null | 102,441 | null | 10,932 | null | 1 | 36 | c#|bit-manipulation|enum-flags | 42,114 | <p><strong>Benefits of using Flags enum:</strong></p>
<ul>
<li>Standard approach: <a href="http://msdn.microsoft.com/en-us/library/ms229062.aspx" rel="noreferrer">"They are the correct design to use when multiple enumeration values can be specified at the same time."</a></li>
<li>Intent is clear</li>
<li>Maintainable ... |
1,093,020 | Unit testing and checking private variable value | <p>I am writing unit tests with C#, NUnit and Rhino Mocks.
Here are the relevant parts of a class I am testing:</p>
<pre><code>public class ClassToBeTested
{
private IList<object> insertItems = new List<object>();
public bool OnSave(object entity, object id)
{
var auditable = entity as... | 1,093,481 | 6 | 2 | null | 2009-07-07 15:29:12.98 UTC | 14 | 2015-09-04 18:39:19.303 UTC | 2011-10-09 07:18:22.81 UTC | null | 11,635 | null | 95,423 | null | 1 | 64 | c#|unit-testing|nunit | 69,946 | <p>The quick answer is that you should never, ever access non-public members from your unit tests. It totally defies the purpose of having a test suite, since it locks you into internal implementation details that you may not want to keep that way.</p>
<p>The longer answer relates to what to do then? In this case, it ... |
42,301,884 | Safari not setting CORS cookies using JS Fetch API | <p>I am unable to get Safari to successfully apply <code>Set-Cookie</code> from server responses when using the Fetch API (actually, via the <a href="https://github.com/github/fetch" rel="noreferrer">fetch polyfill</a>). The same code works correctly in FF and Chrome (I tested using both native and polyfill <code>fetch... | 42,359,630 | 3 | 3 | null | 2017-02-17 15:39:53.617 UTC | 7 | 2022-07-19 20:41:06.23 UTC | 2022-03-15 16:22:58.183 UTC | null | 3,689,450 | null | 279,608 | null | 1 | 29 | javascript|cookies|safari|cross-domain|fetch-api | 13,146 | <p>Answering my own question.</p>
<p>I find it pretty enraging that this is a "working as intended" behaviour of Safari, though I understand their motivation. XHR (and presumably native fetch when it lands natively) does not support the setting of third-party cookies at all. This failure is completely transparent beca... |
31,133,301 | Expected response code 250 but got code "", with message "" | <p>I can send my emails in localhost flawlessly. but ever since I uploaded my program into a hosting site I get this error </p>
<blockquote>
<p>Expected response code 250 but got code "", with message ""</p>
</blockquote>
<p>I also updated the <code>.env</code> file.</p>
<pre><code>MAIL_DRIVER=smtp
MAIL_HOST=smtp... | 31,133,964 | 7 | 4 | null | 2015-06-30 08:31:22.73 UTC | 3 | 2022-06-21 11:19:24.957 UTC | 2015-06-30 08:47:14.34 UTC | null | 2,133,785 | null | 2,133,785 | null | 1 | 28 | php|email|laravel|outlook | 91,974 | <p>looks like the smtp was blocked for hostinger free users.</p>
<p><a href="http://www.hostinger.ph/forum/news-and-announcements/229-email-service-updates-1.html" rel="noreferrer">http://www.hostinger.ph/forum/news-and-announcements/229-email-service-updates-1.html</a></p> |
32,567,208 | Best way to verify string is empty or null | <p>i am sure this must have been asked before in different ways - as isEmptyOrNull is so common yet people implement it differently. but i have below curious query in terms of best available approach which is good for memory and performance both. </p>
<p>1) Below does not account for all spaces like in case of empty X... | 56,202,538 | 14 | 7 | null | 2015-09-14 14:20:17.873 UTC | 6 | 2021-05-14 06:18:13.81 UTC | 2019-09-06 03:55:11.723 UTC | null | 2,131,040 | null | 2,131,040 | null | 1 | 36 | java|regex|string|trim|is-empty | 127,979 | <p>Haven't seen any fully-native solutions, so here's one:</p>
<pre><code>return str == null || str.chars().allMatch(Character::isWhitespace);
</code></pre>
<p>Basically, use the native Character.isWhitespace() function. From there, you can achieve different levels of optimization, depending on how much it matters (I... |
32,414,345 | Aligning multiple div boxes horizontally and vertically | <p>I'm using <a href="https://almsaeedstudio.com/preview" rel="nofollow noreferrer">https://almsaeedstudio.com/preview</a> theme which gives some brilliant boxes layout and social widget boxes layout which I want to use in my project. </p>
<p>Refer to simple box screenshot </p>
<p><a href="https://i.stack.imgur.com/p... | 32,486,662 | 5 | 19 | null | 2015-09-05 14:44:19.913 UTC | 5 | 2016-02-20 18:38:19.643 UTC | 2017-05-23 12:32:08.41 UTC | null | -1 | null | 751,223 | null | 1 | 31 | javascript|jquery|html|css|twitter-bootstrap | 5,888 | <h2><strong>>>>>>>>>>>>>>>>>>>>>FLEXBOX SOLUTION<<<<<<<<<<<<<<<<<<<<</strong></h2>
<p>Here is the <strong>REAL SOLUTION</strong> to the <strong>ORIGINAL QUESTION</strong> if anyone is actually interested. </p>
<p>dark_shadow:</p>
<blockquote>
<p>While zer... |
20,993,947 | Prevent a specific child div from expanding the parent div | <p>I'm currently developping a website and encountered a problem with CSS.</p>
<p>I have a parent <code>div</code> containing 2 or more children: one containing the name of a user that sits on top of the other children, and just below 1 or more side by side <code>div</code>s which display items owned by the user.</p>
... | 20,994,123 | 2 | 4 | null | 2014-01-08 11:11:59.517 UTC | 5 | 2021-11-18 22:01:43.583 UTC | 2018-12-17 21:55:40.903 UTC | null | 3,345,644 | null | 3,172,899 | null | 1 | 60 | css | 61,276 | <p>You can use <strong>Absolute positioning</strong></p>
<p><strong><a href="http://jsfiddle.net/chadocat/mLxjL/15/" rel="noreferrer">FIDDLE</a></strong></p>
<pre><code>position:absolute;
top:0;
left:0;
width:100%;
</code></pre>
<p>and on the container div :</p>
<pre><code>padding-top: /*the height of the absolutly... |
21,078,445 | Find connected components in a graph | <p>If I have an undirected graph (implemented as a list of vertices), how can I find its connected components? How can I use quick-union?</p> | 21,078,752 | 2 | 5 | null | 2014-01-12 18:15:11.073 UTC | 15 | 2016-12-21 03:42:13.653 UTC | 2016-12-21 03:42:13.653 UTC | null | 880,772 | null | 3,187,921 | null | 1 | 45 | algorithm|graph | 55,798 | <p>Use depth-first search (DFS) to mark all individual connected components as visited:</p>
<pre><code>dfs(node u)
for each node v connected to u :
if v is not visited :
visited[v] = true
dfs(v)
for each node u:
if u is not visited :
visited[u] = true
connected_component += 1
dfs(u)
<... |
33,412,974 | How to uninstall a package installed with pip install --user | <p>There is a <code>--user</code> option for pip which can install a Python package per user:</p>
<pre><code>pip install --user [python-package-name]
</code></pre>
<p>I used this option to install a package on a server for which I do not have root access. What I need now is to uninstall the installed package on the c... | 35,524,522 | 7 | 5 | null | 2015-10-29 11:27:43.79 UTC | 67 | 2021-06-11 17:33:53.48 UTC | 2019-07-09 08:34:33.76 UTC | null | 2,303,761 | null | 546,822 | null | 1 | 279 | python|python-3.x|pip|virtualenv | 489,505 | <p>Having tested this using Python 3.5 and pip 7.1.2 on Linux, the situation appears to be this:</p>
<ul>
<li><p><code>pip install --user somepackage</code> installs to <code>$HOME/.local</code>, and uninstalling it does work using <code>pip uninstall somepackage</code>.</p></li>
<li><p>This is true whether or not <co... |
1,664,402 | How can I specify per-face colors when using indexed vertex arrays in OpenGL 3.x? | <p>I'm trying to render a cube using an array of 8 vertices and an index-array of 24 (4<code>*</code>6) indices into the vertex array. But how can I specify <em>per-face</em> variables, like colors and normals without using deprecated functions? For this I need a separate set of indices, but when I specify two index-ar... | 1,666,059 | 5 | 0 | null | 2009-11-02 23:39:43.113 UTC | 15 | 2020-08-16 07:24:12.613 UTC | null | null | null | null | 178,419 | null | 1 | 28 | opengl | 17,946 | <p>The actual answer first:<br>
See Goz's answer. Keep 24 separate vertices.</p>
<p>Some nomenclature second:<br>
A Vertex is a set of vertex attributes. Please keep that distinction in mind when reading the following:</p>
<p>You have a misconception that using deprecated APIs would help you solve the issue. This is ... |
2,309,708 | Delegate: Method name expected error | <p>I'm trying to get the following simple Delegate example working. According to a book I've taken it from it should be ok, but I get a <code>Method name expected</code> error.</p>
<pre><code>namespace TestConsoleApp
{
class Program
{
private delegate string D();
static void Main(string[] args... | 2,309,714 | 6 | 0 | null | 2010-02-22 08:41:35.27 UTC | 1 | 2016-04-08 16:54:08.37 UTC | null | null | null | null | 42,636 | null | 1 | 15 | c#|delegates | 40,793 | <p>Remove the ():</p>
<pre><code>D code = new D(x.ToString);
</code></pre>
<p>You want to <strong>specify</strong> the method, not <strong>execute</strong> it.</p> |
1,523,482 | .vimrc configuration for Python | <p>My current .vimrc configuration is below:</p>
<pre><code>set nohlsearch
set ai
set bg=dark
set showmatch
highlight SpecialKey ctermfg=DarkGray
set listchars=tab:>-,trail:~
set list
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
set tabstop=4
set shiftwidth=4
set... | 1,523,512 | 6 | 0 | null | 2009-10-06 03:45:54.82 UTC | 14 | 2019-04-18 14:58:09.1 UTC | 2009-10-28 19:22:31.607 UTC | null | 41,718 | null | 179,736 | null | 1 | 19 | python|vim | 32,201 | <p>The short answer is that your autocmd is missing the BufEnter trigger, so it isn't being fired when you create a new file. Try this instead:</p>
<pre><code> au BufEnter,BufRead *.py setlocal smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
</code></pre>
<p>Note that I also changed the <code... |
1,619,737 | Migrate project from RCS to git? | <p>I have a <a href="http://www.cs.tufts.edu/~nr/noweb/" rel="noreferrer">20-year-old project</a> that I would like to migrate from RCS to git, without losing the history. All web pages suggest that the One True Path is through CVS. But after an hour of Googling and trying different scripts, I have yet to find anythi... | 1,620,677 | 6 | 7 | null | 2009-10-25 02:01:08.393 UTC | 15 | 2022-08-29 02:08:51.157 UTC | 2012-02-03 09:12:38.25 UTC | null | 714,965 | null | 41,661 | null | 1 | 46 | git|migration|cvs|rcs | 12,648 | <p>See <a href="https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools" rel="nofollow noreferrer">Interfaces, frontends, and tools</a> page on Git Wiki, in "Tools", "Interaction with other Revision Control Systems", "Other". There you would find a description and a link to ... |
1,525,928 | What Add-Ons / Utilities are available for TFS? | <p>I'm interested in knowing what high quality and useful add-ons or utilities are available for TFS. They can be commercial or open source. Of particular interest are any tools allowing visualisation of branches and tracking changesets as they are merged across branches (yes I know that the next version of TFS will be... | 1,541,549 | 7 | 0 | null | 2009-10-06 14:27:15.913 UTC | 23 | 2013-12-10 07:33:47.52 UTC | 2013-12-10 07:33:47.52 UTC | null | 881,229 | null | 7,532 | null | 1 | 24 | tfs | 16,027 | <ul>
<li><a href="http://msdn.microsoft.com/en-us/teamsystem/bb980963.aspx" rel="nofollow noreferrer">TFS Power Tools</a> - collection of MS utilities has grown too large and too powerful to summarize here. Don't leave home without it!</li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FAEB7636... |
1,572,934 | Where to store an application log file on Windows | <p>Where would be the best "standard" place to put an application's debug log file in a Windows user environment?</p>
<p>In this particular case, it is an application that is run once and could go wrong. It will be run by system administrator types who may need to inspect the log after the application is run. Everyt... | 1,573,094 | 7 | 3 | null | 2009-10-15 14:57:21.773 UTC | 6 | 2019-03-03 23:30:29.383 UTC | 2017-05-23 12:10:08.02 UTC | null | -1 | null | 5,062 | null | 1 | 39 | windows|logging | 32,672 | <p>The Application Data directory would seem to be the perfect place, but it's an area that is nearly invisible. You need to give your users an easy way to get to it.</p>
<p>Have your installation script create a Log folder in the Application Data area for your program, and include a link to the folder in your Start m... |
2,298,165 | Is there a module for balanced binary tree in Python's standard library? | <p>Is there a module for an <a href="https://en.wikipedia.org/wiki/AVL_tree" rel="noreferrer">AVL tree</a> or a <a href="https://en.wikipedia.org/wiki/Red%E2%80%93black_tree" rel="noreferrer">red–black tree</a> or some other type of a balanced binary tree in the standard library of Python?</p> | 2,298,316 | 7 | 5 | null | 2010-02-19 17:06:42.147 UTC | 20 | 2020-06-24 19:32:26.937 UTC | 2020-03-31 08:25:46.933 UTC | null | 562,769 | null | 160,992 | null | 1 | 97 | python|tree|standard-library | 53,932 | <p>No, there is not a balanced binary tree in the stdlib. However, from your comments, it sounds like you may have some other options:</p>
<ul>
<li>You say that you want a BST instead of a list for <code>O(log n)</code> searches. If searching is all you need and your data are already sorted, the <code>bisect</code> mo... |
1,409,543 | Using SAS Macro to pipe a list of filenames from a Windows directory | <p>I am trying to amend the macro below to accept a macro parameter as the 'location' argument for a dir command. However I cannot get it to resolve correctly due to the nested quotes issue. Using %str(%') does not work, neither do quoting functions for some reason.</p>
<p>The macro will work fine when the filepath ... | 1,412,947 | 8 | 0 | null | 2009-09-11 07:49:12.58 UTC | 4 | 2012-01-24 18:37:26.58 UTC | 2009-09-11 12:04:07.373 UTC | null | 66,696 | null | 66,696 | null | 1 | 7 | sas|pipe|sas-macro|dir|file-io | 43,102 | <p>Here's another way of achieving the same result without needing to use a PIPE. </p>
<pre><code>%macro get_filenames(location);
filename _dir_ "%bquote(&location.)";
data filenames(keep=memname);
handle=dopen( '_dir_' );
if handle > 0 then do;
count=dnum(handle);
do i=1 to count;
memname=dre... |
2,230,286 | Unit Testing or Functional Testing? | <p>I have recently heard of Functional Testing over Unit Testing.</p>
<p>I understand that Unit Testing tests each of the possibilities of a given piece of code from its most atomic form. But what about Functional Testing?</p>
<p>This sounds to me like only testing if the code works, but is it as reliable as Unit Tes... | 2,230,616 | 8 | 3 | null | 2010-02-09 15:44:40.487 UTC | 17 | 2012-11-30 05:15:15.323 UTC | null | null | null | null | 162,167 | null | 1 | 28 | .net|unit-testing|functional-testing|testdrivendesign | 6,546 | <p>Jason's answer is correct. Different types of tests have different purposes, and can be layered for best results (good design, meeting specifications, reduced defects).</p>
<ul>
<li>Unit testing = drives design (with <a href="http://en.wikipedia.org/wiki/Test-driven_development" rel="noreferrer">Test-Driven Develop... |
1,528,525 | Alternatives to System.Drawing for use with ASP.NET? | <p>After several days of tracking down bizarre GDI+ errors, I've stumbled across this little gem on <a href="http://msdn.microsoft.com/en-us/library/system.drawing.aspx" rel="nofollow noreferrer">MSDN</a>:</p>
<blockquote>
<p>Classes within the System.Drawing namespace are not supported for use within a Windows or A... | 11,991,193 | 8 | 2 | null | 2009-10-06 22:56:26.103 UTC | 20 | 2020-11-07 07:09:44.12 UTC | 2018-12-24 08:29:45.153 UTC | null | 107,625 | null | 5,017 | null | 1 | 34 | c#|asp.net|gdi+|system.drawing|system.drawing.imaging | 18,917 | <p>There is an excellent blog post including C# code about using the <a href="http://www.imagemagick.org/script/index.php" rel="nofollow noreferrer">ImageMagick graphics library</a> through Interop over at <a href="http://www.toptensoftware.com/Articles/17/High-Quality-Image-Resampling-in-Mono-Linux" rel="nofollow nore... |
1,674,742 | Intersection of multiple lists with IEnumerable.Intersect() | <p>I have a list of lists which I want to find the intersection for like this:</p>
<pre><code>var list1 = new List<int>() { 1, 2, 3 };
var list2 = new List<int>() { 2, 3, 4 };
var list3 = new List<int>() { 3, 4, 5 };
var listOfLists = new List<List<int>>() { list1, list2, list3 };
// exp... | 1,676,684 | 8 | 0 | null | 2009-11-04 15:56:16.797 UTC | 28 | 2017-10-12 15:14:14.007 UTC | 2009-11-05 08:52:55.64 UTC | null | 83,111 | null | 83,111 | null | 1 | 97 | c#|.net|linq | 41,220 | <p>How about:</p>
<pre><code>var intersection = listOfLists
.Skip(1)
.Aggregate(
new HashSet<T>(listOfLists.First()),
(h, e) => { h.IntersectWith(e); return h; }
);
</code></pre>
<p>That way it's optimized by using the same HashSet throughout and still in a single statement. Just ... |
1,739,706 | How to insert an item at the beginning of an array in PHP? | <p>I know how to insert it to the end by:</p>
<pre><code>$arr[] = $item;
</code></pre>
<p>But how to insert it to the beginning?</p> | 1,739,717 | 8 | 3 | null | 2009-11-16 02:17:18.157 UTC | 19 | 2022-09-14 16:34:56.647 UTC | 2018-05-16 00:20:58.833 UTC | null | 4,974,784 | null | 211,732 | null | 1 | 249 | php|arrays | 218,336 | <p>Use <a href="http://php.net/manual/en/function.array-unshift.php" rel="noreferrer">array_unshift($array, $item);</a></p>
<pre><code>$arr = array('item2', 'item3', 'item4');
array_unshift($arr , 'item1');
print_r($arr);
</code></pre>
<p>will give you</p>
<pre><code>Array
(
[0] => item1
[1] => item2
[2] =&... |
1,832,290 | Android id naming convention: lower case with underscore vs. camel case | <p>I'm currently programming an application for the Android. Now what I found out is that you cannot place resource objects, say, an image in the drawable folder and name it like "myTestImage.jpg". This will give you a compiler error since camel case syntax is not allowed, so you'd have to rename it like "my_test_image... | 1,833,639 | 9 | 1 | null | 2009-12-02 11:17:37.583 UTC | 23 | 2022-03-10 05:47:25.963 UTC | 2013-03-16 03:14:18.63 UTC | null | 918,414 | null | 50,109 | null | 1 | 97 | android|mobile | 49,027 | <p>The device will not complain if you use camel-case id names. For my first application I wrote all the ids in camel-case because I think it appears better in the Java code that way, and it works just fine.</p>
<p>I am slowly changing my mind on camel-case, though, because you end up with two different naming conven... |
2,213,627 | When you exit a C application, is the malloc-ed memory automatically freed? | <p>Let's say I have the following C code:</p>
<pre><code>int main () {
int *p = malloc(10 * sizeof *p);
*p = 42;
return 0; //Exiting without freeing the allocated memory
}
</code></pre>
<p>When I compile and execute that C program, ie after allocating some space in memory, will that memory I allocated be still... | 2,213,644 | 9 | 2 | null | 2010-02-06 15:37:21.79 UTC | 34 | 2015-10-13 17:27:53.17 UTC | null | null | null | null | 44,084 | null | 1 | 111 | c|memory-management | 42,578 | <p>It depends on the operating system. The majority of modern (and all major) operating systems will free memory not freed by the program when it ends.</p>
<p>Relying on this is bad practice and it is better to free it explicitly. The issue isn't just that your code looks bad. You may decide you want to integrate your... |
2,110,732 | How to get name of calling function/method in PHP? | <p>I am aware of function <code>debug_backtrace</code>, but I am looking for some ready to use implementation of function like <code>GetCallingMethodName()</code>? It would be perfect if it gave method's class too (if it is indeed a method).</p> | 2,110,758 | 10 | 1 | null | 2010-01-21 16:10:17.39 UTC | 66 | 2022-03-28 10:24:14.31 UTC | 2020-01-30 13:49:23.477 UTC | null | 2,753,501 | null | 239,129 | null | 1 | 273 | php|debugging|backtrace|method-call | 278,889 | <p>The <code>debug_backtrace()</code> function is the only way to know this, if you're lazy it's one more reason you should code the <code>GetCallingMethodName()</code> yourself. <strong>Fight the laziness! :D</strong></p> |
1,361,437 | JavaScript equivalent of PHP’s die | <p>Is there something like "die" in JavaScript? I've tried with "break", but doesn't work :)</p> | 1,365,521 | 14 | 7 | null | 2009-09-01 09:18:03.927 UTC | 26 | 2022-01-07 12:16:04.883 UTC | null | null | null | null | 115,201 | null | 1 | 125 | javascript | 157,904 | <p>You can only <code>break</code> a block scope if you label it. For example:</p>
<pre><code>myBlock: {
var a = 0;
break myBlock;
a = 1; // this is never run
};
a === 0;
</code></pre>
<p>You cannot break a block scope from within a function in the scope. This means you can't do stuff like:</p>
<pre><code>foo:... |
33,700,580 | Laravel 5 Application Key | <p>I am new to Laravel. I just started it tonight. Actually, I have the following code: </p>
<pre><code>'key' => env('APP_KEY', 'SomeRandomString'),
</code></pre>
<p>In <em>xampp/htdocs/laravel/blog/config/app.php</em>.<br>
I want to change this key to 32-bit by cmd as:</p>
<pre><code>xampp\htdocs\laravel/blog>... | 33,701,687 | 5 | 3 | null | 2015-11-13 19:40:06.467 UTC | 16 | 2020-04-05 08:31:52.527 UTC | 2019-03-23 08:42:59.57 UTC | null | 9,331,166 | null | 3,528,332 | null | 1 | 90 | php|laravel|laravel-5.1 | 276,992 | <p>This line in your <code>app.php</code>, <code>'key' => env('APP_KEY', 'SomeRandomString'),</code>, is saying that the key for your application can be found in your <code>.env</code> file on the line <code>APP_KEY</code>.</p>
<p>Basically it tells Laravel to look for the key in the <code>.env</code> file first an... |
8,428,422 | Detect an MSISDN (mobile number) with the browser | <p>Are there any HTTP headers one can use to detect a mobile users number other than this X-header <code>x-up-calling-line-id</code> ?</p>
<p>I want to detect from all browsers as much as possible to cover all platform mobiles.</p> | 11,152,022 | 3 | 2 | null | 2011-12-08 08:53:59.3 UTC | 11 | 2019-11-14 19:29:59.29 UTC | 2012-09-10 07:09:10.397 UTC | null | 618,172 | null | 751,689 | null | 1 | 13 | mobile|phone-number|msisdn | 54,156 | <p>I will give you the exact same answer I gave to a very similar question as it should provide some insight into what you are trying to achieve.</p>
<p>The ability to get the MSISDN of the user visiting the WAP site depends on a number of things.</p>
<p>Firstly, the user has to be on Mobile Data. If the user is on W... |
18,065,807 | Regular expression for removing whitespaces | <p>I have some text which looks like this - </p>
<pre><code>" tushar is a good boy "
</code></pre>
<p>Using javascript I want to remove all the extra white spaces in a string. </p>
<p>The resultant string should have no multiple white spaces instead have only one. Moreover the starting and the end should... | 18,066,013 | 7 | 6 | null | 2013-08-05 19:07:45.327 UTC | 9 | 2021-07-04 18:55:40.283 UTC | null | null | null | null | 1,040,006 | null | 1 | 22 | javascript|regex | 81,532 | <p>This can be done in a single <code>String#replace</code> call:</p>
<pre><code>var repl = str.replace(/^\s+|\s+$|\s+(?=\s)/g, "");
// gives: "tushar is a good boy"
</code></pre> |
6,533,610 | Android Gmail app-Mail Attachment URI issue | <p>I have to open attachment file from gmail app thru my app.</p>
<p>I get link in pattern like <em>content://gmail-ls/messages/mailid%40gmail.com/4/attachments/0.1/BEST/false</em></p>
<p>My problem is the link is not unique for each file in the mail client..
One or more file has same <em>Uri</em>.</p>
<p>Is there a... | 6,936,224 | 4 | 0 | null | 2011-06-30 10:49:47.44 UTC | 1 | 2019-03-26 08:24:04.827 UTC | 2011-06-30 10:58:17.497 UTC | null | 390,177 | null | 286,831 | null | 1 | 5 | android|gmail | 44,282 | <p>I resolved this issue in an indirect way.</p>
<p>I identified the uniqueness using the file size.</p>
<p>In-case if you need the code here it is</p>
<pre><code>InputStream is = getContentResolver().openInputStream(uri);
FILE_SIZE=is.available();
</code></pre> |
23,461,713 | Obtaining values used in boxplot, using python and matplotlib | <p>I can draw a boxplot from data:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
data = np.random.rand(100)
plt.boxplot(data)
</code></pre>
<p>Then, the box will range from the 25th-percentile to 75th-percentile, and the whisker will range from the smallest value to the largest value between (<co... | 23,462,659 | 3 | 2 | null | 2014-05-04 21:21:16.977 UTC | 10 | 2022-01-06 20:13:50.433 UTC | 2020-06-11 19:48:40.627 UTC | null | 7,758,804 | null | 2,203,311 | null | 1 | 28 | python|numpy|matplotlib|scipy | 50,077 | <p>Why do you want to do so? what you are doing is already pretty direct.</p>
<p>Yeah, if you want to fetch them for the plot, when the plot is already made, simply use the <code>get_ydata()</code> method.</p>
<pre><code>B = plt.boxplot(data)
[item.get_ydata() for item in B['whiskers']]
</code></pre>
<p>It returns a... |
18,800,727 | MS Access call SQL Server stored procedure | <p>I have an MS Access application that contains all tables linked to SQL Server, so in MS Access VBA code or query I work with those tables very simple, I access them via name, like <code>[Customers]</code>.</p>
<p>Also I have a stored procedure in SQL Server called <code>sp_CopyData</code> which I need to call from ... | 19,213,929 | 4 | 2 | null | 2013-09-14 10:24:12.163 UTC | 6 | 2022-04-07 07:29:37.167 UTC | 2013-09-14 10:49:00.443 UTC | null | 13,302 | null | 206,330 | null | 1 | 18 | sql-server|vba|ms-access|stored-procedures|ms-access-2007 | 76,257 | <p>The right answer found out, it should be like:</p>
<pre><code>Dim qdef As DAO.QueryDef
Set qdef = CurrentDb.CreateQueryDef("")
qdef.Connect = CurrentDb.TableDefs("[ANY LINKED TABLE TO MS SQL SERVER]").Connect
qdef.SQL = "EXEC sp_CopyData"
qdef.ReturnsRecords = False ''avoid 3065 error
qdef.Execute
</code></pre> |
5,595,956 | replace innerHTML in contenteditable div | <p>i need to implement highlight for numbers( in future im add more complex rules ) in the contenteditable div. The problem is When im insert new content with javascript replace, DOM changes and contenteditable div lost focus. What i need is keep focus on div with caret on the current position, so users can just type w... | 5,596,688 | 2 | 3 | null | 2011-04-08 13:41:41.797 UTC | 13 | 2017-06-27 20:28:00.683 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 595,701 | null | 1 | 10 | javascript|html|range|contenteditable|rangy | 15,266 | <p>The problem is that Rangy's save/restore selection module works by inserting invisible marker elements into the DOM where the selection boundaries are and then your code strips out all HTML tags, including Rangy's marker elements (as the error message suggests). You have two options:</p>
<ol>
<li>Move to a DOM trav... |
370,055 | Programmatically Switching Views in Cocoa Touch | <p>How would one change the view on the screen programmatically in an iPhone app?</p>
<p>I've been able to create navigation view's and programmatically push/pop them to produce this behaviour, but if I wanted to simply change the current view (not using a UINavigation controller object), what is the neatest way to ac... | 370,390 | 7 | 1 | null | 2008-12-15 23:23:43.177 UTC | 10 | 2019-01-21 11:57:10.607 UTC | 2019-01-21 11:57:10.607 UTC | Akusete | 1,033,581 | Akusete | 40,175 | null | 1 | 7 | ios|objective-c|iphone|cocoa-touch | 6,537 | <p>I use <code>presentModalViewController:animated:</code> to bring up a settings view from my main window's <code>UIViewController</code> and then when the user presses "done" in the settings view I call <code>dismissModalViewControllerAnimated:</code> from the settings view (reaching back to the parent view) like thi... |
710,675 | Is it possible to set the position of an UIImageView's image? | <p>I have a <code>UIImageView</code> that displays a bigger image. It appears to be centered, but I would like to move that image inside that <code>UIImageView</code>. I looked at the <a href="https://developer.apple.com/LIBRARY/IOS/samplecode/MoveMe/Introduction/Intro.html" rel="noreferrer">MoveMe</a> sample from Appl... | 711,210 | 7 | 0 | null | 2009-04-02 17:09:57.52 UTC | 2 | 2021-04-12 07:43:28.973 UTC | 2013-11-01 08:53:19.547 UTC | null | 1,752,200 | Unknown Individual | 62,553 | null | 1 | 18 | iphone|image|uiimageview | 44,784 | <p>Original Answer has been superseded by CoreAnimation in iOS4.</p>
<p>So as Gold Thumb says: you can do this by accessing the UIView's CALayer. Specifically its contentRect:</p>
<p>From the <a href="https://developer.apple.com/library/ios/documentation/graphicsimaging/reference/CALayer_class/Introduction/Introducti... |
1,016,409 | fastest way to use css for html table without affecting another html table | <p>My css is located at <a href="http://sillybean.net/css/seaglass.css" rel="nofollow noreferrer">http://sillybean.net/css/seaglass.css</a> and i want to use this css for only one of html table, On the same page i have multiple html tables so i do not want to affect other html tables. What is the fastest way to do it ... | 1,016,414 | 8 | 0 | null | 2009-06-19 05:05:01.183 UTC | 4 | 2017-04-12 20:38:04.61 UTC | 2017-01-27 08:00:53.47 UTC | null | 6,637,668 | null | 108,869 | null | 1 | 8 | html|css | 52,752 | <p>Can you just apply a class to the table you want to affect, then use that class in your CSS?</p>
<p>In your HTML, you can put:</p>
<pre><code><table class="mytable">
... CONTENT OF THE TABLE, AS NORMAL ...
</table>
</code></pre>
<p>And then, add the class selector to your CSS:</p>
<pre class="lang-cs... |
1,281,353 | Use Java FFmpeg wrapper, or simply use Java runtime to execute FFmpeg? | <p>I'm pretty new to Java, need to write a program that listen to video conversion instructions and convert the video once an new instruction arrives. (Instructions are stored in Amazon SQS, but it's irrelevant to my question)</p>
<p>I'm facing a choice, either use Java runtime to exec FFmpeg conversion (like from comm... | 1,281,454 | 8 | 0 | null | 2009-08-15 06:59:23.613 UTC | 28 | 2022-05-20 06:40:56.15 UTC | 2022-05-20 06:40:20.447 UTC | null | 452,775 | null | 156,153 | null | 1 | 53 | java|ffmpeg|runtime.exec | 89,418 | <p>If I'm not mistaken, the "ffmpeg-wrapper" project you linked to is out of date and not maintained. FFmpeg is a very active project, lot's of changes and releases all the time.</p>
<p>You should look at the Xuggler project, this provides a Java API for what you want to do, and they have tight integration w... |
1,146,624 | How to do static content in Rails? | <p>Looking at different options:</p>
<p>One is to just put the static pages in the public/ folder, but I do want the header from layout/application to be consistent.</p>
<p>I tried this, but I got an error:</p>
<pre><code># in routes.rb:
map.connect '*path', :controller => 'content', :action => 'show'
# in co... | 1,688,840 | 8 | 0 | null | 2009-07-18 03:23:37.643 UTC | 37 | 2020-10-23 07:22:54.703 UTC | 2015-03-11 19:05:37.077 UTC | null | 201,911 | null | 92,679 | null | 1 | 73 | ruby-on-rails|ruby|static-content | 57,692 | <p>thoughtbot has a plugin called high_voltage for displaying static content: <a href="https://github.com/thoughtbot/high_voltage" rel="noreferrer">https://github.com/thoughtbot/high_voltage</a></p> |
998,235 | Does Visual Studio 2010 support iPhone Development? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/22358/how-can-i-develop-for-iphone-using-a-windows-development-machine">How can I develop for iPhone using a Windows development machine?</a> </p>
</blockquote>
<p>Does Visual Studio 2010 support iPhone Develop... | 998,264 | 9 | 2 | null | 2009-06-15 20:35:32.893 UTC | 3 | 2019-02-01 07:57:48.917 UTC | 2017-05-23 12:26:44.457 UTC | null | -1 | null | 109,676 | null | 1 | 7 | iphone|visual-studio | 38,504 | <p><a href="https://developer.apple.com/xcode/" rel="nofollow noreferrer">Xcode</a> must be used to develop for the iPhone. It is the only platform for which the iPhone SDK is available.</p> |
217,549 | Which Typesafe Enum in C++ Are You Using? | <p>It is common knowledge that built-in enums in C++ are not typesafe.
I was wondering which classes implementing typesafe enums are used out there...
I myself use the following "bicycle", but it is somewhat verbose and limited:</p>
<p>typesafeenum.h:</p>
<pre><code>struct TypesafeEnum
{
// Construction:
public:
... | 439,004 | 11 | 4 | null | 2008-10-20 04:58:33.603 UTC | 33 | 2016-10-06 21:53:47.893 UTC | 2014-06-16 20:37:18.057 UTC | Alex Jenter | 76,722 | Alex Jenter | 22,046 | null | 1 | 45 | design-patterns|enums|enumeration|type-safety|c++03 | 27,413 | <p>I'm currently playing around with the Boost.Enum proposal from the <a href="https://github.com/boost-vault/Miscellaneous" rel="noreferrer">Boost Vault</a> (filename <code>enum_rev4.6.zip</code>). Although it was never officially submitted for inclusion into Boost, it's useable as-is. (Documentation is lacking but ... |
626,899 | How do you change the datatype of a column in SQL Server? | <p>I am trying to change a column from a <code>varchar(50)</code> to a <code>nvarchar(200)</code>. What is the SQL command to alter this table? </p> | 626,904 | 11 | 0 | null | 2009-03-09 16:06:41.09 UTC | 45 | 2022-09-18 13:52:29.883 UTC | 2020-10-21 00:19:24 UTC | mwigdahl | 285,795 | Ascalonian | 65,230 | null | 1 | 387 | sql-server|tsql|type-conversion|alter-table | 786,334 | <pre><code>ALTER TABLE TableName
ALTER COLUMN ColumnName NVARCHAR(200) [NULL | NOT NULL]
</code></pre>
<p><strong>EDIT</strong>
As noted NULL/NOT NULL should have been specified, see <a href="https://stackoverflow.com/a/635360/1165522">Rob's answer</a> as well. </p> |
620,993 | Determining binary/text file type in Java? | <p>Namely, how would you tell an archive (jar/rar/etc.) file from a textual (xml/txt, encoding-independent) one?</p> | 621,003 | 12 | 1 | null | 2009-03-07 00:31:04.477 UTC | 12 | 2022-06-18 22:49:39.437 UTC | 2012-11-23 16:50:32.597 UTC | null | 145,989 | gsmd | 15,187 | null | 1 | 48 | java|file|text|binary | 39,892 | <p>There's no guaranteed way, but here are a couple of possibilities:</p>
<ol>
<li><p>Look for a header on the file. Unfortunately, headers are file-specific, so while you might be able to find out that it's a RAR file, you won't get the more generic answer of whether it's text or binary.</p>
</li>
<li><p>Count the nu... |
69,913 | Why don't self-closing script elements work? | <p>What is the reason browsers do not correctly recognize:</p>
<pre><code><script src="foobar.js" /> <!-- self-closing script element -->
</code></pre>
<p>Only this is recognized:</p>
<pre><code><script src="foobar.js"></script>
</code></pre>
<p>Does this break the concept of XHTML support?<... | 69,984 | 12 | 14 | null | 2008-09-16 06:52:38.563 UTC | 177 | 2022-02-21 13:21:39.817 UTC | 2019-04-09 03:58:42.973 UTC | JasonBunting | 606,371 | dimarzionist | 10,778 | null | 1 | 1,483 | javascript|html|internet-explorer|xhtml | 155,565 | <p>The non-normative appendix ‘HTML Compatibility Guidelines’ of the XHTML 1 specification says:</p>
<p><a href="http://www.w3.org/TR/xhtml1/#C_3" rel="nofollow noreferrer">С.3. Element Minimization and Empty Element Content</a></p>
<blockquote>
<p>Given an empty instance of an element whose content model is not <code>... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.