input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Can I override the value returned by require() in webpack? <p>For testing purposes, I want to use <code>require('whatever.js')</code> to return an arbitrary content rather than having it actually load the file.</p>
<pre><code>// made up code
var AAA = {};
require.setFor('./whatever.js', AAA);
var BBB = require('./wh... | <p>Simply overwrite the <code>require</code> function:</p>
<pre><code>var realRequire = require;
require = function (what) {
return realRequire('mocked-' + what);
}
</code></pre>
<p>You could use a lookup table for your mocks as well and call <code>realRequire()</code> if no mock exists.</p>
|
Rails 5: Why is javascript executing twice? <p>I am in the process of learning Rails, and am struggling with best practices with respect to page-specific javascript. Even with this simple approach, turbolinks (I believe) is causing javascript to execute twice if I visit a page and then return to it.</p>
<p>To simplif... | <p>This was caused by turbolinks displaying a preview when revisiting the page. My understanding is that turbolinks briefly displays a preview, to improve perceived load times, then replaces it. In my example Javascript is executed both when the preview is displayed, and again when it is replaced.</p>
<p>In my scena... |
How would one print out a created ascii display multiple times side by side? <p>For example, if I had created a shape:</p>
<pre><code>iiiiiiiii
i i
i i
iiiiiiiii
</code></pre>
<p>and wanted to print that five times side by side, how would I do that? A for loop?</p>
<p>I've already tried just manually pri... | <p>I had noticed that you had asked this with the "C++ Tag" So here it goes, I also assume this would be for a Console application, I had also attempted this with Visual Studio I have no clue what you're using but this is how I did it!</p>
<pre><code>#include <iostream>
using namespace std;
int main() {
... |
histogram and scatter plot on the same graph but the axis overlapped <p>I am plotting a histogram of actual data along with a density plot on the same graph but the x axis and y axis all mixed up. Is there a way to make sure the graph has the same axis e.g set a range to the graph for both the plot.</p>
<p>The reason ... | <p>Since nobody answers my question. I have figured it out.</p>
<p>set the same <code>xlim</code> and <code>ylim</code> to <strong>both</strong> graph which makes aligned the x,y axes.</p>
|
Where is copy constructor getting called? <p>I wrote a small snippet of C++ code in a main.cpp file and am trying to understand how it's working.</p>
<p>First I defined a class "Value":</p>
<pre><code>#include <algorithm>
#include <iostream>
using namespace std;
class Value {
int v;
public:
Valu... | <p>Here are the copies:</p>
<ul>
<li><code>auto v = Value(10);</code> initializes <code>v</code> using copy-constructor from <code>Value(10)</code>.</li>
<li><code>auto newValue = Value(v.rawValue() * 2);</code> initializes <code>newValue</code> using copy-constructor from <code>Value(v.rawValue()*2)</code>.</li>
<li>... |
Unable to insert data into mysql in node <p>Trying to insert data into mysql with <code>'INSERT INTO users SET ?'</code>, I get 500 error in front end. data is reaching the server but unable to insert into database. Tried even <code>'INSERT INTO users VALUES ?'</code> but still fails. i'm able to retrieve the data from... | <p>And what if you try to first do a dummy query. I don't know for sure you can simply put "?" to insert a value without giving a column like </p>
<pre><code>'INSERT INTO table_name (column1,column2,column3,...)
VALUES ('?','?','?',...)'
</code></pre>
<p>If it still isn't working you know it's something else.</p>
|
SQlite.Net.SQliteCommand ExecuteQuery requires calss <p>I am working on SQlite with Windows Universal App. I have a scenario where the column names are unknown and want to fetch the data from Sqlite table. The method ExecuteQuery in SQlite.Net.SQlite.SQlCommand expects a class name to be passed. I tried with dictionary... | <p>What you need is actually map it to a list of dynamic objects with SQLite in UWP app, I'm sorry to tell you that SQLite for UWP doesn't support this function.</p>
<p>And <a href="https://github.com/StackExchange/dapper-dot-net" rel="nofollow">Dapper.Net</a> is now not available for UWP apps. </p>
<p>You can try to... |
How can i consume this webservice with Java? <p>this is a very simple question apparently but i was unavaible to find a certain information searching in google. Let me tell you, i have a jboss running in my computer with only this webservice:</p>
<pre><code>import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import ... | <p>Use <a href="https://spring.io/blog/2009/03/27/rest-in-spring-3-resttemplate" rel="nofollow">Spring RestTemplate</a> to consume a Rest service. </p>
<p>You need to first register the <code>RestTesmplate</code> into spring context</p>
<pre><code><bean class="org.springframework.web.client.RestTemplate" id="restT... |
Element Tree find output empty text <p>I have a problem using Element Tree to extract the text.</p>
<p>My format of my xml file is</p>
<pre><code><elecs id = 'elecs'>
<elec id = "CLM-0001" num = "0001">
<elec-text> blah blah blah </elec-text>
<elec-text> blah blah bla... | <p>You can simply find elements that directly contains the text by name i.e <code>elec-text</code> in this case :</p>
<pre><code>>>> elec_texts = tree.findall('.//elec-text')
>>> for elec_text in elec_texts:
... print elec_text.text
... ... |
selecting properties from other table with Lambda expression <p>I am less experienced with Lambda expression for .NET and trying to get data from SQL using lambda expression. With below query, I am able to get data back, but do not want to use <code>include</code> to get all properties from other tables. </p>
<pre><co... | <p>With lambda expressions, you can use <code>SelectMany</code> to flatten 1-n associations into a 1 dimensional list (i.e. parent and child properties side-by-side). In your case, judging from the <code>Where</code> clause, I think only <code>ResourceGroup</code> - <code>ServerGroup</code> is 1 - n, so it should be so... |
How move a rectangle with arrow keys while clearing the canvas in between every re-draw <pre><code><!DOCTYPE html>
<html>
<head>
<title></title>
<style>
canvas {
border: 1px solid black;
width: 1200px;
... | <p>This is the corrected code:</p>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<meta char... |
500 error while deploying asp.net core web api to IIS 7.5 <p>I have a asp.net core web api project which I am trying to host in IIS 7.5.</p>
<p>As suggested by below article,</p>
<p><a href="http://stackoverflow.com/questions/39157781/the-configuration-file-appsettings-json-was-not-found-and-is-not-optional">The conf... | <p>Create a new login "IIS APPPOOL[App Pool Name]" for SQL Server and later assign website/IIS application to "IIS APPPOOL[App Pool Name]" works for me.</p>
<p>Thanks,</p>
|
dropbox says "no preview available" when loading Xcode ipa ad hoc file <p>Yesterday, I was able to load ad hoc build ipa files created in Xcode using dropbox. Today, the file appears to load (progress bar moves to the right) but dropbox finishes with the message "preview not available". I'm afraid I modified a projec... | <p>You can for sure be calm, you have probably not modified and destroyed anything in your project. .ipa files is not supported by Dropbox preview. If you´re not sure how to upload your ipa file to Dropbox, take a look at <a href="https://appsandhacksblog.wordpress.com/2015/05/17/ad-hoc-distribution-over-dropbox/" rel... |
Handling impure DOM manipulation after redux state change <p>I have an interface that is a list of <code><input></code>s. Pressing enter in one of the inputs should move focus to the next input, and if you're already on the last input, another one should be added and that one focused. The list of items is managed... | <p>Rather than focusing programatically and using <code>state</code> in your List like you are doing above, you should pass a prop to the ListItem, and the list item themselves can focus themselves if the prop is true. So you could change your actions slightly as well to include the isFocused or not flag, for example:<... |
Is Parasitic Combination Inheritance really used anymore? <p>I am new to JavaScript. I'm reading the section on "Parasitic Combination Inheritance" in the <em>Professional Javascript for Web Developers</em> 3rd Edition in Chapter 6. With the introduction of <strong>ES6</strong> and a strong push to move away from "new"... | <p>The most "right" method I know of to do inheritance in Javascript is this:</p>
<pre><code>let SubClass = function() { SuperClass.call(this, arguments); /*Do other stuff here*/ }
SubClass.prototype = Object.create(SuperClass.prototype);
</code></pre>
<p><code>Object.create(o)</code> is about the same as <code>{__pr... |
Searching binary tree of objects for a single class member <p>So I'm working on a program that will use a binary tree template class I've created to hold a set of EmployeeInfo objects which is another class I've created. The EmployeeInfo class has two data members, one to hold the employee's ID number and one to hold t... | <p>Display the info using the binary tree class.</p>
<p>Edit your <code>searchNode</code> function in the Binary Tree class</p>
<pre><code>template <class T>
bool BinaryTree<T>::searchNode(T item) {
TreeNode *nodePtr = root;
while (nodePtr) {
if (nodePtr->value == item) {
c... |
counting missing values in a time series using R <p>I have a large time series dataset taken from a rain station with hourly intervals. To assess the quality of the data I'll like to know which days don't have the 24 measurements they should.</p>
<p>This is the structure of my dataframe where the Date column is alread... | <p>you can try this</p>
<pre><code>tab = table(df$Date)
tab[which(tab<24)]
</code></pre>
|
Execute a command from a variable inside a while loop or export variable out of while loop <p>I've written a script with a while loop, not realising the difficulty of getting a variable out of said while loop.</p>
<p>What I want to do is to run the command the while loop saves in the 'stream' variable (see code below)... | <p>Well, the way to run it as a command would be to just remove the <code>echo</code>:</p>
<pre><code>done
$stream
</code></pre>
<p>... except that you can't, because the <code>while</code> loop is on the right side of a pipe. That means it runs in a "subshell" and can't have side effects back in its parent shell (ou... |
how to pick data by key from dictionary array? <p>I try to pick data from array dictionary by key.<br>I can do it index number.<br> but here is my dictionary <code>[[String : AnyObject]]</code> what is the <strong>key</strong> store each element when i Deserializing from json to dictionary.<br>because dictionary set ... | <p>Place this inside photo</p>
<pre><code>for (key, value) in photo {
print(key)
print(value)
}
</code></pre>
|
Parse post data with punctuation incorrectly in golang <p>I know how to parse post data in golang</p>
<pre><code>r.ParseForm()
pid := r.PostFormValue("pid")
code := r.PostFormValue("code")
lang := r.PostFormValue("lang")
author := r.PostFormValue("author")
</code></pre>
<p>But the post data is <code>pid=1&code=#i... | <p>You're passing the raw code, which could be <strong>unsafe</strong>, your problem is because of this:</p>
<p><a href="https://golang.org/src/net/url/url.go?s=21047:21092#L761" rel="nofollow">https://golang.org/src/net/url/url.go?s=21047:21092#L761</a></p>
<p><a href="https://i.stack.imgur.com/bi8vF.png" rel="nofol... |
Java retrieving array and printing it in a for each loop <p>I am trying to make a program where it retrieves a set of arrays from a different class</p>
<pre><code>int barHeights[] = new int[]
{ 1, 2, 3, 4, 5, 6, 7 };
</code></pre>
<p>then calling it in a method and printing it out</p>
<pre><code>public void init(int... | <p>In line:</p>
<pre><code>Bar[] barArray = new Bar[barHeights.length];
</code></pre>
<p>You are creating an instance of array of Bar class references instead of int. <br>This array is automaticly initialized with null values, and in line:</p>
<pre><code>for (Bar bar : barArray){
System.out.println(bar);
</code>... |
Jade sets it's own style tag to every p element <p>In my website, I wondered why I couldn't set a font size for my p elements, and it turns out jade has been adding style="font-size: 12px" to all my p elements as if I did it. Any way to fix this? It's probably my fault but I don't know what I did.</p>
| <p>I'm really stupid, sorry about that, it was my own js file adding it on.</p>
|
In Ruby, how do I add multiple user input in f.number_field? <p>I'm a complete Ruby noob so please explain things to me like I'm 5. I have a form that has seven f.number_fields. I would like to add them and store them in :total. Here is an example of what I'm talking about:</p>
<pre><code> <%= f.label :icecrea... | <p>Ok you have your form in your view your model and your controller. What is going to happen is you are going to fill out your form that is in the new view for totals. Hit the submit button, that is going to make a request to your controller action <code>create</code>. In the <code>create</code> action it is going to ... |
Keep All Characters Before Backslash R <p>I have a list of 10 chr called data and am trying to remove everything that occurs after the first backslash but am having difficulty.</p>
<p>For example, here is the first string:</p>
<p><code>Nov. 3, 2016\n\t\t\t\n\t\t\t\n\t\t\t\tBO</code></p>
<p>I only want to keep Nov. 3... | <p><code>sub</code> function would be enough for this case since the replacement would occur only once.,</p>
<pre><code>sub("\\n[\\s\\S]*", "", x)
</code></pre>
<p><a href="https://regex101.com/r/SxRKe6/1" rel="nofollow">DEMO</a></p>
|
String to numeric conversion using regex in scala <p>Hi have an array of numbers as string: </p>
<p><code>val original_array = Array("-0,1234567",......)</code> which is a string and I want to convert to a numeric Array.</p>
<pre><code>val new_array = Array("1234567", ........)
</code></pre>
<p>How can I aheive... | <p>The simple answer is ...</p>
<pre><code>val arrNums = Array("123", "432", "99").map(_.toDouble)
</code></pre>
<p>... but this a little dangerous because it will throw if any of the strings are not proper numbers.</p>
<p>This is safer...</p>
<pre><code>val arrNums = Array("123", "432", "99").collect{ case n
... |
Hadoop Mutlicluster installation on Amazon ubuntu instances <p>In all the explanations of installation of hadoop on linux, the mention of folders like : hadoop/etc or hadoop/bin occurs.
However, after I downloaded, extracted and renamed hadoop, my hadoop folder contains the following subfolders:
!<a href="https://s13.... | <p>I understood my mistake</p>
<p>I was downloading src file from the release page of hadoop. I should download the binaries</p>
|
How to hide number of comments text in Wordpress website <p>I'm creating a website by using Wordpress CMS (wordpress.org). My question is how to hide or remove number of comments text above the comments elements. See below image.</p>
<p><a href="https://i.stack.imgur.com/NJq9q.png" rel="nofollow"><img src="https://i.s... | <p>You can hide number of comments text by css like.</p>
<pre><code>.comments-area .comments-title{
display: none;
}
</code></pre>
<p>Or you can remove code from <code>comment.php</code> file.</p>
<pre><code> <h2 class="comments-title">
<?php
printf( _nx( 'One thought on &ldquo;%... |
Why is my webpage load time more than 10 secs even with 98% speed performance score? <p>Is there any way to identify why this <a href="http://eamcetexams.com" rel="nofollow">website</a> initial loading is very slow? I have checked in my each and every part of the HTML structure and code (Requests, Response).</p>
<p>It... | <p>It seems to me that there is an issue with your subdomain. Possibly with DNS resolution maybe.</p>
|
Java Programming: Turtle not moving in desired direction <p>I'm writing a Java program in which I have to get the turtle to move West, but what I have so far isn't getting the turtle to move in the desired direction.</p>
<pre><code>public static void moveTurtleWest(Turtle t, int n)
{
for(; n > t.getX();... | <p>Possibly correct for loop:</p>
<pre><code> public static void moveTurtleWest(Turtle t, int n) {
for(int i=0; i <n;i++ ){
t.moveWest();
}
}
</code></pre>
|
C ++ simple function returning huge value - always the same value no matter the inputs - 4309838 <p>I am learning to code and this is a very simple function but it keeps returning the same answer every time, 4309838, and I don't know why. It is meant to calculate a paycheck, adding 50 whenever there is overtime. Any he... | <p>You have not declared payCheck variable in payCheck method. This works:</p>
<pre><code>float payCheck(int ratePar, float hoursPar)
{
float payCheck;
if (hoursPar>40)
payCheck = ratePar*hoursPar + 50;
else
payCheck = ratePar*hoursPar;
return payCheck;
}
</code></pre>
|
Why do i get this error "TypeError: 'int' object is not callable"? <pre><code>def diameter(Points):
'''Given a list of 2d points, returns the pair that's farthest apart.'''
diam,pair = max([((p[0]-q[0])**2 + (p[1]-q[1])**2, (p,q))
for p,q in rotatingCalipers(Points)])
return pair
n=in... | <p>From the Traceback it's clear than you are trying to call <code>int</code> object, So <code>rotatingCalipers</code> may be declared as integer in your code. </p>
<p>See this example you will understand the error,</p>
<pre><code>In [1]: a = (1,2,3)
In [2]: list(a)
Out[1]: [1, 2, 3]
In [3]: list = 5
In [4]: list(a)
... |
Querying across multiple tables avoiding a union all <p>I have the following DB tables that I am trying to query:</p>
<pre><code>t_shared_users
user_id
user_category
folder_id
expiry
t_documents
id
folder_id
user_id
user_category
description
created
updated
t_folder
id
type
user_id
user_category
created
updated
</co... | <p>This is your query:</p>
<pre><code> SELECT
id,
folder_id,
user_id,
user_category,
description,
created,
updated
FROM
t_documents
WHERE
user_category = 100
AND user_id = 1
UNION ALL
SELECT
d.id,
d.folder_id,
d.user_id,
d.user_category,
d.descript... |
ionic - login page not redirecting to main page <p>This is happening only when login page is used as fallback. Same login page is working fine when main page is used as fallback. I'm very new to this framework and any help for fixing this would be much appreciated. Please feel free to ask if you need any other code for... | <p>You have not injected ui-router as a dependency to the module,</p>
<pre><code>angular.module('starter.controllers', ['ui.router']);
</code></pre>
<p>also refer the js for the ui.router</p>
<pre><code> <!-- Angular -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.min.js"></... |
check number falls between range <p><a href="https://i.stack.imgur.com/09V43.png" rel="nofollow"><img src="https://i.stack.imgur.com/09V43.png" alt="This is the format how i want"></a></p>
<p>column A and Column C is the range and column B is the reference value which I have to compare with Column A and Column C .
Eg... | <p>you can do this way:</p>
<pre><code>Sub main()
With Worksheets("Sheet1")
With .Range("D1:D" & .Cells(.Rows.Count, 1).End(xlUp).row)
.FormulaR1C1 = "=IF(AND(RC2>=RC1,RC2<=RC3),""Correct"",""Wrong"")"
.Value = .Value
End With
End With
End Sub
</code></pre>
|
In A-Frame how do I change an entity's attributes from a raycaster intersection event? <p>I've attached a raycaster to a vive controller entity using <a href="https://aframe.io/" rel="nofollow">Mozilla's A-Frame</a>. I'd like some intersected objects to change opacity while they're being intersected. These objects shou... | <p>this.el is referring to your raycaster entity, not the target entity. The target entity is contained within the event detail, passed in through the event handler callback. Try:</p>
<pre><code>this.el.addEventListener('raycaster-intersected', function (evt) {
evt.detail.el.setAttribute('material', 'opacity',... |
App Crashed when device time is in 24 hour format <p>In my App if IPhone device time is in 12 hour formate then date formatter works correctly but if device time is in 24 hour formate then app crashed.</p>
<pre><code> let dateFormatter = NSDateFormatter();
dateFormatter.dateStyle = NSDateFormatterStyle.ShortStyle
da... | <p>Assuming that you are using Swift 2.x version after seeing your code.</p>
<p>The problem is because your <code>dateFormatter</code> contains <code>a</code> and for the 24 Hour Format time we don't have <code>a</code></p>
<p>So in order to fix your problem, you have to check whether your device is in 24-Hour format... |
How to access checkboxes which are not yet visible on the screen in a Recycler view <p>I am new to Android and pretty much learning as I go. Hence this query maybe very basic</p>
<p>I am displaying a list of checkboxes through a RecyclerViewAdapter. Some of the checkboxes are to select entire group of checkboxes. What... | <p>Just figured out a way to handle this situation. Sharing it in case someone else has a similar query in future.</p>
<p>For views that are not yet visible, I just marked them in the array that the adapter is using. The each element of the array has a name and type. Used type to store status of the checkbox and each ... |
golang server: how to retrieve multiple files continuously <p>I have implemented a http server based on <code>gin</code> (golang web framework).</p>
<p>I post 2 pictures to server with <code>curl multipart/form-data</code>:</p>
<p><code>curl -X POST -F upload0=@jpg -F upload1=@jpg -H "Content-Type: multipart/form-dat... | <p>Since <code>FormFile</code> indexes the files from the posted form, it requires that the entire form already be parsed. From the <code>FormFile</code> docs:</p>
<blockquote>
<p>FormFile calls ParseMultipartForm and ParseForm if necessary.</p>
</blockquote>
<p>If you want to stream the the multipart form one part... |
Angular2 Webpack and Express <p>I've installed Angular 2 Webpack which includes a sample app and demonstrates routing. What I want to look into is using Angular2 for the front end routing but to the use ExpressJS for a RESTful API backend, but on the same server i.e.</p>
<p><a href="http://localhost:3000/#/" rel="nofo... | <p>I couldn't find a way to do it on the same port so I went with placing this in config/webpack.common.js. (I had thought I would need to start a separate 'npm' process for the API but clearly not!)</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snipp... |
In PHP, what does this block of code do in forms required field? <p><strong>What does this block of PHP code do?</strong></p>
<pre><code>function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
</code></pre>
<p><strong>This is the entire P... | <p><em>What it does</em></p>
<p><code>trim()</code> removes whitespace from the beginning and end, <code>stripslashes()</code> any slash that might be added if magic_quotes is active (which depends on your PHP configuration&version), and <code>htmlspecialchars()</code> adds slashes again.</p>
<p><em>Why</em></p>
... |
Why I am getting error with my activity in android? <p>I declare both of my activity class in AndroidManifest.xml file them when I run my application it stop unfortunately with this error message:-</p>
<pre><code> android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidtutorialpoi... | <p>You placed it in the wrong location it should be inside the application tag. All your <code><activity... /></code> tags should be placed under the <code><application.. /></code> tag.</p>
<p>Hope this helps!</p>
|
Retrieving running totals from two separate tables <p>I'm trying to perform a running total query based on two tables and I'm a bit stumped. Here is what I have thus far. Firstly let me provide you guys with a DDL of the table and the sample data that I'm using.
Table 1</p>
<pre><code>create table Actuals
(
f_year var... | <p>please try this, I joined the tables in cte first, then calculate the running total.</p>
<pre><code>;with cte as(
select
Coalesce(a.f_year, b.f_year) as f_year
,coalesce(a.f_period, b.f_period) as f_period
,coalesce(a.f_fund, b.f_fund) as f_fund
,coalesce(a.f_org, b.f_org) as f_org
,coalesce(a... |
Arduino mega + esp 8266 sending get request <p>i have a php script which help to store data into google firebase.</p>
<p>i am using this url to access my php scipt and input the data:
arduino.byethost22.com/FirebaseTest.php?slot1_data=empty&slot2_data=occupied</p>
<p>i have tried it and it is able to store slot1_... | <p>My code finally can work and send data online. i change to use 000webhost as my host server instead of byethost and the data manage to be updated. </p>
<p>i dont really know why but i guess that byethost dont support javascript.</p>
|
i am creating a canvas drawing apps but i got stock <p>i am creating a canvas drawing apps but i got stock in my code.I am new at javascript so it seems difficult for me to code</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class=... | <p>You should go this this <a href="http://www.williammalone.com/articles/create-html5-canvas-javascript-drawing-app/" rel="nofollow">link</a>. It will help you.</p>
<p>And you just specify that what type of output you should and which types of function you want to use in canvas.</p>
|
Remove label section from paper-textarea <p>I'd like to remove the extra space that the label takes up in a polymer text-area. Is this possible? Thank you.</p>
| <p>I guess there are some default margin on padding. Without code it's hard to say.</p>
|
Using a integer flag to save radio button status like a boolean <p>I'm using this code to "convert" the status of a Radio Button to a integer in "boolean way"</p>
<pre><code>If MyRadioButton.Checked Then
cmdConnection.Parameters.AddWithValue("@paramMychoice", 1)
Else
cmdConnection.Parameters.AddWithValue("@par... | <p>Using If</p>
<pre><code>Dim flag As Integer
flag = if(MyRadioButton.Checked,1, 0)
</code></pre>
<p><a href="https://msdn.microsoft.com/en-us/library/bb513985.aspx" rel="nofollow">If Operator (Visual Basic)</a></p>
<p>Also set explicit and strict to on to your project. (I recommend to set those two default to on i... |
Why javascript does not return rounded number <p>```</p>
<pre><code>function addTwoDigits(n) {
var result;
result = Math.floor(n/10) + 10*(n/10-Math.floor(n/10));
console.log(result);
return result;
}
addTwoDigits(29);
</code></pre>
<p>```
the output was 10.9999999999999999999999999999999
I wonder why it was not 11 ... | <p>put <strong>Math.round()</strong></p>
<pre><code>function addTwoDigits(n) {
var result;
result = Math.floor(n/10) + 10*(n/10-Math.floor(n/10));
console.log(Math.round(result));
return result;
}
addTwoDigits(29);
</code></pre>
<p>Hope this helps.</p>
|
A strange ConcurrentModificationException on iteration <p><a href="http://stackoverflow.com/questions/16245587/concurrentmodificationexception-on-iterator-next">this</a>
is probably the closest case to mine, but that didn't help either.</p>
<p>I'm getting the ConcurrentModificationException here:</p>
<pre><code>for (... | <p>To help narrow down the problem, there is a trick that might help.</p>
<p>Assuming <code>projectiles</code> is the only reference to the <code>ArrayList</code>, you can temporarily replace it with an immutable list, while you're iterating, so only the <code>Iterator</code> can modify the list. If some other code tr... |
Array of object is always null in MVC core controller <p>I am trying to post array of a simple object to my MVC core controller with the Frombody attribute, but for some reason it coming as null. If I post just a single object it is working fine here is my code: </p>
<pre><code>$(document).ready(function() {
var t... | <p>remove FromBody in your action, for complex types the Request will contain complex types in Request body.
try use PostMan and try different options.</p>
<p>1 pass object in URL , use [FromUri] </p>
<p>2 pass object in body ,remove FromBody</p>
<p>3 pass simple values like string ,use [FromUri] if you want to acce... |
save edit text value on changing radio button <p>I have two radio buttons in a radio group and three text edit fields in one layout.</p>
<p>Now when I switch radio button I would able to save data of edit text for pervious selected radio button and vice versa </p>
<p>Please help me.</p>
| <p>You can do using radio group.</p>
<pre><code> RadioGroup radioGroup = (RadioGroup) findViewById(R.id.yourRadioGroup);
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// ch... |
Is there any best practice for packaging MVP layers? <p>I have done some Android applications using MVP methodology,</p>
<p>But I am not so sure if it is better to place different layers objects of the same feature in a same package? or package all layers items of different features in the same package with layer name... | <p>Just to throw my thoughts into the mix. I have worked on projects with each of these approaches. My preference now is to package by feature. There are two main reasons I prefer this approach:</p>
<p><strong>Ease of Induction</strong></p>
<p>Increased visibility of project structure for developers new to the code... |
SQL query to get all rows when there is no matching row in left join <p>I have a table structure like this:</p>
<pre><code>person (pid, pname)
personSamples(sid,pid,sampleName)
groups(gid,groupName)
groupPersons(gpid,gid,pid)
grouppersonSamples(gpsid,gid,sid)
</code></pre>
<p>Whenever a person is added to a group (i.... | <p>The following query will give you group-person-samples(gid, sid) for a given person(pid) which are not already present in grouppersonSamples table: </p>
<p>Assume pid of the given person is 3. I've not considered the gid of the group in which this person is added. If you wish to consider a specific group, add the g... |
How can I exclude package private class using Class Diagram Options? <p>I trying to generate UML Graph with Javadoc using <a href="http://www.spinellis.gr/umlgraph/" rel="nofollow">UMLGraph</a>.</p>
<p>I'm searching an option on <a href="http://www.spinellis.gr/umlgraph/doc/cd-opt.html" rel="nofollow">here</a> for exc... | <p>I don't see UMLGraph having such an option. Consider adding the <code>@hidden</code> tag to the class's Javadoc comment as documented <a href="http://www.spinellis.gr/umlgraph/doc/cd-opt-spec.html" rel="nofollow">here</a>.</p>
|
grayscale - how to disable it automatically <p>Many websites in Thailand are now in grayscale, mostly using -webkit-filter: grayscale(100%), filter: grayscale(100%) and so on.</p>
<p>I know we can see them in colors as usual, "manually" (in Chrome) by pressing/clicking the F12 > elements > styles and uncheck grayscale... | <p>Though it appears you have already tried this you should create a custom CSS stylesheet that Chrome will use with a plugin like <a href="https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe?hl=en" rel="nofollow">Stylish</a> (not sure if there is a built in feature in Chrome).</p>
<p>Th... |
javascript/jquery - hide/show table row if radio buttons checked <p>I am very new to js and jQuery. </p>
<p>I have a simple bootstrap table. In two rows, I have radio buttons, one for item 1a and another for item 2a. I have another two rows with classes of price-1 and price-2. I am hiding price-2 initially (class="hid... | <p>Here is your solution:<a href="https://jsfiddle.net/dhs3gphz/7/" rel="nofollow">jsFiddle</a></p>
<pre><code>$(document).ready(function() {
var pricePerRegUnder = 10;
var pricePerRegAbove = 12;
var licenseRegsSelect = $('#licenseRegs');
function updateTotalPrice() {
licenseRegs = parseInt(licenseRegsSe... |
adding validations to data that is imported through excel file <p>I want to import excel sheet data which contains fields like Employee Id,Employee Name,Gender,Phone No in first column and their respective value in second column ,and save the data to database.
I used oledb connection to import the excel sheet and then ... | <p>It's a bit of process. So I am not writing anything for this. The following shows a step by step process to validate and how to import data from spreadsheet:</p>
<p><a href="http://stackoverflow.com/questions/6464601/how-to-validate-a-csv-file-before-importing-into-the-database-using-ssis">Validate Data While Impor... |
How can i create border box arround dynamic div? <p>I'm using bootstrap 3.</p>
<p>here is my html code</p>
<pre><code><div class="border-box">
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<div class="padding-top">Record</div>
<div>Record</div>
<d... | <p>html</p>
<pre><code><div class="border-box">
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<div class="padding-top">Record</div>
<div>Record</div>
<div>Record</div>
<div>Record</div>
<div>Record</div... |
Loopback - one-to-many relation between 3 models <p>I'm using IBM API Connect for a Loopback application. I've 3 models - owner, home and room. The relationship is described as follows:</p>
<p>OWNER:</p>
<ul>
<li>an owner might have one or more than one home(s)</li>
<li>a home or all of the homes belong to a particul... | <p>I believe you are looking for a function called <code>nestRemoting()</code>.</p>
<p>Take your case as an example, you need to call <code>Owner.nestRemoting('homes')</code> in the boot file to enable nest endpoints</p>
<p>Details please see our doc: <a href="http://loopback.io/doc/en/lb2/Nested-queries.html" rel="n... |
Exception Details java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library <blockquote>
<p>Exception Details java.lang.IllegalArgumentException: You need to use
a Theme.AppCompat theme (or descendant) with the design library. Â Â at
android.support.design... | <p>Logcat output is clear, Set your <code>AppTheme</code> to inherit from <code>Theme.AppCompat</code>.</p>
<pre><code><style name="AppTheme" parent="@style/Theme.AppCompat>
</style>
</code></pre>
<p>You can find this in values file and you can also check manifest file to see what theme your are imposing.... |
Linux C Network communication program works in debugger but not outside <p>I have two files, server.c and client.c. The server listens for a client request and then replies appropriately (right now just LIST with a static directory is implemented). When the server receives the LIST command, it counts the amount of regu... | <p>As <a href="https://stackoverflow.com/users/106104/immibis">immibis</a> pointed out, your code assumes that each individual <code>send</code> corresponds to an individual <code>recv</code>. When you <strong>slowly</strong> step through the code, this assumption turns out to be (accidentally) correct, but when the pr... |
How to use a variable as input for the alignment in JLabel, Java <p>I want to know how to pass variables through the JLabel alignment parameter. For example:</p>
<pre><code>String myString = "CENTER";
JLabel label = new JLabel("text", JLabel.myString);
</code></pre>
| <p>Check the documentation of javax.swing.SwingConstants <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/javax/swing/SwingConstants.java#SwingConstants.0LEFT" rel="nofollow">here</a> and
below are the respective values for LEFT, RIGHT, CENTER</p>
<pre><code>public static final in... |
Unable to move Unity launcher or Menu Bar in Ubuntu? <p>I have just upgraded my Ubuntu to 16.04 LTS, I want my launcher to be displayed in Mac style i.e. in the bottom of the screen. I tried changing couple of settings but nothing worked for me. Is it possible to achieve it? How? Thanks.</p>
| <p>Install <strong>Unity Tweak Tool</strong> in Ubuntu - 16.04 by typing the commands given below (one-by-one) in the terminal :-</p>
<pre><code>sudo apt update
sudo apt install unity-tweak-tool
</code></pre>
<p>Then open the Unity Tweak Tool. And click on <strong>Launcher</strong> which is under <strong>Unity</stron... |
Oracle SQL Case with Condition <p>I have a question regarding Oracle SQL case statement.</p>
<p>in the where condition I would like to apply the following condition.
if salary_date is null then effective_date should be greater than 01-Jan-2016</p>
<p>I have the tried as</p>
<pre><code>case when salary_date is null t... | <p>The problem with your code is that SQL interpreter expects to see the value after 'then' keyword, whereas you have a condition clause.</p>
<p>Try something like this maybe:</p>
<pre><code>case when salary_date is null and trunc(effective_date) >= '01-JAN-2016'
then <value you need>
else null
<... |
paragraph inside a full height flexbox column with wrapping <p>I tried to create a flexbox layout with sticky header and footer. Everything works fine until I turn on the flex-wrap: wrap mode and put a lot of long texts inside my container.</p>
<p>Here is the html:</p>
<pre><code><html>
<body>
<div c... | <p>Set height on main container. It will work fine.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>html, body {
margin: 0;
padding: 0;
width: 100%;
overflow: ... |
multiple select conditions in php mysqli <p><a href="https://i.stack.imgur.com/1zP0p.png" rel="nofollow">i have table like above</a></p>
<p>I want to select and display cost when pickup and droplocation are same as that selected by user from a dropdown having above options.</p>
<pre><code>$result = mysqli_query($conn... | <p>Try this </p>
<p>your code looks have sql attack vulnerability try to use mysqli prepared statement.</p>
<pre><code> <?php
$stmt = $conn->prepare("SELECT * FROM location WHERE Pickup=? AND DropLocation=?");
$stmt->bind_param('ss',$pick,$drop);
//The argume... |
python calling variables from another script into current script <p>I'm trying to call a variable from another script into my current script but running into "variable not defined" issues.</p>
<p>botoGetTags.py</p>
<pre><code>20 def findLargestIP():
21 for i in tagList:
22 #remove all the sp... | <p>You imported the module, not the function. So you need to refer to the function via the module:</p>
<pre><code>import botoGetTags
largestIP = botoGetTags.findLargestIP()
</code></pre>
<p>Alternatively you could import the function directly:</p>
<pre><code>from botoGetTags import findLargestIP
largestIP = findLarg... |
How to join 3 column based on one coumn <p>I would like to compare the first column of three files. if matched, i would like to print the output as 4th column from file2 and 5th column from 2nd column of fil3. If no matches 0 will be added into the 4th and 5th column of the output.</p>
<pre><code> file1.txt
12... | <p>You'll need to join the first 2 files, and then join that output with the 3rd file. You'll need several extra options for join to do an outer join, with 0 as the default field value. Assuming your files are already sorted <em>lexicographically</em> by the first field, then:</p>
<pre><code>join -t , -a 1 -a 2 -e 0 -... |
Push items into array using eventlistener <p>I'm trying to update the array with values once the user clicks on an element in the DOM. The elements seem to be pushed into the array inside the anonymous function but outside the function the array is still empty. How can I fix that? Here is the javascript code:</p>
<pre... | <p>The function you pass to <code>addEventListener</code> won't run until the event happens.</p>
<p>It isn't possible for you to click any of the list items before the <code>console.log</code> that runs immediately after the assignment fires.</p>
<blockquote>
<p>Basically, after the items are clicked, the main arra... |
How to increase the width of "float:left"-elements when an element goes down to next line? <p>I want to create a footer with 4 columns (sections). Each section has these styles:</p>
<pre><code>.footer-sections {
width:24%;
min-width: 140px;
float:left;
}
</code></pre>
<p><a href="https://i.stack.imgur.com/Lu8cn... | <p>I think a media query will be needed here. Here is what I would do:</p>
<p><strong>HTML</strong></p>
<pre><code><div class="footer-sections">
<p>SECTION1</p>
</div>
<div class="footer-sections">
<p>SECTION2</p>
</div>
<div class="footer-sections">
&... |
rdd to json in spark and scala <p>I take a Json file with spark/scala and i save it in a rdd.</p>
<pre><code> val dataFile = "resources/tweet-json/hello.json"
lazy val rdd = SparkCommons.sqlContext.read.format("json").load(dataFile)
</code></pre>
<p>After quering rdd, i want to generate again a Json output file (t... | <p>You can simply use the write function to write out the Json
Example:</p>
<pre><code>dfTobeSaved.write.format("json").save("/root/data.json")
</code></pre>
<p>I think this should work fine !</p>
|
Go to Definition (jump to CSS file) <p>I am using Visual Studio Code and I really love this editor for working on HTML pages. Nevertheless I am looking for a way to jump to the corresponding CSS file when I select the class or id node. Did I miss something or is this still not working?</p>
| <p>Features like this are implemented in extensions. So if the HTML support extension you have installed supports providing locations of CSS rules to Visual Studio then it will allow you to jump to that location. If not then not.</p>
<p>I haven't looked for HTML extensions, but it could be there are several in the VS ... |
Calculating Exponential Moving Average (EMA) using javascript <p>Hi Is possible to calculate EMA in javascript?</p>
<p>The formula for EMA that I'm trying to apply is this</p>
<blockquote>
<p>EMA = array[i] * K + EMA(previous) * (1 â K)</p>
</blockquote>
<p>Where K is the smooth factor:</p>
<blockquote>
<p>K ... | <p>I don't know if I completely understood what you need, but I will give you the code for a function that returns an array with the EMA computed for each index > 0 (the first index doesn't have any previous EMA computed, and will return the first value of the input).</p>
<pre><code>function EMACalc(mArray,mRange) {
... |
Spring Batch process XMl message from MQ (IBM Websphere) <p>I am new to spring batch. I have a message xml in MQ i want to process this message through Spring batch.
can we integrate spring batch to MQ directly? or with the help of Camel ?</p>
| <p>Take a look at the <a href="http://docs.spring.io/spring-batch/apidocs/org/springframework/batch/item/jms/JmsItemReader.html" rel="nofollow"><code>JmsItemReader</code></a>. It will read via JMS Template.</p>
|
How to Digitalley sign a pdf document in the server using USB token in the client's system? <p>I need to digitally sign the PDF document in our server using digital certificate in the usb token. How this can be achieved? Is there any library/api for this?
I tried to access the certificates in the browser as suggested i... | <p>The link is for SSL authentication, not digital signature. You need a local java application to access USB token and a PDF library like itext or pdfbox. </p>
<p>Itis not possible from browser (except using applets with IE / firefox and old versions of JRE plugin. I do not recommend it). See <a href="http://stackove... |
Django, viewing models from different app <p>I am super new to python programming and django and i got the basics out of the way. I created a project with two apps, home and video. In my video models.py i have the following data:</p>
<pre><code>class Video(models.Model):
name = models.CharField(max_length=200)
... | <p>In settings, check the following is there.</p>
<pre><code>TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.cont... |
About inheritance of java <p>/**
* Created by zhangzhongzheng on 2016/10/15.
*/</p>
<p>public class ExtendsTest {</p>
<pre><code>static Dog d = new Dog();
public static void main(String[] args) {
Animal a = d;
System.out.println(a instanceof Animal);//true
System.out.println(a instanceof Dog);//true
... | <p>Here Animal is a Parent and Dog is a child.</p>
<p>Parent class reference can hold child class object.</p>
<p>Animal animal = new Dog();</p>
<p>So all above conditions are true.</p>
|
Automation of Windows Phone Application with Selenium and Appium <p>I have an android application. I have automated it with Selenium and Appium. I wrote the scripts in Java language.</p>
<p>Now I want to automate the same application in Windows Phone platform. AFAIK, <em>Appium supports Android and IOS platform only.<... | <p>You can not automate Windows Phone application with Appium. You can try Xamarin (not open source).</p>
|
Regex to match everything except image name and extension <p>I have this regex
<code>((?:https?\:\/\/)(?:[a-zA-Z]{1}(?:[\w\-]+\.)+(?:[\w]{2,5}))(?:\:[\d]{1,5})?\/(?:[^\s\/]+\/)*(?:[^\s]+\.(?:png|jpe?g|gif|svg|PNG|JPE?G|GIF|SVG))(?:\?\w+=\w+(?:&\w+=\w+)*)?)</code></p>
<p>to select these image urls from a string</p... | <p>Or if you just don't care whether or not you use RegEx:</p>
<p><strong>Required imports:</strong></p>
<pre><code>import java.io.File
import java.net.MalformedURLException;
import java.net.URL;
</code></pre>
<p>The code:</p>
<pre><code>URL url = new URL("http://my.a.example.com/kf/urjlsjjsXVXXq6xXFXXX6/20jaa/jajc... |
Java: return previous value of field <p>i start learn java and i have a little problem:</p>
<p>I have a class <code>Point</code>:</p>
<pre><code>public class Point {
int x;
int y;
void setX(Point point){
x=point.x;
}
void setY(Point point){
y=point.y;
}
}
</code></pre>
<p>Now i have ... | <p>You'd have to change from <code>void</code> to <code>int</code> return type(s) and then store the old value to return after you set it. Something like,</p>
<pre><code>int setX(Point point) {
int old = this.x;
this.x = point.x;
return old;
}
int setY(Point point) {
int old = this.y;
this.y = poi... |
Java Array Loop to Display different noCourse <p>I already writing a coding to accept noSem and noCourse from users. Each semester there will be a different noCourse. My problem is, I only can display data if users enter the same value of noCourse. I want it to show different between the Semester. </p>
<p>Here some ou... | <ol>
<li><p>You have re-initialized <code>courseCode</code> before displaying the results from it. Remove this line of code</p>
<p>courseCode[row] = new String[noCourse];</p></li>
</ol>
<p>before displaying your results and everything will work fine.</p>
<ol start="2">
<li>The variable noCourse might different for e... |
Set last tableView cell as constant cell among variable cells in Swift <p>As the title says, I would like to create a cell which is constant in a tableView where cells are variable. I want this cell to be the last. Actually, all my cells are created with data from Firbase. The last constant cell should be always there.... | <p>Yes, you can achieve it many ways.</p>
<p>This is my approach for it. I will create new tableview section for it. Where I will keep the number of rows as one always.
In cell for row at indexpath I will check the condition for that section and will return the corresponding constant cell.</p>
|
Is it good practice to insert blank lines into HTML code? <p>For example, to break up code into chunks for readability/maintainability, or is there a better method?
e.g: </p>
<pre><code><div class="list">
<p class="list-item">Lorem ipsum</p>
<p class="list-author">Jane Doe</p>
... | <p>If you want to follow Coding Conventions, you can follow this link...
<a href="http://www.w3schools.com/html/html5_syntax.asp" rel="nofollow">From WcSchool</a></p>
<p>So don't put unnecessary blank space and as well as put necessary space to improve readability and maintainability. </p>
|
How to use service in angular2 NgModule <p>I have written I service and send get request.But working good with angular2 rc4.I am using angular2 rc5.It is giving error.I am using rc5 NgModule.</p>
<p>I am getting the following error.Please help me</p>
<pre><code>"Error: DI Exceptionâµ originalStack:
"Error: DI Except... | <p>import HttpClient in your gridview.module.ts</p>
<pre><code>import { HttpClient } from '../../shared/http/base.http';
</code></pre>
<p>and define HttpClient in providers of gridview.module.ts</p>
<pre><code>providers: [ ItemService, HttpClient ]
</code></pre>
<p>See if this helps.</p>
|
HOW TO DISABLE SUBPAGE LISTING IN GOOGLE SEARCH <p>Google search page:</p>
<p><img src="https://i.stack.imgur.com/IuhIl.png" alt="Google search page"></p>
<p>How to hide the sub page (sitelinks) listing in google search results website.. that is shown in the above picture </p>
| <p>By default Google shows sitelink, we have very little control over it but we always have the permission to block sitelinks which we donât want to show in search result. Make sure to check if there is any unwanted pages are shown in your sitelink. </p>
<ul>
<li>Login to your Google Search console tool dashboard</l... |
Neon intrinsic code not boosting performance compared to C code <p>I have a simple C code that subtracts 'num' no. of values from two different pointers and writes back into a third pointer. I tried the same code using neon intrinsics to boost the performance, but am unable to see any reduction in the code execution ti... | <p>The compiler wrote this (buried inside of a lot of setup code to take care of edge cases):</p>
<pre><code>214: f4690adf vld1.64 {d16-d17}, [r9 :64]
218: e2877001 add r7, r7, #1
21c: e1570004 cmp r7, r4
220: e2899010 add r9, r9, #16
224: f4682a0f vld1.8 {d18-d19}, [r8]
228: e2888010... |
Pass an updated function to an existing function <p>In this short sequence, the user creates a function <code>userfunc()</code>, but then wants to update the first definition to do something different. However the <code>programfunc()</code> has already compiled the first version, and continues to use it. </p>
<pre><co... | <p><code>invoke</code> will do it. (Note though this will probably not compile to nice specialized code)</p>
<p>The issue here is that julia specialized on Type.
That is to say it compiles a custom version of the function for every combination of types passed to it.
Since Functions have a type in julia 0.5
(Each func... |
How to sort ArrayList<HashMap<String, String>> which contain number and string <p>Hello i get json response in following format</p>
<pre><code>["{\"papersize\":\"4X6\"}","{\"papersize\":\"6X8\"}","{\"papersize\":\"5X7\"}","{\"papersize\":\"8X10\"}","{\"papersize\":\"8X12\"}","{\"papersize\":\"12X24\"}","{\"papersize\"... | <p>To solve this issue you can parse the size and then sort them.</p>
<p>For Example,</p>
<pre><code>import java.util.*;
public class HelloWorld{
public static void main(String []args){
List<String> sizes = new ArrayList<>();
sizes.add("10X12");
sizes.add("4X6");
siz... |
How split java string using character which does not have an escape character before it <p>I've a string like this:</p>
<pre><code>a=b\=c
</code></pre>
<p>and I need to split it using java <code>split</code> method such that my assertion does not throw an exception:</p>
<pre><code>String[] res = "a=b\\=c".split("SPL... | <p>You can use a negative lookbehind before <code>=</code> to skip splitting in <code>\=</code>:</p>
<pre><code>String res = "a=b\\=c";
String[] toks = res.split("(?<!\\\\)=");
//=> ["a", "b\\=c"]
</code></pre>
<p><code>(?<!\\\\)</code> is negative lookahead that asserts failure when <code>\</code> is presen... |
Why do we have a slow `malloc`? <p>As far as I know, custom memory managers are used in several medium and large-scale projects. This <a href="https://security.stackexchange.com/questions/139364/how-is-the-heartbleed-exploit-even-possible">recent answer</a> on security.se discusses the fact that a custom memory allocat... | <p>There are two problems:</p>
<ol>
<li><p>No single allocation scheme fits all application needs.</p></li>
<li><p>The C library was poorly designed (or not designed). Some non-eunuchs operating systems have configurable memory managers that can allow the application to choose the allocation scheme. In eunuchs-land, t... |
Is there something like a static thread_local method? <p>I guess it would not make much sense and I'm not sure what a <code>static thread_local</code> method would do, but does this exist?</p>
| <p><code>static</code> unfortunately in C++ has many different unrelated meanings.</p>
<p><code>thread_local</code> is a storage class specifier, and can be combined with <code>static</code> (that can also be used as a storage class specifier).</p>
<p><code>static</code> in a method declaration however is NOT a stora... |
What is masking here <p>In the python tutorial:</p>
<p>In interactive mode, the last printed expression is assigned to the variable _. This means that when you are using Python as a desk calculator, it is somewhat easier to continue calculations, for example:</p>
<pre><code>>>> tax = 12.5 / 100
>>> ... | <p>A variable is masked if some other variable with the same name exists, which is preferred. An example is having a global variable x. If you're in a function which also has a local variable x, then the global won't be accessible, without special measures the local variable is preferred whenever you use identifier x i... |
Creating arrays of structs using text file <p>Given a text file with a semi-known format. Total characters in 1 line will be less than 1000. Zinteger is just a normal integer but it serves a different purpose. String terminated via space.</p>
<p>String ZInteger Integer Integer</p>
<p>String ZInteger Integer Integer I... | <p>Your structure looks reasonable, however, it is missing a field to store a count for the number of pairs:</p>
<pre><code>typedef struct {
int num1;
int num2;
} int_pair_t;
typedef struct {
char term[1000];
int zinteger; /* so named to avoid confusion */
int n_pairs;
int_pair_t *pairs;
} ... |
NewbieQ: Jupyter HTML command not working when multiple code lines <p>I'm new to Jupyter Notebook and have this simple line of code:</p>
<pre><code>HTML('<b>Question</b>')
Q=1
</code></pre>
<p>I have found that the first line only works when nothing else comes after it. Is this normal? Do I have to have e... | <p>There are two things at play here:</p>
<ol>
<li><code>HTML</code> creates an HTML <em>object</em>, whose <a href="https://nbviewer.jupyter.org/github/ipython/ipython/blob/5.0.0/examples/IPython%20Kernel/Rich%20Output.ipynb" rel="nofollow">rich representation</a> is the HTML string <code><b>...</code>. Instant... |
use variables in Google Chart Options Javascript <p>I have created a Google Pie Chart using the following code:</p>
<pre><code>var data = google.visualization.arrayToDataTable(array);
var options = {
title: 'Meta Share',
is3D: true,
sliceVisibilityThreshold: .04,
slices: { 6 : {offset: 0.2},
... | <p>You can't use variables as keys in object literals, you'd have to first create the object, then use brackets to use the variable as a key</p>
<pre><code>var slice = 8;
var slices = {};
slices[slice] = {offset: 0.2};
var data = google.visualization.arrayToDataTable(array);
var options = {
title : 'Meta Share... |
What are the reserved keywords in Elm? <p>Every once in a while you get a compiler error like this:</p>
<pre><code>It looks like the keyword `port` is being used as a variable.
</code></pre>
<p>That's annoying. Is there a complete official list of these keywords? I've gotten as far as finding <a href="https://github.... | <p>According to the <a href="https://github.com/elm-lang/elm-compiler" rel="nofollow">elm-compiler source code</a> the <a href="https://github.com/elm-lang/elm-compiler/blob/master/src/Parse/Helpers.hs#L25-L35" rel="nofollow">list of reserved keywords</a> is:</p>
<pre><code>reserveds :: [String]
reserveds =
[ "if"... |
How to remove a grey shadow from a JPEG? <p>So in Photoshop we all know it's relatively easy to remove a white background from a .jpg image if the contrast is quite visible.</p>
<p>The problem with this image though is it has a grey shadow at the bottom of the image that is reliant on the white background, and therefo... | <p>You can use the Polygonal Lasso Tool. Manual removing.
Zoom to the shadow, select it with the Polygonal Lasso Tool > Right click and : Refine the edge + give it a bit of Feather and paint using the background color of the image.</p>
|
Lato Font not rendering in IE but its working fine in Chrome <p>I am using Google Lato font for my UI Development perspective but i had a problem when i using lato font it doesn't render correctly in IE but its working fine in Chrome Browser, I couldn't understand what happened?</p>
<p><br/>
I just download the Google... | <p>I used google font lato via</p>
<pre><code><link href="https://fonts.googleapis.com/css?family=Lato&amp;subset=latin-ext" rel="stylesheet">
</code></pre>
<p>and it renders properly on IE11 (on windows) as well as chrome , so I suggest try to used google font from google api instead of downloading it on u... |
unable to send ckeditor data using Ajax post <p>I have a textarea which using ckeditor</p>
<pre><code><textarea rows="25" cols="50" id="content" name="content" required="required"></textarea>
<script type="text/javascript">
CKEDITOR.replace( 'content' );
</script>
<input type="submit" na... | <p>You need to disable encoding of HTML entities on Ckeditor. Then, once you POST your data, you should be good. See more info here...</p>
<p><a href="http://ckeditor.com/forums/CKEditor-3.x/Trying-disable-html-entities-not-working" rel="nofollow">http://ckeditor.com/forums/CKEditor-3.x/Trying-disable-html-entities-no... |
Selecting all the records from table to which given number belongs to <p>Suppose I have following three records in my model :</p>
<pre><code>#<Rda:0xf6e8a0c
id: 1,
age_group: "18-100",
weight: "60",
nutrient: "energy(kcal/day)",
value: "2730",
created_at: Sat, 15 Oct 2016 08:21:43 UTC +00:00,
updated_at: Sat... | <p>You might do</p>
<pre><code>def self.foo(age)
all.select { |rda| Range.new(*rda.age_group.split('-').map(&:to_i)).cover? age }
end
</code></pre>
|
PDF report generating in php <p>I have a php file which generate pdf report of guest reviews from the table. It shows well. But problem is in the report , Review cell content shows in a single line. Not breaks it. Please help me to break the line in review cell in a suitable point.</p>
<p><img src="https://i.stack.img... | <p>You need to use <strong>MultiCell</strong>. Here is the example</p>
<pre><code>$pdf->MultiCell(55, 5, $row['review'], 1, 'L', 1, 0, '', '', true);
</code></pre>
<p>And here is the example from the <strong>tcpdf</strong>: <a href="https://tcpdf.org/examples/example_005/" rel="nofollow">https://tcpdf.org/examples... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.