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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
23,038,682 | java.lang.RuntimeException: Only one Looper may be created per thread | <p>I have a simple thread that goes like this: </p>
<pre><code>public class AwesomeRunnable extends Thread {
Handler thisHandler = null;
Handler uihandler = null;
String update = null;
long time = 0;
public AwesomeRunnable(Handler h, long howLong) {
uihandler = h;
time = howLong;
... | 24,115,631 | 2 | 5 | null | 2014-04-13 03:10:15.917 UTC | 1 | 2016-05-24 08:03:36.043 UTC | 2014-04-13 03:40:21.917 UTC | null | 3,081,519 | null | 3,081,519 | null | 1 | 31 | java|android|multithreading | 22,347 | <blockquote>
<p>java.lang.RuntimeException: Only one Looper may be created per thread</p>
</blockquote>
<p>The exception is thrown because you (or core Android code) has already called <code>Looper.prepare()</code> for the current executing thread.</p>
<p>The following checks whether a Looper already exists for the... |
32,017,457 | How to implement a REST API Server? | <p>I am a university student with an intermediate level of C++ programming experience. <em>I would like to implement a simple REST based API for my application as quickly as possible.</em> </p>
<p>I have looked at <a href="https://casablanca.codeplex.com/" rel="noreferrer">Casablanca</a> and <a href="https://libwebsoc... | 32,018,952 | 5 | 6 | null | 2015-08-14 19:32:29.01 UTC | 12 | 2017-12-07 13:49:51.997 UTC | 2015-08-14 21:24:09.787 UTC | null | 4,882,392 | null | 4,798,352 | null | 1 | 17 | c++|api|rest | 69,896 | <p>Hey I also was new to the whole API game not too long ago. I found that deploying an <strong>ASP.NET Web API</strong> with Visual Studio was a great way to start. The template provided by VS (I'm using 2013) makes it really easy to create your own controllers. </p>
<p>If you look up a couple tutorials on HTTP metho... |
9,090,332 | Android: dynamically change ActionBar icon? | <p>I would like to dynamically change the "home" icon in the ActionBar. This is easily done in v14 with ActionBar.setIcon(...), but I can't find anyway to accomplish this in previous versions. </p> | 9,203,086 | 4 | 3 | null | 2012-02-01 03:24:52.237 UTC | 13 | 2015-04-11 16:18:39.913 UTC | null | null | null | null | 426,493 | null | 1 | 24 | android | 25,296 | <p>If you are using the <a href="http://developer.android.com/resources/samples/ActionBarCompat/index.html" rel="noreferrer">ActionbarCompat</a> code provided by google, you can access the home icon via the ActionBarHelperBase.java class for API v4 onwards. </p>
<pre><code> //code snippet from ActionBarHelperBase.j... |
9,537,797 | R grep: Match one string against multiple patterns | <p>In R, grep usually matches a vector of multiple strings against one regexp. </p>
<p><strong>Q: Is there a possibility to match a single string against multiple regexps? (without looping through each single regexp pattern)?</strong></p>
<p><em>Some background:</em></p>
<p>I have 7000+ keywords as indicators for se... | 9,538,033 | 3 | 3 | null | 2012-03-02 17:35:57.07 UTC | 14 | 2019-07-11 04:37:25.823 UTC | 2017-05-23 12:10:39.893 UTC | null | -1 | null | 924,912 | null | 1 | 30 | regex|r | 22,769 | <p>What about applying the regexpr function over a vector of keywords?</p>
<pre><code>keywords <- c("dog", "cat", "bird")
strings <- c("Do you have a dog?", "My cat ate by bird.", "Let's get icecream!")
sapply(keywords, regexpr, strings, ignore.case=TRUE)
dog cat bird
[1,] 15 -1 -1
[2,] -1 4 15
... |
18,430,324 | How to debug the error "OOM command not allowed when used memory > 'maxmemory'" in Redis? | <p>I'm getting "OOM command not allowed" when trying to set a key,
<code>maxmemory</code> is set to 500M with <code>maxmemory-policy</code> "volatile-lru", I'm setting TTL for each key sent to redis.</p>
<p><code>INFO</code> command returns : <code>used_memory_human:809.22M</code></p>
<ol>
<li>If maxmemory is set to... | 18,458,713 | 6 | 0 | null | 2013-08-25 15:00:11.063 UTC | 8 | 2020-09-21 17:57:14.82 UTC | 2017-07-02 23:46:36.42 UTC | null | 472,495 | null | 1,119,004 | null | 1 | 39 | redis | 64,729 | <p>Any chance you changed the number of databases? If you use a very large number then the initial memory usage may be high</p> |
18,360,118 | SQL Variables as Column names in Where Clause | <p>I need some help with my SQL logic, and I've been working (and researching) this for 2 days now with zero success.</p>
<p>My goal is to try an pass a variable from an ASP page to a stored procedure, which is utilizing the variable as criteria for a column name in the where clause.</p>
<p>So for example (a simplifi... | 18,363,855 | 7 | 2 | null | 2013-08-21 14:25:03.407 UTC | 1 | 2015-01-03 11:25:26.333 UTC | null | null | null | null | 2,703,905 | null | 1 | 4 | sql|sql-server|tsql | 59,966 | <p>If this is an internal company application why is everyone re-iterating and beating SQL Injection to death... Its very simple to just use Dynamic SQL.
If you are comfortable that these are only internal users using this then its very simple. Here is the concept. You essentially write a SQL Statement that writes a st... |
18,456,192 | Get specific objects from ArrayList when objects were added anonymously? | <p>I have created a short example of my problem. I'm creating a list of objects anonymously and adding them to an <code>ArrayList</code>. Once items are in the <code>ArrayList</code> I later come back and add more information to each object within the list. Is there a way to extract a specific object from the list if y... | 18,456,299 | 7 | 1 | null | 2013-08-27 02:54:10.877 UTC | 1 | 2015-01-27 18:08:53 UTC | 2015-01-27 18:08:53 UTC | null | 1,585,868 | null | 1,585,868 | null | 1 | 13 | java|object|arraylist | 121,158 | <p>Given the use of <code>List</code>, there's no way to "lookup" a value without iterating through it...</p>
<p>For example...</p>
<pre><code>Cave cave = new Cave();
// Loop adds several Parties to the cave's party list
cave.parties.add(new Party("FirstParty")); // all anonymously added
cave.parties.add(new Party("... |
18,267,091 | Open a DatePickerDialog on Click of EditText takes two clicks | <p>I want to open a Calendar on the click of Edit text. After that I want to set the date which the user selects from the Calendar in the edit text. Problem is that, only when I click on the EditText for the second time then the calendar open. Please help me to resolve the issue(<code>why calendar don't open for the fi... | 18,267,997 | 20 | 11 | null | 2013-08-16 06:28:08.34 UTC | 4 | 2022-02-28 11:00:23.58 UTC | 2015-02-07 07:26:59.193 UTC | null | 3,496,570 | null | 2,618,323 | null | 1 | 25 | android|android-layout|android-datepicker | 70,325 | <p>I'll try to address your problem, but I am not completely sure about the first reason.</p>
<ol>
<li><p>The calendar opening only on the second click is because you are using an edittext. On the first click, your Edit Text will get focus. then the second click only calls the onClickListener.</p>
<p>If you are not l... |
19,920,052 | Disable the notification panel from being pulled down | <p>I am working on a lockscreen app and I need to disable the ability to pull down the notification/status bar at the top of the screen. There is an app called Holo Locker and what this app does is when the user pulls down from the top of the screen, it just sets the bar back up to the top of the screen and making it i... | 20,008,799 | 6 | 2 | null | 2013-11-12 02:58:01.46 UTC | 15 | 2020-04-09 17:36:43.763 UTC | 2013-11-15 05:37:44.927 UTC | null | 529,691 | null | 1,701,764 | null | 1 | 17 | android|android-notification-bar | 47,063 | <p>This is possible using reflection. There are plenty of problems though.</p>
<p>There's no way to check if the notification panel is open, or opening. So, we'll have to rely on <code>Activity#onWindowFocusChanged(boolean)</code>. And this is where the problems begin. </p>
<p>What the method does:</p>
<blockquote>
... |
27,604,431 | Handling a timer in React/Flux | <p>I'm working on an application where I want a timer to countdown from, say, 60 seconds to 0 and then change some content, after which the timer restarts again at 60.</p>
<p>I have implemented this in React and Flux but since I'm new to this, I'm still running into some problems.</p>
<p>I now want to add a start/sto... | 27,666,235 | 3 | 5 | null | 2014-12-22 14:15:54.783 UTC | 10 | 2015-03-20 18:34:44.497 UTC | null | null | null | null | 613,721 | null | 1 | 17 | javascript|reactjs|reactjs-flux | 19,845 | <p>I ended up downloading your code and implementing the start/stop/reset feature you wanted. I think that's probably the best way to explain things - to show code that you can run and test along with some comments.</p>
<p>I actually ended up with two implementations. I'll call them Implementation A and Implementation... |
27,541,290 | bug of autocorrelation plot in matplotlib‘s plt.acorr? | <p>I am plotting autocorrelation with python. I used three ways to do it: 1. pandas, 2. matplotlib, 3. statsmodels. I found the graph I got from matplotlib is not consistent with the other two. The code is:</p>
<pre><code> from statsmodels.graphics.tsaplots import *
# print out data
print mydata.values
#1. pandas
... | 27,558,293 | 1 | 7 | null | 2014-12-18 07:29:34.357 UTC | 11 | 2014-12-19 00:55:59.397 UTC | 2014-12-18 10:50:45.343 UTC | null | 3,951,977 | null | 3,951,977 | null | 1 | 12 | python|matplotlib|pandas|statsmodels | 15,225 | <p>This is a result of different common definitions between statistics and signal processing. Basically, the signal processing definition assumes that you're going to handle the detrending. The statistical definition assumes that subtracting the mean is all the detrending you'll do, and does it for you.</p>
<p>First ... |
15,434,810 | RabbitMQ "Hello World" example gives "Connection Refused" | <p>II'm trying to make the "hello world" application from here: <a href="http://www.rabbitmq.com/tutorials/tutorial-one-java.html" rel="noreferrer">RabbitMQ Hello World</a></p>
<p>Here is the code of my producer class:</p>
<pre><code>package com.mdnaRabbit.producer;
import com.rabbitmq.client.ConnectionFactory;
impo... | 15,540,476 | 8 | 3 | null | 2013-03-15 14:22:31.99 UTC | 3 | 2020-11-18 17:13:26.943 UTC | 2017-05-23 12:32:29.133 UTC | null | -1 | null | 2,082,631 | null | 1 | 21 | java|exception-handling|rabbitmq | 43,331 | <p>To deal with it I installed RabbitMQ server. If rabbitmq-server is not installed this error will be thrown.
Make sure you have installed RabbitMQ server and it's up and running by hitting <a href="http://localhost:15672/" rel="noreferrer">http://localhost:15672/</a></p> |
15,460,279 | How do I setup nested views in AngularJS? | <p>I have an application with various <em>screens</em>. Each screen is assigned a URL, such as <code>#</code>, <code>mails</code>, <code>contacts</code>, and so on.</p>
<p>In my main HTML file I have an <code>ng-view</code> element which updates according to the route the user selects. So far, so good.</p>
<p>Now som... | 15,495,104 | 2 | 4 | null | 2013-03-17 11:32:22.307 UTC | 10 | 2016-02-10 11:45:39.773 UTC | null | null | null | null | 1,333,873 | null | 1 | 39 | uiview|angularjs|nested | 44,923 | <p><a href="https://github.com/angular-ui/ui-router">AngularJS ui-router</a> solved my issues :-)</p> |
43,740,513 | Typescript access dynamic property with [' '] syntax | <pre><code>export class Foo{
someproperty: string;
}
</code></pre>
<p>I am trying to understand why, when trying to access dynamic object property I can do the following as I saw on one of the answers here:</p>
<pre><code>let fooObj: foo = someObj['someproperty'];
</code></pre>
<p>but by doing this, I get an error... | 43,740,761 | 2 | 6 | null | 2017-05-02 14:30:42.987 UTC | 2 | 2022-01-29 14:22:26.147 UTC | 2017-05-23 10:31:33.987 UTC | null | -1 | null | 2,964,415 | null | 1 | 23 | javascript|typescript | 39,551 | <p>This is just a convention in TypeScript, available for convenience. If you want to access some arbitrary property that is not defined in the type signature of the object, you can use the <code>["foo"]</code> notation, and the type checker will not try to enforce that the instance you're accessing has such a property... |
38,189,660 | Two variables in Python have same id, but not lists or tuples | <p>Two variables in Python have the same <code>id</code>:</p>
<pre><code>a = 10
b = 10
a is b
>>> True
</code></pre>
<p>If I take two <code>list</code>s:</p>
<pre><code>a = [1, 2, 3]
b = [1, 2, 3]
a is b
>>> False
</code></pre>
<p>according to <a href="https://stackoverflow.com/questions/27460234/... | 38,189,759 | 4 | 5 | null | 2016-07-04 17:21:10.37 UTC | 29 | 2020-04-20 11:07:50.063 UTC | 2017-05-23 11:54:20.443 UTC | null | -1 | null | 6,548,439 | null | 1 | 55 | python|python-3.x|tuples|identity|python-internals | 17,906 | <p>Immutable objects don't have the same <code>id</code>, and as a mater of fact this is not true for any type of objects that you define separately. Generally speaking, every time you define an object in Python, you'll create a new object with a new identity. However, for the sake of optimization (mostly) there are s... |
9,402,658 | Delete selected item from JList | <p>Can anyone tell me a short way to delete the selected items from my <code>JList</code>?</p>
<p>I searched on google and here, but I found very many ways. Which way should I use?</p> | 9,402,948 | 3 | 6 | null | 2012-02-22 20:46:39.05 UTC | 2 | 2019-02-07 17:59:50.733 UTC | 2015-08-21 10:02:02.587 UTC | null | 4,370,109 | null | 1,173,452 | null | 1 | 16 | java|swing|jlist | 46,945 | <p>As @Andreas_D said, the data centered, more abstract ListModel is the solution. This can be a <a href="http://docs.oracle.com/javase/6/docs/api/javax/swing/DefaultListModel.html" rel="noreferrer">DefaultListModel</a>. You should explicitly set the model in the JList.
So (thanks to comment by @kleopatra):</p>
<pre><... |
8,952,688 | didSelectRowAtIndexPath: not being called | <p>I have a <code>UITableView</code> as a subview of my <code>UIScrollVIew</code>, which is the main view controlled by my <code>MainViewController</code>. </p>
<p>In MainViewController.h</p>
<pre><code>@interface MainViewController : UIViewController <UIGestureRecognizerDelegate, UITableViewDelegate, UITableViewD... | 9,248,827 | 14 | 4 | null | 2012-01-21 11:40:04.94 UTC | 26 | 2020-09-05 10:50:55.613 UTC | 2014-07-08 18:21:27.4 UTC | null | 1,053,564 | null | 1,053,564 | null | 1 | 60 | iphone|ios|uitableview|didselectrowatindexpath | 47,900 | <p>I have found the answer. I had a UITapGestureRecognizer set for myTableView's superView. This overrode the selection call. Credit to whoever suggested that that might be it. Your answer was deleted before I could mark it correct.</p>
<p>Set the <code>cancelsTouchesInView</code> property to <code>NO</code> on the ge... |
5,047,406 | Textbox Width Problems - ASP.NET | <p>I have a user control on a page of a website that generates a text box. The textbox has a width specified, but the text box is intermitently being shown at a much smaller width than is specified in the code. I asked the users to send me copies of the "view source" output so that I could compare good and bad results.... | 5,047,493 | 5 | 0 | null | 2011-02-18 22:51:10.997 UTC | 3 | 2016-09-15 04:14:00.547 UTC | 2011-02-18 23:03:22.293 UTC | null | 602,554 | null | 623,863 | null | 1 | 10 | asp.net|textbox|tags|coding-style | 50,655 | <p>Try setting the TextBox with in the CssClass, or as a style attribute parameter rather than using the Width attribute</p>
<pre><code><asp:TextBox id="ShortDescription" runat="server" CssClass="content" MaxLength="100" style="width: 800px" /></code></pre>
<pre><code><style>.content { width: 800px }</s... |
5,413,719 | Photoshop Custom Shape to SVG path string | <p>Is there any way to get the SVG path string off a Photoshop custom shape or path? Or is there another way to get/construct similar data? I'm looking to do something similar to this:</p>
<p><a href="http://raphaeljs.com/icons/" rel="noreferrer">http://raphaeljs.com/icons/</a></p> | 23,337,275 | 5 | 0 | null | 2011-03-24 01:28:18.793 UTC | 19 | 2019-10-29 11:34:36.863 UTC | 2014-11-18 10:03:53.133 UTC | null | 1,482,673 | null | 620,680 | null | 1 | 35 | vector|svg|raphael|photoshop | 60,890 | <p><strong>Update:</strong> in recent versions of Photoshop, there is a built-in option to export the image as SVG, which works well on paths and custom shapes. Just do:</p>
<blockquote>
<p>File -> Export -> Export as... and select SVG in the file settings.</p>
</blockquote>
<p><strong>Original Answer:</strong></p>... |
5,239,997 | Regex, how to match multiple lines? | <p>I'm trying to match the <code>From</code> line all the way to the end of the <code>Subject</code> line in the following:</p>
<pre><code>....
From: XXXXXX
Date: Tue, 8 Mar 2011 10:52:42 -0800
To: XXXXXXX
Subject: XXXXXXX
....
</code></pre>
<p>So far I have:</p>
<pre><code>/From:.*Date:.*To:.*Subject/m
</code></p... | 5,240,101 | 5 | 5 | null | 2011-03-09 00:19:48.61 UTC | 5 | 2015-08-12 21:14:31.927 UTC | 2015-08-12 21:14:31.927 UTC | null | 664,833 | null | 149,080 | null | 1 | 65 | ruby|regex|rubular | 63,180 | <p>You can use the <code>/m</code> modifier to enable multiline mode (i.e. to allow <code>.</code> to match newlines), and you can use <code>?</code> to perform non-greedy matching:</p>
<pre><code>message = <<-MSG
Random Line 1
Random Line 2
From: person@example.com
Date: 01-01-2011
To: friend@example.com
Subjec... |
5,046,771 | How to get today's Date? | <p>In other words, I want functionality that provides Joda-Time:</p>
<pre><code>today = today.withTime(0, 0, 0, 0);
</code></pre>
<p>but without Joda-Time, only with java.util.Date.</p>
<p>Methods such as .setHours() and etc. are deprecated. Is there are more correct way?</p> | 5,046,816 | 8 | 4 | null | 2011-02-18 21:28:59.397 UTC | 10 | 2018-11-27 23:52:58.993 UTC | 2011-02-18 22:54:00.9 UTC | null | 458,066 | null | 458,066 | null | 1 | 52 | java|date | 317,263 | <pre><code>Date today = new Date();
today.setHours(0); //same for minutes and seconds
</code></pre>
<p>Since the methods are deprecated, you can do this with <code>Calendar</code>:</p>
<pre><code>Calendar today = Calendar.getInstance();
today.set(Calendar.HOUR_OF_DAY, 0); // same for minutes and seconds
</code></pre>... |
5,204,082 | Is it possible in java make something like Comparator but for implementing custom equals() and hashCode() | <p>I have an array of objects and I want to concatenate it with another array of objects, except that objects that have same id's. That objects are used in many places in the system and don't have hash code or equals implemented. So I don't want to implement <code>hashCode()</code> and <code>equals()</code>, cause I'm ... | 5,204,242 | 8 | 5 | null | 2011-03-05 13:27:25.297 UTC | 15 | 2021-07-27 00:52:35.09 UTC | 2018-06-06 20:42:09.71 UTC | null | 632,293 | null | 260,894 | null | 1 | 61 | java|collections|equals|hashcode | 21,683 | <p>Yes it is possible to do such a thing. (And people have done it.) But it won't allow you to put your objects into a <code>HashMap</code>, <code>HashSet</code>, etc. That is because the standard collection classes expect the key objects themselves to provide the <code>equals</code> and <code>hashCode</code> methods... |
5,539,139 | Change/Get check state of CheckBox | <p>I just want to get/change value of CheckBox with JavaScript. Not that I cannot use jQuery for this. I've tried something like this but it won't work.</p>
<p>JavaScript function</p>
<pre><code> function checkAddress()
{
if (checkAddress.checked == true)
{
alert("a");
}
... | 5,539,186 | 11 | 0 | null | 2011-04-04 13:26:24.453 UTC | 7 | 2020-02-01 08:36:58.873 UTC | 2011-11-29 23:25:02.613 UTC | null | 15,168 | null | 440,611 | null | 1 | 61 | javascript|html | 224,864 | <p>Using <code>onclick</code> instead will work. In theory it may not catch changes made via the keyboard but all browsers do seem to fire the event anyway when checking via keyboard.</p>
<p>You also need to pass the checkbox into the function:</p>
<pre><code>function checkAddress(checkbox)
{
if (checkbox.checked... |
5,284,646 | Rank items in an array using Python/NumPy, without sorting array twice | <p>I have an array of numbers and I'd like to create another array that represents the rank of each item in the first array. I'm using Python and NumPy.</p>
<p>For example:</p>
<pre><code>array = [4,2,7,1]
ranks = [2,1,3,0]
</code></pre>
<p>Here's the best method I've come up with:</p>
<pre><code>array = numpy.arr... | 5,284,703 | 11 | 1 | null | 2011-03-12 18:52:11.203 UTC | 36 | 2022-06-19 16:11:50.763 UTC | 2019-05-28 14:02:38.85 UTC | null | 202,229 | null | 401,818 | null | 1 | 137 | python|sorting|numpy | 121,970 | <p>Use <em>advanced indexing</em> on the left-hand side in the last step:</p>
<pre><code>array = numpy.array([4,2,7,1])
temp = array.argsort()
ranks = numpy.empty_like(temp)
ranks[temp] = numpy.arange(len(array))
</code></pre>
<p>This avoids sorting twice by inverting the permutation in the last step.</p> |
16,785,579 | java.sql.SQLException: Io exception: Connection reset by peer: socket write error | <p>I am using oracle 11g,hibernate 3 and jsf2.I deployed my application on was7.Every thing is going well but when i try to login after 5-6 hours it is gives me error</p>
<pre><code>ERROR org.hibernate.util.JDBCExceptionReporter - Io exception: Connection reset by peer: socket write error
[5/28/13 11:31:25:048 IST] 00... | 16,785,889 | 3 | 2 | null | 2013-05-28 06:52:52.097 UTC | 2 | 2013-08-06 06:56:15.613 UTC | 2013-08-06 06:51:16.303 UTC | null | 314,291 | null | 2,427,229 | null | 1 | 7 | java|database | 39,234 | <p>You are probably facing a database connection timeout. On every databases there is a timeout when a connection is open and there is no activity for a certain period. You need a connection pool manager.</p>
<p>If you install <code>c3p0</code> and configure it correctly it will allow hibernate to keep your connection... |
41,331,631 | Why command "php artisan serve" not working | <p>I started Laravel at this path:</p>
<pre><code>C:\Users\Mad\Work\trunk\product\backend\v1.2.1\laravel
</code></pre>
<p>but it is not working, it is not starting. </p>
<p>Please give me suggestions how I will do it ?</p> | 41,336,685 | 10 | 3 | null | 2016-12-26 12:54:32.467 UTC | 9 | 2022-01-20 13:07:50.143 UTC | 2016-12-27 17:35:31.193 UTC | null | 7,205,060 | null | 7,205,060 | null | 1 | 16 | laravel|angular | 84,472 | <p>try</p>
<pre><code>php -S localhost:8000 -t public/
</code></pre>
<p>source : <a href="http://allbitsnbytes.com/posts/php-artisan-serve-not-working/" rel="noreferrer">http://allbitsnbytes.com/posts/php-artisan-serve-not-working/</a></p> |
12,524,920 | Set Text Color for textView Android | <p>In the string.xml file i use the following tag</p>
<pre><code> <string name="CodeColor" >"#0000ff"</string>
</code></pre>
<p>If I use</p>
<pre><code> textview1.setTextColor(Color.RED);
</code></pre>
<p>it works, but when I use </p>
<pre><code> textview1.setTextColor(TextViewStyles.this.getResources... | 12,524,948 | 8 | 0 | null | 2012-09-21 05:47:17.41 UTC | 5 | 2018-07-24 12:36:20.407 UTC | null | null | null | null | 928,712 | null | 1 | 9 | android|colors|textview | 86,739 | <p>You need to create a set of styles in your xml (regularly in res/values/styles.xml)</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="gray">#eaeaea</color>
<color name="titlebackgroundcolor">#00abd7</color>
<color name="titlecolor">#... |
12,142,174 | Run a python script with arguments | <p>I want to call a Python script from C, passing some arguments that are needed in the script.</p>
<p>The script I want to use is mrsync, or <a href="http://sourceforge.net/projects/mrsync/">multicast remote sync</a>. I got this working from command line, by calling:</p>
<pre><code>python mrsync.py -m /tmp/targets.l... | 12,185,376 | 2 | 0 | null | 2012-08-27 12:40:56.677 UTC | 13 | 2015-11-15 18:17:46.593 UTC | 2012-09-03 18:50:57.613 UTC | null | 458,741 | null | 960,585 | null | 1 | 24 | python|c|eclipse | 35,939 | <p>Seems like you're looking for an answer using the python development APIs from Python.h. Here's an example for you that should work:</p>
<pre><code>#My python script called mypy.py
import sys
if len(sys.argv) != 2:
sys.exit("Not enough args")
ca_one = str(sys.argv[1])
ca_two = str(sys.argv[2])
print "My command... |
12,165,002 | How to work with infinity arguments in a function (like PHP's isset()) | <p>You know how PHP's <code>isset()</code> can accept multiple (no limit either) arguments?</p>
<p>Like I can do:</p>
<pre><code>isset($var1,$var2,$var3,$var4,$var5,$var6,$var7,$var8,$var9,$var10,$var11);
//etc etc
</code></pre>
<p>How would I be able to do that in my own function? How would I be able to work with i... | 12,165,045 | 4 | 0 | null | 2012-08-28 18:07:14.567 UTC | 4 | 2014-11-04 13:44:55.127 UTC | 2012-09-06 16:02:01.667 UTC | user849137 | null | user849137 | null | null | 1 | 29 | php|function|parameters|parameter-passing|param | 14,633 | <p><a href="http://php.net/manual/en/function.func-get-args.php"><code>func_get_args</code></a> will do what you want:</p>
<pre><code>function infinite_parameters() {
foreach (func_get_args() as $param) {
echo "Param is $param" . PHP_EOL;
}
}
</code></pre>
<p>You can also use <code>func_get_arg</code>... |
12,161,541 | Work-around for failing "git svn clone" (requiring full history) | <p>I want to convert a Subversion repository sub-directory (denoted by <code>module</code> here) into a git repository with full history. There are many <code>svn copy</code> operations (Subversion people call them branches) in the history of my Subversion repository. The release policy has been that after each release... | 31,060,826 | 5 | 9 | null | 2012-08-28 14:29:24.697 UTC | 11 | 2016-03-21 03:47:33.657 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 709,646 | null | 1 | 30 | git|svn|git-svn | 29,345 | <p>I ran into this problem when I had identically-named subdirectories within branches or tags.</p>
<p>For example, I had tags <code>candidates/1.0.0</code> and <code>releases/1.0.0</code>, and this caused the documented error because subdirectory <code>1.0.0</code> appears within both <code>candidates</code> and <cod... |
12,265,421 | How can I password-protect my /sidekiq route (i.e. require authentication for the Sidekiq::Web tool)? | <p>I am using sidekiq in my rails application.
By Default, Sidekiq can be accessed by anybody by appending "/sidekiq" after the url.
I want to password protect / authenticate only the sidekiq part. How can i do that?</p> | 13,409,418 | 8 | 0 | null | 2012-09-04 14:16:46.963 UTC | 9 | 2021-10-05 14:57:47.293 UTC | 2015-05-07 15:49:07.707 UTC | null | 190,135 | null | 1,337,996 | null | 1 | 61 | ruby|ruby-on-rails-3|redis|rescue|sidekiq | 24,335 | <p>Put the following into your sidekiq initializer</p>
<pre><code>require 'sidekiq'
require 'sidekiq/web'
Sidekiq::Web.use(Rack::Auth::Basic) do |user, password|
# Protect against timing attacks:
# - See https://codahale.com/a-lesson-in-timing-attacks/
# - See https://thisdata.com/blog/timing-attacks-against-str... |
3,448,943 | Best design pattern for "undo" feature | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/49755/design-pattern-for-undo-engine">Design Pattern for Undo Engine</a> </p>
</blockquote>
<p>In general, how do you deal with supporting an "undo" feature in your application? I have worked on web apps and de... | 3,448,959 | 3 | 1 | null | 2010-08-10 12:35:07.603 UTC | 15 | 2010-08-10 12:45:13.477 UTC | 2017-05-23 11:33:13.66 UTC | null | -1 | null | 402,169 | null | 1 | 23 | design-patterns|undo | 43,653 | <p>I believe it should be <a href="http://en.wikipedia.org/wiki/Command_pattern" rel="noreferrer">Command</a> design pattern.</p>
<p>Here is <a href="http://www.codeproject.com/KB/architecture/UndoRedoPart2.aspx" rel="noreferrer">article</a> about multilevel Undo/Redo with Command pattern.</p>
<p>EDIT: Here is <a hre... |
3,538,728 | What is the difference between a background and foreground service? | <p>I am currently writing my first Android application and I keep running into references to background and foreground services. Since I intend on using a service in my application I was hoping to get a clarification between the two and how they are used.</p> | 3,538,859 | 3 | 0 | null | 2010-08-21 20:01:49.447 UTC | 11 | 2021-08-01 08:15:59.703 UTC | 2021-08-01 08:15:59.703 UTC | null | 4,057,416 | null | 420,377 | null | 1 | 58 | android|android-service|background-service|foreground-service | 68,907 | <p>Perhaps this will answer your question:<br></p>
<blockquote>
<p>A started service can use the startForeground API to put the service
in a foreground state, where the system considers it to be something
the user is actively aware of and thus not a candidate for killing
when low on memory. By default services... |
3,718,125 | Notification alert similar to how stackoverflow functions | <p>How does stackoverflow create the slidedown effect to alert a user of a change ? </p> | 3,718,155 | 4 | 0 | null | 2010-09-15 13:35:54.567 UTC | 11 | 2014-09-16 01:35:10.87 UTC | 2014-09-16 01:35:10.87 UTC | null | 1,172,451 | null | 364,114 | null | 1 | 7 | javascript|css | 2,392 | <p>Stack Overflow uses the <a href="http://jQuery.com" rel="noreferrer">jQuery framework</a>, which has a method to show a hidden element using a simple animation, something like:</p>
<pre><code>$('#notification-bar').show('slow');
</code></pre>
<p><a href="http://api.jquery.com/show/" rel="noreferrer">http://api.jqu... |
20,810,378 | Should I mark a compiler-generated constructor as constexpr? | <p>Is there a difference between doing:</p>
<pre><code>X() = default;
</code></pre>
<p>and</p>
<pre><code>constexpr X() = default;
</code></pre>
<p>Default-constructing the class within constant expressions work fine, so is there a difference between these two examples? Should I use one over the other?</p> | 20,810,439 | 1 | 5 | null | 2013-12-28 02:26:22.867 UTC | 6 | 2013-12-28 02:47:00.7 UTC | null | null | null | null | 1,935,708 | null | 1 | 33 | c++|c++11 | 2,035 | <p>Since the implicit constructor is actually <code>constexpr</code> in your case…</p>
<blockquote>
<p><code>[C++11: 12.1/6]:</code> <em>[..]</em> If that user-written default constructor would satisfy the requirements of a <code>constexpr</code> constructor (7.1.5), the implicitly-defined default constructor... |
22,406,478 | remove blur effect on child element | <p>I have a <code><div></code> with an background-image with blur effect.</p>
<pre><code>-webkit-filter: blur(3px);
-moz-filter: blur(3px);
-o-filter: blur(3px);
-ms-filter: blur(3px);
filter: blur(3px);
</code></pre>
<p>The only problem is that all the Child elements also get the blur effect. Is it possible to... | 22,406,621 | 3 | 4 | null | 2014-03-14 13:33:29.56 UTC | 5 | 2021-08-19 06:57:07.1 UTC | null | null | null | null | 3,305,290 | null | 1 | 24 | html|css | 58,902 | <p>Create a div inside content & give bg image & blur effect to it. & give it z-index less the the opacity div, something like this.</p>
<pre><code><div class="content">
<div class="overlay"></div>
<div class="opacity">
<div class="image">
<img s... |
22,204,836 | Regex to find 3 out of 4 conditions | <p>My client has requested that passwords on their system must following a specific set of validation rules, and I'm having great difficulty coming up with a "nice" regular expression.</p>
<p>The rules I have been given are...</p>
<ul>
<li>Minimum of 8 character</li>
<li>Allow any character</li>
<li>Must have at leas... | 22,205,697 | 4 | 7 | null | 2014-03-05 17:26:03.3 UTC | 5 | 2019-02-28 14:21:24.847 UTC | 2014-03-05 17:56:34.507 UTC | null | 930,393 | null | 930,393 | null | 1 | 33 | regex|passwords | 12,581 | <p>It's not much of a better solution, but you can reduce <code>[^a-zA-Z0-9]</code> to <code>[\W_]</code>, since a word character is all letters, digits and the underscore character. I don't think you can avoid the alternation when trying to do this in a single regex. I think you have pretty much have the best solutio... |
10,915,770 | Localization with bean validation in JSF | <p>I made a MVC based website using JSF 2.0 and RichFaces 4. Every input text validation is been done using bean validation annotations. I am using Hibernate Validator as bean validation implementation.</p>
<p>How can I display a localized message?</p>
<p>If I use</p>
<pre><code>@NotNull(message="<h:outputText va... | 10,915,876 | 2 | 0 | null | 2012-06-06 14:00:56.55 UTC | 9 | 2015-04-24 17:04:36.363 UTC | 2012-06-06 14:11:12.043 UTC | null | 157,882 | null | 1,346,690 | null | 1 | 10 | java|jsf-2|localization|richfaces|bean-validation | 8,235 | <p>You should and can not put JSF tags in the message. Also, JSF's own resource bundle won't be used to resolve localized validation messages. JSR303 bean validation is a completely separate API unrelated to JSF. </p>
<p>To internationalize JSR303 bean validation messages, you need to create a separate <code>Validatio... |
11,088,292 | No vimrc, gvimrc and .vim on mac | <p>There are no <code>.vimrc</code>, <code>.gvimrc</code> files and <code>.vim/</code> directory on my mac, and so I can't install any script. And when I create a folder <code>.vim/</code> and <code>.vim/plugin</code> and paste any script in there, it doesn't work.
Sorry for my english.</p> | 11,089,347 | 3 | 2 | null | 2012-06-18 17:51:26.343 UTC | 9 | 2016-01-04 04:29:38.777 UTC | 2012-06-18 19:33:45.51 UTC | null | 630,160 | null | 1,464,374 | null | 1 | 13 | macos|vim | 28,142 | <p>You <em>must</em> create those files and folder yourself:</p>
<ol>
<li><p>Open Terminal.app (found under <code>/Applications/Utilities/</code>).</p></li>
<li><p>At the prompt, a <code>$</code>, type each of these lines followed by <code><Enter></code> (don't type the <code>$</code>):</p>
<pre><code>$ touch .... |
10,889,909 | DIV :after - add content after DIV | <p><a href="https://i.stack.imgur.com/ngSMr.png"><img src="https://i.stack.imgur.com/ngSMr.png" alt="Website layout"></a></p>
<p>I'm designing a simple website and I have a question.
I want after all <code><div></code> tags with <code>class="A"</code> to have a image separator on the bottom, right after the <cod... | 10,889,931 | 1 | 1 | null | 2012-06-04 23:54:13.42 UTC | 1 | 2015-08-07 02:36:00.073 UTC | 2015-08-07 02:36:00.073 UTC | null | 875,941 | null | 470,664 | null | 1 | 32 | css|html | 138,155 | <p>Position your <code><div></code> absolutely at the bottom and don't forget to give <code>div.A</code> a <code>position: relative</code> - <a href="http://jsfiddle.net/TTaMx/" rel="noreferrer">http://jsfiddle.net/TTaMx/</a></p>
<pre><code> .A {
position: relative;
margin: 40px 0;
hei... |
10,912,151 | HttpClient get status code | <p>Using Apache HttpClient 4.1.3 and trying to get the status code from an <code>HttpGet</code>:</p>
<pre><code>HttpClient client = new DefaultHttpClient();
HttpGet response = new HttpGet("http://www.example.com");
ResponseHandler<String> handler = new BasicResponseHandler();
String body = client.execute(respons... | 10,912,260 | 3 | 0 | null | 2012-06-06 10:08:45.943 UTC | 1 | 2015-08-31 21:44:05.693 UTC | 2013-10-16 07:41:26.83 UTC | null | 391,445 | null | 892,029 | null | 1 | 42 | java|apache-httpclient-4.x | 93,083 | <p><strong>EDIT:</strong></p>
<p>Try with:</p>
<pre><code>HttpResponse httpResp = client.execute(response);
int code = httpResp.getStatusLine().getStatusCode();
</code></pre>
<p>The HttpStatus should be 200 ( <code>HttpStatus.SC_OK</code> )</p>
<p>(I've read too fast the problem!)</p>
<hr>
<p>Try with:</p>
<pre>... |
11,455,667 | Are there any offline HTML CSS JavaScript editors like JSFiddle, jsbin, codepen etc.? | <p>Are there any offline tools like JSFiddle.net to play with JavaScript, HTML, CSS <strong>without Internet</strong> in the fashion of JSFiddle.net?</p>
<p><img src="https://i.stack.imgur.com/NI7nA.jpg" alt="enter image description here"></p> | 11,455,779 | 6 | 11 | null | 2012-07-12 15:49:24.007 UTC | 28 | 2022-02-08 05:55:38.337 UTC | 2018-07-01 08:20:54.61 UTC | null | 3,773,011 | null | 84,201 | null | 1 | 50 | javascript|html|css | 30,296 | <p>You can install the excellent <a href="http://jsbin.com/#javascript,html,live" rel="noreferrer">JSBin</a> locally.</p>
<p><a href="https://github.com/remy/jsbin/wiki/How-to-install-JS-Bin-in-your-own-environment" rel="noreferrer">https://github.com/remy/jsbin/wiki/How-to-install-JS-Bin-in-your-own-environment</a></... |
13,216,554 | What does wait() do on Unix? | <p>I was reading about the <code>wait()</code> function in a Unix systems book. The book contains a program which has <code>wait(NULL)</code> in it. I don't understand what that means. In other program there was</p>
<pre><code>while(wait(NULL)>0)
</code></pre>
<p>...which also made me scratch my head.</p>
<p>Can... | 13,216,585 | 3 | 1 | null | 2012-11-04 06:24:42.333 UTC | 5 | 2016-11-15 18:47:06.793 UTC | 2012-11-04 06:27:26.803 UTC | null | 23,897 | null | 1,725,372 | null | 1 | 7 | c|unix|ubuntu|wait | 53,004 | <p>man <a href="http://linux.die.net/man/2/wait">wait(2)</a></p>
<blockquote>
<p>All of these system calls are used to wait for state changes in
a child of the calling process, and obtain information about the child
whose state has changed. A state change is considered to be: the child terminated; the chil... |
12,844,137 | Spring, working with @Configuration and @Bean annotations | <p>I have a code:</p>
<pre><code>@Configuration
public class BeanSample {
@Bean(destroyMethod = "stop")
public SomeBean someBean() throws Exception {
return new SomeBean("somebean name1");
}
class SomeBean {
String name;
public SomeBean(String name) {
this.name ... | 12,844,221 | 3 | 0 | null | 2012-10-11 16:20:26.42 UTC | 4 | 2012-10-11 17:46:41.65 UTC | 2012-10-11 17:46:41.65 UTC | null | 369,759 | null | 369,759 | null | 1 | 9 | java|spring|annotations | 46,478 | <p>First, if you use the Java config, you have to instantiate your context like this:</p>
<pre><code>new AnnotationConfigApplicationContext(BeanSample.class)
</code></pre>
<p>Second, the <code>@Configuration</code> annotation doesn't make a bean out of the class that is annotated. Only the <code>@Bean</code> methods ... |
12,782,373 | html select option SELECTED | <p>I have in my php</p>
<pre><code>$sel = "
<option> one </option>
<option> two </option>
<option> thre </option>
<option> four </option>
";
</code></pre>
<p>let say I have an inline URL = <code>site.php?sel=one</code></p>
<p>if I didn't saved those opt... | 12,782,476 | 6 | 3 | null | 2012-10-08 13:04:57.93 UTC | 7 | 2022-08-31 16:04:36.16 UTC | 2022-08-31 16:04:36.16 UTC | null | 1,007,220 | null | 1,557,430 | null | 1 | 13 | php|html|html-select | 169,396 | <p>Just use the array of options, to see, which option is currently selected.</p>
<pre><code>$options = array( 'one', 'two', 'three' );
$output = '';
for( $i=0; $i<count($options); $i++ ) {
$output .= '<option '
. ( $_GET['sel'] == $options[$i] ? 'selected="selected"' : '' ) . '>'
... |
13,005,112 | How to activate combobox on first click (Datagridview) | <p>In winforms, you need to click the combobox twice to properly activate it - the first time to focus it, the second time to actually get the dropdown list.</p>
<p>How do I change this behavior so that it activates on the very first click?</p>
<p>This is for DATAGRIDVIEW combobox.</p> | 26,530,645 | 6 | 3 | null | 2012-10-22 04:53:52.467 UTC | 10 | 2020-06-24 10:16:04.417 UTC | 2018-08-20 04:50:46.443 UTC | null | 647,612 | null | 1,455,529 | null | 1 | 43 | c#|.net|winforms|datagridview|combobox | 44,588 | <p>I realize this is an old question, but I figured I would give my solution to anyone out there that may need to be able to do this.</p>
<p>While I couldn't find any answers to do exactly this... I did find an <a href="https://stackoverflow.com/a/242760/4000801">answer</a> to a different question that helped me.</p>
... |
12,740,967 | How do you add pseudo classes to elements using jQuery? | <p>In CSS, when you hover your mouse over an element, you can specify views for it using the :hover pseudo class:</p>
<pre><code>.element_class_name:hover {
/* stuff here */
}
</code></pre>
<p>How can you use jquery to add or "turn on" this pseudo class? Typically in jQuery if you want to add a class you would do... | 12,741,013 | 4 | 3 | null | 2012-10-05 06:47:02.123 UTC | 8 | 2020-04-21 17:01:45.17 UTC | 2012-10-05 06:50:26.537 UTC | null | 106,224 | null | 722,890 | null | 1 | 47 | jquery|css|pseudo-class | 68,891 | <p>You can't force a certain pseudo-class to apply using jQuery. That's not how pseudo-classes (especially dynamic pseudo-classes) work, since they're designed to select based on information that cannot be expressed via the DOM (<a href="http://www.w3.org/TR/selectors/#pseudo-classes">spec</a>).</p>
<p>You have to spe... |
12,695,474 | How to access environment variables in an Expect script? | <p>I would like to access the PATH environment variable inside an expect script.</p>
<p>How can I achieve that ?</p>
<p>My actual script is :</p>
<pre><code>#!/usr/bin/expect
set timeout 300
send "echo $PATH\r"
</code></pre>
<p>and its ouput is :</p>
<pre><code>can't read "PATH": no such variable
while executi... | 12,699,077 | 4 | 0 | null | 2012-10-02 17:45:45.797 UTC | 5 | 2022-08-18 22:17:01.427 UTC | null | null | null | null | 413,301 | null | 1 | 47 | environment-variables|expect | 32,675 | <p>Expect is an extension of <a href="http://www.tcl.tk">Tcl</a>. Tcl access enviroment variables via the global <a href="http://tcl.tk/man/tcl8.5/TclCmd/tclvars.htm#M4"><code>env</code> array</a>:</p>
<pre><code>send_user "$env(PATH)\n"
</code></pre> |
13,112,280 | Mercurial (hg) equivalent of git reset (--mixed or --soft) | <p>what would be an equivalent mercurial command (or workflow) for </p>
<pre><code>git reset --mixed HEAD^
</code></pre>
<p>or </p>
<pre><code>git reset --soft HEAD^
</code></pre>
<p>i.e. I want leave the working tree intact but get the repository back into the state it was before the last commit. Surprisingly I d... | 19,064,016 | 2 | 1 | null | 2012-10-28 19:36:12.74 UTC | 17 | 2020-10-12 17:14:16.927 UTC | 2012-10-28 21:27:01.463 UTC | null | 371,137 | null | 371,137 | null | 1 | 54 | mercurial | 20,556 | <p>The right way to replicate <code>git reset --soft HEAD^</code> (undo the current commit but keep changes in the working copy) is:</p>
<pre><code>hg strip --keep -r .
</code></pre>
<p><code>-1</code> will only work if the commit you want to strip is the very last commit that entered the repository. <code>.</code> r... |
12,973,777 | How to run a shell script at startup | <p>On an <a href="https://en.wikipedia.org/wiki/Amazon_S3" rel="noreferrer">Amazon S3</a> Linux instance, I have two scripts called <code>start_my_app</code> and <code>stop_my_app</code> which start and stop <em><a href="https://www.npmjs.com/package/forever" rel="noreferrer">forever</a></em> (which in turn runs my Nod... | 12,973,826 | 22 | 3 | null | 2012-10-19 11:56:39.327 UTC | 188 | 2022-07-22 09:31:13.857 UTC | 2019-12-30 23:46:08.357 UTC | null | 63,550 | null | 1,113,023 | null | 1 | 463 | linux|node.js|init.d|forever | 1,302,067 | <p>The file you put in <code>/etc/init.d/</code> have to be set to executable with:</p>
<pre><code>chmod +x /etc/init.d/start_my_app
</code></pre>
<p>As pointed out by @meetamit, if it still does not run you might have to create a symbolic link to the file in <code>/etc/rc.d/</code></p>
<pre><code>ln -s /etc/init.d/sta... |
16,619,274 | Cuda gridDim and blockDim | <p>I get what <code>blockDim</code> is, but I have a problem with <code>gridDim. Blockdim</code> gives the size of the block, but what is <code>gridDim</code>? On the Internet it says <code>gridDim.x</code> gives the number of blocks in the x coordinate.</p>
<p>How can I know what <code>blockDim.x * gridDim.x</code> g... | 16,619,633 | 4 | 0 | null | 2013-05-17 23:38:37.21 UTC | 33 | 2022-05-18 17:56:13.47 UTC | 2019-02-27 07:43:55.367 UTC | null | 8,464,442 | null | 2,354,356 | null | 1 | 59 | cuda | 90,756 | <ul>
<li><code>blockDim.x,y,z</code> gives the number of threads in a block, in the
particular direction</li>
<li><code>gridDim.x,y,z</code> gives the number of blocks in a grid, in the
particular direction</li>
<li><code>blockDim.x * gridDim.x</code> gives the number of threads in a grid (in the x direction, in this c... |
25,647,454 | How to pass parameters using ui-sref in ui-router to the controller | <p>I need to pass and receive two parameters to the state I want to transit to using <code>ui-sref</code> of ui-router.</p>
<p>Something like using the link below for transitioning the state to <code>home</code> with <code>foo</code> and <code>bar</code> parameters:</p>
<pre><code><a ui-sref="home({foo: 'fooVal... | 25,647,714 | 3 | 4 | null | 2014-09-03 14:50:39.583 UTC | 125 | 2022-06-03 14:45:03.45 UTC | 2022-06-03 14:45:03.45 UTC | null | 6,291,976 | null | 411,449 | null | 1 | 378 | javascript|html|angularjs|angular-ui-router|angular-ui | 385,154 | <p>I've created an <a href="http://plnkr.co/edit/r2JhV4PcYpKJdBCwHIWS?p=preview" rel="noreferrer">example</a> to show how to. Updated <code>state</code> definition would be:</p>
<pre><code> $stateProvider
.state('home', {
url: '/:foo?bar',
views: {
'': {
templateUrl: 'tpl.home.html',... |
25,763,896 | Running app gives 2 app icons in Android Studio | <p>I am running an app in Android Studio and it gives 2 app icons in Androi Studio.</p>
<p>Also, I have moved from Eclipse to Android Studio and now I'm having trouble with how to make the color of logcat same as in Eclipse.</p>
<p>My question is that there are 2 app icons when I run the app, and when I uninstall it,... | 25,778,663 | 8 | 7 | null | 2014-09-10 11:11:54.997 UTC | 7 | 2022-08-03 07:32:08.897 UTC | 2018-12-08 06:52:01.87 UTC | null | 10,589,041 | null | 3,974,048 | null | 1 | 49 | android|android-studio | 30,472 | <p>I got it! yes at last , i have to study gradles and stuff.</p>
<p>Actually I have 2 android projects inside the Project, one is a library and the other one is the main app.</p>
<p>I found out that when i imported those projects Android Studio (I exported the lib to gradle build from eclipse) doesn't care if that i... |
25,444,328 | What does the smiley face ":)" mean in CSS? | <p>I spotted this CSS code in a project:</p>
<pre><code>html, body { :)width: 640px;}
</code></pre>
<p>I have been around with CSS for a long time now but I never saw this ":)" code before. Does it mean anything or is it just a typo?</p> | 25,444,600 | 2 | 8 | null | 2014-08-22 09:56:28.953 UTC | 62 | 2022-09-22 19:04:02.91 UTC | 2022-09-22 19:04:02.91 UTC | null | 2,756,409 | null | 284,577 | null | 1 | 322 | css | 35,002 | <p>From an <a href="http://www.javascriptkit.com/dhtmltutors/csshacks3.shtml" rel="noreferrer">article at javascriptkit.com</a>, that's applied for <strong>IE 7</strong> and earlier versions:</p>
<blockquote>
<p>if you add a non-alphanumeric character such as an asterisk (<code>*</code>) immediately before a propert... |
4,561,681 | How to select row in grid AFTER load grid? | <p>Model.getSelectionModel().selectRow(0) not work ...</p> | 4,561,965 | 2 | 2 | null | 2010-12-30 10:01:14.553 UTC | 1 | 2010-12-30 13:13:42.147 UTC | null | null | null | null | 418,507 | null | 1 | 6 | extjs | 41,381 | <pre><code>this.store = new Ext.data.Store({
...
listeners: {
load: function() {
this.grid.getSelectionModel().selectFirstRow();
},
scope: this
}
});
this.grid = new Ext.grid.GridPanel({
...
store: this.store
});
</code></pre>
<p>Something like this should work,... |
41,652,112 | Why would C have "fake arrays"? | <p>I'm reading <a href="http://web.mit.edu/~simsong/www/ugh.pdf" rel="noreferrer"><em>The Unix haters handbook</em></a> and in chapter 9 there's something I don't really understand:</p>
<blockquote>
<p>C doesn’t really have arrays either. It has something that looks like an array
but is really a pointer to a memor... | 41,652,311 | 5 | 11 | null | 2017-01-14 16:11:12.373 UTC | 8 | 2017-01-16 05:52:07.857 UTC | 2017-01-15 21:14:17.387 UTC | null | 792,066 | null | 7,391,374 | null | 1 | 30 | c|arrays | 2,163 | <p>I think the author’s point is that C arrays are really just a thin veneer on pointer arithmetic. The subscript operator is defined simply as <code>a[b] == *(a + b)</code>, so you can easily say <code>5[a]</code> instead of <code>a[5]</code> and do other horrible things like access the array past the last index.</p>
... |
9,815,901 | Display view above status bar? | <p>I recently saw an image of an app that was capable of displaying a view above the status bar and was also able to cover it with a view.</p>
<p>I know you can get a view right below the status bar from a view with align parent top. But how would you get a view on top of the status bar??</p>
<p><a href="http://tomba... | 13,653,075 | 4 | 3 | null | 2012-03-22 03:09:40.793 UTC | 10 | 2017-03-10 10:38:29.737 UTC | null | null | null | null | 1,190,019 | null | 1 | 10 | android|eclipse|view|statusbar | 19,561 | <p>The answer by @Sadeshkumar is incorrect for ICS and above (perhaps GB as well).</p>
<p>A view created with <code>TYPE_SYSTEM_ALERT</code> and <code>FLAG_LAYOUT_IN_SCREEN</code> is covered by the <code>StatusBar</code>.</p>
<p>To get an overlay on top of the <code>StatusBar</code>, you need to use <code>TYPE_SYSTEM... |
9,835,863 | Log user activities in ROR | <p>I have an application where there are two types of user currently, Admin and Vendor, and i want to log their activities like</p>
<pre><code>"TestAdmin" viewed transaction
"TestAdmin" added a new vendor
"TestAdmin" edited a Transaction
"TestVendor" added a new Transaction
"TestAdmin" approved Transaction
"TestAdmin... | 9,981,462 | 5 | 0 | null | 2012-03-23 08:11:21.727 UTC | 13 | 2019-07-13 18:38:28.537 UTC | 2012-03-23 09:20:35.593 UTC | null | 839,256 | null | 839,256 | null | 1 | 21 | ruby-on-rails | 15,973 | <p>Ok this is what i did...</p>
<p>First create table </p>
<pre><code>create_table "activity_logs", :force => true do |t|
t.string "user_id"
t.string "browser"
t.string "ip_address"
t.string "controller"
t.string "action"
t.string "params"
t.string "note"
t.datetime "created_at"
... |
9,897,345 | Pickle alternatives | <p>I am trying to serialize a large (~10**6 rows, each with ~20 values) list, to be used later by myself (so pickle's lack of safety isn't a concern).</p>
<p>Each row of the list is a tuple of values, derived from some SQL database. So far, I have seen <code>datetime.datetime</code>, strings, integers, and NoneType, b... | 9,897,487 | 8 | 2 | null | 2012-03-27 20:38:41.327 UTC | 8 | 2022-02-20 03:23:43.883 UTC | 2019-07-02 16:48:06.563 UTC | null | 1,079,075 | null | 1,032,006 | null | 1 | 33 | python|serialization | 38,440 | <p>I think you should give <a href="http://www.pytables.org/" rel="noreferrer">PyTables</a> a look. It should be ridiculously fast, at least faster than using an RDBMS, since it's very lax and doesn't impose any read/write restrictions, plus you get a better interface for managing your data, at least compared to pickli... |
10,065,287 | Why is ushort + ushort equal to int? | <p>Previously today I was trying to add two ushorts and I noticed that I had to cast the result back to ushort. I thought it might've become a uint (to prevent a possible unintended overflow?), but to my surprise it was an int (System.Int32).</p>
<p>Is there some clever reason for this or is it maybe because int is se... | 10,157,517 | 5 | 2 | null | 2012-04-08 18:32:17.413 UTC | 6 | 2018-12-19 05:05:23.623 UTC | 2018-12-19 05:05:23.623 UTC | null | 2,063,755 | null | 319,611 | null | 1 | 35 | c#|types|integer-arithmetic | 20,946 | <p>The simple and correct answer is "because the C# Language Specification says so".</p>
<p>Clearly you are not happy with that answer and want to know "why does it say so". You are looking for "credible and/or official sources", that's going to be a bit difficult. These design decisions were made a long time ago, 1... |
10,013,906 | Android - zoom in/out RelativeLayout with spread/pinch | <p>I have an activity with a <code>RelativeLayout</code> and a private class in it, which extends the <code>SimpleOnScaleGestureListener</code>. In the <code>onScale</code> method of the listener I'd like to zoom in/out of the whole layout (everything the user sees) with the user spreading/pinching his fingers.</p>
<p... | 10,029,320 | 4 | 1 | null | 2012-04-04 15:06:21.8 UTC | 18 | 2022-07-22 04:52:22.053 UTC | 2017-05-23 12:34:34.957 UTC | null | -1 | null | 1,137,282 | null | 1 | 37 | android|android-layout|android-animation | 55,588 | <p>So I created a subclass of <code>RelativeLayout</code> as described in the above mentioned topics. It looks like this:</p>
<pre><code>public class ZoomableRelativeLayout extends RelativeLayout {
float mScaleFactor = 1;
float mPivotX;
float mPivotY;
public ZoomableRelativeLayout(Context context) {
super(context... |
10,149,416 | Numpy modify array in place? | <p>I have the following code which is attempting to normalize the values of an <code>m x n</code> array (It will be used as input to a neural network, where <code>m</code> is the number of training examples and <code>n</code> is the number of features).</p>
<p>However, when I inspect the array in the interpreter after... | 10,149,508 | 4 | 0 | null | 2012-04-13 23:10:30.317 UTC | 7 | 2019-03-08 21:13:32.163 UTC | null | null | null | null | 155,268 | null | 1 | 40 | python|arrays|numpy|in-place | 40,024 | <p>If you want to apply mathematical operations to a numpy array in-place, you can simply use the standard in-place operators <code>+=</code>, <code>-=</code>, <code>/=</code>, etc. So for example:</p>
<pre><code>>>> def foo(a):
... a += 10
...
>>> a = numpy.arange(10)
>>> a
array([0, 1... |
9,953,295 | How to repair my mongodb? | <p>I can't seem to connect to Mongo DB, which I've installed as a Windows Service on my local machine. I've also built a little WPF application which communicates with MongoDB.
The errormessage: </p>
<p><em>Error: couldn't connect to server 127.0.0.1 shell/mongo.js:8
4
exception: connect failed
Unclean shutdown detec... | 9,953,305 | 7 | 1 | null | 2012-03-31 05:33:33.227 UTC | 20 | 2021-06-11 22:33:51.323 UTC | null | null | null | null | 219,167 | null | 1 | 45 | mongodb | 95,966 | <p>You should launch it with <code>--repair</code> flag.</p>
<pre><code>mongod --repair
</code></pre>
<p>After repair is finished, stop this one and launch it normally. <a href="https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption--repair" rel="noreferrer">Documentation on --repair option</a>.</p> |
8,306,237 | Android: Login with Twitter using Twitter4J | <p><strong>What I Have Tried:</strong></p>
<p>I already have registered an app in twitter and got Consumer Key and Secret.Even I got various codes to login with twitter.These are what I have tried from:</p>
<p><a href="http://thetechnib.blogspot.com/2011/01/android-sign-in-with-twitter.html" rel="noreferrer">http://t... | 8,307,443 | 3 | 2 | null | 2011-11-29 05:21:20.443 UTC | 9 | 2013-10-30 16:47:51.71 UTC | 2013-04-23 02:42:16.327 UTC | null | 427,309 | null | 867,603 | null | 1 | 6 | android|authentication|twitter-oauth|twitter4j | 17,639 | <p>It's because your app is registered as a desktop client.
To overwrite callback URL, your app need to be registered as a browser client.</p>
<p>Try configuring a dummy callback URL (http://example.com/ or whatever you want) at
https://dev.twitter.com/apps/[appid]/settings > Callback URL
and your app will be recogniz... |
11,991,007 | jQuery get the selected dropdown value on change | <p>I'm trying to get the value of a dropdown on change (and then change the values in a second dropdown).</p>
<p><strong>EDIT:</strong> Thanks for all the replies, i've updated to add the () but the code is returning nothing, not null or undefined just a blank alert window</p>
<p>However when I alert it out the attr(... | 11,991,041 | 6 | 2 | null | 2012-08-16 15:50:58.613 UTC | null | 2020-06-12 09:11:09.793 UTC | 2012-08-16 15:57:49.7 UTC | null | 900,659 | null | 900,659 | null | 1 | 12 | javascript|jquery | 79,473 | <p><a href="http://api.jquery.com/val/" rel="noreferrer"><code>val</code></a> is a method, not a property.</p>
<p>use it like <code>val()</code></p>
<p>If you are using it many places, i would assign it to a local variable and use it thereafter.</p>
<p>Also you can use the <a href="http://api.jquery.com/jQuery.no... |
11,773,433 | Android Master Detail Flow Example | <p><img src="https://i.stack.imgur.com/Fbl2e.png" alt="enter image description here"></p>
<p>I'm trying to implement a user interface like above and looking for a good tutorial to or code sample to learn it. Can someone help me to get this done</p> | 11,773,551 | 2 | 0 | null | 2012-08-02 08:09:12.66 UTC | 4 | 2013-11-08 15:14:28.86 UTC | null | null | null | null | 438,877 | null | 1 | 18 | android|android-layout | 42,895 | <p>If you are using Eclipse with ADT installed, you can create a new Activity (or Android Project) and select MasterDetailFlow as the template to be used for that activity. This will contain a Master Detail flow with a simple list of items.</p>
<p><strong>EDIT</strong></p>
<p>For an advanced list layout, you will nee... |
11,746,071 | How to split a multi-line string containing the characters "\n" into an array of strings in bash? | <p>
I have a <em>string</em> in the following format:</p>
<pre class="lang-none prettyprint-override"><code>I'm\nNed\nNederlander
I'm\nLucky\nDay
I'm\nDusty\nBottoms
</code></pre>
<p>I would like to move this to an array of strings line by line such that:</p>
<pre class="lang-none prettyprint-override"><code>$ echo ... | 11,746,174 | 2 | 2 | null | 2012-07-31 17:48:59.417 UTC | 4 | 2017-04-13 08:44:59.273 UTC | 2017-04-13 08:44:59.273 UTC | null | 1,062,281 | null | 446,554 | null | 1 | 22 | arrays|string|bash|escaping | 40,725 | <p>By default, the <code>read</code> builtin allows \ to escape characters. To turn off this behavior, use the <code>-r</code> option. It is not often you will find a case where you do not want to use <code>-r</code>. </p>
<pre><code>string="I'm\nNed\nNederlander
I'm\nLucky\nDay
I'm\nDusty\nBottoms"
arr=()
while read... |
11,666,385 | select document root using jquery | <p>I can select the body and html parts of the document using</p>
<pre><code>$('body')
</code></pre>
<p>and</p>
<pre><code>$('html')
</code></pre>
<p>respectively, but how do I select the document root?</p> | 11,666,422 | 3 | 2 | null | 2012-07-26 09:31:27.29 UTC | 2 | 2016-07-25 10:17:46.113 UTC | null | null | null | null | 246,622 | null | 1 | 22 | jquery|html|jquery-selectors|document-root | 55,520 | <p>Not sure what you mean, but to select the document you do</p>
<pre><code>$(document);
</code></pre>
<p>To get the contents of the document I'm guessing you need the documentElement, which is just the same as the <code><html></code> tag in most enviroments.</p>
<pre><code>$(document.documentElement);
</code>... |
11,661,503 | Django Caching for Authenticated Users Only | <h1>Question</h1>
<p>In Django, how can create a single cached version of a page (same for all users) that's only visible to authenticated users?</p>
<h2>Setup</h2>
<p>The pages I wish to cache are only available to authenticated users (they use <code>@login_required</code> on the view). These pages are the same for al... | 11,703,958 | 5 | 1 | null | 2012-07-26 02:34:50.08 UTC | 12 | 2022-09-01 23:50:31.46 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 1,006,036 | null | 1 | 23 | python|django|caching|heroku|memcached | 6,478 | <p>The default <code>cache_page</code> decorator accepts a variable called <code>key_prefix</code>. However, it can be passed as a string parameter only. So you can write your own decorator, that will dynamically modify this <code>prefix_key</code> based on the <code>is_authenticated</code> value. Here is an example:</... |
11,923,235 | scandir() to sort by date modified | <p>I'm trying to make <code>scandir();</code> function go beyond its written limits, I need more than the alpha sorting it currently supports. I need to sort the <code>scandir();</code> results to be sorted by modification date. </p>
<p>I've tried a few solutions I found here and some other solutions from different we... | 11,923,516 | 4 | 0 | null | 2012-08-12 15:10:15.367 UTC | 14 | 2021-05-21 04:01:02.103 UTC | 2018-01-17 15:23:20.777 UTC | null | 472,495 | null | 445,820 | null | 1 | 32 | php|arrays|sorting|scandir | 75,578 | <pre><code>function scan_dir($dir) {
$ignored = array('.', '..', '.svn', '.htaccess');
$files = array();
foreach (scandir($dir) as $file) {
if (in_array($file, $ignored)) continue;
$files[$file] = filemtime($dir . '/' . $file);
}
arsort($files);
$files = array_keys($files);... |
11,514,242 | Add CSS3 transition expand/collapse | <p>How do I add an expand/collapse transition?</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 showHide(shID) {
if (document.getElementById(shID)) {
if (d... | 11,837,673 | 5 | 1 | null | 2012-07-16 23:50:10.017 UTC | 13 | 2019-04-01 13:42:38.127 UTC | 2019-04-01 13:42:38.127 UTC | null | 2,756,409 | null | 876,960 | null | 1 | 56 | javascript|html|css | 212,531 | <p><a href="http://jsfiddle.net/9ccjE/" rel="noreferrer">This</a> is my solution that adjusts the height automatically:</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>functio... |
11,880,360 | How to implement a bitmask in php? | <p>I'm not sure if bitmask is the correct term. Let me explain:</p>
<p>In php, the <code>error_reporting</code> function can be called multiple ways:</p>
<pre><code>// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variab... | 11,880,410 | 4 | 0 | null | 2012-08-09 09:26:04.07 UTC | 35 | 2022-09-22 02:36:00.067 UTC | 2014-02-25 19:10:08.46 UTC | null | 321,731 | null | 755,692 | null | 1 | 91 | php|bitmask | 33,547 | <p>It's quite simple actually. First a bit of code to demonstrate how it can be implemented. If you don't understand anything about what this code is doing or how it works, feel free to ask additional questions in the comments:</p>
<pre><code>const FLAG_1 = 0b0001; // 1
const FLAG_2 = 0b0010; // 2
const FLAG_3 = 0b010... |
11,801,186 | CMake unable to determine linker language with C++ | <p>I'm attempting to run a cmake hello world program on Windows 7 x64 with both Visual Studio 2010 and Cygwin, but can't seem to get either to work. My directory structure is as follows:</p>
<pre><code>HelloWorld
-- CMakeLists.txt
-- src/
-- -- CMakeLists.txt
-- -- main.cpp
-- build/
</code></pre>
<p>I do a <code>cd ... | 11,802,004 | 10 | 3 | null | 2012-08-03 18:19:06.08 UTC | 19 | 2022-09-17 06:05:44.897 UTC | 2012-08-03 18:31:29.267 UTC | null | 374,691 | null | 374,691 | null | 1 | 123 | c++|c|cmake | 200,467 | <p>Try changing</p>
<pre><code>PROJECT(HelloWorld C)
</code></pre>
<p>into</p>
<pre><code>PROJECT(HelloWorld C CXX)
</code></pre>
<p>or just</p>
<pre><code>PROJECT(HelloWorld)
</code></pre>
<p>See: <a href="https://cmake.org/cmake/help/latest/command/project.html" rel="nofollow noreferrer">https://cmake.org/cmake/help/... |
11,876,238 | Simple Pivot Table to Count Unique Values | <p>This seems like a simple Pivot Table to learn with. I would like to do a count of unique values for a particular value I'm grouping on.</p>
<p>For instance, I have this:</p>
<pre><code>ABC 123
ABC 123
ABC 123
DEF 456
DEF 567
DEF 456
DEF 456
</code></pre>
<p>What I want is a pivot table that shows m... | 11,876,301 | 16 | 1 | null | 2012-08-09 03:09:56.63 UTC | 44 | 2021-01-12 09:35:45.797 UTC | 2014-03-07 04:49:47.443 UTC | null | 641,067 | null | 1,586,422 | null | 1 | 139 | excel|excel-formula|pivot-table | 886,889 | <p>Insert a 3rd column and in Cell <code>C2</code> paste this formula</p>
<pre><code>=IF(SUMPRODUCT(($A$2:$A2=A2)*($B$2:$B2=B2))>1,0,1)
</code></pre>
<p>and copy it down. Now create your pivot based on 1st and 3rd column. See snapshot</p>
<p><img src="https://i.stack.imgur.com/B0DTk.png" alt="enter image descript... |
20,310,000 | error: ISO C++ forbids in-class initialization of non-const static member | <p>this is the header file: employee.h</p>
<pre><code>#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <iostream>
#include <string>
using namespace std;
class Employee {
public:
Employee(const string &first, const string &last)
</code></pre>
<p>Overloaded Constructor</p>
<pre><code> : fir... | 20,310,041 | 2 | 5 | null | 2013-12-01 07:56:33.547 UTC | 5 | 2020-03-13 22:26:59.927 UTC | null | null | null | null | 3,053,929 | null | 1 | 22 | c++|static|compiler-errors|standards|iso | 58,558 | <p>The <em>initialization</em> of the static member <code>counter</code> must not be in the header file. </p>
<p>Change the line in the header file to</p>
<pre><code>static int counter;
</code></pre>
<p>And add the following line to your employee.cpp:</p>
<pre><code>int Employee::counter = 0;
</code></pre>
<p>Reas... |
3,917,601 | ffmpeg split avi into frames with known frame rate | <p>I posted this as comments under <a href="https://stackoverflow.com/questions/3002601/converting-avi-frames-to-jpgs-on-linux">this related thread</a>. However, they seem to have gone unnoticed =(</p>
<p>I've used</p>
<pre><code>ffmpeg -i myfile.avi -f image2 image-%05d.bmp
</code></pre>
<p>to split <code>myfile.av... | 3,917,648 | 4 | 0 | null | 2010-10-12 18:01:14.4 UTC | 10 | 2020-12-01 07:45:42.36 UTC | 2017-05-23 10:31:15.87 UTC | null | -1 | null | 278,793 | null | 1 | 26 | linux|image-processing|ffmpeg | 47,173 | <pre><code>ffmpeg -i myfile.avi -r 1000 -f image2 image-%07d.png
</code></pre>
<p>I am not sure outputting 150k bmp files will be a good idea. Perhaps png is good enough?</p> |
3,641,671 | The user instance login flag is not supported on this version of SQL Server. The connection will be closed | <p>Hi I am using sql server fulll edition.</p>
<p>any idea how should I solve this issue, I search on net but not found any helpful answer.</p>
<p>Thanks</p> | 3,641,691 | 4 | 1 | null | 2010-09-04 09:35:59.417 UTC | 5 | 2010-09-04 09:39:55.417 UTC | null | null | null | null | 479,291 | null | 1 | 30 | asp.net | 42,801 | <p>SQL Server 2005(Full Version) does not support the "user instance"(automatic creation of databases from code) directive in the connection string. Its a feature of sql server express edition.</p>
<p>Also if your connection string has user Instance attribute, then try removing the "User Instance=True;" </p> |
3,993,759 | PHP: how to get a list of classes that implement certain interface? | <p>I've got an interface</p>
<pre><code>interface IModule {
public function Install();
}
</code></pre>
<p>and some classes that implement this interface</p>
<pre><code>class Module1 implements IModule {
public function Install() {
return true;
}
}
class Module2 implements IModule {
public fu... | 3,993,796 | 5 | 1 | null | 2010-10-22 03:54:56.847 UTC | 11 | 2022-05-12 10:22:58.59 UTC | 2010-10-22 04:08:12.453 UTC | null | 244,415 | null | 244,415 | null | 1 | 48 | php|oop|class | 27,293 | <p>You can use PHP's <a href="http://us3.php.net/manual/en/reflectionclass.implementsinterface.php" rel="noreferrer"><code>ReflectionClass::implementsInterface</code></a> and <a href="http://php.net/manual/en/function.get-declared-classes.php" rel="noreferrer"><code>get_declared_classes</code></a> functions to accompli... |
3,267,213 | Send email from rails console | <p>I'm trying to send out some mails from the console on my production server, and they're not going out. I can't work out why. I have just your standard email setup with sendmail. When I call the Mailer.deliver_ method I get this back:</p>
<pre><code>#<TMail::Mail port=#<TMail::StringPort:id=0x3fe1c205dbcc> b... | 26,994,273 | 5 | 2 | null | 2010-07-16 16:58:37.517 UTC | 18 | 2022-06-21 19:56:03.63 UTC | 2022-06-21 19:56:03.63 UTC | null | 1,145,388 | null | 138,557 | null | 1 | 74 | ruby-on-rails|sendmail | 49,425 | <p>For Sending email from Rails Console first we have to execute this setting in console for action mailer settings.</p>
<pre><code>ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
authentication: 'plain',
enable_st... |
3,633,621 | How does Chrome know my geolocation? | <p>Chrome seems to be very accurate in detecting my location. How does it do it? Can you point me to the source code?</p> | 3,633,675 | 6 | 1 | null | 2010-09-03 06:57:31.67 UTC | 9 | 2016-03-03 15:09:15.177 UTC | 2010-09-03 07:03:29.223 UTC | null | 11,125 | null | 11,125 | null | 1 | 26 | html|google-chrome|geolocation | 20,915 | <p>Geolocation can be calculated based on:</p>
<ol>
<li>GPS (if available)</li>
<li>Available wi-fi networks and signal strengths</li>
<li>Available cell towers and signal strengths</li>
<li>IP Address lookup</li>
</ol>
<p>See the <a href="http://dev.w3.org/geo/api/spec-source.html" rel="noreferrer">W3C Geolocaton AP... |
3,932,230 | Oracle: SQL query that returns rows with only numeric values | <p>I have a field (column in Oracle) called X that has values like "a1b2c3", "abc", "1ab", "123", "156"</p>
<p>how do I write an sql query that returns me only the X that hold pure numerical values = no letters? from the example above would be „123“ and „156“</p>
<p>select X
from myTable
where ...??</p> | 3,932,261 | 6 | 0 | null | 2010-10-14 10:32:57.587 UTC | 20 | 2021-07-21 07:07:44.847 UTC | 2010-10-14 10:34:53.107 UTC | null | 21,234 | null | 26,817 | null | 1 | 46 | sql|oracle | 211,871 | <p>You can use the <code>REGEXP_LIKE</code> function as:</p>
<pre><code>SELECT X
FROM myTable
WHERE REGEXP_LIKE(X, '^[[:digit:]]+$');
</code></pre>
<p>Sample run:</p>
<pre><code>SQL> SELECT X FROM SO;
X
--------------------
12c
123
abc
a12
SQL> SELECT X FROM SO WHERE REGEXP_LIKE(X, '^[[:digit:]]+$');
X
-... |
3,426,089 | Fill ComboBox with List of available Fonts | <p>How can I fill a combo-box with a list of all the available fonts in the system?</p> | 3,426,133 | 7 | 2 | null | 2010-08-06 17:14:28.86 UTC | 4 | 2020-07-04 06:35:38.093 UTC | 2010-08-07 00:31:42.303 UTC | null | 158,455 | null | 158,455 | null | 1 | 48 | c#|winforms|fonts|windows-xp | 47,506 | <p>You can use <code>System.Drawing.FontFamily.Families</code> to get the available fonts.</p>
<pre><code>List<string> fonts = new List<string>();
foreach (FontFamily font in System.Drawing.FontFamily.Families)
{
fonts.Add(font.Name);
}
// add the fonts to your ComboBox here
</code></pre> |
3,666,306 | How to iterate UTF-8 string in PHP? | <p>How to iterate a UTF-8 string character by character using indexing?</p>
<p>When you access a UTF-8 string with the bracket operator <code>$str[0]</code> the utf-encoded character consists of 2 or more elements. </p>
<p>For example:</p>
<pre><code>$str = "Kąt";
$str[0] = "K";
$str[1] = "�";
$str[2] = "�";
$str[3]... | 3,666,326 | 7 | 8 | null | 2010-09-08 09:27:39.177 UTC | 21 | 2019-09-12 19:36:24.93 UTC | null | null | null | null | 139,594 | null | 1 | 52 | php|utf-8 | 19,061 | <p>Use <a href="http://www.php.net/manual/en/function.preg-split.php" rel="noreferrer">preg_split</a>. With <a href="http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php" rel="noreferrer">"u" modifier</a> it supports UTF-8 unicode.</p>
<pre><code>$chrArray = preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY... |
3,989,122 | Microsoft.Office.Interop.Excel really slow | <p>I am exporting a 1200 X 800 matrix (indexMatrix) to a excel file using the standard Microsoft.Office.Interop.Excel. The app works, just that it is really really really slow( even for the 100 x 100 matrix) . I also export in a text file through a TextWriter an it works almost instantly . Is there any way to export to... | 3,989,452 | 8 | 0 | null | 2010-10-21 15:28:40.783 UTC | 21 | 2019-11-08 06:03:53.397 UTC | 2010-10-21 15:39:12.38 UTC | null | 47,550 | null | 476,024 | null | 1 | 48 | c#|excel|interop | 53,045 | <p>You are updating individual cells. That's going to be very slow. If you think about it, each time you update a cell, an RPC call will be marshalled to the Excel process.</p>
<p>It will be <strong>much</strong> faster if you assign your two dimensional array of values to an Excel Range of the same dimensions in a ... |
3,483,514 | Why is client-side validation not enough? | <p>I saw <a href="http://livevalidation.com/examples" rel="noreferrer">here</a> that:</p>
<blockquote>
<p>As you probably already know, relying
on client-side validation alone is a
very bad idea. Always perform
appropriate server-side validation as
well.</p>
</blockquote>
<p>Could you explain why server-sid... | 3,483,524 | 14 | 5 | null | 2010-08-14 13:31:40.307 UTC | 13 | 2013-08-10 14:46:45.977 UTC | 2013-06-25 23:42:31.62 UTC | null | 247,243 | null | 247,243 | null | 1 | 41 | validation|server-side|client-side-validation | 12,544 | <p>Client-side validation - I assume you are talking about web pages here - relies on <a href="http://en.wikipedia.org/wiki/Javascript" rel="noreferrer">JavaScript</a>. </p>
<p>JavaScript powered validation can be turned off in the user's browser, fail due to a scripting error, or be maliciously circumvented without m... |
8,262,884 | Python C extension: Use extension PYD or DLL? | <p>I have a Python extension written in C and I wonder if I should use the file extension DLL or PYD under Windows. (And what would I use in Linux?)</p>
<p>Are there any differences (besides the filename)?</p>
<p>I found <a href="http://pyfaq.infogami.com/is-a-pyd-file-the-same-as-a-dll" rel="noreferrer">an unofficia... | 8,471,102 | 4 | 1 | null | 2011-11-24 22:03:18.203 UTC | 11 | 2020-08-21 22:59:07.377 UTC | 2011-12-15 13:17:37.92 UTC | null | 667,301 | null | 672,848 | null | 1 | 30 | python|python-c-extension|pyd | 30,834 | <p>pyd files are just dll files ready for python importing.</p>
<p>To distinguish them from normal dlls, I recommend .pyd not .dll in windows.</p>
<p>Here is the official doc about this issue:</p>
<p><a href="http://docs.python.org/faq/windows.html#is-a-pyd-file-the-same-as-a-dll" rel="noreferrer">http://docs.python... |
7,709,928 | JAXB vs DOM and SAX | <p>I have been using DOM for parsing my small xml docs for sometime.Afer reading about the JAXB (<a href="http://www.oracle.com/technetwork/articles/javase/index-140168.html" rel="noreferrer">http://www.oracle.com/technetwork/articles/javase/index-140168.html</a>), I'm planning to use JAXB instaed of DOM.</p>
<p>Pleas... | 7,710,721 | 6 | 0 | null | 2011-10-10 07:58:14.74 UTC | 15 | 2017-07-27 21:58:42.807 UTC | 2012-04-11 10:45:03.587 UTC | null | 1,106,053 | null | 987,265 | null | 1 | 27 | java|xml|performance|jaxb | 56,043 | <p>JAXB is not directly comparable to DOM and SAX. The Java DOM and SAX parsing APIs are lower-level APIs to parse XML documents, while JAXB (Java API for XML Binding) is a higher-level API for converting XML elements and attributes to a Java object hierarchy (and vice versa). Implementations of JAXB will most likely u... |
7,748,137 | Is it possible to select text on a Windows form label? | <p>Is it possible to highlight/select part of text in a Windows Form label control? I know its possible with RTFtextbox control but that using that control would be overkill as I need to create many instances of the label.</p> | 7,748,496 | 7 | 3 | null | 2011-10-13 00:31:30.35 UTC | 4 | 2020-03-11 23:10:25.43 UTC | 2011-10-13 01:41:59.8 UTC | null | 591,656 | null | 934,257 | null | 1 | 71 | c#|.net|asp.net|winforms|label | 54,610 | <p>Is it possible to select text on a Windows form label? - NO (At least no easy way without overriding Label.Paint method)</p>
<p>You can easily change a TextBox for this purpose.</p>
<pre><code>TextBox1.Text = "Hello, Select Me";
TextBox1.ReadOnly = true;
TextBox1.BorderStyle = 0;
TextBox1.BackColor = this.BackColo... |
8,105,688 | "Expected a type" error pointing to the return type of a method | <p>I've attempted to compile, but every time I do, one method throws a strange "expected a type" error. I have a method in the header:</p>
<pre><code>-(ANObject *)generateSomethingForSomethingElse:(NSString *)somethingElse;
</code></pre>
<p>The error points at the return type for this method. I've imported <code>ANOb... | 8,226,397 | 9 | 3 | null | 2011-11-12 16:16:06.583 UTC | 12 | 2022-01-20 16:11:29.15 UTC | 2012-02-05 23:14:13.433 UTC | null | 603,977 | null | 1,039,540 | null | 1 | 44 | objective-c|xcode|cocoa|compilation|compiler-errors | 62,986 | <p>This is to do with the order that the source files are compiled in. You are already probably aware that you can't call a method before it is defined (see below pseudocode):</p>
<pre><code>var value = someMethod();
function someMethod()
{
...
}
</code></pre>
<p>This would cause a compile-time error because som... |
4,259,729 | Updating a date format in MySQL | <p>I am working on a table that has two formats of dates stored in a field some are in <code>mm/dd/yy</code> and the newer entries are in <code>yyyy/mm/dd</code> like they should be.</p>
<p>I want to run an query like this</p>
<pre><code>UPDATE table
SET date_field = DATE_FORMAT(date_field, '%Y/%m/%d')
WHERE date_f... | 4,259,791 | 3 | 1 | null | 2010-11-23 19:01:42.667 UTC | 4 | 2021-04-15 00:14:55.683 UTC | 2021-04-15 00:14:55.683 UTC | null | 814,702 | null | 517,905 | null | 1 | 8 | mysql|date-format | 50,950 | <p>You want to use STR_TO_DATE function, not DATE_FORMAT. Plus, I assume you only want to update the misformed dates, so I guess you could do this :</p>
<pre><code>UPDATE your_table
SET date_field = DATE(STR_TO_DATE(date_field, '%m/%d/%Y'))
WHERE DATE(STR_TO_DATE(date_field, '%m/%d/%Y')) <> '0000-00-00';
</code>... |
4,138,277 | Error in IE when manually calling event handler, given certain conditions | <h2>Preface</h2>
<ul>
<li>Please note, I'm not looking for a code solution, but rather insight into why this may occur.</li>
<li>The error occurs in IE (tested 7 & 8), but not Firefox, Chrome, Safari.</li>
</ul>
<h2>Description</h2>
<p>When manually calling a function assigned to <code>onclick</code>, IE with th... | 4,177,240 | 3 | 25 | null | 2010-11-09 20:30:40.173 UTC | 11 | 2011-10-10 09:34:52.473 UTC | 2010-11-10 02:14:47.193 UTC | null | 113,716 | null | 113,716 | null | 1 | 15 | javascript|internet-explorer|event-handling | 3,551 | <p>As to "why" it was implemented this way, there's probably no answer from the outside. A good example is when former IE developer, the inventor of innerHTML, faces <a href="http://www.ericvasilik.com/2006/07/code-karma.html" rel="nofollow">problems</a> with innerHTML itself.</p>
<p>Asking why is also unnecessary bec... |
4,184,108 | python: json.dumps can't handle utf-8? | <p>Below is the test program, including a Chinese character:</p>
<pre><code># -*- coding: utf-8 -*-
import json
j = {"d":"中", "e":"a"}
json = json.dumps(j, encoding="utf-8")
print json
</code></pre>
<p>Below is the result, look the json.dumps convert the utf-8 to the original numbers!</p>
<pre><code>{"e": "a", "d"... | 4,184,289 | 3 | 4 | null | 2010-11-15 12:00:16.523 UTC | 4 | 2016-06-15 20:40:50.113 UTC | null | null | null | null | 197,036 | null | 1 | 21 | python|json | 39,559 | <p>You should read <a href="http://json.org" rel="noreferrer">json.org</a>. The complete JSON specification is in the white box on the right.</p>
<p>There is nothing wrong with the generated JSON. Generators are allowed to genereate either UTF-8 strings or plain ASCII strings, where characters are escaped with the <co... |
4,489,976 | XPath to return default value if node not present | <p>Say I have a pair of XML documents</p>
<pre><code><Foo>
<Bar/>
<Baz>mystring</Baz>
</Foo>
</code></pre>
<p>and</p>
<pre><code><Foo>
<Bar/>
</Foo>
</code></pre>
<p>I want an XPath (Version 1.0 only) that returns "mystring" for the first document and "not... | 4,490,667 | 5 | 0 | null | 2010-12-20 13:16:08.773 UTC | 9 | 2020-06-04 20:05:07.253 UTC | 2010-12-20 13:48:13.353 UTC | null | 135,624 | null | 135,624 | null | 1 | 17 | xpath | 22,878 | <p>In XPath 1.0, use:</p>
<pre><code>concat(/Foo/Baz,
substring('not-found', 1 div not(/Foo/Baz)))
</code></pre>
<p>If you want to handle the posible empty <code>Baz</code> element, use:</p>
<pre><code>concat(/Foo/Baz,
substring('not-found', 1 div not(/Foo/Baz[node()])))
</code></pre>
<p>With this inp... |
4,118,123 | Read a very large text file into a list in clojure | <p>What is the best way to read a very large file (like a text file having 100 000 names one on each line) into a list (lazily - loading it as needed) in clojure?</p>
<p>Basically I need to do all sorts of string searches on these items (I do it with grep and reg ex in shell scripts now). </p>
<p>I tried adding '( at... | 4,118,289 | 5 | 0 | null | 2010-11-07 14:23:57.563 UTC | 11 | 2020-12-15 16:02:51.653 UTC | null | null | null | null | 487,855 | null | 1 | 28 | file|text|clojure | 16,807 | <p>You need to use <a href="http://clojuredocs.org/clojure_core/clojure.core/line-seq"><code>line-seq</code></a>. An example from clojuredocs:</p>
<pre><code>;; Count lines of a file (loses head):
user=> (with-open [rdr (clojure.java.io/reader "/etc/passwd")]
(count (line-seq rdr)))
</code></pre>
<p>But w... |
4,149,415 | OnScreen keyboard opens automatically when Activity starts | <p>When my Activity with a <code>ScrollView</code> layout and <code>EditText</code>s starts, the <code>EditText</code>s get focus and the Android OnScreen keyboard opens.</p>
<p>How I can avoid that?</p>
<p>When I was using <code>LinearLayout</code> and <code>RelativeLayout</code> without the <code>ScrollView</code> ... | 4,150,363 | 5 | 1 | null | 2010-11-10 21:46:25.437 UTC | 10 | 2019-06-11 05:02:19.033 UTC | 2011-07-13 11:19:47.01 UTC | null | 418,183 | null | 479,886 | null | 1 | 46 | android|keyboard|focus|scrollview | 35,331 | <p>Android opens the OnScreenKeyboard automatically if you have an <code>EditText</code> focussed when the Activity starts.</p>
<p>You can prevent that by adding following into your Activity's <code>onCreate</code> method.</p>
<pre><code> getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_A... |
4,131,091 | dynamic_cast from "void *" | <p>According to <a href="https://stackoverflow.com/questions/3155277/cannot-dynamic-cast-void-to-templated-class">this</a>, <code>void*</code> has no RTTI information, therefore casting from <code>void*</code> is not legal and it make sense.</p>
<p>If I remember correctly, <code>dynamic_cast</code> from <code>void*</c... | 4,131,099 | 6 | 0 | null | 2010-11-09 06:36:37.73 UTC | 2 | 2020-02-25 17:43:19.9 UTC | 2017-05-23 10:29:28.723 UTC | null | -1 | null | 135,960 | null | 1 | 42 | c++|rtti|void-pointers|dynamic-cast | 37,692 | <p><code>dynamic_cast</code> works only on polymorphic types, i.e. classes containing virtual functions.</p>
<p>In gcc you can <code>dynamic_cast</code> <strong>to</strong> <code>void*</code> but not <strong>from</strong>:</p>
<pre><code>struct S
{
virtual ~S() {}
};
int main()
{
S* p = new S();
void* v ... |
4,794,927 | Why does this return Resource id #2? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/4290108/how-do-i-echo-a-resource-id-6-from-a-mysql-response-in-php">How do i “echo” a “Resource id #6” from a MySql response in PHP?</a> </p>
</blockquote>
<p>I am new at php and SQL and I'm trying to make the ... | 4,794,959 | 7 | 0 | null | 2011-01-25 14:55:07.233 UTC | 2 | 2011-01-25 15:16:27.79 UTC | 2017-05-23 12:30:24.063 UTC | null | -1 | null | 551,924 | null | 1 | 11 | php|sql|mysql | 63,519 | <p>Because you get a mysql ressource when you do a <a href="http://ch2.php.net/manual/en/function.mysql-query.php" rel="noreferrer"><code>mysql_query()</code></a>.</p>
<p>Use something like <a href="http://ch2.php.net/mysql_fetch_assoc" rel="noreferrer"><code>mysql_fetch_assoc()</code></a> to get the next row. It retu... |
4,656,802 | midpoint between two latitude and longitude | <p>I am trying to convert the code snippet given in this <a href="http://www.movable-type.co.uk/scripts/latlong.html" rel="noreferrer">http://www.movable-type.co.uk/scripts/latlong.html</a> into java. But I am not getting same result as that of site. Here is my code to find the midpoint between two points where their l... | 4,656,937 | 7 | 0 | null | 2011-01-11 10:50:22.727 UTC | 8 | 2020-12-09 07:52:48.71 UTC | 2011-01-11 11:18:43.743 UTC | null | 1,319,205 | null | 1,319,205 | null | 1 | 34 | java|math|maps | 41,007 | <p>You need to convert to radians. Change it to the following:</p>
<pre><code>public static void midPoint(double lat1,double lon1,double lat2,double lon2){
double dLon = Math.toRadians(lon2 - lon1);
//convert to radians
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
lon1 = Math.toRadia... |
4,590,490 | try/catch + using, right syntax | <p>Which one:</p>
<pre><code>using (var myObject = new MyClass())
{
try
{
// something here...
}
catch(Exception ex)
{
// Handle exception
}
}
</code></pre>
<p>OR</p>
<pre><code>try
{
using (var myObject = new MyClass())
{
// something here...
}
}
catch(Exception ex)
{
... | 4,590,518 | 9 | 3 | null | 2011-01-04 03:53:54.37 UTC | 38 | 2020-08-03 10:14:41.983 UTC | null | null | null | null | 313,421 | null | 1 | 222 | c#|try-catch|using-statement | 110,133 | <p>I prefer the second one. May as well trap errors relating to the creation of the object as well.</p> |
4,201,713 | Synchronization vs Lock | <p><code>java.util.concurrent</code> API provides a class called as <code>Lock</code>, which would basically serialize the control in order to access the critical resource. It gives method such as <code>park()</code> and <code>unpark()</code>. </p>
<p>We can do similar things if we can use <code>synchronized</code> k... | 4,201,734 | 10 | 1 | null | 2010-11-17 05:13:01.42 UTC | 83 | 2020-08-18 18:18:11.92 UTC | 2016-01-17 18:57:54.81 UTC | null | 4,999,394 | null | 379,235 | null | 1 | 204 | java|multithreading|concurrency|synchronization|java.util.concurrent | 178,887 | <p>If you're simply locking an object, I'd prefer to use <code>synchronized</code></p>
<p>Example:</p>
<pre><code>Lock.acquire();
doSomethingNifty(); // Throws a NPE!
Lock.release(); // Oh noes, we never release the lock!
</code></pre>
<p>You have to explicitly do <code>try{} finally{}</code> everywhere.</p>
<p>Whe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.