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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
19,143,360 | Python: Writing to and Reading from serial port | <p>I've read the documentation, but can't seem to find a straight answer on this.
I have a list of all COM Ports in use by Modems connected to the computer. From this list, I try to open it, send it a command, and if it says anything back, add it to another list. I'm not entirely sure I'm using pyserial's read and writ... | 19,143,704 | 2 | 9 | null | 2013-10-02 17:44:29.133 UTC | 1 | 2019-11-27 20:25:39.783 UTC | 2013-10-02 17:53:11.547 UTC | null | 2,816,588 | null | 2,816,588 | null | 1 | 8 | python|serial-port|pyserial | 140,618 | <p><code>ser.read(64)</code> should be <code>ser.read(size=64)</code>; ser.read uses keyword arguments, not positional.</p>
<p>Also, you're reading from the port twice; what you probably want to do is this:</p>
<pre><code>i=0
for modem in PortList:
for port in modem:
try:
ser = serial.Serial(p... |
8,911,230 | What is the function of an asterisk before a function name? | <p>I've been confused with what I see on most C programs that has unfamiliar function declaration for me.</p>
<pre><code>void *func_name(void *param){
...
}
</code></pre>
<p>What does <code>*</code> imply for the function? My understanding about (<code>*</code>) in a variable type is that it creates a pointer to... | 8,911,253 | 4 | 6 | null | 2012-01-18 13:49:57.437 UTC | 24 | 2016-09-22 12:33:35.763 UTC | 2016-09-22 12:33:35.763 UTC | null | 560,648 | null | 969,645 | null | 1 | 77 | c|function|pointers | 47,718 | <p>The asterisk belongs to the return type, and not to the function name, i.e.:</p>
<pre><code>void* func_name(void *param) { . . . . . }
</code></pre>
<p>It means that the function returns a void <em>pointer</em>.</p> |
21,969,851 | What is the difference between File.ReadLines() and File.ReadAllLines()? | <p>I have query regarding File.ReadLines() and File.ReadAllLines().what is difference between
them. i have text file where it contains data in row-wise.<code>File.ReadAllLines()</code> return array and using <code>File.ReadLines().ToArray();</code> will also i can get same result.So is there any performance difference... | 21,970,035 | 3 | 4 | null | 2014-02-23 14:58:58.287 UTC | 7 | 2018-06-18 09:44:01.767 UTC | 2016-08-15 22:31:18.47 UTC | null | 3,769 | null | 1,118,932 | null | 1 | 57 | c#|readline|file.readalllines | 61,329 | <blockquote>
<p>is there any performance difference related to these methods?</p>
</blockquote>
<p><strong>YES</strong> there is a difference </p>
<p><code>File.ReadAllLines()</code> method reads the whole file at a time and returns the string[] array, so it takes time while working with large size of files and not... |
10,902,959 | How to hide or show a div | <p>I have on my Page_Load registered this</p>
<pre><code> Page.ClientScript.RegisterStartupScript(this.GetType(), "clientscript", "document.getElementById('showdiv').style.visibility = 'hidden';", true);
</code></pre>
<p>But its not getting hidden... My div is as shown below</p>
<pre><code><div id="showdiv">
... | 10,903,791 | 8 | 2 | null | 2012-06-05 18:40:42.397 UTC | null | 2017-07-31 15:09:56.043 UTC | 2012-06-05 19:17:25.403 UTC | null | 819,494 | null | 1,416,156 | null | 1 | 5 | c#|javascript|asp.net | 59,924 | <p>I highly recommend doing this simple client side manipulation (show/hode rows controls, etc.) with JavaScript or even more easily with a .js library like jQuery. After you include the jQuery scripts in your application, this is all you need to do to have that DIV be hidden after the page has completed its initializa... |
10,964,821 | Exception caught but program keeps running | <p>I am working on my first Java project implementing a class called "HeartRates" which takes the user's date of birth and returns their max and target heart rate. Everything in the main test program works except for one thing, I can't figure out how to stop the rest of the code from printing after the exception is cau... | 10,964,835 | 3 | 1 | null | 2012-06-09 21:47:42.6 UTC | 3 | 2012-06-09 22:00:04.237 UTC | 2012-06-09 22:00:04.237 UTC | null | 369 | null | 1,383,628 | null | 1 | 14 | java|exception-handling | 57,921 | <p>Not really sure why you want to terminate the application after the exception is caught - wouldn't it be better to fix whatever went wrong?</p>
<p>In any case, in your catch block:</p>
<pre><code>catch(Exception e) {
e.printStackTrace(); //if you want it.
//You could always just System.out.println("Excepti... |
11,276,043 | How to add a SearchWidget to the ActionBar? | <p>I'm trying to add a Search-ActionView to my application (as explained here <a href="http://developer.android.com/guide/topics/search/search-dialog.html#UsingSearchWidget" rel="noreferrer">http://developer.android.com/guide/topics/search/search-dialog.html#UsingSearchWidget</a>). Unfortunately I keep getting a NullPo... | 11,276,285 | 7 | 5 | null | 2012-06-30 17:16:31.523 UTC | 16 | 2016-09-03 09:45:39.797 UTC | 2012-07-20 09:47:18.34 UTC | null | 1,493,269 | null | 1,493,269 | null | 1 | 26 | android|nullpointerexception|android-actionbar|searchview | 48,686 | <p>use this way as in <a href="http://www.edumobile.org/android/android-development/action-bar-search-view/" rel="noreferrer">link</a></p>
<pre><code>public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.me... |
11,138,939 | How to trigger javascript on print event? | <p>Is it possible to trigger a javascript event when a user prints a page?
I would like to remove a dependancy on a javascript library, when a user opts to print a page, as the library is great for screen but not for print.</p>
<p>Any idea how to achieve this?</p> | 15,713,060 | 5 | 5 | null | 2012-06-21 13:11:18.663 UTC | 4 | 2022-05-17 14:14:57.18 UTC | 2012-06-21 14:14:40.587 UTC | null | 1,437,962 | null | 578,667 | null | 1 | 31 | javascript|browser|printing | 48,315 | <p>For anyone stumbling upon this answer from Google, let me try to clear things up:</p>
<p>As Ajay pointed out, there are two events which are fired for printing, but they are not well-supported; as far as I have read, they are only supported in Internet Explorer and Firefox (6+) browsers. Those events are window.onb... |
11,107,263 | How compatible are different versions of glibc? | <p>Specifically:</p>
<ol>
<li><p>Is it assured somehow that all versions of glibc 2.x are binary compatible?</p></li>
<li><p>If not, how can I run a binary (game) on my system which has been compiled for a different version? Can I install glibc in a different folder?</p></li>
</ol>
<p>My specific problem is the compa... | 11,108,336 | 3 | 0 | null | 2012-06-19 18:38:48.62 UTC | 13 | 2020-12-11 12:20:32.587 UTC | 2012-09-12 07:16:31.127 UTC | null | 241,776 | null | 34,088 | null | 1 | 33 | installation|shared-libraries|glibc|binary-compatibility | 26,198 | <p>In general, running binaries that were compiled for an older glibc version (e.g. 2.13) will run fine on a system with a newer glibc (e.g. 2.14, like your system).</p>
<p>Running a binary that was built for a newer glibc (e.g. 2.15, like the one that fails) on a system with an older glibc will probably not work.</p>... |
12,785,638 | Command for opening serial port in Windows 7 | <p>Is there a Windows command for opening serial ports, say COM3 via the command prompt in Windows 7? For example:</p>
<pre><code>OPEN "COM6" AS #1
</code></pre>
<p>I cannot use pyserial or any other utilities that are not distributed with Windows 7.</p>
<p><strong>Preferred solution</strong>
<a href="https://stacko... | 12,801,667 | 2 | 4 | null | 2012-10-08 16:26:30.253 UTC | 4 | 2020-03-27 14:33:54.907 UTC | 2018-08-03 12:42:39.853 UTC | null | 3,826,372 | null | 181,783 | null | 1 | 10 | windows|batch-file|cmd|windows-7|serial-port | 71,189 | <p>Maybe you can use the Powershell? It's included in Win7... </p>
<p>code taken from here <a href="http://blogs.msdn.com/b/powershell/archive/2006/08/31/writing-and-reading-info-from-serial-ports.aspx" rel="noreferrer">http://blogs.msdn.com/b/powershell/archive/2006/08/31/writing-and-reading-info-from-serial-ports.a... |
12,964,021 | Script to install app in iOS Simulator | <p>I am trying to automate the process of building an app, running unit tests, and finally running UI tests. </p>
<p>I am building the app via command line (xcodebuild -sdk iphonesimulator6.0) in some directory. </p>
<p>How do I install this app to the iOS simulator via command line (in ~/Library/Application Support/... | 12,982,349 | 2 | 0 | null | 2012-10-18 21:27:16.97 UTC | 10 | 2016-10-06 17:02:07.467 UTC | 2014-06-13 22:06:01.073 UTC | null | 1,160,022 | null | 1,160,022 | null | 1 | 11 | shell|command-line|ios-simulator | 14,570 | <p>I made a shell script which installs the app to the simulator.</p>
<pre><code>#!/bin/sh
# Pick a uuid for the app (or reuse existing one).
if ! [ -f installApp.uuid ]; then
uuidgen > installApp.uuid
fi
UUID=$(cat installApp.uuid)
#create supporting folders
TOPDIR="$HOME/Library/Application Support/\
iPhone S... |
12,678,833 | C# - when to use public int virtual, and when to just use public int | <p>I am working through a tutorial 'Professional ASP.NET MVC 3' by J Galloway. In this tutorial, Jon shows us how to build the MVC music store.</p>
<p>I am at the part where we are creating CS classes to model the data using EF code first.</p>
<p>I <strong>all</strong> the examples in the book, <code>public virtual i... | 12,678,883 | 7 | 4 | null | 2012-10-01 18:24:25.767 UTC | 10 | 2012-10-02 03:14:37.443 UTC | 2012-10-01 19:29:22.033 UTC | null | 1,137,379 | null | 1,239,122 | null | 1 | 23 | c#|asp.net-mvc|asp.net-mvc-3|entity-framework | 25,485 | <p>In order to truly understand the <code>virtual</code> keyword you are going to want to read up on <a href="http://msdn.microsoft.com/en-us/library/ms173152.aspx">Polymorphism in general</a>:</p>
<blockquote>
<p>Polymorphism is often referred to as the third pillar of
object-oriented programming, after encapsula... |
12,742,695 | Use or not leading slash in value for @RequestMapping. Need official docs or point to Spring source? | <p>I involved in project where I found a mix of:</p>
<pre>
@RequestMapping(value = "events/...");
@RequestMapping(value = "/events/...");
</pre>
<p>(with and without slash before method level annotation).</p>
<p>I perform search:</p>
<pre>
site:http://static.springsource.org/spring/docs/3.1.x slash
</pre>
<p>and read ... | 12,744,010 | 1 | 0 | null | 2012-10-05 08:48:39.667 UTC | 5 | 2012-10-05 10:08:53.677 UTC | 2021-10-07 05:46:31.917 UTC | null | -1 | null | 173,149 | null | 1 | 33 | java|spring|spring-mvc | 7,483 | <p>It does not matter: If the path does not start with an <code>/</code> then Spring (DefaultAnnotationHandlerMapping) will add it.</p>
<p>See method <code>String[] determineUrlsForHandler(String beanName)</code> of Class <code>DefaultAnnotationHandlerMapping</code> line 122 (Spring 3.1.2) (that is for the class level... |
12,775,265 | iOS 6 shouldAutorotate: is NOT being called | <p>I have been scouring the internet for a solution to this but am finding nothing. I am trying to make my iOS 5 app iOS 6 compatible. I cannot get the orientation stuff to work right. I am unable to detect when a rotation is about to happen. Here is the code I am trying:</p>
<pre><code>- (BOOL)shouldAutorotate {
... | 12,790,798 | 9 | 2 | null | 2012-10-08 04:20:01.17 UTC | 12 | 2019-04-23 12:00:52.403 UTC | 2015-07-17 08:17:37.3 UTC | null | 1,820,838 | null | 985,027 | null | 1 | 48 | iphone|ios|cocoa-touch|rotation|ios6 | 48,851 | <p>See if you are getting the following error when your App starts.</p>
<blockquote>
<p>Application windows are expected to have a root view controller at the end of application launch</p>
</blockquote>
<p>If so the way to fix it is by making the following change in the <code>AppDelegate.m</code> file (although the... |
30,678,712 | FBSDK Login Error Code: 308 in Objective-C | <p>I keep getting </p>
<blockquote>
<p>"Error Domain=com.facebook.sdk.login Code=308 "The operation couldn’t
be completed. (com.facebook.sdk.login error 308.)""</p>
</blockquote>
<p>upon trying to login with Facebook from my device.</p>
<p>My code works on the simulator, but not on an actual device. Has anyone r... | 33,883,052 | 18 | 5 | null | 2015-06-06 03:46:13.317 UTC | 13 | 2018-12-19 03:42:59.567 UTC | 2015-06-06 04:08:15.847 UTC | null | 3,940,672 | null | 975,798 | null | 1 | 57 | ios|facebook|parse-platform|facebook-sdk-4.0 | 38,183 | <p>One solution, at least for me, is to not run on device via the Xcode debugger. If I run the app on device outside the debugger the Facebook login works fine. If I run the app in the sim via the debugger the Facebook login works fine.</p>
<p>Only if I run the app on device via the Xcode debugger do I get the com.fac... |
17,057,934 | Wpf merged resource dictionary no being recognized from app.xaml | <p>I have a WPF .net 4.5 application where I am having trouble merging resource dictionaries.</p>
<p>I have the exact same problem as <a href="https://stackoverflow.com/a/4166345/1923268">This SO question</a> and <a href="https://stackoverflow.com/a/4113594/1923268">This Question</a> but the accepted solution does not... | 17,083,360 | 3 | 10 | null | 2013-06-12 04:57:50.733 UTC | 12 | 2022-08-29 15:21:47.043 UTC | 2018-03-27 15:56:48.347 UTC | null | 102,937 | null | 1,854,382 | null | 1 | 25 | .net|wpf|xaml|resourcedictionary | 24,558 | <p>I hava a big problem with MergedDictionaries and I believe that your problem is the same.
I want my ResourceDictionaries to be properly organized, which means for me that there are for example seperate Buttons.xaml, TextBoxes.xaml, Colors.xaml and so on. I merge them in Theme.xaml, often all the Styles are in a sepe... |
17,099,025 | Determine whether doc is new or exists in mongoose Post middleware's 'save'? | <p>From <a href="http://mongoosejs.com/docs/middleware.html" rel="noreferrer">Mongoose JS</a> documentation:</p>
<pre><code>schema.post('save', function (doc) {
console.log('%s has been saved', doc._id);
})
</code></pre>
<p>Is there any way to determine whether this is the original save or the saving of an existing... | 18,305,924 | 3 | 0 | null | 2013-06-13 23:45:09.713 UTC | 9 | 2016-04-11 11:36:16.403 UTC | null | null | null | null | 2,005,565 | null | 1 | 34 | mongoose | 20,107 | <p><a href="https://github.com/LearnBoost/mongoose/issues/1474">@aheckmann reply at github </a></p>
<pre><code>schema.pre('save', function (next) {
this.wasNew = this.isNew;
next();
});
schema.post('save', function () {
if (this.wasNew) {
// ...
}
});
</code></pre>
<p><code>isNew</code> is an... |
16,952,846 | How to keep console window open | <p>When I run my program, the console window seems to run and close. How to keep it open so I can see the results? </p>
<pre><code>class Program
{
public class StringAddString
{
public virtual void AddString()
{
var strings2 = new string[] { "1", "2"... | 16,952,898 | 13 | 0 | null | 2013-06-06 02:35:36.977 UTC | 4 | 2022-03-16 10:57:11.78 UTC | 2014-03-14 19:29:21.02 UTC | null | 41,956 | null | 1,929,393 | null | 1 | 45 | c#|console-application | 151,912 | <p>You forgot calling your method:</p>
<pre><code>static void Main(string[] args)
{
StringAddString s = new StringAddString();
s.AddString();
}
</code></pre>
<p>it should stop your console, but the result might not be what you expected, you should change your code a little bit:</p>
<pre><code>Con... |
4,779,188 | How to use mmap to allocate a memory in heap? | <p>Just the question stated, how can I use <code>mmap()</code> to allocate a memory in heap? This is my only option because <code>malloc()</code> is not a reentrant function.</p> | 4,779,245 | 2 | 4 | null | 2011-01-24 06:19:48.68 UTC | 14 | 2021-11-16 16:50:21.567 UTC | 2021-11-16 16:50:21.567 UTC | null | 5,459,839 | null | 130,278 | null | 1 | 16 | c|memory-management|heap-memory|mmap | 26,251 | <p>Why do you need reentrancy? The only time it's needed is for calling a function from a signal handler; otherwise, thread-safety is just as good. Both <code>malloc</code> and <code>mmap</code> are thread-safe. Neither is async-signal-safe per POSIX. In practice, <code>mmap</code> probably works fine from a signal han... |
4,175,188 | Setting memory of Java programs that runs from Eclipse | <p>I'm running a Java application from Eclipse that need a lot of memory.</p>
<p>Where can i put the <strike><code>-Xmms</code></strike><code>-xms</code> flag ?</p> | 4,175,193 | 2 | 0 | null | 2010-11-13 23:01:53.45 UTC | 1 | 2010-11-13 23:19:03.917 UTC | 2010-11-13 23:19:03.917 UTC | null | 449,071 | null | 449,071 | null | 1 | 20 | java|eclipse|memory | 40,832 | <p>You can set the VM arguments for a specific run configuration:</p>
<p><em>Run → Run Configurations... → Arguments Tab → VM arguments</em></p>
<p>Btw, you may want to try <code>-Xms</code> instead of <code>-Xmms</code>.</p> |
4,333,463 | What does this strange Jersey warning mean? | <p>What does this warning mean in Jersey 1.4:</p>
<pre><code>WARNING: A sub-resource method, public final java.lang.String com.XXX.render(),
with URI template, "/", is treated as a resource method
</code></pre>
<p>This is how the method looks:</p>
<pre><code>@GET
@Produces(MediaType.APPLICATION_XML)
@Path("/")
publ... | 4,333,532 | 2 | 0 | null | 2010-12-02 09:31:33.42 UTC | 1 | 2012-06-28 01:35:45.873 UTC | 2012-06-28 01:35:45.873 UTC | null | -1 | null | 187,141 | null | 1 | 29 | java|jersey | 8,569 | <p>Why do you need specify such path for method? @Get is enough to tell jersey that it is default method for entire class (I'm assuming that your class has some @Path("/MyRes") annotation).</p> |
4,173,483 | HTML Encoding Strings - ASP.NET Web Forms VS Razor View Engine | <p>I'm not quite sure how this works yet... trying to find documentation.</p>
<p>In my existing app I've got two different ways of rendering strings in my View</p>
<pre><code><%: model.something %>
<!-- or -->
<%= model.something %>
</code></pre>
<p>The first one is html encoded, and the second one... | 5,259,479 | 2 | 0 | null | 2010-11-13 16:27:46.877 UTC | 0 | 2012-04-09 13:50:37.27 UTC | 2012-04-09 13:50:37.27 UTC | null | 124,069 | null | 124,069 | null | 1 | 35 | asp.net-mvc-3|razor|viewengine|html-encode | 25,208 | <p>I guess the best approach would be to use the Raw extension-method: <code>@Html.Raw(Model.Something)</code></p> |
68,444,429 | How can I distinguish between high- and low-performance cores/threads in C++? | <p>When talking about multi-threading, it often seems like threads are treated as equal - just the same as the main thread, but running next to it.</p>
<p>On some new processors, however, such as the <a href="https://en.wikipedia.org/wiki/Apple_silicon#M_series" rel="nofollow noreferrer">Apple "M" series</a> ... | 68,448,721 | 5 | 9 | null | 2021-07-19 17:06:31.233 UTC | 9 | 2021-10-18 20:38:39.723 UTC | 2021-10-18 20:38:39.723 UTC | null | 12,501,684 | null | 12,501,684 | null | 1 | 71 | c++|multithreading|performance|intel|apple-m1 | 7,394 | <blockquote>
<p>How to distinguish between high- and low-performance cores/threads in C++?</p>
</blockquote>
<p>Please understand that "thread" is an abstraction of the hardware's capabilities and that something beyond your control (the OS, the kernel's scheduler) is responsible for creating and managing this... |
9,938,008 | Variance and Mean of Image | <p>I am calculating mean and variance of my original and stego image to compare them
I am using grayscale BMP image for comaprison</p>
<pre><code>image=imread("image name")
M = mean(image(:))
V = var((image(:)))
</code></pre>
<p>Is this is correct way fo calculating mean/var in MATLAB? My Variance is getting more tha... | 9,938,918 | 2 | 0 | null | 2012-03-30 06:28:05.717 UTC | 4 | 2012-08-15 12:51:31.363 UTC | null | null | null | null | 1,268,559 | null | 1 | 6 | matlab | 39,332 | <p>These are indeed the correct way to calculate the mean and variance over all the pixels of your image.</p>
<p>It is not impossible that your variance is larger than the mean as both are defined in the following way:</p>
<pre><code>mean = sum(x)/length(x)
variance = sum((x - mean(x)).^2)/(length(x) - 1);
</code... |
9,932,072 | Matplotlib table formatting | <p><img src="https://i.stack.imgur.com/XtUKQ.png" alt="enter image description here">
Can't seem to locate in the documentation how to <strong>increase the line-height</strong> of the cells, as the text itself is very cramped.</p>
<p>Any help with code is appreciated! Table formatting doesn't seem to be well documen... | 9,947,184 | 2 | 1 | null | 2012-03-29 19:24:26.067 UTC | 15 | 2017-09-14 18:34:07.35 UTC | 2017-03-17 19:50:41.843 UTC | null | 4,370,109 | null | 321,781 | null | 1 | 30 | python|matplotlib | 47,922 | <p>The matplotlib documentation says </p>
<blockquote>
<p>Add a table to the current axes. Returns a matplotlib.table.Table instance. For finer grained control over tables, use the Table class and add it to the axes with add_table().</p>
</blockquote>
<p>You could do is the following, look at the properties of your... |
10,204,471 | Convert char array to a int number in C | <p>I want to convert a char array[] like:</p>
<pre><code>char myarray[4] = {'-','1','2','3'}; //where the - means it is negative
</code></pre>
<p>So it should be the integer: -1234
using <strong>standard</strong> libaries in <strong>C</strong>. I could not find any elegant way to do that.</p>
<p>I can append the '\0... | 10,204,663 | 5 | 5 | null | 2012-04-18 07:02:04.493 UTC | 16 | 2020-07-02 20:57:57.01 UTC | 2012-04-18 07:25:06.61 UTC | null | 812,912 | null | 1,221,495 | null | 1 | 41 | c|arrays|char|int | 304,642 | <p>I personally don't like <code>atoi</code> function. I would suggest <code>sscanf</code>:</p>
<pre><code>char myarray[5] = {'-', '1', '2', '3', '\0'};
int i;
sscanf(myarray, "%d", &i);
</code></pre>
<p>It's very standard, it's in the <code>stdio.h</code> library :)</p>
<p>And in my opinion, it allows you much ... |
9,718,117 | Selecting first 10 records, then next 10, paging using Linq | <p>How select first 10 records, Then the next 10, Then the next 10, and so long as the array will not end.</p>
<pre><code>Phrases = bannersPhrases.Select(x=>x.Phrase).Take(10).ToArray()
</code></pre>
<p>How get the next 10 records?</p> | 9,718,155 | 4 | 0 | null | 2012-03-15 10:44:45.063 UTC | 16 | 2018-11-27 09:37:13.117 UTC | 2012-11-28 00:31:05.97 UTC | null | 815,724 | null | 1,266,349 | null | 1 | 42 | c#|linq | 109,344 | <pre><code>var total = bannersPhrases.Select(p => p.Phrase).Count();
var pageSize = 10; // set your page size, which is number of records per page
var page = 1; // set current page number, must be >= 1 (ideally this value will be passed to this logic/function from outside)
var skip = pageSize * (page-1);
var c... |
9,769,496 | Celery Received unregistered task of type (run example) | <p>I'm trying to run <a href="http://ask.github.com/celery/getting-started/first-steps-with-celery.html#id3" rel="noreferrer">example</a> from Celery documentation.</p>
<p>I run: <code>celeryd --loglevel=INFO</code></p>
<pre><code>/usr/local/lib/python2.7/dist-packages/celery/loaders/default.py:64: NotConfigured: No ... | 9,769,705 | 40 | 3 | null | 2012-03-19 11:40:50.567 UTC | 27 | 2022-07-06 14:53:57.557 UTC | 2012-06-27 11:00:56.643 UTC | null | 171,278 | null | 824,088 | null | 1 | 133 | python|celery | 136,813 | <p>You can see the current list of registered tasks in the <code>celery.registry.TaskRegistry</code> class. Could be that your celeryconfig (in the current directory) is not in <code>PYTHONPATH</code> so celery can't find it and falls back to defaults. Simply specify it explicitly when starting celery.</p>
<pre><code>... |
9,841,623 | Mockito : how to verify method was called on an object created within a method? | <p>I am new to Mockito.</p>
<p>Given the class below, how can I use Mockito to verify that <code>someMethod</code> was invoked exactly once after <code>foo</code> was invoked?</p>
<pre><code>public class Foo
{
public void foo(){
Bar bar = new Bar();
bar.someMethod();
}
}
</code></pre>
<p>I wo... | 9,841,929 | 8 | 3 | null | 2012-03-23 15:09:31.85 UTC | 49 | 2022-03-10 09:34:59.05 UTC | null | null | null | null | 584,862 | null | 1 | 435 | java|unit-testing|junit|mockito | 783,814 | <p><a href="http://en.wikipedia.org/wiki/Dependency_injection" rel="noreferrer">Dependency Injection</a></p>
<p>If you inject the Bar instance, or a factory that is used for creating the Bar instance (or one of the other 483 ways of doing this), you'd have the access necessary to do perform the test.</p>
<p>Factory Exa... |
63,241,719 | Improve the speed of a JavaScript function | <p>I have a task I found on CodeWars and I managed to solve it, however, after submitting is says:</p>
<blockquote>
<p>Execution timed out: (12000 ms)</p>
</blockquote>
<p>When I try to test the function is passed, but I guess it is too slow.
Before you condemn me for not finding the answer on my own. I don't really ca... | 63,241,820 | 6 | 7 | null | 2020-08-04 07:02:16.79 UTC | 2 | 2020-08-24 13:30:51.767 UTC | 2020-08-04 18:49:00.867 UTC | null | 1,048,572 | null | 13,108,189 | null | 1 | 29 | javascript|arrays|function|sum | 1,529 | <p>For this kind of array maipulations, you better not use build in methods, like <code>slice</code> or <code>reduce</code>, because they are slow in comparison to a <code>for</code> loop, or any other looping approaches.</p>
<p>This approach takes a sinlge loop and uses the index for getting a value of the given array... |
8,054,009 | jQuery/JavaScript: Is it a date? (Validate whether is a date) | <p>I have datepicker, but I could not find a way to validate if the user's entry is a date or not AND if it follows the required format (<strong>format: yyyy-mm-dd</strong>) </p>
<p>This is my datepicker:</p>
<pre><code>$("input[name='date']").datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true, ... | 8,054,052 | 3 | 2 | null | 2011-11-08 16:46:27.613 UTC | 2 | 2017-02-23 05:16:55.123 UTC | 2017-05-23 12:34:28.393 UTC | null | -1 | null | 931,377 | null | 1 | 20 | javascript|jquery|validation|date|datepicker | 83,002 | <p>Something like this should work:</p>
<pre><code>jQuery.validator.addMethod("customDateValidator",
function(value, element) {
try { jQuery.datepicker.parseDate("mm/dd/yyyy", value); return true; }
catch(e) {
return false;
}
},
"Please enter a valid date"
);
$("input[... |
7,933,596 | Django dynamic model fields | <p>I'm working on a <strong>multi-tenanted</strong> application in which some users can define their own data fields (via the admin) to collect additional data in forms and report on the data. The latter bit makes JSONField not a great option, so instead I have the following solution:</p>
<pre><code>class CustomDataF... | 7,934,577 | 3 | 1 | null | 2011-10-28 18:58:20.063 UTC | 159 | 2015-12-10 04:52:04.307 UTC | 2011-12-21 20:39:40.673 UTC | null | 497,056 | null | 402,605 | null | 1 | 176 | python|django|dynamic|django-models|django-custom-manager | 83,972 | <p><strong><em>As of today, there are four available approaches, two of them requiring a certain storage backend:</em></strong></p>
<ol>
<li><p><strong><a href="https://github.com/mvpdev/django-eav" rel="noreferrer">Django-eav</a></strong> (the original package is no longer mantained but has some <strong><a href="http... |
11,786,530 | Can python threads access variables in the namespace? | <p>I have a script that creates a bunch of threads, runs a program to use the threads to run tasks from a queue, and returns something from each thread. I want to count how many of these returned successfully, so I set a variable "successful=0" and increment it every time the queue reports a task completed successfully... | 11,786,875 | 3 | 0 | null | 2012-08-02 22:07:00.563 UTC | 13 | 2012-08-03 15:47:32.743 UTC | null | null | null | null | 331,118 | null | 1 | 18 | python|multithreading|scope|queue | 27,154 | <pre><code>successful+=1
</code></pre>
<p>is not a thread-safe operation. With multiple threads trying to increment a shared global variable, collisions may happen and <code>successful</code> will not be incremented properly.</p>
<p>To avoid this error, use a lock:</p>
<pre><code>lock = threading.Lock()
def foo():
... |
11,980,062 | In python, how do you import all classes from another module without keeping the imported module's namespace? | <p>How do you import classes and methods from another module without retaining the former module namespace? </p>
<p>I am current refactoring some legacy code and am frequently doing imports similar to these. </p>
<pre><code>from legacy_module import ClassA as ClassA
from legacy_module import ClassB as ClassB
from leg... | 11,980,088 | 1 | 0 | null | 2012-08-16 02:48:55.443 UTC | null | 2012-08-16 03:34:21.743 UTC | null | null | null | null | 160,507 | null | 1 | 32 | python | 39,008 | <p>Use <code>from legacy_module import *</code> as your entire import.</p> |
11,489,055 | SQLite ORDER BY string containing number starting with 0 | <p>as the title states:</p>
<p>I have a select query, which I'm trying to "order by" a field which contains numbers, the thing is this numbers are really strings starting with 0s, so the "order by" is doing this...</p>
<pre><code>...
10
11
12
01
02
03
...
</code></pre>
<p>Any thoughts?</p>
<p>EDIT: if I do this: ".... | 11,489,098 | 5 | 4 | null | 2012-07-15 03:01:51.49 UTC | 12 | 2019-07-12 12:49:17.043 UTC | 2013-09-04 03:16:52.95 UTC | null | 1,447,087 | null | 1,447,087 | null | 1 | 39 | sql|string|sqlite|sql-order-by|numeric | 35,284 | <p>You can use <code>CAST</code> <a href="http://www.sqlite.org/lang_expr.html#castexpr" rel="noreferrer">http://www.sqlite.org/lang_expr.html#castexpr</a> to cast the expression to an Integer.</p>
<pre><code>sqlite> CREATE TABLE T (value VARCHAR(2));
sqlite> INSERT INTO T (value) VALUES ('10');
sqlite> INSERT... |
11,476,371 | Sort by multiple keys using different orderings | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/11206884/how-to-write-python-sort-key-functions-for-descending-values">How to write Python sort key functions for descending values</a> </p>
</blockquote>
<p>In Python 3, it's pretty easy to sort a list of obje... | 11,476,588 | 3 | 1 | null | 2012-07-13 18:38:38.597 UTC | 23 | 2012-07-13 19:47:20.807 UTC | 2017-05-23 12:18:07.867 UTC | null | -1 | null | 469,408 | null | 1 | 60 | python|python-3.x | 35,151 | <p>There is no built-in way to handle this. For the general case, you must sort twice: first by the secondary sort, then by the primary sort. As @Mark Ransom mentioned in his comment, in many cases the variables are numeric, and so you can use the negative value to flip the ordering.</p>
<p>If you know the type of t... |
11,830,174 | How to flatten tree via LINQ? | <p>So I have simple tree:</p>
<pre><code>class MyNode
{
public MyNode Parent;
public IEnumerable<MyNode> Elements;
int group = 1;
}
</code></pre>
<p>I have a <code>IEnumerable<MyNode></code>. I want to get a list of all <code>MyNode</code> (including inner node objects (<code>Elements</code>)) as one f... | 11,830,287 | 16 | 4 | null | 2012-08-06 14:22:05.487 UTC | 49 | 2022-08-25 11:03:58.62 UTC | null | null | null | null | 1,056,328 | null | 1 | 107 | c#|.net|linq|.net-4.0|tree | 56,669 | <p>You can flatten a tree like this:</p>
<pre><code>IEnumerable<MyNode> Flatten(IEnumerable<MyNode> e) =>
e.SelectMany(c => Flatten(c.Elements)).Concat(new[] { e });
</code></pre>
<p>You can then filter by <code>group</code> using <code>Where(...)</code>.</p>
<p>To earn some "points for style",... |
11,787,330 | Is it possible in SASS to inherit from a class in another file? | <p>The question pretty much says it all.</p>
<p>For instance, if I were using, say, <a href="http://twitter.github.com/bootstrap/" rel="noreferrer">Twitter Bootstrap</a>, could I define classes in my own SASS stylesheet that inherit from Bootstrap's CSS classes? Or does inheritance in SASS only work within the scope o... | 15,272,790 | 4 | 0 | null | 2012-08-02 23:36:00.413 UTC | 13 | 2020-06-25 13:06:29.667 UTC | 2013-03-07 13:47:55.883 UTC | null | 2,053,161 | null | 105,570 | null | 1 | 111 | css|inheritance|stylesheet|sass | 66,788 | <p><strong>YES!</strong> its possible.</p>
<p>If you want all <code><button></code> elements to inherit the <code>.btn</code> class from <a href="http://twitter.github.com/bootstrap/base-css.html#buttons">Twitter Bootstrap's Default buttons</a></p>
<p>In your <code>styles.scss</code> file you would have to firs... |
11,614,047 | What makes a keychain item unique (in iOS)? | <p>My question concerns keychains in iOS (iPhone, iPad, ...). I think (but am not sure) that the implementation of keychains under Mac OS X raises the same question with the same answer.</p>
<hr>
<p>iOS provides five types (classes) of keychain items. You must chose one of those five values for the key <code>kSecClas... | 11,672,200 | 4 | 1 | null | 2012-07-23 14:00:14.523 UTC | 92 | 2020-03-18 15:33:58.38 UTC | 2016-08-17 21:49:16.307 UTC | null | 231,684 | null | 1,302,716 | null | 1 | 121 | objective-c|ios|macos|keychain | 25,999 | <p>The primary keys are as follows (derived from open source files from Apple, see <a href="http://www.opensource.apple.com/source/libsecurity_cdsa_utilities/libsecurity_cdsa_utilities-55006/lib/Schema.m4" rel="noreferrer">Schema.m4</a>, <a href="http://www.opensource.apple.com/source/libsecurity_cdsa_utilities/libsecu... |
3,505,170 | Entity Framework - what's the difference between using Include/eager loading and lazy loading? | <p>I've been trying to familiarize myself with the Entity Framework. Most of it seems straight forward, but I'm a bit confused on the difference between eager loading with the Include method and default lazy loading. Both seem like they load related entities, so on the surface it looks like they do the same thing. W... | 3,505,233 | 4 | 0 | null | 2010-08-17 17:27:55.9 UTC | 12 | 2018-03-28 05:37:11.543 UTC | null | null | null | null | 399,584 | null | 1 | 18 | entity-framework|lazy-loading|eager-loading | 11,800 | <p>Let's say you have two entities with a one-to-many relationship: Customer and Order, where each Customer can have multiple Orders.</p>
<p>When loading up a Customer entity, Entity Framework allows you to either eager load or lazy load the Customer's Orders collection. If you choose to eager load the Orders collecti... |
3,511,057 | Git receive/update hooks and new branches | <p>I have a problem with the 'update' hook. In the case of a new branch, it gets a 0000000000000000000000000000000000000000 as the 'oldrev'. And I don't know how to handle that case.</p>
<p>We have the requirement, that every commit message references a valid Jira issue. So I have installed an "update" hook on our cen... | 3,512,275 | 4 | 1 | null | 2010-08-18 10:23:24.847 UTC | 5 | 2014-06-19 17:15:51.533 UTC | null | null | null | null | 410,713 | null | 1 | 34 | git|git-push|githooks | 11,934 | <p>The term "right answer" is a bit ambiguous in this case. I actually think that "all revs reachable from newrev but nowhere else" is completely correct. This is true even if there was a merge - in that case, you should see the commits unique to the new ref, and the merge commit, but not the commits that were merged.<... |
3,338,680 | Is there a CSS selector by class prefix? | <p>I want to apply a CSS rule to any element whose one of the classes matches specified prefix.</p>
<p>E.g. I want a rule that will apply to div that has class that starts with <code>status-</code> (A and C, but not B in following snippet):</p>
<pre class="lang-html prettyprint-override"><code><div id='A' class='f... | 8,588,532 | 4 | 0 | null | 2010-07-26 20:22:08.693 UTC | 56 | 2018-11-19 00:38:14.027 UTC | 2015-06-22 01:09:21.33 UTC | null | 2,756,409 | null | 93,422 | null | 1 | 225 | css|css-selectors | 150,513 | <p>It's not doable with CSS2.1, but it is possible with CSS3 attribute substring-matching selectors (which <em>are</em> supported in IE7+):</p>
<pre><code>div[class^="status-"], div[class*=" status-"]
</code></pre>
<p>Notice the space character in the second attribute selector. This picks up <code>div</code> elements... |
3,946,709 | #1222 - The used SELECT statements have a different number of columns | <p>Why am i getting a #1222 - The used SELECT statements have a different number of columns
? i am trying to load wall posts from this users friends and his self.</p>
<pre><code>SELECT u.id AS pid, b2.id AS id, b2.message AS message, b2.date AS date FROM
(
(
SELECT b.id AS id, b.pid AS pid, b.message AS m... | 3,946,730 | 5 | 0 | null | 2010-10-15 22:50:23.323 UTC | 3 | 2020-09-23 09:04:23.313 UTC | 2010-10-15 22:53:45.187 UTC | null | 135,152 | null | 458,642 | null | 1 | 12 | sql|mysql|mysql-error-1222 | 55,954 | <p>The first statement in the UNION returns four columns:</p>
<pre><code>SELECT b.id AS id,
b.pid AS pid,
b.message AS message,
b.date AS date
FROM wall_posts AS b
</code></pre>
<p>The second one returns <strong><em>six</em></strong>, because the * expands to include all the columns from <... |
3,822,609 | Documentation and API Samples for drawing on Windows Aero Glass (DWM, GDI, GDI+) for all Win32 programmers | <p>I am looking for good resources for learning to use the Win32/GDI APIs or whatever supercedes it to draw and paint directly using the Win32 API to a glass form.</p>
<p>While I am using Delphi, I tagged this as Delphi or Visual C++. Any code samples and articles that you can find would be appreciated. MSDN article... | 3,826,784 | 5 | 0 | null | 2010-09-29 14:31:08.64 UTC | 17 | 2013-12-03 23:38:13.147 UTC | 2013-12-03 23:38:13.147 UTC | null | 464,709 | null | 84,704 | null | 1 | 18 | windows|delphi|visual-c++|windows-7|aero-glass | 6,666 | <p>This is a subset of my "Glass" bookmarks folder, the result of a <em>lot</em> of research / searching on this topic. I've found all of these useful for learning about glass and solving various problems drawing on it. Most of these include Delphi code, but I've noted where it's for another language.</p>
<h2>Plain ... |
3,287,966 | Reasons for and against moving from SQL server to MongoDB | <p>I know this is a big question and it's not a yes or no answer but we develop web apps and are looking into using MongoDB for our persistence solution. Combining MongoDB with NoRM for object storage.</p>
<p>What I want to ask is what pitfalls have you experienced with switching from SQL to mongo? When is mongo simpl... | 3,288,325 | 6 | 0 | null | 2010-07-20 07:52:10.463 UTC | 16 | 2018-07-25 16:59:53.557 UTC | 2017-11-26 10:21:28.897 UTC | null | 3,885,376 | null | 43,337 | null | 1 | 47 | c#|sql|mongodb|nosql | 17,276 | <p>In my opinion the format of your data should be the primary concern when choosing a storage backend. Do you have data that is relational in nature? If so, can it and is it a good idea to model the data in documents? Data modeling is as important in a document database as in an relational database, it just done diffe... |
3,728,617 | Adding model-wide help text to a django model's admin form | <p>In my django app, I would like to be able to add customized help text to the admin change form for some of my models. Note I'm not talking about the field specific <code>help_text</code> attribute that I can set on individual fields. For example, at the top of the change form for <code>My_Model</code> in <code>My_... | 3,729,995 | 6 | 0 | null | 2010-09-16 16:20:20.717 UTC | 23 | 2021-08-19 18:26:22.88 UTC | null | null | null | null | 58,001 | null | 1 | 54 | python|django|django-models|django-admin | 24,594 | <p>There is a fairly simple, yet underdocumented way of accomplishing this. </p>
<h2>Define render_change_form in the Admin class</h2>
<p>First, you need to pass extra context to your admin. To do this, you can define a render_change_form function within your admin Class, e.g.:</p>
<pre><code># admin.py
class Custom... |
3,335,162 | Creating stored procedure and SQLite? | <p>Is it somehow possible to create a stored procedure, when using SQLite?</p> | 3,335,202 | 6 | 0 | null | 2010-07-26 13:23:53.893 UTC | 29 | 2022-09-16 00:42:28.87 UTC | 2012-10-23 19:53:41.92 UTC | null | 41,071 | null | 304,357 | null | 1 | 223 | sqlite|stored-procedures | 203,847 | <blockquote>
<p>SQLite has had to sacrifice other characteristics that some people find useful, such as high concurrency, fine-grained access control, a rich set of built-in functions, <strong><em>stored procedures</em></strong>, esoteric SQL language features, XML and/or Java extensions, tera- or peta-byte scalabili... |
3,464,061 | Cast base class to derived class python (or more pythonic way of extending classes) | <p>I need to extend the Networkx python package and add a few methods to the <code>Graph</code> class for my particular need</p>
<p>The way I thought about doing this is simplying deriving a new class say <code>NewGraph</code>, and adding the required methods.</p>
<p>However there are several other functions in netwo... | 3,464,154 | 9 | 0 | null | 2010-08-12 01:20:12.843 UTC | 23 | 2021-05-24 11:11:47.653 UTC | null | null | null | null | 93,580 | null | 1 | 58 | python|inheritance|derived-class|base-class | 53,323 | <p>If you are just adding behavior, and not depending on additional instance values, you can assign to the object's <code>__class__</code>:</p>
<pre><code>from math import pi
class Circle(object):
def __init__(self, radius):
self.radius = radius
def area(self):
return pi * self.radius**2
cla... |
3,861,634 | How to reduce compiled file size? | <p>Lets compare c and go:
Hello_world.c :</p>
<pre><code>#include<stdio.h>
int main(){
printf("Hello world!");
}
</code></pre>
<p>Hello_world.go:</p>
<pre><code>package main
import "fmt"
func main(){
fmt.Printf("Hello world!")
}
</code></pre>
<p>Compile both:</p>
<pre><code>$gcc Hello_world.c -o Hell... | 3,861,677 | 11 | 6 | null | 2010-10-05 07:29:48.647 UTC | 32 | 2021-11-22 09:37:14.983 UTC | null | null | null | null | 461,133 | null | 1 | 100 | go | 60,007 | <h2>Note: This answer is outdated</h2>
<p>Please note that this answer is outdated. Please refer to the other higher-voted answers. I would like to delete this post, accepted answers can't be deleted though.</p>
<hr />
<p>Is it a problem that the file is larger? I don't know Go but I would assume that it statically lin... |
3,687,315 | How to delete shared preferences data from App in Android | <p>How do I delete SharedPreferences data for my application?</p>
<p>I'm creating an application that uses a lot of web services to sync data. For testing purposes, I need to wipe out some SharedPreferences values when I restart the app.</p> | 3,687,333 | 29 | 0 | null | 2010-09-10 18:34:52.493 UTC | 103 | 2022-07-26 11:10:42.233 UTC | 2019-11-14 07:13:37.843 UTC | null | 6,717,610 | null | 406,790 | null | 1 | 570 | android|sharedpreferences | 473,660 | <p>To remove specific values: <a href="https://developer.android.com/reference/android/content/SharedPreferences.Editor.html#remove(java.lang.String)" rel="noreferrer">SharedPreferences.Editor.remove()</a> followed by a <code>commit()</code></p>
<p>To remove them all <code>SharedPreferences.Editor.clear()</code> follo... |
7,983,655 | Why should someone use the .NET Framework 4 Client Profile? | <p>Are there any good reasons to use .NET Framework 4 <a href="https://en.wikipedia.org/wiki/.NET_Framework_version_history#.NET_Framework_3.5_SP1_Client_Profile" rel="noreferrer">Client Profile</a> instead of the <em>full version</em>?</p>
<p>I mean, real-life reasons. I am creating a .NET application, and since it's... | 7,983,733 | 4 | 1 | null | 2011-11-02 16:15:46.633 UTC | 3 | 2014-04-25 21:07:13.837 UTC | 2013-05-22 13:46:13.59 UTC | null | 63,550 | user1026028 | null | null | 1 | 29 | .net | 37,313 | <p>The <a href="http://msdn.microsoft.com/en-us/library/cc656912.aspx">documentation</a> answers this:</p>
<blockquote>
<p>The .NET Framework 4 Client Profile is a subset of the .NET Framework
4 that is optimized for client applications. It provides functionality
for most client applications, including Windows P... |
8,293,426 | error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’ | <p>Wrong form: </p>
<pre><code>int &z = 12;
</code></pre>
<p>Correct form:</p>
<pre><code>int y;
int &r = y;
</code></pre>
<p><em><strong>Question</em></strong>:<br>
Why is the first code wrong? What is the "<strong>meaning</strong>" of the error in the title?</p> | 8,294,009 | 5 | 4 | null | 2011-11-28 08:51:09.847 UTC | 43 | 2017-02-09 14:22:44.573 UTC | null | null | null | null | 462,608 | null | 1 | 95 | c++|pointers|reference | 195,394 | <p>C++03 3.10/1 says: "Every expression is either an lvalue or an rvalue." It's important to remember that lvalueness versus rvalueness is a property of expressions, not of objects.</p>
<p>Lvalues name objects that persist beyond a single expression. For example, <code>obj</code> , <code>*ptr</code> , <code>ptr[inde... |
7,764,812 | How to write C# Scheduler | <p>How do I write a Alert which will run at 00:00, 00:15, 00:30, and so on every day?</p>
<p>Can you give me an example code?</p>
<p>Thank you.</p> | 7,764,862 | 6 | 3 | null | 2011-10-14 08:11:43.38 UTC | 5 | 2013-12-13 09:12:42.733 UTC | 2011-10-17 10:09:57.137 UTC | null | 149,578 | null | 149,578 | null | 1 | 10 | c# | 44,289 | <p>You can use a timer that runs every minute that checks the current time. The check can look like:</p>
<pre><code>private void OnTimerTick()
{
if(DateTime.Now.Minutes%15==0)
{
//Do something
}
}
</code></pre>
<p>But if you are looking for a program or service that has to be run every 15 minutes ... |
8,070,805 | Difference between UIImage and UIImageView | <p>What is the difference between <code>UIImage</code> and <code>UIImageView</code>? Can someone explain it with an example?</p> | 8,070,847 | 8 | 0 | null | 2011-11-09 19:57:43.483 UTC | 10 | 2020-08-20 11:29:50.92 UTC | 2011-11-09 21:11:11.937 UTC | null | 603,977 | null | 605,395 | null | 1 | 36 | objective-c|ios|cocoa-touch|uiimageview|uiimage | 26,783 | <p>Example:</p>
<pre><code>UIImage *bgImage = [UIImage imageNamed:@"Default@2x.png"];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:bgImage];
backgroundImageView.frame = [[UIScreen mainScreen] bounds];
</code></pre>
<p><a href="http://developer.apple.com/library/ios/#documentation/uikit/refere... |
8,302,928 | AngularJS with Django - Conflicting template tags | <p>I want to use AngularJS with Django however they both use <code>{{ }}</code> as their template tags. Is there an easy way to change one of the two to use some other custom templating tag?</p> | 11,108,407 | 12 | 3 | null | 2011-11-28 21:55:48.517 UTC | 117 | 2017-09-16 22:39:14.273 UTC | 2012-03-06 09:53:24.417 UTC | null | 71,343 | null | 432,193 | null | 1 | 306 | javascript|django|django-templates|angularjs | 75,378 | <p>For Angular 1.0 you should use the $interpolateProvider apis to configure the interpolation symbols: <a href="http://docs.angularjs.org/api/ng.%24interpolateProvider">http://docs.angularjs.org/api/ng.$interpolateProvider</a>.</p>
<p>Something like this should do the trick:</p>
<pre><code>myModule.config(function($... |
4,480,278 | List of Python format characters | <p>I've been looking for the list Python format characters for a good 30 minutes. I can't find any.</p>
<p>Examples are</p>
<blockquote>
<p>%d, %r</p>
</blockquote>
<p>etc but I need a list with them along with a description if possible please.</p> | 4,480,309 | 3 | 2 | null | 2010-12-18 21:33:10.81 UTC | 11 | 2016-06-14 04:49:30.5 UTC | null | null | null | null | 540,909 | null | 1 | 23 | python|format|character | 166,889 | <p>Here you go, Python documentation on <a href="http://docs.python.org/library/stdtypes.html#string-formatting" rel="nofollow noreferrer">old string formatting</a>. tutorial -> 7.1.1. Old String Formatting -> "More information can be found in the [link] section".</p>
<p>Note that you should start using the <a href="h... |
4,762,594 | jQuery: keyup for TAB-key? | <p>So, i'm having some trouble getting my script to run IF the Tab key is pressed. After some quick googling, the charcode for Tab is 9. Also, while we're talking, is there any better ways of checking if a key is pressed without using charcodes? I'm asking because i keep getting the following Warning by firebug when us... | 4,762,812 | 3 | 0 | null | 2011-01-21 18:48:54.447 UTC | 6 | 2011-01-21 19:47:03.91 UTC | 2011-01-21 18:51:14.65 UTC | null | 220,819 | null | 584,899 | null | 1 | 43 | jquery|tabs | 76,112 | <p>My hunch is that when you press the tab key, your form's input loses focus, before the keyup happens. Try changing the binding to the body, like this:</p>
<pre><code> $('body').keyup(function(e) {
console.log('keyup called');
var code = e.keyCode || e.which;
if (code == '9') {
alert('Tab pressed');
... |
4,498,998 | How to initialize members in Go struct | <p>I am new to Golang so allocation in it makes me insane:</p>
<pre><code>import "sync"
type SyncMap struct {
lock *sync.RWMutex
hm map[string]string
}
func (m *SyncMap) Put (k, v string) {
m.lock.Lock()
defer m.lock.Unlock()
m.hm[k] = v, true
}
</code></pre>
<p>and later, I ... | 4,499,375 | 3 | 1 | null | 2010-12-21 11:58:09.343 UTC | 20 | 2016-08-02 18:43:16.253 UTC | 2016-08-02 18:43:16.253 UTC | user6169399 | null | null | 255,667 | null | 1 | 58 | new-operator|go | 63,453 | <p>You just need a constructor. A common used pattern is</p>
<pre><code>func NewSyncMap() *SyncMap {
return &SyncMap{hm: make(map[string]string)}
}
</code></pre>
<p>In case of more fields inside your struct, starting a goroutine as backend, or registering a finalizer everything could be done in this construct... |
4,475,726 | Devise and OmniAuth remembering OAuth | <p>So, I just got setup using Rails 3, Devise and OmniAuth via <a href="https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview" rel="noreferrer">https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview</a>.</p>
<p>I'm successfully authenticating users via Facebook, but they are not "rememberable" despi... | 4,679,631 | 4 | 0 | null | 2010-12-17 23:42:15.55 UTC | 12 | 2014-05-07 16:43:45.073 UTC | null | null | null | null | 520,267 | null | 1 | 18 | facebook|devise|ruby-on-rails-3|omniauth | 3,948 | <p>I agree that you would expect Devise to set a session before the request goes to FB. I guess this is a missing feature of Devise.</p>
<p>I had the problem myself where I used token_authenticatable. An api client was calling the following url directly:</p>
<pre><code>/users/auth/facebook?auth_token=TnMn7pjfADapMdsa... |
4,743,030 | Passing object as parameter to constructor function and copy its properties to the new object? | <p>I have a JavaScript constructor like this:</p>
<pre><code>function Box(obj) {
this.obj = obj;
}
</code></pre>
<p>which i want to pass an object as a parameter like this:</p>
<pre><code>var box = new Box({prop1: "a", prop2: "b", prop3: "c"})
</code></pre>
<p>and gives me something like this:</p>
<pre><code>b... | 4,743,038 | 4 | 1 | null | 2011-01-20 02:56:38.987 UTC | 8 | 2020-08-23 01:11:16.51 UTC | null | null | null | null | 483,780 | null | 1 | 35 | javascript|jquery|object|constructor | 28,258 | <p>You could do this. There is probably also a jquery way...</p>
<pre><code>function Box(obj) {
for (var fld in obj) {
this[fld] = obj[fld];
}
}
</code></pre>
<p>You can include a test for hasOwnProperty if you've (I think foolishly) extended object</p>
<pre><code>function Box(obj) {
for (var fld in obj) ... |
4,373,485 | Android Swipe on List | <p>Does anyone have a simple example of a ListActivity displaying Textviews in a column and when you swipe left to right you see that row in a new view? This would be to say edit the data for that row or show more detailed info on that row. Please do not reference code shogun or other sites as I have googled and have... | 9,340,202 | 4 | 2 | null | 2010-12-07 04:45:06.38 UTC | 65 | 2015-01-24 14:34:01.513 UTC | null | null | null | null | 346,309 | null | 1 | 48 | android|list|textview|listactivity|swipe | 31,165 | <p>I had the same problem and I didn't find my answer here.</p>
<p>I wanted to detect a swipe action in ListView item and mark it as swiped, while continue to support OnItemClick and OnItemLongClick.</p>
<p>Here is me solution:</p>
<p>1st The SwipeDetector class:</p>
<pre><code>import android.util.Log;
import andro... |
4,050,784 | Defining multiple foreign keys in one table to many tables | <p>I have 3 models:</p>
<p><strong>Post</strong>:</p>
<ul>
<li>id</li>
<li>title</li>
<li>body</li>
</ul>
<p><strong>Photo</strong>:</p>
<ul>
<li>id</li>
<li>filepath</li>
</ul>
<p><strong>Comment</strong>:</p>
<ul>
<li>id</li>
<li>post_id</li>
<li>body</li>
</ul>
<p>and corresponding tables in DB. Now, if I wan... | 4,050,811 | 5 | 0 | null | 2010-10-29 09:54:15.47 UTC | 9 | 2010-11-01 05:58:40.097 UTC | null | null | null | null | 450,449 | null | 1 | 14 | database-design|foreign-keys | 21,116 | <p>You could do this:</p>
<pre><code> post:
* post_id (PK)
* title
* body
photo:
* photo_id (PK)
* filepath
comment:
* comment_id (PK)
* body
comment_to_post
* comment_id (PK) -> FK to comment.comment_id
* post_id (PK) -> FK to post.post_id
comment_to_photo
* comment_id (PK) -> FK ... |
4,103,809 | How to create a ssh tunnel in ruby and then connect to mysql server on the remote host | <p>I would like to create a ruby script that I can run mysql commands on a remote server through a ssh tunnel. </p>
<p>Right now I have a manual process to do this:</p>
<ol>
<li>Create a tunnel -> ssh -L 3307:127.0.0.1:3306 </li>
<li>run ruby script.</li>
<li>Close tunnel.</li>
</ol>
<p>I would love to be able to a... | 9,912,538 | 5 | 0 | null | 2010-11-05 05:36:45.707 UTC | 17 | 2014-12-04 16:55:51.307 UTC | 2011-02-21 05:18:45.567 UTC | null | 557,279 | null | 498,023 | null | 1 | 30 | mysql|ruby|ssh | 19,715 | <p>I was able to get this to work without a fork using the mysql2 gem</p>
<pre><code>require 'rubygems'
require 'mysql2'
require 'net/ssh/gateway'
gateway = Net::SSH::Gateway.new(
'remotehost.com',
'username'
)
port = gateway.open('127.0.0.1', 3306, 3307)
client = Mysql2::Client.new(
host: "127.0.0.1",
user... |
4,196,968 | ObservableCollection<> vs. List<> | <p>I have lots of entities with nested <code>List<></code> in each.</p>
<p>For example, I have <code>BaseEntity</code> which has <code>List<ColumnEntity></code>.
<code>ColumnEntity</code> class has <code>List<Info></code> and so on.</p>
<p>We are working with a <a href="http://en.wikipedia.org/wiki/... | 4,197,068 | 5 | 0 | null | 2010-11-16 17:19:40.38 UTC | 18 | 2021-12-07 17:39:58.483 UTC | 2016-11-27 14:04:40.603 UTC | null | 63,550 | null | 399,250 | null | 1 | 82 | c#|.net|wpf | 99,592 | <p>Interesting question, considering that both <code>List</code> and <code>ObservableCollection</code> implement <code>IList<T></code> there isn't much of a difference there, <code>ObservableCollection</code> also implements <code>INotifyCollectionChanged</code> interface, which allows WPF to bind to it.</p>
<p>O... |
4,833,635 | C# properties: how to use custom set property without private field? | <p>I want to do this:</p>
<pre><code>public Name
{
get;
set
{
dosomething();
??? = value
}
}
</code></pre>
<p>Is it possible to use the auto-generated private field?
<br>Or is it required that I implement it this way:</p>
<pre><code>private string name;
public string Name
{
get
... | 4,833,660 | 5 | 1 | null | 2011-01-28 22:23:54.047 UTC | 5 | 2019-05-23 15:33:47.4 UTC | 2011-01-28 22:29:11.49 UTC | null | 23,234 | null | 107,029 | null | 1 | 121 | c#|properties | 115,514 | <p>Once you want to do anything custom in either the getter or the setter you cannot use auto properties anymore.</p> |
4,664,893 | How to manually set an authenticated user in Spring Security / SpringMVC | <p>After a new user submits a 'New account' form, I want to manually log that user in so they don't have to login on the subsequent page.</p>
<p>The normal form login page going through the spring security interceptor works just fine.</p>
<p>In the new-account-form controller I am creating a UsernamePasswordAuthentic... | 4,672,083 | 6 | 4 | null | 2011-01-12 02:44:11.57 UTC | 65 | 2021-12-09 05:01:21.573 UTC | null | null | null | null | 4,790,871 | null | 1 | 120 | java|authentication|spring-mvc|spring-security | 204,591 | <p>I had the same problem as you a while back. I can't remember the details but the following code got things working for me. This code is used within a Spring Webflow flow, hence the RequestContext and ExternalContext classes. But the part that is most relevant to you is the doAutoLogin method. </p>
<pre><code>public... |
4,481,163 | Most Popular/Frequently Used/Important Interfaces in C# .NET? | <p>Apart from IEnumerable, IComparable, what other "important" (or frequently used) interfaces are there for me to know in C#.NET? </p> | 4,481,345 | 7 | 3 | null | 2010-12-19 01:26:44.29 UTC | 13 | 2010-12-21 15:35:42.4 UTC | 2010-12-19 01:35:17.79 UTC | null | 257,558 | null | 257,558 | null | 1 | 40 | c#|.net | 16,211 | <p><a href="https://stackoverflow.com/questions/4240438/what-are-the-most-used-interfaces-in-c/4240764#4240764">Same question</a></p>
<p>Copy-Paste from there:</p>
<ul>
<li>IEnumerable (and IEnumerable): for use with foreach and LINQ</li>
<li>IDisposable: for resources requiring cleanup, used with using</li>
<li>IQue... |
4,387,680 | Transparent background on winforms? | <p>I wanted to make my windows form transparent so removed the borders, controls and everything leaving only the forms box, then I tried to the BackColor and TransparencyKey to transparent but it didnt work out as BackColor would not accept transparent color. After searching around I found this at msdn:</p>
<pre><code... | 4,387,762 | 8 | 7 | null | 2010-12-08 12:57:40.95 UTC | 12 | 2020-06-26 11:16:14.24 UTC | 2016-07-08 18:47:15.583 UTC | null | 2,827,771 | null | 342,740 | null | 1 | 52 | c#|winforms|background|transparent | 122,676 | <p>The manner I have used before is to use a wild color (a color no one in their right mind would use) for the BackColor and then set the transparency key to that.</p>
<pre><code>this.BackColor = Color.LimeGreen;
this.TransparencyKey = Color.LimeGreen;
</code></pre> |
4,173,787 | String exact match | <p>I have a string in which the word "LOCAL" occurs many times. I used the <code>find()</code> function to search for this word but it returns another word "Locally" as well. How can I match the word "local" exactly?</p> | 4,173,810 | 9 | 0 | null | 2010-11-13 17:32:18.883 UTC | 6 | 2022-08-11 12:07:51.147 UTC | 2016-03-24 21:19:43.34 UTC | null | -1 | null | 1,648,247 | null | 1 | 24 | python|string | 92,978 | <p>For this kind of thing, regexps are very useful :</p>
<pre><code>import re
print(re.findall('\\blocal\\b', "Hello, locally local test local."))
// ['local', 'local']
</code></pre>
<p>\b means word boundary, basically. Can be space, punctuation, etc.</p>
<p>Edit for comment :</p>
<pre><code>print(re.sub('\\bloca... |
4,654,653 | How can I use NSError in my iPhone App? | <p>I am working on catching errors in my app, and I am looking into using <code>NSError</code>. I am slightly confused about how to use it, and how to populate it.</p>
<p><strong>Could someone provide an example on how I populate then use <code>NSError</code>?</strong></p> | 4,654,759 | 9 | 0 | null | 2011-01-11 05:53:59.593 UTC | 93 | 2020-04-02 16:10:38.99 UTC | 2015-10-26 09:16:11.183 UTC | null | 2,725,435 | null | 144,695 | null | 1 | 235 | iphone|ios|objective-c|ios4|nserror | 137,597 | <p>Well, what I usually do is have my methods that could error-out at runtime take a reference to a <code>NSError</code> pointer. If something does indeed go wrong in that method, I can populate the <code>NSError</code> reference with error data and return nil from the method.</p>
<p>Example:</p>
<pre><code>- (id) en... |
2,631,305 | Visual Studio: What happened to the "Break when an exception is unhandled" option? | <p>As far as I remember, Visual Studio (both 2008 and 2010) used to have an option to break either on thrown exceptions or on unhandled exceptions. Now when I bring up the Exceptions dialog (Ctr+Alt+E), it just offers to break when an exception is thrown:</p>
<p><img src="https://i.stack.imgur.com/1Mdm4.png" alt="ente... | 2,631,353 | 2 | 0 | null | 2010-04-13 16:29:50.377 UTC | 5 | 2014-08-08 15:16:37.54 UTC | 2014-08-08 15:16:37.54 UTC | null | 394,157 | null | 59,301 | null | 1 | 30 | visual-studio|visual-studio-2008|debugging|exception|visual-studio-2010 | 3,050 | <p><a href="http://vaultofthoughts.net/UserUnhandledCheckboxMissingFromExceptionsWindow.aspx" rel="noreferrer">This</a> seems to indicate it can occur if you don't have "Enable Just My Code (Managed Only)" enabled.</p>
<p>Edit: just tried it here (VS 2008) and I can verify that disabling that option will cause the Use... |
2,921,945 | Useful example of a shutdown hook in Java? | <p>I'm trying to make sure my Java application takes reasonable steps to be robust, and part of that involves shutting down gracefully. I am reading about <a href="http://www.ibm.com/developerworks/ibm/library/i-signalhandling/?open&l=409,t=grj,p=jsh#9" rel="noreferrer">shutdown hooks</a> and I don't actually get h... | 2,922,031 | 2 | 1 | null | 2010-05-27 14:20:58.127 UTC | 59 | 2015-08-30 09:42:40.297 UTC | 2011-08-16 15:32:32.183 UTC | null | 276,052 | null | 44,330 | null | 1 | 130 | java|shutdown-hook | 146,504 | <p>You could do the following:</p>
<ul>
<li>Let the shutdown hook set some AtomicBoolean (or volatile boolean) "keepRunning" to false</li>
<li>(Optionally, <code>.interrupt</code> the working threads if they wait for data in some blocking call)</li>
<li>Wait for the working threads (executing <code>writeBatch</code> i... |
26,446,338 | How to multiply all integers inside list | <p>Hello so I want to multiply the integers inside a list.</p>
<p>For example;</p>
<pre><code>l = [1, 2, 3]
l = [1*2, 2*2, 3*2]
</code></pre>
<p>output:</p>
<pre><code>l = [2, 4, 6]
</code></pre>
<p>So I was searching online and most of the answers were regarding multiply all the integers with each other such as:<... | 26,446,349 | 6 | 0 | null | 2014-10-19 01:29:28.9 UTC | 9 | 2020-04-27 05:31:38.51 UTC | 2016-06-17 18:46:41.18 UTC | null | 906,693 | null | 3,973,873 | null | 1 | 63 | python|list|multiplication|scalar|elementwise-operations | 226,643 | <p>Try a <a href="https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions" rel="noreferrer">list comprehension</a>:</p>
<pre><code>l = [x * 2 for x in l]
</code></pre>
<p>This goes through <code>l</code>, multiplying each element by two.</p>
<p>Of course, there's more than one way to do it. If you... |
38,703,876 | Log warning: Thread starvation or clock leap detected (housekeeper delta=springHikariConnectionPool) | <p>I'm using HikariCP 2.4.6 and at Tomcat 8 startup, I get a warning message:</p>
<pre><code>01-Aug-2016 11:18:01.599 INFO [RMI TCP Connection(4)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'Spring MVC Dispatcher Servlet'
[2016-08-01 11:18:01,654] Artifact blueberry:... | 38,703,956 | 7 | 0 | null | 2016-08-01 16:35:59.443 UTC | 20 | 2021-10-09 14:15:44.2 UTC | 2016-10-05 18:56:16.373 UTC | null | 192,465 | null | 192,465 | null | 1 | 87 | hikaricp | 127,263 | <p>There's a good <a href="https://groups.google.com/forum/#!topic/hikari-cp/inAL5wyUIxk" rel="noreferrer">rundown</a> of why clock leap detections might legitimately occur. To quote the external link by Brett Woolridge:</p>
<blockquote>
<p>This runs on the housekeeper thread, which executes every 30 seconds. If y... |
40,704,760 | InvalidOperationException: Could not find 'UserSecretsIdAttribute' on assembly | <p>After deploying ASP.NET Core app to azure and opening the site, I get the following error:</p>
<blockquote>
<p>InvalidOperationException: Could not find 'UserSecretsIdAttribute' on
assembly '******, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'.</p>
</blockquote>
<p>The exception details also includ... | 40,704,864 | 3 | 0 | null | 2016-11-20 13:47:40.02 UTC | 1 | 2021-07-14 14:20:52.517 UTC | 2016-11-20 13:53:10.743 UTC | null | 3,453,517 | null | 3,453,517 | null | 1 | 31 | asp.net|azure|asp.net-core | 14,700 | <p>There was an update to the user secrets module just recently. Version 1.0.1 and up now requires you specify an assembly-level attribute for the id of the user secrets, or as a fallback, the way it was previously in project.json.</p>
<p>Here is the announcement on GitHub: <a href="https://github.com/aspnet/Announcem... |
48,714,689 | Javascript re-assign let variable with destructuring | <p>In my React app I am using airbnb's eslint style guide which will throw an error if I do not use destructuing.</p>
<p>In the situation below, I first use <code>let</code> to assign the two variables <code>latitude</code> and <code>longitude</code> to the coordinates of the first item in an array of location objects... | 48,714,713 | 1 | 0 | null | 2018-02-09 21:57:12.683 UTC | 14 | 2018-02-09 21:59:03.02 UTC | null | null | null | null | 3,833,246 | null | 1 | 125 | javascript|ecmascript-6|eslint | 21,877 | <pre><code> ({ latitude, longitude } = props.userLocation.coords);
</code></pre>
<p>Destructuring needs to be either after a <code>let</code>, <code>const</code> or <code>var</code> declaration or it needs to be in an expression context to distinguish it from a block statement.</p> |
33,701,160 | python, heapq: difference between heappushpop() and heapreplace() | <p>I couldn't figure out the difference (other than ordinality of push/pop actions) between functions heapq.heappushpop() and heapq.heapreplace() when i tested out the following code.</p>
<pre><code>>>> from heapq import *
>>> a=[2,7,4,0,8,12,14,13,10,3,4]
>>> heapify(a)
>>> heappus... | 33,701,261 | 4 | 0 | null | 2015-11-13 20:22:01.793 UTC | 7 | 2021-04-03 13:28:58.06 UTC | null | null | null | null | 1,682,131 | null | 1 | 31 | python|heap | 17,499 | <p><code>heapreplace(a, x)</code> returns the smallest value originally in <code>a</code> regardless of the value of <code>x</code>, while, as the name suggests, <code>heappushpop(a, x)</code> pushes <code>x</code> onto <code>a</code> <em>before</em> popping the smallest value. Using your data, here's a sequence that ... |
34,580,095 | Using R and plot.ly - how do I script saving my output as a webpage | <p>I want to make some interactive graphs using R and <a href="https://plot.ly/" rel="noreferrer">plot.ly</a>. When I run the following code in R-Studio, it produces an interactive graph. </p>
<pre><code>library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
plot_ly(d, x = carat, y = price, tex... | 34,605,451 | 2 | 0 | null | 2016-01-03 18:33:34.837 UTC | 12 | 2019-02-09 12:58:16.1 UTC | null | null | null | null | 2,396,037 | null | 1 | 31 | r|plotly | 34,893 | <p>Assign the <code>plot_ly</code> object to a variable and then use <code>htmlwidgets::saveWidget()</code> to save the actual file, like so:</p>
<pre><code>library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
p <- plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity),
... |
53,636,756 | Typescript - interface extending another interface with nested properties | <p>I have an interface like:</p>
<pre><code>export interface Module {
name: string;
data: any;
structure: {
icon: string;
label: string;
...
}
}
</code></pre>
<p>How can I extend it, so that I add some new properties to structure, without repeating myself? Do I have to make a new interface for str... | 53,636,853 | 1 | 0 | null | 2018-12-05 16:32:46.91 UTC | 10 | 2022-08-29 19:25:44.393 UTC | null | null | null | null | 5,603,476 | null | 1 | 45 | typescript|syntax | 29,271 | <p>Interfaces can't add to the types of members in the base interface (at least not directly). You can use an intersection type instead:</p>
<pre><code>export interface Module {
name: string;
data: any;
structure: {
icon: string;
label: string;
}
}
export type DataModule = Module & ... |
29,135,885 | netcdf4 extract for subset of lat lon | <p>I would like to extract a spatial subset of a rather large netcdf file. From <a href="https://stackoverflow.com/questions/18665078/loop-through-netcdf-files-and-run-calculations-python-or-r">Loop through netcdf files and run calculations - Python or R</a> </p>
<pre><code>from pylab import *
import netCDF4
f = netC... | 29,136,166 | 7 | 0 | null | 2015-03-19 01:46:42.997 UTC | 10 | 2020-10-15 14:58:52.84 UTC | 2019-05-15 09:28:08.793 UTC | null | 6,068,294 | null | 308,827 | null | 1 | 10 | python|netcdf|nco|cdo-climate | 24,599 | <p>Well this is pretty easy, you have to find the index for the upper and lower bound in latitude and longitude.
You can do it by finding the value that is closest to the ones you're looking for.</p>
<pre><code>latbounds = [ 40 , 43 ]
lonbounds = [ -96 , -89 ] # degrees east ?
lats = f.variables['latitude'][:]
lons... |
29,162,662 | postgresql insert null value on query | <p>In my php code query, i got some error when i will place a null value
into the table. The column names "number1","number2", and "number3" are integers and can have a null value. </p>
<p>if there is no null value, the query works</p>
<p>query is like this
<strong>insert into table(number1,number2,number3) values ... | 29,162,719 | 1 | 0 | null | 2015-03-20 08:53:28.3 UTC | 2 | 2022-06-12 14:51:15.197 UTC | 2015-03-20 09:10:27.51 UTC | null | 4,693,222 | null | 4,693,222 | null | 1 | 27 | php|postgresql | 86,088 | <p>You insert <code>NULL</code> value by typing NULL:</p>
<pre><code>INSERT INTO table(number1,number2,number3) VALUES (1,NULL,3);
</code></pre>
<p>If you have a variable and when that variable is empty you want to insert a <code>NULL</code> value you can use <code>NULLIF</code> with the variable enclosed in single q... |
29,463,131 | Mapping multiple locations with Google Maps JavaScript API v3 and Geocoding API | <p>I'm using Google Maps JavaScript API v3 to generate a map with multiple locations/markers. I only have the address for these locations, not the coordinates, so I'm using the Geocoding API to get the coordinates.</p>
<p>I finally got Google's geocoding to work, so the location markers are showing up where they are s... | 29,463,348 | 3 | 0 | null | 2015-04-05 22:55:17.217 UTC | 8 | 2020-10-16 18:17:14.923 UTC | null | null | null | null | 3,878,771 | null | 1 | 6 | javascript|google-maps|google-maps-api-3|google-geocoder|google-geocoding-api | 59,433 | <p>This is a duplicate of <a href="https://stackoverflow.com/questions/13278368/google-map-info-window-multiple-addresses-via-xml">google map info window multiple addresses via xml</a>, just not an exact duplicate. The geocoder is asynchronous, so when the geocoder callback runs, the value of address is that from the ... |
44,923,353 | unable to select top 10 records per group in sparksql | <p>Hi I am new to spark sql. I have a data frame like this.</p>
<pre><code> ---+----------+----+----+----+------------------------+
|tag id|timestamp|listner| orgid |org2id|RSSI
+---+----------+----+----+----+------------------------+
| 4|1496745912| 362| 4| 3| 0.60|
| 4|1496745924|1901| ... | 44,924,156 | 3 | 0 | null | 2017-07-05 10:16:15.403 UTC | 4 | 2019-08-01 23:53:59.957 UTC | 2019-08-01 23:53:59.957 UTC | null | 6,395,770 | null | 8,235,369 | null | 1 | 12 | sql|apache-spark-sql | 49,456 | <p>Doesn't this work?</p>
<pre><code>select rssi, timestamp, tagid
from avg_table
order by timestamp desc
limit 10;
</code></pre>
<p>EDIT:</p>
<p>Oh, I get it. You want <code>row_number()</code>:</p>
<pre><code>select rssi, timestamp, tagid
from (select a.*,
row_number() over (partition by listner ord... |
31,685,244 | Updating existing Excel file in Java Apache POI | <p>I'm trying to write a Java program that will run daily (using a task scheduler) and will append a column to an Excel spreadsheet every time it runs. The problem I am having is it merely re-writes the file, not appending to it. I am using Apache POI, here is the relevant code:</p>
<pre><code> public static void toE... | 31,685,290 | 1 | 0 | null | 2015-07-28 19:18:06.343 UTC | 7 | 2018-11-24 12:03:55.597 UTC | 2015-07-29 09:24:30.103 UTC | null | 1,606,632 | null | 4,147,997 | null | 1 | 7 | java|excel|apache-poi | 46,943 | <p>I think you are creating the new rows and cells again and again and causing the re-write of excel.</p>
<blockquote>
<p>Essentially you need to get the rows and cells instead of creating
them in your program.</p>
</blockquote>
<pre><code>HSSFRow row1 = worksheet.createRow(0);
</code></pre>
<p>You may need to g... |
28,332,630 | Rails: Render view from outside controller | <p>I'm trying to create an HTML string using a view. I would like to render this from a class that is not a controller. How can I use the rails rendering engine outside a controller? Similar to how ActionMailer does?</p>
<p>Thanks!</p> | 70,027,370 | 9 | 0 | null | 2015-02-04 22:20:54.783 UTC | 5 | 2021-11-22 21:19:28.45 UTC | 2015-02-04 22:42:09.403 UTC | null | 1,464,892 | null | 1,464,892 | null | 1 | 34 | ruby-on-rails|ruby|ruby-on-rails-4 | 21,515 | <p>In Rails 5:</p>
<pre><code>view = ActionView::Base.new(ActionController::Base.view_paths)
view.render(file: 'template.html.erb')
</code></pre>
<p>In Rails 6.1:</p>
<pre><code>lookup_context = ActionView::LookupContext.new(ActionController::Base.view_paths)
context = ActionView::Base.with_empty_template_cache.new(loo... |
46,218,270 | Swift 4 ,must be used from main thread only warning | <p>When I using <code>Swift4</code>in <code>Xcode 9</code> gives me</p>
<blockquote>
<p>UIApplication.delegate must be used from main thread only</p>
<p>.... must be used from main thread only</p>
<p>UI API called from background thread Group</p>
</blockquote>
<p>Purple Warning.</p>
<p>My codes;</p>
<pre><code>var appD... | 46,218,441 | 1 | 0 | null | 2017-09-14 11:47:00.04 UTC | 7 | 2018-04-18 15:55:20.21 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 5,393,528 | null | 1 | 33 | appdelegate|swift4|xcode9 | 47,743 | <p>You're making this call on a background queue. To fix, try something like… </p>
<pre><code>public var context: NSManagedObjectContext
DispatchQueue.main.async {
var appDelegate = UIApplication.shared.delegate as! AppDelegate
context = appDelegate.persistentContainer.viewContext
}
</code></pre>
... |
34,252,817 | Handlebarsjs check if a string is equal to a value | <p>Is it possible in Handlebars to check if a string is equal to another value without registering a helper? I can't seem to find anything relevant to this in the Handlebars reference.</p>
<p>For example:</p>
<pre><code>{{#if sampleString == "This is a string"}}
...do something
{{/if}}
</code></pre> | 34,252,942 | 15 | 0 | null | 2015-12-13 15:37:30.237 UTC | 11 | 2022-05-21 22:55:55.35 UTC | 2018-06-25 12:44:50.62 UTC | null | 2,370,483 | null | 2,219,876 | null | 1 | 71 | string|handlebars.js|logical-operators | 144,915 | <p>It seems you can't do it "directly"</p>
<p>Try use helper, why not?</p>
<p>Register helper in your javascript code:</p>
<pre><code>Handlebars.registerHelper('ifEquals', function(arg1, arg2, options) {
return (arg1 == arg2) ? options.fn(this) : options.inverse(this);
});
</code></pre>
<p>Use in template:</p>
... |
50,844,781 | Android MVVM ViewModel and Repositories for each entity? | <p>With the Android Architecture components and the MVVM pattern I have some question.</p>
<p>Based on most examples around the web there are usually simple examples.</p>
<ol>
<li>Have an entity for Room</li>
</ol>
<pre><code> @Entity
public class User{
...
}
</code></pre>
<ol start="2">
<li>Have a DAO</li>
... | 50,844,907 | 1 | 0 | null | 2018-06-13 19:22:47.09 UTC | 13 | 2020-07-08 13:13:06.78 UTC | 2020-07-08 13:13:06.78 UTC | null | 1,466,287 | null | 379,865 | null | 1 | 40 | android|mvvm|android-architecture-components|android-jetpack | 9,733 | <h1>1</h1>
<p>You should have contextual DAOs, let's say an UserDao which should contains the queries related to the users, if you have posts in your app, you should have a PostDao for everything related to posts.</p>
<h1>2</h1>
<p>Same logic for repositories, remember the Single Responsibility Principle for classes, s... |
31,561,090 | Finding Records in a Database using a Textbox and Search Button in VB.Net | <p>I am Trying to Create a Library management system, I am a beginner at coding. The Problem I am having is I want to search my books database by title in Visual Basic, using a Textbox and Search button and wanting it to display the results in an seperate form. How would I go about a search in my database in visual bas... | 31,577,240 | 2 | 1 | null | 2015-07-22 10:54:30.067 UTC | null | 2020-01-30 20:10:55.6 UTC | 2015-07-23 01:23:43.507 UTC | null | 4,634,499 | null | 4,634,499 | null | 1 | 2 | database|visual-studio|ms-access|visual-studio-2012 | 56,382 | <p>I have found someone elses code and have modified it to work with my application
<a href="http://www.sattsoft.com/sourcecodes/details/1/4/vb-net-add-edit-delete-and-search-data-from-access-database.html" rel="nofollow">http://www.sattsoft.com/sourcecodes/details/1/4/vb-net-add-edit-delete-and-search-data-from-access... |
6,061,869 | Are block-level elements allowed inside inline-level elements in HTML5? | <p><strong>For an example</strong></p>
<p>Is <code><a href="#"><h1>Heading</h1></a></code> valid in HTML5?</p> | 6,062,035 | 1 | 0 | null | 2011-05-19 16:35:47.217 UTC | 9 | 2014-09-21 15:19:03.237 UTC | 2014-09-21 15:19:03.237 UTC | null | 1,779,477 | null | 84,201 | null | 1 | 26 | html|semantic-markup | 9,962 | <p>yes what you've written is valid in HTML5, but it's not all inline elements, I think it's just <code><a></code> 's it applies to..</p>
<h3>Reference: <a href="http://html5doctor.com/block-level-links-in-html-5/" rel="noreferrer">“Block-level” links in HTML5 </a></h3>
<p>Tip: if using this set the <code><a&g... |
6,223,864 | How to install Punjabi Language font in android samsung galaxy? | <p>i have an Android Phone, Samsung Galaxy Pop and I want my phone to read the Punjabi font too. So can you tell me how to install Punjabi font in my mobile Phone.
suggest me any solution for it.</p> | 6,223,931 | 2 | 1 | null | 2011-06-03 06:44:47.45 UTC | 2 | 2014-04-04 18:56:44.453 UTC | 2013-09-26 06:26:46.56 UTC | null | 243,557 | null | 552,027 | null | 1 | 0 | android-emulator | 67,499 | <p>I think you should check out this app:</p>
<p><a href="http://www.androidzoom.com/android_applications/productivity/gurmukhi-keyboard_rppe.html" rel="nofollow">http://www.androidzoom.com/android_applications/productivity/gurmukhi-keyboard_rppe.html</a></p>
<p>The app provides an input method in Gurmukhi Locale wit... |
24,548,032 | How do I match a Google Play Services revision with an install version? | <p>Android SDK Manager notified me this morning that there was a new Google Play Services release to download: revision 18. So how do I find the corresponding long version number to put in my build.gradle file? All my test devices are running version 5.0.84, so I tried updating</p>
<pre><code>compile 'com.google.andro... | 24,548,522 | 2 | 0 | null | 2014-07-03 07:53:00.327 UTC | 12 | 2015-03-28 09:16:59.773 UTC | 2015-03-28 09:16:59.773 UTC | null | 440,921 | null | 440,921 | null | 1 | 24 | android|gradle|google-play-services|android-gradle-plugin|build.gradle | 22,632 | <p>OK, I haven't quite managed to find a mapping of one to the other, but I've managed the next best thing which is to see a list of Play Services long version numbers installed on my development machine.</p>
<p>For Windows, it's in <code>[android-sdk]\extras\google\m2repository\com\google\android\gms\play-services</c... |
56,608,996 | SwiftUI - Search in List Header | <p>I am trying to to recreate what everyone know from UITableView with SwiftUI: A simple search field in the header of the tableview:</p>
<p><a href="https://i.stack.imgur.com/KZoXE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KZoXE.png" alt="A simple search field in the header of the tableview"></a></p>
... | 56,611,503 | 4 | 0 | null | 2019-06-15 09:10:57.553 UTC | 9 | 2021-06-09 19:48:10.147 UTC | null | null | null | null | 345,258 | null | 1 | 16 | uitableview|search|textfield|swiftui | 13,872 | <p><strong>Xcode 13 / SwiftUI 3</strong></p>
<p>You can now use <code>.searchable</code> to make a List... searchable!</p>
<pre><code>struct ContentView: View {
@State private var searchQuery: String = ""
var body: some View {
NavigationView {
List {
ForEach(Array... |
18,620,711 | PhoneGap with Django Backend | <p>I'm working on a web application that uses django. </p>
<p>I would like to create a native application of the site for ios / android using phone gap. </p>
<p>Is this possible? As I understand native devices cannot interpret python code. </p>
<p>It is early in the project and if it proves too difficult I may go wi... | 18,622,571 | 1 | 0 | null | 2013-09-04 17:56:26.613 UTC | 12 | 2013-09-05 20:23:46.833 UTC | null | null | null | user1725997 | null | null | 1 | 15 | ios|django|cordova | 11,831 | <p>That's right, you cannot run python code on iOS or Android using PhoneGap, but there is no need to do that. Yes, you can build a native mobile application of your site using PhoneGap.</p>
<p>I'll try to explain a bit how these technologies compare to each other:</p>
<ul>
<li>Django is a python web framework runnin... |
792,170 | iPhone/Xcode: can different project targets have different bundle identifiers? | <p>I'm a little confused how this works - this is my understanding:</p>
<ul>
<li>A target's provisioning profile is linked to a specific app ID</li>
<li>The bundle identifier for a target is found under <strong>Target info\Properies\Identifier</strong></li>
</ul>
<p>But... bundle ID is also located in Info.plist. It ... | 795,726 | 1 | 0 | null | 2009-04-27 03:30:48.89 UTC | 11 | 2014-06-04 14:24:37.22 UTC | 2009-04-27 13:12:51.737 UTC | null | 18,505 | null | 18,505 | null | 1 | 15 | iphone|xcode | 14,697 | <p>There isn't a precedence, the properties dialog is just serving as another way for you to see your Info.plist.</p>
<p>To share the plist between the targets but have different identifiers, make sure that the "Expand Build Settings in Info.plist File" option is enabled for both targets. Then, for each target, make a... |
719,609 | Having HierarchicalDataTemplates in a TreeView | <p><em>With regards to a question I posted earlier on (<a href="https://stackoverflow.com/questions/718858/wpf-correctly-storing-an-object-in-a-treeviewitem/718895#718895">WPF: Correctly storing an object in a TreeViewItem</a>)</em></p>
<p><strong>Is it possible to have nested <code>HierarchicalDataTemplate</code>s in... | 719,840 | 1 | 0 | null | 2009-04-05 20:19:41.063 UTC | 9 | 2012-06-08 14:43:12.987 UTC | 2017-05-23 12:01:02.72 UTC | null | -1 | Dreas Grech | 44,084 | null | 1 | 27 | c#|.net|wpf|xaml|treeview | 37,302 | <p>You dont need a nested template here, since TreeView control will take care of nesting it based on the DataType it requires. So just define Two HierarchicalDataTemplates for Album and Artist Type and one ordinary DataTemplate for your Track class.</p>
<pre><code> <HierarchicalDataTemplate DataType="{x:Type lo... |
63,455,427 | fatal error: opencv2/opencv_modules.hpp: No such file or directory #include "opencv2/opencv_modules.hpp" | <p>Hello all I am trying to use opencv-c++ API (version 4.4.0) which I have built from source. It is installed in /usr/local/ and I was simply trying to load and display an image using the following code -</p>
<pre><code>#include <iostream>
#include <opencv4/opencv2/opencv.hpp>
#include <opencv4/opencv2/... | 63,456,129 | 2 | 5 | null | 2020-08-17 17:03:09.55 UTC | 3 | 2022-08-26 14:01:45.927 UTC | 2022-08-26 14:01:45.927 UTC | null | 6,885,902 | null | 13,594,617 | null | 1 | 15 | c++|opencv | 39,861 | <p>The solution is to just include_directories path till <code>/usr/local/opencv4</code> and it works perfectly.</p>
<p>However, the best way I believe is to use the <code>find_package</code> function. I updated my Cmake to the following and it takes care of linking during build.</p>
<pre><code>cmake_minimum_required(V... |
21,075,983 | How to use particular CSS styles based on screen size / device | <p>Bootstrap 3 has nice CSS classes in responsive utilities that allow me to hide or show some blocks depending upon the screen resolution <a href="http://getbootstrap.com/css/#responsive-utilities-classes" rel="noreferrer">http://getbootstrap.com/css/#responsive-utilities-classes</a></p>
<p>I have some style rules i... | 21,076,033 | 5 | 0 | null | 2014-01-12 14:46:18.857 UTC | 14 | 2019-03-28 08:18:20.3 UTC | 2015-11-12 20:02:19.523 UTC | null | 2,756,409 | null | 118,657 | null | 1 | 63 | css|twitter-bootstrap|twitter-bootstrap-3 | 155,333 | <p>Use <a href="http://www.w3.org/TR/css3-mediaqueries/"><code>@media</code> queries</a>. They serve this exact purpose. Here's an example how they work:</p>
<pre class="lang-css prettyprint-override"><code>@media (max-width: 800px) {
/* CSS that should be displayed if width is equal to or less than 800px goes here ... |
49,663,545 | Is it possible to resize vuetify components? | <p>I recently use <strong>Vuetify</strong> to implement some UI designs. However, I found the default input component (such as v-text-field, v-select) are too large. I found that I can adjust the width of them, but for the height and font size, how can I change them?</p> | 49,663,917 | 5 | 1 | null | 2018-04-05 03:11:08.68 UTC | 5 | 2021-02-16 10:55:11.35 UTC | null | null | null | null | 6,204,233 | null | 1 | 23 | vue.js|vue-component|vuetify.js | 47,721 | <p>Although you can use <code>:style</code> bindings, to get what you want you'll have to resort to CSS.</p>
<p>You can use <code>!important</code> to "force in" your styles, but there are alternatives that can make it work without it. See demo below.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-... |
47,563,013 | Unable to import path from django.urls | <p>Tried to run command:</p>
<pre><code>from django.urls import path
</code></pre>
<p>Getting error:</p>
<blockquote>
<p>Traceback (most recent call last): File "< stdin >", line 1, in
ImportError: cannot import name 'path'</p>
</blockquote>
<p>I am using django version 1.11</p> | 47,563,055 | 14 | 0 | null | 2017-11-29 22:37:39.533 UTC | 9 | 2022-03-27 09:23:23.72 UTC | 2018-02-18 03:31:24.717 UTC | null | 3,476,943 | null | 3,476,943 | null | 1 | 55 | python|django|python-3.x|django-views | 140,456 | <p>The reason you cannot import path is because it is new in Django 2.0 as is mentioned here: <a href="https://docs.djangoproject.com/en/2.0/ref/urls/#path" rel="noreferrer">https://docs.djangoproject.com/en/2.0/ref/urls/#path</a>. </p>
<p>On that page in the bottom right hand corner you can change the documentation v... |
26,090,198 | Concatenate string and int in Python 3 .4 | <p>I'm new to Python, so I've been running through my own set of exercises to simply start memorizing basic functions and syntax.</p>
<p>I'm using the <a href="https://en.wikipedia.org/wiki/PyCharm" rel="nofollow noreferrer">PyCharm</a> IDE and Python 3.4. I've run into an issue when running through some basic string a... | 26,090,288 | 6 | 0 | null | 2014-09-28 22:14:40.023 UTC | 2 | 2022-03-04 06:34:20.2 UTC | 2022-03-04 06:19:17.07 UTC | null | 63,550 | null | 4,083,766 | null | 1 | 5 | python|string | 41,206 | <p>Note that <a href="https://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function" rel="nofollow noreferrer"><code>print</code> is a function in Python 3</a>. In Python 2, your first line would concatenate "Type string: " and "123" and then print them. In Python 3, you are calling the <code>pr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.