input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Flexbox 2 column layout with parent scolling <p>I'm trying to create 2 column full height design by using flexbox. When i adding scrolling to whole middle part than i have a strange behavior. It seems that flex-grow/stretch doesn't grow/stretch other items if parent container has a scrollbar.</p>
<p>Here is my <a href... | <p>I see that you have added <code>height: 100%</code> to <code>container</code> which inherits the height of the <code>body</code> element. </p>
<p>So that means When you apply <code>overflow</code> to <code>#container section</code>, it gets viewport height only.</p>
<p>So to take the world go back to normal, remov... |
Facebook Like icon not vertically aligned <p>When adding the <a href="https://developers.facebook.com/docs/plugins/like-button" rel="nofollow">facebook like button</a> into my page, it aligns with text in the body of the page, but not the navbar, where it will appear higher than the rest of the text. I was able to fix ... | <p>This should work. </p>
<pre><code>.fb-like {
vertical-align:middle;
line-height: parent height;
}
</code></pre>
|
Accessing pre-configured IIS response headers from a web service <p>How to access IIS-configured response headers from a Web API 2 service?</p>
<p>In my IIS configuration there is a pre-configured response header <code>Environment=DEV</code>, which I need to check to figure out which environment settings to use.</p>
... | <p>I don't think you should dependent on response headers as they are added to response by IIS at a very later stage in the pipeline and the control is already out of WEB API.</p>
<p>If you have to do this you can go with URL Rewrite + Server Variables. Install URL Rewrite and add a rule in your web.config under syste... |
SwiftyJSON supported in Xcode 8 and iOS 10? <p>I recently upgraded my Swift iOS application from <code>Xcode7</code> to <code>Xcode8</code> and deployment platform from <code>iOS 9.3</code> to <code>iOS 10</code>. My application started breaking with errors like this:</p>
<blockquote>
<p>Module file was created by a... | <p>At the time of writing this: no.</p>
<p>But there is a fork of the <code>swift3</code>-branch which is working with the GM seeds.</p>
<p><a href="https://github.com/acegreen/SwiftyJSON">https://github.com/acegreen/SwiftyJSON</a></p>
|
dnn uxguide not helpful <p>The DNN uxguide</p>
<p><a href="http://uxguide.dotnetnuke.com/" rel="nofollow">http://uxguide.dotnetnuke.com/</a></p>
<p>purports to provide patterns that would be useful in writing DNN modules, but many of them do not work correctly. </p>
<p>Take the Simple Form Demo - if I use the Markup... | <p>DNN hero Sebastian explains:</p>
<p>The UX Guide was created for DNN 6 and UX has been overhauled in DNN 7 and 8 - unfortunately without providing a similar guide. You should have a look at the latest module development templates - either MVC or SPA, which are now methods of choice. Another starting point might be ... |
Firebase orderByChild in android; can't get it to work <p>I have data structure as:</p>
<pre><code>https://law-apps-44h221543638e.firebaseio.com/apps to promote/0/ >> name:"First App", package:"fra"
https://law-apps-44h221543638e.firebaseio.com/apps to promote/1/ >> name:"Second App", package:"sca"
https:/... | <p>Ok so I found the answer to this question and I am writing it so others may benefit from it. I was using an older technique wherein I was finding from datasnapshot my apps using their parents' numbers and due to this, I was delibrately undoing the ordering.</p>
<p>Now I have used dataSnapshot.getChildren().iterator... |
How to add the single element in xml with the help of xsl? <p>How to add the single xml element with closing tags in xml with the help of xsl stylesheet.</p>
<p>here the below is my xml.</p>
<pre><code> <Checkpax xmlns="http://xml.api.com/test">
<customerLevel>
<customerDetails>
... | <p>The general structure of your XSLT is good, with the XSLT identity template and overriding templates for elements you wish to change. The problem is with a couple of you templates. Firstly with this one...</p>
<pre><code><xsl:template match="ns0:customerLevel/ns0:productLevel">
<xsl:copy-of select="."/... |
Gulp + browserify + babelify: "Unexpected token" for JSX code <p>The code I tried to transpile is this:</p>
<pre><code>var React = require('react');
var ReactDOM = require('react-dom');
var listOfItems = <ul>
<li className="item-1">Item 1</li>
<li className... | <p>From the <a href="https://github.com/babel/babelify" rel="nofollow"><code>babelify</code> docs</a>:</p>
<blockquote>
<p>As of <a href="http://babeljs.io/blog/2015/10/29/6.0.0/" rel="nofollow">Babel 6.0.0</a> there are <strong>no plugins included by default</strong>. For babelify to be useful, you must also includ... |
Decorators in class methods: compatibility with 'getattr' <p>I need to make wrappers for class methods, to be executed before and/or after the call of a specific method.</p>
<p>Here is a minimal example:</p>
<pre><code>class MyClass:
def call(self, name):
print "Executing function:", name
getattr... | <p>This has nothing to do with <code>getattr()</code>. You get the exact same error when you try to call <code>my_function()</code> directly:</p>
<pre><code>>>> engine.my_function()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callabl... |
unlist and merge selected columns to data frame in R <p>Suppose I have a list such like: </p>
<pre><code>df1<-data.frame(n=letters[1:4], x=1:4, y=2:5, z=3:6)
df2<-data.frame(n=letters[2:5], x=2:5, y=3:6, z=4:7)
df3<-data.frame(n=letters[3:7], x=2:6, y=3:7, z=4:8)
ls<-list(df1, df2, df3)
ls
[[1]]
n x y z... | <p>We get the <code>unique</code> column names from the <code>list</code> of <code>data.frame</code>s except the 'n' ('nm1'), loop through those (<code>lapply(nm1,...</code>), subset the columns of each of the 'data.frame' in 'ls' (<code>lapply(ls, function(x) ...</code>), and use <code>Reduce</code>, with <code>merge<... |
How to add an ASCII value of a byte to an integer in golang? <p>I'd like to get a byte[] variables' asic value added to an integer. For example, I fisrt read all input in a byte[] buffer. And then I get out a number string "123" in it. And then I can assign it to an integer by ('1' - '0')*100 + ('2' - '0')*10 + '3' - '... | <p>In go, you can convert byte array to string with the string() coercion and then use strconv.Atoi on it. Presumably, you also want to use slice operations to isolate just the part of the input you want to convert.</p>
<pre><code>package main
import (
"strconv"
"fmt"
)
func main() {
data := []byte { 0x... |
Run container without assigning a public IP using devops <p>I want to run a docker container (using Bluemix DevOps Services) without assigning a public IP. Wondering how to do that...its always assigning a public IP.</p>
<p>Thx</p>
| <p>The current default deploy script (you can see the git in the script box) for a single container is <a href="https://github.com/Osthanes/deployscripts/blob/master/deploycontainer.sh" rel="nofollow">https://github.com/Osthanes/deployscripts/blob/master/deploycontainer.sh</a></p>
<p>Looking at that, the port field is... |
phantomjs not loading instagram and pintersest webpages <p>I'm using PhantomJS 2.1.1 in python 2.7.12 under Ubuntu Server 16.04.1, with Display from pyvirtualdisplay</p>
<p>PhantomJS is unable to load instagram interactive dom pages (<a href="https://www.instagram.com/accounts/login/" rel="nofollow">https://www.instag... | <p>SOLVED.</p>
<p>I solved compiling phantomjs on Ubuntu Server directly from git repository.
So maybe the pre-compiled binaries are not complete.</p>
<p>Details here: <a href="http://phantomjs.org/build.html" rel="nofollow">http://phantomjs.org/build.html</a></p>
|
TeraData Query to get min and max from a table <p>I have a table named <code>HMS_PGHL8_HQID_MAP_DEMO</code> and database named <code>UDMTOOL_STG</code>.</p>
<p>Below query fetches me reuired values.</p>
<pre><code>SELECT udm_main.RECORD_ID AS record_id ,udm_main.HMS_PGH_NODE_ID AS hms_pgh_node_id,
udm_main.... | <p>You can use <code>QUALIFY</code> to filter the MIN/MAX:</p>
<pre><code>SELECT udm_main.RECORD_ID,udm_main.HMS_PGH_NODE_ID AS hms_pgh_node_id,
udm_main.HMS_PGH_NODE_NAME AS hms_pgh_node_name,udm_main.HQ_NODE_ID AS hq_node_id, udm_main.HQ_NODE_NAME AS hq_node_name,
udm_main.NODE_TYPE_IND as node_type_... |
Combine query for sum of two tables with date <p>I have two tables like following</p>
<p>challenge_table</p>
<pre><code>Challenger chdate
----------------------
abc 11-02-2012
aaa 12-02-2012
ccc 12-02-2012
bbb 13-02-2012
ddd 14-02-2012... | <p>Since MySQL does not support a FULL OUTER JOIN, you need to combine the 2 tables with a UNION.</p>
<p>Then group by the date and count the values of the 2 tables</p>
<pre><code>select caldate, count(distinct Challenger), count(distinct Initiateid)
from
(
SELECT Challenger, null as Initiateid, chdate as caldate... |
How to concatenate strings in a for-loop? <p>I'm using a loop in C and trying to determine how <code>fprintf</code> works. </p>
<pre><code>fprintf(out, "%02X", (int)(ch & 0x00FF);
</code></pre>
<p>This statement prints out a single hex value char for every iteration of the loop.</p>
<p>Can I store this in a var... | <p>Maybe this can help.</p>
<p>The program expects a number of decimal inputs (max 50). It prints the corresponding hex value and append the char to a string (zero terminated char array). Finally, it prints the string.</p>
<pre><code>#include <stdio.h>
int main(void) {
const int N = 50;
int i = 0;
... |
Understanding Cross Browser Transform & Origin <p>I'm obviously missing something here and hoping someone can fill in the blanks for me about cross browser <code>transform</code> & <code>origin</code> in use with SVG.</p>
<p>So the quick version of the question, why does the example below look/work as expected in ... | <p>As @DaniP points out, caniuse.com is going to be your go-to resource for figuring out cross-browser issues. From the more direct link <a href="http://caniuse.com/#feat=transforms2d" rel="nofollow">http://caniuse.com/#feat=transforms2d</a>: IE <= 10 doesn't support transforms on svg elements.</p>
<p>And FF has tr... |
How to give score only once for each level? <p>In my game i have many levels.Each level have 3 objectives.For completing one objective in each level the player gets one star.the value of all the stars player gets in all the levels is saved as totalstars.now the problem is i want increment the value of totalstars only o... | <p>The most basic way to do this would be to create a N * 3 (n being the amount of levels) array. So with booleans. So it would like this</p>
<pre><code>int[,] objectives = new bool[N, 3]
{true , false, true},
{false, false, false}
</code></pre>
<p>Then on increment just do a check whether they have already obtained ... |
Delete Strings from an array in Ruby <p>Lets say I have an Array that looks like this:</p>
<pre><code>arr = [ 1, 5, "dog", 6 ]
</code></pre>
<p>How can I delete the String so that my output will look like this:</p>
<pre><code>[ 1, 5, 6 ]
</code></pre>
| <p>The other way round would be to use <em>case-equal</em>:</p>
<pre><code>[1, 5, "dog", 6].reject &String.method(:===)
#â [1, 5, 6]
</code></pre>
|
How to create a burn down for an epic in TFS? <p>This question is on how to use either TFS build in reporting or any other means to create a burn up or burn down the chart. <p>
I have an epic, which spawns multiple iterations, and some may not be even assigned to an iteration. Is it possible to create either a burnup o... | <p>You can try PivotTable in Excel, and filter the work item type, then you'll get Epic work item type and all iteration paths:</p>
<p><a href="http://i.stack.imgur.com/6nrBe.png" rel="nofollow"><img src="http://i.stack.imgur.com/6nrBe.png" alt="enter image description here"></a></p>
|
js mousedown with touch <p>is there a way to detect whether a 'mousedown' is a touch right click (hold the finger about 1 sec in place) or just a normal right click?</p>
<p>I think chrome can do this with "ev.originalEvent.sourceCapabilities.firesTouchEvents". But only chrome.</p>
<pre><code>$('#container').mousedown... | <p>I think you can use setTimeout/clearTimeout to count 1s. The pseudo code:</p>
<pre><code>var global_timer = null;
$('#container').mousedown(function(ev) {
if (ev.button === 2) {
global_timer = setTimeout(fireTouchRightClick, 1000);
}
});
$('#container').mousemove(function(ev) {
cancelTouchRightClick();
})... |
Input.mousePosition.x or y equivalent on Raycast with World Space canvas <p>I'm trying to convert a mouse event into a VR Raycast event.</p>
<p>I've <code>Input.mousePosition.x</code> & <code>Input.mousePosition.y</code> as the coordinate of a mouse click event. I want to apply the same event on a VR Raycast hit.<... | <p>I'm not a huge expert on VR in Unity, but you would usually use <code>Camera.WorldToScreenPoint</code> for these purposes. To use it on the main camera, use these lines:</p>
<pre><code>Ray ray = new Ray(CameraRay.transform.position, CameraRay.transform.forward);
RaycastHit hit;
if (GetComponent<Collider>().R... |
Clang-Tidy can't find my header files <p>new to clang and clang-tidy here.</p>
<p>I have a project with this type of structure:
<code>
project/
- build/
- cmake/
- component1/
- src/
- someFile.cpp
- someFile2.cpp
- someFile.hpp
- someFile2.hpp
- component2/
- etc...
-
</code></p>
<p>W... | <p>This answer will only help you if you use CMake to manage your project.</p>
<p>CMake has an option to create a .json file that contains all the compiler calls with command line options. This file can be given to clang-tidy with the option:</p>
<pre><code>-p <build-path> is used to read a compile command data... |
Python zip - Why do we need to unpack the argument? <p>I'm trying to understand the need to unpack the arguments using <code>*</code> when the input to <code>zip</code> is a 2D list. The <a href="https://docs.python.org/3/library/functions.html#zip" rel="nofollow">docs</a> state,</p>
<blockquote>
<p>[zip] Returns a... | <p>Consider this example:</p>
<pre><code>>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> z = [7, 8, 9]
>>> zip(x,y,z)
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
>>> zip(x,y)
[(1, 4), (2, 5), (3, 6)]
>>> zip(x)
[(1,), (2,), (3,)]
>>> zip()
[]
</code></pre>
<p>Observe that ... |
What does a knot mean as a software metric? <p>We use a software quality analysis tool that calculates quality metrics of C code, e.g. levels of nesting, complexity, static paths, etc. One of the metrics it calculates is the number of 'knots' in a function. What does this metric mean? Is it desirable to have less knots... | <p><em>Knots</em> have been around for quite some time (1979, Woodward, Hennell, Hedley ) in the software metrics world. The concept of <em>knots</em> can basically be broken down to the amount of knots (or pathes/branches...) you would have to draw in a flowchart of your software, i.e. loops, decision points, jumps...... |
Sabre seat map based on flight number <p>I am developing an app which will show live seat availability based on flight number using sabre apis.
<a href="https://developer.sabre.com/io-docs" rel="nofollow">https://developer.sabre.com/io-docs</a></p>
<p>I didnt find any way to do it.</p>
<p>Sabre needs marketing career... | <p>I believe that you want the seat map, this shows the available seats.
<a href="https://developer.sabre.com/docs/read/rest_apis/air/search/seat_map" rel="nofollow">https://developer.sabre.com/docs/read/rest_apis/air/search/seat_map</a></p>
<p>Keep in mind, that if prices are returned they are as extra, the price of ... |
MySql if distinct print true <p>I am trying to write a sql statement that will print the id and true if it is distinct false if not. Here is my query</p>
<pre><code>Select Id, IF(Id IS DISTINCT('True', 'False')) from Table;
</code></pre>
| <p>I'm not sure what are you looking for exactly. But if it is a rowset indicating if the Id you have is unique or not, this may help:</p>
<pre><code>SELECT
Id,
case when (select count(Id) from Table where id = T.id)=1 then 'True' else 'False' End As 'isunique'
FROM
Table T
</code></pre>
|
No instance for (Fractional a0) arising from a use of âitâ <p>I am writing a function, but I'm unable to find a proper solution. How can I fix this:</p>
<pre><code>findLoot val [] = 0
findLoot val ((x:y:[]):xs) | val == 0 = 0.0
| val < y = ((val*x)/y)
| val... | <p>The problem is that Haskell can only do arithmetic on values of the same type. When you do <code>x + y</code> or <code>x * y</code> or <code>x == y</code>, then <code>x</code> and <code>y</code> must have the same type.</p>
<p>The second issue is that Haskell's numeric types fall (mainly) into two classes, integral... |
Importing Tensorflow Session Bundle in Python <p>How do you import from inside Python a Tensorflow session bundle? The docs explain <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/session_bundle#exporting-python-code" rel="nofollow">exporting from Python</a> and <a href="https://github.... | <p>SessionBundle consists of a checkpoint and a MetaGraph definition that's needed for serving (see <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/session_bundle" rel="nofollow">here</a>). Since TensorFlow Serving is in C++, I don't think you will find any Python examples).</p>
<p>How... |
how to get specific item sold history through eBay Api <p>I am using the eBay shopping API and I cannot find a way to get the specific item sale history fields. I tried Google but found nothing.</p>
<p>Thanks in Advance!</p>
| <p>You have <a href="http://developer.ebay.com/Devzone/XML/docs/Reference/ebay/GetItemTransactions.html" rel="nofollow">GetItemTransactions()</a> in the Trading API that might suit your needs.</p>
|
How to SELF JOIN using Sequelize in Node <p>I'm using sequelize-cli for migrations and have researched different scenarios but there doesn't seem to be a definite solid answer as to how to self join. I want to have a join table called friendships which joins users and friends (which are essentially just users).</p>
<p... | <p>There is many-to-many relation, it should go through <code>belongsToMany</code> associations, no more relation is needed. There is no need even to define friends table, sequelize will create table automatically</p>
<pre><code>'use strict';
module.exports = function(sequelize, DataTypes) {
var user = sequelize... |
CSS menu overlapping another menu <p>I am using Wordpress for my website and in one of the template files i have added my own menu (see fiddle)</p>
<p><a href="https://jsfiddle.net/bxdm4kye/" rel="nofollow">https://jsfiddle.net/bxdm4kye/</a></p>
<p>I am having an issue with the main wordpress menu now which overlaps ... | <p>Here is the solution. Please change the colors like you want to have. Hover the Switches item to see the effect.</p>
<p>See also on <a href="https://jsfiddle.net/bxdm4kye/1/" rel="nofollow">JSFiddle</a></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class... |
Javascript new Date() returns 31 Dec 1969 <p>I am trying to obtain a date by feeding year, month and day parameters to <code>new Date()</code>. Like so:</p>
<pre><code>Logger.log(dates[i]);
var date = dates[i].trim();
Logger.log(date);
var dateMDY = date.split("/");
Logger.log(dateMDY);
Logger.log(parseInt(dateMDY[2],... | <p>The problem is <code>parseInt("09")</code> with no radix.</p>
<p>Shockingly, <code>parseInt</code> in Google Apps Script (which isn't, quite, JavaScript) still treats a leading 0 in a string as meaning it's in octal. (This was never in the JavaScript spec, but some engines implemented it; eventually it was explicit... |
Dropwizard - Where is my YML file? <p>I followed the Getting Started guide of Dropwizard by executing the maven command below:</p>
<pre><code>mvn archetype:generate -DarchetypeGroupId=io.dropwizard.archetypes -DarchetypeArtifactId=java-simple -DarchetypeVersion=0.9.1
</code></pre>
<p>I was able to run, modify the pro... | <p>Yes, I don't think a YAML file is generated by itself since Dropwizard can function without having one.</p>
<p>It's only when you <strong>tweak an inbuilt configuration</strong> or <strong>add one of your own</strong>, you'll need to specify it the <code>AppConfiguration</code> class and provide the corresponding v... |
VSTS returns Bad Request, when specifying changeset for build <p>I'm using <strong>VSTS</strong> for my <strong>Nightly/CI</strong> builds. </p>
<p><strong>VSTS</strong> pulls the code from <strong>TFS</strong> repository. </p>
<p>I noticed that triggering the build against (specific changeset E.g.'33333', 'C33333') ... | <p>You mean Team Foundation Version Control repository type. Based on my test with VSTS, I can reproduce that issue, the same as REST API.</p>
<p>You can vote this feedback (<a href="https://connect.microsoft.com/VisualStudio/feedback/details/3102566/specifying-a-source-version-in-vsts-returns-a-400-bad-request" rel="... |
iOS - afnetworking 3 delete with body <p>I have a rest service which works with DELETE method and http body. But I don't get it to work.</p>
<p>This is what I've tried.</p>
<pre><code>super.manager.requestSerializer.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", nil];
</code></pre>
<p>An... | <p><code>AFNetworking</code> does not support the combination of <code>DELETE</code> with an HTTP body. This is because the HTTP spec does not require such support.</p>
<p>See <a href="http://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request">Is an entity body allowed for an HTTP... |
Filter by multiple checkboxes angular <p>I've got array of objects containing STATUS field. I need to be able to filter by name, using search field, also I need to show only items with status READY, or only with status FAILED, or items with status Failed and items with status Ready. I'm using angularJs</p>
<pre><code>... | <p>The comparasion won't match, the checkbox will set the values of "getStateClass" to "true" or "false", so the comparasion you are making will never match. You could make the following change:</p>
<pre><code>vm.getStateClass = {
taskReady: true,
taskPending: true,
taskFailed: true,
... |
Where do you put SQL RAISERROR code? <p>I'm trying to set up a custom error message to pass to MS Access (from SQL Server) when a user enters a duplicate key (instead of system message 2627). I've read up on sp_addmessage and RAISERROR and TRY/CATCH blocks which all make perfect sense. But nowhere I've looked does it... | <p>Don't think about it in terms of users entering duplicate keys. Instead, think in terms of users just entering keys, some of which turn out to be duplicates when you try to insert them. It's a subtle difference, but it helps you here, because it means you think in terms of having your code available for all new tabl... |
How do I correct this trigger function? <pre><code>create trigger trig1
-> after insert on student
-> for each row
-> when (new.name="rgb")
-> begin
-> insert into class ("ug1",1)
-> end;
</code></pre>
<p>it tells me that something is wrong near when statement. Can you help me... | <p>Your trigger statement should be like below. See <a href="http://dev.mysql.com/doc/refman/5.7/en/trigger-syntax.html" rel="nofollow">Trigger Syntax and Examples</a></p>
<pre><code>create trigger trig1
-> after insert on student
-> for each row
-> begin //begin should come... |
Maven structure with a single exposed artifact and internal dependencies <p>I'm currently building an application and I have a maven project structured like so:</p>
<pre><code>|-> root
|
|-------> ui
| |---> pom.xml
|
|-------> core
| |---> pom.xml
|
|
|-------> pom.xml
</code></pre>
<ul... | <p>You can create another module, <code>myapp</code>, that will specifically package your application including <code>ui</code> and <code>core</code>. This new module will depend on both the <code>ui</code> and <code>core</code> modules, and Maven will take care of the build order itself. Then, you can configure your b... |
shiny histogram not filtering correctly using ggplot2 <p>I am making a shiny web app where a histogram will be made based on two sets of filtering criteria (Regions = "Americas", "EMEA", etc. and Metrics = "ElapsedTime", "LabourTime", etc.). I first made a function in base R and made sure that what I was wanting to do ... | <p>I guess there are some better solutions but with few changes your code should work. Try to replace to code defining the reg.filt with:</p>
<pre><code>reg.filt = reactive({
df <- as.data.frame(CallClosure[CallClosure$Region == input$Region, input$Metric])
names(df <- input$Metric)
... |
How to read int and strings from a text file? <p>Alright so I've recently started toying with C++ and I have a text file that I want to hold some values. Right now it's name, ability, attack, and defense on every line of my data file, so for instance:</p>
<p>Bill Punch 10 5</p>
<p>Jack Jab 7 7</p>
<p>Joe Kick 8 4</p... | <p>There are better methods to read a CSV than you are using. Your method to read in a file of data are complicated and injecting defects. Simplifying your algorithm can reduce the number of defects. </p>
<p>For example, using a structure to model the data row. Let us call each line of data, a record. </p>
<pre>... |
Replace characters in string <p>I need to replace values in a string:</p>
<pre><code>public static String replaceVals(String str) {
String[] array = str.split("");
String newStr = "";
for (int i = 0; i < array.length; i++) {
newStr += (array[i] == "T") ? "F" : "T";
}
return newStr;
}
</code></pre>
<p... | <p>I would just convert your given String to a char array, modify the array, and return a new String using the modified char array. </p>
<pre><code>public static String replaceVals(String str) {
String[] array = str.toCharArray();
for (int i=0; i<array.length;i++) {
array[i] = array[i] == 'T' ? '... |
How to read text file data and display in dataGridView with vb.net <p>I am new to reading from and writing to text files. I need to read the file and store the data of each cell in their respective arrays.</p>
<p>My text file has this character: "|" for column separators. The first column is string based,and the secon... | <p>You are trying to assign whole data lines to the individual variables. Instead, you need to split the value returned by <code>ReadLine</code> and convert the parts to the appropriate data type. Adding <code>Option Strict On</code> will also help (either at the top of the file or in the project compile options). Y... |
How to chage timer value format to MM:Sec from fixed counter in angular js <p>I have AngularJS code for a timer where, on starting the counter, the timer starts its countdown backward from 300 to 0. It is working fine. But now I want to replace 300 with MM:SEC format(clock) i.e.,5:00 and go on and end at 0:00 which I a... | <p>Why don't you try something like this: <a href="http://jsfiddle.net/z18j7o2q/2/" rel="nofollow">http://jsfiddle.net/z18j7o2q/2/</a></p>
<p>What you want is a custom filter. Answer borrowed from <a href="http://stackoverflow.com/questions/28394572/angularjs-seconds-to-time-filter">here</a></p>
<pre><code>filter('se... |
Having problems with the logic in mysql stored procedures <p>I having a problem with the logic problem on checkfirstnamecount!=1 for example:</p>
<pre><code>DELIMITER go
/* Passing the parameters */
/* I still get firstname error message every time I tried to execute*/
Create procedure registerusers(
... | <p>Check your procedure code as pointed below. So the first name <code>Jerry</code> matches multiple records and thus the end result.</p>
<pre><code>If(checkfirstnamecount!=1) then
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Fill out the First Name ';
</code></pre>
<p>Where your local variable <code>checkfirstnamecou... |
Test with my own smartphone using Unity3d plugin <p>I'm developing a game using Unity3D and I have a question about controllers. I set the "Browser start mode" as "Normal", then the airconsole web is opened properly but when I put the code into my smartphone, just a "loading" screen is shown (in the smartphone screen I... | <p>Look at this from the FAQ at <a href="http://developers.airconsole.com" rel="nofollow">http://developers.airconsole.com</a>:</p>
<blockquote>
<p>I can't load my game in the simulator or on a test phone!</p>
<p>Make sure your screen.html and controller.html are accessible from all
devices. Let's assume you ... |
Use of DLM and DSD at same time in SAS <p>I am new to SAS and learning it at the moment.
I have read that we can use both DSD and DLM options to the infile statement.</p>
<p>But however i get an error when executing the below with data having multiple delimiters.</p>
<p><strong>Code:</strong></p>
<pre><code>data tes... | <p>The problem here is your DLM is '@' (meaning you say the field delimiter is @ character) but your data shows ',' as the delimiter (comma). </p>
<p>As such, your error is that SAS is trying to read all of hta ("102,vis2,10mg") into one numeric field (pid). You either need to change to <code>dlm=','</code> or have... |
Internet Explorer responsive images losing aspect ratio <p>Internet Explorer will sometimes lose the aspect ratio of responsive images using <code>max-width: 100%</code> whether or not <code>height: auto</code> is set. The 'sometimes' depends on the image file used. So this is not a coding issue, but a glitch in IE tha... | <p>Swap height: auto for max-height.</p>
<pre><code>max-width: 100%;
max-height: 300px;
</code></pre>
<p>Here's a screenshot in IE, images maintain aspect ratio.
<a href="http://i.stack.imgur.com/WC8wp.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/WC8wp.jpg" alt="enter image description here"></a></p>
|
exporting some of data in a text file to a CSV file, while text file has different types of delimiters <pre><code>TT1 4444 | Drowsy | 9 19 bit drowsy
TT2 45888 | Blurred see - hazy | 29 50 little seeing vision
TT4 45933 | Excessive upper pain | 62 78 pain problems
</code></pre>
<p>I want export part of the info... | <p>I'm assuming you can read in the data as a list of strings. The code parses them using regular expressions (re) to the desired output which you can then write out to a csv file:</p>
<pre><code>import re
#read lines from file using:
#lines = my_file.readlines()
lines = ["TT1 4444 | Drowsy | 9 19 bit drowsy",
... |
Yii2 - How to filter a related model via a pivot table <p>This is my first question, I hope someone can help me.</p>
<p>How to filter a related model (via a pivot table) ? </p>
<p>I have <em>model A</em>, <em>model A_B</em>, and <em>model B</em>. <strong><em>A_B</em></strong> is the pivot (<em>id, a_id, b_id</em>)</p... | <p>You can use multi relation by using hasMany relation and filter as below.</p>
<p><strong>Model A file</strong></p>
<pre><code>namespace app\models;
use Yii;
class A extends yii\db\ActiveRecord
{
....
function getRelated(){
return $this->hasMany(B::className(), ['id' => 'b_id'])
->viaTable(A_B::tableNa... |
Ruby gem native extension with Crystal? <p>I'm just trying to gather some general information, as I'm looking to improve performance of ActiveModelSerializers.</p>
<p>I've also never written a native extension before, but have looked at some C extensions and Rust extensions.</p>
<p>My Questions: </p>
<ul>
<li>Has th... | <p>Since the Ruby API is written in C, it should be possible to create Crystal bindings for it, then write Ruby extensions in Crystal.</p>
<p>Have a look to the <code>crystalyzed_ruby</code> project for example:
<a href="https://github.com/phoffer/crystalized_ruby" rel="nofollow">https://github.com/phoffer/crystalized... |
Change the source of the image inside the <td> that has alt=âselectedâ. Image has no ID tag <p>Trying to change the source of an image with JavaScript or jQuery. Its not possible for us to change the source of the file or to replace the image itself. The table is created programmatically.</p>
<p>Problem is that ... | <p>try this :</p>
<pre><code>$( "img[alt='selected']" ).attr('src',"http://myimage.png" );
</code></pre>
|
Powershell - Process to test a file for lock, and then document process locking file with counter? <p>I have been beating myself up over trying to come up with a process to accomplish a specific set of tasks, what I need to do is, test file for a lock from a specific program, if a lock is detected I need to increment a... | <p>You can start with something like the code below:</p>
<pre><code>#Path to the files list. I'm assuming you will have one complete path per line.
$Paths = gc "c:\Temp\Paths.txt"
#Path to the log file
$logFile = "c:\Temp\Log.txt"
$counter = 0
foreach ($Path in $Paths)
{
$oFile = New-Object System.IO.FileInfo $Pa... |
IEnumerable versus List in a concrete class implementation <p>I am writing a class library for financial modeling. </p>
<p>I want to define the models using interfaces to create abstraction for testing, and the possible later addition of new concrete classes.</p>
<p>I am struggling on how to define lists of things, ... | <p>It depends on what you actually want to do. Having <code>List</code> or <code>IList</code> properties is not recommended, because you can do everything with it (like <code>Clear</code>, <code>Add</code> and so on) without the owning class know about it. This is not good for encapsulation. You wouldn't be able to do ... |
Efficiency of StringBuiler <p>I noticed there's a performance difference between these two styles of using StringBuilder:</p>
<pre><code>StringBuilder text = new StringBuilder();
// style 1
text.append("a" + "b");
// style 2
text.append("a").append("b");
</code></pre>
<p>It seems the more data text append, the less e... | <p>Style 1 needs to create an immutable string "ab" to be appended (to StringBuilder). Style 2 appends the string "a" and "b" directly into the StringBuilder.</p>
|
Add object property from input.value <p>Say I have an object with states as properties and an html input text field.</p>
<pre><code><input id="input" type="text">
</code></pre>
<hr>
<pre><code>var foo = {
"Wisconsin" : "Madison",
"Illinois" : "Springfield"
}
</code></pre>
<p>How can I add properties ... | <pre><code>foo.newValue = input.value
</code></pre>
<p>You are dealing with an object not an array.</p>
<p>So this will result in </p>
<p>{
"Wisconsin" : "Madison",
"Illinois" : "Springfield",
"newValue" : VALUE-OF-INPUT-FIELD</p>
<p>}</p>
<p><a href="https://jsfiddle.net/1mk1quow/7/" rel="nofollow">He... |
Spark streaming jobs duration in program <p>How do I get in my program (which is running the spark streaming job) the time taken for each rdd job.
for example </p>
<pre><code>val streamrdd = KafkaUtils.createDirectStream[String, String, StringDecoder,StringDecoder](ssc, kafkaParams, topicsSet)
val processrdd = strea... | <p>You can use the StreamingListener in you spark app. This interface provides a method onBatchComplete that can give you total time taken by the batch jobs. </p>
<p><code>context.addStreamingListener(new StatusListenerImpl());</code></p>
<p>StatusListenerImpl is the implementation class that you have to implement us... |
is jtextfield has a getEditor method <p>i search my problem but answers does not fit for my problem. My code below:</p>
<pre><code>jtf=new JTextField(15);
jtf.getEditor().getEditorComponent().addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent evt)
{
if(evt.getKeyCode() == KeyEvent.VK_EN... | <p>Can you give us more context?</p>
<p>I tried adding a enter listener on the text field and it seems to be working just fine, here is my code.</p>
<pre><code>package com.apixandru.jvshot;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.s... |
ruby how to add a hash element into an existing json array <p>I have code that outputs the following:</p>
<pre><code>car_id = ["123"]
model = [:model].product(car_id).map { |k,v| {k=>v} }
model = [{:model=>"123"}]
</code></pre>
<p>I would like to then add a new hash <code>:make</code> into the json like this:</... | <p><strong>Ruby convention for showing result of a calculation</strong></p>
<p>I assume you mean that</p>
<pre><code>model = [:model].product(car_id).map { |k,v| {k=>v} }
</code></pre>
<p>produces an array containing a single hash:</p>
<pre><code>[{:model=>"123"}]
</code></pre>
<p>and that you are not then e... |
Hibernate Cannot add or update a child row: a foreign key constraint fails <p>When I'm trying to save object into database I got error: </p>
<pre><code>java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`smartphones`.`smartphone`, CONSTRAINT `fk_smartph... | <p>You're trying to <code>add/update</code> a row to <code>resolution</code> that does not have a valid value for the <code>id</code> field based on the values stored in <code>smartphone</code>.<br>
You must first insert the row to your <code>resolution</code> table.</p>
|
Quotes/Double Quotes within PHP/MySql <p>This is the piece of code I am currently working with:</p>
<pre><code>$outputDisplay .= '<div class="col-md-3">
<p class="launch">Mission: '.$mission.'</p>';
//If there are mission details, they will be displayed here
if (!$details){
... | <p>Just use a <a href="http://php.net/heredoc">HEREDOC</a>, which eliminates having to worry about quotes at the PHP level:</p>
<pre><code>if ($details) {
$outputDisplay .= <<<EOL
<a href="{$outputDisplay}" target="_blank">Mission Details</a>
EOL;
}
</code></pre>
|
How to retrive data from Dynamics CRM Online using console application? <p>I am new in Dynamics CRM and I want to create a console application that can create a new record for account entity and can display a list of all account names from account entity from Dynamics CRM online.</p>
<p>This is my code:</p>
<pre><cod... | <p>Here is my answer</p>
<p>Inside Case 2: I've used following code:</p>
<pre><code>QueryExpression query = new QueryExpression { EntityName = "account", ColumnSet = new ColumnSet(new string[] { "name" }) };
EntityCollection account = crmService.RetrieveMultiple(query);
string name = "";
foreach (var count in account... |
Is nimbus.host a valid option in Storm 1.0.2 version? <p>There seems to be some conflicting information between <a href="https://issues.apache.org/jira/browse/STORM-1185" rel="nofollow">STORM-1185</a> and <a href="https://issues.apache.org/jira/browse/STORM-726" rel="nofollow">STORM-726</a>.</p>
<p>If we do not want H... | <p>Yes, you can leave <code>nimbus.hosts</code> there for now. You will get a log message warning that that configuration is deprecated, but things should still work.</p>
|
My ProjectEuler implementation is much too slow <p>These is the problem:</p>
<blockquote>
<p>2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?</p>
</blockquote>... | <p>This is my implementation for a C++ program.</p>
<p>Instead of <code>number++</code>, I go for <code>number += 2</code>, Why? because odd number are never divisible by 2 therefore reducing my search space from <code>O(n)</code> to <code>O(n/2)</code>. There is one more way to reduce space search, by shifting the co... |
Python Serial Writes to Arduino is different from Arduino's Serial Monitor's Serial Writes <p>I have a Python script that writes a string <code>test</code> to the Arduino serial port. If the arduino receives the <code>test</code> string, it should reply with a string <code>ok</code> and LED 13 should like up..</p>
<p>... | <pre><code>port = 'COM5'
ser = serial.Serial(
port=port,
baudrate=9600,
timeout=5
)
# you need to sleep after opening the port for a few seconds
time.sleep(5) # arduino takes a few seconds to be ready ...
#also you should write to your instance
ser.write("test\r\n")
# and give arduino time to respond
time... |
wso2 das 3.0.1 Error while starting binary data receiver: Address already in use <p>wso2 das 3.0.1 errors out while starting binary data receiver: Address already in use. It is running with default port 9443 with no or 0 offset.</p>
<p>On the same box, wso2 am 1.10.0 is running with port offset as -1000.</p>
<p>What ... | <p>Seems like API manager thrift server ports are not getting changed with the minus port offset. Can you change the port offset to a plus value (1000) instead of minus one and check please</p>
|
Why does my Xcode 8 GM have 50+ Simulator versions to choose from? <p>How can I fix this? I have 2.5 full pages of this: <a href="http://i.stack.imgur.com/lgQIb.png" rel="nofollow"><img src="http://i.stack.imgur.com/lgQIb.png" alt="enter image description here"></a></p>
| <p>Go into Window -> Devices. Then just select the Simulators you don't want and delete them (by hitting the Delete key, or right-clicking).</p>
<p>You can also un-select the "Show in Run Destinations Menu" item (when you right-click).</p>
|
Cannot connect to MQTT broker from ESP8266 <p>I have installed Mosquitto on my windows machine and it's a MQTT v3.1 broker (downloaded recently from mosquitto.org).</p>
<p>I am trying to connect to broker from ESP8266 and so far I have not been able to connect to the broker. I can connect to a public broker, but not t... | <p>Sorry, too long for a comment.</p>
<p>Both the <a href="http://nodemcu.readthedocs.io/en/latest/en/modules/mqtt/" rel="nofollow">NodeMCU MQTT docs</a> and the <a href="http://stackoverflow.com/questions/36667049/mqtt-esp8266-nodemcu-lua-code-not-publishing">SO question you referenced</a> make it clear that you need... |
React toggle button issue <p>I'm trying to get this switch <a href="https://github.com/pgrimard/react-toggle-switch" rel="nofollow">https://github.com/pgrimard/react-toggle-switch</a> working in my react project. It is currently working as expected (it toggles and calls the toggleFeature function), however i'm struggli... | <p>While binding the <code>_toggleFeature</code> function, you can give it arguments with which it will be called:</p>
<pre class="lang-js prettyprint-override"><code><Switch className= {this.props.description} onClick={this._toggleFeature.bind(this, 'toggle1')} on={this.state.on1}/>
<Switch className= {thi... |
Remove a package from within DrRacket <p>In the command line, I can add and remove packages with <code>raco pkg</code>. In DrRacket, however, package management is handled through either <code>File -> Install Package</code> (if you are only installing packages), or <code>File -> Package Manager</code> (if you wan... | <p>You can remove a package by going to: <code>File -> Package Manager</code>, and click on the second tab (<code>Currently Installed</code>) to see a list of all of your installed packages. Select the package you want to remove, and you will find a remove button in the bottom right corner. If you click that button ... |
Selecting specific COLUMNS after a previous select that returned one ROW <p>I am completely stumped here and am in need of help.</p>
<p>I have a Table called "2016Blocks" This table has rows for each individual. Each row has columns for every day of the year (365 columns for each row). </p>
<p>I currently have a sele... | <p>You'll have to use UNPIVOT function for that. As you have 365 columns so you might not want to mention 365 hardcoded column names. For this purpose you can use dynamic query. Finally you can use below query in subquery or insert records in temp table and add filter for BlockValue. Hope this helps.</p>
<pre><code>DE... |
Java: Reading data with type that isn't known in advance <p>I'm working on a project in which I have to read a bunch of features (properties) from a database (which is in the form of a CSV file).</p>
<p>This is how the file looks (formatted a bit for easier readability):</p>
<pre><code>IsFast; Speed; IsRed; R; G;... | <p>Your <code>List<Feature></code> uses the raw-type <code>Feature</code> (as the warning says). If you know what subtype <code>Feature</code> has you can use the generic type e.g <code>List<Feature<Boolean>></code>.</p>
<p>However if you want your <code>List<Feature</code> to contain <code>BoolFe... |
Why do flex items wrap instead of shrink? <p>I wonder if anyone could give me a simple intro about how flexbox layout gets calculated, especially in which priority order, for example:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre ... | <p>See <a href="https://www.w3.org/TR/css-flexbox-1/#layout-algorithm" rel="nofollow">Flex Layout Algorithm</a> in the spec:</p>
<blockquote>
<ol>
<li><a href="https://www.w3.org/TR/css-flexbox-1/#box-manip" rel="nofollow">Initial Setup</a></li>
<li><a href="https://www.w3.org/TR/css-flexbox-1/#layout-algorithm"... |
What is the maximum version of PHP that cakephp version 1.3.7 will work with? <p>I have a moodle course that uses cake 1.3.7 that has started generating errors. </p>
<p>These are the three that come up: </p>
<blockquote>
<ol>
<li>Redefining already defined constructor for class Object in /home/eslwow87/public_htm... | <p>you can open the file <code>Config/core.php</code> and change the error_reporting to this:</p>
<pre><code>Configure::write('Error', array(
'handler' => 'ErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED & ~E_STRICT,
'trace' => true
));
</code></pre>
<p>Or alternatively upgra... |
Pandas groupby object filtering <p>i have a pandas dataframe</p>
<pre><code>df.columns
Index([uâcar_idâ,uâcolorâ,uâmakeâ,uâyearâ)]
</code></pre>
<p>I would like to create a new FILTERABLE object that has the count of each group (color,make,year);</p>
<pre><code>grp = df[[âcolorâ,âmakeâ,âyea... | <p>I think you need add <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reset_index.html" rel="nofollow"><code>reset_index</code></a> and then output is <code>DataFrame</code>. Last use <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing" rel="nofollow"><c... |
How do I accomplish this with url rewriting? <p>I have a menu, which when you open goes to /#0 to indicate that the menu has been opened and the menu the slides in and shows. What I want to know is how to rewrite the url so that instead of site.com/#0 we simply get site.com. I believe this can be done with .htaccess th... | <p>Please try this if I'm getting your point. </p>
<pre><code> # Rewrite --- www.site.com/#0 => www.site.com
RewriteRule ^$ /?&%{QUERY_STRING}
</code></pre>
|
Windows Form. Limit User input to a certain range <p>I am creating a windows form program for class and I am trying to limit input for a 'weight' textbox from 1-1000. I got the user input to parse to a double but some reason the error message I created will not popup at the right time as intended. (The error message wi... | <p>instead of using KeyPress you should use TextChanged event
because if you use keypress the new char is not part of the control text yet.</p>
<pre><code>private void inputTextBox_TextChanged(object sender, EventArgs e)
{
var inputTextBox = sender as TextBox;
var sourceValue = inputTex... |
Issues while testing on AWS Auto Scaling, ELB, Cloud Watch <p>I created a Web App in JSP. One of my web app URL is to return a unique ID.</p>
<p>Here it is the URL.
<a href="http://www.biomobilestrokelab.com/GateKeeper/newUserId.jsp" rel="nofollow">www.biomobilestrokelab.com/GateKeeper/newUserId.jsp</a></p>
<p>It wor... | <p>I suggest you either reduce the number of requests per second for a fixed number of instances (to let's say two) or increase the number of instances until there is no error and all the thousand requests per second are handled successfully. Then based on this, you can set the min in your auto scaling group and adjust... |
C#: Trying to aggregate a dictionary with a tuple<datetime,int> key using the datetime and one of the associated values <p>I've spent a few hours trying to piece this together but I am having a hard time finding an example. I have a dictionary with a tuple key and a set of values from a class. What I want to be able to... | <p>maybe something like this:</p>
<pre><code> class MyClass
{
public DateTime Time { get; set; }
public int OtherVal { get; set; }
public double AggField { get; set; }
}
List<MyClass> lst = new List<MyClass>();
lst.Add(new MyClass { Time = DateTime.To... |
splitting one column into several <p>First time poster here, so please forgive mishaps. </p>
<p>I have a query in sql that for the sake of simplicity returns duration, business duration and impacted service. The problem lies in the fact that if its impacted service, sometimes it has more than one value in the row. For... | <p>One method uses a split function. Google "SQL Server split function" on the web. Then you will have a split function.</p>
<p>You can then do this with <code>outer apply</code>:</p>
<pre><code>select t.duration, t.business_duration, s.impacted_service
from t outer apply
(dbo.split(t.impacted_service)) s(impa... |
Searching through data with multiple conditions VBA/Excel <p>I have a list of data with columns indicating the test a product went under and the product. Each product undergoes several tests for example (hot medium cold). If you can imagine, the data for a specific product may look like </p>
<pre><code> A B
h... | <p>Make four new columns with these formulas</p>
<p>C: <code>COUNTIFS(B:B,$A1,A:A,"hot")</code></p>
<p>D: <code>COUNTIFS(B:B,$A1,A:A,"medium")</code></p>
<p>E: <code>COUNTIFS(B:B,$A1,A:A,"cold")</code></p>
<p>These will show you how many times each of those products has been tested in the respective category. Then,... |
Wix install to multiple remote machines <p>I'm new to Wix and am wondering if there's a way to install files to several machines that are all on the same network from a single MSI? </p>
<p>The installer would prompt the user for all the machine names and then the installer would install on each of the machines.</p>
| <p>Microsoft <a href="https://en.wikipedia.org/wiki/Active_Directory" rel="nofollow">Active directory</a>'s Group policy is used exactly for this. For tutorial see for example <a href="http://docs.trendmicro.com/all/ent/officescan/v10.6/en-us/osce_10.6_sp3_olh/ins_mth_msi.html" rel="nofollow">this</a> link.</p>
|
Can the ROOT element in a select statement using FOR XML PATH be set using a variable? <p>I have a query that creates an xml file. Currently, I have the ROOT element hard-coded. I would like to use a variable value to set this root element value but substituting the hard-coded string with the variable throws a syntax ... | <p>Here is a little cheat using concat()</p>
<blockquote>
<p><strong>Create some sample data</strong></p>
</blockquote>
<pre><code>Declare @SomeTable table (id int,First_Name varchar(50),Last_Name varchar(50),EMail varchar(50))
Insert into @SomeTable values
(1,'John','Smith','john.smith@gmail.com'),
(2,'Jane','Doe'... |
Retrieve email subject from file via bash <p>I've a shell script which downloads files from the servers mail folder to a NAS devices so the client has copies made locally with a backup.</p>
<p>The files are saved as <strong>11469448248.H15587P19346.smtp.x14.eu_2,S</strong> files.
I've changed the extension to standard... | <p>The following is <strong>wrong</strong> but implements what you seem to be asking.</p>
<pre><code>subj=$(sed -n '/^Subject: PD *//!d;p;q;/^$/q' "$f")
</code></pre>
<p>The problem with this is that it succeeds in the trivial case, but fails when you have a MIME RFC2047-encoded <code>Subject:</code> header, and (mor... |
Java Reference Object Duplicating <p>Ok, here is the code I written</p>
<pre><code> public void Print( Object obj ){
System.out.println( obj.toString() );
}
public Main() {
LinkedList<Integer> link = new LinkedList<Integer>();
LinkedList<Integer> temp = link;
link.push(1);
link... | <p>Java only has primitive and reference variable types. Your variables</p>
<pre><code>LinkedList<Integer> link = new LinkedList<Integer>(); // reference to a list
LinkedList<Integer> temp = link; // another reference to the same list.
</code></pre>
<p>You only created one <code>new</code> LinkedLis... |
How to compare temporary columns created from select in order to calculate SLA? <p>This is the whole query that I have now, the first part seems to be fine but starting from "Y as" it shows all the columns underlined with red. I have marked the statements in bold which shows a red underline. I need to calculate the per... | <ul>
<li>Since you need to reuse <code>time_to_accept</code> and <code>time_to_resolve</code>, use a CTE so you don't have to repeat those long <code>DATEDIFF</code> expressions. </li>
<li>Use another CTE so you don't have to repeat the long <code>CASE</code> expressions for
<code>time_to_accept and</code>time_to_resol... |
Indexing Cell arrays for more efficient performance <p>I have the following code to display a 9-by-3 cell array:</p>
<pre><code>data = cell (9,3);
col1 = [2, 3, 5, 7, 8, 11, 12, 15, 16];
col2 = {[1 1], [1 5], [3 9], [4 2], [4 6], [6 2], [7 6], [6 9], [9 9]};
col3 = {[2 3 4 5 8],[1 3 5 8],[1 2 5 7 8],[1 2 3 6 7],[3 ... | <p>Your have written code to assign a 9 x 3 cell array, which can also be written as:</p>
<pre><code>data2 = [num2cell(col1') col2' col3']
data2 =
[ 2] [1x2 double] [1x5 double]
[ 3] [1x2 double] [1x4 double]
[ 5] [1x2 double] [1x5 double]
[ 7] [1x2 double] [1x5 double]
[... |
Cannot edit Sharepoint files on my mac. <p>I'm using Sharepoint on my mac. (tried both Safari and Chrome) Editing files online is not possible. Error: "Sorry, this document can't be opened for editing."
Tried .doc files and .docx files, both did not work. </p>
<p>Some files, made by colleagues can be opened, but the b... | <p>How a file opens is determined by settings in the library. If the library does not allow the file to open in a browser view and you don't have the appropriate software in your machine then it won't open.</p>
<p>The browser view making a mess of document layouts is pretty much standard for MS file types in browser v... |
When pushing code to Google Cloud remote repo git manually requires password <p><strong>Context :</strong>
I try to push my code to a google remote repo</p>
<p>From git bash , in my project folder :
I ran the below cmd :</p>
<pre><code>git push --all google
</code></pre>
<p>and i got :</p>
<pre><code>fatal: remot... | <p>Assuming you added your Google Cloud git remote repository as</p>
<pre><code>git remote add google https://source.developers.google.com/p/PROJECT
</code></pre>
<p>you would then have had to do</p>
<pre><code>git config credential.helper gcloud.cmd
</code></pre>
<p>then </p>
<pre><code>git pull google
</code></p... |
Why is a bean declared in @SpringBootApplication class registered even though it is not a stereotyped class? <p>I have this main class in my project</p>
<pre><code>@SpringBootApplication
@EnableOAuth2Sso
public class App
{
public static void main(String[] args) throws Exception {
SpringApplication.run(App... | <p><a href="https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java#L50" rel="nofollow"><code>@SpringBootApplication</code></a> is a meta annotation which looks like:</p>
<pre><code>// Some details omitted
@Spr... |
Mocking SecurityContext in Symfony2 using PHPUnit <p>These are my mocks:</p>
<pre><code>$this->user->method('getCustomerId')
->willReturn($this->customerId);
$this->userToken->method('getUser')
->willReturn($this->user);
$this->securityContext->method('getToken'... | <p>Try using <code>willReturn</code> instead of <code>will</code> and add the <code>with</code></p>
<p>So try this:</p>
<pre><code>$this->securityContext->expects($this->once())
->method('isGranted')
->with('IS_AUTHENTICATED_FULLY')
->... |
Openshift python requests proxy permission denied <p>I'm trying to use a proxy with the python 'requests' package on an Openshift server. I am getting a permission denied error. See below.</p>
<p>Is Openshift blocking the connection or am I not configuring it correctly? Something else? Openshift doesn't want to let ... | <p>Most probably OpenShift blocks uncommon outgoing ports for <a href="http://security.stackexchange.com/questions/24310/why-block-outgoing-network-traffic-with-a-firewall">security reasons</a>. your proxy is listening on 6060. You should try to ssh into your gear and try <code>telnet</code></p>
<p>In my gear, post 60... |
GoogleMap object is null in AppCompatActivity <p>I have an activity where I just want to display a map. Thus, I use a MapView along with a GoogleMap object to do so. However, I got a null object error in my Maps activity when trying to change the map type of my map. I have read some topics on such a problem but my prob... | <p><code>map</code> is never initialized until <code>onMapReady</code>, therefore all other usages of it in <code>onCreate</code> will cause a NullPointerException. </p>
<p>You can try this</p>
<pre><code>map_view.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
... |
How to use regex to disallow non-digts but allow a dot in Python? <p>I am new to regex and trying to remove all <strong>non-digts</strong> but keep the <strong>dot</strong> (<strong>.</strong>) of a string:</p>
<pre><code>x = ['ABCD, EFGH ', ' 20.9&dog; ', ' IJKLM />']
</code></pre>
<p>So far I have tried the ... | <p>Instead of using the class <code>\D</code> you can define your own class of characters using <code>[...]</code>, and invert that class using <code>[^...]</code>. Now just put all the digits <code>0-9</code> and the <code>.</code> into that class:</p>
<pre><code>>>> x = ['ABCD, EFGH ', ' 20.9&dog; ', ' ... |
javascript works on localhost but fails on hosting server <p>When i click on add-to-basket button i see an error which appears in my browser console saying :</p>
<p><a href="http://i.stack.imgur.com/GMHEi.png" rel="nofollow"><img src="http://i.stack.imgur.com/GMHEi.png" alt="error.png"></a></p>
<p>Here is my basket.j... | <p>This is mainly due to Rules of Origins (CORS), for some reason the javascript(browser) sees the request as not residing in the same server. And the reason for that, I believe, is because /home/u919084925/public_html/mod/basket.php is not seen as a valid url on the server, it should start with http://{hostname}/{path... |
How do I change a UIImage color when tapping tableview cell? <p>So I have been stuck on this for a day or so. How do I change the color of an UIImage color when tapping on a tableview cell? So for example I have a black image and when I tap a tableview cell it changes that image to white? Thank you! </p>
<p>I tried us... | <p>It looks like you have the right pieces but don't know where to call them. You will assign the image to the image view in your <code>cellForRowAt:</code> method.</p>
<pre><code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusa... |
td background colouring applied to complete column rather to a single cell <p>I've below html. </p>
<pre><code> <table border="1" class="myTable">
<tr>
<th class="cname">Component</th>
<th class="pname">Properties</th>
... | <pre><code>$('.myTable tr').each(function() {
$(this).find('td:eq('+x+')').css("background-color", "red");
});
</code></pre>
<p>this piece of code assign a background colour to each cell of index 'x' for each rows (each cells of index x of each table rows represent a column).</p>
<p>You have to select only the r... |
Alternative of threading.Timer? <p>I have a producer-consumer pattern Queue, it consumes incoming events and schedule qualified events sending out in 5 seconds. I am using <code>threading.Timer()</code><a href="https://docs.python.org/2/library/sched.html" rel="nofollow">python document</a>to do it and everything was w... | <p>Thanks for @dano 's comment about the 3rd party modules! Based on my work requirement, I didn't install them on the server. </p>
<p>Instead of using <code>threading.Timer()</code>, I choose to use a Redis based Delay Queue, I found some helpful source online: <a href="http://www.saltycrane.com/blog/2011/11/unique-p... |
What are good reasons for using Camel XML routes? <p>The Camel Java DSL provides type-safety, code completion and proper support for refactoring. It also helps to modularize and (unit-)test your code in a great manner. </p>
<p>Speaking for the Camel XML syntax I only see the advantage of being able to modify and reloa... | <ol>
<li>In-Place editing of routes (although I would discourage doing that)</li>
<li>quick&dirty one-off routes (e.g. routing from test to qa environment) or very simple projects - when you have a container like karaf or servicemix. No need to fire up your IDE/compile. Just write and drop to deploy folder.</li>
<l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.