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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
39,494,473 | Is there any basis for this alternative 'for' loop syntax? | <p>I came across <a href="https://www.fefe.de/c++/c%2B%2B-talk.pdf" rel="noreferrer">a set of slides</a> for a <strike>rant</strike> talk on C++. There were some interesting tidbits here and there, but slide 8 stood out to me. Its contents were, approximately:</p>
<blockquote>
<h2>Ever-changing styles</h2>
<h3>Old and ... | 39,494,777 | 7 | 26 | null | 2016-09-14 15:35:11.113 UTC | 1 | 2016-09-15 14:19:21.617 UTC | 2020-06-20 09:12:55.06 UTC | user719662 | -1 | null | 3,580,294 | null | 1 | 45 | c++|for-loop | 4,345 | <ol>
<li><blockquote>
<p>Direct initialization using a constructor vs copy initialization</p>
</blockquote>
<p>These are exactly identical for <code>int</code>s and will generate identical code. Use whichever one you prefer to read or what your code policies are, etc.</p></li>
<li><blockquote>
<p><code>!=</code> c... |
21,660,249 | How do I make one particular line of a batch file a different color then the others? | <p>I'm working on a program which generates the day's weather for D&D games. I want the program to display a warning in red text when a storm is generated so the DM is aware that this weather is not typical. To reduce the number of keystrokes, it must do this on the same screen as the text detailing the weather its... | 21,666,354 | 4 | 10 | null | 2014-02-09 14:26:25.29 UTC | 7 | 2018-11-21 16:47:32.903 UTC | 2017-03-09 15:14:50.18 UTC | null | 1,033,581 | null | 2,195,713 | null | 1 | 16 | batch-file | 55,124 | <p>I was having the same problem yesterday, I did some research and <em>this</em> worked for me.
EDIT: This is <strong>NOT</strong> the same code as the other one.</p>
<pre><code>@Echo Off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do re... |
17,575,392 | How do I test for an empty string in a Bash case statement? | <p>I have a Bash script that performs actions based on the value of a variable. The general syntax of the case statement is:</p>
<pre><code>case ${command} in
start) do_start ;;
stop) do_stop ;;
config) do_config ;;
*) do_help ;;
esac
</code></pre>
<p>I'd like to execute a default routine if no co... | 17,575,693 | 3 | 1 | null | 2013-07-10 15:56:02.44 UTC | 11 | 2020-03-01 21:41:27.56 UTC | 2020-03-01 21:41:27.56 UTC | null | 6,862,601 | null | 770,123 | null | 1 | 102 | string|bash|null|case | 50,767 | <p>The <code>case</code> statement uses globs, not regexes, and insists on exact matches.</p>
<p>So the empty string is written, as usual, as <code>""</code> or <code>''</code>:</p>
<pre><code>case "$command" in
"") do_empty ;;
something) do_something ;;
prefix*) do_prefix ;;
*) do_other ;;
e... |
18,360,225 | elastic search, is it possible to update nested objects without updating the entire document? | <p>I'm indexing a set of documents (imagine them as forum posts) with a nested object which is the user related to that post. My problem is that the user fields might be updated, but since the posts do not change they are not reindexed and the user nested objects become outdated. Is there a way to update the nested obj... | 18,361,387 | 3 | 0 | null | 2013-08-21 14:29:40.757 UTC | 13 | 2022-04-28 18:29:39.823 UTC | 2016-12-13 09:05:55.387 UTC | null | 4,723,795 | null | 693,628 | null | 1 | 41 | elasticsearch | 40,788 | <p>You can use the Update API. </p>
<pre><code>curl -XPOST localhost:9200/docs/posts/post/_update -d '{
"script" : "ctx._source.nested_user = updated_nested_user",
"params" : {
"updated_nested_user" : {"field": "updated"}
}
}'
</code></pre>
<p>See this <a href="https://stackoverflow.com/questions/... |
18,684,579 | How do I change the highlight color for selected text with Emacs / deftheme? | <p>I'm using Emacs 24; I've installed the <strong>zenburn</strong> theme, which is great, except I cannot see the selection highlight easily with the highlight color provided by <strong>zenburn</strong>:</p>
<p><img src="https://i.stack.imgur.com/pZwnZ.png" alt="enter image description here"></p>
<p>By <strong>"selec... | 18,685,171 | 3 | 0 | null | 2013-09-08 14:03:48.857 UTC | 9 | 2017-01-24 22:32:28.507 UTC | 2013-09-08 14:09:07.677 UTC | null | 18,505 | null | 18,505 | null | 1 | 69 | emacs | 20,830 | <p>What you're looking for is the <code>region</code> face. For example:</p>
<pre><code>(set-face-attribute 'region nil :background "#666")
</code></pre> |
25,952,348 | Laravel: Run migrations on another database | <p>In my app every user has its own database that created when user registered. Connection and database data (database name, username, password) are saved in a table in default database.</p>
<pre><code>try{
DB::transaction(function() {
$website = new Website();
$website->user_id = Auth::get()-&... | 60,374,390 | 8 | 2 | null | 2014-09-20 19:08:13.703 UTC | 7 | 2020-02-24 10:55:00.713 UTC | 2014-09-21 17:36:02.27 UTC | null | 1,953,536 | null | 1,953,536 | null | 1 | 33 | laravel|laravel-4|database-migration|multi-tenant | 52,681 | <p>If you mean using different database connection, it exists in the docs:</p>
<pre><code>Schema::connection('foo')->create('users', function (Blueprint $table) {
$table->bigIncrements('id');
});
</code></pre> |
12,507,244 | How to check value length with using Javascript? | <p>Hello everyone I would like to ask how to check value's length from textbox ?</p>
<p>Here is my code :</p>
<pre><code>@*<script>
function validateForm() {
var x = document.forms["frm"]["txtCardNumber"].value;
if (x == null || x == "" ) {
alert("First name must be filled out");... | 12,507,258 | 2 | 0 | null | 2012-09-20 06:40:46.013 UTC | null | 2012-09-20 06:45:51.513 UTC | null | null | null | null | 1,682,416 | null | 1 | 3 | javascript | 46,084 | <p>You could use <code>x.length</code> to get the length of the string:</p>
<pre><code>if (x.length < 5) {
alert('please enter at least 5 characters');
return false;
}
</code></pre>
<p>Also I would recommend you using the <a href="https://developer.mozilla.org/en-US/docs/DOM/document.getElementById" rel="n... |
51,620,139 | ImportError: No module named 'flask_sqlalchemy' w/ 2 Versions of Python Installed | <p>Tried running a file with the following imports:</p>
<pre><code>from flask_sqlalchemy import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
</code></pre>
<p>Received the following error:</p>
<pre><code>ImportError: No module named 'flask_sqlalchemy'
</code>... | 60,438,611 | 14 | 19 | null | 2018-07-31 18:46:41.123 UTC | 1 | 2022-06-17 23:48:59.627 UTC | null | null | null | null | 3,828,443 | null | 1 | 8 | python|sqlalchemy|flask-sqlalchemy | 39,257 | <p>Ultimately, I resolved this issue ages after I posted the above question. </p>
<p>The fix was to run all package updates and installs thru Anaconda and do my work in Spyder. </p>
<p>The lesson learned was simple: Once you start using Anaconda as your go-to environment for all things Python, all updates -- made via... |
5,000,213 | How to Set the Checkbox on the right side of the text | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/3156781/how-to-show-android-checkbox-at-right-side">How to show android checkbox at right side?</a> </p>
</blockquote>
<p>In my android application, I have a checkbox and some text associate with it. By default... | 5,000,285 | 3 | 1 | null | 2011-02-15 05:31:40.47 UTC | 3 | 2015-09-14 10:06:37.8 UTC | 2017-05-23 10:27:45.9 UTC | null | -1 | null | 595,543 | null | 1 | 27 | android|checkbox | 47,316 | <p>I dont know whether it is possible or not by styling ,</p>
<p>But here is a solution for you</p>
<p>Use <code>""</code> as the value of the <code>CheckBox</code> ,then add a <code>TextView</code> to the left of the <code>CheckBox</code> with your desired text.</p> |
5,013,163 | How can I check/upgrade Proguard version when using it in Eclipse for Android development? | <p>The documentation on this is extremely poor. I understand that ProGuard can be enabled by manually editing "default.properties" in the project's rot directory. And all the settings go into the "proguard.cfg" file in the same place, but I'd like to know which version of ProGuard is being used (I'm using Eclise Indigo... | 5,023,215 | 3 | 0 | null | 2011-02-16 06:24:51.123 UTC | 10 | 2020-12-27 11:29:05.08 UTC | 2020-12-27 11:29:05.08 UTC | null | 1,127,485 | null | 496,854 | null | 1 | 32 | android|eclipse|obfuscation|proguard | 16,006 | <p>The ProGuard jar is located inside the Android SDK: android-sdk/tools/proguard/lib/proguard.jar</p>
<p>You can print out its version number with</p>
<pre><code>java -jar android-sdk/tools/proguard/lib/proguard.jar
</code></pre>
<p>(with the proper path). If necessary, you can <strong>replace the jar</strong> (act... |
5,116,296 | How to drop multiple databases in SQL Server | <p>Just to clarify, ths isn't really a question, more some help for people like me who were looking for an answer.<br>
A lot of applications create temp tables and the like, but I was surprised when Team Foundation Server created 80+ databases on my test SQL Server. TFS didn't install correctly, and kindly left me to c... | 8,791,560 | 3 | 1 | null | 2011-02-25 10:49:10.49 UTC | 11 | 2019-07-31 04:58:04.63 UTC | 2014-03-25 00:39:19.997 UTC | null | 881,229 | null | 419,426 | null | 1 | 33 | database|tsql|sql-drop | 41,844 | <p>this is easy...</p>
<pre><code>use master
go
declare @dbnames nvarchar(max)
declare @statement nvarchar(max)
set @dbnames = ''
set @statement = ''
select @dbnames = @dbnames + ',[' + name + ']' from sys.databases where name like 'name.of.db%'
if len(@dbnames) = 0
begin
print 'no databases to drop'
end
e... |
43,331,510 | How to train an SVM classifier on a satellite image using Python | <p>I am using <code>scikit-learn</code> library to perform a supervised classification (Support Vector Machine classifier) on a satellite image. My main issue is how to train my SVM classifier. I have watched many videos on youtube and have read a few tutorials on how to train an SVM model in <code>scikit-learn</code>.... | 43,453,194 | 2 | 4 | null | 2017-04-10 19:29:23.733 UTC | 10 | 2021-05-07 13:38:11.053 UTC | 2017-04-17 15:01:10.56 UTC | null | 6,160,119 | null | 7,133,523 | null | 1 | 4 | python|machine-learning|scikit-learn|svm|k-means | 6,937 | <p>Here's a complete example that should get you on the right track. For the sake of simplicity, let us assume that your goal is that of classifying the pixels on the three-band image below into three different categories, namely building, vegetation and water. Those categories will be displayed in red, green and blue ... |
43,388,893 | What is the difference between [ngFor] and [ngForOf] in angular2? | <p>As per my understanding, <em>Both are doing the same</em> functions. But,</p>
<ul>
<li><p><code>ngFor</code> would be works like as <a href="https://www.tutorialspoint.com/csharp/csharp_collections.htm" rel="noreferrer">collections</a>?.</p></li>
<li><p><code>ngForOf</code> would be works like as <a href="https://w... | 43,389,260 | 5 | 4 | null | 2017-04-13 09:47:34.547 UTC | 7 | 2020-01-04 11:35:57.377 UTC | 2019-10-09 08:48:05.597 UTC | null | 2,218,635 | null | 2,218,635 | null | 1 | 59 | angular|typescript|ngfor | 45,270 | <p><code>ngFor</code> and <code>ngForOf</code> are not two distinct things - they are actually the selectors of the NgForOf directive.</p>
<p>If you examine the <a href="https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_for_of.ts" rel="noreferrer">source</a>, you'll see that the NgForOf... |
18,583,881 | Changing Persistence Unit dynamically - JPA | <p>Persistence units in persistence.xml are created during building the application. As I want to change the database url at runtime, is there any way to modify the persistence unit at runtime? I supposed to use different database other than pre-binded one after distributed.</p>
<p>I'm using EclipseLink (JPA 2.1)</p> | 18,733,128 | 4 | 2 | null | 2013-09-03 04:01:48.933 UTC | 13 | 2020-08-13 13:20:11.12 UTC | null | null | null | null | 2,264,512 | null | 1 | 18 | java|jpa|persistence.xml | 19,080 | <p>Keep the persistence unit file (Persistence.xml) as it's. You can override the properties in it as follows.</p>
<pre><code>EntityManagerFactory managerFactory = null;
Map<String, String> persistenceMap = new HashMap<String, String>();
persistenceMap.put("javax.persistence.jdbc.url", "<url>");
per... |
18,683,421 | why do I get "Invalid appsecret_proof provided in the API argument" | <p>Since the latest change on Facebook, regarding the appsecret_proof: <a href="https://developers.facebook.com/docs/reference/api/securing-graph-api/">https://developers.facebook.com/docs/reference/api/securing-graph-api/</a>, we are still unable to download performance reports even after enabling/disabling features f... | 18,690,810 | 15 | 0 | null | 2013-09-08 11:58:03.46 UTC | 3 | 2021-07-29 10:12:08.067 UTC | 2013-09-08 12:45:33.127 UTC | null | 1,343,690 | null | 1,508,682 | null | 1 | 52 | facebook|facebook-graph-api|app-secret | 82,050 | <p>The error is (based on my experience) almost certainly correct; it means you're proving an invalid appsecret_proof with your API call</p>
<p>Assuming you're using the standard PHP SDK without modifications, the most likely reasons for this are:</p>
<ul>
<li>You configured the wrong app ID in the SDK code</li>
<li>... |
14,992,879 | Node.js mysql query syntax issues UPDATE WHERE | <p>I trying to update some info in MYSQL DB, but I'm not sure of how to do it with in node.js. This is the mysql driver I'm using <a href="https://github.com/felixge/node-mysql" rel="noreferrer">https://github.com/felixge/node-mysql</a></p>
<p>What I have so far</p>
<pre><code>connection.query('SELECT * FROM users WH... | 14,993,148 | 5 | 0 | null | 2013-02-21 01:03:32.587 UTC | 12 | 2021-04-16 02:59:44.173 UTC | 2017-09-15 08:59:20.387 UTC | null | 125,816 | null | 2,073,984 | null | 1 | 26 | mysql|node.js | 75,769 | <p>[<strong>Note (added 2016-04-29):</strong> This answer was accepted, but it turns out that there <em>is</em> a reasonable way to use <code>SET ?</code>. For details, see Bala Clark's answer on this same page. <em>—ruakh</em>]</p>
<hr>
<p>From <a href="https://github.com/felixge/node-mysql/blob/master/lib/Con... |
15,031,386 | How do I disable proguard for building my Android app? | <p>It used to be that proguard was controlled by project.properties, but that's no longer the case, and the Android documentation has not been updated. The project.properties file now clearly states that the it is generated by Android Tools and changes will be erased. I've tried commenting out the proguard.config line,... | 15,031,801 | 6 | 5 | null | 2013-02-22 19:03:51.673 UTC | 2 | 2022-05-17 11:01:37.733 UTC | 2013-02-22 19:24:00.02 UTC | null | 528,934 | null | 528,934 | null | 1 | 29 | android | 55,930 | <p>Try to delete the proguard directory in your project. So proguard will forget its mapping.</p> |
15,268,953 | How to install Python package from GitHub? | <p>I want to use a new feature of httpie. This feature is in the github repo <a href="https://github.com/jkbr/httpie" rel="noreferrer">https://github.com/jkbr/httpie</a> but not in the release on the python package index <a href="https://pypi.python.org/pypi/httpie" rel="noreferrer">https://pypi.python.org/pypi/httpie<... | 15,268,990 | 2 | 1 | null | 2013-03-07 10:39:33.68 UTC | 132 | 2021-09-16 23:37:30.927 UTC | null | null | null | null | 284,795 | null | 1 | 312 | python|pip | 426,477 | <p>You need to use the proper git URL:</p>
<pre><code>pip install git+https://github.com/jkbr/httpie.git#egg=httpie
</code></pre>
<p>Also see the <a href="https://pip.pypa.io/en/stable/topics/vcs-support/" rel="noreferrer"><em>VCS Support</em> section</a> of the pip documentation.</p>
<p>Don’t forget to include the <co... |
8,007,993 | In Android, check if sqlite database exists fails from time to time | <p>In Android I use the following method to see if the sqlite database exist and if I can open it and use it. </p>
<p>If it fail this test I copy the database file from the assets (this should only happen once, when the user first start the app).</p>
<pre><code>/*
* Check if the database already exist to avoid re-cop... | 8,011,264 | 2 | 1 | null | 2011-11-04 10:37:29.047 UTC | 10 | 2014-01-26 08:35:05.773 UTC | null | null | null | null | 611,494 | null | 1 | 8 | android|database|sqlite | 23,708 | <p>How about just checking the filesystem to see if the database exists instead of trying to open it first? </p>
<p>You could be trying to open a database that is already open and that will throw an error causing you to think it does not exist.</p>
<pre><code>File database=getApplicationContext().getDatabasePath("dat... |
9,200,268 | invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] | <pre><code>int :: cadena calculatelenght(const cadena& a, const char* cad)
{
cadena c;
int lenght = 0;
char* punt; punt = cad;
while(*punt){
lenght++; punt++;
}
return lenght;
}
</code></pre>
<p>I have this problem, I want to calculate the length of a C string without using functio... | 9,200,337 | 2 | 13 | null | 2012-02-08 19:42:17.91 UTC | 2 | 2012-11-23 00:38:24.07 UTC | 2012-02-08 21:27:47.34 UTC | null | 53,974 | null | 646,565 | null | 1 | 9 | c++|c|string | 60,852 | <p>You can declare <code>punt</code> to be of the correct type:</p>
<pre><code>const char * punt = cad;
</code></pre> |
8,708,632 | Passing Objects By Reference or Value in C# | <p>In C#, I have always thought that non-primitive variables were passed by reference and primitive values passed by value.</p>
<p>So when passing to a method any non-primitive object, anything done to the object in the method would effect the object being passed. (C# 101 stuff)</p>
<p>However, I have noticed that wh... | 8,708,674 | 9 | 3 | null | 2012-01-03 06:19:54.33 UTC | 112 | 2021-09-28 17:36:59.353 UTC | 2016-10-13 05:55:21.823 UTC | null | 661,933 | null | 902,012 | null | 1 | 308 | c#|parameter-passing|pass-by-reference|pass-by-value | 302,112 | <p><em>Objects</em> aren't passed at all. By default, the argument is evaluated and its <em>value</em> is passed, by value, as the initial value of the parameter of the method you're calling. Now the important point is that the value is a reference for reference types - a way of getting to an object (or null). Changes ... |
8,702,603 | Merging two objects in C# | <p>I have an object model <code>MyObject</code> with various properties. At one point, I have two instances of these <code>MyObject</code>: instance A and instance B. I'd like to copy and replace the properties in instance A with those of instance B if instance B has non-null values.</p>
<p>If I only had 1 class with 3... | 8,702,650 | 7 | 5 | null | 2012-01-02 15:36:19.54 UTC | 12 | 2022-09-12 22:44:44.607 UTC | 2022-09-12 22:44:44.607 UTC | null | 11,178,549 | null | 565,968 | null | 1 | 60 | c#|.net | 107,725 | <p><strong>Update</strong>
Use <a href="https://github.com/AutoMapper/AutoMapper" rel="noreferrer">AutoMapper</a> instead if you need to invoke this method a lot. Automapper builds dynamic methods using <code>Reflection.Emit</code> and will be much faster than reflection.'</p>
<p>You could copy the values of the prope... |
5,507,026 | before_filter with parameters | <p>I have a method that does something like this:</p>
<pre><code>before_filter :authenticate_rights, :only => [:show]
def authenticate_rights
project = Project.find(params[:id])
redirect_to signin_path unless project.hidden
end
</code></pre>
<p>I also want to use this method in some other Controllers, so i co... | 5,507,401 | 5 | 0 | null | 2011-03-31 22:17:50.233 UTC | 18 | 2016-05-18 05:40:58.663 UTC | 2015-11-07 15:01:29.69 UTC | null | 2,202,702 | null | 253,288 | null | 1 | 85 | ruby-on-rails|ruby|ruby-on-rails-3|before-filter | 44,493 | <p>I'd do it like this:</p>
<pre><code>before_filter { |c| c.authenticate_rights correct_id_here }
def authenticate_rights(project_id)
project = Project.find(project_id)
redirect_to signin_path unless project.hidden
end
</code></pre>
<p>Where <code>correct_id_here</code> is the relevant id to access a <code>Proj... |
5,300,047 | JPA TemporalType.Date giving wrong date | <p>I have a class that has a date field representing a "valid from" date for a piece of data. It is defined like this:</p>
<pre><code>@Temporal( TemporalType.DATE )
private Date validFrom;
</code></pre>
<p>All seems to be working fine right up the the point where I pull the date from the database and display it. If I... | 5,300,958 | 6 | 1 | null | 2011-03-14 14:36:52.83 UTC | 14 | 2020-06-29 11:14:32.533 UTC | null | null | null | null | 333,842 | null | 1 | 16 | java|mysql|jpa | 43,381 | <p>After much experimenting and searching I'm pretty sure I've found the cause of the problem. The date is held in a java.util.Date which comes with all the baggage of time and a timezone. It would seem that JPA is reading the date 18 Sep 2003 from the database and then populating the date like this: "Thu Sep 18 00:00:... |
5,418,856 | NuGet for solutions with multiple projects | <p>Suppose I have a solution with 3 projects:</p>
<ul>
<li>Core</li>
<li>UI</li>
<li>Tests</li>
</ul>
<p>Some of the NuGet packages I use will apply to all 3 projects. Some will just apply to UI and Tests, and some will just apply to Tests (like NUnit).</p>
<p>What is the <strong>right</strong> way to set this up us... | 8,653,312 | 6 | 0 | null | 2011-03-24 12:09:09.177 UTC | 40 | 2019-10-15 10:52:13.123 UTC | null | null | null | null | 57,132 | null | 1 | 158 | .net|nuget | 52,999 | <p>For anybody stumbling across this, now there is the following option :</p>
<blockquote>
<p>Right-click your solution > Manage NuGet Packages for Solution...</p>
</blockquote>
<p>... Or:</p>
<blockquote>
<p>Tools > Library Package Manager > Manage NuGet Packages for Solution...</p>
</blockquote>
<p>And if you... |
5,537,622 | Dynamically loading css file using javascript with callback without jQuery | <p>I am trying to load a css file dynamically using javascript and cannot use any other js library (eg jQuery).</p>
<p>The css file loads but I can't seem to get a callback to work for it. Below is the code I am using</p>
<pre><code>var callbackFunc = function(){
console.log('file loaded');
};
var head = doc... | 5,537,911 | 7 | 2 | null | 2011-04-04 11:09:52.58 UTC | 17 | 2020-10-14 14:44:44.56 UTC | 2011-04-04 11:26:35.077 UTC | null | 246,616 | null | 624,934 | null | 1 | 32 | javascript|css|callback|loading | 46,008 | <p>Unfortunately there is no onload support for stylesheets in most modern browsers. There is a solution I found with a little Googling.</p>
<p><strong>Cited from:</strong> <a href="http://thudjs.tumblr.com/post/637855087/stylesheet-onload-or-lack-thereof" rel="noreferrer">http://thudjs.tumblr.com/post/637855087/styl... |
5,060,465 | Get variables from the outside, inside a function in PHP | <p>I'm trying to figure out how I can use a variable that has been set outside a function, inside a function. Is there any way of doing this? I've tried to set the variable to "global" but it doesn't seems to work out as expected.</p>
<p>A simple example of my code</p>
<pre><code>$var = '1';
function() {
$var + ... | 5,060,486 | 8 | 1 | null | 2011-02-20 22:19:34.35 UTC | 6 | 2021-02-27 22:10:10.44 UTC | 2020-05-23 11:37:22.28 UTC | null | 2,332,721 | null | 621,855 | null | 1 | 37 | php|function|variables|global-variables | 84,816 | <p>You'll need to use the global keyword <em>inside</em> your function.
<a href="http://php.net/manual/en/language.variables.scope.php">http://php.net/manual/en/language.variables.scope.php</a></p>
<p><em>EDIT</em> (embarrassed I overlooked this, thanks to the commenters)</p>
<p>...and store the result somewhere</p>
... |
4,971,206 | select TOP (all) | <pre><code>declare @t int
set @t = 10
if (o = 'mmm') set @t = -1
select top(@t) * from table
</code></pre>
<p>What if I want generally it resulted with 10 rows, but rarely all of them.</p>
<p>I know I can do this through "SET ROWCOUNT". But is there some variable number, like -1, that causing TOP to result all elemen... | 4,971,263 | 9 | 0 | null | 2011-02-11 16:00:03.483 UTC | 5 | 2022-04-28 16:22:31.487 UTC | null | null | null | null | 40,789 | null | 1 | 28 | sql-server | 27,450 | <p>The largest possible value that can be passed to <code>TOP</code> is <code>9223372036854775807</code> so you could just pass that. </p>
<p>Below I use the binary form for max signed bigint as it is easier to remember as long as you know the basic pattern and that bigint is 8 bytes.</p>
<pre><code>declare @t bigint... |
5,596,484 | ASP.NET using Bind/Eval in .aspx in If statement | <p>in my .aspx I'm looking to add in an If statement based on a value coming from the bind. I have tried the following:</p>
<pre><code><% if(bool.Parse(Eval("IsLinkable") as string)){ %>
monkeys!!!!!!
(please be aware there will be no monkeys,
this is only for humour ... | 5,596,576 | 11 | 0 | null | 2011-04-08 14:21:20.53 UTC | 1 | 2019-11-19 12:02:03.563 UTC | null | null | null | null | 545,877 | null | 1 | 19 | c#|if-statement|eval|bind|webforms | 73,036 | <p>You need to add your logic to the <code>ItemDataBound</code> event of ListView. In the aspx you cannot have an if-statement in the context of a DataBinder: <code><%# if() %></code> doesn't work.</p>
<p>Have a look here: <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemda... |
16,627,441 | Excel VBA using FileSystemObject to list file last date modified | <p>this is my first time asking question so hopefully I'm following protocol.
This is in reference to "get list of subdirs in vba" <a href="https://stackoverflow.com/questions/9827715/get-list-of-subdirs-in-vba">get list of subdirs in vba</a>.</p>
<p>I found Brett's example #1 - Using FileScriptingObject most helpful.... | 16,627,924 | 1 | 2 | null | 2013-05-18 18:13:02.177 UTC | 2 | 2016-12-05 10:51:22.567 UTC | 2017-05-23 12:10:13.95 UTC | null | -1 | null | 2,397,403 | null | 1 | 4 | vba | 47,561 | <p>Try this code :</p>
<pre><code>Sub ListFilesinFolder()
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder
Dim FileItem As Scripting.File
SourceFolderName = "C:\Users\Santosh"
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName... |
29,465,096 | How to send an e-mail with C# through Gmail | <p>I am getting an error when trying to send an e-mail through my web service. I have tried enabling access to less secure apps disabling 2-step verification and logging into the account via a web browser. None of the solutions on SO have worked for me. I am still getting:</p>
<blockquote>
<p>Error: System.Net.Mail.... | 29,465,275 | 1 | 5 | null | 2015-04-06 03:50:36.32 UTC | 10 | 2017-01-14 10:33:02.86 UTC | 2015-04-06 22:31:02.457 UTC | null | 1,817,121 | null | 1,817,121 | null | 1 | 15 | c#|smtp|gmail|smtpclient | 48,718 | <p>Just Go here : <a href="https://www.google.com/settings/security/lesssecureapps">Less secure apps</a> , Log on using your Email and Password which use for sending mail in your c# code , and choose <code>Turn On</code>.</p>
<p>Also please go to this link and click on <strong>Continue</strong> <a href="https://accou... |
41,267,553 | Powershell - Test-Connection failed due to lack of resources | <p>Test-connection intermittently fails with a lack of resources error:</p>
<pre><code>test-connection : Testing connection to computer 'SOMESERVER' failed: Error due to lack of resources
At line:1 char:45
+ ... ($server in $ServersNonProd.Name) { test-connection $server -Count 1}
+ ... | 41,268,361 | 6 | 4 | null | 2016-12-21 16:30:47.357 UTC | 3 | 2021-11-01 19:34:38.503 UTC | null | null | null | null | 2,137,461 | null | 1 | 26 | powershell|ping | 48,568 | <p>In newer versions of PowerShell, the <code>-Quiet</code> parameter on <code>Test-Connection</code> does seem to always return either <code>True</code> or <code>False</code>. It didn't seem to work consistently on older versions, but either I'm doing something differently now or they've improved it:</p>
<pre><code>$P... |
12,589,758 | @font-face doesn't work | <p>I downloaded a font <code>inlove-light-wf.ttf</code>, in order to use the rule <code>@font-face</code>.</p>
<p>I have in my folder: <code>home.html</code> and <code>inlove-light-wf.ttf</code>.</p>
<p>In my CSS I have :</p>
<pre><code>@font-face {
font-family: 'Inlove';
src: url('inlove-light-wf.ttf');
... | 12,590,144 | 3 | 3 | null | 2012-09-25 19:26:33.713 UTC | 2 | 2015-06-23 21:58:24.27 UTC | 2012-12-24 20:28:28.24 UTC | null | 299,509 | null | 1,257,304 | null | 1 | 8 | css|font-face | 42,933 | <p>One source of the problem could be if your css is in a separate file that isn't in the root folder. For example, if you keep all of your css files in a 'css' folder, you'll need to modify the font url to be relative to that file, not to the root folder. In this example it would be <code>src: url('../inlove-light-w... |
12,291,199 | Example showing how to override TabExpansion2 in Windows PowerShell 3.0 | <p>Does anyone have an example showing how to override the TabExpansion2 function in Windows PowerShell 3.0? I know how to override the old TabExpansion function, but I want to provide a list of items for the intellisense in PowerShell ISE. I looked at the definition of TabExpansion2 and it wasn't easily understandab... | 13,326,286 | 2 | 0 | null | 2012-09-05 23:41:21.64 UTC | 10 | 2016-07-23 15:21:29.903 UTC | null | null | null | null | 45,459 | null | 1 | 17 | powershell|windows-8|powershell-3.0|tabexpansion | 2,783 | <p>I think this example should give you a good starting point: <a href="https://books.google.com/books?id=78w1953mptUC&lpg=PA56&ots=z0ssmJ1_RJ&dq=powershell%20cookbook%20tabexpansion2&pg=PA56#v=onepage&q=powershell%20cookbook%20tabexpansion2&f=false" rel="noreferrer">Windows Powershell Cookbook:... |
12,613,926 | SQLite query, 'LIKE' | <p>I am trying to retrieve information from my database.<br>
I have words like <code>Lim Won Mong</code> and <code>Limited</code>.</p>
<p>If I do my query, <code>SELECT name FROM memberdb WHERE name LIKE '%LIM%'</code>, it displays both <code>Lim Won Mong</code> and <code>Limited</code> and I only want data from <code... | 12,613,978 | 3 | 2 | null | 2012-09-27 04:06:12.2 UTC | 6 | 2013-12-07 05:04:33.107 UTC | 2013-12-07 05:04:33.107 UTC | null | 210,916 | null | 1,425,002 | null | 1 | 18 | sql|sqlite|sql-like | 52,312 | <p>Execute following Query:</p>
<pre><code>select name from memberdb where name like '% LIM %' OR name like "LIM %" OR name like "% LIM" OR name like "LIM"
</code></pre> |
12,053,627 | How can I stop Entity Framework 5 migrations adding dbo. into key names? | <p>I started a project using Entity Framework 4.3 Code First with manual migrations and SQL Express 2008 and recently updated to EF5 (in VS 2010) and noticed that now when I change something like a foreign key constraint, the migrations code adds the "dbo." to the start of the table name and hence the foreign key name ... | 12,060,958 | 4 | 1 | null | 2012-08-21 11:13:54.277 UTC | 11 | 2015-03-23 05:37:09.95 UTC | 2012-08-21 11:52:20.313 UTC | null | 625,113 | null | 625,113 | null | 1 | 30 | entity-framework|entity-framework-5 | 10,758 | <p>You can customize the generated code by sub-classing the <a href="http://msdn.microsoft.com/en-us/library/system.data.entity.migrations.design.csharpmigrationcodegenerator" rel="noreferrer"><code>CSharpMigrationCodeGenerator</code></a> class:</p>
<pre><code>class MyCodeGenerator : CSharpMigrationCodeGenerator
{
... |
12,087,905 | Pythonic way to sorting list of namedtuples by field name | <p>I want to sort a list of named tuples without having to remember the index of the fieldname. My solution seems rather awkward and was hoping someone would have a more elegant solution.</p>
<pre><code>from operator import itemgetter
from collections import namedtuple
Person = namedtuple('Person', 'name age score')
... | 12,087,992 | 5 | 2 | null | 2012-08-23 08:44:13.68 UTC | 12 | 2021-10-13 09:46:58.34 UTC | 2016-08-08 04:07:47.443 UTC | null | 1,219,006 | null | 1,619,135 | null | 1 | 80 | python|sorting|namedtuple|field-names | 33,345 | <pre><code>from operator import attrgetter
from collections import namedtuple
Person = namedtuple('Person', 'name age score')
seq = [Person(name='nick', age=23, score=100),
Person(name='bob', age=25, score=200)]
</code></pre>
<p>Sort list by name</p>
<pre><code>sorted(seq, key=attrgetter('name'))
</code></pre... |
12,050,393 | How to force the Y axis to only use integers in Matplotlib | <p>I'm plotting a histogram using the matplotlib.pyplot module and I am wondering how I can force the y-axis labels to only show integers (e.g. 0, 1, 2, 3 etc.) and not decimals (e.g. 0., 0.5, 1., 1.5, 2. etc.). </p>
<p>I'm looking at the guidance notes and suspect the answer lies somewhere around <a href="http://matp... | 12,051,323 | 3 | 1 | null | 2012-08-21 07:48:30.597 UTC | 16 | 2022-06-22 00:51:22.073 UTC | 2022-06-22 00:51:22.073 UTC | null | 7,758,804 | null | 1,191,626 | null | 1 | 117 | python|matplotlib|axis-labels | 142,123 | <p>If you have the y-data </p>
<pre><code>y = [0., 0.5, 1., 1.5, 2., 2.5]
</code></pre>
<p>You can use the maximum and minimum values of this data to create a list of natural numbers in this range. For example,</p>
<pre><code>import math
print range(math.floor(min(y)), math.ceil(max(y))+1)
</code></pre>
<p>yields</... |
12,384,704 | The Ruby %r{ } expression | <p>In a model there is a field</p>
<pre><code>validates :image_file_name, :format => { :with => %r{\.(gif|jpg|jpeg|png)$}i
</code></pre>
<p>It looks pretty odd for me. I am aware that this is a regular expression. But I would like:</p>
<ul>
<li>to know what exactly it means. Is <code>%r{value}</code> equal to <co... | 12,384,762 | 5 | 0 | null | 2012-09-12 09:06:27.447 UTC | 24 | 2022-08-10 19:32:40.413 UTC | 2022-08-10 19:32:40.413 UTC | null | 17,581,828 | null | 468,345 | null | 1 | 152 | ruby-on-rails|ruby | 61,615 | <p><code>%r{}</code> is equivalent to the <code>/.../</code> notation, but allows you to have '/' in your regexp without having to escape them:</p>
<pre><code>%r{/home/user}
</code></pre>
<p>is equivalent to:</p>
<pre><code>/\/home\/user/
</code></pre>
<p>This is only a syntax commodity, for legibility.</p>
<p>Edi... |
43,080,505 | c# 7.0: switch on System.Type | <p>No existing question has an answer to this question.</p>
<p>In c# 7, can I switch directly on a <code>System.Type</code>?</p>
<p>When I try:</p>
<pre><code> switch (Type)
{
case typeof(int):
break;
}
</code></pre>
<p>it tells me that <code>typeof(int)</code> needs to be a constant expression... | 43,080,709 | 10 | 15 | null | 2017-03-28 21:43:59.807 UTC | 11 | 2022-07-30 00:47:14.567 UTC | 2020-07-01 16:31:53.667 UTC | null | 1,045,881 | null | 1,045,881 | null | 1 | 87 | c# | 70,083 | <p>The (already linked) new pattern matching feature allows this.</p>
<p>Ordinarily, you'd switch on a value:</p>
<pre><code>switch (this.value) {
case int intValue:
this.value = Math.Max(Math.Min(intValue, Maximum), Minimum);
break;
case decimal decimalValue:
this.value = Math.Max(Math.Min(decimalVal... |
8,917,885 | Which version of Python do I have installed? | <p>I have to run a Python script on a Windows server. How can I know which version of Python I have, and does it even really matter?</p>
<p>I was thinking of updating to the latest version of Python.</p> | 8,917,907 | 27 | 6 | null | 2012-01-18 21:43:13.277 UTC | 68 | 2022-08-01 03:56:36.97 UTC | 2019-11-24 16:58:39.44 UTC | null | 63,550 | null | 275,510 | null | 1 | 543 | python|version|windows-server | 1,500,351 | <pre><code>python -V
</code></pre>
<p><a href="http://docs.python.org/using/cmdline.html#generic-options">http://docs.python.org/using/cmdline.html#generic-options</a></p>
<p><code>--version</code> may also work (introduced in version 2.5)</p> |
8,414,552 | Java: String - add character n-times | <p>Is there a simple way to add a character or another String n-times to an existing String?
I couldn’t find anything in <code>String</code>, <code>Stringbuilder</code>, etc.</p> | 47,451,056 | 15 | 7 | null | 2011-12-07 11:27:31.36 UTC | 3 | 2019-04-24 17:10:39.07 UTC | 2015-01-23 19:50:04.68 UTC | null | 905,686 | null | 905,686 | null | 1 | 44 | java|string | 157,846 | <p>You are able to do this using Java 8 stream APIs. The following code creates the string <code>"cccc"</code> from <code>"c"</code>:</p>
<pre><code>String s = "c";
int n = 4;
String sRepeated = IntStream.range(0, n).mapToObj(i -> s).collect(Collectors.joining(""));
</code></pre> |
8,840,319 | Build a tree from a flat array in PHP | <p>I've looked around the internet and haven't quite found what I'm looking for. I have a flat array with each element containing an 'id' and a 'parent_id'. Each element will only have ONE parent, but may have multiple children. If the parent_id = 0, it is considered a root level item. I'm trying to get my flat array i... | 8,841,921 | 14 | 8 | null | 2012-01-12 18:28:19.96 UTC | 23 | 2022-03-30 08:52:55.217 UTC | 2012-01-12 18:55:57.103 UTC | null | 467,362 | null | 467,362 | null | 1 | 55 | php|arrays|tree|flat | 68,839 | <p>You forgot the <code>unset()</code> in there bro.</p>
<pre><code>function buildTree(array &$elements, $parentId = 0) {
$branch = array();
foreach ($elements as $element) {
if ($element['parent_id'] == $parentId) {
$children = buildTree($elements, $element['id']);
if ($ch... |
11,201,262 | How to read data from a file in Lua | <p>I was wondering if there was a way to read data from a file or maybe just to see if it exists and return a <code>true</code> or <code>false</code></p>
<pre><code>function fileRead(Path,LineNumber)
--..Code...
return Data
end
</code></pre> | 11,204,889 | 4 | 1 | null | 2012-06-26 05:32:27.85 UTC | 12 | 2022-01-26 19:09:41.123 UTC | 2015-08-06 14:01:29.99 UTC | user1465457 | 1,009,479 | user1465457 | null | null | 1 | 43 | lua | 150,810 | <p>Try this:</p>
<pre><code>-- http://lua-users.org/wiki/FileInputOutput
-- see if the file exists
function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil
end
-- get all lines from a file, returns an empty
-- list/table if the file does not exist
function line... |
11,088,909 | Expire cache on require.js data-main | <p>I'm using require.js and r.js to package my AMD modules. I'm using jquery & requirejs via the following syntax:</p>
<pre><code><script data-main="/js/client" src="/js/external/require-jquery.js"></script>
</code></pre>
<p>This all works great pre & post packaging, but I run into issues a lot wh... | 11,724,555 | 2 | 1 | null | 2012-06-18 18:34:25.887 UTC | 14 | 2017-01-09 10:02:11.503 UTC | null | null | null | null | 77,011 | null | 1 | 43 | javascript|caching|requirejs|browser-cache|amd | 20,932 | <p>How are you defining your require.config? I think for it to take effect before you import require.js, you need to code it like this:</p>
<pre><code><script type="text/javascript">
var require = {
baseUrl: "/scripts/",
waitSeconds: 15,
urlArgs : "bust="+new Date().getTime()
};
&... |
13,115,053 | scala anonymous function missing parameter type error | <p>I wrote the following</p>
<pre><code>def mapFun[T, U](xs: List[T], f: T => U): List[U] = (xs foldRight List[U]())( f(_)::_ )
</code></pre>
<p>and when I did</p>
<pre><code>def f(x: Int):Int=x*x
mapFun(List(1,2,3), f)
</code></pre>
<p>It worked fine. However, I really wanted to make the following work too</p>
... | 13,115,105 | 2 | 0 | null | 2012-10-29 02:01:55.19 UTC | 4 | 2014-08-18 13:42:21.05 UTC | 2012-10-29 06:30:34.047 UTC | null | 745,188 | null | 534,617 | null | 1 | 28 | scala | 26,115 | <p>It seems to me that because "f" is in the same parameter list as "xs", you're required to give some information regarding the type of x so that the compiler can solve it.</p>
<p>In your case, this will work:</p>
<pre><code>mapFun(List(1,2,3) , (x: Int) => x * x)
</code></pre>
<p>Do you see how I'm informing ... |
13,004,226 | How to interact with leaflet marker layer from outside the map? | <p>I have a leaflet map showing points for public art pieces, rendered from <a href="http://geojson.org/" rel="noreferrer">GeoJSON</a>. Next to the map, I created a list of the pieces from the same <a href="http://geojson.org/" rel="noreferrer">GeoJSON</a> data and want to be able to click on an item from the list outs... | 13,012,714 | 2 | 1 | null | 2012-10-22 02:16:17.5 UTC | 22 | 2016-06-08 12:50:03.05 UTC | 2016-06-06 22:06:12.753 UTC | null | 128,421 | null | 340,648 | null | 1 | 30 | javascript|jquery|leaflet|geojson | 31,738 | <p>Felix Kling is right but I'll expand on his comment a little bit... </p>
<p>Since L.LayerGroup and L.FeatureGroup (which L.GeoJSON extends from) don't have methods to retrieve individual layers you will need to either extend from L.GeoJSON and add such a method or keep your own seperate mapping from unique ID to Ci... |
12,906,789 | Preventing an image from being draggable or selectable without using JS | <p>Does anyone know of a way to make an image not draggable and not selectable -- at the same time -- in Firefox, without resorting to Javascript? Seems trivial, but here's the issue:</p>
<ol>
<li><p>Can be dragged and highlighted in Firefox:</p>
</li>
<li><p>So we add this, but image can still be highlighted while d... | 12,906,840 | 10 | 3 | null | 2012-10-16 02:40:20.097 UTC | 65 | 2022-07-21 07:55:41.71 UTC | 2020-10-10 06:42:42.94 UTC | user7437719 | null | null | 1,741,860 | null | 1 | 176 | css|html|firefox|draggable | 199,911 | <p>Set the following CSS properties to the image:</p>
<pre class="lang-css prettyprint-override"><code>.selector {
user-drag: none;
-webkit-user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
</code></pre> |
16,970,803 | Correct naming structure for CodeIgniter | <p>I'm starting my 1st CodeIgniter project and want to get some advice before i start. I'm a little confused with how the name of the controller and models work.</p>
<p>If i want the url to my company page to be <a href="http://example.com/Company/view" rel="noreferrer">http://example.com/Company/view</a></p>
<p>the ... | 16,972,966 | 2 | 3 | null | 2013-06-06 19:42:29.593 UTC | 15 | 2018-04-05 02:06:33.463 UTC | 2018-04-05 02:06:33.463 UTC | null | 1,033,581 | null | 2,457,994 | null | 1 | 14 | codeigniter | 34,102 | <h3>URLs</h3>
<p>Your URLs should typically be all lowercase letters. If you expect capital letters, there's a chance you could accidentally exclude their lowercase counterparts, even though they're the same URL. Example: <code>www.example.com/controller/method/param</code></p>
<h3>Controllers</h3>
<p>Controller cla... |
17,070,101 | Why I cannot link the Mac framework file with CMake? | <p>I have a question related to CMake in MAC. I make sure that the executable program will link the framework and libraries correctly with the following codes:</p>
<pre><code>link_directories(directory_to_framework_and_libs)
add_executable(program ${FILE_LIST})
target_link_libraries(program framework_name lib1 lib2)
<... | 17,073,875 | 5 | 1 | null | 2013-06-12 15:59:05.563 UTC | 8 | 2022-03-27 23:11:44.747 UTC | null | null | null | null | 1,264,018 | null | 1 | 17 | cmake | 29,607 | <p>You can't link to a framework this way, you have to use <a href="https://cmake.org/cmake/help/latest/command/find_library.html" rel="noreferrer"><code>find_library</code></a> as it includes some special handling for frameworks on OSX.</p>
<p>Also, don't use <a href="https://cmake.org/cmake/help/latest/command/link_... |
16,961,021 | How to get span to take up the full height of the containing td | <p>I have a table, and in the left column I want to add an indicator for the row. I'm using a span to render the indicator, but I can't get the span to take up the full height:</p>
<pre><code><table>
<tr>
<td style="padding:0px;"><span style="height:100%; width:5px; background-color:pi... | 16,961,177 | 9 | 5 | null | 2013-06-06 11:32:01.293 UTC | 3 | 2021-09-17 03:41:15.697 UTC | null | null | null | null | 24,109 | null | 1 | 21 | html|css | 51,308 | <p>Should add overflow:auto to the span (and display:block of course)</p>
<pre><code><table>
<tr>
<td style="padding:0px;"><span style="height:100%; width:5px; background-color:pink;display:block;overflow:auto">&nbsp;</span></td>
<td>Some content</td>
... |
16,725,392 | Share a single service between multiple angular.js apps | <p>I'm building an ecommerce site (based on shopify) and I'm using multiple small angularjs apps to handle things such as a quick shopping cart, wishlists, filtering products and a few other smaller items. I initially used one big application (that had routing and everything), but it was a bit to restrictive when I did... | 16,725,874 | 2 | 0 | null | 2013-05-23 23:13:14.44 UTC | 16 | 2014-09-05 10:10:24.197 UTC | null | null | null | null | 334,133 | null | 1 | 34 | javascript|angularjs | 18,966 | <p>The <code>sharedService</code> is being shared, but one angular app doesn't know that something updated in the other app so it doesn't kick off a <code>$digest</code>. You have to manually tell the <code>$rootScope</code> of each application to start a <code>$digest</code> by calling <code>$rootscope.$apply()</code>... |
16,768,930 | Implementations of Emoji (Emoticon) View/Keyboard Layouts | <p>I am trying to figure out how the emoji (emoticon) selections are implemented on the <code>Facebook</code> app and the Google <code>Hangouts</code> app. I looked into the <code>SoftKeyboard</code> Demo app in the Android API Samples but the display of these emoji views does not look like a <code>SoftKeyboard</code>... | 17,014,940 | 6 | 2 | null | 2013-05-27 08:12:58.537 UTC | 47 | 2018-07-11 21:05:07.283 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 502,671 | null | 1 | 61 | android|android-softkeyboard|emoji|emoticons | 96,074 | <p>I found a very useful <a href="https://github.com/chiragjain/Emoticons-Keyboard" rel="noreferrer">Emoticon Keyboard</a>. This keyboard is not using Unicode sequences but rather just local image assets. I am thinking that this type of keyboard can only be useful within this app and not with other apps or Operating Sy... |
20,502,860 | Scroll View not functioning IOS 7 | <p>I have a scrollview inside which i have 20 UItextviews. The scrollview is not working. I have set the following in viewdidload.</p>
<pre><code>self.MainScroll.contentSize = CGSizeMake(320, 1800);
</code></pre>
<p>Still it doesn't scroll. However, if i give bounce vertically, it just bounces. My scrollview is a chil... | 20,503,513 | 2 | 8 | null | 2013-12-10 18:51:18.94 UTC | 26 | 2017-06-28 15:23:26.7 UTC | 2020-06-20 09:12:55.06 UTC | null | -1 | null | 2,150,969 | null | 1 | 28 | iphone|uiscrollview|ios7 | 21,991 | <p>There are two ways you can get the scrolling to work.</p>
<p><strong>Approach 1 (with code):</strong></p>
<p>1) Pin <code>UIScrollView</code> to the sides of its parent view, as mentioned below.</p>
<p><img src="https://i.stack.imgur.com/ugYxG.png" alt="enter image description here"></p>
<p>2) Set content size o... |
25,787,555 | LINQ performance Count vs Where and Count | <pre><code>public class Group
{
public string Name { get; set; }
}
</code></pre>
<p>Test: </p>
<pre><code>List<Group> _groups = new List<Group>();
for (int i = 0; i < 10000; i++)
{
var group = new Group();
group.Name = i + "asdasdasd";
_groups.Add(group);
}
Stopwatch _stopwatch2 ... | 25,789,631 | 6 | 14 | null | 2014-09-11 12:32:29.56 UTC | 10 | 2014-09-12 08:42:55.643 UTC | 2014-09-12 08:42:43.81 UTC | null | 1,411,104 | null | 1,411,104 | null | 1 | 36 | c#|linq | 6,176 | <p>The crucial thing is in the implementation of <code>Where()</code> where it casts the <code>IEnumerable</code> to a <code>List<T></code> if it can. Note the cast where <code>WhereListIterator</code> is constructed (this is from .Net source code obtained via reflection):</p>
<pre><code>public static IEnumerabl... |
63,067,555 | How to make an import shortcut/alias in create-react-app? | <p>How to set import shortcuts/aliases in create-react-app?
From this:</p>
<pre><code>import { Layout } from '../../Components/Layout'
</code></pre>
<p>to this:</p>
<pre><code>import { Layout } from '@Components/Layout'
</code></pre>
<p>I have a <code>webpack</code> 4.42.0 version.
I don't have a webpack.config.js file... | 63,068,531 | 5 | 5 | null | 2020-07-24 05:46:03.943 UTC | 13 | 2022-09-08 05:46:25.163 UTC | 2020-07-24 07:10:17.083 UTC | null | 7,882,470 | null | 12,355,067 | null | 1 | 57 | javascript|reactjs|webpack|alias|create-react-app | 57,093 | <h2>NOTE FOR CONFUSING TERMS</h2>
<pre><code>// Absolute path: paths which are relative to a specific path
import Input from 'components' // src/components
import UsersUtils from 'page/users/utils' // src/page/users/utils
// Alias path: other naming to specific path
import Input from '@components' // src/components
im... |
41,351,739 | main.jsbundle, Foundation and Security missing in the project, causing error | <p>I've noticed that file <code>main.jsbundle</code> file is missing from the project and am not sure of how to fix it, should I delete the file / is there a step I can perform to fix it?</p>
<p>Here is a screenshot of where it is in the project:</p>
<p><a href="https://i.stack.imgur.com/5RKO0.png" rel="noreferrer"><... | 41,444,682 | 4 | 7 | null | 2016-12-27 20:22:35.67 UTC | 10 | 2018-11-29 11:46:59.383 UTC | null | null | null | null | 911,930 | null | 1 | 16 | javascript|ios|xcode|reactjs|react-native | 12,983 | <p>The problem can be resolved as follows</p>
<ul>
<li>By using the <code>react native</code> command line</li>
<li><code>$ react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundle</code> using this in the <em>root of the react native project</em></li>
<li>When the <code>main.js... |
9,716,779 | How to Read a TXT file in Java Server Page Directory | <p>I'd like to create an app that requires to read a <code>.txt</code> file on my project directory. </p>
<p>This is my code of my <code>index.jsp</code>: </p>
<pre><code><%@page import="java.io.FileReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page contentType="text/html" pageEncoding="UTF-8"... | 9,716,945 | 5 | 0 | null | 2012-03-15 09:13:48.923 UTC | null | 2017-02-08 03:24:26.23 UTC | 2014-12-20 20:03:28.507 UTC | user1733583 | 4,818,540 | null | 1,052,070 | null | 1 | 5 | java|jsp|web | 49,651 | <p>Try to locate it from application's root path.</p>
<p><a href="http://www.java2s.com/Code/Java/JSP/ReadingBinaryData.htm" rel="nofollow">http://www.java2s.com/Code/Java/JSP/ReadingBinaryData.htm</a></p> |
10,038,673 | Using Eclipse with Play Framework 2.0 | <p>I am new to Framework 2.0. In Play 1.0, after you Eclipsify your project, you have have a *.launch file that you can use to launch your project.</p>
<p>After you eclipsify in Play 2.0, you don't seem to have anything similar. Is there a way to control your launching and to debug Play 2.0, using Eclipse?</p>
<p>A... | 10,040,676 | 1 | 0 | null | 2012-04-06 03:09:21.043 UTC | 8 | 2012-04-06 07:49:14.19 UTC | 2017-05-23 12:29:34.01 UTC | null | -1 | null | 953,068 | null | 1 | 11 | eclipse|playframework-2.0 | 14,948 | <p>Question 1:</p>
<p>After you have eclipsified, open Eclipse and choose <code>File -> Import... -> Existing Projects into Workspace</code>. A dialog will open, choose your Play Framework 2.0 project folder and click <code>Finish</code>.</p>
<p>Question 2:</p>
<ol>
<li><p>Start your Play Framework application... |
10,095,225 | Tracking Individual Users with Google Analytics Custom Variables | <p>I've been working on a support center for my company and we need to track individual users when they login. If possible we would like to track details as well such as pages visited and time spent on the site as well.
I'm able to track how many people login to the site using a custom variable, but I am unable to trac... | 10,097,412 | 5 | 0 | null | 2012-04-10 19:35:04.973 UTC | 8 | 2014-08-16 08:55:10.177 UTC | 2012-10-02 10:43:23.27 UTC | null | 140,938 | null | 1,324,805 | null | 1 | 22 | google-analytics|userid | 20,390 | <p>That is a violation of <a href="http://www.google.com/analytics/tos.html" rel="noreferrer">Google Analytics terms of service</a>. See number 7 PRIVACY.</p>
<blockquote>
<p>7.PRIVACY . You will not (and will not allow any third party to) use the Service to track or collect personally identifiable information of In... |
10,109,788 | Callback after the DOM was updated in Meteor.js | <p>I have this Meteor project: <a href="https://github.com/jfahrenkrug/code_buddy" rel="noreferrer">https://github.com/jfahrenkrug/code_buddy</a> </p>
<p>It's basically a tool with a big textarea and a pre area that lets you enter source code snippets that automatically get pushed to all connected clients. </p>
<p>I'... | 10,119,993 | 9 | 0 | null | 2012-04-11 16:10:44.95 UTC | 19 | 2016-01-19 16:03:10.28 UTC | null | null | null | null | 171,933 | null | 1 | 35 | meteor | 14,388 | <p>A hacky way to do it is:</p>
<p><strong>foo.html</strong></p>
<pre><code><template name="mytemplate">
<div id="my-magic-div">
.. stuff goes here ..
{{add_my_special_behavior}}
</div>
</template>
</code></pre>
<p><strong>foo.js</strong></p>
<pre><code>Template.mytemplate.add_my... |
9,799,074 | How to make ReSharper re-evaluate its assembly reference highlighting | <p>I am creating a Prism Project Template, and the template works great. But after I create a project with the template some of the files look like this:</p>
<p><img src="https://i.stack.imgur.com/p10Pt.png" alt="Bad References"></p>
<p><strong>Despite appearances, everything is just fine.</strong></p>
<p>If I do a ... | 17,806,179 | 15 | 7 | null | 2012-03-21 05:29:45.7 UTC | 53 | 2019-04-12 17:05:54.363 UTC | 2017-05-23 12:26:32.747 UTC | null | -1 | null | 16,241 | null | 1 | 189 | visual-studio|visual-studio-2010|resharper|project-template|visual-studio-extensions | 46,910 | <p>Except for reinstalling, the only way to successfully clear the caches is to delete the files manually from your AppData directory.</p>
<p>Delete the solution folder that's giving you grief in the following locations:</p>
<blockquote>
<ul>
<li><code>%LOCALAPPDATA%\JetBrains\ReSharper\v7.1\SolutionCaches\</code... |
7,935,603 | C++ - pointer being freed was not allocated error | <pre><code>malloc: *** error for object 0x10ee008c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
</code></pre>
<p>Or I get this when I try and print everything</p>
<pre><code>Segmentation fault: 11
</code></pre>
<p>I'm doing some homework for an OOP class a... | 7,935,879 | 3 | 5 | null | 2011-10-28 22:39:54.53 UTC | 2 | 2011-10-28 23:27:12.597 UTC | null | null | null | null | 871,111 | null | 1 | 10 | c++|input|cin | 38,445 | <p>Welcome to the exciting world of C++!</p>
<p>Short answer: you're passing Store as a value. All your menu functions should take a Store& or Store* instead.</p>
<p>When you're passing Store as a value then an implicit copy is done (so the mainStore variable is never actually modified). When you return from the ... |
11,523,765 | How well does the Android NFC API support Mifare Desfire? | <p>I'm likely to be working on a project where existing Desfire cards (used to access paid services) will be replaced with an NFC-capable mobile device. Can anyone point me to any resources to help me understand what's involved in a) replicating a Desfire card's data onto a mobile device so it can take the place of a c... | 11,524,507 | 4 | 0 | null | 2012-07-17 13:40:52.857 UTC | 16 | 2015-04-08 16:18:14.673 UTC | 2012-07-17 14:36:52.547 UTC | null | 1,202,968 | null | 477,415 | null | 1 | 8 | android|nfc|mifare | 23,520 | <p>MIFARE DESFire is ISO 14443-4 compliant. Support in Android for ISO 14443-4 (and therefore MIFARE DESFire) is done by the <a href="http://developer.android.com/reference/android/nfc/tech/IsoDep.html"><code>IsoDep</code></a> class. You can send any DESFire command using the <code>transceive()</code> method of that cl... |
11,592,015 | Support for target-densitydpi is removed from WebKit | <p>According to this <a href="https://bugs.webkit.org/show_bug.cgi?id=88047">https://bugs.webkit.org/show_bug.cgi?id=88047</a> WebKit dropped the support for target-densitydpi from viewport params. Unfortunately, the bug description states neither the motivation for the change, nor the workaround. </p>
<p>Certain web-... | 13,364,025 | 4 | 0 | null | 2012-07-21 12:04:58.34 UTC | 21 | 2022-06-09 23:31:54.553 UTC | null | null | null | null | 244,888 | null | 1 | 29 | google-chrome|webkit | 51,095 | <p>The webkit-dev mailing list thread <a href="http://lists.webkit.org/pipermail/webkit-dev/2012-May/020847.html" rel="nofollow noreferrer">http://lists.webkit.org/pipermail/webkit-dev/2012-May/020847.html</a> contains a discussion (or at least the background) of the feature removal.</p>
<p>In short, WebKit had a few ... |
11,475,885 | python .replace() regex | <p>I am trying to do a grab everything after the <code>'</html>'</code> tag and delete it, but my code doesn't seem to be doing anything. Does <code>.replace()</code> not support regex?</p>
<pre><code>z.write(article.replace('</html>.+', '</html>'))
</code></pre> | 11,475,905 | 4 | 4 | null | 2012-07-13 18:03:50.237 UTC | 53 | 2021-01-03 17:08:41.473 UTC | 2021-01-03 17:08:41.473 UTC | null | 4,100,225 | null | 1,442,957 | null | 1 | 409 | python|regex | 715,021 | <p>No. Regular expressions in Python are handled by the <a href="http://docs.python.org/library/re.html" rel="noreferrer"><code>re</code></a> module.</p>
<pre><code>article = re.sub(r'(?is)</html>.+', '</html>', article)
</code></pre>
<p>In general:</p>
<pre><code>text_after = re.sub(regex_search_term, rege... |
20,268,477 | IIS Express - increase memory limit | <p>I have a VS project in .NET MVC5 which loads an external dll file that uses a lot of memory. In average it uses from 500-1000MB memory.</p>
<p>Now when I try to debug my project with default IIS Express server I almost always get OutOfMemory exception.</p>
<p>I know that there is a /3gb flag for normal IIS but wha... | 35,814,763 | 2 | 6 | null | 2013-11-28 14:21:09.563 UTC | 5 | 2019-10-26 12:23:28.583 UTC | 2019-10-26 12:23:28.583 UTC | null | 2,581,562 | null | 310,080 | null | 1 | 38 | c#|asp.net|visual-studio|iis|iis-express | 18,120 | <p>Go to Visual Studio - Tools - Options Menu</p>
<p>Choose: - Projects and Solutions, then Web Projects</p>
<p>tick the checkbox: "User the 64 bit version of IIS Express for web sites and projects"</p>
<p>No Registry edit necessary.</p> |
20,354,083 | EF6 and multiple configurations (SQL Server and SQL Server Compact) | <p><strong>Update:</strong> Problem solved, see end of this question.</p>
<p><strong>The problem</strong>:</p>
<p>We are trying to use Entity Framework 6 and code-based configuration in a scenario were we have use both a SQL Server and SQL Server CE in the same <code>AppDomain</code>.</p>
<p>This quite simple scenar... | 20,354,462 | 3 | 10 | null | 2013-12-03 14:39:20.04 UTC | 11 | 2017-03-21 16:31:45.55 UTC | 2013-12-03 17:14:18.073 UTC | null | 259,205 | null | 259,205 | null | 1 | 23 | c#|entity-framework|configuration|entity-framework-6 | 21,305 | <p>EDIT: based On Error details:
Did you already try tell EF where the config class is found?</p>
<pre><code>[DbConfigurationType("MyNamespace.MyDbConfiguration, MyAssemblyFullyQualifiedName")]
public class MyContextContext : DbContext
{
}
</code></pre>
<p>If that cant be made work, then see alternative</p>
<p>Use t... |
61,306,802 | Lombok getter/setter vs Java 14 record | <p>I love project <a href="https://projectlombok.org/" rel="noreferrer">Lombok</a> but in these days I'm reading and trying some of the new features of java 14.</p>
<p>Inside the new capability, there is the <a href="https://openjdk.java.net/jeps/359" rel="noreferrer">record</a> keyword that allows creating a class wit... | 61,325,018 | 6 | 4 | null | 2020-04-19 15:20:51.567 UTC | 7 | 2022-02-14 15:25:40.49 UTC | 2021-07-03 12:10:04.267 UTC | null | 5,945,360 | null | 5,945,360 | null | 1 | 61 | java|getter|lombok|java-14|java-record | 16,203 | <p>Lombok, and the <code>record</code> feature of the Java language, are different tools for different things. There is some superficial overlap, but don't let that distract you.</p>
<p>Lombok is largely about <em>syntactic</em> convenience; it is a macro-processor pre-loaded with some known useful patterns of code. ... |
3,754,180 | adding a column description | <p>Does anyone know how to add a description to a SQL Server column by running a script? I know you can add a description when you create the column using SQL Server Management Studio.</p>
<p>How can I script this so when my SQL scripts create the column, a description for the column is also added?</p> | 3,754,214 | 4 | 2 | null | 2010-09-20 18:11:52.923 UTC | 13 | 2020-06-17 12:59:01.07 UTC | 2010-09-20 18:35:47.353 UTC | null | 23,199 | null | 444,443 | null | 1 | 59 | sql|sql-server|sql-server-2005 | 70,253 | <p>I'd say you will probably want to do it using the <a href="https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addextendedproperty-transact-sql?view=sql-server-ver15" rel="noreferrer">sp_addextendedproperty</a> stored proc.</p>
<p>Microsoft has some good documentation on it.</p>
<... |
3,242,873 | Grep for literal strings | <p>I'm after a grep-type tool to search for purely literal strings. I'm looking for the occurrence of a line of a log file, as part of a line in a seperate log file. The search text can contain all sorts of regex special characters, e.g., <code>[]().*^$-\</code>.</p>
<p>Is there a Unix search utility which would not... | 3,242,906 | 5 | 1 | null | 2010-07-14 02:01:29.43 UTC | 14 | 2016-03-09 11:14:17.867 UTC | 2010-07-14 02:23:35.633 UTC | null | 14,860 | null | 26,633 | null | 1 | 122 | unix|grep | 59,203 | <p>You can use grep for that, with the -F option.</p>
<pre><code>-F, --fixed-strings PATTERN is a set of newline-separated fixed strings
</code></pre> |
3,877,907 | time format in SQL Server | <p>Does anyone know how can I format a select statement datetime value to only display time in SQL Server?</p>
<p>example:</p>
<pre><code>Table cuatomer
id name datetime
1 Alvin 2010-10-15 15:12:54:00
2 Ken 2010-10-08 09:23:56:00
</code></pre>
<p>When I select the table I like the result will display a... | 3,877,918 | 7 | 1 | null | 2010-10-07 00:36:02.843 UTC | null | 2020-04-12 12:01:15.28 UTC | 2010-10-07 01:41:35.43 UTC | null | 334,849 | null | 52,745 | null | 1 | 12 | sql-server|tsql|time | 78,301 | <p>You can use a combination of CONVERT, RIGHT and TRIM to get the desired result:</p>
<pre><code>SELECT ltrim(right(convert(varchar(25), getdate(), 100), 7))
</code></pre>
<p>The <code>100</code> you see in the function specifies the date format <code>mon dd yyyy hh:miAM (or PM)</code>, and from there we just grab t... |
3,998,483 | Objective-C Category Causing unrecognized selector | <p>My project has a <code>UIImage</code> category function that I want to call from another class. I properly import the header file for the image category and I get the project to compile with no warning.</p>
<p>The problem is that when I call the <code>UIImage</code> category function I seen an unrecognized selector... | 3,998,700 | 8 | 5 | null | 2010-10-22 15:41:05.453 UTC | 15 | 2021-08-09 08:20:05.417 UTC | 2017-08-15 10:45:44.607 UTC | null | 3,908,884 | null | 157,894 | null | 1 | 69 | iphone|objective-c|cocoa|categories | 26,862 | <p>A couple possibilities:</p>
<ol>
<li>You did not link <code>UIImage+TTShare.m</code> into your target. So while you have the header, you're not compiling the implementation.</li>
<li>If this is part of a static library, you need to add <code>-all_load</code> to the <strong>Other Linker Flags</strong> build setting... |
3,599,413 | Is there a more elegant way to add nullable ints? | <p>I need to add numerous variables of type nullable int. I used the null coalescing operator to get it down to one variable per line, but I have a feeling there is a more concise way to do this, e.g. can't I chain these statements together somehow, I've seen that before in other code.</p>
<pre><code>using System;
na... | 3,599,500 | 9 | 1 | null | 2010-08-30 10:06:03.337 UTC | 2 | 2020-11-18 21:17:04.217 UTC | null | null | null | null | 4,639 | null | 1 | 43 | c#|nullable|null-coalescing-operator | 22,141 | <pre><code>var nums = new int?[] {1, null, 3};
var total = nums.Sum();
</code></pre>
<p>This relies on the <a href="http://msdn.microsoft.com/en-us/library/bb156065.aspx" rel="noreferrer"><code>IEnumerable<Nullable<Int32>></code>overload </a> of the <a href="http://msdn.microsoft.com/en-us/library/bb345537... |
3,814,145 | How can I declare a two dimensional string array? | <pre><code>string[][] Tablero = new string[3][3];
</code></pre>
<p>I need to have a 3x3 array arrangement to save information to. How do I declare this in C#?</p> | 3,814,164 | 12 | 3 | null | 2010-09-28 15:05:57.37 UTC | 10 | 2021-11-12 15:45:56.003 UTC | 2019-10-03 04:29:27.37 UTC | user12031933 | null | delete | null | null | 1 | 85 | c#|arrays|multidimensional-array|jagged-arrays|array-initialization | 268,742 | <pre><code>string[,] Tablero = new string[3,3];
</code></pre>
<p>You can also instantiate it in the same line with array initializer syntax as follows:</p>
<pre><code>string[,] Tablero = new string[3, 3] {{"a","b","c"},
{"d","e","f"},
{"g","... |
8,332,222 | How to programmatically add a Drop down list in asp.net with specific pre-selected item | <p>I've worked out how to create a DropDownList using the following code:</p>
<pre><code><select id="salesPersonDropList" runat="server"></select>
</code></pre>
<p>In my .aspx page, then my code behind loops through database output running:</p>
<pre><code>Dim newListItem As ListItem
newListItem = New Lis... | 8,332,283 | 4 | 0 | null | 2011-11-30 20:03:01.423 UTC | 2 | 2021-06-23 15:25:04.35 UTC | null | null | null | null | 956,482 | null | 1 | 5 | asp.net|vb.net|drop-down-menu | 61,397 | <p>Set your <code>Selected</code> property of the <code>ListItem</code> to true:</p>
<pre><code>Dim newListItem As ListItem
newListItem = New ListItem("Title", "Value")
newListItem.Selected = True
salesPersonDropList.Items.Add(newListItem )
</code></pre> |
7,767,427 | How to compare hex values using C? | <p>I am working with hex values. Until now I know how to print hex values and also precision thing. Now I want to compare the hex values. For example I am reading data from a file into a char buffer. Now I want to compare the hex value of data in the buffer. Is there anything like this?</p>
<pre><code>if hex(buffer[i... | 7,767,450 | 5 | 0 | null | 2011-10-14 12:16:16.743 UTC | 1 | 2018-01-17 00:41:49.623 UTC | 2011-10-14 13:05:40.903 UTC | null | 287,954 | null | 621,510 | null | 1 | 8 | c|hex | 49,748 | <p>You're nearly there:</p>
<pre><code>if (buffer[i] > 0x3f)
{
// do something
}
</code></pre>
<p>Note that there is no need to "convert" anything to hex - you can just compare character or integer values directly, since a hex constant such as 0x3f is just another way of representing an integer value. 0x3f == ... |
7,976,646 | PowerShell: Store Entire Text File Contents in Variable | <p>I'd like to use PowerShell to store the <em>entire</em> contents of a text file (including the trailing blank line that may or may not exist) in a variable. I'd also like to know the total number of lines in the text file. What's the most efficient way to do this?</p> | 7,976,784 | 5 | 0 | null | 2011-11-02 06:42:20.37 UTC | 18 | 2016-04-18 22:17:31.79 UTC | 2016-01-08 00:57:11.707 UTC | null | 503,969 | null | 937,084 | null | 1 | 148 | powershell | 217,085 | <p>To get the entire contents of a file:</p>
<pre><code>$content = [IO.File]::ReadAllText(".\test.txt")
</code></pre>
<p>Number of lines:</p>
<pre><code>([IO.File]::ReadAllLines(".\test.txt")).length
</code></pre>
<p>or</p>
<pre><code>(gc .\test.ps1).length
</code></pre>
<p>Sort of hackish to include trailing emp... |
8,101,532 | Android: Set margins in a FrameLayout programmatically- not working | <p>here is the code-</p>
<pre><code>FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) searchPin.getLayoutParams();
params.setMargins(135, 176, 0, 0);
//params.leftMargin = 135; // also not worked
//params.topMargin = 376;
searchPin.setLayoutParams(params);
</code></pre>
<p>Where ever, from xml its working... | 11,348,168 | 6 | 1 | null | 2011-11-12 00:32:56.8 UTC | 4 | 2014-01-21 13:42:55.86 UTC | null | null | null | null | 515,976 | null | 1 | 20 | android|android-layout|android-framelayout | 45,833 | <p>Try this:</p>
<pre><code>params.gravity = Gravity.TOP;
</code></pre> |
8,018,118 | Cross-origin image load denied with three.js in chrome | <p>Trying to add material in <code>THREE.js</code> like this</p>
<pre><code>var materialWall = new materialClass( { color: 0xffffff, map: THREE.ImageUtils.loadTexture( 'images/a.png' ) } );
</code></pre>
<p>It works fine in Chrome, IE, FF, until 3 days ago, after Chrome updated itself to the latest dev version 17.</p... | 8,019,408 | 7 | 0 | null | 2011-11-05 04:04:57.88 UTC | 3 | 2018-05-24 07:47:53.297 UTC | 2018-05-24 07:47:53.297 UTC | null | 991,295 | null | 991,295 | null | 1 | 20 | javascript|google-chrome|cross-domain|three.js | 45,283 | <p><a href="https://github.com/mrdoob/three.js/issues/687" rel="nofollow noreferrer">https://github.com/mrdoob/three.js/issues/687</a> refers to an issue on three.js' GitHub, which has good list of workarounds, including <a href="https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally" rel="nofollow noreferre... |
8,100,622 | Finding even or odd ID values | <p>I was working on a query today which required me to use the following to find all odd number ID values</p>
<pre><code>(ID % 2) <> 0
</code></pre>
<p>Can anyone tell me what this is doing? It worked, which is great, but I'd like to know why.</p> | 8,100,649 | 8 | 1 | null | 2011-11-11 22:15:09.243 UTC | 3 | 2018-02-21 11:31:42.347 UTC | null | null | null | null | 567,269 | null | 1 | 74 | sql|sql-server-2008 | 223,820 | <p><code>ID % 2</code> is checking what the remainder is if you divide ID by 2. If you divide an even number by 2 it will always have a remainder of 0. Any other number (odd) will result in a non-zero value. Which is what is checking for.</p> |
7,782,080 | How to print a two dimensional array? | <p>I have a [20][20] two dimensional array that I've manipulated. In a few words I am doing a turtle project with user inputting instructions like pen up = 0 and pen down = 1. When the pen is down the individual array location, for instance [3][4] is marked with a "1".</p>
<p>The last step of my program is to... | 7,782,111 | 10 | 0 | null | 2011-10-16 03:00:56 UTC | 9 | 2020-08-17 02:19:55.577 UTC | 2020-06-23 16:46:36.86 UTC | null | 7,910,454 | null | 997,462 | null | 1 | 25 | java | 170,979 | <pre><code>public void printGrid()
{
for(int i = 0; i < 20; i++)
{
for(int j = 0; j < 20; j++)
{
System.out.printf("%5d ", a[i][j]);
}
System.out.println();
}
}
</code></pre>
<p>And to replace</p>
<pre><code>public void replaceGrid()
{
for (int i = 0; i < 20; i++)... |
4,122,040 | How to make sphinx look for modules in virtualenv while building html? | <p>I want to build html docs using a virtualenv instead of the native environment on my machine. </p>
<p>I've entered the virtualenv but when I run <code>make html</code> I get errors saying the module can't be imported - I <em>know</em> the errors are due to the module being unavailable in my native environment.
How... | 4,249,730 | 3 | 0 | null | 2010-11-08 07:42:24.383 UTC | 16 | 2013-08-19 21:41:43.23 UTC | 2012-05-08 13:19:17.833 UTC | null | 121,725 | null | 121,725 | null | 1 | 54 | virtualenv|python-sphinx | 10,060 | <p>The problem here is that <code>make html</code> uses the <code>sphinx-build</code> command as a normal shell command, which explicitly specifies which Python interpreter to use in the first line of the file (ie. <code>#!/usr/bin/python</code>). If Python gets invoked in this way, it will not use your virtual environ... |
4,684,112 | How do CDI and EJB compare? interact? | <p>I'm having a tough time understanding how the two interact and where the boundary between them lies. Do they overlap? Are there redundancies between them?</p>
<p>I know there are annotations associated with both, but I haven't been able to find a complete list for both with brief descriptions. Not sure if this woul... | 4,684,305 | 3 | 1 | null | 2011-01-13 19:03:35.083 UTC | 82 | 2019-12-03 07:37:52.513 UTC | null | null | null | null | 5,284 | null | 1 | 110 | java|ejb|java-ee-6|cdi | 45,443 | <p><strong>CDI:</strong> it is about dependency injection. It means that you can inject interface implementation anywhere. This object can be anything, it can be not related to EJB. <a href="http://download.oracle.com/javaee/6/tutorial/doc/gjcxv.html" rel="noreferrer">Here</a> is an example of how to inject random gene... |
4,692,311 | How do I create my own Scaffold Template in ASP.NET MVC 3? | <p>ASP.NET MVC provides the ability to select a 'Scaffold template' upon which a newly-created view will be based (Add View > Create a strongly-typed view > Scaffold template).</p>
<p>Is it possible to create your own Scaffold Template? And if so, how?</p> | 4,692,521 | 5 | 2 | null | 2011-01-14 14:53:12.303 UTC | 10 | 2013-07-02 14:20:26.577 UTC | null | null | null | null | 1,943 | null | 1 | 35 | asp.net-mvc|asp.net-mvc-3 | 16,511 | <p>ASP.NET MVC uses T4 templates. <a href="http://blogs.msdn.com/b/joecar/archive/2011/01/06/add-the-asp-net-mvc-3-code-templates-to-your-application-with-nuget.aspx" rel="noreferrer">Here's an overview</a>.</p>
<p>Here are the steps:</p>
<ol>
<li>In the Package Manager Console type: <code>install-package mvc3codetem... |
4,315,111 | How to do HTTP-request/call with JSON payload from command-line? | <p>What's the easiest way to do a JSON call from the command-line? I have a website that does a JSON call to retrieve additional data.</p>
<p>The <strong>Request Payload</strong> as shown in Google Chrome looks like this:</p>
<pre><code>{"version": "1.1", "method":"progr","id":2,"params":{"call":...} }
</code></pre>
... | 4,315,155 | 5 | 0 | null | 2010-11-30 15:01:01.46 UTC | 10 | 2022-01-26 07:29:59.05 UTC | 2010-12-01 09:00:32.91 UTC | null | 26,387 | null | 26,387 | null | 1 | 61 | linux|json|command-line|web-crawler | 117,950 | <p>Use curl, assuming the data is POST'ed, something like</p>
<pre><code>curl -X POST http://example.com/some/path -d '{"version": "1.1", "method":"progr","id":2,"params":{"call":...} }'
</code></pre>
<p>If you're just retrieving the data with a GET , and don't need to send anything bar URL parameters,
you'd just run... |
4,425,681 | How can I convert a VBScript to an executable (EXE) file? | <p>I'd looked around for information to convert a VBScript <code>(*.vbs)</code> to an executable and realised that most of the tools available are actually wrapping the script in the executable. Tried a few tools and it didn't worked as well as expected. I tried IExpress (in Windows XP) to create the Win32 self extract... | 4,426,499 | 6 | 2 | null | 2010-12-13 03:52:16.657 UTC | 9 | 2018-03-10 09:05:17.723 UTC | 2018-03-07 11:06:35.617 UTC | null | 5,211,833 | null | 324,236 | null | 1 | 19 | vbscript|executable|iexpress | 122,327 | <p><strong>There is no way to convert a VBScript (.vbs file) into an executable (.exe file) because VBScript is <em>not a compiled language</em>.</strong> The process of converting source code into native executable code is called <a href="http://en.wikipedia.org/wiki/Compiler" rel="noreferrer">"compilation"</a>, and i... |
4,321,456 | 'find -exec' a shell function in Linux | <p>Is there a way to get <code>find</code> to execute a function I define in the shell?</p>
<p>For example:</p>
<pre><code>dosomething () {
echo "Doing something with $1"
}
find . -exec dosomething {} \;
</code></pre>
<p>The result of that is:</p>
<pre><code>find: dosomething: No such file or directory
</co... | 4,321,522 | 14 | 0 | null | 2010-12-01 05:25:34.68 UTC | 58 | 2022-04-08 16:05:35.663 UTC | 2021-04-19 15:53:32.567 UTC | null | 63,550 | null | 303,896 | null | 1 | 241 | linux|bash|shell|find|bsd | 96,649 | <p>Since only the shell knows how to run shell functions, you have to run a shell to run a function. You also need to mark your function for export with <code>export -f</code>, otherwise the subshell won't inherit them:</p>
<pre><code>export -f dosomething
find . -exec bash -c 'dosomething "$0"' {} \;
</code></pre> |
4,530,069 | How do I get a value of datetime.today() in Python that is "timezone aware"? | <p>I am trying to subtract one date value from the value of <code>datetime.datetime.today()</code> to calculate how long ago something was. But it complains:</p>
<pre class="lang-none prettyprint-override"><code>TypeError: can't subtract offset-naive and offset-aware datetimes
</code></pre>
<p>The return value from <co... | 4,530,166 | 19 | 5 | null | 2010-12-25 10:59:49.863 UTC | 74 | 2022-04-27 00:31:47.04 UTC | 2022-04-27 00:31:47.04 UTC | user17242583 | null | null | 323,874 | null | 1 | 439 | python|datetime|date|timezone | 508,329 | <p>In the standard library, there is no cross-platform way to create aware timezones without creating your own timezone class. (<strong>Edit:</strong> Python 3.9 introduces <a href="https://docs.python.org/3/library/zoneinfo.html" rel="noreferrer"><code>zoneinfo</code></a> in the standard library which does provide thi... |
14,622,962 | What is transaction.commit() in Hibernate? | <p>What does <strong>transaction.commit()</strong> do?</p>
<pre><code>Account account = new Account();
account.setId(100);
account = (Account) session.get(Account.class, account.getId());
System.out.println("Before Transaction: Balance = " + account.getBalance());
double preBal = account.getBalance();
account.setBalan... | 14,626,510 | 2 | 0 | null | 2013-01-31 09:58:06.563 UTC | 7 | 2015-07-16 21:59:45.343 UTC | 2013-01-31 10:25:36.007 UTC | null | 1,597,838 | null | 1,597,838 | null | 1 | 10 | java|mysql|database|hibernate | 41,085 | <p><strong>Commit</strong> will make the database commit. The changes to persistent object will be written to database.
<strong>Flushing</strong> is the process of <em>synchronizing</em> the underlying persistent
store with persistant state held in memory.
ie. it will update or insert into your tables in the running
tr... |
14,744,984 | Jade/Pug if else condition usage | <p>I'm sending a date to a .jade file from my .js file using <code>Node.js</code>. When the <code>#{date}</code> field is <code>false</code>, it executes the else and print <code>man</code> as it's answer. What could be going wrong?</p>
<pre><code>if #{date} == false
| #{date}
else
| man
</code></pre> | 14,961,069 | 3 | 0 | null | 2013-02-07 06:27:14.553 UTC | 5 | 2017-06-23 04:59:40.347 UTC | 2017-06-04 13:21:55.293 UTC | null | 1,053,103 | null | 2,049,614 | null | 1 | 18 | node.js|pug | 44,297 | <p>If date is false, do you want to output the string 'man'?
If yes, your if and else statements are the wrong way around...</p>
<p>How about:</p>
<pre><code>if date
= date
else
| man
</code></pre>
<p>or even:</p>
<pre><code>| #{date ? date : 'man'}
</code></pre>
<p>or simply:</p>
<pre><code>| #{date || 'man'... |
14,829,190 | How to use markdown for maven project site? | <p>How to start with project documentation using maven and markdown markup language?
Maven site default is APT, which is uncomfortable to learn just to do thing maven way.
(Usually nobody in a team will start writing maven site documentation when they also need to learn one more markup language along the way.)</p>
<p>... | 14,831,412 | 2 | 3 | null | 2013-02-12 09:22:31.743 UTC | 30 | 2021-05-07 13:10:00.293 UTC | 2013-02-12 12:58:45.717 UTC | null | 482,717 | null | 482,717 | null | 1 | 48 | maven|markdown|maven-site-plugin | 14,768 | <p>Quote from <a href="http://maven.apache.org/doxia/references/index.html" rel="noreferrer">http://maven.apache.org/doxia/references/index.html</a></p>
<p>Add this to <code>pom.xml</code></p>
<pre><code> <plugin>
<groupId>org.apache.maven.plugins</groupId>
&... |
14,492,138 | Mime type for .txt files? | <p>I´m trying to share a <code>.txt</code> file with share intent. If I set "text/plain" as mime type, it reads the content like text not like text file, then the options given in the share menu are Whatsapp, Line, etc..</p>
<p>Does anybody know how to configure the share intent so that the share options are only the ... | 25,488,949 | 2 | 0 | null | 2013-01-24 00:55:23.563 UTC | 7 | 2016-01-27 15:15:47.023 UTC | 2016-01-27 15:15:47.023 UTC | null | 1,736,451 | null | 1,736,451 | null | 1 | 86 | android|text-files|share|mime-types | 81,385 | <p>You can try the specific mime:</p>
<pre><code>text/plain
</code></pre>
<p>or, the more general text mime:</p>
<pre><code>text/*
</code></pre> |
45,326,775 | Dagger: IllegalArgumentException: No injector factory bound for Class | <p>I am new to Dagger 2. I have 2 Activities, I want to use injected ViewModel for both. Here is my <strong>ViewModuleFactory</strong> :</p>
<pre><code>@Singleton
public class ProductViewModelFactory implements ViewModelProvider.Factory {
private final Map<Class<? extends ViewModel>, Provider<ViewMode... | 45,327,464 | 5 | 0 | null | 2017-07-26 12:17:47.753 UTC | 6 | 2022-07-27 13:42:03.437 UTC | 2017-07-26 20:05:07.653 UTC | null | 525,004 | null | 525,004 | null | 1 | 71 | android|dependency-injection|dagger-2|dagger | 55,889 | <p>I believe you have forgot to put <code>@ContributesAndroidInjector</code> annotation:</p>
<pre>
<code>
@Module
public abstract class ActivityModule {
@ContributesAndroidInjector
abstract ProductListActivity contributeProductListActivity();
@ContributesAndroidInjector
abstract... |
2,749,863 | AppleScript Editor, write message to the "Result" window | <p>I am using the Mac OS X Apple Script Editor and (while debugging) instead of writing a lot of <code>display dialog</code> statements, I'd like to write the results of some calculation in the window below, called "Result" (I have the German UI here, so the translation is a guess). So is there a write/print statement ... | 2,749,931 | 2 | 0 | null | 2010-05-01 12:15:23.1 UTC | 8 | 2017-07-07 11:11:00.767 UTC | 2015-04-27 15:53:58.333 UTC | null | 253,056 | null | 317,915 | null | 1 | 60 | macos|logging|applescript | 70,785 | <p>You can use the <a href="https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW49" rel="noreferrer">log</a> command, which puts messages into the <strong>Log History</strong> window, e.g.:</p>
<p><br></p>
<p... |
39,715,803 | What is the difference between mini-batch vs real time streaming in practice (not theory)? | <p>What is the difference between mini-batch vs real time streaming in practice (not theory)? In theory, I understand mini batch is something that batches in the given time frame whereas real time streaming is more like do something as the data arrives but my biggest question is why not have mini batch with epsilon tim... | 39,719,036 | 3 | 0 | null | 2016-09-27 04:08:21.353 UTC | 12 | 2017-04-09 15:46:56.517 UTC | 2017-04-09 15:44:35.1 UTC | null | 318,054 | null | 1,870,400 | null | 1 | 24 | apache-spark|batch-processing|apache-flink|data-processing|stream-processing | 8,555 | <p><em>Disclaimer</em>: I'm a committer and PMC member of Apache Flink. I'm familiar with the overall design of Spark Streaming but do not know its internals in detail.</p>
<p>The mini-batch stream processing model as implemented by Spark Streaming works as follows: </p>
<ul>
<li>Records of a stream are collected in ... |
58,339,005 | What is the most common way to authenticate a modern web app? | <p>I'm writing a web app (REST API) using Spring, Spring Security. Right now I have Basic authentication and a really straightforward authorization using username, password and roles. I want to improve the security layer but I have no experience with this.</p>
<p>When I had looked at postman for possible authentication... | 58,404,641 | 2 | 0 | null | 2019-10-11 10:09:42.027 UTC | 13 | 2021-05-27 08:13:55.357 UTC | 2020-12-31 17:55:26.343 UTC | null | 11,249,957 | null | 9,753,003 | null | 1 | 31 | rest|web-services|security|spring-security|restful-authentication | 16,223 | <p>As far as web application is concerned web application request should have state, <strong>session</strong> is the most common way to have state.</p>
<p>And when we consider <strong>REST API's</strong> requests are preferred to be stateless, but to authenticate and identify user or client there are lot of ways as OP... |
31,231,696 | iOS 9 ATS SSL error with supporting server | <p>I installed Xcode 7 and tried running my app under iOS 9.
I'm getting the infamous error: <code>Connection failed! Error - -1200 An SSL error has occurred and a secure connection to the server cannot be made.</code>
The thing is my server DOES support TLSv1.2 and I'm using <code>NSURLSession</code>.</p>
<p>What cou... | 31,245,309 | 5 | 0 | null | 2015-07-05 15:02:33.367 UTC | 14 | 2018-02-23 16:22:21.997 UTC | 2015-08-08 22:37:24.093 UTC | null | 1,544,627 | null | 915,824 | null | 1 | 21 | ios|objective-c|ssl|nsurlsession|ios9 | 27,722 | <p>Apple has released the full requirements list for the <a href="https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/">App Transport Security</a>.</p>
<p>Turned out that we were working with TLS v1.2 but were missing some of the other requirements.</p>
<p><strong>Here's the f... |
49,841,324 | What does calling fit() multiple times on the same model do? | <p>After I instantiate a scikit model (e.g. <code>LinearRegression</code>), if I call its <code>fit()</code> method multiple times (with different <code>X</code> and <code>y</code> data), what happens? Does it fit the model on the data like if I just re-instantiated the model (i.e. from scratch), or does it keep into a... | 49,841,366 | 3 | 0 | null | 2018-04-15 11:19:47.837 UTC | 9 | 2022-09-23 10:40:47.803 UTC | 2018-04-15 11:33:39.813 UTC | null | 5,741,205 | null | 4,262,324 | null | 1 | 62 | python|machine-learning|scikit-learn | 31,031 | <p>If you will execute <code>model.fit(X_train, y_train)</code> for a second time - it'll overwrite all previously fitted coefficients, weights, intercept (bias), etc.</p>
<p>If you want to fit just a portion of your data set and then to improve your model by fitting a new data, then you can use <a href="https://scikit... |
40,478,018 | Pyspark dataframe convert multiple columns to float | <p>I am trying to convert multiple columns of a dataframe from string to float like this</p>
<pre><code>df_temp = sc.parallelize([("1", "2", "3.4555"), ("5.6", "6.7", "7.8")]).toDF(("x", "y", "z"))
df_temp.select(*(float(col(c)).alias(c) for c in df_temp.columns)).show()
</code></pre>
<p>but I am getting the error</p... | 40,484,961 | 4 | 0 | null | 2016-11-08 02:31:24.557 UTC | 1 | 2021-12-03 18:13:42.283 UTC | 2016-11-08 04:25:15.123 UTC | null | 399,111 | null | 399,111 | null | 1 | 24 | python|apache-spark|pyspark | 45,724 | <p><code>float()</code> is not a Spark function, you need the function <code>cast()</code>:</p>
<pre><code>from pyspark.sql.functions import col
df_temp.select(*(col(c).cast("float").alias(c) for c in df_temp.columns))
</code></pre> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.