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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
17,567,326 | How does getContentResolver() work? | <p>I watched a course about <code>ContentProvider</code> on the Internet demonstrating how to define and use a <code>ContentProvider</code>.</p>
<p>I was confused about using the method named <code>getContentResolver()</code>. What does this method return?</p>
<p>My <code>ContentProvider</code> is not instanced and t... | 17,567,462 | 2 | 1 | null | 2013-07-10 09:41:01.643 UTC | 11 | 2016-08-06 02:28:10.827 UTC | 2016-08-06 02:28:10.827 UTC | null | 2,305,826 | null | 2,315,009 | null | 1 | 22 | android|android-contentresolver | 30,803 | <p>It returns Content Resolver. </p>
<hr>
<p><strong>What is the Content Resolver?</strong></p>
<p>The Content Resolver is the single, global instance in your application that provides access to your (and other applications') content providers. The Content Resolver behaves exactly as its name implies: it accepts req... |
17,453,105 | Android open pdf file | <p>I'm developing an Android application and I have to open some files.</p>
<p>This is my code using intent:</p>
<pre><code>public class FacturaActivity extends Activity {
(...)
public void downloadInvoice(View view) {
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() ... | 17,453,242 | 6 | 3 | null | 2013-07-03 16:16:21.62 UTC | 18 | 2022-04-02 13:47:00.797 UTC | 2014-01-12 16:30:17.097 UTC | null | 321,731 | null | 1,088,643 | null | 1 | 40 | android|file|pdf|android-manifest | 140,473 | <p>The problem is that there is no app installed to handle opening the PDF. You should use the Intent Chooser, like so:</p>
<pre><code>File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/"+ filename);
Intent target = new Intent(Intent.ACTION_VIEW);
target.setDataAndType(Uri.fromFile(fil... |
30,355,650 | Define buildconfigfield for an specific flavor AND buildType | <p>I have 2 flavors, lets say Vanilla and Chocolate. I also have Debug and Release build types, and I need Vanilla Release to have a field true, while the other 3 combinations should be false.</p>
<pre><code>def BOOLEAN = "boolean"
def VARIABLE = "VARIABLE"
def TRUE = "true"
def FALSE = "false"
VANILLA {
... | 30,486,355 | 8 | 3 | null | 2015-05-20 16:40:52.74 UTC | 11 | 2020-02-06 09:56:43.16 UTC | 2015-05-27 13:46:48.777 UTC | null | 1,398,731 | null | 1,398,731 | null | 1 | 62 | android|gradle|android-gradle-plugin|build-tools | 25,398 | <p>Loop the variants and check their names:</p>
<pre><code>productFlavors {
vanilla {}
chocolate {}
}
applicationVariants.all { variant ->
println("Iterating variant: " + variant.getName())
if (variant.getName() == "chocolateDebug") {
variant.buildConfigField "boolean", "VARIABLE", "true"
... |
18,503,096 | Python Integer Partitioning with given k partitions | <p>I'm trying to find or develop Integer Partitioning code for Python.</p>
<p>FYI, Integer Partitioning is representing a given integer n as a sum of integers smaller than n. For example, an integer 5 can be expressed as <code>4 + 1 = 3 + 2 = 3 + 1 + 1 = 2 + 2 + 1 = 2 + 1 + 1 + 1 = 1 + 1 + 1 + 1 + 1</code></p>
<p>I'v... | 18,503,391 | 4 | 5 | null | 2013-08-29 05:41:26.843 UTC | 15 | 2022-01-10 20:10:27.937 UTC | 2015-05-18 05:43:07.76 UTC | null | 1,048,572 | user2211319 | null | null | 1 | 24 | python|algorithm|integer-partition | 13,384 | <p>I've written a generator solution</p>
<pre><code>def partitionfunc(n,k,l=1):
'''n is the integer to partition, k is the length of partitions, l is the min partition element size'''
if k < 1:
raise StopIteration
if k == 1:
if n >= l:
yield (n,)
raise StopIteratio... |
26,347,394 | Node.js (with express & bodyParser): unable to obtain form-data from post request | <p>I can't seem to recover the form-data of a post request sent to my Node.js server. I've put below the server code and the post request (sent using postman in chrome):</p>
<p><strong>Post request</strong></p>
<pre><code>POST /api/login HTTP/1.1
Host: localhost:8080
Cache-Control: no-cache
----WebKitFormBoundaryE19... | 26,347,677 | 6 | 3 | null | 2014-10-13 19:23:39.533 UTC | 9 | 2021-12-01 04:36:46.177 UTC | 2018-04-01 18:28:56.84 UTC | null | 3,539,857 | null | 987,818 | null | 1 | 45 | node.js|express|post|multipartform-data|body-parser | 109,612 | <p>In general, an express app needs to specify the appropriate <a href="https://github.com/expressjs/body-parser">body-parser middleware</a> in order for <code>req.body</code> to contain the body.</p>
<p>[EDITED]</p>
<ol>
<li><p>If you required parsing of url-encoded (non-multipart) form data, as well as JSON, try ad... |
10,035,030 | How can I make a LDAP query that returns only groups having OU=Groups from all levels? | <p>If I am looking for all <code>Groups</code>, I get too much garbage. </p>
<p>If I try to narrow down the base, I get too few.</p>
<p>Here is an example:</p>
<pre><code>CN=A Team,OU=Groups,OU=Americas,DC=example,DC=com
CN=B TEAM,OU=Groups,OU=EMEA,DC=example,DC=com
CN=C Team,OU=Legacy Groups,DC=example,DC=com
CN=D ... | 10,041,875 | 1 | 2 | null | 2012-04-05 19:48:01.14 UTC | 4 | 2019-03-29 12:52:41.483 UTC | null | null | null | null | 99,834 | null | 1 | 2 | ldap|ldap-query | 42,187 | <p>First, on Microsoft Active Directory is impossible to do this in a single search, that's because AD is not fully LDAP compatible.</p>
<p>LDAP-compliant servers support an <code>extensible-match</code> filter which provides the necessary
filtering. From <a href="https://www.rfc-editor.org/rfc/rfc4511#section-4.5" rel... |
23,013,274 | shutting down computer (linux) using python | <p>I am trying to write a script that will shut down the computer if a few requirements are filled with the command</p>
<pre><code> os.system("poweroff")
</code></pre>
<p>also tried</p>
<pre><code> os.system("shutdown now -h")
</code></pre>
<p>and a few others. but nothing happens when I run it, the computer ... | 23,013,969 | 10 | 6 | null | 2014-04-11 12:58:45.47 UTC | 5 | 2022-02-20 15:45:54.697 UTC | 2014-04-11 13:06:36.08 UTC | null | 3,522,859 | null | 3,522,859 | null | 1 | 18 | python|linux|python-2.7|system-shutdown | 47,542 | <p>Many of the linux distributions out there require super user privileges to execute <code>shutdown</code> or <code>halt</code>, but then, how come that if you're sitting on your computer you can power it off without being root? You open a menu, hit <em>Shutdown</em> and it shutdowns without you becoming <code>root</c... |
5,387,868 | Oracle Install for SSIS connectivity (and drivers 32 64 bit) | <p>I have an SSIS package (SQL 2008) that I need to connecto to an Oracle DB (11g) with. What do I need to install to connect to oracle? What's the terminology ? All searches I've done talk about Instant Client, but on downloading that I see no exe's? I know installing the server will give me that Oracle Net manager (U... | 5,414,872 | 3 | 0 | null | 2011-03-22 07:06:30.01 UTC | 3 | 2013-09-05 21:59:03.82 UTC | 2011-03-24 06:13:25.28 UTC | null | 30,292 | null | 30,292 | null | 1 | 7 | oracle|ssis|driver | 48,155 | <p>Well, what I did was download <strong>Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64)</strong> from <a href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html" rel="noreferrer">http://www.oracle.com/technetwork/database/enterprise-editi... |
5,127,616 | Does ESPN Cricinfo have an API? | <p>Has <a href="http://espncricinfo.com" rel="noreferrer">espncricinfo.com</a> exposed an API? I'm interested in live scores, news, and maybe photos. </p>
<p>Up until now I have only known of the rss feed..</p> | 5,127,713 | 3 | 0 | null | 2011-02-26 15:00:12.183 UTC | 21 | 2015-04-01 18:49:20.173 UTC | 2013-05-03 15:26:45.793 UTC | null | 535,822 | null | 587,532 | null | 1 | 44 | web-services|api|espn | 52,751 | <p>I do not believe an API exists - unfortunately.</p>
<p>What a number of users have done - and what is suggested by cricinfo themselves - is use Yahoo Pipes to merge a number of different feeds. You can then get the resultant pipe in JSON and other formats.</p>
<p>It's probably best demonstrated by example by looki... |
9,443,004 | What does the `#` operator mean in Scala? | <p>I see this code in this blog: <a href="http://apocalisp.wordpress.com/2010/06/08/type-level-programming-in-scala/" rel="noreferrer">Type-Level Programming in Scala</a>:</p>
<pre><code>// define the abstract types and bounds
trait Recurse {
type Next <: Recurse
// this is the recursive function definition
t... | 9,444,487 | 4 | 3 | null | 2012-02-25 09:57:16.07 UTC | 59 | 2018-03-26 18:22:33.543 UTC | null | null | null | null | 342,235 | null | 1 | 146 | scala|type-systems | 16,514 | <p>To explain it, we first have to explain nested classes in Scala. Consider this simple example:</p>
<pre><code>class A {
class B
def f(b: B) = println("Got my B!")
}
</code></pre>
<p>Now let's try something with it:</p>
<pre><code>scala> val a1 = new A
a1: A = A@2fa8ecf4
scala> val a2 = new A
a2: A = A... |
19,992,984 | Verbs that act after backtracking and failure | <p>I was recently reading along in the <a href="http://www.pcre.org/pcre.txt" rel="noreferrer"><code>PCRE</code></a> - (Perl-compatible regular expressions) documentation and came across some interesting tricks with regular expression. As I continued to read and exhaust myself, I stopped because of some confusion in re... | 20,008,790 | 1 | 2 | null | 2013-11-15 03:29:21.933 UTC | 17 | 2021-08-26 09:26:00.52 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 2,206,004 | null | 1 | 26 | regex|perl|pcre | 1,619 | <p>Before reading this answer, you should be familiar with the mechanism of backtracking, atomic groups, and possessive quantifiers. You can find information about these notions and features in the Friedl book and following these links: <a href="http://www.regular-expressions.info" rel="nofollow noreferrer">www.regular... |
15,051,128 | Prevent form from submitting via event.preventDefault(); not working | <p>I'm using jQuery to submit my form variables, and im trying to prevent the form from submitting via the usual ways (click submit button or press enter on one of the fields)</p>
<p>i have this:</p>
<pre><code>$('#form').submit(function(){
event.preventDefault();
});
</code></pre>
<p>but it doesn't seem to work... | 15,051,168 | 7 | 3 | null | 2013-02-24 11:06:03.617 UTC | 1 | 2022-05-18 13:49:35.657 UTC | 2013-10-29 14:21:42.563 UTC | null | 1,185,053 | null | 1,797,947 | null | 1 | 17 | jquery|forms|submit | 58,601 | <p>If the only thing you need to do is to prevent the default action, you can supply <code>false</code> instead of a function:</p>
<pre><code>$('#form').submit(false);
</code></pre> |
15,466,298 | Simple caret (^) at end of Windows batch file consumes all memory | <p>This simple batch file in relatively short order consumes all available memory on Windows 7 (x64). What's going on? and what precautions can be taken to ward against it?</p>
<pre><code>any-invalid-command-you-like-here ^
</code></pre>
<p>Apparently necessary preconditions to exhibit the effect: </p>
<ul>
<li>the ... | 15,469,225 | 1 | 4 | null | 2013-03-17 21:12:37.557 UTC | 24 | 2019-11-18 16:30:45.71 UTC | 2015-07-17 00:40:12.803 UTC | null | 202,229 | null | 14,420 | null | 1 | 56 | windows|security|batch-file|cmd | 13,213 | <h3>Thoughts</h3>
<p>The cause of this (from my understanding) is due to the cmd interpreter looking for a character to escape since the <code>^</code> is the batch escape character. Instead of properly identifying the end of file <code>eof</code> in this scenario, cmd just keeps looping and initializing something whi... |
15,077,466 | What is a converting constructor in C++ ? What is it for? | <p>I have heard that C++ has something called "conversion constructors" or "converting constructors". What are these, and what are they for? I saw it mentioned with regards to this code:</p>
<pre><code>class MyClass
{
public:
int a, b;
MyClass( int i ) {}
}
int main()
{
MyClass M = 1 ;
}
</code></p... | 15,077,788 | 3 | 1 | null | 2013-02-25 22:09:36.25 UTC | 33 | 2019-01-12 07:23:35.17 UTC | 2013-02-25 22:36:21.39 UTC | null | 845,092 | null | 1,141,493 | null | 1 | 59 | c++|constructor|copy-constructor | 48,507 | <p>The definition for a <em>converting constructor</em> is different between C++03 and C++11. In both cases it must be a non-<code>explicit</code> constructor (otherwise it wouldn't be involved in implicit conversions), but for C++03 it must also be callable with a single argument. That is:</p>
<pre><code>struct foo
{... |
15,009,194 | Assign only if condition is true in ternary operator in JavaScript | <p>Is it possible to do something like this in JavaScript?</p>
<pre><code>max = (max < b) ? b;
</code></pre>
<p>In other words, assign value only if the condition is true. If the condition is false, do nothing (no assignment). Is this possible?</p> | 15,009,278 | 11 | 3 | null | 2013-02-21 18:02:03.507 UTC | 10 | 2022-01-12 05:39:57.58 UTC | null | null | null | null | 1,958,032 | null | 1 | 67 | javascript|ternary-operator | 109,614 | <p>Don't use the <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Conditional_Operator" rel="noreferrer">ternary operator</a> then, it requires a third argument. You would need to reassign <code>max</code> to <code>max</code> if you don't want it to change (<code>max = (max < b) ? b :... |
15,458,650 | Make an image responsive - the simplest way | <p>I notice that my code is responsive, in the fact that if I scale it down to the size of a phone or tablet - all of the text, links, and social icons scale accordingly.</p>
<p>However, the ONLY thing that doesn't is my image in the body; which is wrapped in paragraph tags... with that being said, is there a simple wa... | 15,458,733 | 12 | 5 | null | 2013-03-17 07:51:25.923 UTC | 37 | 2021-06-05 11:50:30.993 UTC | 2021-06-05 11:50:30.993 UTC | null | 4,356,300 | null | 2,176,358 | null | 1 | 89 | html|css|image|mobile | 510,031 | <p>You can try doing</p>
<pre><code><p>
<a href="MY WEBSITE LINK" target="_blank">
<img src="IMAGE LINK" style='width:100%;' border="0" alt="Null">
</a>
</p>
</code></pre>
<p>This should scale your image if in a fluid layout.</p>
<p>For responsive (meaning your layout reacts to ... |
28,360,978 | CSS: How to get browser scrollbar width? (for :hover {overflow: auto} nice margins) | <p>I'm not sure if title is clear, so few words of explanation. I've got few little elements, let say <code>div</code>'s (<code>200px</code> x <code>400px</code> CONSTANT). Inside each of them, there is a paragraph with about 20 lines of text. <strong>Of course, this it to much for a poor little div</strong>. What I wa... | 28,361,560 | 11 | 2 | null | 2015-02-06 07:52:30.257 UTC | 7 | 2022-08-04 14:15:39.34 UTC | null | null | null | null | 1,125,465 | null | 1 | 29 | html|css|width|scrollbar | 58,280 | <p>Scrollbar widths can vary between browsers and operating systems, and unfortunately CSS does not provide a way to detect those widths: we need to use JavaScript.</p>
<p>Other people have solved this problem by measuring the width of the scrollbar on an element:</p>
<ul>
<li><a href="http://davidwalsh.name/detect-scr... |
28,100,809 | NoSuchBeanDefinitionException expected at least 1 bean which qualifies as autowire candidate for this dependency | <p>I know this question has been asked so many times but I'm really having trouble to get over it. I have tried so many combinations by seeing those question but no one seems to fit my case.</p>
<p>The full log error is the following:</p>
<pre><code>org.springframework.beans.factory.BeanCreationException: Error creat... | 28,100,948 | 5 | 3 | null | 2015-01-22 23:54:19.563 UTC | 0 | 2018-09-17 13:39:34.807 UTC | 2015-01-26 10:00:32.96 UTC | null | 115,835 | null | 2,026,010 | null | 1 | 9 | java|hibernate|spring-mvc|jpa | 59,038 | <p>Add the package of <code>JpaProfessorDao</code> to the list of packages to be scanned</p>
<pre><code><context:component-scan base-package="com.personal.online.controller, com.personal.online.dao" />
</code></pre> |
7,705,929 | how to select the most frequently appearing values? | <p>I've seen examples where the query orders by count and takes the top row, but in this case there can be multiple "most frequent" values, so I might want to return more than just a single result.</p>
<p>In this case I want to find the most frequently appearing last names in a users table, here's what I have so far:<... | 7,705,993 | 2 | 0 | null | 2011-10-09 19:20:44.443 UTC | 8 | 2017-01-25 20:04:29.087 UTC | null | null | null | null | 964,195 | null | 1 | 11 | sql|oracle | 42,293 | <pre><code>select
x.last_name,
x.name_count
from
(select
u.last_name,
count(*) as name_count,
rank() over (order by count(*) desc) as rank
from
users u
group by
u.last_name) x
where
x.rank = 1
</code></pre>
<p>Use the analytical function <code>rank</code>. It will assign a numbering bas... |
8,828,451 | How to right align this submit button? | <p>I have a large number for forms with submit buttons and I need to right align the buttons. The problem is that when I use <code>float: right</code>, the submit element is taken out of the normal document flow. This means the form's height is reduced and it's bottom border then interferes with the button.</p>
<p>H... | 8,828,484 | 5 | 5 | null | 2012-01-11 23:56:52.907 UTC | 0 | 2015-04-23 12:58:09.803 UTC | null | null | null | null | 356,282 | null | 1 | 3 | css | 48,171 | <p>You can use the CSS <code>:after</code> pseudoelement to clear the container, without adding any extra HTML markup.</p>
<p>You would add something like this to your CSS:</p>
<pre><code>#loginForm:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
</code></pre>
... |
5,315,659 | jQuery change hash (fragment identifier) while scrolling down page | <p>I'm building a one pager website. Eg. every page (5 in total) is on one big page with the main menu fixed at the top. When you click on a menu link it slides you down to that pages anchor tag and the clicked menu item get a "active" CSS class. </p>
<p>What I'd like to do now is allow the user to scroll themself bu... | 5,315,993 | 4 | 1 | null | 2011-03-15 17:33:58.62 UTC | 10 | 2016-05-24 08:24:32.837 UTC | 2016-05-24 08:24:32.837 UTC | null | 1,010,918 | null | 498,187 | null | 1 | 13 | javascript|jquery|url | 19,756 | <p>its possible but there are a requirement to your page (for my solution to work): </p>
<p>your page have to be separated in divs(or sections whatever) with unique ids (i hope you dont use anchor <code><a></code>'s)</p>
<p>than you can use code like this:</p>
<pre><code>$(document).bind('scroll',function(e){
... |
5,083,954 | Send Message in C# | <p>I'm creating an application that uses a main project that is connected to several different DLLs. From one DLL window I need to be able to open a window in another but the DLL's can't reference each other. </p>
<p>It was suggested to me to use the sendmessage function in the first DLL and have a listener in the mai... | 5,084,002 | 6 | 2 | null | 2011-02-22 21:05:28.033 UTC | 8 | 2019-11-19 15:54:17.643 UTC | null | null | null | null | 629,099 | null | 1 | 16 | c#|sendmessage | 122,719 | <p>You don't need to send messages.</p>
<p>Add an <a href="http://msdn.microsoft.com/en-us/library/aa645739%28VS.71%29.aspx" rel="noreferrer">event</a> to the one form and an event handler to the other. Then you can use a third project which references the other two to attach the event handler to the event. The two DL... |
5,587,207 | Why put void in params? | <p>What's the reason for putting void inside of the params? </p>
<p>Why not just leave it blank? </p>
<pre><code>void createLevel(void);
void createLevel();
</code></pre> | 5,587,262 | 6 | 5 | null | 2011-04-07 20:28:38.023 UTC | 7 | 2016-01-13 16:30:54.493 UTC | 2016-01-13 16:30:54.493 UTC | null | 2,504,659 | null | 438,339 | null | 1 | 36 | c++ | 11,383 | <p>The <code>void</code> in the parenthesis are from C. In C a function with empty parentheses could have any number of parameters. In C++ it doesn't make any difference.</p> |
4,981,440 | Scrapy - how to manage cookies/sessions | <p>I'm a bit confused as to how cookies work with Scrapy, and how you manage those cookies.</p>
<p>This is basically a simplified version of what I'm trying to do:
<img src="https://i.stack.imgur.com/nn517.png" alt="enter image description here"></p>
<hr>
<h2>The way the website works:</h2>
<p>When you visit the we... | 25,516,223 | 6 | 2 | null | 2011-02-12 23:51:01.863 UTC | 37 | 2022-07-26 12:51:15.407 UTC | 2011-02-13 00:28:25.95 UTC | null | 311,220 | null | 311,220 | null | 1 | 62 | python|session|cookies|session-cookies|scrapy | 53,914 | <p>Three years later, I think this is exactly what you were looking for:
<a href="http://doc.scrapy.org/en/latest/topics/downloader-middleware.html#std:reqmeta-cookiejar" rel="noreferrer">http://doc.scrapy.org/en/latest/topics/downloader-middleware.html#std:reqmeta-cookiejar</a></p>
<p>Just use something like this in ... |
4,986,844 | What does "cdecl" stand for? | <p>Yes, I know that "cdecl" is the name of a prominent calling convention, so please don't explain calling conventions to me. What I'm asking is what the abbreviation (?) "cdecl" actually stands for. I think it's a poor naming choice, because at first sight it reminds one of "C declarator" (a rather unique syntactic a... | 69,833,093 | 8 | 8 | null | 2011-02-13 21:00:13.817 UTC | 10 | 2021-11-04 02:01:07.71 UTC | 2011-02-13 21:28:56.587 UTC | null | 505,088 | null | 252,000 | null | 1 | 38 | c++|c|calling-convention|nomenclature|cdecl | 16,640 | <p>The term CDECL originates from Microsoft's BASIC and their Mixed Language Programming ecosystem. The ecosystem permitted any of the Microsoft's four major languages (BASIC, FORTRAN, Pascal and C) to make calls to any other. Each language had a slightly different calling convention, and each had a way to declare an e... |
5,472,362 | Android automatic horizontally scrolling TextView | <p>I am trying to implement a single-line text view that will scroll automatically. But I unfortunatly cannot get it to work. The AutoScrollTextView is declared inside a LinearLayout (width and height = fill_parent). The class basically uses a Handler that calls itself to scroll by a given amount. I have simplified the... | 5,472,637 | 9 | 2 | null | 2011-03-29 12:18:04.667 UTC | 45 | 2022-08-11 14:00:27.34 UTC | null | null | null | null | 490,961 | null | 1 | 70 | android|scroll|textview | 106,458 | <p>If you don't need to sub-class the <code>TextView</code>, you can try this in your layout file:</p>
<pre><code> <TextView
android:text="Single-line text view that scrolls automatically if the text is too long to fit in the widget"
android:singleLine="true"
android:ellipsize="marquee"
... |
17,018,685 | Display image in its actual size in angular.js | <p>I need to display an image in its actual size, even if it is bigger than its container. I tried the trick of using Image variable and <a href="https://stackoverflow.com/a/7686392/196451">capturing the size on load</a> with something like this:</p>
<p>HTML:</p>
<pre><code><div ng-controller="MyCtrl">
<... | 17,018,779 | 3 | 2 | null | 2013-06-10 07:19:46.573 UTC | 2 | 2014-10-29 21:13:53.847 UTC | 2017-05-23 12:31:55.807 UTC | null | -1 | null | 196,451 | null | 1 | 5 | angularjs | 40,020 | <p>You need to use <a href="http://docs.angularjs.org/api/ng.%24rootScope.Scope#%24apply" rel="noreferrer"><code>$scope.$apply</code></a>, otherwise any changes to <code>$scope</code> made in non-Angular event handlers won't be processed properly:</p>
<pre><code>img.onload = function () {
$scope.$apply(function() {
... |
12,575,022 | Generating an Instagram- or Youtube-like unguessable string ID in ruby/ActiveRecord | <p>Upon creating an instance of a given ActiveRecord model object, I need to generate a shortish (6-8 characters) unique string to use as an identifier in URLs, in the style of Instagram's photo URLs (like <a href="http://instagram.com/p/P541i4ErdL/" rel="nofollow noreferrer">http://instagram.com/p/P541i4ErdL/</a>, whi... | 12,587,277 | 3 | 7 | null | 2012-09-25 01:19:57.28 UTC | 8 | 2017-11-22 10:13:33.837 UTC | 2017-05-23 12:16:51.223 UTC | null | -1 | null | 463,892 | null | 1 | 13 | ruby|postgresql|activerecord|sinatra | 6,448 | <p>You could do something like this:</p>
<p><em>random_attribute.rb</em></p>
<pre><code>module RandomAttribute
def generate_unique_random_base64(attribute, n)
until random_is_unique?(attribute)
self.send(:"#{attribute}=", random_base64(n))
end
end
def generate_unique_random_hex(attribute, n)
... |
12,279,236 | backbone.js collection events | <p>I develop a jquery & backbone.js web app.<br>
One component has an html table and behind this table is a backbone.js collection.<br>
Any change in this collection should lead to an update of the html table, so I write </p>
<pre><code>this.collection.bind("reset add remove", this.renderRows, this);
</code><... | 12,279,458 | 1 | 0 | null | 2012-09-05 10:19:02.507 UTC | 12 | 2021-11-30 14:56:12.69 UTC | 2013-11-06 16:09:40.667 UTC | null | 229,044 | null | 780,522 | null | 1 | 16 | backbone.js | 44,892 | <p>The <code>change</code> events from models bubble up to the collection. (Collection's <code>_onModelEvent</code> -function in the <a href="http://backbonejs.org/docs/backbone.html#section-105" rel="nofollow noreferrer">annotated source</a>. The method just basically takes all events from models and triggers them on ... |
12,562,624 | Terminal window inside Sublime Text 2 | <p>I saw <a href="http://wbond.net/sublime_packages/terminal">this project</a> that basically opens a new terminal window from sublime text-2.<br>
What I'm looking for is a way to open the terminal <strong>inside</strong> sublime text 2 via console.<br>
Does anyone knows how can I do that?</p> | 12,563,619 | 6 | 0 | null | 2012-09-24 09:54:15.153 UTC | 10 | 2019-05-24 01:58:30.963 UTC | 2013-10-18 12:49:26.657 UTC | null | 771,578 | null | 543,601 | null | 1 | 51 | terminal|sublimetext2 | 91,660 | <p>SublimeREPL does what you want</p>
<p><a href="https://github.com/wuub/SublimeREPL/">https://github.com/wuub/SublimeREPL/</a></p>
<p>Of course, there are some limitations because the window of Sublime Text 2 is not originally designed for continuous running buffer of stdin input.</p> |
19,122,942 | AngularJS sorting rows by table header | <p>I have four table headers:</p>
<pre><code>$scope.headers = ["Header1", "Header2", "Header3", "Header4"];
</code></pre>
<p>And I want to be able to sort my table by clicking on the header.</p>
<p>So if my table looks like this</p>
<pre><code>H1 | H2 | H3 | H4
A H D etc....
B G C
C F B
D E ... | 19,123,525 | 9 | 4 | null | 2013-10-01 18:06:18.623 UTC | 32 | 2020-03-25 01:19:22.947 UTC | 2016-11-28 23:56:26.74 UTC | null | 4,370,109 | null | 1,108,761 | null | 1 | 68 | angularjs|angularjs-ng-repeat|html-table | 141,623 | <p>I think this <a href="http://codepen.io/anon/pen/fjkcg">working CodePen example</a> that I created will show you exactly how to do what you want.</p>
<p>The template:</p>
<pre><code><section ng-app="app" ng-controller="MainCtrl">
<span class="label">Ordered By: {{orderByField}}, Reverse Sort: {{rever... |
24,208,842 | Visual Studio 2013, TFS is very slow | <p>When I originally installed VS Ultimate 2013 everything was fine but for the last month or so it's been a dog.
The source control explore in my Visual Studio 2013 install is very slow. Just clicking on a node and the act of displaying the node contents takes 20+ seconds.</p>
<p>Everyone else on the team is ok so it... | 24,264,059 | 13 | 5 | null | 2014-06-13 15:22:05.897 UTC | 8 | 2021-04-19 07:27:44.537 UTC | null | null | null | null | 17,579 | null | 1 | 35 | tfs|visual-studio-2013 | 28,267 | <p>Having tried all suggestions, unloaded all add ons, tried to reinstall VS, removed all extra workspaces etc. the answer to my problem was to unmap my workspace and then remap it.
Problem solved. Not got a clue what the underlying fault was.</p> |
3,583,757 | How to make sure that Tomcat6 reads CATALINA_OPTS on Windows? | <p>I have a Tomcat6 running on a Windows2003 machine.
I deployed 2 Grails apps on this server and I soon noticed that everything was crashing sometime after the deploy with a classic PermGen error.</p>
<pre><code>java.lang.OutOfMemoryError: PermGen space
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.Cl... | 3,600,542 | 4 | 3 | null | 2010-08-27 11:41:24.85 UTC | 7 | 2015-02-16 00:58:50.943 UTC | 2010-08-27 12:05:02.39 UTC | null | 338,365 | null | 338,365 | null | 1 | 6 | tomcat|logging|grails|permgen | 38,000 | <p>Thank you all!
I finally solved the issue by adding:</p>
<pre><code>-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:+UseConcMarkSweepGC
-XX:PermSize=128m
-XX:MaxPermSize=512m
</code></pre>
<p>To the java options on tomcat6w.exe.</p>
<p>Thanks!</p> |
22,520,413 | C strlen() implementation in one line of code | <p>Yesterday I was at interview and was asked to implement strlen() in C without using any standard functions, all by hands. As an absolute amateur, I implemented primitive version with while loop. Looking at this my interviewer said that it can be implemented at just one line of code. I wasn't be able to produce this ... | 22,520,702 | 9 | 6 | null | 2014-03-19 23:30:27.753 UTC | 8 | 2017-08-24 16:44:21.487 UTC | null | null | null | null | 1,236,726 | null | 1 | 12 | c|algorithm|strlen | 15,651 | <p>Similar to @DanielKamilKozar's answer, but with a for-loop, you can do this with no for-loop body, and <code>len</code> gets initialized properly in the function:</p>
<pre><code>void my_strlen(const char *str, size_t *len)
{
for (*len = 0; str[*len]; (*len)++);
}
</code></pre> |
19,145,787 | FieldError: Cannot resolve keyword 'XXXX' into field | <p>This is a very strange error. I only receive it on my heroku server. </p>
<p>Here is how my model is: </p>
<pre><code># Abstract Model
class CommonInfo(models.Model):
active = models.BooleanField('Enabled?', default=False)
date_created = models.DateTimeField(auto_now_add=True)
date_updated = models.Da... | 19,418,412 | 6 | 12 | null | 2013-10-02 20:00:29.503 UTC | 4 | 2020-04-16 16:28:00.873 UTC | 2013-10-02 21:04:10.493 UTC | null | 1,197,939 | null | 1,197,939 | null | 1 | 18 | python|django | 57,050 | <p>Finally, I was able to resolve the issue.</p>
<p>First, I managed to replicate the error in my local environment. At first, I was testing the application using built-in Django runserver. However, my production environment is Heroku that uses Gunicorn as webserver. When I switched to Gunicorn and foreman on my local... |
11,020,575 | PHP: return value from function and echo it directly? | <p>this might be a stupid question but …</p>
<p><strong>php</strong></p>
<pre><code>function get_info() {
$something = "test";
return $something;
}
</code></pre>
<p><strong>html</strong></p>
<pre><code><div class="test"><?php echo get_info(); ?></div>
</code></pre>
<p>Is there a way to ma... | 11,020,600 | 7 | 0 | null | 2012-06-13 17:53:58.697 UTC | 4 | 2020-08-22 09:49:03.493 UTC | 2012-06-13 18:54:11.653 UTC | null | 83,805 | null | 1,444,475 | null | 1 | 16 | php|function|echo | 98,476 | <p>You can use the special tags:</p>
<pre><code><?= get_info(); ?>
</code></pre>
<p>Or, of course, you can have your function echo the value:</p>
<pre><code>function get_info() {
$something = "test";
echo $something;
}
</code></pre> |
11,233,633 | Understanding Asynchronous Code in Layman's terms | <p>I understand the basic thing about asynchronous-ness: things don't execute sequentially. And I understand there is something very powerful about that... allegedly. But for the life of me I can't wrap my head around the code. Let's take a look at async Node.JS code that I HAVE WRITTEN...but don't truly get.</p>
<pre... | 11,233,849 | 3 | 0 | null | 2012-06-27 19:32:04.403 UTC | 16 | 2013-08-10 21:10:55.537 UTC | 2012-06-27 19:46:48.087 UTC | null | 361,684 | null | 1,222,564 | null | 1 | 21 | javascript|node.js|asynchronous | 16,709 | <p>I'm not sure where this function is being used, but the point of callbacks is that you pass them into some function that runs asynchronously; it stores your callback away, and when that function is done with whatever it needs to do, it will <em>call</em> your callback with the necessary parameters. An example from f... |
11,453,530 | applicationContext not finding Controllers for Servlet context | <p>I have a Spring web app with an applicationContext.xml and a dispatcher-servlet.xml configuration. I've defined the <code><context:component-scan /></code> in applicationContext.xml, but when I run my app the Controllers are not found unless I also add <code><context:component-scan /></code> to the disp... | 11,471,568 | 3 | 3 | null | 2012-07-12 14:01:32.977 UTC | 13 | 2015-10-30 05:55:51.46 UTC | 2012-07-13 15:41:14.61 UTC | null | 971,813 | null | 971,813 | null | 1 | 22 | spring|spring-mvc|spring-annotations | 35,335 | <p>You are right - there are two different application contexts, the root application context loaded up by ContextLoaderListener (at the point the ServletContext gets initialized), and the Web Context (loaded up by DispatcherServlet), the root application context is the parent of the Web context.</p>
<p>Now, since th... |
11,112,216 | How to Convert a byte array into an int array? | <p>How to Convert a byte array into an int array? I have a byte array holding 144 items and the ways I have tried are quite inefficient due to my inexperience. I am sorry if this has been answered before, but I couldn't find a good answer anywhere.</p> | 11,112,236 | 4 | 2 | null | 2012-06-20 02:54:48.06 UTC | 3 | 2020-07-05 16:03:18.81 UTC | null | null | null | null | 1,166,981 | null | 1 | 24 | c#|arrays | 39,629 | <p>Simple:</p>
<pre><code>//Where yourBytes is an initialized byte array.
int[] bytesAsInts = yourBytes.Select(x => (int)x).ToArray();
</code></pre>
<p>Make sure you include <code>System.Linq</code> with a using declaration:</p>
<pre><code>using System.Linq;
</code></pre>
<p>And if LINQ isn't your thing, you can... |
11,021,304 | JDBC connection default autoCommit behavior | <p>I'm working with JDBC to connect to Oracle. I tested <code>connection.setAutoCommit(false)</code> vs <code>connection.setAutoCommit(true)</code> and the results were as expected. </p>
<p>While by default connection is supposed to work as if <code>autoCommit(true)</code> [correct me if I'm wrong], but none of the re... | 11,022,406 | 1 | 4 | null | 2012-06-13 18:42:19.85 UTC | 3 | 2016-11-07 11:15:06.787 UTC | 2016-11-07 11:15:06.787 UTC | null | 814,702 | null | 1,454,452 | null | 1 | 27 | oracle|jdbc|autocommit | 39,774 | <p>From <a href="http://docs.oracle.com/javase/tutorial/jdbc/basics/transactions.html">Oracle JDBC documentation</a>:</p>
<blockquote>
<p>When a connection is created, it is in auto-commit mode. This means
that each individual SQL statement is treated as a transaction and is
automatically committed right after i... |
11,053,516 | CSS Styling for a Button: Using <input type="button> instead of <button> | <p>I'm trying to style a button using <code><input type="button"></code> instead of just <code><button></code>. With the code I have, the button extends all the way across the screen. I just want to be able to fit it to the text that it's in the button. Any ideas?</p>
<p>See the <a href="http://jsfiddle.ne... | 11,053,651 | 6 | 1 | null | 2012-06-15 15:16:28.553 UTC | 4 | 2018-01-06 09:38:29.023 UTC | 2012-06-15 15:19:25.753 UTC | null | 526,741 | null | 1,306,994 | null | 1 | 28 | css|button | 301,356 | <p>In your <code>.button</code> CSS, try <code>display:inline-block</code>. See this <a href="http://jsfiddle.net/w29DC/" rel="noreferrer">JSFiddle</a></p> |
11,185,873 | Variable scope and Try Catch in python | <pre><code>import Image
import os
for dirname, dirs, files in os.walk("."):
for filename in files:
try:
im = Image.open(os.path.join(dirname,filename))
except IOError:
print "error opening file :: " + os.path.join(dirname,filename)
print im.size
</code></pre>
<p>Her... | 11,185,984 | 3 | 6 | null | 2012-06-25 08:33:55.413 UTC | 5 | 2017-04-18 15:58:26.687 UTC | 2017-04-18 15:58:26.687 UTC | null | 1,516,116 | null | 835,415 | null | 1 | 31 | python|variables|try-catch|scope|python-imaging-library | 34,965 | <p>What's wrong with the "else" clause ?</p>
<pre><code>for filename in files:
try:
im = Image.open(os.path.join(dirname,filename))
except IOError, e:
print "error opening file :: %s : %s" % (os.path.join(dirname,filename), e)
else:
print im.size
</code></pre>
<p>Now since you're i... |
11,268,437 | How to convert string to integer in UNIX shelll | <p>I have <code>d1="11"</code> and <code>d2="07"</code>. I want to convert <code>d1</code> and <code>d2</code> to integers and perform <code>d1-d2</code>. How do I do this in UNIX?</p>
<p><code>d1 - d2</code> currently returns <code>"11-07"</code> as result for me.</p> | 11,269,389 | 5 | 1 | null | 2012-06-29 20:18:46.37 UTC | 12 | 2022-07-15 12:22:16.257 UTC | 2022-07-15 12:22:16.257 UTC | null | 4,374,258 | null | 1,484,056 | null | 1 | 57 | linux|shell|unix|interactive | 300,422 | <p>The standard solution:</p>
<pre><code> expr $d1 - $d2
</code></pre>
<p>You can also do:</p>
<pre><code>echo $(( d1 - d2 ))
</code></pre>
<p>but beware that this will treat <code>07</code> as an octal number! (so <code>07</code> is the same as <code>7</code>, but <code>010</code> is different than <code>10</code... |
11,397,757 | SQL COUNT* GROUP BY bigger than, | <p>I want to select the distinct keys with the occurence number, this query seems functionate:</p>
<pre><code>SELECT ItemMetaData.KEY, ItemMetaData.VALUE, count(*)
FROM ItemMetaData
GROUP BY ItemMetaData.KEY
ORDER BY count(*) desc;
</code></pre>
<p>But I also want to filter these result, meaning I want only where ... | 11,397,793 | 4 | 1 | null | 2012-07-09 15:01:54.297 UTC | 6 | 2017-08-23 10:24:41.233 UTC | 2016-02-11 21:30:16.46 UTC | null | 179,386 | null | 1,087,718 | null | 1 | 63 | sql|count|group-by | 96,869 | <p>HAVING clause for aggregates</p>
<pre><code>SELECT ItemMetaData.KEY, ItemMetaData.VALUE, count(*)
FROM ItemMetaData
Group By ItemMetaData.KEY, ItemMetaData.VALUE
HAVING count(*) > 2500
ORDER BY count(*) desc;
</code></pre> |
11,089,540 | Textarea height: 100% | <p>Here's my fiddle: <a href="http://jsfiddle.net/e6kCH/15/" rel="noreferrer">http://jsfiddle.net/e6kCH/15/</a></p>
<p>It may sound stupid, but I can't find a way to make the text area height equal to 100%. It works for the width, but not for height.</p>
<p>I want the text area to resize depending of the window size.... | 11,089,591 | 1 | 0 | null | 2012-06-18 19:16:47.59 UTC | 2 | 2016-02-17 18:44:14.487 UTC | 2012-07-20 20:14:16.307 UTC | null | 830,691 | null | 1,290,453 | null | 1 | 73 | html|css | 84,233 | <p><strong>Height of an element is relative to its parent.</strong> Thus, if you want to make expand your element into the whole height of the viewport, you need to apply your CSS to <code>html</code> and <code>body</code> as well (the parent elements):</p>
<pre><code>html, body {
height: 100%;
}
#textbox {
w... |
11,207,638 | Advantages of bundledDependencies over normal dependencies in npm | <p>npm allows us to specify <a href="https://docs.npmjs.com/files/package.json#bundleddependencies" rel="noreferrer"><code>bundledDependencies</code></a>, but what are the advantages of doing so? I guess if we want to make absolutely sure we get the right version even if the module we reference gets deleted, or perhaps... | 11,292,519 | 5 | 4 | null | 2012-06-26 12:45:48.98 UTC | 23 | 2019-11-21 09:55:40.76 UTC | 2019-03-19 23:56:21.16 UTC | null | 2,688,027 | null | 130,638 | null | 1 | 92 | node.js|npm|dependencies | 53,045 | <p>One of the biggest problems right now with Node is how fast it is changing. This means that production systems can be very fragile and an <code>npm update</code> can easily break things.</p>
<p>Using bundledDependencies is a way to get round this issue by ensuring, as you correctly surmise, that you will always del... |
13,190,337 | Avoid Memory Leak / Usage Javascript | <p>I am newbie to jQuery. I am bit confused whether is it fine or may cause memory leak ?</p>
<p>Here is the code: This method is called on certain date filters for each new values </p>
<pre><code>function preapreTooltip(chart) {
var tickLength = chart.xAxis[0].tickPositions.length,
ticks = chart.xAxis[0]... | 13,191,289 | 2 | 7 | null | 2012-11-02 06:21:47.573 UTC | 11 | 2016-05-26 10:54:07.187 UTC | 2012-11-02 06:50:44.767 UTC | null | 559,026 | null | 559,026 | null | 1 | 13 | javascript|jquery|memory-leaks | 7,552 | <p>Whilst there are browser specific issues that need to be avoided when writing large pure JavaScript projects, when using a library such as jQuery it should be assumed that the library's design helps you avoid these problems. However, considering memory leaks are rather hard to track down, and each different version ... |
13,180,293 | AngularJS multiple uses of Controller and rootScope | <p>I want to use a controller on 2 seperated HTML elements, and use the $rootScope to keep the 2 lists in sync when one is edited:</p>
<p><strong>HTML</strong></p>
<pre><code><ul class="nav" ng-controller="Menu">
<li ng-repeat="item in menu">
<a href="{{item.href}}">{{item.title}}</a&... | 13,181,133 | 3 | 3 | null | 2012-11-01 15:28:47.597 UTC | 23 | 2014-04-15 06:34:42.44 UTC | 2013-05-10 08:57:37.283 UTC | null | 629,685 | null | 884,842 | null | 1 | 19 | javascript|data-binding|controller|angularjs | 45,309 | <p>I would suggest to use a service that holds the menu and its methods. The service will update the menu which is referenced by the controller(s).</p>
<p>See a working plunker here: <a href="http://plnkr.co/edit/Bzjruq" rel="noreferrer">http://plnkr.co/edit/Bzjruq</a></p>
<p>This is the sample JavaScript code:</p>
... |
13,054,950 | Can Nexus or Artifactory store simple tar.gz artifacts? | <p>I have cloud servers located in separate data centers across the world. Each data center is separate from the others.</p>
<p>I'm looking for an easy way to deploy artifacts to individual clusters of servers (that may be running different versions of software i.e. a dev, test, and production cluster) in each of the... | 13,082,709 | 5 | 0 | null | 2012-10-24 17:54:51.25 UTC | 3 | 2021-01-15 16:03:38.91 UTC | 2012-10-24 18:09:01.803 UTC | null | 1,255,551 | null | 592,965 | null | 1 | 32 | deployment|nexus|artifactory|artifacts | 32,591 | <p><strong>Both Artifactory</strong> and <strong>Nexus</strong> can handle any type of file, as they both are <strong>"Binary Repository Managers"</strong>.</p>
<p>Albeit that, Nexus can technically store any file, but lacks support for binaries that do not adhere to the Maven repository layout. For example, such file... |
13,216,092 | How to sort a hash by value in descending order and output a hash in ruby? | <pre><code>output.sort_by {|k, v| v}.reverse
</code></pre>
<p>and for keys</p>
<pre><code>h = {"a"=>1, "c"=>3, "b"=>2, "d"=>4}
=> {"a"=>1, "c"=>3, "b"=>2, "d"=>4}
Hash[h.sort]
</code></pre>
<p>Right now I have these two. But I'm trying to sort hash in descending order by value so that it ... | 13,216,103 | 2 | 1 | null | 2012-11-04 04:30:06.043 UTC | 14 | 2012-11-04 04:59:29.07 UTC | 2012-11-04 04:59:29.07 UTC | null | 445,345 | null | 445,345 | null | 1 | 41 | ruby-on-rails|ruby|sorting|hash | 42,060 | <p>Try:</p>
<pre><code>Hash[h.sort.reverse]
</code></pre>
<p>This should return what you want. </p>
<p><strong>Edit:</strong></p>
<p>To do it by value:</p>
<pre><code>Hash[h.sort_by{|k, v| v}.reverse]
</code></pre> |
17,013,227 | Select only rows if its value in a particular column is 'NA' in R | <p>I'm trying to create a subset of data that contains only the rows with missing data in one of my columns.</p>
<p>The data:</p>
<pre><code>data<-structure(list(ID = c(1, 2, 3, 4, 7, 9, 10, 12, 13, 14, 15, 16,
17, 18, 20, 21, 22, 23, 24, 25, 27, 28, 29, 31, 34, 37, 38, 39,
40, 41), QnSinV1 = c(0L, 0L, 0L, 0L, 0L,... | 17,013,250 | 3 | 0 | null | 2013-06-09 19:17:41.887 UTC | 8 | 2021-12-31 06:23:19.067 UTC | 2021-12-31 06:23:19.067 UTC | null | 15,293,191 | null | 1,009,215 | null | 1 | 14 | r | 64,738 | <p>You can do it also without <code>subset()</code>. To select NA values you should use function <code>is.na()</code>.</p>
<pre><code>data[is.na(data$ColWtCL_6),]
</code></pre>
<p>Or with <code>subset()</code></p>
<pre><code>subset(data,is.na(ColWtCL_6))
</code></pre> |
16,856,650 | Android Studio failed to open by giving error "Files Locked" | <p>After running once successfully, Android Studio is getting failed to open.
The error is:</p>
<blockquote>
<p>Files in C:\Program Files (x86)\Android\android-studio\system\caches are locked. Android Studio will not be able to start.</p>
</blockquote>
<p>Did any one find its solution?</p> | 17,019,393 | 7 | 2 | null | 2013-05-31 11:51:28.93 UTC | 6 | 2019-12-05 06:27:26.037 UTC | null | null | null | null | 1,927,210 | null | 1 | 64 | android-studio | 25,438 | <p>Solved in Windows 7:</p>
<ol>
<li><p>Go to folder where android-studio is installed. (e.g. <code>C:\Program Files (x86)\Android\android-studio</code>)</p></li>
<li><p>Now go up one folder. (i.e. <code>C:\Program Files (x86)\Android</code>)</p></li>
<li><p>Right click on the <code>android-studio</code> folder and go... |
20,393,093 | How to get the ajax response from success and assign it in a variable using jQuery? | <p>Hello guys I have a problem in getting the response from my ajax. If I display it in the console. I can view it. But How do I assign it in a variable?</p>
<p>Here's what I have.
In my PHP code I have this</p>
<pre><code>public function checkPassword($password){
$username = $this->session->userda... | 20,393,170 | 10 | 7 | null | 2013-12-05 06:32:25.777 UTC | 1 | 2018-06-08 12:21:33.413 UTC | 2013-12-05 06:40:46.093 UTC | null | 2,706,036 | null | 2,706,036 | null | 1 | 2 | javascript|php|jquery|ajax | 42,900 | <pre><code>$.ajax({
type: 'POST',
url: password_url,
data: '',
dataType: 'json',
success: function(response){
var k=response;
if(k.indexOf("1") != -1)
$('#existing_info').html('Password is VALID');
else
$('#existing_inf... |
51,053,280 | Modifying a global variable in a constexpr function in C++17 | <p>In C++17, are you allowed to modify global variables in a <code>constexpr</code> function?</p>
<pre><code>#include <iostream>
int global = 0;
constexpr int Foo(bool arg) {
if (arg) {
return 1;
}
return global++;
}
int main() {
std::cout << global;
Foo(true);
std::cout ... | 51,053,445 | 2 | 6 | null | 2018-06-27 01:19:05.59 UTC | 5 | 2018-06-28 00:29:47.013 UTC | 2018-06-28 00:29:47.013 UTC | null | 963,864 | null | 595,605 | null | 1 | 36 | c++|language-lawyer|c++17|constexpr | 2,732 | <blockquote>
<p>Which compiler is correct?</p>
</blockquote>
<p>Clang is right.</p>
<p>The definition of a <code>constexpr</code> function as per <a href="https://timsong-cpp.github.io/cppwp/dcl.constexpr#3" rel="noreferrer">dcl.constexpr/3</a></p>
<blockquote>
<p>The definition of a <code>constexpr</code> funct... |
57,856,561 | How to check when my widget screen comes to visibility in flutter like onResume in Android | <p>In android if an activity is visible <code>onResume</code> is called. What is the equivalent method of <code>onResume</code> in <strong>Flutter</strong>? </p>
<p>I need the know when my widget screen is visible so I can auto-play a video based on that. I might go to another widget screen an when I come back it sh... | 58,504,433 | 5 | 4 | null | 2019-09-09 14:57:08.307 UTC | 10 | 2022-03-18 17:42:50.907 UTC | 2019-12-28 07:40:51.627 UTC | null | 4,768,512 | null | 4,768,512 | null | 1 | 50 | android|flutter | 27,559 | <p>All of the problems are solved.</p>
<p>Put an observer on the navigator from the root of the widget tree (materialappwidget).</p>
<p>If you need more explanation please follow this link:
<a href="https://api.flutter.dev/flutter/widgets/RouteObserver-class.html" rel="noreferrer">https://api.flutter.dev/flutter/widget... |
58,128,248 | How can I resolve the error "URL scheme must be "http" or "https" for CORS request." for this code | <p>It shows below message in the <code>console</code>.</p>
<blockquote>
<p>sandbox.js:1 Fetch API cannot load
file:///C:/Users/Lizzi/Desktop/novice%20to%20ninja/todos/luigi.json.
URL scheme must be "http" or "https" for CORS request </p>
</blockquote>
<p>I'm new to <code>aynchronouse</code> programming but I ha... | 58,129,062 | 1 | 6 | null | 2019-09-27 05:16:01.39 UTC | 5 | 2019-09-27 06:36:07.56 UTC | 2019-09-27 05:37:00.753 UTC | null | 9,763,011 | null | 9,035,071 | null | 1 | 22 | javascript|promise|fetch | 84,501 | <p>You need to be serving your index.html locally or have your site hosted on a live server somewhere for the Fetch API to work properly. The files need to be served using the http or https protocols.</p>
<p>If you just clicked on your index.html from your file explorer than your browser is grabbing those files direct... |
4,294,752 | Using a string as the argument to a Django filter query | <p>I'm trying to do a django query, but with the possibility of several different <code>WHERE</code> parameters. So I was thinking of doing something like:</p>
<pre><code>querystring = "subcat__id__in=[1,3,5]"
Listing.objects.filter(querystring)
</code></pre>
<p>Here Listing is defined in my model, and it contains t... | 4,294,771 | 2 | 0 | null | 2010-11-28 00:53:09.5 UTC | 9 | 2018-05-25 11:36:38.113 UTC | 2018-05-25 11:36:38.113 UTC | null | 9,663,023 | null | 480,815 | null | 1 | 29 | django|django-queryset | 13,958 | <p>Perhaps...</p>
<pre><code>filter_dict = {'subcat__id__in': [1,3,5]}
Listing.objects.filter(**filter_dict)
</code></pre> |
4,161,662 | How do I describe an Action<T> delegate that returns a value (non-void)? | <p>The <code>Action<T></code> delegate return void. Is there any other built-in delegate which returns non void value?</p> | 4,161,690 | 2 | 0 | null | 2010-11-12 04:39:49.143 UTC | 8 | 2010-11-12 04:51:53.68 UTC | 2010-11-12 04:51:53.68 UTC | null | 414,076 | null | 496,949 | null | 1 | 42 | c#|.net|delegates | 37,478 | <p>Yes. <code>Func<></code> returns the type specified as the final generic type parameter, such that <code>Func<int></code> returns an <code>int</code> and <code>Func<int, string></code> accepts an integer and returns a string. Examples:</p>
<pre><code>Func<int> getOne = () => 1;
Func<in... |
4,095,696 | Mercurial .hgignore for Visual Studio 2010 projects | <p>Not to be confused with <a href="https://stackoverflow.com/questions/34784/mercurial-hgignore-for-visual-studio-2008-projects">Mercurial .hgignore for Visual Studio 2008 projects</a></p>
<p>I was asking whether if that same file can be reused for Visual Studio 2010, or some other extensions, etc should be added to ... | 4,095,783 | 2 | 0 | null | 2010-11-04 10:26:13.51 UTC | 58 | 2013-08-21 07:05:58.207 UTC | 2017-05-23 12:05:59.473 UTC | null | -1 | null | 406,464 | null | 1 | 119 | visual-studio-2010|visual-studio|mercurial|hgignore | 14,767 | <p>The new things are related to MSTest stuff. This is the one that I use:</p>
<pre><code># use glob syntax
syntax: glob
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*.vssscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.[Cc]ache
*.ilk
*.log
*.lib
*.sbr
*.scc
*.DotSettings
[Bb]in
[Dd]ebug*/**
obj/
[Rr]elease*/**
_ReSharper*... |
26,459,911 | --resource-rules has been deprecated in mac os x >= 10.10 | <p>I tried to resign my ipa file with new provisioning profile on Mac Os 10.10 with iResign app but I got this warning: "Warning: --resource-rules has been deprecated in Mac OS X >= 10.10". </p>
<p>What should I do now? </p> | 26,678,311 | 8 | 4 | null | 2014-10-20 06:49:07.513 UTC | 19 | 2018-09-14 12:44:39.533 UTC | 2017-03-17 21:34:17.067 UTC | null | 5,115,977 | null | 1,468,082 | null | 1 | 69 | ios|iphone|code-signing|ipa|osx-yosemite | 30,372 | <p>I found <strong>workaround</strong>: if you run the iResign app from XCode — then you will resign app without problem (warning will appears in console instead of popup).
But if you close XCode and run app alone — then popup will back to you!</p>
<p>BTW: bug found :)
The condition</p>
<pre><code>if (systemVersionFl... |
9,847,843 | Looking for example code to implement a SNMP table using AgentX | <p>I've written an AgentX app (Linux, gcc, g++) which works well at sending back scalers. Here is what I'm doing now:</p>
<pre><code>init_agent( "blah" );
netsnmp_register_read_only_scalar( netsnmp_create_handler_registration( "foo1", handle_foo1, oid, oid.size(), HANDLER_CAN_RONLY ) );
init_snmp( "blah" );
while ( t... | 10,038,553 | 1 | 1 | null | 2012-03-23 23:43:47.573 UTC | 12 | 2013-12-10 11:03:28.67 UTC | null | null | null | null | 13,022 | null | 1 | 8 | c++|c|snmp|net-snmp | 18,248 | <p>I think the biggest pain when it comes to net-snmp is all those Doxygen pages the Google indexes but which provides near-zero usable content. Reading the <code>.h</code> files is probably already obvious to most developers, and the truth is that net-snmp provides many different layers of APIs with very little docum... |
10,121,693 | Decode JSON to NSArray or NSDictionary | <p>I hope to decode the JSON data below:</p>
<pre><code>{
"content":
[
{
"1":"a",
"2":"b",
"3":"c",
"4":"d",
"mark":"yes"
}
]
}
</code></pre>
<p>Not sure if put it in NSArray or NSDictionary</p>
<p>Welcome any comment</p> | 10,121,757 | 5 | 1 | null | 2012-04-12 10:20:48.687 UTC | 4 | 2015-11-09 12:33:11.113 UTC | 2012-04-12 10:26:56.763 UTC | null | 713,558 | null | 262,325 | null | 1 | 12 | objective-c|json | 42,074 | <p>which iOS version are you using? in iOS 5 you have the <code>NSJSONSerialization</code> class to parse JSON data, if you need to target older iOSs or MAC OSX you should use third parties lib such as <code>SBJSON</code>. The string posted will be a NSDictionary with an array with one dictionary. The array will be ac... |
9,823,140 | multiple mongo update operator in a single statement? | <p>Can i combine $pushAll and $inc in one statement ?</p>
<p>Before combine, this works fine :</p>
<pre><code>db.createCollection("test");
db.test.insert({"name" : "albert", "bugs" : []});
db.test.update({"name":"albert"},
{"$pushAll" : {"bugs" : [{"name":"bug1", "count":1}]}});
db.test.update({"name":"albert"... | 9,825,001 | 1 | 4 | null | 2012-03-22 13:21:54.94 UTC | 9 | 2012-05-02 02:30:29.77 UTC | 2012-05-02 02:30:29.77 UTC | null | 500,451 | null | 500,451 | null | 1 | 22 | mongodb | 28,951 | <p>Multiple updates may be performed on the same document, as long as those updates do not conflict (hence the "have conflicting mods in update" error). </p>
<p>Because "$push" : {"bugs" : [{"name":"bug1", "count":1}]} and "$inc" : {"bugs.0.count" : 1} are both attempting to modify the same portion of the document (n... |
8,009,379 | how to output a standings table on the fly from a mysql table of football [soccer] results? | <p>I have been trying to find something about this topic and I can't seem to find anything, there were a few questions on here but they didn't work for my particular project. </p>
<p>I asked a similar question about updating the table but its not going to work for what I actually want
here is the list of result.</p>
... | 8,009,883 | 3 | 8 | null | 2011-11-04 12:47:05.337 UTC | 13 | 2019-02-07 00:02:48.927 UTC | 2019-02-07 00:02:48.927 UTC | null | 2,370,483 | null | 1,010,198 | null | 1 | 16 | php|mysql|sql-order-by | 9,566 | <p>First union the scores table together swapping the hometeam with the awayteam and swapping the goal counts. This gives you some source data that is easily aggregated and the query to generate the score card is something like this:</p>
<pre><code>select
team,
count(*) played,
count(case when goalsfor ... |
7,991,770 | InputStreamReader vs FileReader | <p>I can't seem to determine any difference between <code>InputStreamReader</code> and <code>FileReader</code> besides the way the two are initialized. Is there any benefit to using one or the other? Most other articles cover <code>FileInputStream</code> vs <code>InputStreamReader</code>, but I am contrasting with <cod... | 7,991,813 | 3 | 1 | null | 2011-11-03 08:07:25.027 UTC | 11 | 2022-03-06 14:45:06.867 UTC | null | null | null | null | 1,025,053 | null | 1 | 33 | java|stream | 21,664 | <p>First, <code>InputStreamReader</code> can handle all input streams, not just files. Other examples are network connections, classpath resources and ZIP files.</p>
<p>Second, <code>FileReader</code> until Java 11 did not allow you to specify an encoding and instead only used the plaform default encoding, which made ... |
8,053,491 | Passing lambda functions as named parameters in C# | <p>Compile this simple program:</p>
<pre><code>class Program
{
static void Foo( Action bar )
{
bar();
}
static void Main( string[] args )
{
Foo( () => Console.WriteLine( "42" ) );
}
}
</code></pre>
<p>Nothing strange there. If we make an error in the lambda function body:</... | 8,056,678 | 3 | 5 | null | 2011-11-08 16:11:14.68 UTC | 10 | 2011-11-09 04:24:33.16 UTC | null | null | null | null | 19,241 | null | 1 | 35 | c#|lambda|named-parameters | 5,039 | <blockquote>
<p>Why doesn't it report the actual error?</p>
</blockquote>
<p>No, that's the problem; it <em>is</em> reporting the actual error. </p>
<p>Let me explain with a slightly more complicated example. Suppose you have this:</p>
<pre><code>class CustomerCollection
{
public IEnumerable<R> Select<... |
11,733,483 | Ember.js routing, outlets and animation | <p>It seems like if you want to animate a transition between states using the new Ember.js router and outlets, you're out of luck, since the previous content of an outlet will be destroyed before you have a chance to animate it. In cases where you can completely animate one view out before transitioning to the new stat... | 15,886,642 | 2 | 1 | null | 2012-07-31 05:11:41.683 UTC | 15 | 2014-01-30 14:57:43.153 UTC | 2017-05-23 12:17:00.147 UTC | null | -1 | null | 501,204 | null | 1 | 20 | ember.js|ember-old-router | 6,941 | <p>You should check this out: <a href="https://github.com/billysbilling/ember-animated-outlet" rel="nofollow">https://github.com/billysbilling/ember-animated-outlet</a>.</p>
<p>Then you can do this in your Handlebars templates:</p>
<pre><code>{{animatedOutlet name="main"}}
</code></pre>
<p>And transition from within... |
11,744,089 | PhantomJS create page from string | <p>Is it possible to create a page from a string? </p>
<p>example:</p>
<pre><code>html = '<html><body>blah blah blah</body></html>'
page.open(html, function(status) {
// do something
});
</code></pre>
<p>I have already tried the above with no luck....</p>
<p>Also, I think it's worth menti... | 11,746,057 | 5 | 0 | null | 2012-07-31 15:50:59.783 UTC | 12 | 2015-08-05 08:51:47.673 UTC | null | null | null | null | 201,255 | null | 1 | 35 | javascript|node.js|phantomjs | 24,537 | <p>Looking at the phantomjs <a href="http://code.google.com/p/phantomjs/wiki/Interface" rel="nofollow">API</a>, page.open requires a URL as the first argument, not an HTML string. This is why the what you tried does not work. </p>
<p>However, one way that you might be able to achieve the effect of creating a page from... |
11,703,010 | Background tasks in Meteor | <p>I'm wondering, is there is way to implement background taks, maybe with workers pool. Can you show me direction, i'm thinking about writing package for this?</p> | 21,351,966 | 4 | 0 | null | 2012-07-28 17:05:23.33 UTC | 50 | 2019-01-30 05:22:19.603 UTC | 2016-11-05 02:35:36.63 UTC | null | 1,269,037 | null | 688,665 | null | 1 | 59 | javascript|meteor|npm | 15,241 | <h2>2019 update</h2>
<p>Before thinking about writing a package for anything, first look if there are existing packages that do what you need. In the Meteor world, this means looking on Atmosphere for "job/queue/task/worker management/scheduling" packages, then on npm for the same search terms. You also need to define... |
20,329,403 | Android Push Notification without using GCM | <p>I need brief steps to implement GCM without using android's standard way. Instead, I need to set up my own central server for device registration and upload file from server to registered device without using GCM.</p>
<p>I also need some suggestions to block certain applications via admin console(For example: Need t... | 20,331,937 | 1 | 5 | null | 2013-12-02 13:23:38.957 UTC | 14 | 2021-08-25 10:53:56.693 UTC | 2021-08-25 10:53:56.693 UTC | null | 11,343,720 | null | 393,953 | null | 1 | 36 | android|push-notification | 32,463 | <p>A few things to get your started:</p>
<p><strong>MQTT / Paho</strong><br>
The Paho project provides open-source client implementations of MQTT and MQTT-SN messaging protocols aimed at new, existing, and emerging applications for Machine‑to‑Machine (M2M) and Internet of Things (IoT).<br>
<a href="http://www.eclipse.... |
3,845,600 | How to access the first character of a character array? | <pre><code>#include <stdio.h>
int main(void){
char x [] = "hello world.";
printf("%s \n", &x[0]);
return 0;
}
</code></pre>
<p>The above code prints out <code>"hello world."</code></p>
<p>How would i print out just <code>"h"</code>? Shouldn't the access <code>x[0]</code> ensure this?</p> | 3,845,627 | 5 | 0 | null | 2010-10-02 12:09:27.64 UTC | 1 | 2020-03-01 14:26:48.213 UTC | 2010-10-03 12:32:04.74 UTC | null | 227,665 | null | 234,712 | null | 1 | 3 | c|arrays|indexing|printf|character | 41,257 | <p>You should do:</p>
<pre><code>printf("%c \n", x[0]);
</code></pre>
<p>The <a href="http://www.cplusplus.com/reference/clibrary/cstdio/printf/" rel="noreferrer">format specifier</a> to print a char is <code>c</code>. So the format string to be used is <code>%c</code>.</p>
<p>Also to access an array element at a va... |
3,634,627 | How to know the preferred display width (in columns) of Unicode characters? | <p>In different encodings of Unicode, for example <strong>UTF-16le</strong> or <strong>UTF-8</strong>, a character may occupy 2 or 3 bytes. Many Unicode applications doesn't take care of display width of Unicode chars just like they are all Latin letters. For example, in <strong>80</strong>-column text, which should co... | 9,145,712 | 5 | 1 | null | 2010-09-03 09:54:00.613 UTC | 18 | 2012-07-26 11:30:38.033 UTC | 2012-07-26 11:30:38.033 UTC | null | 217,071 | null | 217,071 | null | 1 | 21 | unicode|text-formatting|character-properties|mbcs | 8,944 | <p>Sounds like you're looking for something like <a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/wcwidth.html" rel="noreferrer"><code>wcwidth</code></a> and <a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/wcswidth.html" rel="noreferrer"><code>wcswidth</code></a>, defined in IEEE Std ... |
3,408,150 | Add attribute 'checked' on click jquery | <p>I've been trying to figure out how to add the attribute "checked" to a checkbox on click. The reason I want to do this is so if I check off a checkbox; I can have my local storage save that as the html so when the page refreshes it notices the checkbox is checked. As of right now if I check it off, it fades the pare... | 3,409,979 | 5 | 0 | null | 2010-08-04 17:36:53.097 UTC | 5 | 2020-06-22 01:05:14.59 UTC | 2010-08-04 18:39:13.193 UTC | null | 400,623 | null | 400,623 | null | 1 | 25 | javascript|jquery|html|local-storage | 171,257 | <p>It seems this is one of the rare occasions on which use of an attribute is actually appropriate. jQuery's <code>attr()</code> method will not help you because in most cases (including this) it actually sets a property, not an attribute, making the choice of its name look somewhat foolish. <strong>[UPDATE: Since jQue... |
3,815,656 | simple encrypt/decrypt lib in python with private key | <p>Is there a simple way to encrypt/decrypt a string with a key?</p>
<p>Something like:</p>
<pre><code>key = '1234'
string = 'hello world'
encrypted_string = encrypt(key, string)
decrypt(key, encrypted_string)
</code></pre>
<p>I couldn't find anything simple to do that.</p> | 3,815,681 | 5 | 1 | null | 2010-09-28 17:57:32.8 UTC | 13 | 2021-02-21 11:27:24.723 UTC | 2020-04-18 09:40:29.957 UTC | null | 7,487,335 | null | 258,564 | null | 1 | 27 | python|encryption | 52,297 | <p><a href="http://www.dlitz.net/software/pycrypto/" rel="noreferrer">http://www.dlitz.net/software/pycrypto/</a> should do what you want.</p>
<p>Taken from their docs page.</p>
<pre><code>>>> from Crypto.Cipher import DES
>>> obj=DES.new('abcdefgh', DES.MODE_ECB)
>>> plain="Guido van Rossu... |
3,763,423 | How to get form fields' id in Django | <p>Is there any way to get the id of a field in a template?</p>
<p>In the HTML I get: <code><input name="field_name" id="id_field_name"...</code></p>
<p>I know I can get the name with <code>{{ field.html_name }}</code>, but is there anything similar for getting the id?<br>
Or can I only get it like this: <code>id_... | 3,765,016 | 5 | 0 | null | 2010-09-21 18:46:59.96 UTC | 19 | 2022-01-17 07:40:51.873 UTC | 2021-08-14 19:42:42.213 UTC | null | 7,758,804 | null | 182,945 | null | 1 | 109 | django|django-forms|django-templates | 63,906 | <p>You can get the ID like this:</p>
<pre><code>{{ field.auto_id }}
</code></pre> |
3,724,242 | What is the difference between “int” and “uint” / “long” and “ulong”? | <p>I know about <code>int</code> and <code>long</code> (32-bit and 64-bit numbers), but what are <code>uint</code> and <code>ulong</code>?</p> | 3,724,255 | 6 | 0 | null | 2010-09-16 06:36:31.577 UTC | 27 | 2022-07-24 06:52:58.963 UTC | 2014-02-03 09:46:39.803 UTC | null | 635,809 | null | 427,224 | null | 1 | 144 | c#|types|integer|unsigned|signed | 247,522 | <p>The primitive data types prefixed with "u" are unsigned versions with the same bit sizes. Effectively, this means they cannot store negative numbers, but on the other hand they can store positive numbers twice as large as their signed counterparts. The signed counterparts do not have "u" prefixed.</p>
<p>The limits... |
3,495,582 | Amazon EC2 as web server? | <p>I have thought a lot recently about the different hosting types that are available out there. We can get pretty decent latency (average) from an EC2 instance in Europe (we're situated in Sweden) and the cost is pretty good. Obviously, the possibility of scaling up and down instances is amazing for us that's in a rea... | 3,523,776 | 8 | 1 | null | 2010-08-16 17:22:30.347 UTC | 42 | 2015-12-02 00:19:59.147 UTC | 2012-05-21 09:07:00.317 UTC | null | 45,773 | null | 198,128 | null | 1 | 63 | amazon-ec2|amazon-web-services|lamp | 48,040 | <blockquote>
<p>So, what should we be concerned about if we were about to run our web server on EC2? What are the pro's and cons?</p>
</blockquote>
<p>The pros and cons of EC2 are somewhat dependent on your business. Below is a list of issues that I believe affect large organizations:</p>
<ul>
<li><strong>Separatio... |
4,015,613 | Good tutorial for using HTML5 History API (Pushstate?) | <p>I am looking into using the HTML5 History API to resolve deep linking problems with AJAX loaded content, but I am struggling to get off the ground. Does any one know of any good resources?</p>
<p>I want to use this as it seems a great way to allow to the possibility of those being sent the links may not have JS tur... | 4,843,248 | 9 | 0 | null | 2010-10-25 14:36:40.227 UTC | 102 | 2014-08-31 21:05:51.267 UTC | 2013-05-03 02:19:31.957 UTC | null | 1,858,225 | null | 445,126 | null | 1 | 167 | javascript|html|pushstate|html5-history | 130,044 | <p>For a great tutorial the Mozilla Developer Network page on this functionality is all you'll need: <a href="https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history" rel="noreferrer">https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history</a></p>
<p>Unfortunately, the HTML5 History API is ... |
3,392,493 | Adjust width of input field to its input | <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="text" value="1" style="min-width:1px;" /></code></pre>
</div>
</div>
</p>
<p>This is my code and it is not wo... | 3,392,617 | 32 | 1 | null | 2010-08-02 23:11:08.813 UTC | 71 | 2022-07-27 13:51:04.317 UTC | 2022-07-27 13:51:04.317 UTC | null | 616,443 | null | 409,131 | null | 1 | 256 | javascript|html|css | 435,951 | <p>It sounds like your expectation is that the style be applied dynamically to the width of the textbox based on the contents of the textbox. If so you will need some js to run on textbox contents changing, something like <a href="http://jsfiddle.net/73T7S/" rel="noreferrer">this</a>:</p>
<pre><code><input id="... |
4,023,830 | How to compare two strings in dot separated version format in Bash? | <p>Is there any way to compare such strings on bash, e.g.: <code>2.4.5</code> and <code>2.8</code> and <code>2.4.5.1</code>?</p> | 4,025,065 | 36 | 0 | null | 2010-10-26 12:53:18.9 UTC | 81 | 2022-09-25 03:18:07.947 UTC | 2017-10-03 20:53:04.527 UTC | null | 6,862,601 | null | 486,405 | null | 1 | 250 | linux|bash|versioning | 127,368 | <p>Here is a pure Bash version that doesn't require any external utilities:</p>
<pre><code>#!/bin/bash
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
... |
8,170,450 | Combine static libraries on Apple | <p>I tried the approach in this <a href="https://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one">question</a>, but it seems the linux version of <code>ar</code> is not the same as the mac version since I failed to combine the object files again.</p>
<p>What I basically want to do is ... | 8,170,851 | 4 | 0 | null | 2011-11-17 16:12:45.367 UTC | 28 | 2021-05-11 17:29:07.35 UTC | 2021-05-11 17:29:07.35 UTC | null | 207,791 | user187676 | null | null | 1 | 50 | objective-c|c|xcode|static-libraries | 21,038 | <p>you can use <code>libtool</code> to do it</p>
<pre><code>libtool -static -o new.a old1.a old2.a
</code></pre> |
8,337,180 | Custom Single choice ListView | <p>I want to make a custom List View having Two TextViews and a radio Button in a single row. And on listitem click the radio button state should be toggle. I cannot use Simple Adapter here.</p>
<p>I have already asked that question <a href="https://stackoverflow.com/questions/8295026/single-choice-listview-custom-row... | 8,502,062 | 5 | 3 | null | 2011-12-01 06:00:27.113 UTC | 17 | 2022-04-28 22:28:54.547 UTC | 2017-10-08 06:41:56.263 UTC | null | 1,033,581 | null | 954,135 | null | 1 | 22 | android|listview|choice | 57,412 | <p>I've been searching for an answer to this problem all morning, and the most useful thing I've found so far is <a href="https://web.archive.org/web/20111205132234/http://tokudu.com/2010/android-checkable-linear-layout/" rel="nofollow noreferrer">this article</a>.</p>
<p>While I haven't implemented the solution it sug... |
7,780,550 | Referencing a .css file in github repo as stylesheet in a .html file | <p>I've got a repository on github with a .css file in it. Is there any way to have github serve this file in a way that I can consume it in a web page?</p>
<p>In other words, I'd like to be able to reference this source file at github directly, from an HTML file on my local computer or a live domain. Something like:<... | 7,790,846 | 5 | 2 | null | 2011-10-15 20:47:42.147 UTC | 11 | 2019-03-08 00:00:22.213 UTC | 2011-10-15 21:08:01.38 UTC | null | 979,672 | null | 979,672 | null | 1 | 35 | github | 27,702 | <p>GitHub repos aren't web hosting, you should push that stuff up to a service specifically designed to serve files, like pages.github.com.</p> |
7,750,982 | Can Python's map function call object member functions? | <p>I need to do something that is functionally equivalent to this:</p>
<pre><code>for foo in foos:
bar = foo.get_bar()
# Do something with bar
</code></pre>
<p>My first instinct was to use <code>map</code>, but this did not work:</p>
<pre><code>for bar in map(get_bar, foos):
# Do something with bar
</cod... | 7,751,029 | 5 | 2 | null | 2011-10-13 07:49:47.097 UTC | 9 | 2019-04-24 23:13:39.003 UTC | null | null | null | null | 58,994 | null | 1 | 49 | python | 29,819 | <p>Either with <code>lambda</code>:</p>
<pre><code>for bar in map(lambda foo: foo.get_bar(), foos):
</code></pre>
<p>Or simply with instance method reference on your instance's class:</p>
<pre><code>for bar in map(Foo.get_bar, foos):
</code></pre>
<p>As this was added from a comment, I would like to note that this ... |
7,703,049 | check 1 billion cell-phone numbers for duplicates | <p>It's an interview question:</p>
<blockquote>
<p>There are 1 billion cell-phone numbers which has 11 digits, they are stored randomly in a file, for
example 12345678910, the first digit gotta be 1. Go through these numbers to see whether there is
one with duplicate, just see if duplicate exists, if duplicate f... | 7,703,297 | 6 | 10 | null | 2011-10-09 11:02:04.563 UTC | 19 | 2017-09-22 07:31:02.92 UTC | 2017-09-22 17:44:54.74 UTC | null | -1 | null | 888,051 | null | 1 | 16 | algorithm|large-data | 7,641 | <p>Fastest solution (also in terms of programmer overhead :)</p>
<pre><code># Generate some 'phones'
yes 1 | perl -wne 'chomp; ++$a; print $_."$a\n";' > phones.txt
# Split phones.txt in 10MB chunks
split -C 10000000 phones.txt
# Sort each 10MB chunk with 10MB of memory
for i in x??; do sort -S 10M $i > $i.srt;... |
7,931,069 | How to fake time in javascript? | <p>I would like to mock the Date constructor so that whenever I call new Date(), it always return specific time.</p>
<p>I found Sinon.js provide useFakeTimers to mock time. But the following code doesn't work for me.</p>
<pre><code>sinon.useFakeTimers(new Date(2011,9,1));
//expect : 'Sat Oct 01 2011 00:00:00' ,
//r... | 11,679,436 | 6 | 1 | null | 2011-10-28 15:03:50.233 UTC | 6 | 2019-01-07 08:04:40.2 UTC | 2011-10-28 15:04:45.697 UTC | null | 370,103 | null | 832,847 | null | 1 | 41 | javascript | 32,564 | <p><code>sinon.useFakeTimers</code> accepts a timestamp (integer) as parameter, not a Date object.</p>
<p>Try with </p>
<pre><code>clock = sinon.useFakeTimers(new Date(2011,9,1).getTime());
new Date(); //=> return the fake Date 'Sat Oct 01 2011 00:00:00'
clock.restore();
new Date(); //=> will return the real t... |
7,872,611 | In Python, what is the difference between pass and return | <p>I have seen some code in Pinax and other django apps that instead of pass, an empty return statement is used. What is the difference and would it have any effect on, for example, the django code below that I am running? The code is a signal method that automatically saves the hashtags into taggit Tag objects for a t... | 7,872,670 | 7 | 1 | null | 2011-10-24 07:50:01.027 UTC | 14 | 2021-04-25 00:20:49.463 UTC | null | null | null | null | 841,766 | null | 1 | 42 | python | 46,298 | <pre><code>if not instance:
return # will pass be better or worse here?
</code></pre>
<p>Worse. It changes the logic. <code>pass</code> actually means: Do nothing. If you would replace <code>return</code> with <code>pass</code> here, the control flow would continue, changing the semantic of the code.</p>
<p>Th... |
8,156,707 | gzip a file in Python | <p>I want to gzip a file in Python. I am trying to use the subprocss.check_call(), but it keeps failing with the error 'OSError: [Errno 2] No such file or directory'. Is there a problem with what I am trying here? Is there a better way to gzip a file than using subprocess.check_call?</p>
<pre><code>from subprocess imp... | 8,156,724 | 8 | 2 | null | 2011-11-16 18:25:41.267 UTC | 9 | 2022-07-21 02:54:15.09 UTC | null | null | null | null | 807,522 | null | 1 | 53 | python|gzip|subprocess | 107,741 | <p>Try this:</p>
<pre><code>check_call(['gzip', fullFilePath])
</code></pre>
<p>Depending on what you're doing with the data of these files, Skirmantas's link to <a href="http://docs.python.org/library/gzip.html">http://docs.python.org/library/gzip.html</a> may also be helpful. Note the examples near the bottom of t... |
4,234,056 | Can we Execute SQL Queries in JQuery | <p>can we execute mySQL queries in jQuery Calllback functions & misc. functions</p>
<p>like simple query</p>
<pre><code>UPDATE EMPLOYEE SET PAY = PAY + 500 WHERE E_ID = '32'
</code></pre> | 4,234,069 | 4 | 2 | null | 2010-11-20 17:37:55.93 UTC | 2 | 2017-09-29 04:06:42.467 UTC | 2010-11-20 17:39:57.073 UTC | null | 13,249 | null | 158,455 | null | 1 | 5 | jquery|mysql | 55,029 | <p>The best thing you can do is to issue an AJAX request to a server and then execute this query using a server side code.</p>
<p>You can use <a href="http://api.jquery.com/jQuery.post/" rel="nofollow"><strong>jQuery.post()</strong></a> in this case.</p>
<p><strong><em>Edit</em></strong></p>
<p>To get an overview of... |
4,701,108 | RSpec send_file testing | <p>How to test a controller action that sends a file?</p>
<p>If I do it with <code>controller.should_receive(:send_file)</code> test fails with "Missing template" because nothing gets rendered.</p> | 4,701,831 | 4 | 0 | null | 2011-01-15 17:43:54.697 UTC | 5 | 2020-02-06 21:47:44.057 UTC | null | null | null | null | 200,122 | null | 1 | 30 | ruby-on-rails|rspec|sendfile | 11,489 | <p>From <a href="http://www.ruby-forum.com/topic/179408" rel="noreferrer">Googling</a> <a href="http://www.ruby-forum.com/topic/181545" rel="noreferrer">around</a>, it appears that <code>render</code> will also be called at some point .. but with no template, will cause an error.</p>
<p>The solution seems to be to stu... |
4,429,966 | How to make a python script "pipeable" in bash? | <p>I wrote a script and I want it to be <em>pipeable</em> in bash. Something like:</p>
<pre><code>echo "1stArg" | myscript.py
</code></pre>
<p>Is it possible? How?</p> | 4,430,047 | 4 | 1 | null | 2010-12-13 14:45:37.45 UTC | 16 | 2022-07-07 09:51:28.223 UTC | 2016-10-10 11:33:43.663 UTC | null | 1,030,960 | null | 189,734 | null | 1 | 64 | python|pipe | 41,076 | <p>See this simple <code>echo.py</code>:</p>
<pre><code>import sys
if __name__ == "__main__":
for line in sys.stdin:
sys.stderr.write("DEBUG: got line: " + line)
sys.stdout.write(line)
</code></pre>
<p>running:</p>
<pre><code>ls | python echo.py 2>debug_output.txt | sort
</code></pre>
<p>out... |
4,708,754 | Optimising the Zend Framework | <p>I'm trying to get as much performance as I can out of my application, which uses the Zend Framework.</p>
<p>I'm considering using the Zend Server, with APC enabled. However, I need to know a few things first.</p>
<p>Is there any benefit of using Zend Server + Zend Framework, or should I just use any ordinary syste... | 4,718,334 | 5 | 5 | null | 2011-01-16 23:16:16.243 UTC | 11 | 2019-04-05 09:42:41.757 UTC | null | null | null | null | 114,865 | null | 1 | 7 | zend-framework|zend-server | 4,440 | <p>My tips for faster ZF (try from top to bottom):</p>
<h3>Optimize include path</h3>
<ul>
<li>zend path first</li>
<li>models next</li>
<li>rest at the end</li>
</ul>
<h3>Use PHP 5.5 with OPCache enabled [NEW]</h3>
<ul>
<li>I can't stress this enough</li>
<li>gains around 50%</li>
</ul>
<h3>Cache table metadata</... |
4,830,164 | What is the best way to simulate a Click with MouseUp & MouseDown events or otherwise? | <p>In WPF most controls have <code>MouseUp</code> and <code>MouseDown</code> events (and the mouse-button-specific variations) but not a simple <code>Click</code> event that can be used right away. If you want to have a click-like behaviour using those events you need to handle both which i consider to be a bit of a pa... | 4,831,110 | 5 | 6 | null | 2011-01-28 15:50:22.163 UTC | 13 | 2014-04-24 14:17:47.487 UTC | 2017-05-23 12:33:56.653 UTC | null | -1 | null | 546,730 | null | 1 | 32 | wpf|controls|click|mouseevent | 15,455 | <p>I would use a <code>Button</code> control and overwrite the <code>Button.Template</code> to just show the content directly.</p>
<pre><code><ControlTemplate x:Key="ContentOnlyTemplate" TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
<Button Template="{StaticResource Co... |
4,126,811 | How do you track record relations in NoSQL? | <p>I am trying to figure out the equivalent of foreign keys and indexes in NoSQL KVP or Document databases. Since there are no pivotal tables (to add keys marking a relation between two objects) I am really stumped as to how you would be able to retrieve data in a way that would be useful for normal web pages.</p>
<p>... | 4,210,561 | 5 | 4 | null | 2010-11-08 18:31:27.827 UTC | 48 | 2020-10-28 14:00:28.563 UTC | 2016-07-14 07:28:46.59 UTC | null | 364,274 | null | 99,923 | null | 1 | 138 | nosql|database-relations | 50,987 | <p>All the answers for how to store many-to-many associations in the "NoSQL way" reduce to the same thing: <strong>storing data redundantly.</strong></p>
<p>In NoSQL, you don't design your database based on the relationships between data entities. You design your database based on the queries you will run against it.... |
4,613,310 | How to call external url in jquery? | <p>I am trying to put comments on Facebook wall using jquery.</p>
<p>But my ajax call not alowing external url .</p>
<p>can anyone explain how can we use external url with jquery ?</p>
<p>below is my code :</p>
<pre><code>var fbUrl="https://graph.facebook.com/16453004404_481759124404/comments?access_token=my_token"... | 4,613,640 | 7 | 1 | null | 2011-01-06 09:10:11.49 UTC | 9 | 2018-12-28 11:39:25.563 UTC | 2011-01-06 09:55:54.913 UTC | null | 80,111 | user319198 | null | null | 1 | 32 | jquery|ajax|cross-domain-policy | 164,025 | <p>All of these answers are wrong!</p>
<p>Like I said in my comment, the reason you're getting that error because the URL fails the "<a href="http://en.wikipedia.org/wiki/Same_origin_policy" rel="noreferrer">Same origin policy</a>", but you can still us the AJAX function to hit another domain, see <a href="https://sta... |
4,079,920 | Is there a point to minifying PHP? | <p>I know you <em>can</em> minify PHP, but I'm wondering if there is any point. PHP is an interpreted language so will run a little slower than a compiled language. My question is: would clients see a visible speed improvement in page loads and such if I were to minify my PHP?</p>
<p>Also, is there a way to compile PH... | 4,079,952 | 8 | 2 | null | 2010-11-02 16:38:37.363 UTC | 32 | 2021-10-01 20:19:53.97 UTC | 2012-08-23 10:32:59.263 UTC | null | 383,609 | null | 383,609 | null | 1 | 107 | php|minify | 51,044 | <p>PHP is compiled into bytecode, which is then interpreted on top of something resembling a VM. Many other scripting languages follow the same general process, including Perl and Ruby. It's not really a traditional interpreted language like, say, BASIC.</p>
<p>There would be no effective speed increase if you attemp... |
4,250,149 | requestFeature() must be called before adding content | <p>I am trying to implement a custom titlebar:</p>
<p>Here is my Helper class:</p>
<pre><code>import android.app.Activity;
import android.view.Window;
public class UIHelper {
public static void setupTitleBar(Activity c) {
final boolean customTitleSupported = c.requestWindowFeature(Window.FEATURE_CUSTOM_T... | 4,250,209 | 9 | 1 | null | 2010-11-22 20:54:06.757 UTC | 29 | 2022-07-07 15:05:56.69 UTC | 2014-01-28 10:03:09.57 UTC | null | 56,285 | null | 19,875 | null | 1 | 146 | android|android-layout|android-activity | 127,479 | <p>Well, just do what the error message tells you.</p>
<p>Don't call <code>setContentView()</code> before <code>requestFeature()</code>.</p>
<p><strong>Note:</strong></p>
<p>As said in comments, for both <code>ActionBarSherlock</code> and <code>AppCompat</code> library, it's necessary to call <code>requestFeature()<... |
14,834,841 | When does 'quietly = TRUE' actually work in the require() function? | <p>I am trying to code a set of functions to check for missing R packages, and to install them if necessary. There's some good code to do that at StackOverflow: <a href="https://stackoverflow.com/questions/4090169/elegant-way-to-check-for-missing-packages-and-install-them?lq=1">start here</a>.</p>
<p>I would like to m... | 24,924,250 | 6 | 3 | null | 2013-02-12 14:29:54.377 UTC | 3 | 2021-05-23 04:08:36.287 UTC | 2017-05-23 11:54:05.047 UTC | null | -1 | null | 635,806 | null | 1 | 30 | r | 15,035 | <p>The simplest solution appears to be</p>
<pre><code>try(library(xyz), silent=TRUE)
</code></pre>
<p><code>require</code> is basically a wrapper around <code>tryCatch(library)</code>, so this just cuts out some extraneous code.</p> |
14,700,577 | Drawing transparent ShapeRenderer in libgdx | <p>I have a drawn a filled circle using ShapeRenderer and now I want to draw this circle as a transparent one. I am using the following code to do that: But the circle is not coming as transparent. Also, I checked th libgdx API and from the wiki, it says that, need to Create CameraStrategy. Has somebody faced similar i... | 14,721,570 | 4 | 2 | null | 2013-02-05 05:10:17.823 UTC | 9 | 2015-12-31 06:08:57.803 UTC | 2013-02-05 06:50:49.783 UTC | null | 527,617 | null | 527,617 | null | 1 | 44 | java|android|libgdx | 30,072 | <p>The following code is working for me in this case, maybe it will help someone else:</p>
<pre><code>Gdx.gl.glEnable(GL10.GL_BLEND);
Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
shapeRenderer.setProjectionMatrix(camera.combined);
shapeRenderer.begin(ShapeType.FilledCircle);
shapeRenderer.setCol... |
14,465,668 | Elastic search, multiple indexes vs one index and types for different data sets? | <p>I have an application developed using the MVC pattern and I would like to index now multiple models of it, this means each model has a different data structure.</p>
<ul>
<li><p>Is it better to use mutliple indexes, one for each model or have a type within the same index for each model? Both ways would also require ... | 14,554,767 | 4 | 0 | null | 2013-01-22 18:40:36.683 UTC | 72 | 2017-03-20 21:48:19.833 UTC | 2013-07-23 09:50:26.53 UTC | null | 171,209 | null | 171,209 | null | 1 | 179 | database|search|elasticsearch | 49,906 | <p>There are different implications to both approaches. </p>
<p>Assuming you are using Elasticsearch's default settings, having 1 index for each model will significantly increase the number of your shards as 1 index will use 5 shards, 5 data models will use 25 shards; while having 5 object types in 1 index is still go... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.