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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,243,079 | How to examine SharedPreferences from adb shell? | <p>Now that we can <a href="http://developer.android.com/guide/developing/tools/adb.html#sqlite" rel="noreferrer">Examining sqlite3 Databases from a Remote Shell</a>, is it possible to examine SharedPreferences from adb shell? Since it would be much more convenient to examine and manipulate SharedPreferences from comma... | 1,243,134 | 8 | 0 | null | 2009-08-07 05:45:00.357 UTC | 17 | 2020-10-14 09:41:50.173 UTC | 2016-01-09 14:23:00.56 UTC | null | 1,221,313 | null | 56,149 | null | 1 | 46 | android|adb|android-sharedpreferences | 39,163 | <p>Fine, I found the file just after I raised the question above. (It seem asking questions publicly stimulate me to search answers by myself much more diligently, since I don't want my dear peers to view me as a lazy programmer.)</p>
<p>It is an XML file under <code>/data/data/your.app.package.name/shared_prefs</code... |
314,800 | Best way to define true, false, unset state | <p>If you have a situation where you need to know where a boolean value wasn't set (for example if that unset value should inherit from a parent value) the Java boolean primitive (and the equivalent in other languages) is clearly not adequate.</p>
<p>What's the best practice to achieve this? Define a new simple class... | 314,809 | 10 | 1 | null | 2008-11-24 17:11:18.053 UTC | 1 | 2019-04-27 18:30:02.807 UTC | null | null | null | Tom Martin | 5,303 | null | 1 | 28 | java|boolean | 39,464 | <pre><code>Boolean a = true;
Boolean b = false;
Boolean c = null;
</code></pre>
<p>I would use that. It's the most straight-forward.</p>
<p>Another way is to use an enumeration. Maybe that's even better and faster, since no boxing is required:</p>
<pre><code>public enum ThreeState {
TRUE,
FALSE,
TRALSE
}... |
497,992 | Why are Virtual Machines necessary? | <p>I was reading <a href="https://stackoverflow.com/questions/453610/javas-virtual-machine-and-clr">this question</a> to find out the differences between the Java Virtual Machine and the .NET CLR and Benji's answer got me wondering why Virtual Machines are necessary in the first place.</p>
<p>From my understanding of ... | 498,052 | 10 | 0 | null | 2009-01-31 01:42:04.133 UTC | 16 | 2015-06-11 09:44:53.66 UTC | 2017-05-23 12:02:11.563 UTC | null | -1 | null | 8,784 | null | 1 | 30 | compiler-construction|vm-implementation | 4,943 | <p>The AMD and intel processors use the same instruction set and machine architecture (from the standpoint of execution of machine code).</p>
<p>C and C++ compilers compile to machine code, with headers appropriate to the OS they are targeted at. Once compiled they cease to associate in any way, shape, or form with t... |
1,300,057 | Internet Explorer 6 emulator recommendation | <p>What good tool can be recommended for emulating Internet Explorer 6? I would rather not have to go and install an old copy of Windows XP somewhere.</p> | 1,300,068 | 11 | 1 | null | 2009-08-19 13:46:59.947 UTC | 14 | 2021-04-30 10:01:02.09 UTC | 2011-01-18 20:21:39.847 UTC | null | 63,550 | null | 117,215 | null | 1 | 51 | testing|internet-explorer-6|emulation | 59,174 | <p><a href="http://www.microsoft.com/Downloads/details.aspx?FamilyID=21eabb90-958f-4b64-b5f1-73d0a413c8ef&displaylang=en" rel="nofollow noreferrer">Microsoft offer a number of Virtual PC images with various versions of IE for download.</a></p>
<p>They now also offer <a href="https://developer.microsoft.com/en-us/m... |
787,239 | What is a dynamic language, and why doesn't C# qualify? | <p>Listening to a podcast, I heard that C# is not dynamic language while Ruby is.</p>
<p>What is a "dynamic language"? Does the existence of dynamic languages imply that there are static languages?</p>
<p>Why is C# a dynamic language and what other languages are dynamic? If C# is <em>not</em> dynamic, why is Microsof... | 787,253 | 12 | 8 | 2009-04-24 19:30:15.867 UTC | 2009-04-24 19:30:15.88 UTC | 10 | 2017-12-03 03:17:34.957 UTC | 2012-06-20 15:58:06.373 UTC | null | 229,044 | null | 66,493 | null | 1 | 31 | c#|ruby|static-libraries|dynamic-languages | 32,142 | <h2>What is a dynamic language?</h2>
<p>Whether or not a language is dynamic typically refers to the type of binding the compiler does: static or late binding. </p>
<p>Static binding simply means that the method (or method hierarchy for virtual methods) is bound at compile time. There may be a virtual dispatch invo... |
1,163,761 | Capture screenshot of active window? | <p>I am making a screen capturing application and everything is going fine. All I need to do is capture the active window and take a screenshot of this active window. Does anyone know how I can do this?</p> | 1,163,781 | 12 | 2 | null | 2009-07-22 08:08:41.27 UTC | 134 | 2020-11-23 16:51:41.663 UTC | 2014-04-11 16:43:02.383 UTC | null | 719,034 | null | 141,831 | null | 1 | 201 | c#|screenshot|active-window | 362,226 | <pre><code>ScreenCapture sc = new ScreenCapture();
// capture entire screen, and save it to a file
Image img = sc.CaptureScreen();
// display image in a Picture control named imageDisplay
this.imageDisplay.Image = img;
// capture this window, and save it
sc.CaptureWindowToFile(this.Handle,"C:\\temp2.gif",ImageFormat.Gi... |
845,060 | What is the difference between 'my' and 'our' in Perl? | <p>I know what <code>my</code> is in Perl. It defines a variable that exists only in the scope of the block in which it is defined. What does <code>our</code> do?</p>
<p>How does <code>our</code> differ from <code>my</code>?</p> | 885,888 | 12 | 0 | null | 2009-05-10 10:24:53.97 UTC | 60 | 2021-11-05 21:27:26.58 UTC | 2019-11-20 13:07:17.35 UTC | null | 63,550 | null | 1,084 | null | 1 | 203 | perl|scope | 125,209 | <p>How does <em><strong><code>our</code></strong></em> differ from <em><strong><code>my</code></strong></em> and what does <em><code>our</code></em> do?</p>
<p>In Summary:</p>
<p>Available since Perl 5, <em><strong><code>my</code></strong></em> is a way to declare non-package variables, that are:</p>
<ul>
<li>private</... |
1,117,211 | How would I tint an image programmatically on iOS? | <p>I would like to tint an image with a color reference. The results should look like the Multiply blending mode in Photoshop, where <em>whites</em> would be replaced with <em>tint</em>:</p>
<p><img src="https://i.stack.imgur.com/CqiUz.png" alt="alt text"></p>
<p>I will be changing the color value continuously.</p>
... | 1,118,005 | 13 | 3 | null | 2009-07-12 23:38:02.05 UTC | 67 | 2019-04-25 08:34:27.397 UTC | 2019-04-25 08:34:27.397 UTC | null | 1,033,581 | null | 23,973 | null | 1 | 87 | ios|cocoa-touch|image-processing|uiimage|tint | 57,825 | <p>First you'll want to subclass UIImageView and override the drawRect method. Your class needs a UIColor property (let's call it overlayColor) to hold the blend color and a custom setter that forces a redraw when the color changes. Something like this:</p>
<pre><code>- (void) setOverlayColor:(UIColor *)newColor {
... |
653,368 | How to create a decorator that can be used either with or without parameters? | <p>I'd like to create a Python decorator that can be used either with parameters:</p>
<pre><code>@redirect_output("somewhere.log")
def foo():
....
</code></pre>
<p>or without them (for instance to redirect the output to stderr by default):</p>
<pre><code>@redirect_output
def foo():
....
</code></pre>
<p>Is ... | 14,412,901 | 14 | 3 | null | 2009-03-17 08:10:19.76 UTC | 33 | 2022-02-11 20:00:37.867 UTC | 2022-02-11 20:00:37.867 UTC | null | 355,230 | gooli | 15,109 | null | 1 | 120 | python|decorator | 25,452 | <p>I know this question is old, but some of the comments are new, and while all of the viable solutions are essentially the same, most of them aren't very clean or easy to read.</p>
<p>Like thobe's answer says, the only way to handle both cases is to check for both scenarios. The easiest way is simply to check to see... |
246,961 | Algorithm to find articles with similar text | <p>I have many articles in a database (with title,text), I'm looking for an algorithm to find the X most similar articles, something like Stack Overflow's "Related Questions" when you ask a question. </p>
<p>I tried googling for this but only found pages about other "similar text" issues, something like comparing ever... | 252,155 | 15 | 0 | null | 2008-10-29 14:16:44.073 UTC | 54 | 2020-08-25 18:29:51.513 UTC | 2018-09-03 16:35:15.703 UTC | null | 1,915,854 | Osama ALASSIRY | 25,544 | null | 1 | 63 | string|algorithm|text|language-agnostic|similarity | 37,346 | <p><a href="http://en.wikipedia.org/wiki/Levenshtein_distance" rel="noreferrer">Edit distance</a> isn't a likely candidate, as it would be spelling/word-order dependent, and much more computationally expensive than Will is leading you to believe, considering the size and number of the documents you'd actually be intere... |
657,447 | Vim clear last search highlighting | <p>After doing a search in Vim, I get all the occurrences highlighted. How can I disable that? I now do another search for something gibberish that can't be found.</p>
<p>Is there a way to just temporarily disable the highlight and then re-enable it when needed again?</p> | 657,457 | 32 | 6 | null | 2009-03-18 09:00:32.31 UTC | 518 | 2022-07-04 13:13:03.463 UTC | 2020-06-08 20:42:12.403 UTC | null | 4,188,795 | solomongaby | 65,503 | null | 1 | 2,232 | vim|full-text-search|highlight | 633,497 | <p>To turn off highlighting until the next search:</p>
<pre><code>:noh
</code></pre>
<p>Or turn off highlighting completely:</p>
<pre><code>set nohlsearch
</code></pre>
<p>Or, to toggle it:</p>
<pre><code>set hlsearch!
nnoremap <F3> :set hlsearch!<CR>
</code></pre> |
6,571,312 | Can't cast int to bool | <p>I'm facing the problem that C# in my case can't cast the number 1 to bool. In my scenario <code>(bool)intValue</code> doesn't work. I get an <code>InvalidCastException</code>. I know I can use <code>Convert.ToBoolean(...)</code> but I'm just wondering it doesn't work. Any explanation for this?</p>
<p>My code is</p>... | 6,571,505 | 11 | 3 | null | 2011-07-04 12:15:06.79 UTC | 7 | 2017-05-26 19:11:54.81 UTC | 2013-12-02 07:40:56.36 UTC | null | 809,277 | null | 809,277 | null | 1 | 52 | c#|casting|int|boolean | 90,591 | <p><code>int</code> and <code>bool</code> can't be converted implicitly (in contrast to C++, for example).</p>
<p>It was a <strong>concious decision made by language designers</strong> in order to save code from errors when a number was used in a condition. Conditions need to take a <code>boolean</code> value explicit... |
6,981,717 | Pythonic way to combine for-loop and if-statement | <p>I know how to use both for loops and if statements on separate lines, such as:</p>
<pre><code>>>> a = [2,3,4,5,6,7,8,9,0]
... xyz = [0,12,4,6,242,7,9]
... for x in xyz:
... if x in a:
... print(x)
0,4,6,7,9
</code></pre>
<p>And I know I can use a list comprehension to combine these when the st... | 6,981,771 | 11 | 9 | null | 2011-08-08 11:56:16.813 UTC | 78 | 2022-05-08 17:47:23.643 UTC | 2022-05-08 17:47:23.643 UTC | null | 365,102 | null | 413,143 | null | 1 | 358 | python|loops|if-statement|for-loop | 595,452 | <p>You can use <a href="https://www.python.org/dev/peps/pep-0289" rel="noreferrer">generator expressions</a> like this:</p>
<pre><code>gen = (x for x in xyz if x not in a)
for x in gen:
print(x)
</code></pre> |
15,527,293 | Pass an entire model on form submission | <p>I understand that I can use <code>@Html.HiddenFor(m => m.parameter)</code> and when the form is submitted, that parameter will be passed to the controller. My model has many properties. </p>
<p>Is there a shorter way of passing the entire model at once to the controller or must I do it one by one each time?</p> | 15,527,597 | 5 | 0 | null | 2013-03-20 15:05:20.713 UTC | 3 | 2018-02-21 18:44:34.83 UTC | 2013-04-12 21:16:25.377 UTC | null | 727,208 | null | 807,223 | null | 1 | 23 | asp.net-mvc|model|form-submit|html.hiddenfor | 46,734 | <p>The model will be passed to the controller in its entirety, but the values of properties that are not bound by input or hidden fields will be lost. </p>
<p>You have to either bind the properties in the form on the client-side, or re-fetch the entity on the server-side.</p>
<p>You seem to be asking for something l... |
15,975,877 | MySQL trigger On Insert/Update events | <p>So I have two tables like this...<br></p>
<pre><code>ext_words
-------------
| id | word |
-------------
| 1 | this |
-------------
| 2 | that |
-------------
| 3 | this |
-------------
ext_words_count
---------------------
| id | word | count |
---------------------
| 1 | this | 2 |
---------------------
... | 15,978,931 | 2 | 5 | null | 2013-04-12 15:57:40.03 UTC | 9 | 2016-09-08 12:36:42.52 UTC | 2017-05-23 12:25:34.51 UTC | null | -1 | null | 1,272,394 | null | 1 | 27 | mysql|triggers|insert|insert-update | 72,217 | <p>With Grijesh's perfect help and his suggestion to use conditional statements, I was able to get <strong>ONE</strong> trigger that does both tasks. Thanks again Grijesh </p>
<pre><code> DELIMITER $$
CREATE TRIGGER update_count AFTER INSERT ON ext_words
FOR EACH ROW
BEGIN
IF NOT EXISTS (SELECT 1 FROM ex... |
15,535,937 | How to set log level in Winston/Node.js | <p>I am using Winston logging with my Node.js app and have defined a file transport. Throughout my code, I log using either <code>logger.error</code>, <code>logger.warn</code>, or <code>logger.info</code>.</p>
<p>My question is, how do I specify the log level? Is there a config file and value that I can set so that on... | 15,536,506 | 5 | 0 | null | 2013-03-20 22:22:04.32 UTC | 3 | 2020-02-15 15:15:06.483 UTC | 2019-07-28 18:05:26.433 UTC | null | 964,243 | null | 1,334,713 | null | 1 | 30 | node.js|express|winston | 45,250 | <p>Looks like there is a level option in the options passed covered <a href="https://github.com/flatiron/winston">here</a></p>
<p>From that doc:</p>
<pre><code>var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({ level: 'error' }),
new (winston.transports.File)({ filename: 's... |
32,627,519 | iOS 9 Splash screen is black | <p>My apps' splash screens are all plain black after upgrading to iOS9.</p>
<p>Does anybody know why this is? Some of them are using a .xib splash screen and some are using images, but they're all just black now. Does an app have to be built with Xcode 7 for the splash screen to work in iOS9? Has anyone seen some docu... | 32,666,462 | 16 | 7 | null | 2015-09-17 09:58:12.867 UTC | 13 | 2019-11-28 08:16:58.527 UTC | 2015-09-19 09:51:00.573 UTC | null | 1,182,897 | null | 1,182,897 | null | 1 | 61 | ios|xcode|splash-screen|ios9|xcode7 | 50,302 | <p>Same problem here after I updated to iOS 9. Re-installing the app from the App Store seems to solve the problem. I guess, it's an iOS 9 glitch.</p> |
35,919,103 | How do I use a regex in a shell script? | <p>I am trying to match a string with a regex in a shell script.
This string is a parameter of the script ( $1 ) and it is a date (MM/DD/YYYY)
The regex I'm trying to use is : </p>
<pre><code>^\d{2}[\/\-]\d{2}[\/\-]\d{4}$
</code></pre>
<p>It seems to work, I tried it on several regex tests websites.</p>
<p>My shell ... | 35,924,143 | 3 | 6 | null | 2016-03-10 14:23:26.817 UTC | 10 | 2018-10-08 18:27:23.43 UTC | 2017-11-29 15:26:29.687 UTC | null | 6,045,244 | null | 6,045,244 | null | 1 | 60 | regex|bash|shell | 144,848 | <p>To complement the existing helpful answers:</p>
<p>Using <strong>Bash's own regex-matching operator, <code>=~</code></strong>, is a faster alternative in this case, given that you're only matching a single value already stored in a variable:</p>
<pre><code>set -- '12-34-5678' # set $1 to sample value
kREGEX_DATE=... |
10,306,254 | Is it possible to block cookies from being set using Javascript or PHP? | <p>A lot of you are probably aware of the new EU privacy law, but for those who are not, it basically means no site operated by a company resident in the EU can set cookies classed as 'non-essential to the operation of the website' on a visitors machine unless given express permission to do so. </p>
<p>So, the questio... | 10,828,998 | 5 | 3 | null | 2012-04-24 21:28:03.477 UTC | 19 | 2019-10-08 16:38:09.807 UTC | 2012-04-24 22:00:42.37 UTC | null | 1,354,771 | null | 1,354,771 | null | 1 | 22 | php|javascript|cookies|blocking | 34,977 | <p>I'm pretty interested in this answer too. I've accomplished what I need to accomplish in PHP, but the JavaScript component still eludes me.</p>
<p>Here's how I'm doing it in PHP:</p>
<pre><code>$dirty = false;
foreach(headers_list() as $header) {
if($dirty) continue; // I already know it needs to be cleaned
... |
10,854,329 | Spinner : onItemSelected not called when selected item remains the same | <p>I have a <code>OnItemSelectedListener</code> for my <code>Spinner</code>, but it is not called when the selected item is the same as the previous one. Apparently the <code>OnClickListener</code> is not an option for a <code>Spinner</code>.
I need to catch everytime a user click on an item. Any idea?</p>
<p>Maybe th... | 11,227,847 | 11 | 3 | null | 2012-06-01 16:46:53.15 UTC | 14 | 2021-11-27 19:06:35.033 UTC | 2012-09-04 11:17:17.77 UTC | null | 1,300,995 | null | 1,058,339 | null | 1 | 54 | android|spinner|listener|android-actionbar|actionbarsherlock | 38,492 | <p>Ok, I finally found a solution, by creating my own class extending Spinner :</p>
<pre><code>public class MySpinner extends Spinner {
OnItemSelectedListener listener;
public MySpinner(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void setSelection(int position) {
super.se... |
10,484,164 | What is the latency and throughput of the RDRAND instruction on Ivy Bridge? | <p>I cannot find any info on <a href="http://www.agner.org/optimize/#manuals" rel="noreferrer">agner.org</a> on the latency or throughput of the <a href="http://en.wikipedia.org/wiki/RdRand" rel="noreferrer">RDRAND</a> instruction. However, this processor exists, so the information must be out there.</p>
<p>Edit: Actu... | 11,042,778 | 4 | 5 | null | 2012-05-07 14:49:21.913 UTC | 10 | 2017-03-07 12:02:37.967 UTC | 2012-06-10 16:23:25.75 UTC | null | 370,756 | null | 239,558 | null | 1 | 31 | assembly|intel|rdrand | 6,295 | <p>I wrote librdrand. It's a very basic set of routines to use the RdRand instruction to fill buffers with random numbers. </p>
<p>The performance data we showed at IDF is from test software I wrote that spawns a number of threads using pthreads in Linux. Each thread pulls fills a memory buffer with random numbers usi... |
24,942,538 | SQL won't insert null values with BULK INSERT | <p>I have a CSV file and each line looks similar to this:</p>
<pre><code>EASTTEXAS,NULL,BELLVILLE AREA,NULL,BELLVILLE AREA,RGP,NULL,NULL,0,NULL,NULL,NULL,1,1,PM,PM Settings,NULL,NULL
</code></pre>
<p>I couldn't find any examples on how NULL values were supposed to be handled when doing BULK INSERT, so I assumed that ... | 24,942,791 | 2 | 5 | null | 2014-07-24 19:38:21.943 UTC | 2 | 2017-06-22 13:46:54.3 UTC | null | null | null | null | 1,339,826 | null | 1 | 12 | sql-server|csv|bulkinsert | 38,083 | <p>According to: </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms187887.aspx">http://msdn.microsoft.com/en-us/library/ms187887.aspx</a></p>
<p>null values can be inserted by having an empty field within your file.</p>
<p>Example file was:</p>
<pre><code>1,,DataField3
2,,DataField3
</code></pre>
<p>Examp... |
35,631,903 | Raw SQL Query without DbSet - Entity Framework Core | <p>With Entity Framework Core removing <code>dbData.Database.SqlQuery<SomeModel></code> I can't find a solution to build a raw SQL Query for my full-text search query that will return the tables data and also the rank. </p>
<p>The only method I've seen to build a raw SQL query in Entity Framework Core is via <co... | 50,452,479 | 20 | 8 | null | 2016-02-25 15:44:12.02 UTC | 48 | 2022-08-08 14:35:19.353 UTC | 2017-03-27 04:11:33.297 UTC | null | 1,857,083 | null | 4,241,818 | null | 1 | 219 | c#|entity-framework-core | 242,595 | <h2>If you're using EF Core 3.0 or newer</h2>
<p>You need to use <a href="https://docs.microsoft.com/ef/core/modeling/keyless-entity-types?tabs=data-annotations" rel="nofollow noreferrer">keyless entity types</a>, previously known as query types:</p>
<blockquote>
<p>This feature was added in EF Core 2.1 under the name ... |
40,073,322 | Plotting list of lists in a same graph in Python | <p>I am trying to plot <code>(x,y)</code> where as <code>y = [[1,2,3],[4,5,6],[7,8,9]]</code>.</p>
<p>Say, <code>len(x) = len(y[1]) = len(y[2])</code>..
The length of the y is decided by the User input. I want to plot multiple plots of y in the same graph i.e, <code>(x, y[1],y[2],y[3],...)</code>. When I tried using lo... | 40,073,609 | 2 | 6 | null | 2016-10-16 17:38:29.623 UTC | 3 | 2021-06-09 06:05:07.57 UTC | 2021-06-09 06:05:07.57 UTC | null | 7,758,804 | null | 5,009,494 | null | 1 | 19 | python|matplotlib|nested-lists | 80,110 | <p>Assuming some sample values for x, below is the code that could give you the desired output.</p>
<pre><code>import matplotlib.pyplot as plt
x = [1,2,3]
y = [[1,2,3],[4,5,6],[7,8,9]]
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.title("A test graph")
for i in range(len(y[0])):
plt.plot(x,[pt[i] for pt in y],labe... |
13,741,946 | Role of datanode, regionserver in Hbase-hadoop integration | <p>From my understanding rows are inserted into HBase tables and are getting stored as regions in different region server. So, the region server stores the data</p>
<p>Similarly in terms of Hadoop, data is stored in the data nodes present in the hadoop cluster.</p>
<p>Lets say that i have HBase 0.90.6 configured on t... | 13,742,379 | 1 | 0 | null | 2012-12-06 10:46:10.21 UTC | 15 | 2016-05-04 00:10:15.437 UTC | 2014-12-08 05:14:52.993 UTC | null | 2,573,335 | null | 1,605,937 | null | 1 | 19 | hadoop|hbase | 20,349 | <p>Data nodes store data. Region server(s) essentially buffer I/O operations; data is permanently stored on HDFS (that is, data nodes). I do not think that putting region server on your 'master' node is a good idea. </p>
<p>Here is a simplified picture of how regions are managed:</p>
<p>You have a cluster running HD... |
13,542,175 | THREE.js Ray Intersect fails by adding div | <p>My Three.js script runs fine when there is only one target div on the page (which holds renderer.domElement). As soon as I add another div with fixed height and width above the target div, ray.intersectObjects returns null. I doubt that the vector that I am creating for ray is causing the problem. Here is the code.<... | 13,544,277 | 3 | 0 | null | 2012-11-24 14:32:00.503 UTC | 13 | 2022-08-24 16:53:23.187 UTC | 2019-05-29 00:52:41.527 UTC | null | 6,521,116 | null | 1,099,235 | null | 1 | 20 | javascript|html|three.js | 14,828 | <p>The short answer is you have to take into consideration the <code>offset</code> of the canvas.</p>
<p>The long answer depends on how your code is written, so I'll give you two answers, which should cover the bases.</p>
<p>There are a lot of possible combinations, so you may have to experiment. Also, different browse... |
13,550,376 | PIL image to array (numpy array to array) - Python | <p>I have a .jpg image that I would like to convert to Python array, because I implemented treatment routines handling plain Python arrays. </p>
<p>It seems that PIL images support conversion to numpy array, and according to the documentation I have written this:</p>
<pre><code>from PIL import Image
im = Image.open("... | 13,550,527 | 4 | 1 | null | 2012-11-25 10:57:52.02 UTC | 12 | 2019-02-04 06:26:05.833 UTC | 2015-12-30 15:55:08.62 UTC | null | 562,769 | null | 1,141,493 | null | 1 | 24 | python|arrays|image|numpy|python-imaging-library | 116,827 | <p>I think what you are looking for is:</p>
<pre><code>list(im.getdata())
</code></pre>
<p>or, if the image is too big to load entirely into memory, so something like that:</p>
<pre><code>for pixel in iter(im.getdata()):
print pixel
</code></pre>
<p>from <a href="http://effbot.org/imagingbook/image.htm#tag-Imag... |
13,678,702 | How is the jQuery selector $('#foo a') evaluated? | <p>As a example of jQuery code (<a href="https://coderwall.com/p/7uchvg">https://coderwall.com/p/7uchvg</a>), I read that the expression <code>$('#foo a');</code> behaves like this: </p>
<blockquote>
<p>Find every <code>a</code> in the page and then filter <code>a</code> inside <code>#foo</code>.</p>
</blockquote>
... | 13,678,739 | 7 | 2 | null | 2012-12-03 07:10:46.157 UTC | 19 | 2014-05-19 16:54:01.417 UTC | 2014-05-19 16:54:01.417 UTC | null | 775,283 | null | 375,966 | null | 1 | 44 | javascript|jquery|performance|jquery-selectors|sizzle | 5,097 | <p>That is correct - Sizzle (jQuery's selector engine) behaves the <a href="http://css-tricks.com/efficiently-rendering-css/">same way as CSS selectors</a>. CSS and Sizzle selectors are <a href="http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-think-right-to-left-with-jquery/">evaluated right-to-left</a>, an... |
13,439,303 | Detect click event inside iframe | <p>I'm writing a plugin for TinyMCE and have a problem with detecting click events inside an iframe. </p>
<p>From my search I've come up with this:</p>
<p>Loading iframe:</p>
<pre><code><iframe src='resource/file.php?mode=tinymce' id='filecontainer'></iframe>
</code></pre>
<p>HTML inside iframe:</p>
<p... | 13,782,102 | 10 | 2 | null | 2012-11-18 10:28:58.847 UTC | 18 | 2021-03-01 05:43:44.18 UTC | 2017-09-07 10:03:53.223 UTC | null | 3,502,164 | null | 1,833,314 | null | 1 | 52 | javascript|jquery|html|iframe|tinymce | 132,177 | <p>I solved it by doing like this:</p>
<pre><code>$('#filecontainer').load(function(){
var iframe = $('#filecontainer').contents();
iframe.find("#choose_pics").click(function(){
alert("test");
});
});
</code></pre> |
13,359,294 | Date.getDay() javascript returns wrong day | <p>Hi I'm new in javascript
I have such javascript code</p>
<pre><code>alert(DATE.value);
var d = new Date(DATE.value);
var year = d.getFullYear();
var month = d.getMonth();
var day = d.getDay();
alert(month);
alert(day);
if(2012 < year < 1971 | 1 > month+1 > 12 | 0 >day > 31){
alert(errorDate);
... | 13,359,330 | 8 | 1 | null | 2012-11-13 10:42:45.59 UTC | 21 | 2022-03-25 18:45:23.733 UTC | 2018-09-17 14:18:56.59 UTC | null | 3,995,261 | null | 1,599,937 | null | 1 | 184 | javascript|date | 114,375 | <p>use <code>.getDate</code> instead of <code>.getDay</code>.</p>
<blockquote>
<p>The value returned by getDay is an integer corresponding to the day of the week: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.</p>
</blockquote> |
13,407,036 | How does interfaces with construct signatures work? | <p>I am having some trouble working out how defining constructors in interfaces work. I might be totally misunderstanding something. But I have searched for answers for a good while and I can not find anything related to this. </p>
<p>How do I implement the following interface in a TypeScript class: </p>
<pre><code>i... | 13,408,029 | 8 | 4 | null | 2012-11-15 22:03:36.57 UTC | 50 | 2022-08-10 12:32:34.22 UTC | 2019-02-13 20:32:52.417 UTC | null | 3,345,644 | null | 1,827,926 | null | 1 | 206 | typescript|constructor|interface | 128,662 | <p>
Construct signatures in interfaces are not implementable in classes; they're only for defining existing JS APIs that define a 'new'-able function. Here's an example involving interfaces <code>new</code> signatures that does work:</p>
<pre class="lang-js prettyprint-override"><code>interface ComesFromString {
n... |
13,744,450 | When should we use Observer and Observable? | <p>An interviewer asked me:</p>
<p><em>What is <code>Observer</code> and <code>Observable</code> and when should we use them?</em></p>
<p>I wasn't aware of these terms, so when I got back home and started Googling about <code>Observer</code> and <code>Observable</code>, I found some points from different resources:</... | 13,744,537 | 10 | 6 | null | 2012-12-06 13:17:55.333 UTC | 92 | 2019-04-24 12:54:48.527 UTC | 2018-11-12 05:56:07.053 UTC | null | 6,214,491 | null | 1,162,620 | null | 1 | 210 | java|design-patterns|observable|observer-pattern|observers | 171,637 | <p>You have a concrete example of a Student and a MessageBoard. The Student registers by adding itself to the list of Observers that want to be notified when a new Message is posted to the MessageBoard. When a Message is added to the MessageBoard, it iterates over its list of Observers and notifies them that the even... |
20,595,227 | How do I get an image from the iOS photo library and display it in UIWebView | <p>I've seen a lot of examples where you use the <code>UIImage</code> for outputting an image. I would like the output to be set to a <code>UIWebView</code> because I want to put some additional HTML formatting around the image.</p>
<p>I want to get the photo library to return the relative path of an image stored on t... | 20,595,386 | 5 | 2 | null | 2013-12-15 13:47:21.613 UTC | 8 | 2019-09-03 20:16:48.157 UTC | 2018-03-23 06:00:08.98 UTC | null | 5,624,053 | null | 3,104,482 | null | 1 | 23 | ios|objective-c|uiwebview | 45,963 | <p>[<strong>Updated to swift 4</strong>]
You can use <code>UIImagePickerController</code> delegate to select the image (or url) you want to edit.</p>
<p>you can do this like this:</p>
<pre><code>let pickerController = UIImagePickerController()
pickerController.sourceType = .photoLibrary
pickerController.delegate = se... |
20,392,243 | Run C# code on linux terminal | <p>How can I execute a C# code on a linux terminal as a shell script.</p>
<p>I have this sample code:</p>
<pre><code>public string Check(string _IPaddress,string _Port, int _SmsID)
{
ClassGlobal._client = new TcpClient(_IPaddress, Convert.ToInt32(_Port));
ClassGlobal.SMSID = _SmsID;
string _result = SendToCAS(_IPaddr... | 44,991,753 | 6 | 2 | null | 2013-12-05 05:34:07.457 UTC | 13 | 2021-08-20 19:29:50.59 UTC | 2018-04-12 13:35:04.46 UTC | null | 888,472 | null | 2,626,016 | null | 1 | 28 | c#|linux|shell | 100,012 | <p>Of course it can be done and the process is extremely simple.</p>
<p>Here I am explaining the steps for Ubuntu Linux.</p>
<p>Open terminal:</p>
<p><kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>T</kbd> </p>
<p>Type </p>
<pre><code>gedit hello.cs
</code></pre>
<p>In the <code>gedit</code> window that opens paste the f... |
24,253,761 | How do you call an instance of a class in Python? | <p>This is inspired by a question I just saw, "Change what is returned by calling class instance", but was quickly answered with <code>__repr__</code> (and accepted, so the questioner did not actually intend to call the instance).</p>
<p>Now calling an instance of a class can be done like this:</p>
<pre><code>instanc... | 24,253,762 | 3 | 4 | null | 2014-06-16 23:40:55.823 UTC | 13 | 2021-10-27 00:57:20.41 UTC | 2017-04-24 19:49:44.033 UTC | null | 541,136 | null | 541,136 | null | 1 | 50 | python|class|call | 103,220 | <p>You call an instance of a class as in the following:</p>
<pre><code>o = object() # create our instance
o() # call the instance
</code></pre>
<p>But this will typically give us an error. </p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'object' object ... |
3,888,033 | How to convert string to xml file in java | <pre><code> <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><LoginResponse xmlns="http://tempuri.org/QuestIPhoneWebService/QuestI... | 3,888,207 | 2 | 2 | null | 2010-10-08 05:56:19.55 UTC | 3 | 2015-03-01 15:01:36.74 UTC | 2010-10-08 09:28:13.437 UTC | null | 257,629 | null | 426,344 | null | 1 | 12 | java|xml | 68,237 | <p>The below code converts a String to an XML document. Once you have the document, you can navigate the nodes or you can write to a file etc.</p>
<pre><code>import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public class Util {
public static Document stringToDom(String xml... |
28,540,598 | AngularJS pass string as function to use at ng-click | <p>I want to assign a javascript function to ng-click which name is sourced by a rest service.</p>
<pre><code><li ng-class="{ active: isActive('url')}" data-ng-repeat="menu in mb.data">
<a href="{{menu.href}}" data-ng-click="{{menu.javascript}}">{{menu.label}}</a>
</li>
</code></pre>
<p>Sad... | 28,541,100 | 2 | 6 | null | 2015-02-16 11:39:15.61 UTC | 6 | 2017-03-27 04:52:30.64 UTC | 2015-10-28 18:35:15.797 UTC | null | 2,435,473 | null | 1,298,461 | null | 1 | 17 | javascript|html|angularjs|angularjs-scope|angularjs-ng-click | 38,326 | <p>You can do something like this </p>
<p><strong>HTML</strong></p>
<pre><code> <div ng-controller="TodoCtrl">
<button ng-click="callFunction('testClick')">CLICK ME</button>
</div>
</code></pre>
<p><strong>Controller</strong></p>
<pre><code>function TodoCtrl($scope) {
$scope.ca... |
9,403,609 | In Symfony2, can the validation.yml file be split into multiple files using imports? | <p>Right now, I have a file called validation.yml with the validation of all the bundle's entities in one file.</p>
<p>validation.yml</p>
<pre><code>Blogger\BlogBundle\Entity\Comment
properties:
username:
- NotBlank:
message: You must enter your name
- MaxLength: 50... | 9,414,343 | 8 | 2 | null | 2012-02-22 21:47:52.907 UTC | 11 | 2019-07-02 10:33:14.88 UTC | 2016-02-26 12:43:42.85 UTC | null | 1,262,820 | null | 625 | null | 1 | 18 | php|symfony|yaml | 9,727 | <p>Add these lines in <code>load</code> method of <code>src/Blogger/BlogBundle/DependencyInjection/BloggerBlogExtension.php</code>.</p>
<pre><code>public function load(array $configs, ContainerBuilder $container)
{
//...
$yamlMappingFiles = $container->getParameter('validator.mapping.loader.yaml_files_loader.ma... |
16,415,827 | Get reviews from google map api | <p>I have to get reviews from Google map API. details are on this page.</p>
<p><a href="https://developers.google.com/places/documentation/details#PlaceDetailsResults" rel="noreferrer">https://developers.google.com/places/documentation/details#PlaceDetailsResults</a></p>
<p>the details will fetch from this page:- </p... | 46,839,598 | 5 | 0 | null | 2013-05-07 09:38:41.983 UTC | 14 | 2021-02-18 15:22:10.023 UTC | 2013-12-30 00:33:44.84 UTC | user1841626 | 881,229 | null | 1,671,234 | null | 1 | 26 | google-maps|google-plus | 49,297 | <p>A more recent way to do this:</p>
<p><code>https://maps.googleapis.com/maps/api/place/details/json?placeid={place_id}&key={api_key}</code></p>
<ul>
<li>place_id: <a href="https://developers.google.com/places/place-id" rel="noreferrer">https://developers.google.com/places/place-id</a></li>
<li>api_key: <a href=... |
16,244,601 | Vagrant reverse port forwarding? | <p>I'm working on a web services architecture. I've got some software that I need to run on the native host machine, not in Vagrant. But I'd like to run some client services on the guest.</p>
<p>Vagrant's <code>config.vm.forwarded_port</code> parameter will open a port on the host and send the data to the guest. But h... | 16,420,720 | 5 | 2 | null | 2013-04-26 20:20:46.91 UTC | 57 | 2015-12-24 16:20:16.093 UTC | null | null | null | null | 54,829 | null | 1 | 129 | vagrant|portforwarding | 49,518 | <p>When you run <code>vagrant ssh</code>, it's actually using this underlying command:</p>
<p><code>ssh -p 2222 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -o IdentitiesOnly=yes -i ~/.vagrant.d/insecure_private_key vagrant@127.0.0.1</code></p>
<p>SSH supports forwarding ports in the ... |
11,224,201 | Java - Exception in thread "main" java.lang.Error: Unresolved compilation problems | <p>I have some problem in my JDBC code. I am trying to connect through MySQL but it gives me an error. My error log is given below if you have some time.</p>
<pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problems:
BLOB cannot be resolved to a type
BLOB cannot be resolved to a t... | 11,224,433 | 2 | 2 | null | 2012-06-27 10:31:23.42 UTC | 0 | 2019-01-04 18:43:52.593 UTC | 2019-01-04 18:43:52.593 UTC | null | 6,214,491 | null | 1,439,243 | null | 1 | 4 | java|mysql|database|jakarta-ee|jdbc | 82,979 | <p>This error happens when you use Eclipse as IDE and try to run code that doesn't even compile. Check your <em>Problems</em> view in Eclipse, and fix the compilation errors before executing the application.</p> |
15,074,043 | iOS otool to detect private apis | <p>I am a first time ios developer and cannot find any documentation on private apis. So I have been searching for some type of tutorial on how to use otool. The only certain thing that I can find is that I had to download the command line tools through xcode preferences. I also keep seeing references to linking it to ... | 15,074,693 | 1 | 2 | null | 2013-02-25 18:41:48.71 UTC | 10 | 2013-02-25 19:18:38.227 UTC | null | null | null | null | 1,803,649 | null | 1 | 4 | ios|xcode|iphone-privateapi|otool | 14,444 | <h1>Otool usage</h1>
<p>Here is <a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/otool.1.html" rel="nofollow noreferrer">official documentation</a></p>
<p>Here is the question about otool usage:
<a href="https://stackoverflow.com/questions/5946756/how-to-use-otool">how to ... |
17,412,826 | Use mock location without setting it in settings | <p>I am writing an App which makes use of the location mocking possibility in android.</p>
<p>What I would like to achive is to mock my location without setting the "allow mock locations" flag in the developer options.</p>
<p>I know that it is possible, because is works with this app:
<a href="https://play.google.com... | 25,849,595 | 3 | 2 | null | 2013-07-01 20:11:49.113 UTC | 5 | 2016-08-06 21:48:45.81 UTC | 2013-07-02 08:50:27.9 UTC | null | 1,248,485 | null | 1,248,485 | null | 1 | 6 | java|android|gps|mocking|location | 72,692 | <p>I have decompiled <code>com.lexa.fakegps</code> you mentioned in question, and what it do like this:<br></p>
<pre><code>private int setMockLocationSettings() {
int value = 1;
try {
value = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ALLOW_MOCK_LOCATION);
Sett... |
19,310,700 | What is a rune? | <p>What is a <code>rune</code> in Go?</p>
<p>I've been googling but Golang only says in one line: <em><code>rune</code> is an alias for <code>int32</code></em>.</p>
<p>But how come integers are used all around like swapping cases?</p>
<p>The following is a function swapcase.
What is all the <code><=</code> and <c... | 19,311,218 | 11 | 3 | null | 2013-10-11 05:14:57.673 UTC | 72 | 2022-09-06 09:21:41.93 UTC | 2022-06-13 04:42:40.42 UTC | user6169399 | 527,702 | user2671513 | null | null | 1 | 302 | go|terminology|rune | 143,840 | <p><strong>Rune literals are just 32-bit integer values</strong> (<em>however they're untyped constants, so their type can change</em>). They represent unicode codepoints. For example, the rune literal <code>'a'</code> is actually the number <code>97</code>.</p>
<p>Therefore your program is pretty much equivalent to:<... |
19,599,361 | Append values to javascript dictionary | <p>I am trying to create the following data structure in javascript:</p>
<pre><code>d = {"foo": [3, 77, 100], "bar": [10], "baz": [99], "biff": [10]}
</code></pre>
<p>My starting data structure is a a list of dictionaries:</p>
<pre><code>input = [{"key": "foo", "val": 3}, {"key": "bar", "val": 10}, {"key": "foo", "v... | 19,599,436 | 7 | 4 | null | 2013-10-25 21:01:02.8 UTC | 1 | 2020-07-10 05:39:11.04 UTC | 2013-10-25 21:06:22 UTC | null | 1,255,817 | null | 1,255,817 | null | 1 | 11 | javascript | 63,201 | <pre><code>for (var i = 0; i < input.length; i++) {
var datum = input[i];
if (!d[datum.key]) {
d[datum.key] = [];
}
d[datum.key].push(datum.val);
}
</code></pre>
<p>FYI, you shouldn't use <code>for (var i in input)</code> to iterate over an array.</p> |
19,621,074 | Finding JavaScript memory leaks with Chrome | <p>I've created a very simple test case that creates a Backbone view, attaches a handler to an event, and instantiates a user-defined class. I believe that by clicking the "Remove" button in this sample, everything will be cleaned up and there should be no memory leaks.</p>
<p>A jsfiddle for the code is here: <a href=... | 19,726,918 | 9 | 5 | null | 2013-10-27 17:28:06.037 UTC | 121 | 2021-02-15 07:38:26.15 UTC | 2017-05-23 12:02:51.35 UTC | null | -1 | null | 2,153,271 | null | 1 | 173 | javascript|google-chrome|backbone.js|memory-leaks | 75,950 | <p>A good workflow to find memory leaks is the <strong>three snapshot</strong> technique, first used by Loreena Lee and the Gmail team to solve some of their memory problems. The steps are, in general:</p>
<ul>
<li>Take a heap snapshot.</li>
<li>Do stuff.</li>
<li>Take another heap snapshot.</li>
<li>Repeat the same s... |
17,325,006 | How to create a foreignkey reference with sqlalchemy | <p>Hi I am not able to understand how to make a foreignkey reference using sqlalchemy. I have created a new table client in my database:</p>
<pre><code>class Client(DeclarativeBase):
__tablename__ = 'client'
id = Column(Integer, primary_key=True)
user_id = Column(
Integer,
ForeignKey('us... | 17,330,019 | 1 | 0 | null | 2013-06-26 16:00:46.51 UTC | 12 | 2021-08-16 20:31:00.45 UTC | 2021-08-16 20:31:00.45 UTC | null | 792,066 | null | 765,836 | null | 1 | 21 | python|sqlalchemy | 29,346 | <p>You need to define a <a href="http://docs.sqlalchemy.org/en/latest/orm/tutorial.html#orm-tutorial-relationship" rel="noreferrer">relationship</a> between <code>User</code> and <code>Client</code> models:</p>
<pre><code>from sqlalchemy.orm import relationship
class Client(DeclarativeBase):
__tablename__ = 'cli... |
17,191,622 | Why would I not leave extglob enabled in bash? | <p>I just found out about the bash extglob shell option here:-
<a href="https://stackoverflow.com/questions/216995/how-can-i-use-inverse-or-negative-wildcards-when-pattern-matching-in-a-unix-linu">How can I use inverse or negative wildcards when pattern matching in a unix/linux shell?</a></p>
<p>All the answers that u... | 17,191,796 | 2 | 1 | null | 2013-06-19 12:49:04.173 UTC | 15 | 2017-01-12 01:17:24.667 UTC | 2017-05-23 12:26:23.92 UTC | null | -1 | null | 2,409,928 | null | 1 | 53 | bash | 13,349 | <p>No nasty surprises -- default-off behavior is only there for compatibility with traditional, standards-compliant pattern syntax.</p>
<hr />
<p>Which is to say: It's possible (albeit unlikely) that someone writing <code>fo+(o).*</code> <em>actually intended</em> the <code>+</code> and the parenthesis to be treated as... |
30,367,590 | Uncaught TypeError: Cannot read property 'mData' of undefined | <p>i followed <a href="https://stackoverflow.com/questions/1790065/how-to-put-multiple-jquery-datatables-in-one-page#1790065">this</a>
for enabling multiple tables(on same page) using DataTables plugin.
for manual tables it work but for dynamic created tables it shows the following error:</p>
<blockquote>
<p>Uncaugh... | 30,371,597 | 4 | 4 | null | 2015-05-21 07:45:24.65 UTC | 2 | 2019-08-14 00:17:39.207 UTC | 2017-05-23 12:25:29.747 UTC | null | -1 | null | 4,391,210 | null | 1 | 8 | javascript|php|jquery|jquery-datatables | 51,771 | <h3>CAUSE</h3>
<p>You are trying to initialize multiple table with the same options, the most important one is <code>aoColumns</code>, array holding column definitions. Your <code>aoColumns</code> array holds 3 items only, however the number of columns differ in each tables, that is why you receive an error. </p>
<p>... |
37,084,537 | How to clear the text field automatically | <p>I have a question about <code>UITextField()</code> in Swift. How can I clear the text in the text field when I click on it?</p>
<p>My <code>textField.text = "0"</code>. I want to automatically remove the number "0" when I click on the text field:</p>
<pre><code>import UIKit
class ViewController: UIViewController, ... | 37,084,618 | 8 | 4 | null | 2016-05-07 04:36:48.08 UTC | 8 | 2022-08-05 10:40:45.993 UTC | 2020-05-27 22:52:05.19 UTC | null | 128,421 | null | 6,116,829 | null | 1 | 19 | ios|swift|iphone|swift2|uitextfield | 59,735 | <p>Use this method,</p>
<p>If you want to manually clear the text field use this code:</p>
<pre><code>textField.text = ""
</code></pre>
<p>If you want the text field to empty when you begin editing, use the delegate method below:</p>
<pre><code>func textFieldDidBeginEditing(textField: UITextField) {
textField.t... |
22,991,387 | How to set default value for ASP.NET MVC DropDownList from model | <p>i am new in mvc. so i populate dropdown this way</p>
<pre><code>public ActionResult New()
{
var countryQuery = (from c in db.Customers
orderby c.Country ascending
select c.Country).Distinct();
List<SelectListItem> countryList = new List<SelectListItem... | 22,991,766 | 3 | 4 | null | 2014-04-10 14:44:45.293 UTC | 2 | 2016-11-25 16:31:48.553 UTC | null | null | null | null | 508,127 | null | 1 | 5 | asp.net-mvc | 57,509 | <p>Well this is not a great way to do this.</p>
<p>Create a ViewModel that will hold everything you want to be rendered at the view.</p>
<pre><code>public class MyViewModel{
public List<SelectListItem> CountryList {get; set}
public string Country {get; set}
public MyViewModel(){
CountryList = new ... |
5,514,367 | Why are there two kinds of JavaScript strings? | <p>This one just stabbed me hard. I don't know if it's the case with all browsers (I don't have any other competent browser to test with), but at least Firefox has two kind of string objects.</p>
<p>Open up the Firebugs console and try the following:</p>
<pre><code>>>> "a"
"a"
>>> new String("a")
St... | 5,514,409 | 3 | 5 | null | 2011-04-01 13:54:36.21 UTC | 5 | 2011-08-16 01:00:38.003 UTC | 2011-04-01 14:00:47.283 UTC | null | 251,153 | null | 251,153 | null | 1 | 37 | javascript|string | 835 | <p>There are two types of strings in Javascript -- literal strings and String objects. They do behave a little differently. The main difference between the two is that you can add additional methods and properties to a String object. For instance:</p>
<pre><code>var strObj = new String("object mode");
strObj.string_m... |
9,384,758 | What is the 'Execution Context' in JavaScript exactly? | <p>My title pretty much sums it all.</p>
<p>Can anyone enlighten me on...</p>
<p><strong>"What is the 'Execution Context' in JavaScript?"</strong></p>
<p>and on how it relates to 'this,' hoisting, prototype chaining, scope and garbage collection?</p> | 9,384,894 | 9 | 3 | null | 2012-02-21 20:36:38.307 UTC | 54 | 2021-03-04 05:25:32.903 UTC | 2013-12-09 09:39:54.127 UTC | null | 985,895 | null | 985,895 | null | 1 | 90 | javascript | 48,791 | <p>You're asking about several different concepts that aren't very closely related. I'll try to briefly address each.</p>
<hr>
<p><em>Execution context</em> is a concept in the language spec that—in layman's terms—roughly equates to the 'environment' a function executes in; that is, variable scope (and t... |
9,184,141 | How do you get centered content using Twitter Bootstrap? | <p>I'm trying to follow a very basic example. Using the <a href="http://getbootstrap.com/css/#grid" rel="noreferrer">starter page and the grid system</a>, I was hoping the following:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre c... | 9,184,443 | 24 | 4 | null | 2012-02-07 21:21:55.823 UTC | 80 | 2022-07-24 15:57:32.843 UTC | 2017-10-28 10:09:54.247 UTC | null | 63,550 | null | 1,011,816 | null | 1 | 585 | html|css|twitter-bootstrap | 954,780 | <h2>This is for Text Centering (<em>which is what the question was about</em>)</h2>
<p>For other types of content, see <a href="https://stackoverflow.com/a/13099189/2812842">Flavien's answer</a>.</p>
<p><strong>Update: Bootstrap 2.3.0+ Answer</strong></p>
<p>The original answer was for an early version of bootstrap.... |
18,406,713 | How to conditionally enable or disable scheduled jobs in Spring? | <p>I am defining scheduled jobs with cron style patterns in Spring, using the <code>@Scheduled</code> annotation.</p>
<p>The cron pattern is stored in a config properties file. Actually there are two properties files: one default config, and one profile config that is environment dependent (e.g. dev, test, prod custom... | 18,406,954 | 11 | 4 | null | 2013-08-23 15:36:28.18 UTC | 18 | 2021-04-21 18:24:55.687 UTC | 2018-09-11 11:19:05.427 UTC | null | 1,481,116 | null | 315,677 | null | 1 | 97 | java|spring|cron|scheduled-tasks | 136,114 | <pre><code>@Component
public class ImagesPurgeJob implements Job {
private Logger logger = Logger.getLogger(this.getClass());
@Value("${jobs.mediafiles.imagesPurgeJob.enable}")
private boolean imagesPurgeJobEnable;
@Override
@Transactional(readOnly=true)
@Scheduled(cron = "${jobs.mediafiles.i... |
18,414,804 | android edittext remove focus after clicking a button | <p>I have an Activity with an EditText and a Button.
When the User clicks on the EditText, the keyboard is shown and he can type in some Text - fine.
But when the user clicks on the Button I want the EditText to be no more in focus i.e. the keyboard hides til the user clicks again on the EditText. </p>
<p>What can I ... | 18,415,233 | 12 | 2 | null | 2013-08-24 04:02:58.007 UTC | 7 | 2021-12-15 09:13:11.667 UTC | 2013-12-26 02:44:27.433 UTC | null | 2,554,605 | null | 2,660,921 | null | 1 | 24 | android|android-edittext | 62,632 | <p>Put this in your button listener:</p>
<pre class="lang-java prettyprint-override"><code>InputMethodManager inputManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
</code></pre>
... |
15,195,578 | how to explain return statement within constructor? | <p>as far as i know , the constructor return nothing , not even void , </p>
<p>and also</p>
<pre><code>return ;
</code></pre>
<p>inside any method means to return void .</p>
<p>so in my program</p>
<pre><code>public class returnTest {
public static void main(String[] args) {
returnTest obj = new retur... | 15,195,610 | 6 | 4 | null | 2013-03-04 06:09:43.527 UTC | 8 | 2018-06-01 01:15:59.567 UTC | 2013-03-04 06:28:05.503 UTC | null | 1,283,215 | null | 1,283,215 | null | 1 | 14 | java|constructor|return | 22,148 | <p><code>return</code> in a constructor just jumps out of the constructor at the specified point. You might use it if you don't need to fully initialize the class in some circumstances.</p>
<p>e.g.</p>
<pre><code>// A real life example
class MyDate
{
// Create a date structure from a day of the year (1..366)
... |
43,804,503 | Jackson Converting String to Object | <p><strong>Link.java</strong></p>
<pre><code>@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "rel", "href","method" })
public class Link {
@JsonProperty("rel")
private String rel;
@JsonProperty("href")
private String href;
@JsonProperty("method")
private Method method;
@Ov... | 43,933,606 | 1 | 4 | null | 2017-05-05 12:05:10.243 UTC | 2 | 2017-05-12 09:02:30.963 UTC | 2017-05-05 12:13:57.12 UTC | null | 3,162,450 | null | 3,162,450 | null | 1 | 10 | java|json|spring-boot|jackson|fasterxml | 46,653 | <p>Just putting the comment by @pvpkiran in an answer.</p>
<p>Use <a href="https://fasterxml.github.io/jackson-databind/javadoc/2.7/com/fasterxml/jackson/databind/ObjectMapper.html" rel="noreferrer">ObjectMapper</a> class from <em>com.fasterxml.jackson.databind</em></p>
<pre><code>ObjectMapper objectMapper = new Obje... |
8,012,799 | Do we still need to use <font> tags in HTML emails? | <p>I'm taking over from someone who builds our HTML emails and the templates are filled with font tags. Is this really necessary? I know CSS support isn't great in emails, but if I set an inline style for text on the container <code><td></code> like this...</p>
<pre><code><td style="font-family:Arial, Helveti... | 8,012,836 | 2 | 0 | null | 2011-11-04 16:43:36.28 UTC | 12 | 2015-11-09 18:50:18.98 UTC | 2011-11-04 16:52:14.593 UTC | null | 20,578 | null | 467,859 | null | 1 | 36 | html|email|html-email | 32,831 | <p>Your assumption is correct. They're unnecessary. Also, technically the <code><font></code> tag was deprecated starting with HTML 4, so you might as well remove it for that sake alone.</p>
<p>If you needed inline css styles on specific text, you would be better of using an inline-styled <code><span></cod... |
8,749,186 | How to detect if a long type is actually NULL? | <p>We have a nullable (type long) column (named referral) in our MySQL database. We use hibernate for ORM.</p>
<p>I am trying to get the value of the column for a given member. Some are null, and if its not, its an id that points to another member whose is the referrer.</p>
<p>The problem is in the java code I am try... | 8,749,227 | 4 | 3 | null | 2012-01-05 20:19:56.063 UTC | null | 2020-06-18 23:17:03.06 UTC | 2012-01-05 20:41:38.317 UTC | null | 358,834 | null | 358,834 | null | 1 | 6 | java|hibernate|nullpointerexception|long-integer | 45,174 | <p>Assuming <code>member.getReferral()</code> returns a <code>Long</code>, use:</p>
<pre><code>if (member.getReferral() != null)
</code></pre>
<p>In Hibernate, if you want to be able to detect nullability in a property, you must not use <em>primitive types</em>, because they will always have a default value <code>0</... |
5,159,352 | Error converting data type bigint to varchar. | <pre><code>DECLARE @ID BIGINT
set @ID = 1323
UPDATE School
SET RegistrationFee = 'fee_' + @ID --<<<<error
Where SchoolRegistrationId = 123
</code></pre>
<p>Error converting data type varchar to bigint.</p> | 5,159,362 | 4 | 0 | null | 2011-03-01 19:30:35.12 UTC | 1 | 2019-03-29 15:51:51.94 UTC | 2014-05-28 18:39:07.78 UTC | null | 1,378,356 | null | 275,390 | null | 1 | 12 | sql-server|sql-server-2008 | 57,803 | <p>You need to explicitly convert your bigint to varchar:</p>
<pre><code>DECLARE @ID BIGINT
set @ID = 1323
UPDATE School
SET RegistrationFee = 'fee_' + CAST(@ID AS VARCHAR(15))
WHERE SchoolRegistrationId = 123
</code></pre>
<p>T-SQL will not do this automatically for you - you need to be explicit and clear about i... |
5,356,133 | How to replace underscores with spaces using a regex in Javascript | <p>How can I replace underscores with spaces using a regex in Javascript?</p>
<pre><code>var ZZZ = "This_is_my_name";
</code></pre> | 5,356,251 | 4 | 4 | null | 2011-03-18 18:13:21.077 UTC | 5 | 2012-08-15 13:48:18.83 UTC | 2011-03-18 18:48:48.717 UTC | null | 19,719 | null | 603,380 | null | 1 | 24 | javascript|regex|replace | 71,745 | <p>If it is a JavaScript code, write this, to have transformed string in <code>ZZZ2</code>:</p>
<pre><code>var ZZZ = "This_is_my_name";
var ZZZ2 = ZZZ.replace(/_/g, " ");
</code></pre>
<p>also, you can do it in less efficient, but more funky, way, without using regex:</p>
<pre><code>var ZZZ = "This_is_my_name";
var ... |
5,085,656 | How to get the current port number in Flask? | <p>Using <a href="http://flask.pocoo.org/" rel="noreferrer">Flask</a>, how can I get the current port number that flask is connected to? I want to start a server on a random port using port 0 but I also need to know which port I am on.</p>
<p><strong>Edit</strong></p>
<p>I think I've found a work around for my issue,... | 5,089,963 | 5 | 1 | null | 2011-02-23 00:14:43.2 UTC | 12 | 2018-08-24 22:03:16.21 UTC | 2011-02-23 08:03:41.1 UTC | null | 477,933 | null | 477,933 | null | 1 | 27 | python|networking|web-frameworks|flask | 33,679 | <p>You can't easily get at the server socket used by Flask, as it's hidden in the internals of the standard library (Flask uses Werkzeug, whose development server is based on the stdlib's <code>BaseHTTPServer</code>).</p>
<p>However, you can create an ephemeral port yourself and then close the socket that creates it, ... |
5,322,642 | SSIS - Flat file always ANSI never UTF-8 encoded | <p>Have a pretty straight forward SSIS package:</p>
<ul>
<li>OLE DB Source to get data via a view, (all string columns in db table nvarchar or nchar).</li>
<li>Derived Column to format existing date and add it on to the dataset, (data type DT_WSTR).</li>
<li>Multicast task to split the dataset between:
<ul>
<li>OLE D... | 5,518,350 | 6 | 2 | null | 2011-03-16 08:26:01.223 UTC | 8 | 2020-11-18 18:54:03.67 UTC | null | null | null | null | 298,426 | null | 1 | 21 | utf-8|ssis|flat-file | 69,551 | <p>OK - seemed to have found an acceptable work-around on <a href="http://social.msdn.microsoft.com/forums/en-us/sqlintegrationservices/thread/9B68C357-A5B4-47BF-8EFD-A05945210CA2" rel="nofollow">SQL Server Forums</a>. Essentially I had to create two UTF-8 template files, use a File Task to copy them to my destination ... |
5,227,295 | How do I delete all lines in a file starting from after a matching line? | <p>I have a file which is made up of several lines of text:</p>
<pre><code>The first line
The second line
The third line
The fourth line
</code></pre>
<p>I have a string which is one of the lines: <code>The second line</code></p>
<p>I want to delete the string and all lines after it in the file, so it will delete <c... | 5,227,429 | 6 | 4 | null | 2011-03-08 01:23:43.233 UTC | 32 | 2018-01-25 18:21:03.867 UTC | 2011-10-27 14:44:35.76 UTC | null | 115,845 | null | 500,281 | null | 1 | 107 | linux|bash|sed | 110,319 | <p>If you don't want to print the matched line (or any following lines):</p>
<pre><code>sed -n '/The second line/q;p' inputfile
</code></pre>
<p>This says "when you reach the line that matches the pattern quit, otherwise print each line". The <code>-n</code> option prevents implicit printing and the <code>p</code> co... |
5,416,872 | Using export keyword with templates | <p>As i Understand "export" keyword can be used so that one can expose template classes or function signatures through an header file and abstract the actual implementation in a library file.<br>
Can anyone please provide a practical sample program which shows how to do this?<br>
Are there any disadvantages or importan... | 5,416,981 | 7 | 5 | null | 2011-03-24 09:07:26.817 UTC | 8 | 2022-09-19 12:01:18.31 UTC | 2011-03-24 09:38:37.32 UTC | null | 452,307 | null | 452,307 | null | 1 | 38 | c++|templates|c++11|export | 31,269 | <p><strong>Attention: This answer is about the historical use of <code>export</code> pre-C++20; C++20 repurposes the keyword for use in modules.</strong></p>
<p>First of all: most compilers (including gcc, Clang and Visual Studio) do not support the <code>export</code> keyword.</p>
<p>It has been implemented in a singl... |
5,433,977 | What about Line Breaks in Jade? | <p>I'm pretty sure that this is a no-brainer but I didn't find any snippet of sample code.
What's the best way to insert line breaks (aka the good ol' br/)?</p>
<p>As far as I can see if I put a "br" at the beginning of an empty line, it is rendered as <code><br/></code> but if I have to show several lines of te... | 6,752,736 | 12 | 2 | null | 2011-03-25 14:43:25.13 UTC | 11 | 2022-01-24 17:01:12.83 UTC | 2015-05-23 09:03:27.35 UTC | null | 2,476,755 | null | 162,293 | null | 1 | 73 | node.js|pug | 81,313 | <p>The cleanest and easiest solution is to use the style attribute <code>white-space: pre;</code> eg:</p>
<pre><code>.poem
p(style='white-space:pre;')
| Si chiamava Tatiana, la sorella…
| Noi siamo i primi, almeno lo crediamo
| Che un tale nome arditamente nella
| Cornice d’un ro... |
5,207,162 | Define a fixed-size list in Java | <p>Is it possible to define a list with a fixed size that's 100? If not why isn't this available in Java?</p> | 5,968,535 | 14 | 8 | null | 2011-03-05 22:17:24.193 UTC | 16 | 2022-08-11 17:55:43.057 UTC | 2017-07-08 14:53:29.99 UTC | null | 964,243 | null | 184,730 | null | 1 | 72 | java|list|collections | 177,211 | <h1><code>FixedSizeList</code></h1>
<p><strong>Yes</strong>,</p>
<p>The <a href="https://commons.apache.org/collections/" rel="nofollow noreferrer"><em>Apache Commons</em></a> library provides the <a href="https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/list/FixedSizeList.h... |
5,309,190 | android pick images from gallery | <p>I want to create a picture chooser from gallery. I use code </p>
<pre><code> intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, TFRequestCodes.GALLERY);
</code></pre>
<p>My problem is that in this activity and video files are disp... | 5,309,217 | 19 | 2 | null | 2011-03-15 08:33:46.763 UTC | 88 | 2022-09-17 11:25:48.057 UTC | 2013-03-12 15:20:23.647 UTC | null | 489,741 | null | 517,558 | null | 1 | 235 | android|gallery|action | 414,650 | <p>Absolutely. Try this:</p>
<pre><code>Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
</code></pre>
<p>Don't forget also to create the constant <strong>PICK_IMAGE</strong>, so yo... |
5,014,632 | How can I parse a YAML file from a Linux shell script? | <p>I wish to provide a structured configuration file which is as easy as possible for a non-technical user to edit (unfortunately it has to be a file) and so I wanted to use YAML. I can't find any way of parsing this from a Unix shell script however. </p> | 13,179,142 | 23 | 5 | null | 2011-02-16 09:25:38.033 UTC | 111 | 2022-07-05 12:26:50.797 UTC | null | null | null | null | 190,822 | null | 1 | 309 | shell|yaml | 393,425 | <p>My use case may or may not be quite the same as what this original post was asking, but it's definitely similar.</p>
<p>I need to pull in some YAML as bash variables. The YAML will never be more than one level deep.</p>
<p>YAML looks like so:</p>
<pre><code>KEY: value
ANOTHER_KEY: another_va... |
16,718,699 | Map Many to Many relationship without navigation property | <p>Is is possible to map a many to many relationship without having a navigation property on one of the ends? For example I have some widgets and some users who can star particular widgets. I'd like to be able to see what widgets a user cares stars, but I don't really care about seeing all the users who have starred a ... | 16,719,203 | 1 | 0 | null | 2013-05-23 16:01:58.387 UTC | 10 | 2013-05-23 16:27:49.863 UTC | null | null | null | null | 228,014 | null | 1 | 13 | ef-code-first|entity-framework-5 | 8,271 | <p>You can and this case <em>must</em> define the many-to-many relationship with Fluent API:</p>
<pre><code>modelBuilder.Entity<User>()
.HasMany(u => u.StarredWidgets)
.WithMany() // <- no parameter here because there is no navigation property
.Map(m =>
{
m.MapLeftKey("UserId");
... |
41,458,859 | How do you create a boolean mask for a tensor in Keras? | <p>I am building a custom metric to measure the accuracy of one class in my multi-class dataset during training. I am having trouble selecting the class. </p>
<p>The targets are one hot (e.g: the class <code>0</code> label is <code>[1 0 0 0 0]</code>):</p>
<pre><code>from keras import backend as K
def single_class_a... | 41,717,938 | 1 | 3 | null | 2017-01-04 07:58:47.49 UTC | 12 | 2020-01-22 14:40:24.06 UTC | 2020-01-22 14:40:24.06 UTC | null | 3,924,118 | null | 4,013,781 | null | 1 | 20 | python|tensorflow|neural-network|keras | 8,948 | <p>Note that when talking about the <em>accuracy</em> of one class one may refer to either of the following (not equivalent) two amounts:</p>
<ul>
<li>The <strong>recall</strong>, which, for class <em>C</em>, is the ratio of examples labelled with class <em>C</em> that are predicted to have class <em>C</em>.</li>
<li>... |
12,112,259 | how to reuse stringstream | <p>These threads do NOT answer me:</p>
<p><a href="https://stackoverflow.com/questions/7623650/">resetting a stringstream</a></p>
<p><a href="https://stackoverflow.com/questions/20731/">How do you clear a stringstream variable?</a></p>
<pre class="lang-cpp prettyprint-override"><code>std::ifstream file( szFIleName_p );... | 12,112,355 | 6 | 1 | null | 2012-08-24 15:21:55.573 UTC | 2 | 2021-03-04 05:07:49.477 UTC | 2021-03-04 05:07:49.477 UTC | null | 65,863 | null | 1,513,481 | null | 1 | 22 | c++|file|parsing|text|stringstream | 38,468 | <p>You didn't <code>clear()</code> the stream after calling <code>str("")</code>. Take another look at <a href="https://stackoverflow.com/questions/20731/in-c-how-do-you-clear-a-stringstream-variable">this answer</a>, it also explains why you should reset using <code>str(std::string())</code>. And in your case, you cou... |
12,168,587 | How to synchronize multiple Backbone.js fetches? | <p>I’m a bit new to Backbone.js, but am already impressed by everything it can do for me, and am trying to learn the patterns and best practices now.</p>
<p>I have two collections:</p>
<pre><code>var CollA = Backbone.Collection.extend({
model: ModelA,
url: '/urlA'
});
var CollB = Backbone.Collection.extend({... | 12,168,628 | 3 | 0 | null | 2012-08-28 22:44:56.673 UTC | 12 | 2016-05-19 17:01:53.633 UTC | null | null | null | null | 49,951 | null | 1 | 24 | concurrency|backbone.js | 12,220 | <p>If you're using jQuery, use <code>when</code>:</p>
<pre><code>$.when(collA.fetch(),collB.fetch()).done(function(){
//success code here.
});
</code></pre>
<p>Background:</p>
<ul>
<li><a href="http://api.jquery.com/jQuery.when/">http://api.jquery.com/jQuery.when/</a></li>
<li><a href="http://documentcloud.githu... |
12,569,568 | Shopping cart persistence: $_SESSION or browser cookie? | <p>On an e-commerce site with no username/login to persist cart data, would it be better to use the PHP $_SESSION variable or a browser cookie to persist items in the shopping cart? I am leaning toward $_SESSION since cookies can be disabled, but would like to hear thoughts from you.</p>
<p>Thank you in advance for yo... | 12,569,786 | 6 | 5 | null | 2012-09-24 16:58:28.03 UTC | 25 | 2015-08-06 06:58:02.497 UTC | null | null | null | user1193509 | null | null | 1 | 35 | php|cookies|session-variables | 34,319 | <h2>Neither</h2>
<p>No large sites would dare store a user's cart in a session or cookie - that data is just to valuable.</p>
<p>What customers are buying, when they select items, how many they purchase, why they don't finish the checkout, etc.. are all <em>very, very</em> important to your business.</p>
<p>Use a da... |
19,035,186 | How to select element using XPATH syntax on Selenium for Python? | <p>consider following HTML:</p>
<pre><code><div id='a'>
<div>
<a class='click'>abc</a>
</div>
</div>
</code></pre>
<p>I want to click abc, but the wrapper div could change, so</p>
<pre><code>driver.get_element_by_xpath("//div[@id='a']/div/a[@class='click']")
</code></pre>
... | 19,035,495 | 2 | 7 | null | 2013-09-26 17:51:20.063 UTC | 9 | 2021-02-11 13:02:28.077 UTC | 2019-05-29 16:42:25.237 UTC | null | 5,780,109 | null | 2,534,633 | null | 1 | 34 | python|xpath|selenium | 172,547 | <p><strong>HTML</strong></p>
<pre class="lang-html prettyprint-override"><code><div id='a'>
<div>
<a class='click'>abc</a>
</div>
</div>
</code></pre>
<p>You could use the <strong>XPATH</strong> as :</p>
<pre class="lang-xpath prettyprint-override"><code>//div[@id='a']//a[... |
24,408,143 | WAMP: Missing http://localhost/ in urls , wrong wamp projects links | <p>I have a problem with Wamp which never happened to me before, cannot find what's wrong. I have a few projects located in my www folder ( running windows 7 ). </p>
<p>My hostfile has the line <code>127.0.0.1 localhost</code> uncommented </p>
<p>When I go to <code>http://localhost/</code> or <code>http://127.0.0.1/<... | 27,345,153 | 14 | 5 | null | 2014-06-25 12:02:45.623 UTC | 7 | 2022-06-21 17:28:00.997 UTC | 2014-07-01 20:21:04.763 UTC | null | 3,679,739 | null | 1,143,651 | null | 1 | 12 | localhost|wamp|local|wampserver | 47,936 | <p>After thorough research, I found out the solution which worked for me as well.. </p>
<pre><code>open wamp/www/index.php.
</code></pre>
<p>Change this line:</p>
<pre><code>$suppress_localhost = true;
</code></pre>
<p>To :</p>
<pre><code>$suppress_localhost = false;
</code></pre> |
3,634,023 | Should I use List[A] or Seq[A] or something else? | <p>I was writing a class that contained some functional-esque methods. First I wrote them using List as parameters and return types. Then I thought "Hey, you could also use a more generic type!" so I replaced the Lists with Seq, hoping that I could make my stuff faster one day by feeding them something else than lists.... | 3,640,446 | 3 | 1 | null | 2010-09-03 08:13:02.23 UTC | 10 | 2013-09-30 11:24:05.353 UTC | 2013-09-30 11:24:05.353 UTC | null | 108,915 | null | 108,915 | null | 1 | 16 | design-patterns|scala | 7,948 | <p>I think, in general, you should use <code>Seq</code> for your parameters and design your methods to work efficiently with <code>List</code>. This way your methods will work ok with most <code>Seq</code> implementations and you will not have to convert your seqs prior to use your methods.</p>
<p><strong>Edit</strong... |
3,664,440 | Android - how to intercept a form POST in android WebViewClient on API level 4 | <p>I have a <code>WebViewClient</code> attached to my <code>WebView</code> like so:</p>
<pre><code>webView.setWebViewClient(new MyWebViewClient());
</code></pre>
<p>Here is my implementation of <code>MyWebViewClient</code>:</p>
<pre><code>private class MyWebViewClient extends WebViewClient {
@Override
publi... | 11,562,391 | 3 | 4 | null | 2010-09-08 03:23:42.607 UTC | 8 | 2014-09-05 03:01:00.237 UTC | 2014-09-05 03:01:00.237 UTC | null | 1,725,980 | null | 409,127 | null | 1 | 32 | android|forms|post|webviewclient | 31,528 | <p>This is known issue, that <code>shouldOverrideUrlLoading</code> don't catch POST. See <a href="http://code.google.com/p/android/issues/detail?id=9122" rel="noreferrer">http://code.google.com/p/android/issues/detail?id=9122</a> for details. </p>
<p>Use GET! I personally tried using POST, because I expected some limi... |
3,479,737 | Sinatra - API - Authentication | <p>We going to develop a little API application in Sinatra. What are the authentication options available to secure the API calls?</p> | 3,482,605 | 3 | 0 | null | 2010-08-13 18:37:17.657 UTC | 46 | 2020-01-28 17:43:46.997 UTC | 2014-03-26 11:18:01.863 UTC | null | 23,855 | null | 170,311 | null | 1 | 59 | api|authentication|sinatra | 14,780 | <p>Sinatra has no built-in authentication support. There are some gems available, but most are designed for user authentication (i.e. for a website). For an API, they seem like overkill. It’s easy enough to make your own. Simply check the request params in each of your routes to see if they contain a valid API key, and... |
36,794,433 | Python: using multiprocessing on a pandas dataframe | <p>I want to use <code>multiprocessing</code> on a large dataset to find the distance between two gps points. I constructed a test set, but I have been unable to get <code>multiprocessing</code> to work on this set.</p>
<pre><code>import pandas as pd
from geopy.distance import vincenty
from itertools import combinatio... | 36,851,214 | 4 | 10 | null | 2016-04-22 12:54:24.533 UTC | 29 | 2022-05-17 03:19:31.227 UTC | 2016-04-22 16:17:14.893 UTC | null | 2,213,669 | null | 2,213,669 | null | 1 | 52 | python|pandas|multiprocessing | 95,600 | <h2>What's wrong</h2>
<p>This line from your code:</p>
<pre><code>pool.map(calc_dist, ['lat','lon'])
</code></pre>
<p>spawns 2 processes - one runs <code>calc_dist('lat')</code> and the other runs <code>calc_dist('lon')</code>. Compare the first example in <a href="https://docs.python.org/2.7/library/multiprocessing... |
26,225,191 | Breakpoint debugging minfied/mangled/compiled variables | <p>Working on building JavaScript sourcemaps into my workflow and I've been looking for some documentation on a particular part of debugging source maps. In the picture below I'm running compressed Javascript code, but through the magic of source maps Chrome debugger was able to reconstruct the seemingly uncompressed c... | 36,050,428 | 3 | 6 | null | 2014-10-06 21:31:37.31 UTC | 12 | 2016-03-17 02:09:24.39 UTC | 2015-09-17 19:03:27.657 UTC | null | 1,506,980 | null | 1,506,980 | null | 1 | 49 | javascript|google-chrome|chromium|source-maps|babeljs | 2,772 | <p>Looks like it's been addressed and will become available <a href="https://codereview.chromium.org/1770263002" rel="nofollow">in the next Chromium update</a></p> |
11,217,832 | how to run a MySQL query using JavaScript | <p>I want to run MySQL query's on command without reloading the page. I think JavaScript can do this but i am unsure how. What i want to do is have a form with an return id field and when you fill out the form once with the return id and come back later and use that return id and it fills in in a lot of the content for... | 11,217,844 | 6 | 1 | null | 2012-06-27 00:34:29.717 UTC | 3 | 2021-08-31 06:40:08.85 UTC | null | null | null | null | 1,399,388 | null | 1 | 7 | javascript|mysql | 66,143 | <p>Javascript cannot run MySQL Queries itself; however, you can use <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">ajax</a> to make a call to the server to retrieve the data. I like to use jQuery's <a href="http://api.jquery.com/jQuery.ajax/" rel="noreferrer">ajax()</a> for my ajax needs... |
11,406,628 | VBA code doesn't run when cell is changed by a formula | <p><strong>Worksheet A</strong> has ranges of data that are collected from <strong>Worksheet B</strong>. <strong>Worksheet A</strong> has a macro that calculates if the data is above a value then calls an email module to email selected users. </p>
<p>When the data is manually input on <strong>Worksheet A</strong> t... | 11,409,569 | 2 | 0 | null | 2012-07-10 04:30:39.36 UTC | 11 | 2014-01-06 07:33:23.397 UTC | null | null | null | null | 1,402,361 | null | 1 | 9 | excel|vba|worksheet | 52,621 | <p>To capture the changes by a formula you have to use the <code>Worksheet_Calculate()</code> event. To understand how it works, let's take an example.</p>
<ol>
<li>Create a New Workbook.</li>
<li>In Sheet1 Cell A1, put this formula <code>=Sheet2!A1+1</code></li>
</ol>
<p>Now In a module paste this code</p>
<pre><co... |
11,328,909 | UIImagePickerController tutorial? | <p>I am currently developing an application and I need to be able when pressing a button to open the camera and take a snapshot that I will attach to a .json file and send to my server.
I am searching on google and StackOverflow for the last couple of hours but all the tutorials seem very old (08'-09') or not match my ... | 11,329,034 | 4 | 0 | null | 2012-07-04 12:15:10.917 UTC | 5 | 2016-04-18 17:58:31.383 UTC | 2016-04-18 17:58:31.383 UTC | null | 1,192,728 | user1498477 | null | null | 1 | 10 | ios|objective-c|swift|class|uiimagepickercontroller | 43,669 | <p>Well if you google something like:</p>
<blockquote>
<p>UIImagePickerController and take snapshot put in json and send to server</p>
</blockquote>
<p>Will be a bit hard. So, use <a href="http://blog.hanpo.tw/2012/01/uiimagepickercontroller-and-simple.html" rel="noreferrer">this</a> tutorial for the <code>UIImageP... |
11,336,713 | How do I create an expression tree for run time sorting? | <p>Using Entity Framework 4, I'm trying to implement dynamic sorting based on a collection of member names. Basically, the user can select fields to sort and the order of the sorting. I've looked at expression tree examples and can't piece this together. Here are some details:</p>
<p>Collection of column names:</p>... | 11,337,472 | 2 | 0 | null | 2012-07-05 00:49:04.177 UTC | 10 | 2022-07-22 15:41:40.19 UTC | null | null | null | null | 1,376,876 | null | 1 | 14 | c#|entity-framework-4|lambda | 5,900 | <p>First you need the <code>OrderBy</code> extension method that @Slace wrote <a href="https://stackoverflow.com/questions/307512/how-do-i-apply-orderby-on-an-iqueryable-using-a-string-column-name-within-a-gene">here</a>. All credit to <a href="https://stackoverflow.com/users/11388/slace">Slace</a> for an awesome piece... |
10,969,366 | vim - automatically formatting golang source code when saving | <p>I'm using vim with the <a href="https://github.com/jnwhiteh/vim-golang">vim-golang</a> plugin. This plugin comes with <a href="https://github.com/jnwhiteh/vim-golang/blob/master/ftplugin/go/fmt.vim">a function called :Fmt</a> that "reformats" the source code using <a href="http://gofmt.com/">gofmt</a>, a command-lin... | 10,969,574 | 3 | 0 | null | 2012-06-10 14:12:17.38 UTC | 10 | 2020-12-29 18:58:30.03 UTC | null | null | null | null | 312,586 | null | 1 | 28 | go|vim | 14,293 | <p>The <code>FileType</code> event doesn't fire on buffer writes; <code>BufWritePre</code> is the correct one, but you need to provide a file pattern, e.g. <code>*.go</code>:</p>
<pre><code>autocmd BufWritePre *.go Fmt
</code></pre>
<p>The only downside is that this duplicates the detection of the <em>go</em> filetyp... |
10,902,643 | Can't Activate WCF service | <p>I'm working over WCF and it worked fine on localhost. After I placed it on the production server, it thows an exception </p>
<blockquote>
<p>The requested service, '<a href="http://global-kazway.kz/Service1.svc" rel="noreferrer">http://global-kazway.kz/Service1.svc</a>' could
not be activated. See the server's ... | 10,902,740 | 7 | 1 | null | 2012-06-05 18:19:06.677 UTC | 3 | 2020-05-12 15:44:20.207 UTC | 2018-03-14 07:59:03.19 UTC | null | 3,077,495 | null | 1,184,452 | null | 1 | 28 | wcf | 84,720 | <p>First step in troubleshooting a WCF application is to bring up a browser and type in the service URI. So based on the client: you'd navigate to <a href="http://global-kazway.kz/Service1.svc" rel="noreferrer">http://global-kazway.kz/Service1.svc</a></p>
<p>Now see what kind of results you get. Exception? The serv... |
11,089,732 | Display image from blob using javascript and websockets | <p>I'm currently working on a WebSocket application that is displaying images send by a C++ server.
I've seen a couple of topics around there but I can't seem to get rid of this error in Firefox:</p>
<blockquote>
<p>Image corrupt or truncated: data:image/png;base64,[some data]</p>
</blockquote>
<p>Here's the Javasc... | 11,092,371 | 6 | 4 | null | 2012-06-18 19:31:40.447 UTC | 20 | 2021-12-25 09:47:12.41 UTC | 2017-05-23 12:10:31.1 UTC | null | -1 | null | 1,464,608 | null | 1 | 32 | javascript|html|websocket|blob|filereader | 79,008 | <p>I think the cleanest solution would be to change the base64 encoder to operate directly on a Uint8Array instead of a string.</p>
<p>Important: You'll need to set the binaryType of the web socket to "arraybuffer" for this. </p>
<p>The onmessage method should look like this:</p>
<pre><code>socket.onmessage = functi... |
11,102,645 | Java Serialization vs JSON vs XML | <p>I am wondering what serialized mechanism should we choose when dealing with object transferring over the network. What are the pros and cons ?</p>
<p>I know most of the time we use <code>JSON</code> or <code>XML</code> for <code>AJAX</code> since the transfer format are pretty much <code>Javascript</code> format, a... | 11,103,591 | 5 | 0 | null | 2012-06-19 14:01:44.577 UTC | 14 | 2020-09-21 23:07:12.287 UTC | 2019-04-12 20:55:50.343 UTC | null | 4,574,309 | null | 1,389,813 | null | 1 | 41 | java|json|serialization|xml-serialization|data-serialization | 28,841 | <p>In general the important question is which client will receive the serialized objects - browsers/JavaScript engines like (node-js), Java client, unknown/multiple clients.</p>
<p>JSON -
JSON syntax is basically JavaScript and therefore any component with a JS engine will handle its parsing very well - even complica... |
10,947,159 | Writing robust R code: namespaces, masking and using the `::` operator | <h2>Short version</h2>
<p>For those that don't want to read through my "case", this is the essence:</p>
<ol>
<li>What is the recommended way of minimizing the chances of new packages breaking existing code, i.e. of making the code you write <strong>as robust as possible</strong>?</li>
<li><p>What is the recommended w... | 10,951,283 | 2 | 21 | null | 2012-06-08 10:30:01.13 UTC | 28 | 2018-03-27 01:36:26.077 UTC | 2012-06-12 11:56:40.373 UTC | null | 989,691 | null | 989,691 | null | 1 | 47 | r|coding-style|namespaces|package|masking | 4,176 | <p>GREAT question.</p>
<h2>Validation</h2>
<p>Writing robust, stable, and production-ready R code IS hard. You said: "Surprisingly, this doesn't seem to bother a lot of programmers out there". That's because most R programmers are not writing <strong>production</strong> code. They are performing one-off academic/r... |
11,329,917 | Restart python-script from within itself | <p>I have a python-based GTK application that loads several modules. It is run from the (linux) terminal like so:</p>
<p><code>./myscript.py --some-flag setting</code></p>
<p>From within the program the user can download (using Git) newer versions.
If such exists/are downloaded, a button appear that I wish would rest... | 11,329,970 | 15 | 2 | null | 2012-07-04 13:19:22.92 UTC | 19 | 2022-09-11 20:31:34.787 UTC | null | null | null | null | 1,099,682 | null | 1 | 63 | python | 147,443 | <p>You're looking for <a href="http://docs.python.org/library/os.html#os.execl" rel="noreferrer"><code>os.exec*()</code></a> family of commands.</p>
<p>To restart your current program with exact the same command line arguments as it was originally run, you could use the following:</p>
<pre><code>os.execv(sys.argv[0], s... |
11,126,315 | What are optimal scrypt work factors? | <p>I'm using a <a href="https://github.com/wg/scrypt" rel="noreferrer">Java scrypt library</a> for password storage. It calls for an <code>N</code>, <code>r</code> and <code>p</code> value when I encrypt things, which its documentation refers to as "CPU cost", "memory cost" and "parallelization cost" parameters. Only p... | 12,581,268 | 3 | 7 | null | 2012-06-20 18:57:07.127 UTC | 44 | 2021-05-14 22:31:11.427 UTC | null | null | null | null | 331,598 | null | 1 | 71 | java|cryptography|scrypt | 16,183 | <p>As a start:</p>
<p><em>cpercival</em> mentioned <a href="http://www.tarsnap.com/scrypt/scrypt-slides.pdf" rel="noreferrer">in his slides from 2009</a> something around</p>
<ul>
<li>(N = 2^14, r = 8, p = 1) for < 100ms (interactive use), and</li>
<li>(N = 2^20, r = 8, p = 1) for < 5s (sensitive storage).</li>... |
12,812,570 | Differences between gevent and tornado | <p>I understand that both <code>tornado</code> and <code>gevent</code> are asynchronous python frameworks.</p>
<p>While reading the <a href="http://bottlepy.org/docs/stable/async.html#the-limits-of-synchronous-wsgi" rel="noreferrer">bottle documentation</a> I found that gevent actually is NOT asynchronous, and you can... | 12,812,839 | 2 | 1 | null | 2012-10-10 05:34:09.043 UTC | 13 | 2014-07-30 13:09:25.857 UTC | null | null | null | null | 1,206,051 | null | 1 | 14 | wsgi|tornado|gevent | 10,398 | <p>Have a read of:</p>
<p><a href="http://en.wikipedia.org/wiki/Coroutines" rel="noreferrer">http://en.wikipedia.org/wiki/Coroutines</a></p>
<p>and:</p>
<p><a href="http://en.wikipedia.org/wiki/Event-driven_architecture" rel="noreferrer">http://en.wikipedia.org/wiki/Event-driven_architecture</a></p>
<p><a href="htt... |
12,763,890 | Exclude Blank and NA in R | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/4862178/r-remove-rows-with-nas-in-data-frame">R - remove rows with NAs in data.frame</a> </p>
</blockquote>
<p>I have a dataframe named sub.new with multiple columns in it. And I'm trying to exclude any cell co... | 12,764,040 | 2 | 5 | null | 2012-10-06 21:08:00.08 UTC | 13 | 2016-03-23 10:58:17.3 UTC | 2017-05-23 11:47:06.12 UTC | null | -1 | null | 1,301,840 | null | 1 | 20 | r|na | 197,812 | <p>A good idea is to set all of the "" (blank cells) to NA before any further analysis.</p>
<p>If you are reading your input from a file, it is a good choice to cast all "" to NAs:</p>
<pre><code>foo <- read.table(file="Your_file.txt", na.strings=c("", "NA"), sep="\t") # if your file is tab delimited
</code></pre>... |
12,883,088 | Python: pass statement in lambda form | <p>A Python newbie question, why is this syntax invalid: <code>lambda: pass</code>, while this: <code>def f(): pass</code> is correct?</p>
<p>Thanks for your insight.</p> | 12,883,120 | 3 | 0 | null | 2012-10-14 14:20:45.83 UTC | 4 | 2016-07-27 14:27:18.2 UTC | null | null | null | null | 1,306,142 | null | 1 | 49 | python|lambda|anonymous-function | 19,645 | <p>That is an error because after the colon you have to put the return value, so:</p>
<pre><code>lambda: pass
</code></pre>
<p>is equal to:</p>
<pre><code>def f():
return pass
</code></pre>
<p>that indeed makes no sense and produces a <code>SyntaxError</code> as well.</p> |
13,020,246 | Remove special symbols and extra spaces and replace with underscore using the replace method | <p>I want to remove all special characters and spaces from a string and replace with an underscore.
The string is</p>
<pre><code> var str = "hello world & hello universe";
</code></pre>
<p>I have this now which replaces only spaces:</p>
<pre><code> str.replace(/\s/g, "_");
</code></pre>
<p>The result I ... | 13,020,280 | 5 | 0 | null | 2012-10-22 21:34:18.953 UTC | 19 | 2019-10-14 05:24:56.423 UTC | 2018-10-11 18:09:58.027 UTC | null | 63,550 | null | 1,361,669 | null | 1 | 65 | javascript | 139,946 | <p>Your regular expression <code>[^a-zA-Z0-9]\s/g</code> says match any character that is not a number or letter followed by a space.</p>
<p>Remove the \s and you should get what you are after if you want a _ for every special character.</p>
<pre><code>var newString = str.replace(/[^A-Z0-9]/ig, "_");
</code></pre>
<... |
12,788,487 | $(document).scrollTop() always returns 0 | <p>I'm simply trying to do something once the scroll position of the page reaches a certain height. However <code>scrollTop()</code> is returning 0 or <code>null</code> no matter how far down I scroll. This is the help function I'm using to check the <code>scrollTop()</code> value: </p>
<pre><code>$('body').click(func... | 12,789,956 | 9 | 15 | null | 2012-10-08 19:50:01.06 UTC | 12 | 2020-05-11 07:00:44.703 UTC | 2012-10-08 19:58:29.053 UTC | null | 1,267,663 | null | 484,358 | null | 1 | 74 | javascript|jquery|scrolltop | 78,768 | <p>For some reason, removing 'height: 100%' from my html and body tags fixed this issue.</p>
<p>I hope this helps someone else!</p> |
12,833,514 | Paused in debugger in chrome? | <p>When debugging in chrome, the scripts are always paused in the debugger even if there are no break points set, and if the the pause is un-paused, it again pauses itself.</p>
<p>What can be done? </p> | 12,897,543 | 18 | 1 | null | 2012-10-11 06:31:05.843 UTC | 27 | 2021-07-05 06:55:29.593 UTC | 2012-10-18 09:32:51.5 UTC | null | 297,408 | null | 1,585,332 | null | 1 | 170 | debugging|google-chrome|google-chrome-devtools | 244,545 | <p>One possible cause, it that you've enabled the "pause on exceptions" (the little stop-sign shaped icon with the pause (||) symbol within in the lower left of the window). Try clicking that back to the off/grey state (not red nor blue states) and reload the page.</p>
<p><a href="https://i.stack.imgur.com/Q... |
17,113,149 | What is the difference between MySQL's create index and alter add index? | <p>I have a table "data" with column id(varchar), text(varchar), date(date). Creating index on mysql, I use heidiSQL.</p>
<p>When I right click on the column and select create new index (key), the code shows it's using <code>alter table data add index 'index1' ('id,date(10)')</code></p>
<p>What is the difference betw... | 17,113,555 | 1 | 0 | null | 2013-06-14 16:27:56.527 UTC | 4 | 2018-05-11 16:44:03.81 UTC | 2013-06-14 16:52:25.697 UTC | null | 212,555 | null | 1,828,260 | null | 1 | 37 | mysql|indexing | 11,593 | <p>The implementation is the same on the server-side.</p>
<p>The only difference is that with CREATE INDEX syntax, you <em>must</em> specify a name for the index.</p>
<p>Whereas with ALTER TABLE, you <em>may</em> specify a name for the index, but you don't have to.</p>
<p>If you don't specify a name, the server gene... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.