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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
29,578,965 | How do I populate two sections in a tableview with two different arrays using swift? | <p>I have two arrays Data1 and Data2 and I want to populate the data within each of these (they contain strings) into a tableview in two different sections.</p>
<p>The first section should have a heading "Some Data 1" and the second section should be titled "KickAss".</p>
<p>I have both sections populating with data ... | 29,579,027 | 5 | 1 | null | 2015-04-11 14:24:16.457 UTC | 25 | 2020-03-09 10:45:41.07 UTC | 2019-12-07 01:31:26.37 UTC | null | 1,265,393 | null | 4,374,672 | null | 1 | 38 | arrays|uitableview|swift|sections | 91,641 | <p><strong>TableView Cells</strong></p>
<p>You could use a multidimensional array. For example:</p>
<pre><code>let data = [["0,0", "0,1", "0,2"], ["1,0", "1,1", "1,2"]]
</code></pre>
<p>For the number of sections use:</p>
<pre><code>override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
r... |
32,496,864 | What is the monomorphism restriction? | <p>I'm puzzled by how the Haskell compiler sometimes infers types that are less
polymorphic than what I'd expect, for example when using point-free definitions.</p>
<p>It seems like the issue is the "monomorphism restriction", which is on by default on
older versions of the compiler.</p>
<p>Consider the follo... | 32,496,865 | 1 | 3 | null | 2015-09-10 08:31:55.323 UTC | 38 | 2022-05-14 07:20:38.25 UTC | 2022-05-14 07:20:38.25 UTC | null | 7,941,251 | null | 510,937 | null | 1 | 85 | haskell|types|polymorphism|type-inference|monomorphism-restriction | 7,305 | <h1>What is the monomorphism restriction?</h1>
<p>The <a href="https://wiki.haskell.org/Monomorphism_restriction" rel="nofollow noreferrer">monomorphism restriction</a> as stated by the Haskell wiki is:</p>
<blockquote>
<p>a counter-intuitive rule in Haskell type inference.
If you forget to provide a type signature, so... |
36,463,966 | MySQL: When is Flush Privileges in MySQL really needed? | <p>When creating new tables and a user to go along with it, I usually just invoke the following commands:</p>
<pre><code>CREATE DATABASE mydb;
GRANT ALL PRIVILEGES ON mydb.* TO myuser@localhost IDENTIFIED BY "mypassword";
</code></pre>
<p>I have never ever needed to utilize the <code>FLUSH PRIVILEGES</code> command a... | 36,464,093 | 4 | 3 | null | 2016-04-06 23:14:55.723 UTC | 18 | 2021-02-01 19:51:17.347 UTC | 2021-02-01 19:51:17.347 UTC | null | 10,907,864 | null | 4,698,242 | null | 1 | 80 | mysql | 182,962 | <p>Privileges assigned through GRANT option do not need FLUSH PRIVILEGES to take effect - MySQL server will notice these changes and reload the grant tables immediately.</p>
<p><a href="http://dev.mysql.com/doc/refman/5.7/en/privilege-changes.html" rel="noreferrer">From MySQL documentation</a>:</p>
<blockquote>
<p>... |
48,508,799 | How to reset all files from working directory but not from staging area? | <p>Is there a way to reset all files from the working directory but not those from staging area?</p>
<p>I know that using the following command one can reset any single file:</p>
<p><code>git checkout thefiletoreset.txt</code></p>
<p>And also that by using the following command it is possible to reset the entire rep... | 57,066,072 | 2 | 3 | null | 2018-01-29 19:41:01.76 UTC | 10 | 2020-11-28 21:44:54.357 UTC | null | null | null | null | 6,510,552 | null | 1 | 10 | git | 20,953 | <blockquote>
<p>But is there any command that can reset the whole working directory, leaving the staging area untouched?</p>
</blockquote>
<p>With Git 2.23 (Q3 2019), yes there is: <a href="https://git-scm.com/docs/git-restore" rel="noreferrer"><strong><code>git restore</code></strong></a>.</p>
<h2>How to use it (<a hr... |
48,699,836 | How to change .NET Framework in Rider IDE? | <p>In Rider IDE, I am trying to create a new solution:</p>
<p><a href="https://i.stack.imgur.com/IPGIF.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/IPGIF.jpg" alt="enter image description here" /></a></p>
<p>But I'm unable to change the .NET Framework as the dropdown is disabled. How can I change the versi... | 48,702,057 | 4 | 4 | null | 2018-02-09 06:18:29.743 UTC | 0 | 2021-04-14 07:24:28.52 UTC | 2021-04-14 07:24:28.52 UTC | null | 1,402,846 | null | 4,222,487 | null | 1 | 21 | c#|.net|.net-framework-version|rider | 42,255 | <p>Actually for now Rider contains the only one Web App Template - for net45.
We are going to add another one - for net4.6.1 (or 4.6.2) in 2018.1.
You can track status here: <a href="https://youtrack.jetbrains.com/issue/RIDER-10888" rel="nofollow noreferrer">https://youtrack.jetbrains.com/issue/RIDER-10888</a></p>
<... |
48,864,985 | VSCode single to double quote automatic replace | <p>When I execute a <code>Format Document</code> command on a Vue Component.vue file VSCode replace all single quoted string with double quoted string.</p>
<p>In my specific case this rule conflicts with electron-vue lint configuration that require singlequote.</p>
<p>I don't have prettier extensions installed (no <c... | 48,866,406 | 30 | 4 | null | 2018-02-19 11:16:25.793 UTC | 25 | 2022-08-08 03:53:47.503 UTC | 2020-05-27 06:39:56.5 UTC | null | 6,904,888 | null | 3,356,777 | null | 1 | 206 | visual-studio-code|vscode-settings | 263,010 | <p>I dont have <code>prettier</code> extension installed, but after reading the <a href="https://stackoverflow.com/questions/47091719/vs-code-auto-indent-code-formatting-changes-single-quotation-marks-to-double">possible duplicate</a> answer I've added from scratch in my User Setting (<code>UserSetting.json</code>, Ctr... |
7,696,347 | To break a message in two or more lines in JOptionPane | <pre><code>try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://"+hostName.getText()+";" +
"databaseName="+dbName.getText()+";user="+userName.getText()+";password="+password.getText()+";";
Connection con = DriverManager.getConnecti... | 7,707,397 | 4 | 0 | null | 2011-10-08 10:59:19.663 UTC | 3 | 2018-11-13 08:46:03.587 UTC | 2011-10-08 12:51:45.317 UTC | null | 714,968 | null | 922,402 | null | 1 | 9 | java|swing|newline|joptionpane | 43,094 | <p><img src="https://i.stack.imgur.com/rJrch.png" alt="enter image description here"></p>
<pre><code>import javax.swing.*;
class FixedWidthLabel {
public static void main(String[] args) {
Runnable r = () -> {
String html = "<html><body width='%1s'><h1>Label Width</h1&g... |
7,439,955 | Servlet API implementation using Netty | <p>Has anyone made a Servlet API implementation built on top of Netty?
I'm tempted to build my own as I can't google an implementation.</p>
<ul>
<li><a href="http://www.jboss.org/netty/community#nabble-td4752485">http://www.jboss.org/netty/community#nabble-td4752485</a></li>
<li><a href="http://markmail.org/message/4q... | 7,456,586 | 4 | 2 | null | 2011-09-16 03:52:29.19 UTC | 9 | 2013-08-10 22:00:25.713 UTC | 2011-11-06 11:39:32.45 UTC | null | 21,234 | null | 318,174 | null | 1 | 17 | java|servlets|nio|netty | 16,588 | <p>Jersey does not require servlet - runs fine even with the lightweight http server included in JDK or even runs with Grizzly NIO framework (which is similar to Netty - see grizzly.java.net). To see what it takes to make it run with Netty, you may want to look at jersey-grizzly2 module in Jersey workspace - would be n... |
7,872,113 | How to remove a folder and all its content from the current directory? | <p>This code that does not work:</p>
<pre><code>@echo off
if exist output @set /p checkdir= Output directory found. Do you wish to overwrite it?:
if /I %checkdir% == Y deltree /s /output
pause
</code></pre> | 7,874,557 | 1 | 1 | null | 2011-10-24 06:47:47.147 UTC | 7 | 2018-03-23 16:26:50.243 UTC | 2017-05-11 16:04:32.89 UTC | null | 576,767 | null | 866,800 | null | 1 | 44 | windows|batch-file | 74,574 | <p>You were looking for this command:</p>
<pre><code>RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path
/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.
/Q Quiet mode, do not ask if ok ... |
1,578,361 | Update Sharepoint List Item | <p>I got following error...</p>
<blockquote>
<p>System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.SharePoint.SPListItem.get_UniqueId()
at ConsoleApplication1.Program.Main(String[] args) in Program.cs:line 21</p>
</blockquote>
<p>running following code</p>
<pre><c... | 1,578,509 | 4 | 1 | null | 2009-10-16 14:21:42.423 UTC | 6 | 2017-11-07 15:10:37.037 UTC | 2009-10-22 04:46:13.127 UTC | null | 25,163 | null | 189,737 | null | 1 | 8 | c#|asp.net|sharepoint|wss | 76,222 | <p>If you're trying to alter values for a just inserted list item, you should go with:</p>
<pre><code>SPList list = web.Lists["ListName"];
//SPListItem item = list.Items.Add();
//item["PercentComplete"] = .45; // 45%
//item.Update();
SPListItemCollection items = list.GetItems(new SPQuery()
{
Query = @"<Where&g... |
2,238,522 | Significance of PermGen Space | <p>What is the significance of PermGen space in java?</p> | 2,238,534 | 4 | 1 | null | 2010-02-10 16:34:52.51 UTC | 9 | 2012-03-27 04:17:18.837 UTC | 2012-03-27 04:17:18.837 UTC | null | 697,449 | null | 268,850 | null | 1 | 29 | java|memory-management|jvm|permgen | 11,710 | <p>PermGen space is reserved for long-term objects - mostly <code>Class</code> objects loaded by the <code>ClassLoader</code>. PermGen will not be garbage collected except under very special circumstances (specifically, when the <code>ClassLoader</code> that loaded those classes goes out of scope). </p>
<p>This is a ... |
1,507,501 | Linq Aggregate complex types into a string | <p>I've seen the simple example of the .net Aggregate function working like so:</p>
<pre><code>string[] words = { "one", "two", "three" };
var res = words.Aggregate((current, next) => current + ", " + next);
Console.WriteLine(res);
</code></pre>
<p>How could the 'Aggregate' function be used if you wish to aggregat... | 1,509,042 | 4 | 0 | null | 2009-10-02 02:29:55.353 UTC | 4 | 2018-03-18 12:54:00.837 UTC | null | null | null | null | 74,449 | null | 1 | 30 | .net|asp.net|linq|string-concatenation | 21,661 | <p>You have two options:</p>
<ol>
<li><p>Project to a <code>string</code> and then aggregate:</p>
<pre><code>var values = new[] {
new { Key = "MyAge", Value = 33.0 },
new { Key = "MyHeight", Value = 1.75 },
new { Key = "MyWeight", Value = 90.0 }
};
var res1 = values.Select(x => string.Format("{0}:{1}",... |
1,676,195 | file upload without activerecord | <p>How do you handle file upload in rail without attaching them to active record ?<br>
I just want to write the files to the disk.</p>
<p>Thanks,</p> | 1,678,388 | 4 | 1 | null | 2009-11-04 19:55:22.6 UTC | 20 | 2017-09-29 05:30:04.867 UTC | null | null | null | null | 143,148 | null | 1 | 35 | ruby-on-rails | 25,598 | <p>If I understand correctly what you need then the most simple example would be this:</p>
<p>The controller:</p>
<pre><code> class UploadController < ApplicationController
def new
end
def create
name = params[:upload][:file].original_filename
path = File.join("public", "images", "upload", name)
... |
2,309,943 | Unioning two tables with different number of columns | <p>I have two tables (Table A and Table B).</p>
<p>These have different number of columns - Say Table A has more columns.</p>
<p>How can I union these two table and get null for the columns that Table B does not have?</p> | 2,309,966 | 4 | 1 | null | 2010-02-22 09:33:02.323 UTC | 33 | 2020-09-04 14:02:12.427 UTC | 2018-01-11 07:55:21.123 UTC | null | 680,068 | null | 122,528 | null | 1 | 147 | sql|mysql | 276,550 | <p>Add extra columns as null for the table having less columns like</p>
<pre><code>Select Col1, Col2, Col3, Col4, Col5 from Table1
Union
Select Col1, Col2, Col3, Null as Col4, Null as Col5 from Table2
</code></pre> |
52,653,337 | vuejs - Redirect from login/register to home if already loggedin, Redirect from other pages to login if not loggedin in vue-router | <p>I want to redirect user to home page if logged-in and wants to access login/register page and redirect user to login page if not logged-in and wants to access other pages. Some pages are excluded that means there is no need to be logged in so my code is right below:</p>
<pre><code>router.beforeEach((to, from, next)... | 52,663,166 | 5 | 4 | null | 2018-10-04 18:49:25.433 UTC | 5 | 2021-08-28 05:08:25.49 UTC | 2018-10-04 19:43:05.767 UTC | null | 9,182,477 | null | 9,182,477 | null | 1 | 26 | vue.js|vue-router | 41,541 | <p>Here's what I'm doing. First I'm using a <code>meta</code> data for the routes, so I don't need to manually put all routes that are not requiring login:</p>
<pre class="lang-js prettyprint-override"><code>routes: [
{
name: 'About' // + path, component, etc
},
{
name: 'Dashboard', // + path, component,... |
10,300,875 | jQuery Check for tablet? | <p>I use a media query to load in a stylesheet (if device is a tablet).</p>
<p>I was just wondering how I could check in my javascript if the user is using a tablet, is there a check or should I just check what stylesheet was loaded in?</p> | 10,301,074 | 3 | 2 | null | 2012-04-24 15:16:56.837 UTC | 2 | 2014-04-05 21:55:14.067 UTC | 2012-04-24 15:18:18.32 UTC | null | 106,224 | null | 1,013,512 | null | 1 | 30 | javascript|jquery | 56,478 | <p>Try to see if perhaps this sheds a light on your question:</p>
<p><a href="https://stackoverflow.com/questions/3514784/best-way-to-detect-handheld-device-in-jquery">What is the best way to detect a mobile device in jQuery?</a></p>
<p>As the answer to that thread says, I'd suggest to rely on 'feature detection' rat... |
10,326,406 | Getting index value on razor foreach | <p>I'm iterating a <code>List<T></code> in a razor foreach loop in my view which renders a partial. In the partial I'm rendering a single record for which I want to have 4 in a row in my view. I have a css class for the two end columns so need to determine in the partial whether the call is the 1st or the 4th rec... | 22,373,172 | 11 | 2 | null | 2012-04-26 02:24:12.51 UTC | 10 | 2021-02-20 16:56:10.14 UTC | null | null | null | null | 151,522 | null | 1 | 76 | asp.net-mvc|asp.net-mvc-2|razor|partial-views | 134,404 | <pre><code> @{int i = 0;}
@foreach(var myItem in Model.Members)
{
<span>@i</span>
@{i++;
}
}
</code></pre>
<p>// Use @{i++ to increment value}</p> |
28,567,549 | How to use if within a map return? | <p>I need to generate diffrent reactJS code based on datamodel but I get </p>
<blockquote>
<p>In file "~/Scripts/Grid.jsx": Parse Error: Line 13: Unexpected token
if (at line 13 column 15) Line: 52 Column:3</p>
</blockquote>
<p>With this code</p>
<pre><code>var GridRow = React.createClass({
render: function(... | 28,567,644 | 2 | 3 | null | 2015-02-17 17:36:53.503 UTC | 12 | 2019-09-26 12:07:13.5 UTC | null | null | null | null | 365,624 | null | 1 | 39 | javascript|reactjs | 131,116 | <p>You put <code>return</code> statement inside <code>if</code> clause like so:</p>
<pre><code> row = this.props.cells.map(function(cell, i) {
if(cell.URL != null && cell.URL.length > 0){
return <td className={cell.Meta.HTMLClass} key={i}>{cell.Text}</td>;
... |
7,293,220 | Adding jquery mobile swipe event | <p>I have a listview and what I am trying to do is add a swipe event on the links. For example, if a user swipes the first link it goes to that page. Is this possible with listview elements. I have tried div,href,a,li,ul but still no alert. It works with body. Thanks</p>
<pre><code><div>
<ul data-role="list... | 7,309,030 | 5 | 1 | null | 2011-09-03 12:53:06.16 UTC | 16 | 2014-06-09 18:57:55.453 UTC | 2013-01-30 12:07:50.917 UTC | null | 31,532 | null | 804,749 | null | 1 | 27 | jquery|jquery-mobile | 102,688 | <p>Live Example:</p>
<ul>
<li><a href="http://jsfiddle.net/yxzZf/4/" rel="nofollow noreferrer">http://jsfiddle.net/yxzZf/4/</a></li>
</ul>
<p>JS:</p>
<pre><code>$("#listitem").swiperight(function() {
$.mobile.changePage("#page1");
});
</code></pre>
<p>HTML:</p>
<pre><code><div data-role="page" id="home">... |
7,479,265 | How to Apply Mask to Image in OpenCV? | <p>I want to <strong>apply a binary mask</strong> to a color image.
Please provide a basic code example with proper explanation of how the code works.</p>
<p>Also, is there some option to apply a mask permanently so all functions operate only within the mask?</p> | 7,504,836 | 6 | 0 | null | 2011-09-20 01:59:41.767 UTC | 8 | 2022-06-06 14:38:28.91 UTC | 2020-06-29 15:08:40.913 UTC | null | 6,674,599 | null | 1,526,152 | null | 1 | 24 | c++|image|image-processing|opencv|mask | 116,529 | <p>You don't apply a binary mask to an image. You (optionally) use a binary mask in a processing function call to tell the function which pixels of the image you want to process. If I'm completely misinterpreting your question, you should add more detail to clarify.</p> |
7,378,644 | How to call getWindow() outside an Activity in Android? | <p>I am trying to organize my code and move repetitive functions to a single class.
This line of code works fine inside a class that extends activity:</p>
<pre><code>getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
</code></pre>
<p>However it is not working... | 7,378,652 | 7 | 0 | null | 2011-09-11 13:49:14.083 UTC | 8 | 2022-08-28 00:50:30.2 UTC | 2014-11-04 10:42:46.493 UTC | null | 529,024 | null | 529,024 | null | 1 | 50 | java|android | 103,792 | <p>Pass a reference of the activity when you create the class, and when calling relevant methods and use it.</p>
<pre><code>void someMethodThatUsesActivity(Activity myActivityReference) {
myActivityReference.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN... |
7,508,322 | How do I map lists of nested objects with Dapper | <p>I'm currently using Entity Framework for my db access but want to have a look at Dapper. I have classes like this:</p>
<pre><code>public class Course{
public string Title{get;set;}
public IList<Location> Locations {get;set;}
...
}
public class Location{
public string Name {get;set;}
...
}
</co... | 7,523,274 | 8 | 2 | null | 2011-09-22 00:48:35.333 UTC | 74 | 2021-05-17 10:24:12.003 UTC | 2018-04-23 14:54:45.65 UTC | null | 206,730 | null | 395,377 | null | 1 | 155 | orm|dapper | 126,881 | <p>Dapper is not a full blown ORM it does not handle magic generation of queries and such. </p>
<p>For your particular example the following would probably work:</p>
<h3>Grab the courses:</h3>
<pre><code>var courses = cnn.Query<Course>("select * from Courses where Category = 1 Order by CreationDate");
</code><... |
13,813,675 | MySQL Timestamp Difference | <p>I have a table with column timestam which stores a timestamp with this format: "2012-12-10 21:24:30"</p>
<p>I am looking for a SQL Query that takes the current timestamp and subtracts it with the one in the column and gives the difference in this format:</p>
<p>"3 Hours and 2 mins Remaining"</p>
<p>Looking for a ... | 13,813,710 | 2 | 0 | null | 2012-12-11 04:30:39.337 UTC | 3 | 2016-04-13 06:32:48.943 UTC | 2016-04-13 06:32:48.943 UTC | null | 5,735,460 | null | 1,089,139 | null | 1 | 22 | mysql|timestamp | 41,836 | <p>use <a href="http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_timestampdiff"><code>TIMESTAMPDIFF</code></a> </p>
<pre><code>TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)
</code></pre>
<blockquote>
<p>where unit argument, which should be one of the following values:
MICROSECOND (... |
14,324,270 | Matplotlib custom marker/symbol | <p>So there is this guide:
<a href="http://matplotlib.org/examples/pylab_examples/scatter_symbol.html" rel="noreferrer">http://matplotlib.org/examples/pylab_examples/scatter_symbol.html</a>
<img src="https://i.stack.imgur.com/YsJ5d.png" alt="enter image description here"></p>
<pre><code># http://matplotlib.org/example... | 58,552,620 | 2 | 2 | null | 2013-01-14 18:24:19.503 UTC | 20 | 2019-11-01 22:59:19.827 UTC | 2013-01-19 10:04:48.343 UTC | null | 618,099 | null | 618,099 | null | 1 | 39 | python|matplotlib | 41,008 | <p>The most flexible option for <code>matplotlib</code> is <a href="https://matplotlib.org/3.1.1/gallery/shapes_and_collections/marker_path.html" rel="noreferrer">marker paths</a>. </p>
<p>I used Inkscape to convert <a href="https://commons.wikimedia.org/wiki/File:718smiley.svg" rel="noreferrer">Smiley face svg</a> in... |
13,973,158 | How do I convert a javascript object array to a string array of the object attribute I want? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/8281824/accessing-properties-of-an-array-of-objects">Accessing properties of an array of objects</a> </p>
</blockquote>
<p>
Given:</p>
<pre><code>[{
'id':1,
'name':'john'
},{
'id':2,
'name':'jane... | 13,973,194 | 4 | 2 | null | 2012-12-20 13:22:47.957 UTC | 18 | 2017-10-31 23:55:55.763 UTC | 2017-10-31 23:55:55.763 UTC | null | 2,729,534 | null | 268,151 | null | 1 | 118 | javascript | 177,546 | <p>If your array of objects is <code>items</code>, you can do:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var items = [{
id: 1,
name: 'john'
}, {
id: 2,
name: 'ja... |
9,235,934 | Get preferred date format string of Android system | <p>Does anybody know how to get the format string used by the system when formatting a date using </p>
<pre><code>DateFormat.getLongDateFormat(Context context).format(Date date)
</code></pre> | 17,718,379 | 8 | 1 | null | 2012-02-10 22:52:00.423 UTC | 3 | 2018-01-23 00:05:36.153 UTC | 2013-09-03 12:22:47.477 UTC | null | 458,741 | null | 1,130,746 | null | 1 | 29 | android | 26,543 | <p>I wrote a method to detect this format string. ( work for my case).</p>
<pre><code>public static String getDateFormat(Context context){
// 25/12/2013
Calendar testDate = Calendar.getInstance();
testDate.set(Calendar.YEAR, 2013);
testDate.set(Calendar.MONTH, Calendar.DECEMBER);
... |
44,511,436 | How to do an explicit fall-through in C | <p>The newer versions of gcc offer the <code>Wimplicit-fallthrough</code>, which is great to have for most switch statements. However, I have one switch statement where I want to allow fall throughs from all case-statements.</p>
<p>Is there a way to do an explicit fall through? I'd prefer to avoid having to compile wi... | 44,511,477 | 3 | 3 | null | 2017-06-13 02:27:09.22 UTC | 4 | 2021-04-22 20:13:22.17 UTC | 2017-06-14 03:13:27.02 UTC | null | 2,638,548 | null | 2,638,548 | null | 1 | 29 | c|gcc|c99|gcc-warning | 13,930 | <p>Use <a href="https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html" rel="nofollow noreferrer"><code>__attribute__ ((fallthrough))</code></a></p>
<pre><code>switch (condition) {
case 1:
printf("1 ");
__attribute__ ((fallthrough));
case 2:
printf("2 ");
... |
19,533,567 | Trouble sorting three numbers in ascending order in Java | <p>I'm currently working on a program and I just cannot get it to work the way it is supposed to work. I need to enter three integers using a scanner, and then output the numbers in ascending order. I technically got this to work but it didn't follow the structure that it HAS to follow. In my main method I have the dec... | 19,533,671 | 10 | 2 | null | 2013-10-23 05:35:18.95 UTC | 0 | 2022-03-12 01:44:51.263 UTC | null | null | null | null | 2,872,123 | null | 1 | -2 | java|sorting | 56,175 | <p>In your main method call your method:</p>
<pre><code>public static void main(String[] args) {
// Declarations
Scanner input = new Scanner(System.in);
System.out.print("Enter three values: ");
int num1 = input.nextInt();
int num2 = input.nextInt();
int num3 = input.nextInt();
displaySort... |
19,687,419 | Android: onClick on LinearLayout with TextView and Button | <p>I have a Fragment that uses the following XML layout:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/card"
a... | 19,687,762 | 10 | 2 | null | 2013-10-30 15:43:20.023 UTC | 5 | 2020-07-09 11:24:45.053 UTC | null | null | null | null | 902,358 | null | 1 | 7 | android|android-layout|onclick|android-xml | 49,147 | <p>add onClick Action for your button dirrectly in code
like this: </p>
<pre><code>Button btn = findViewById(R.id.factory_button_edit);
btn.setOnClickListener(button_click);
OnClickListener button_click = new OnClickListener() {
@Override
public void onClick(View v) {
editActions;... |
19,519,328 | Testing javascript alerts with Jasmine | <p>I'm writing some Jasmine tests for some legacy javascript that produces an alert or a confirm at some points in the code. </p>
<p>At the moment where the alert pops up it pauses execution in the browser requiring me to press ok before going on.</p>
<p>I'm sure I'm missing something but is there a way of faking an ... | 26,976,989 | 4 | 2 | null | 2013-10-22 13:30:41.977 UTC | 4 | 2020-07-02 21:48:28.063 UTC | 2013-10-22 14:08:03.753 UTC | null | 1,023,425 | null | 1,023,425 | null | 1 | 31 | javascript|jasmine | 19,198 | <pre><code>spyOn(window, 'alert');
. . .
expect(window.alert).toHaveBeenCalledWith('a message');
</code></pre> |
52,244,808 | Backpressure mechanism in Spring Web-Flux | <p>I'm a starter in <strong>Spring Web-Flux</strong>. I wrote a controller as follows: </p>
<pre><code>@RestController
public class FirstController
{
@GetMapping("/first")
public Mono<String> getAllTweets()
{
return Mono.just("I am First Mono")
}
}
</code></pre>
<p>I know one of the re... | 52,245,213 | 1 | 4 | null | 2018-09-09 13:04:05.317 UTC | 35 | 2021-06-18 07:39:19.577 UTC | 2018-09-09 13:40:13.88 UTC | null | 4,922,375 | null | 793,934 | null | 1 | 54 | java|reactive-programming|spring-webflux|backpressure | 21,524 | <h1>Backpressure in WebFlux</h1>
<p>In order to understand how Backpressure works in the current implementation of the WebFlux framework, we have to recap the transport layer used by default here. As we may remember, the normal communication between browser and server (server to server communication usually the same as... |
35,160,256 | How do I output lists as a table in Jupyter notebook? | <p>I know that I've seen some example somewhere before but for the life of me I cannot find it when googling around.</p>
<p>I have some rows of data:</p>
<pre><code>data = [[1,2,3],
[4,5,6],
[7,8,9],
]
</code></pre>
<p>And I want to output this data in a table, e.g.</p>
<pre><code>+---+---+-... | 35,161,699 | 12 | 5 | null | 2016-02-02 17:40:45.297 UTC | 19 | 2022-01-16 06:20:47.317 UTC | null | null | null | null | 344,286 | null | 1 | 104 | python|jupyter-notebook | 171,611 | <p>I finally re-found the <a href="http://nbviewer.jupyter.org/github/ipython/ipython/blob/4.0.x/examples/IPython%20Kernel/Rich%20Output.ipynb#HTML" rel="noreferrer">jupyter/IPython documentation</a> that I was looking for.</p>
<p>I needed this:</p>
<pre><code>from IPython.display import HTML, display
data = [[1,2,3... |
914,143 | Display XML on an ASP.NET page | <p>I have a string containing XML document using LinqtoXML</p>
<p>What is the best way of displaying it on an asp.net page as is.</p> | 914,318 | 5 | 0 | null | 2009-05-27 05:44:57.037 UTC | 3 | 2016-07-07 08:06:09.32 UTC | null | null | null | null | 105,133 | null | 1 | 15 | asp.net | 49,205 | <p>I would have liked to do it the way Dennis has mentioned (using an <code><asp:Xml></code> control). But that necessitates the use of an XSL stylesheet to format the XML. The Xml control does not allow an HTML encoded string to be passed as the DocumentContent property and does not expose any method to encode t... |
1,310,422 | How to do something to every file in a directory using bash? | <p>I started with this:</p>
<pre><code>command *
</code></pre>
<p>But it doesn't work when the directory is empty; the * wildcard becomes a literal "*" character. So I switched to this:</p>
<pre><code>for i in *; do
...
done
</code></pre>
<p>which works, but again, not if the directory is empty. I resorted to us... | 1,310,438 | 5 | 1 | null | 2009-08-21 07:12:14.493 UTC | 8 | 2011-11-23 09:27:47.22 UTC | null | null | null | new sys admin | null | null | 1 | 21 | bash|shell | 41,629 | <p>Assuming you only want to do something to files, the simple solution is to test if $i is a file:</p>
<pre><code>for i in *
do
if test -f "$i"
then
echo "Doing somthing to $i"
fi
done
</code></pre>
<p>You should really always make such tests, because you almost certainly don't want to treat fil... |
760,301 | Implementing a no-op std::ostream | <p>I'm looking at making a logging class which has members like Info, Error etc that can configurably output to console, file, or to nowhere.</p>
<p>For efficiency, I would like to avoid the overhead of formatting messages that are going to be thrown away (ie info messages when not running in a verbose mode). If I im... | 760,350 | 5 | 2 | null | 2009-04-17 12:55:46.367 UTC | 11 | 2019-07-24 19:30:18.81 UTC | 2019-07-24 19:21:18.347 UTC | null | 212,378 | null | 32,817 | null | 1 | 32 | c++|logging|debugging | 8,924 | <p>To prevent the <code>operator<<()</code> invocations from doing formatting, you should know the streamtype at compile-time. This can be done either with macros or with templates.</p>
<p>My template solution follows.</p>
<pre><code>class NullStream {
public:
void setFile() { /* no-op */ }
template<... |
741,950 | Programmatically determining amount of parameters a function requires - Python | <p>I was creating a simple command line utility and using a dictionary as a sort of case statement with key words linking to their appropriate function. The functions all have different amount of arguments required so currently to check if the user entered the correct amount of arguments needed for each function I pla... | 741,957 | 6 | 0 | null | 2009-04-12 15:43:34.777 UTC | 4 | 2017-04-10 16:35:58.38 UTC | 2017-04-10 16:35:58.38 UTC | null | 1,033,581 | null | 56,924 | null | 1 | 38 | python|parameters|function | 28,347 | <p><a href="http://docs.python.org/library/inspect.html#inspect.getargspec" rel="noreferrer">inspect.getargspec()</a>:</p>
<blockquote>
<p>Get the names and default values of a function’s arguments. A tuple of four things is returned: (args, varargs, varkw, defaults). args is a list of the argument names (it may con... |
810,493 | Recommendations for java captcha libraries | <p>I'm looking for a replacement for JCaptcha, which doesn't seem to be maintained any more, and isn't very good to begin with. The replacement has to integrate nicely with JavaEE webapps.</p>
<p>As I can see it, there are three options:</p>
<ul>
<li>JCaptcha - No longer maintained, crude API</li>
<li>SimpleCaptcha -... | 810,499 | 6 | 2 | 2009-06-27 21:33:45.433 UTC | 2009-05-01 07:20:10.023 UTC | 34 | 2021-04-15 07:54:11.317 UTC | 2014-11-16 13:51:48.547 UTC | null | 573,032 | null | 21,234 | null | 1 | 67 | java|jakarta-ee|captcha|recaptcha|simplecaptcha | 77,776 | <p><a href="http://recaptcha.net/" rel="noreferrer">ReCaptcha</a> is the only captcha you should use, because it's the only captcha that makes the world better (improve OCR results to old text), with almost unlimited database.</p>
<p>All other captchas are usually limited by its database, or do nothing good to this wo... |
274,360 | Checking if an instance's class implements an interface? | <p>Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)?</p> | 274,363 | 6 | 0 | null | 2008-11-08 04:24:28.397 UTC | 18 | 2021-12-14 12:50:31.647 UTC | null | null | null | Wilco | 5,291 | null | 1 | 180 | php|interface|oop | 117,999 | <pre><code>interface IInterface
{
}
class TheClass implements IInterface
{
}
$cls = new TheClass();
if ($cls instanceof IInterface) {
echo "yes";
}
</code></pre>
<p>You can use the "instanceof" operator. To use it, the left operand is a class instance and the right operand is an interface. It returns true if the... |
31,169,514 | Microsoft.ReportViewer.Common Version=12.0.0.0 | <p>I'm getting the following exception in my Windows Service Application:</p>
<blockquote>
<p>System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The
system cannot find t... | 31,170,281 | 7 | 3 | null | 2015-07-01 18:59:37.363 UTC | 4 | 2020-10-20 22:01:21.8 UTC | 2016-12-10 00:38:18.937 UTC | null | 1,760,479 | null | 148,051 | null | 1 | 14 | .net|reportviewer | 132,467 | <p>Version 12 of the ReportViewer bits is referred to as <em>Microsoft Report Viewer 2015 Runtime</em> and can downloaded for installation from the following link:</p>
<p><a href="https://www.microsoft.com/en-us/download/details.aspx?id=45496" rel="noreferrer">https://www.microsoft.com/en-us/download/details.aspx?id=4... |
32,581,644 | Branch-aware programming | <p>I'm reading around that branch misprediction can be a hot bottleneck for the performance of an application. As I can see, people often show <em>assembly</em> code that unveil the problem and state that programmers usually can predict where a branch could go the most of the times and avoid branch mispredictons.</p>
<... | 32,581,909 | 8 | 17 | null | 2015-09-15 08:48:47.16 UTC | 9 | 2020-09-20 20:26:33.203 UTC | 2020-09-20 20:26:33.203 UTC | null | 6,461,462 | null | 2,508,150 | null | 1 | 41 | c++|c|performance|optimization|branch-prediction | 7,733 | <blockquote>
<p>people often ... and state that programmers usually can predict where a branch could go</p>
</blockquote>
<p>(*) Experienced programmers often remind that human programmers are very bad at predicting that.</p>
<blockquote>
<p>1- Is it possible to avoid branch mispredictions using some high level p... |
46,777,626 | Mathematically producing sphere-shaped hexagonal grid | <p>I am trying to create a shape similar to this, hexagons with 12 pentagons, at an arbitrary size.</p>
<p><a href="https://i.stack.imgur.com/F35J0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/F35J0.png" alt="https://i.stack.imgur.com/F35J0.png"></a></p>
<p>(<a href="https://stackoverflow.com/questions/2... | 47,043,459 | 3 | 5 | null | 2017-10-16 19:20:51.903 UTC | 13 | 2021-08-21 00:52:03.25 UTC | 2017-10-24 22:14:44.313 UTC | null | 4,441,547 | null | 4,441,547 | null | 1 | 27 | algorithm|geometry|computational-geometry|tiling|hexagonal-tiles | 21,131 | <p>First some analysis of the image in the question: the spherical triangle spanned by neighbouring pentagon centers seems to be equilateral. When five equilateral triangles meet in one corner and cover the whole sphere, this can only be the configuration induced by a <a href="https://en.wikipedia.org/wiki/Icosahedron"... |
63,312,642 | How to install node.tar.xz file in linux | <p>I recently downloaded the Nodejs file from the official site and I don't know how to install the Nodejs from a archived file.</p>
<p>Please help me how can I install this file so that I can run the "npm" command from the CLI for installation of several packages for my own project.</p> | 66,166,866 | 6 | 2 | null | 2020-08-08 06:58:03.22 UTC | 22 | 2022-05-01 00:19:19.77 UTC | null | null | null | null | 11,588,855 | null | 1 | 50 | node.js|node-modules|npm-install | 58,666 | <p><strong>Steps to download and install node in ubuntu</strong></p>
<p>Step 1: Download latest or recommended <strong>node</strong> .tar.xz file from <a href="https://nodejs.org/en/" rel="noreferrer">https://nodejs.org/en/</a></p>
<p>or you can download node version 14.15.5 (.tar.xz file) directly from here -></p>
... |
54,298,051 | Argument of type '...' is not assignable to parameter of type '...' TS 2345 | <p>Given the following:</p>
<pre class="lang-js prettyprint-override"><code>interface MyInterface {
type: string;
}
let arr: object[] = [ {type: 'asdf'}, {type: 'qwerty'}]
// Alphabetical sort
arr.sort((a: MyInterface, b: MyInterface) => {
if (a.type < b.type) return -1;
if (a.type > b.type) re... | 54,299,005 | 1 | 6 | null | 2019-01-21 21:33:07.843 UTC | 1 | 2020-11-26 14:17:55.94 UTC | 2020-11-26 14:17:55.94 UTC | null | 572,747 | null | 572,747 | null | 1 | 10 | typescript | 52,447 | <p>Here is a simplified example to reproduce the error: </p>
<pre><code>interface MyInterface {
type: string;
}
let arr:object[] = []
// Error: "object" is not compatible with MyInterface
arr.sort((a: MyInterface, b: MyInterface) => {});
</code></pre>
<p>The reason its an error is because <code>object</code> ca... |
1,897,129 | How to convert unordered list into nicely styled <select> dropdown using jquery? | <p>How do I convert an unordered list in this format</p>
<pre><code><ul class="selectdropdown">
<li><a href="one.html" target="_blank">one</a></li>
<li><a href="two.html" target="_blank">two</a></li>
<li><a href="three.html" target="_blank">... | 1,897,468 | 5 | 1 | null | 2009-12-13 17:36:54.173 UTC | 17 | 2017-04-01 15:20:01.687 UTC | 2014-03-24 14:13:33.147 UTC | null | 221,381 | null | 84,201 | null | 1 | 20 | javascript|jquery|css|xhtml | 49,843 | <pre><code>$('ul.selectdropdown').each(function() {
var select = $(document.createElement('select')).insertBefore($(this).hide());
$('>li a', this).each(function() {
var a = $(this).click(function() {
if ($(this).attr('target')==='_blank') {
window.open(this.href);
... |
1,850,162 | Is there an open source WebSockets (JavaScript) XMPP library? | <p>Has anyone written an open source XMPP library that uses WebSockets and is meant to be run by a browser?</p> | 1,875,848 | 6 | 1 | null | 2009-12-04 22:47:29.157 UTC | 19 | 2013-08-27 20:38:30.387 UTC | null | null | null | null | 195,656 | null | 1 | 34 | javascript|xmpp | 18,947 | <p>We don't yet have a standard for XMPP over <a href="https://datatracker.ietf.org/doc/html/draft-hixie-thewebsocketprotocol" rel="nofollow noreferrer">WebSockets</a> that the servers can implement, which will be required before the client side can be tackled adequately.</p>
<p>The first step is to finish WebSocket st... |
1,518,594 | When should one use the following: Amazon EC2, Google App Engine, Microsoft Azure and Salesforce.com? | <p>I am asking this in very general sense. Both from cloud provider and cloud consumer's perspective. Also the question is not for any specific kind of application (in fact the intention is to know which type of applications/domains can fit into which of the cloud slab -SaaS PaaS IaaS).</p>
<p>My understanding so far ... | 1,519,048 | 7 | 3 | null | 2009-10-05 07:06:03.503 UTC | 46 | 2013-05-14 04:39:13.96 UTC | 2009-10-06 05:12:34.503 UTC | null | 32,262 | null | 32,262 | null | 1 | 93 | google-app-engine|amazon-ec2|azure|cloud|salesforce | 11,811 | <p>Good question! As you point out, the different offerings fit into different categories:</p>
<p>EC2 is Infrastructure as a Service; you get VM instances, and do with them as you wish. Rackspace Cloud Servers are more or less the same.</p>
<p>Azure, App Engine, and Salesforce are all Platform as a Service; they offe... |
1,609,742 | Efficient way of calculating likeness scores of strings when sample size is large? | <p>Let's say that you have a list of 10,000 email addresses, and you'd like to find what some of the closest "neighbors" in this list are - defined as email addresses that are suspiciously close to other email addresses in your list.</p>
<p>I'm aware of how to calculate the <a href="http://en.wikipedia.org/wiki/Levens... | 1,613,372 | 8 | 2 | null | 2009-10-22 20:24:19.883 UTC | 9 | 2016-01-01 13:36:24.453 UTC | 2017-05-23 11:53:22.447 UTC | null | -1 | null | 4,249 | null | 1 | 15 | algorithm|string|cluster-analysis|complexity-theory|edit-distance | 5,281 | <p>Yup - you can find all strings within a given distance of a string in O(log n) time by using a <a href="http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees" rel="nofollow noreferrer">BK-Tree</a>. Alternate solutions involving generating every string with distance n may be faster for a levenshtein dist... |
1,448,819 | How to install pysqlite? | <p>I am trying to install pysqlite (Python interface to the SQLite). I downloaded the file with the package (pysqlite-2.5.5.tar.gz). And I did the following:</p>
<pre><code>gunzip pysqlite-2.5.5.tar.gz
tar xvf pysqlite-2.5.5.tar
\cd pysqlite-2.5.5
python setup.py install
</code></pre>
<p>At the last step I have a pro... | 1,448,865 | 11 | 4 | null | 2009-09-19 15:55:09.66 UTC | null | 2018-07-30 15:23:46.76 UTC | 2009-09-19 16:20:18.89 UTC | null | 12,855 | null | 175,960 | null | 1 | 4 | python|linux|sqlite|gcc|pysqlite | 38,873 | <blockquote>
<p>how to check if I have "sqlite3-dev"</p>
</blockquote>
<p>That's entirely dependent on what Linux distro you're using -- is it Fedora, Suse, Ubuntu, Gentoo, Mandrake, or which other one out of the dozens out there; there are several packaging strategies and tools used to check which packages are ther... |
1,414,951 | How do I get elapsed time in milliseconds in Ruby? | <p>If I have a <code>Time</code> object got from :</p>
<pre><code>Time.now
</code></pre>
<p>and later I instantiate another object with that same line, how can I see how many milliseconds have passed? The second object may be created that same minute, over the next minutes or even hours.</p> | 1,415,073 | 11 | 0 | null | 2009-09-12 12:00:10.897 UTC | 12 | 2021-12-10 19:12:02.047 UTC | 2012-05-05 02:00:01.363 UTC | null | 15,168 | null | 31,610 | null | 1 | 104 | ruby | 129,602 | <p>As stated already, you can operate on <code>Time</code> objects as if they were numeric (or floating point) values. These operations result in second resolution which can easily be converted. </p>
<p>For example:</p>
<pre><code>def time_diff_milli(start, finish)
(finish - start) * 1000.0
end
t1 = Time.now
# ar... |
2,003,534 | How to find out how many lines of code there are in an Xcode project? | <p>Is there a way to determine how many lines of code an Xcode project contains? I promise not to use such information for managerial measurement or employee benchmarking purposes. ;)</p> | 2,003,645 | 14 | 2 | null | 2010-01-05 01:18:55.917 UTC | 102 | 2021-06-13 10:57:25.7 UTC | 2016-02-07 19:19:27.833 UTC | user4639281 | null | null | 153,040 | null | 1 | 181 | xcode|code-metrics | 101,264 | <p>Check out <a href="https://github.com/AlDanial/cloc" rel="noreferrer">CLOC</a>.</p>
<blockquote>
<p>cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.</p>
</blockquote>
<p>(<a href="http://cloc.sourceforge.net/" rel="noreferrer">Legacy builds are archived on Sour... |
1,912,676 | I am not able launch JNLP applications using "Java Web Start"? | <p>Up until recently, I was able to launch/open <em>JNLP</em> files in <em>Firefox</em> using <em>Java web start</em>.</p>
<p>Don't know what happened all of a sudden <em>JNLP</em> files stopped launching, a splash screen appears saying <em>Java Starting...</em> and then nothing happens. Even the <em>Java Console</em>... | 18,461,490 | 17 | 1 | null | 2009-12-16 06:18:13.937 UTC | 4 | 2022-04-19 15:14:03.923 UTC | 2016-06-01 12:17:33.467 UTC | null | 3,956,223 | null | 108,769 | null | 1 | 28 | java|jnlp|java-web-start | 254,502 | <p>Although this question is bit old, the issue was caused by <strong>corrupted ClearType registry setting</strong> and resolved by fixing it, as described in this <a href="http://www.rarst.net/software/cleartype-install4j-java-bug/" rel="nofollow noreferrer">ClearType, install4j and case of Java bug</a> post.</p>
<blo... |
1,590,608 | How do I forward-declare a function to avoid `NameError`s for functions defined later? | <p>Is it possible to forward-declare a function in Python? I want to sort a list using my own <code>cmp</code> function before it is declared.</p>
<pre><code>print "\n".join([str(bla) for bla in sorted(mylist, cmp = cmp_configs)])
</code></pre>
<p>I've put the definition of <code>cmp_configs</code> method af... | 1,590,657 | 17 | 0 | null | 2009-10-19 19:29:21.987 UTC | 36 | 2022-07-03 17:21:26.16 UTC | 2022-07-03 17:16:05.643 UTC | null | 365,102 | null | 1,084 | null | 1 | 252 | python|forward-declaration | 223,507 | <p>If you don't want to define a function <em>before</em> it's used, and defining it <em>afterwards</em> is impossible, what about defining it in some other module?</p>
<p>Technically you still define it first, but it's clean.</p>
<p>You could create a recursion like the following:</p>
<pre><code>def foo():
bar(... |
1,720,421 | How do I concatenate two lists in Python? | <p>How do I concatenate two lists in Python?</p>
<p>Example:</p>
<pre><code>listone = [1, 2, 3]
listtwo = [4, 5, 6]
</code></pre>
<p>Expected outcome:</p>
<pre><code>>>> joinedlist
[1, 2, 3, 4, 5, 6]
</code></pre> | 1,720,432 | 31 | 3 | null | 2009-11-12 07:04:09.05 UTC | 404 | 2022-09-22 20:50:48.6 UTC | 2019-03-17 09:15:29.797 UTC | null | 63,550 | null | 206,504 | null | 1 | 3,246 | python|list|concatenation | 3,831,656 | <p>Use the <code>+</code> operator to combine the lists:</p>
<pre><code>listone = [1, 2, 3]
listtwo = [4, 5, 6]
joinedlist = listone + listtwo
</code></pre>
<p>Output:</p>
<pre><code>>>> joinedlist
[1, 2, 3, 4, 5, 6]
</code></pre> |
8,760,322 | Troubles implementing IEnumerable<T> | <p>I'm trying to write my own (simple) implementation of List. This is what I did so far:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace provaIEnum
{
class MyList<T> : IEnumerable<T>
{
private T[] _array;
public int Co... | 8,760,350 | 7 | 2 | null | 2012-01-06 15:38:14.217 UTC | 2 | 2015-11-09 12:22:44.773 UTC | null | null | null | null | 521,776 | null | 1 | 32 | c# | 23,703 | <p>Since <a href="http://msdn.microsoft.com/en-us/library/9eekhta0.aspx"><code>IEnumerable<T></code></a> implements <a href="http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx"><code>IEnumerable</code></a> you need to implement this interface as well in your class which has the non-generi... |
17,784,587 | gradient descent using python and numpy | <pre><code>def gradient(X_norm,y,theta,alpha,m,n,num_it):
temp=np.array(np.zeros_like(theta,float))
for i in range(0,num_it):
h=np.dot(X_norm,theta)
#temp[j]=theta[j]-(alpha/m)*( np.sum( (h-y)*X_norm[:,j][np.newaxis,:] ) )
temp[0]=theta[0]-(alpha/m)*(np.sum(h-y))
temp[1]=theta[... | 17,796,231 | 5 | 1 | null | 2013-07-22 09:55:30.337 UTC | 77 | 2022-03-12 10:15:25.303 UTC | 2014-02-10 11:44:37.617 UTC | null | 540,873 | null | 1,658,129 | null | 1 | 64 | python|numpy|machine-learning|linear-regression|gradient-descent | 190,541 | <p>I think your code is a bit too complicated and it needs more structure, because otherwise you'll be lost in all equations and operations. In the end this regression boils down to four operations:</p>
<ol>
<li>Calculate the hypothesis h = X * theta</li>
<li>Calculate the loss = h - y and maybe the squared cost (loss... |
18,202,818 | Classes vs. Functions | <p>Functions are easy to understand even for someone without any programming experience, but with a fair math background. On the other hand, classes seem to be more difficult to grasp.</p>
<p>Let's say I want to make a class/function that calculates the age of a person given his/her birthday year and the current year... | 18,202,865 | 8 | 3 | null | 2013-08-13 07:12:57.92 UTC | 57 | 2021-05-07 17:58:58.117 UTC | 2013-08-13 08:13:47.853 UTC | null | 126,214 | null | 1,585,017 | null | 1 | 107 | class|function|oop | 168,107 | <p>Create a function. Functions <em>do</em> specific things, classes <em>are</em> specific things.</p>
<p>Classes often have methods, which are functions that are associated with a particular class, and do things associated with the thing that the class is - but if all you want is to do something, a function is all yo... |
7,006,888 | How to get combobox not to accept user input in Excel-Vba? | <p>Does anyone know what the properties are in the combobox that I can manipulate in order not to allow the user to key/type in any data?</p> | 7,007,075 | 3 | 2 | null | 2011-08-10 06:49:03.527 UTC | 5 | 2014-10-10 21:15:03.63 UTC | 2011-08-10 06:55:08.963 UTC | null | 13,295 | null | 694,831 | null | 1 | 24 | excel|vba|controls|excel-2007 | 90,493 | <p>Set the the Style of the combobox to <code>2 - fmStyleDropDownList</code>. This will disallow user input, and will also prevent (combobox).value changes via macro. </p> |
6,463,459 | When to use Observable.FromEventPattern rather than Observable.FromEvent? | <p>We've got a client calling off to a TIBCO EMS queue and are wiring up the events like this:</p>
<pre><code>var msgConsumer = _session.CreateConsumer(responseQueue);
var response = Observable.FromEvent<EMSMessageHandler,EMSMessageEventArgs>
(h => msgConsumer.MessageHandler += h, h => msgConsu... | 6,468,952 | 3 | 3 | null | 2011-06-24 04:41:30.123 UTC | 12 | 2015-11-27 11:34:10.573 UTC | 2015-11-27 11:34:10.573 UTC | user1400995 | null | null | 5,130 | null | 1 | 60 | c#|system.reactive | 26,616 | <p>"Use FromEvent for events structurally don't look like a .NET event pattern (i.e. not based on sender, event args), and use FromEventPattern for the pattern-based ones." - <a href="http://social.msdn.microsoft.com/Forums/en-CA/rx/thread/5f4df41c-6df1-42be-b7bb-bbf072143c24" rel="noreferrer">Bart De Smet (Rx team)</a... |
23,469,051 | JavaScript Alert Selected Option of html drop down | <p>I have searched around and tried various things but I cannot find a way to get javascript to alert my chosen option. All that happens with what I have is in the console debugging section at the bottom of the page it says " 'null' is not an object (evaluating 'x.options') " which suggests to me that my variable x is ... | 23,470,017 | 2 | 3 | null | 2014-05-05 09:27:16.647 UTC | 1 | 2014-05-05 10:15:59.757 UTC | null | null | null | null | 3,603,650 | null | 1 | 5 | javascript|html | 49,358 | <p>I believe you want to alert the text of the chosen element, you can do it by doing this in a shorter way too</p>
<p>HTML:
</p>
<pre><code><select id="test-dropdown" onchange="choice1(this)">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3"... |
34,937,724 | Running bash scripts with npm | <p>I want to try using npm to run my various build tasks for a web application. I know I can do this by adding a <code>scripts</code> field to my <code>package.json</code> like so:</p>
<pre><code>"scripts": {
"build": "some build command"
},
</code></pre>
<p>This gets unwieldy when you have more complex commands ... | 34,938,559 | 4 | 8 | null | 2016-01-22 01:54:33.847 UTC | 25 | 2022-08-27 03:04:43.713 UTC | null | null | null | null | 2,962,432 | null | 1 | 115 | node.js|bash|shell|npm | 137,251 | <p>Its totally possible... </p>
<pre><code>"scripts": {
"build": "./build.sh"
},
</code></pre>
<p>also, make sure you put a hash bang at the top of your bash file <code>#!/usr/bin/env bash</code></p>
<p>also make sure you have permissions to execute the file </p>
<pre><code>chmod +x ./build.sh
</code></pre>
<p>... |
35,127,060 | How to implement atoi using SIMD? | <p>I'd like to try writing an atoi implementation using SIMD instructions, to be included in <a href="http://rapidjson.org/" rel="noreferrer">RapidJSON</a> (a C++ JSON reader/writer library). It currently has some SSE2 and SSE4.2 optimizations in other places.</p>
<p>If it's a speed gain, multiple <code>atoi</code> r... | 35,132,718 | 2 | 11 | null | 2016-02-01 09:33:51.45 UTC | 12 | 2017-11-12 12:36:20.863 UTC | 2016-02-01 14:18:17.533 UTC | null | 224,132 | null | 85,140 | null | 1 | 29 | c++|x86|sse|simd|atoi | 6,536 | <p>The algorithm and its implementation is finished now. It's complete and (moderately) tested (<em>Updated for less constant memory usage and tolerating plus-char</em>).</p>
<p><strong>The properties of this code are as follows:</strong></p>
<ul>
<li>Works for <code>int</code> and <code>uint</code>,
from <code>MIN_... |
34,354,401 | "The remote certificate is invalid according to the validation procedure" using HttpClient | <p>Can't solve the problem with certificate validation. </p>
<p>There's Web API server, that uses HTTPS to handle requests. Server's certificate has this certification path: RCA (root) -> ICA (intermediate) -> Web API server. RCA, ICA and Web API server are members of the same Active Directory domain.</p>
<p>Client ... | 34,355,415 | 3 | 7 | null | 2015-12-18 11:16:42.617 UTC | 4 | 2021-05-10 03:33:20.777 UTC | 2017-05-23 11:59:52.66 UTC | null | -1 | null | 580,053 | null | 1 | 21 | c#|ssl-certificate|dotnet-httpclient | 38,951 | <p>The issue you are experiencing is because the subject CN presented by the certificate does not match the host name in the Uri.</p>
<p>Make sure that the certificate bound to the public IP address of the host does have a matching CN with the host name you are using to access the resource.</p>
<p>To easily verify, o... |
27,808,734 | JDK8 - Error "class file for javax.interceptor.InterceptorBinding not found" when trying to generate javadoc using Maven javadoc plugin | <p>I am using JDK8 (tried it on my Eclipse workspace with Win x64 u25 JDK + on Linux launched by Jenkins - jdk-8u20-linux-x64, same problem for both).</p>
<p>I have multi-module Maven project (I am launching Maven goal "javadoc:aggregate" from a main module with packaging type "pom").</p>
<p>Pom build section looks l... | 28,755,606 | 10 | 3 | null | 2015-01-06 23:00:09.28 UTC | 16 | 2021-10-27 20:02:40.86 UTC | 2015-06-16 19:19:39.42 UTC | null | 540,552 | null | 3,626,641 | null | 1 | 91 | java|maven|java-8|maven-javadoc-plugin | 46,643 | <p>This appears to be due to <code>javax.transaction.Transactional</code> (or any other class in your classpath for that matter) being itself annotated with <code>javax.interceptor.InterceptorBinding</code>, which is missing in classpath unless explicitly declared in dependencies:</p>
<pre><code>@Inherited
@Intercepto... |
27,852,343 | Split Python sequence (time series/array) into subsequences with overlap | <p>I need to extract all subsequences of a time series/array of a given window. For example:</p>
<pre><code>>>> ts = pd.Series([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> window = 3
>>> subsequences(ts, window)
array([[0, 1, 2],
[1, 2, 3],
[2, 3, 4],
[3, 4, 5],
[4, 5, 6],... | 27,852,474 | 3 | 3 | null | 2015-01-09 01:07:26.447 UTC | 10 | 2019-07-16 11:55:40.067 UTC | 2015-01-09 21:49:17.62 UTC | null | 711,705 | null | 711,705 | null | 1 | 13 | python|performance|numpy|pandas|time-series | 9,104 | <p>This is 34x faster than your fast version in my machine:</p>
<pre><code>def rolling_window(a, window):
shape = a.shape[:-1] + (a.shape[-1] - window + 1, window)
strides = a.strides + (a.strides[-1],)
return np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides)
>>> rolling_window(ts.... |
5,580,935 | Converting iPhone app to a Universal app in Xcode 4 | <p>I am trying to upgrade my existing iPhone app project to an Universal app but I can not find any option in Xcode 4 to do so. Where is it?</p> | 5,582,407 | 2 | 1 | null | 2011-04-07 12:21:52.983 UTC | 9 | 2014-03-31 19:03:25.163 UTC | 2011-06-21 02:48:03.473 UTC | null | 19,617 | null | 319,097 | null | 1 | 25 | objective-c|ios|xcode4|universal-binary | 15,690 | <p>{ Outdated / incorrect information removed. Moderators, I've asked to at least unmark my answer as accepted. Please clean this up. }</p>
<p><strong>See Nick Lockwood's answer!</strong></p> |
16,504,084 | What is Object Reference Variable? | <p>What is Object Reference variable in java?</p>
<p>Does the reference variable holds the memory address of the object?</p>
<p>I am confused. Please do explain.</p> | 16,504,133 | 5 | 0 | null | 2013-05-12 04:05:34.553 UTC | 8 | 2015-11-25 06:52:19.64 UTC | 2013-05-12 06:10:11.347 UTC | null | 418,556 | null | 2,301,829 | null | 1 | 9 | java | 69,877 | <p>I'm not sure I have the elegance to properly answer this, but...</p>
<ul>
<li>An Object is an instance of a Class, it is stored some where in memory</li>
<li>A reference is what is used to describe the pointer to the memory location where the Object resides.</li>
<li>A variable is a means by which you can access th... |
1,065,247 | How do I calculate tree edit distance? | <p>I need to calculate the edit distance between trees. <a href="http://erikdemaine.org/papers/TreeEdit_ICALP2007/paper.ps" rel="nofollow noreferrer">This</a> paper describes an algorithm, but I can't make heads or tails out of it. Could you describe an applicable algorithm in a more approachable way? Pseudocode or c... | 1,065,485 | 7 | 2 | null | 2009-06-30 18:34:55.723 UTC | 20 | 2021-08-17 09:34:49.573 UTC | 2020-01-27 15:00:32.673 UTC | null | 1,536,976 | null | 32,944 | null | 1 | 27 | algorithm|tree | 16,760 | <p>Here's some <a href="http://web.science.mq.edu.au/%7Eswan/howtos/treedistance/" rel="nofollow noreferrer">Java source code</a> (gzipped tarball at the bottom) for a <em>tree edit distance</em> algorithm that might be useful to you.</p>
<p>The page includes references and some slides that go through the "Zhang a... |
917,551 | Func delegate with no return type | <p>All of the Func delegates return a value. What are the .NET delegates that can be used with methods that return void?</p> | 917,572 | 7 | 0 | null | 2009-05-27 19:21:42.033 UTC | 71 | 2018-03-06 00:18:13.67 UTC | 2013-01-10 16:51:29.803 UTC | null | 265,570 | null | 113,165 | null | 1 | 657 | c#|.net | 261,866 | <p>All Func delegates return something; all the Action delegates return void.</p>
<p><code>Func<TResult></code> takes no arguments and returns TResult:</p>
<pre><code>public delegate TResult Func<TResult>()
</code></pre>
<p><code>Action<T></code> takes one argument and does not return a value:</p>
... |
659,025 | How to remove non-alphanumeric characters? | <p>I need to remove all characters from a string which aren't in <code>a-z A-Z 0-9</code> set or are not spaces.</p>
<p>Does anyone have a function to do this?</p> | 659,030 | 7 | 0 | null | 2009-03-18 16:29:19.14 UTC | 59 | 2019-08-06 22:39:34.977 UTC | 2015-03-19 19:33:25.23 UTC | null | 55,075 | zuk1 | 26,823 | null | 1 | 408 | php|regex|string | 274,033 | <p>Sounds like you almost knew what you wanted to do already, you basically defined it as a regex.</p>
<pre><code>preg_replace("/[^A-Za-z0-9 ]/", '', $string);
</code></pre> |
1,264,833 | Class factory to produce simple struct-like classes? | <p>While investigating Ruby I came across this to create a simple Struct-like class:</p>
<pre><code>Person = Struct.new(:forname, :surname)
person1 = Person.new('John', 'Doe')
puts person1 #<struct Person forname="John", surname="Doe">
</code></pre>
<p>Which raised a few Python questions for me. I have written... | 1,275,088 | 8 | 1 | null | 2009-08-12 07:57:57.577 UTC | 12 | 2022-06-20 16:29:38.427 UTC | 2017-08-31 19:58:21.35 UTC | null | 355,230 | null | 134,107 | null | 1 | 13 | python|struct|class-factory | 8,406 | <p>An update of ThomasH's variant:</p>
<pre><code>def Struct(*args, **kwargs):
def init(self, *iargs, **ikwargs):
for k,v in kwargs.items():
setattr(self, k, v)
for i in range(len(iargs)):
setattr(self, args[i], iargs[i])
for k,v in ikwargs.items():
setat... |
1,004,327 | Getting rid of derby.log | <p>I'm using the Apache Derby embedded database for unit testing in a Maven project. Unfortunately whenever I run the test I end up with the <code>derby.log</code> file in the root of the project. The database itself is created in the <code>target</code> directory (<code>jdbc:derby:target/unittest-db;create=true</code>... | 1,004,686 | 8 | 0 | null | 2009-06-16 22:54:36.47 UTC | 15 | 2016-07-27 12:13:20.11 UTC | null | null | null | null | 417,328 | null | 1 | 28 | java|maven-2|derby | 28,381 | <p>You can get rid of <a href="http://db.apache.org/derby/docs/dev/devguide/cdevdvlp25889.html" rel="noreferrer"><code>derby.log</code></a> file by creating the following class</p>
<pre><code>public class DerbyUtil {
public static final OutputStream DEV_NULL = new OutputStream() {
public void write(int b) ... |
42,182 | How to escape < and > inside <pre> tags | <p>I'm trying to write a blog post which includes a code segment inside a <code><pre></code> tag. The code segment includes a generic type and uses <code><></code> to define that type. This is what the segment looks like:</p>
<pre><code><pre>
PrimeCalc calc = new PrimeCalc();
Func<int, int... | 42,195 | 8 | 2 | null | 2008-09-03 17:41:06.43 UTC | 15 | 2022-05-31 10:12:34.153 UTC | 2022-05-31 10:12:34.153 UTC | null | 3,689,450 | urini | 373 | null | 1 | 97 | html|escaping|blogger|markup|pre | 88,373 | <pre><code><pre>
PrimeCalc calc = new PrimeCalc();
Func&lt;int, int&gt; del = calc.GetNextPrime;
</pre>
</code></pre> |
230,454 | How to Fill an array from user input C#? | <p>What would be the best way to fill an array from user input?</p>
<p>Would a solution be showing a prompt message and then get the values from from the user?</p> | 230,463 | 9 | 0 | null | 2008-10-23 16:37:23.503 UTC | 7 | 2017-08-23 01:13:31.237 UTC | 2008-10-23 16:51:44.27 UTC | Longhorn213 | 2,469 | arin | 30,858 | null | 1 | 18 | c# | 221,328 | <pre><code>string []answer = new string[10];
for(int i = 0;i<answer.length;i++)
{
answer[i]= Console.ReadLine();
}
</code></pre> |
411,249 | Coding style checker for C | <p>I'm working for a company that has strict coding style guidelines but no automatic tool to validate them. I've looked around and the only tools I could find were lint like tools that seem to be aimed at verifying what the code does, and preventing bugs and not at making sure the coding style is correct.</p>
<p>What... | 411,698 | 9 | 0 | null | 2009-01-04 16:46:06.79 UTC | 16 | 2018-10-23 13:49:31.697 UTC | null | null | null | gooli | 15,109 | null | 1 | 24 | c|coding-style | 36,510 | <p>The traditional beautifier <a href="http://en.wikipedia.org/wiki/Indent_(Unix)" rel="noreferrer">indent</a>, available on every Unix machine. The version found on some is <a href="http://www.gnu.org/software/indent/" rel="noreferrer">GNU indent</a>, which can be compiled and installed on every machine. GNU indent ca... |
681,827 | How to create and fill a ZIP file using ASP.NET? | <p>Need to dynamically package some files into a .zip to create a SCORM package, anyone know how this can be done using code? Is it possible to build the folder structure dynamically inside of the .zip as well?</p> | 681,956 | 9 | 1 | null | 2009-03-25 14:29:48.113 UTC | 8 | 2020-08-20 06:09:23.11 UTC | null | null | null | Ryan | 18,309 | null | 1 | 27 | asp.net|zip | 45,392 | <p>You don't have to use an external library anymore. System.IO.Packaging has classes that can be used to drop content into a zip file. Its not simple, however. <a href="http://weblogs.asp.net/jongalloway//creating-zip-archives-in-net-without-an-external-library-like-sharpziplib" rel="noreferrer">Here's a blog post ... |
470,256 | Process.WaitForExit() asynchronously | <p>I want to wait for a process to finish, but <code>Process.WaitForExit()</code> hangs my GUI. Is there an event-based way, or do I need to spawn a thread to block until exit, then delegate the event myself?</p> | 470,288 | 9 | 3 | null | 2009-01-22 18:13:58.397 UTC | 13 | 2022-06-22 01:23:30.15 UTC | 2022-06-22 01:23:30.15 UTC | null | 11,178,549 | Dustin Getz | 20,003 | null | 1 | 72 | c#|.net|winforms|user-interface|asynchronous | 43,672 | <p><a href="https://msdn.microsoft.com/en-us/library/system.diagnostics.process.enableraisingevents.aspx" rel="noreferrer">process.EnableRaisingEvents</a> = true;<br>
<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.exited.aspx" rel="noreferrer">process.Exited</a> += [EventHandler]</p> |
170,907 | Is there a downside to adding an anonymous empty delegate on event declaration? | <p>I have seen a few mentions of this idiom (including <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c#9282">on SO</a>):</p>
<pre><code>// Deliberately empty subscriber
public event EventHandler AskQuestion = delegate {};
</code></pre>
<p>The upside is clear - it avoids the need to check for nu... | 170,915 | 9 | 0 | null | 2008-10-04 19:41:15.103 UTC | 30 | 2015-08-10 18:23:23.57 UTC | 2017-05-23 12:18:17.367 UTC | Joel Coehoorn | -1 | serg10 | 1,853 | null | 1 | 84 | c#|coding-style|delegates|events|idioms | 12,287 | <p>The only downside is a very slight performance penalty as you are calling extra empty delegate. Other than that there is no maintenance penalty or other drawback.</p> |
602,706 | Batch renaming files with Bash | <p>How can Bash rename a series of packages to remove their version numbers? I've been toying around with both <code>expr</code> and <code>%%</code>, to no avail.</p>
<p>Examples:</p>
<p><code>Xft2-2.1.13.pkg</code> becomes <code>Xft2.pkg</code></p>
<p><code>jasper-1.900.1.pkg</code> becomes <code>jasper.pkg</code><... | 602,770 | 10 | 2 | null | 2009-03-02 15:20:44.83 UTC | 50 | 2018-08-22 09:05:25.937 UTC | 2017-06-12 03:59:21.147 UTC | null | 6,862,601 | Nerdling | 70,519 | null | 1 | 117 | bash|shell|file-rename | 105,863 | <p>You could use bash's parameter expansion feature</p>
<pre><code>for i in ./*.pkg ; do mv "$i" "${i/-[0-9.]*.pkg/.pkg}" ; done
</code></pre>
<p>Quotes are needed for filenames with spaces.</p> |
1,309,452 | How to replace innerHTML of a div using jQuery? | <p>How could I achieve the following:</p>
<pre><code>document.all.regTitle.innerHTML = 'Hello World';
</code></pre>
<p>Using jQuery where <code>regTitle</code> is my <code>div</code> id?</p> | 1,309,454 | 14 | 0 | null | 2009-08-20 23:51:36.783 UTC | 123 | 2021-06-22 09:52:00.59 UTC | 2020-07-20 18:12:45.403 UTC | null | 2,430,549 | null | 111,479 | null | 1 | 1,148 | javascript|jquery|innerhtml | 1,823,320 | <pre><code>$("#regTitle").html("Hello World");
</code></pre> |
1,163,376 | HTML +CSS +Javascript Editor | <p>Hello I am looking for a good HTML + CSS +Javascript Editor Microsoft Windows platform </p>
<p>Thank you very much !!!!</p>
<p><strong>UPDATES</strong> : </p>
<hr>
<p>1) I found an amazing one, which I use already for a while on windows and on MAC as well :</p>
<p><a href="http://www.sublimetext.com/2" rel="no... | 1,163,396 | 15 | 5 | null | 2009-07-22 06:28:58.04 UTC | 4 | 2016-05-25 19:06:34.26 UTC | 2014-10-21 18:09:37.567 UTC | null | 119,084 | null | 119,084 | null | 1 | 26 | javascript|html|css|editor | 89,739 | <p>I prefer Netbeans 6.7 PHP , it includES CSS / JS / HTML and PHP Features. Codefolding, Syntax Highlighting, Code completion, CSS Preview...</p>
<p>But my Favourite function is code completion for JQuery + Dojo</p>
<p>Download : <a href="https://netbeans.org//downloads/index.html" rel="nofollow noreferrer">Netbeans... |
254,281 | Best practices for overriding isEqual: and hash | <p>How do you properly override <code>isEqual:</code> in Objective-C? The "catch" seems to be that if two objects are equal (as determined by the <code>isEqual:</code> method), they must have the same hash value.</p>
<p>The <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObje... | 254,380 | 16 | 2 | null | 2008-10-31 17:22:25.783 UTC | 160 | 2022-01-20 23:08:10.38 UTC | 2009-07-11 13:49:29.39 UTC | Ned Batchelder | 120,292 | Dave Dribin | 26,825 | null | 1 | 272 | objective-c|equality | 94,221 | <p>Start with</p>
<pre><code> NSUInteger prime = 31;
NSUInteger result = 1;
</code></pre>
<p>Then for every primitive you do</p>
<pre><code> result = prime * result + var
</code></pre>
<p>For objects you use 0 for nil and otherwise their hashcode.</p>
<pre><code> result = prime * result + [var hash];
</code></pre... |
1,257,482 | RedirectToAction with parameter | <p>I have an action I call from an anchor thusly, <code>Site/Controller/Action/ID</code> where <code>ID</code> is an <code>int</code>.</p>
<p>Later on I need to redirect to this same Action from a Controller.</p>
<p>Is there a clever way to do this? Currently I'm stashing <code>ID</code> in tempdata, but when you
hi... | 1,257,632 | 16 | 1 | null | 2009-08-10 22:05:09.077 UTC | 102 | 2022-04-26 06:17:20.55 UTC | 2018-02-13 12:46:47.177 UTC | null | 5,978,553 | null | 86,431 | null | 1 | 690 | c#|asp.net-mvc|controller|redirecttoaction | 967,686 | <p>You can pass the id as part of the routeValues parameter of the RedirectToAction() method.</p>
<pre><code>return RedirectToAction("Action", new { id = 99 });
</code></pre>
<p>This will cause a redirect to Site/Controller/Action/99. No need for temp or any kind of view data.</p> |
226,663 | Parse RSS with jQuery | <p>I want to use jQuery to parse RSS feeds. Can this be done with the base jQuery library out of the box or will I need to use a plugin?</p> | 6,271,906 | 20 | 3 | null | 2008-10-22 16:49:58.017 UTC | 122 | 2019-10-15 07:52:05.897 UTC | 2012-07-12 04:34:09.693 UTC | pkaeding | 9,314 | null | 12,442 | null | 1 | 195 | jquery|jquery-plugins|rss|feedparser | 223,819 | <p><strong>WARNING</strong></p>
<blockquote>
<p><a href="https://developers.google.com/feed/" rel="nofollow noreferrer">The Google Feed API</a> is officially <strong>deprecated</strong> and <strong>doesn't work anymore</strong>!</p>
</blockquote>
<hr>
<p>No need for a whole plugin. This will return your RSS as a J... |
1,056,316 | Algorithm for Determining Tic Tac Toe Game Over | <p>I've written a game of tic-tac-toe in Java, and my current method of determining the end of the game accounts for the following possible scenarios for the game being over:</p>
<ol>
<li>The board is full, and no winner has yet been declared: Game is a draw.</li>
<li>Cross has won.</li>
<li>Circle has won.</li>
</ol>... | 1,056,352 | 25 | 1 | null | 2009-06-29 02:18:21.727 UTC | 72 | 2022-01-10 08:46:45.69 UTC | 2021-06-11 17:15:50.983 UTC | null | 1,373,465 | null | 112,765 | null | 1 | 116 | algorithm|state|tic-tac-toe | 252,451 | <p>You know a winning move can only happen after X or O has made their most recent move, so you can only search row/column with optional diag that are contained in that move to limit your search space when trying to determine a winning board. Also since there are a fixed number of moves in a draw tic-tac-toe game once... |
492,558 | Removing multiple files from a Git repo that have already been deleted from disk | <p>I have a Git repo that I have deleted four files from using <code>rm</code> (<strong>not</strong> <code>git rm</code>), and my Git status looks like this:</p>
<pre><code># deleted: file1.txt
# deleted: file2.txt
# deleted: file3.txt
# deleted: file4.txt
</code></pre>
<p>How do I remove thes... | 1,402,793 | 31 | 6 | null | 2009-01-29 17:18:14.777 UTC | 879 | 2021-12-22 09:43:15.33 UTC | 2015-06-24 06:12:48.897 UTC | null | 2,790,048 | Mr. Matt | 12,037 | null | 1 | 1,367 | git|git-commit|git-add|git-rm | 533,980 | <h3>For Git 1.x</h3>
<pre><code>$ git add -u
</code></pre>
<p>This tells git to automatically stage tracked files -- including deleting the previously tracked files. </p>
<h3>For Git 2.0</h3>
<p>To stage your whole working tree:</p>
<pre><code>$ git add -u :/
</code></pre>
<p>To stage just the current path:</p>
... |
359,732 | Why is it considered a bad practice to omit curly braces? | <p>Why does everyone tell me writing code like this is a bad practice?</p>
<pre><code>if (foo)
Bar();
//or
for(int i = 0 i < count; i++)
Bar(i);
</code></pre>
<p>My biggest argument for omitting the curly braces is that it can sometimes be twice as many lines with them. For example, here is some code to ... | 359,753 | 52 | 20 | 2008-12-11 16:47:01.76 UTC | 2008-12-11 15:34:22.827 UTC | 48 | 2016-08-19 17:07:33.35 UTC | 2016-08-19 17:07:33.35 UTC | Gortok | 1,413,395 | Bob | 45 | null | 1 | 184 | java|c#|c++|c|coding-style | 64,590 | <p>Actually, the only time that's ever really bit me was when I was debugging, and commented out bar():</p>
<pre><code>if(foo)
// bar();
doSomethingElse();
</code></pre>
<p>Other than that, I tend to use:</p>
<pre><code>if(foo) bar();
</code></pre>
<p>Which takes care of the above case.</p>
<p><strong>EDIT</stro... |
6,616,599 | Does the ^ symbol replace C#'s "ref" in parameter passing in C++/CLI code? | <p>In C#, passing by reference is:</p>
<pre><code>void MyFunction(ref Dog dog)
</code></pre>
<p>But in C++/CLI code examples I have seen so far, there is no use of <code>ref</code> but instead <code>^</code> symbol is used:</p>
<pre><code>void MyFunction(Dog ^ dog)
</code></pre>
<p>Is the use of <code>^</code> symb... | 6,616,684 | 5 | 2 | null | 2011-07-07 20:16:58.423 UTC | 10 | 2020-01-06 11:25:12.993 UTC | null | null | null | null | 1,418,093 | null | 1 | 20 | c#|c++-cli | 25,963 | <p>If <code>Dog</code> is a reference type (<code>class</code> in C#) then the C++/CLI equivalent is:</p>
<pre><code>void MyFunction(Dog^% dog)
</code></pre>
<p>If <code>Dog</code> is a value type (<code>struct</code> in C#) then the C++/CLI equivalent is:</p>
<pre><code>void MyFunction(Dog% dog)
</code></pre>
<p>A... |
6,497,373 | Make content horizontally scroll inside a div | <p>I have a division in which I wanna show images and on click open them in a lightbox. I have floated them left and displayed them inline. set overflow-x to scroll but it still puts the images below once the row space is not enough. I wanna get them to be inline and display a horizontal scroll when needed.</p>
<p><str... | 6,497,462 | 5 | 0 | null | 2011-06-27 18:40:06.317 UTC | 19 | 2021-10-05 01:57:06.857 UTC | 2021-10-05 01:57:06.857 UTC | null | 5,052,024 | null | 159,475 | null | 1 | 60 | html|css | 131,742 | <p>It may be something like this in HTML:</p>
<pre class="lang-html prettyprint-override"><code><div class="container-outer">
<div class="container-inner">
<!-- Your images over here -->
</div>
</div>
</code></pre>
<p>With this stylesheet:</p>
<pre class="la... |
15,866,451 | How to insert row at end of table with HTMLTableElement.insertRow | <h3>Background and Setup</h3>
<p>I'm trying to create a table from tabular data in javascript, but when I try inserting rows into a table element, it inserts in the opposite order from what I expect and the opposite order of what you get from using <code>appendChild</code>. (Here's <a href="http://jsfiddle.net/jtratne... | 15,866,688 | 4 | 6 | null | 2013-04-07 18:55:48.063 UTC | 5 | 2018-11-20 07:09:54.847 UTC | null | null | null | null | 1,316,786 | null | 1 | 22 | javascript|html|dom|html-table | 82,617 | <p>The <code>.insertRow</code> and <code>.insertCell</code> methods take an index. In absence of the index, the default value is <code>-1</code> in most browsers, however some browsers may use <code>0</code> or may throw an error, so it's best to provide this explicitly.</p>
<p>To to an append instead, just provide <c... |
15,602,667 | Possible approach to secure a Rest API endpoints using Facebook OAuth | <p>I've been reading a lot about the topic but all I find are obsolete or partial answers, which don't really help me that much and actually just confused me more.
I'm writing a Rest API (Node+Express+MongoDB) that is accessed by a web app (hosted on the same domain than the API) and an Android app. </p>
<p>I want the... | 15,603,312 | 1 | 0 | null | 2013-03-24 19:01:59.877 UTC | 19 | 2013-03-24 20:01:09.137 UTC | null | null | null | null | 874,634 | null | 1 | 23 | facebook|api|rest|oauth | 6,016 | <p>I think the better solution would be this:</p>
<ol>
<li>Login via Facebook</li>
<li>Pass the Facebook AccessToken to the server (over SSL for the
android app, and for the web app just have it redirect to an API endpoint
after FB login)</li>
<li>Check the <code>fb_access_token</code> given, make sure its valid. Get ... |
15,738,847 | Sending Files using HTTP POST in c# | <p>I have a small C# web application.How can I get the c# code that allows user to send files by HTTP POST.It should be able to send text files,image files,excel, csv, doc (all types of files) without using stream reader and all.</p> | 15,739,043 | 3 | 3 | null | 2013-04-01 06:41:26.873 UTC | 8 | 2013-10-29 17:17:48.61 UTC | 2013-04-01 06:49:22.293 UTC | null | 1,925,983 | null | 1,925,983 | null | 1 | 23 | c#|file|web-applications|http-post | 60,413 | <p>You can try the following code:</p>
<pre><code> public void PostMultipleFiles(string url, string[] files)
{
string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "multip... |
15,882,991 | Range of UTF-8 Characters in C++11 Regex | <p>This question is an extension of <a href="https://stackoverflow.com/questions/11254232/do-c11-regular-expressions-work-with-utf-8-strings">Do C++11 regular expressions work with UTF-8 strings?</a></p>
<pre><code>#include <regex>
if (std::regex_match ("中", std::regex("中") )) // "\u4e2d" also works
std::co... | 15,895,746 | 1 | 11 | null | 2013-04-08 15:22:38.957 UTC | 7 | 2013-04-16 07:40:53.25 UTC | 2017-05-23 10:29:37.407 UTC | null | -1 | null | 412,417 | null | 1 | 30 | c++|regex|unicode|utf-8|c++11 | 7,179 | <p>Encoded in UTF-8, the string <code>"[一-龠々〆ヵヶ]"</code> is equal to this one: <code>"[\xe4\xb8\x80-\xe9\xbe\xa0\xe3\x80\x85\xe3\x80\x86\xe3\x83\xb5\xe3\x83\xb6]"</code>. And this is not the <strike>droid</strike> character class you are looking for.</p>
<p>The character class you are looking for is the one that incl... |
15,962,421 | How can I disable scratch preview window? | <p>While coding Python, I like Vim's omnicompletion function, but I don't want Scratch Window to pop up at top. </p>
<p>How can I disable it?</p>
<p>(I'm using gVim 7.3)</p> | 15,963,488 | 2 | 0 | null | 2013-04-12 03:11:38.743 UTC | 4 | 2019-03-11 09:19:50.2 UTC | 2017-04-12 23:28:37.357 UTC | null | 4,694,621 | null | 423,905 | null | 1 | 38 | vim|autocomplete | 17,439 | <p>This behavior is defined by the presence of <code>preview</code> in the value of the <code>'completeopt'</code> option.</p>
<p>The default value is:</p>
<pre><code>menu,preview
</code></pre>
<p>To remove <code>preview</code>, simply add this line to your <code>~/.vimrc</code> or modify an existing <code>completeo... |
32,108,179 | Linear Regression :: Normalization (Vs) Standardization | <p>I am using Linear regression to predict data. But, I am getting totally contrasting results when I Normalize (Vs) Standardize variables. </p>
<p>Normalization = x -xmin/ xmax – xmin
Zero Score Standardization = x - xmean/ xstd
</p>
<pre><code>a) Also, when to Normalize (Vs) Standardize ?
b) How N... | 32,113,835 | 5 | 2 | null | 2015-08-20 01:32:29.85 UTC | 39 | 2022-02-10 11:18:00.097 UTC | 2015-08-20 16:23:00.883 UTC | null | 4,443,264 | null | 4,443,264 | null | 1 | 39 | machine-learning|linear-regression|feature-extraction | 56,005 | <p>Note that the results might not necessarily be so different. You might simply need different hyperparameters for the two options to give similar results.</p>
<p>The ideal thing is to test what works best for your problem. If you can't afford this for some reason, most algorithms will probably benefit from standardiz... |
56,622,926 | Safari Viewport Bug, Issues with Fixed Position and Bottom or Top | <p>I'm experiencing something strange in iOS 12.3.1 Safari. <strong>This issue dates back to at least iOS 12.2,</strong> but I imagine it's been a problem for much longer than that.</p>
<p>The issue manifests itself when trying to align an element to the bottom axis of the viewport, and is a problem in both portrait an... | 56,671,096 | 1 | 4 | null | 2019-06-16 22:01:18.273 UTC | 9 | 2019-06-21 03:15:22.703 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 7,543,162 | null | 1 | 33 | html|css|iphone|mobile|safari | 19,967 | <p>Hello this question kind of got me at first and I thought back to my days poking around in HTML and CSS for hours on end trying to get things right. Alas all those hours of missery have been for this moment. </p>
<p><code>vh</code> used to be calculated by the current viewport of your browser. If you loaded a site ... |
13,408,419 | How do I tell if Intent extras exist in Android? | <p>I have this code that checks for a value of an extra in an Intent on an Activity that is called from many places in my app:</p>
<pre><code>getIntent().getExtras().getBoolean("isNewItem")
</code></pre>
<p>If isNewItem isn't set, will my code crash? Is there any way to tell if it's been set or not before I call it?<... | 13,408,731 | 5 | 0 | null | 2012-11-16 00:05:52.873 UTC | 16 | 2018-01-31 19:05:22.14 UTC | 2012-11-16 01:01:07.18 UTC | null | 639,520 | null | 546,509 | null | 1 | 57 | java|android|android-intent | 65,113 | <p>As others have said, both <code>getIntent()</code> and <code>getExtras()</code> may return null. Because of this, you don't want to chain the calls together, otherwise you might end up calling <code>null.getBoolean("isNewItem");</code> which will throw a <code>NullPointerException</code> and cause your application t... |
13,265,153 | How do I import a CSV file in R? | <p>I have a <code>.csv</code> file in my workstation. How can I open that file in R and do statistical calculation?</p> | 13,265,177 | 1 | 1 | null | 2012-11-07 07:38:45.59 UTC | 10 | 2018-05-07 18:43:05.92 UTC | 2015-12-22 06:58:03.987 UTC | null | 1,079,354 | null | 1,758,521 | null | 1 | 118 | r|csv|import | 314,312 | <p>You would use the <code>read.csv</code> function; for example:</p>
<pre><code>dat = read.csv("spam.csv", header = TRUE)
</code></pre>
<p>You can also reference <a href="http://www.cyclismo.org/tutorial/R/input.html#read" rel="noreferrer">this tutorial</a> for more details.</p>
<p><strong>Note:</strong> make sure ... |
20,444,578 | Get current language with angular-translate | <p>Is there a way to get the current used language in a controller (without <code>$translateProvider</code>)?</p>
<p>Couldn't find anything in the <code>$translate</code> service.</p> | 20,445,143 | 9 | 2 | null | 2013-12-07 17:53:46.857 UTC | 19 | 2022-09-22 07:50:43.457 UTC | 2018-04-04 10:00:28.007 UTC | null | 1,423,874 | null | 1,641,422 | null | 1 | 86 | angularjs|angular-translate | 83,698 | <p><code>$translate.use()</code> is a getter and setter.</p>
<p>See this demo found in links of docs:</p>
<p><a href="http://jsfiddle.net/PascalPrecht/eUGWJ/7/" rel="noreferrer">http://jsfiddle.net/PascalPrecht/eUGWJ/7/</a></p> |
24,244,326 | Swift: Global constant naming convention? | <p>In Swift, it seems that global constants should be camelCase.</p>
<p>For example:</p>
<pre><code>let maximumNumberOfLoginAttempts = 10
</code></pre>
<p>Is that correct?</p>
<p>I'm used to all caps, e.g., <code>MAXIMUM_NUMBER_OF_LOGIN_ATTEMPTS</code>, from C, but I want to acquiesce to Swift conventions.</p> | 38,078,903 | 8 | 3 | null | 2014-06-16 12:58:02.513 UTC | 13 | 2022-04-22 02:01:33.43 UTC | null | null | null | null | 242,933 | null | 1 | 71 | naming-conventions|constants|swift|global | 29,996 | <p>Swift 3 API guidelines state that "Names of types and protocols are UpperCamelCase. Everything else is lowerCamelCase."</p>
<p><a href="https://swift.org/documentation/api-design-guidelines/" rel="nofollow noreferrer">https://swift.org/documentation/api-design-guidelines/</a></p>
<p>Ideally your global con... |
3,648,564 | python subclass access to class variable of parent | <p>I was surprised to to learn that a class variable of a subclass can't access a class variable of the parent without specifically indicating the class name of the parent:</p>
<pre><code>>>> class A(object):
... x = 0
...
>>> class B(A):
... y = x+1
...
Traceback (most recent call last):
... | 3,648,653 | 2 | 0 | null | 2010-09-06 01:34:42.243 UTC | 13 | 2010-09-06 02:28:09.34 UTC | null | null | null | null | 136,598 | null | 1 | 41 | python|subclass|class-variables | 42,004 | <p>In Python, the body of a class is executed in its own namespace before the class is created (after which, the members of that namespace become the members of the class). So when the interpreter reaches y = x+1, class B does not exist yet at that point and, therefore, has no parent.</p>
<p>For more details, see <a ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.