input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
DOMDocument node with boolean value <p>What is the correct way to extract a boolean value from an XML node? I have tried with this:</p>
<pre><code><?php
$xml = "<node><code>false</code></node>";
$dom = new DOMDocument();
$dom->loadXML($xml);
$nodeList = $dom->getElementsByTagName('co... | <p>nodeValue is going to return a string, so you need to do a string comparison. For example:</p>
<pre><code>if($nodeList->item(0)->nodeValue != 'false'){
echo 'VALID';
} else {
echo 'NOT VALID';
}
</code></pre>
<p>You may also consider using <code>filter_var($string, FILTER_VALIDATE_BOOLEAN)</code> to ... |
TypeError: jQuery.sap is undefined <p>Hi i am using openui5 and <code>jquery.sheet.js</code> for excel type ui.</p>
<p>to use <code>jquery.sheet.js</code> we have to include <code>jquery-1.10.2.min.js</code>.
If i use <code>jquery-1.10.2.min.js</code> openui5 throws error :
<strong>TypeError: jQuery.sap is undefined... | <p>issue is fixed by first Bootstrapping the openui 5</p>
<pre><code> <script
id="sap-ui-bootstrap"
src="resources/sap-ui-core.js"
data-sap-ui-libs="sap.ui.m"
data-sap-ui-theme="sap_bluecrystal" >
</script>
</code></pre>
<p>and then include... |
Why do I need a custom domain in order to have SSL to my endpoint <p>This is more a theoretical question than a practical one.</p>
<p>I have four different App Services in Azure (each one for <code>dev</code>, <code>tst</code>, <code>acc</code> and <code>prd</code>), and I want to secure them with SSL.</p>
<p>So, in ... | <p>You can use the .azurewebsites.net endpoint with SSL directly already (out of the box). The reason not to do this for production, however, is that that particular domain is not owned by you, it's shared amongst every other web app running on Azure. So it's usually fine for dev/test environments and proving that yo... |
Ruby `require': cannot load such file (LoadError) <p>I have a directory structure that looks like this:</p>
<pre><code> - lib
- yp-crawler (directory)
- file-a.rb
- file-b.rb
- file-c.rb
- yp-crawler.rb
</code></pre>
<p>My <code>lib/yp-crawler.rb</code> file looks like this:</p>
<pre><code>re... | <p>According to API Dock, <code>require_relative</code> is what you need.</p>
<blockquote>
<p>Ruby tries to load the library named string relative to the requiring
fileâs path. If the fileâs path cannot be determined a LoadError is
raised. If a file is loaded true is returned and false otherwise.</p>
</block... |
Why does tensorlow LSTM takes only the hidden size as input? <p>In the tensorflow <a href="https://www.tensorflow.org/versions/r0.9/api_docs/python/rnn_cell.html#LSTMCell" rel="nofollow">LSTM</a> cell we only initialize it by number of units (<code>num_units</code>) which is the hidden size of the cell. However, the ce... | <p>LSTM cell (or other types of RNN cells) is just an object you pass to the function such as <code>tf.nn.rnn</code>. <code>tf.nn.rnn</code> takes cell and data for input. Cell is called inside of rnn function with the data you've passed to <code>tf.nn.rnn</code>. </p>
|
UnsafePointer<UInt8> initializer in Swift 3 <p>I have a receipt validation class that is deprecated since Swift 3 has released. I fixed some issues, but I still have many ...</p>
<p>Here is the GitHub source code I used : <a href="https://gist.github.com/baileysh9/4386ea92b047d97c7285#file-parsing_productids-swift" re... | <ol>
<li><p>In Swift 3, you cannot init an <code>UnsafePointer</code> using an <code>UnsafeRawPointer</code>.</p>
<p>You can use <code>assumingMemoryBound(to:)</code> to convert an <code>UnsafeRawPointer</code> into an <code>UnsafePointer<T></code>. Like this:</p>
<pre><code>var ptr = data.bytes.assumingMemoryB... |
bootstrap navbar center vertically horizontally? <p>Is it possible to center the navbar vertically and horizontally?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>/**
... | <p>to place your navbar in the center of your screen you can simply add </p>
<pre><code>nav {
position: fixed;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
</code></pre>
<p><a href="https://jsfiddle.net/anpvtaxu/1/" rel="nofollow">https://jsfiddle.net/an... |
Android switching between gl views causes app freeze <p>I'm still learning how to program in Android and I created an Activity with a start view:</p>
<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_activity);
... | <p>You could solve this problem using a Frame or Relative layout.
If I understand correctly, both mMainView and mGLView are fullscreen.
There are a few options:</p>
<p>You could change the visibility of the views:</p>
<pre><code>public void switchViews() {
if(mMainView.getVisibility() == View.VISIBLE){
mMainVi... |
onRequestPermissionsResult called with a different request code each time <p>I request permission in a fragment with this code </p>
<pre><code>requestPermissions(new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE},14);
</code></pre>
<p>and in my <code>HomeActivity</code> I use this code to get the result<... | <p>Your activity doesn't know which fragment is calling <code>startActivityForResult</code></p>
<p>So if you are calling <code>startActivityForResult(intent, 1)</code> from a fragment, you need to replace it with <code>getActivity().startActivityForResult(intent, 1)</code></p>
<p>it will most probably solve your iss... |
Internet Explorer: expiration date for cookies doesn't work <p>We are trying to set a cookie in order to use user auto login.</p>
<p>We are using an SPA with Reactjs + Redux + JavaScript (ES6),<br>
To set the cookie we have created a component called <code>CookieHandler</code> which contains the set cookie function</p... | <p><a href="http://stackoverflow.com/questions/12941511/internet-explorer-cookie-not-being-set-properly-using-javascript">Here</a> I found some info that IE doesn't like "=" sign.
Maybe it's the problem?</p>
<blockquote>
<p>Don't use "=" signs in your cookie names. </p>
<p>If you need them, use the single quote... |
python replace will not replace "'" with "\'" <pre><code> dctLineItems = InvFunctions.dctLineItems
for value in dctLineItems.values():
iORDER_ID = value[0]
iITEM_No = value[1]
iQUANTITY = value[2]
sTmp = value[3]
sTmp2 = sTmp.replace("'", "\'", 1)
#sTmp2 = connPy.e... | <p>My best guess is that the backslash is known in Python as an escape sequence. Python doesn't recognize this as a literal, so you would have to put <code>\\</code> instead. The same applies to the single quote (<code>\'</code>)</p>
<p>So where you're using your replace function (I'm guessing the 5th line from the to... |
Attempting to display top 2 average prices <p>I am trying to display the top 2 average prices, however I am having an issue as the two columns I need to display are from different tables and the join is giving me error messages when I attempt solutions from other threads. For example:</p>
<pre><code>Customer Table ... | <p>First, learn proper <code>join</code> syntax. <em>Never</em> use a comma in a <code>FROM</code> clause. <em>Always</em> use <code>JOIN</code> and <code>ON</code>.</p>
<p>Then, in Oracle 12C+, you can do:</p>
<pre><code>SELECT c.CNAME, AVG(o.OPRICE)
FROM CUSTOMER c JOIN
ORDER o
ON c.CID = o.CID
GROUP BY... |
XML validation in spark java <p>We have got a 3GB XML which we have to validate and then flatten. We are expected to use Spark-Java to validate it and flattening as well. Flattened data will be ingested into Hive table.
Also, the validation should throw the bad record in XML (so that we can write the same back to Kafka... | <p>You can use javax.xml.validation.Validator. This api will help you to validate XML.</p>
|
How to connect iOS app to localhost webpage (RaspberryPi3) <p>I am very new to web programing and I want to do a very simple (at least I hope) thing but I have no idea how to proceed.
I have created a local webpage that I host on my RaspberryPi3 to display a custom web page with multiple useful infos such as time, wea... | <p>Well, I guess there are a few steps to take, not sure what you already have:</p>
<ol>
<li>Webserver on the Pi (e.g. Apache), website ("index.php") to react
to calls from the phone/other devices (anything able to call it :-)</li>
<li>Probably the Pi is inside your home network, so when your phone
is logged in there ... |
Is there a way to create AWS Dashboard using cloudformation or AWS CLI <p>I wanted to create an AWS Dashboard using cloudformation but did find a way.
Guess AWS has not yet added support for that.</p>
<p>As an alternative is it possible to create that using AWS CLI</p>
| <p>If I'm correct your question is concerns <a href="https://aws.amazon.com/premiumsupport/knowledge-center/what-are-resource-groups/" rel="nofollow">Resource Groups</a>. It is not possible at this time to create Resource Group in Cloud Formation Templates or via the awscli.</p>
<p><a href="https://aws.amazon.com/prem... |
How can I reload a Geolocation Javascript every minute? <p>I have made a prototype with Geolocation JavaScript and in the browser it shows a Map with several markers and a marker with your current location. At this time i would like make my website so that it automatically reloads so you can see your new location (if y... | <p><a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval" rel="nofollow">setInterval()</a> is used to run a piece of code every x milliseconds.</p>
<p>Just wrap the code you want to run every second in a function called runFunction.</p>
<p>Like this:</p>
<pre><code>var time=setInterval(r... |
Differences in simple proguard keep option <p>What is the difference between these two proguard options?</p>
<pre><code> -keep class com.myclass.**
-keep class com.myclass.** { *; }
</code></pre>
| <p>The first rule will only keep the <strong>classes</strong> themselves (and the default constructors).</p>
<p>The second rule will also keep all <strong>methods</strong> and <strong>fields</strong> in the classes.</p>
|
Change checkbox tick color and icon - sapui5 <p>I need to change the color of the tick on a UI5 checkbox.
I've looked at the CSS and found out that this is in the <code>::before</code> selector:</p>
<p><a href="http://i.stack.imgur.com/2IMc4.png" rel="nofollow"><img src="http://i.stack.imgur.com/2IMc4.png" alt="enter ... | <p>Add new <code>CSS</code> class to <code>CheckBox</code> DOM once it is rendered. You can get respective <code>DOM</code> element with <code>getDomRef</code>, which gives you <code>HTML DOM</code> for the <code>UI5</code> element on which it is invoked.</p>
<pre><code>.green::before{
color: #00a600 !important;
}... |
passing an object to nunjucks template in node express <p>I am passing an object in Express to a Nunjucks template </p>
<pre><code>app.get('/purchase', function (req, res) {
purchase_data = JSON.stringify(req.query);
res.render('purchase', {"purchase": purchase_data});
})
------------------------
<ul>
... | <blockquote>
<p>I am passing an object in Express to a Nunjucks template</p>
</blockquote>
<p>No, you're not. You're passing a string:</p>
<pre><code>purchase_data = JSON.stringify(req.query); // make a string
res.render('purchase', {"purchase": purchase_data}); // pass the string to the template
</code><... |
Download specific file in url using PHP/Python <p>I previously used to use <code>wget -r</code> on the linux terminal for downloading files with certain extensions:</p>
<pre><code>wget -r -A Ext URL
</code></pre>
<p>But now I was assigned by my lecturer to do the same thing using PHP or Python. Who can help?</p>
| <p>I guess urllib pretty well for you</p>
<pre><code>import urllib
urllib.urlretrieve (URL, file)
</code></pre>
|
How can I use successor function in addition for more two input? <p>here is the addition code for two input( like we want the result in Z if X+1 plus Y have Z+1 for a result).</p>
<pre><code> natural_number(0).
natural_number(s(X)) :- natural_number(X).
pl(0,X,X) :- natural_number(X).
pl(s(X),Y,s(Z)) :... | <pre><code>pl(A, B, C, Sum) :-
pl(A, B, Tmp),
pl(Tmp, C, Sum).
</code></pre>
<p>Or, if you want to add a list of natural numbers, you can of course do a fold over it:</p>
<pre><code>pl([], 0).
pl([N|Ns], Sum) :-
foldl(pl, Ns, N, Sum).
</code></pre>
<p>or even (after the suggestion by CapelliC):</p>
<pre... |
Mysql PHP exention unloaded! Error shows in PHP7 How can i solve it?â <pre><code> Mysql PHP exention unloaded! Error shows in PHP7 How can i solve it?â
Version: Windows Server 2012 64-bit
XAMPP Version: 7.0.9
Control Panel Version: 3.2.2
</code></pre>
<p><a href="http://i.stack.imgur.com/Z9NQQ.png" rel="nofol... | <p>Mysql extension is deprecated use PDO instead or if you want you can also use MySQLI. That script your trying to install is old prob for php4.</p>
<p>You can use this to have mysql pdo.
php.ini</p>
<pre><code>extension=pdo.so
extension=pdo_mysql.so
</code></pre>
|
Why does a browser attach cookies to requests originating from another origin? <p>From RFC6265 section 8.2:</p>
<blockquote>
<p>A server that uses cookies to authenticate users can suffer security
vulnerabilities because some user agents let remote parties issue
HTTP requests from the user agent (e.g., via... | <p>Well, it might seem strange at first, and maybe it is not the best idea, but here it shouldn't be an issue in most cases:</p>
<ul>
<li><p>the responses of the request are blocked by SOP, so no information is leaked anyways</p></li>
<li><p>POST request (and any state-altering requests) should be protected by a CSRF ... |
The efficient way of Array transformation by using numpy <p>How to change the ARRAY U(Nz,Ny, Nx) to U(Nx,Ny, Nz) by using numpy? thanks</p>
| <p>Just <code>numpy.transpose(U)</code> or <code>U.T</code>.</p>
|
Permanently hide an item on Interface Builder via code <p>I have a weird question. Wasn't able to find a solution via search neither in SO nor via google.</p>
<p>I have a <code>UIView</code> in my <code>UIViewController</code> which is lead by a storyboard.
This <code>UIView</code> is set, via Interface Builder, to hi... | <p>You should take a look at <a href="https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/PreservingandRestoringState.html" rel="nofollow">Apple's documentation for Preserving and Restoring State</a>.</p>
<p>The preservation and restoration process is mostly automatic, but you need... |
s3cmd 1.6 failed too many times <p>I have recently updated my <strong>s3cmd</strong> from 1.5 to 1.6. This is the error when I try to upload files of any size. I am using the same configuration as before.</p>
<pre><code>ERROR: Upload of ,<myfile>' failed too many times (Last reason: Upload failed [1 of 1]
... | <p>These days, it is recommended to use the <a href="http://aws.amazon.com/cli/" rel="nofollow">AWS Command-Line Interface (CLI)</a> rather than <code>s3cmd</code>.</p>
<p>The AWS CLI supports multi-part uploads, synchronizing of directories and copying of files to stdout, plus supports all API calls to AWS (not just ... |
Complex SPARQL query - Virtuoso performance hints? <p>I have a rather complex SPARQL query, which is executed thousands of times in parallel threads (400 threads). The query is here somewhat simplified (namespaces, properties, and variables have been reduced) for readability, but the complexity is left untouched (union... | <p>First thing -- your Virtuoso build is long outdated; updating to <a href="http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VOSNews" rel="nofollow">7.20.3217 as of April 2016</a> (or later) is strongly recommended.</p>
<p>Optimization suggestions are naturally limited when looking at a simplified query., but h... |
Merging cells in WPF DataGrid vertically <p>I want to make a <code>DataGrid</code> in WPF, where some of the cells will "merge together", if they are alike.</p>
<p>Example:</p>
<pre><code>+---------+------+-----+
| Country | Name | Age |
+---------+------+-----+
| | Lisa | 24 |
+ +------+-----+
| Dan... | <p>Sorry, got buisy with other stuff.</p>
<p>Trick to such scenarios is to use the <code>Groups</code> formed in <code>CollectionViewSource</code> as the <code>ItemsSource</code> of a <code>DataGrid</code>. And, use a <code>DataGrid</code> itself as the <code>CellTemplate</code> of <code>Column</code>.</p>
<p><strong... |
UIPanGestureRecognizer action method not called in Swift 3 <p>I have set a pan gesture to an imageView, though it's action method never being called in swift 3. </p>
<pre><code>let panGesture = UIPanGestureRecognizer(target: self, action: #selector(self.panGestureHandler(panGesture:)))
panGesture.minimumNumberOfTouche... | <p>Ok, seems dumb, but after debugging I've noticed that the imageView's userInteractionEnabled is set to false. </p>
<p>After adding this line <code>imageview.isUserInteractionEnabled = true</code> everything seems to be working properly. </p>
|
No databases are available. Permissions could be missing <p>I installed and configured sentry for hive. However, I keep getting :</p>
<p><code>No databases are available.Permissions could be missing</code> in hive editor. I have created <code>role</code> and <code>permission</code> for the user that I used to login i... | <p>Solved the problem: <a href="http://This%20is%20how%20I%20solved%20it:%20http://www.yourtechchick.com/hadoop/no-databases-available-permissions-missing-error-hive-sentry/" rel="nofollow">link to the solution</a></p>
|
MDX: Query Performance <p>This query is taking too much of time for executing result set, is there any way to optimise the query</p>
<pre><code>WITH MEMBER PatientName AS [DimPatient].[Full Name].CurrentMember.Member_Caption
MEMBER PatientAge AS [DimPatient].[Age].CurrentMember.Member_Caption
MEMBER Patient... | <p>Can you try the following? There is no need to build measures to return dimension captions. And a <code>NON EMPTY</code> should speed it up by returning only combinations of dimensions that make sense (combinations with Num of Minutes I assume):</p>
<pre><code>SELECT NON EMPTY (([DimPatient].[Patient Key].[Patient... |
Python remove duplicates from the list? <p>I have list like this(they are dimension values) </p>
<pre><code>val = [6'6 X 9'8, 6'6" X 9'8"]
</code></pre>
<p>I am using the set function to remove the duplicates.</p>
<pre><code>val = set(val)
</code></pre>
<p>Output:</p>
<pre><code>{6'6 X 9'8, 6'6" X 9'8"}
</code></p... | <p>Its not working as you expected because of your quotation marks not being closed properly.</p>
<p>If you change the elements of your list to be strings like:</p>
<pre><code>l = ["6'6 X 9'8", "6'6 X 9'8"]
</code></pre>
<p>instead of:</p>
<pre><code>l = [6'6 X 9'8, 6'6" X 9'8"]
</code></pre>
<p>then say:</p>
<p... |
how to set value to angularjs constant file from angularjs controller <p>Hi I have a module with constants defined inside it. I want to make modification to this constant value under some condition from controller so that this changed constant value can be used in other places. This is the sample of my constants file <... | <p>If you want to change values you shouldn't be using a <code>Constant</code> even if it allows you to change values.</p>
<p>Just replace your <code>Constant</code> with a <code>Factory</code>, it will work in the same way</p>
<p><strong>Constant</strong> </p>
<pre><code>angular.module('myapp').constant("Constanto... |
'Typeerror: is not a function' when using JQuery module pattern <p><a href="https://jsfiddle.net/fvkuk7c0/3/" rel="nofollow">https://jsfiddle.net/fvkuk7c0/3/</a></p>
<p>style.css</p>
<pre><code>.gallery .container {
max-width: 600px;
background-color: black;
margin: 0 auto;
text-align: center;
}
.container .... | <p>The error is caused by the following code:</p>
<pre><code>$(thumbnails.getThumbnailArray).find("div").click(function() { //Thumnail click.
var divIndex = $(this).index();
if(divIndex != images.getCurrentImageIndex) {
images.clearCurrentImage(); //Clear current image from browser.
images.getC... |
Re-enabling a button after disabling it in an if statement <p>I have some poorly written if statements I'd like some help with.</p>
<p>I am attempting to cycle through divs using left and right arrow buttons.</p>
<p>When I use the right arrow and reach the last div (called using the class selector "pars"), I disable ... | <p>It looks like you could use the last if statements I added to both functions.</p>
<pre><code>var $pars = $('.pars');
var $fwdBtn = document.getElementById('cycle-forward');
var $backBtn = document.getElementById('cycle-back');
$('#cycle-forward').click(function() {
var $next = $pars.filter('.active').removeCla... |
Excel VBA Macro - Copy Cells and Paste Values to Active Cell Range <p>I am running into some problems with this Excel macro, as I'm pretty new to it.</p>
<p>I want to take various cells, copy them, then paste their values to the active cell and the cells below it.</p>
<p>For example, I have cell D2 currently selected... | <p>D2 would be:</p>
<pre><code>Selection.Value = ActiveSheet.Range("A1").Value
</code></pre>
<p>D3 would use OFFSET:</p>
<pre><code>Selection.Offset(1).Value = ActiveSheet.Range("B4").Value
</code></pre>
<p>So D4:</p>
<pre><code>Selection.Offset(2).Value = ActiveSheet.Range("C3").Value
</code></pre>
|
Take a User Specified list and search for all instance of text in a folder full of excel files <p>I have the following code that takes user input for a folder containing excel files and then another input for a specified "key-word" or "Dirty-Word" search. I can not get it to pull every instance for the word search. It ... | <p>I finally figured it out. Nothing like good old F8 to walk through each step and Google to give you options. </p>
|
How to get json data in AJAX success function <p>This is my AJAX code to fetch dropdown record.</p>
<pre><code>function item_value() {
$.ajax({
type: "POST",
url: "ajax.php",
contentType: "application/json; charset=utf-8",
async: false,
data: data,
dataType: "json",
success: function (jso... | <p>In you php script make sure to add following headers before you print our the encoded data</p>
<pre><code>header('Content-type: application/json');
echo json_encode($data);
</code></pre>
|
How to check if a sentence contains a specific word? <p>I'm not looking for how to find a string inside another string. I'm looking for a word. So the solution should pass these tests:</p>
<pre><code>let result: Bool = senx.contains(word: "are")
let sen1 = "We are good." //true
let sen2 = "We care about you." //false... | <p>You need a regex with a word boundaries <code>\b</code> around the value you are checking the presence for:</p>
<pre><code>let pattern = "(?i)\\bare\\b"
if string.rangeOfString(pattern, options: .RegularExpressionSearch) != nil ...
</code></pre>
<p>The <code>\bare\b</code> matches any <code>are</code> that is a wh... |
aplay does not play audio when run by systemd <p>I'm developing a Qt application which includes the following block of code to play sound</p>
<pre><code>QString soundApp = "/usr/bin/aplay";
QStringList soundFile;
soundFile << "/home/pi/urna-files/sources/som-longo.wav";
QProcess *playSound = new QProcess;
playS... | <p>The process probably needs to be run as the user "pi".</p>
<p>That can be done in the <code>Service</code> section</p>
<pre><code>[Service]
User=pi
</code></pre>
|
How to show a message by an if-statement in Javascript <p>I have an <code>index.html</code> and inside this file, I wrote code in order to show a message which is "hello" here. My goal is to implement code that shows three types of message: "Good morning", "Good evening", and "Good night".</p>
<p>Follows my code:</p>
... | <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>window.onload = function() {
var h = new Date().getHours(),
msg = 'morning';
if (h > 12) { msg = 'afternoon'; ... |
xcode 8 "Command failed due to signal: Segmentation fault: 11" <p>I updated my Xcode to Xcode 8 and accepted all the updates but I get an error telling me <code>"Command failed due to signal: Segmentation fault: 11"</code></p>
<p>note that I am aware this question is very close to this one :</p>
<p><a href="http://st... | <p>We encountered the same problem. This answer did solve our problem:
<a href="http://stackoverflow.com/questions/24222644/swift-compiler-segmentation-fault-when-building/26204610#26204610">Swift compiler segmentation fault when building</a></p>
<p>You have to unwrap all optionals before you can use them in a if stat... |
IResourceScopeCache for Avoid expensive scope calculation <p>I have the same problem that described <a href="https://www.eclipse.org/forums/index.php/t/490065" rel="nofollow">is this link</a></p>
<p>I want to use IResourceScopeCache in my getScope function I implemented, but I don't know how to do it. Didn't found any... | <p>The interface <code>IResourceScopeCache</code> allows to store values computed for a given resource in a map using keys of your choice.
It has two methods: <code><T> T get(Object key, Resource res, Provider<T> provider)</code> and <code>void clear(Resource res)</code>.
<code>get</code> checks whether a ... |
Hitting search button in website with no id <p>I'm putting together a VBA where it will search a firms name into a website and search it.
The problem is that I can't seem to get my code right to hit the search button </p>
<p>Code:</p>
<pre><code>Sub SearchBot()
Dim objIE As InternetExplorer
Dim aEle As HTML... | <p>Got it! Thanks guys. For those that are curious, I used: </p>
<pre><code>set oNode = objIE.document.getElementsbyClassName("iPadHack tbmsearchright")(0)
oNode.click
</code></pre>
|
startMonitoringSignificantLocationChanges needs background location enabled? <p>i need to use a location with significant change, with this:</p>
<pre><code>startMonitoringSignificantLocationChanges
</code></pre>
<p>If i use this, i have to enable location backgrounds in the capabilities of the app config?</p>
<p>tha... | <p>Yes You need to enable background mode.As per apple d</p>
<blockquote>
<p>If your iOS app must keep monitoring location even while itâs in the background, use the standard location service and specify the location value of the UIBackgroundModes key to continue running in the background and receiving location up... |
Symfony clear cache memory limit <p>Here's my problem: when I try to execute the cache:clear command in my dev environment, I have a fatal error because of the PHP memory limit. So, I tried to increase this limit to 2048M, which should be enough, but still the same issue.</p>
<p>I tried everything: manually deleting t... | <p>Where did you change the memory limit.</p>
<p>There is a big chance your <code>php.ini</code> is different for web server and command line Interface(CLI).</p>
<p>If you face the problem of <code>memory limit</code> in command line, make sure you are edit the correct <code>php.ini</code> file.</p>
<p>To know what ... |
How can I embed an EXE File inside a VC++ exe program <p>I want to hide my exe file, it is VB code, so I thought I can but it inside a vc++ code and then I can call it from VC++ code like run(myfile.exe) or execute(myfile.exe).
But I do not how can I add it inside a VC++!</p>
| <p>You could do it using <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ff468900(v=vs.85).aspx" rel="nofollow">Resources</a>.</p>
<p>There are 2 stages that you need to work on:</p>
<ul>
<li>build time: when building your <em>C++</em> application, you must instruct <em>Visual Studio</em> to include... |
Processing a .txt file of 10 GB <p>I have a text file of around 10 GB, I need to have some processing on the textual data in the file.
What is the best way to read, access and process such a huge file?</p>
<p>I am thinking to break the file into chunks and then process it by handling smaller files (or can be in buffer... | <p>Options how to process data:</p>
<ul>
<li><p>load everything into RAM and process it at once - if it fits there...</p></li>
<li><p>process only one line at once; for example line by line. Great if all the processing requires no other information than the processed line itself - no shared storage, no database...</p>... |
Why is my application thowing me Metadata file could not be found even though I just added it? <p>So I recently asked a question why my references were not added and thats because I forgot to add a snippet of code.
That snippet was this.</p>
<pre><code>parameters.ReferencedAssemblies.Add("Microsoft.CSharp");
</code></... | <p><code>ReferencedAssemblies.Add()</code> is looking for a <em>file name</em>, so add the extension:</p>
<pre><code>parameters.ReferencedAssemblies.Add("Microsoft.CSharp.dll");
</code></pre>
|
Why synchronized not working properly? <p>Here's my following code: </p>
<pre><code>private int count = 0;
public synchronized void increment() {
count++;
}
public void doWork() throws InterruptedException {
Thread t1 = new Thread(new Runnable() {
public void run() {
for (int i = ... | <p>While <code>count++;</code> indeed is synchronized <code>System.out.println(count+" "+Thread.currentThread().getName());</code> is not, but it access to <code>count</code> variable.</p>
<p>Even if you synchronize access, it won't help you because next scenario will be still possible:</p>
<ul>
<li>Thread 1 increme... |
Find Most Frequent Combination within a Vector by Group <p>I have a table with two columns namely <code>id</code> and <code>item</code>:</p>
<pre><code>df <- data.frame(id=c(1,1,2,2,2,2,3,3,3,4,4,4,4,4),item=c(1,2,3,1,2,3,4,1,2,3,1,2,1,2))
</code></pre>
<p>I want to find the most frequent combination (order doesn'... | <p>Here is one idea using <code>dplyr</code> </p>
<pre><code>df1 <- df %>%
group_by(id) %>%
arrange(item) %>%
summarise(new = paste(unique(combn(item, length(unique(item)), toString)), collapse = '/'))
df1
# A tibble: 4 Ã 2
# id ne... |
GAMS: card operator over subset <p>I am trying to model a Cross Dock Problem. It has the following sets:</p>
<p>j for Outbound Trucks,</p>
<p>s for sorting stations and</p>
<p>l for Outbound Docks.</p>
<p>And moreover there is a binary variable z(j,s), which is one, if Outbound Truck j is assigned to sorting statio... | <p>First of all k is not at subset it is a multidimensional set.</p>
<p>No, it is not possible to use card of a multidimensional set.</p>
<p>It seems that you wish to calculate how many outbound docks, there is for each sorting station. The constraint should be formulated as:</p>
<p>equation(s).. sum(j, z(j,s)) =l=... |
stardog sesame remote access - class org.openrdf.repository.base.AbstractRepository not found? <p>I am trying to integrate my application with stardog. The application accesses already other RDF repositories in Java via sesame remoteRepository interface.</p>
<p>Stardog writes in <a href="http://docs.stardog.com/#_usin... | <p>The solution is: include openrdf-sesame-4.1.2-onejar.jar and the stardog code will compile.</p>
|
Opening link in new tab without moving away from the active tab (and without taking user to the new tab) in HTML <a> tag <p>When I use <code><a href="some url" target="_blank"></code> and when the user clicks the corresponding link, new tab opens and the user is directed to the new tab.</p>
<p>I want that new ta... | <p>Try this </p>
<pre><code><a href="www.stackoverflow.com" onclick="window.open('#','_blank');window.open(this.href,'_self');">
linktext
</a>
</code></pre>
|
best way to convert float into varchar in sql server <p>What is the correct output of this SQL query in SQL Server</p>
<pre><code>DECLARE @dt float;
SET @dt = 12345678912345678912345678912345678912;
SELECT
STR(@dt, 50)
</code></pre>
<p>Output is:</p>
<blockquote>
<pre><code> 123456789123456800000000000000... | <p>You can't use <code>FLOAT</code> to store anything with more precision than 15 digits or they will get rounded, as per MSDN <a href="https://msdn.microsoft.com/en-za/library/ms173773.aspx" rel="nofollow">documentation</a>. Either use <code>DECIMAL(38)</code> to get better precision - of up to 38 and use <code>CAST</... |
Tweaking Eloquent relations â how to get N related models per parent? <p>How to get 2 latest comments of each post?
I use laravel 5.2 and Postgres</p>
<p>My comments table</p>
<pre><code>+-----+---------------------+---------+
| id | created_at | post_id |
+-----+---------------------+---------+
| 344 | 2... | <p>You need to define additional relation in your <strong>Post</strong> model that will return <strong>2 latest comments</strong>:</p>
<pre><code>class Post extends Model {
public function latest_comments() {
return $this->hasMany(Comment::class)->take(2)->orderBy('created_at', 'desc');
}
}
</code></p... |
Saving changes of edited UIImage to same file <p>So this one should be simple for you.
I am having a trouble saving edited UIImage (just flipping it horizontally) to the same file. Instead, it creates a new one.</p>
<p>Code:</p>
<pre><code> // Get current photo
id<MWPhoto> currentPhoto = [self photoAtInd... | <p>The Assets Library framework is deprecated as of iOS 9.0, i suggest you tu use PHPhotoLibrary.
Anyway to write image to file you can use:</p>
<pre><code>[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES];
</code></pre>
<p>or</p>
<pre><code>[imageData writeToFile:path options:NSDataWritingAtomic... |
JavaScript - fixed div when reaching the top edge of the body creates an abrupt little scroll movement? <p>In the example bellow when the black div touches\reaches the top edge the abrupt scroll movement occurs. You can't see the first "Lorem ipsum" line after that.
Why is this?
Is it JavaScript or rather CSS related ... | <p>Your #menu div change from position fixed to position relative, so automatically your .text div gets pushed 50px bellow when this happend.</p>
<p>have a look at W3Schools for more info
<a href="http://www.w3schools.com/cssref/pr_class_position.asp" rel="nofollow">http://www.w3schools.com/cssref/pr_class_position.as... |
Can get data from node, but not command line using postgres <p>I created a table called alpha and a table within alpha named 'event'. I can add a row to the event table, and retrieve all rows from the event table in node. However when I try in the command line I am getting a 'blank' when I select all. </p>
<p><strong>... | <p><a href="https://www.postgresql.org/docs/current/static/app-psql.html#R2-APP-PSQL-4" rel="nofollow">As documented in the manual</a></p>
<blockquote>
<p>At the prompt, the user can type in SQL commands. Ordinarily, input lines are sent to the server when a command-terminating <strong>semicolon is reached</strong>.... |
No visible @interface for UIPresentationController declares the selector initWithPresentingViewController:presentedViewController <p>I was watching WWDC 2014 video <a href="https://developer.apple.com/videos/play/wwdc2014/228/" rel="nofollow">A Look Inside Presentation Controllers</a><br>
I downloaded the source code (... | <p>I found the answer from the documentation of UIPresentationController the method is supposed to be
<code>- (instancetype)initWithPresentedViewController (UIViewController *)presentedViewController presentingViewController:(UIViewController*)presentingViewController;</code> not <code>-(instancetype)initWithPresentin... |
Import huge dataset into Access from Excel via VBA <p>I have a huge dataset which I need to import from Excel into Access (~800k lines). However, I can ignore lines with a particular column value, which make up like 90% of the actual dataset. So in fact, I only really need like 10% of the lines imported.</p>
<p>In the... | <p>Consider running a special Access query for the import. Add the below SQL into an Access query window or as SQL query in a DAO/ADO connection. Include any <code>WHERE</code> clauses which requires named column headers, right now set to <code>HDR:No</code>:</p>
<pre class="lang-sql prettyprint-override"><code>INSERT... |
Automatically requiring "controllers" from a folder in nodejs and express <p>I'm trying to include all files in a directory called "controllers" which has files with express routes and some other things in them.</p>
<p>The problem is that the routes defined inside those files are not working, but if I paste all the co... | <p>I think you're initializing new express instances each time you're requiring it like this:</p>
<pre><code>const app = require('express')();
</code></pre>
<p>Can you use only one express instance and pass it to your controllers ?
Something like so:</p>
<pre><code>module.exports = function(app){
app.get('/', (... |
Which is better way to write an if condition in smarty? <p>Which is the better way to write an if condition in Smarty?</p>
<h2>A</h2>
<pre><code>{if $searchCount > 0}
</code></pre>
<h2>B</h2>
<pre><code>{if $searchCount}
</code></pre>
<h2>C</h2>
<pre><code>{if $searchCount == 0}
</code></pre>
<h2>D</h2>
<pr... | <p>It depends on what you want.</p>
<p><strong>Example A:</strong></p>
<ul>
<li>Use this if you want to check if your <code>$searchCount</code> is greater than <code>0</code>.</li>
</ul>
<p><strong>Example B:</strong></p>
<ul>
<li>Use this to check if your <code>$searchCount</code> is <code>true</code>. It's true i... |
JS expand and reveal blocks not displaying all blocks <p>I have the piece of code below that displays boxes, once you click on a box it expands and displays more information, which you can then close to view the boxes again. For some reason even though I have put 7 list items, not all of them appear and they don't appe... | <p>I believe your problem is caused by some CSS rules:</p>
<pre><code>section.school-finder li .school-block {
position: absolute;
top: 0;
...
}
</code></pre>
<p>you need to specify a different value for "top" on your blocks 6 & 7 (like top: 210px for exemple) because right now ther are displayed righ... |
AngularJS ui-router with templateProvider for A/B testing not rendering templates <p>I have created an angular app where I would like to randomly render two different homepage view when a user accesses the url.</p>
<p>I have created the app.js file with the following code using templateProvider to inject the testServi... | <p>According to this article: <a href="https://github.com/angular-ui/ui-router/wiki" rel="nofollow">https://github.com/angular-ui/ui-router/wiki</a></p>
<p>You can do this in several ways. I think your use of ng-include is failing, because basically this is done at page load time, and it's too late for that. I think a... |
How to dynamically build a form based on TreeBuilder object? <p>I want to define configuration schema for my class and override them with admin choices.
In order to do this I need a form to capture data from admin.</p>
<p>In Symfony <code>Configuration Component</code>, the <code>TreeBuilder</code> class is responsibl... | <p>Your treebuilder, or a part of it, will have to be iterable. So by letting it represent a form as strict as possible you can use it to easily map the configuration to the builder. It would be easiest to use the <code>yml</code> format:</p>
<pre><code>form:
name: 'exampleForm'
path: 'target_path'
fields:... |
How to change bower's installation folder? <p>When I try to install bower in my working project folder using <code>npm install -g bower</code> command in Windows 7 it is installed in another folder. I delete that folder and try to reinstall it. But again automatically that folder is created and bower is installed withi... | <p>You need to add a new file in the root of the project. The file has no name, only with the extension: </p>
<p><strong>.bowerrc</strong></p>
<p>with this:</p>
<pre><code>{
"directory": "Mynewdirectory/newfolder/subfolder"
}
</code></pre>
|
Can't set external (global?) variable when calculating geolocation <p>Here is my code:</p>
<pre><code>var lat;
$(document).ready(function() {
navigator.geolocation.getCurrentPosition(function(position) {
lat = position.coords.latitude;
console.log("inside", lat);
});
console.log("outside"... | <p><code>navigator.geolocation.getCurrentPosition</code> is an async function, it's only going to call the function and thus run the "inside" code once it has retrieved the position. This is why you first see the "outside" message (at which point <code>lat</code> is indeed undefined) and then the inside message.</p>
<... |
dart angular2 - validate number in form <p>Is there a builtin validator in Angular2 to validate a number input? The attributes "min" and "max" do not seem to be interpreted by the validator.</p>
<p>Thanks for your help.</p>
<p>My input in my template :</p>
<pre><code><input id="nbLuggage" name="nbLuggage" classe=... | <p>No, but you can create your own, something like this</p>
<pre><code>const NUMBER_VALIDATOR = const Provider(NG_VALIDATORS, useExisting: NumberValidator, multi: true);
@Directive(
selector:
"input[type=number][ngControl],input[type=number][ngFormControl],input[type=number][ngModel])",
providers: const [... |
How to permanently set environment variable? <p>Host is Ubuntu 16.04</p>
<p>I'm trying to set environment variable for user, with:</p>
<pre><code>- hosts: all
remote_user: user1
tasks:
- name: Adding the path in the bashrc files
lineinfile: dest=/home/user1/.bashrc line='export MY_VAR=TEST' insertafter='EOF... | <p>Because lookups happen locally, and because each task runs in it's own process, you need to do something a bit different. </p>
<pre><code>- hosts: all
remote_user: user1
tasks:
- name: Adding the path in the bashrc files
lineinfile: dest=/home/user1/.bashrc line='export MY_VAR=TEST' insertafter='EOF' stat... |
Latex Letter template with sidebar <p>I'm looking for someone who can tell me how to make this letter template in LaTeX, i currently using a template made in word. I'm wondering where it's possible to make the same template in LaTeX.</p>
<p>Background info:</p>
<p>Two fonts are used: Garamond and Arial
Fontsize: 12 a... | <pre><code> My normal preamble is the following (which i have used a lot of time writing):
\documentclass[10pt,a4paper]{extarticle}
\usepackage{fontspec}
\usepackage{titlesec}
\usepackage{titling}
\usepackage{listings}
\usepackage{caption}
%\usepackage[helvet]{sfmath}
% commands from fontspec
\defaultfont... |
Stacking charts in JavaFX with small values <p>I want to use a stacking charts (bar chart and line chart) to show data, and I found this tutorial: <em><a href="http://stackoverflow.com/questions/28788117/stacking-charts-in-javafx">Stacking charts in JavaFX</a></em>. </p>
<p>It works well, but when I use a list of smal... | <p>I don't have enough "reputation" yet to add a comment below hamdane's question, but the same issue with sample solution was described here <a href="http://stackoverflow.com/a/38751587/6887655">http://stackoverflow.com/a/38751587/6887655</a></p>
|
C# no PasswordChar field missing from textbox <p>Im writing a c# program using vs2015, however there is no option in the properties field of the textbox for PasswordChar. Im trying to make it so the textbox would show '*' instead of the inputted text. </p>
<p>I have tried manually coding in <code>mytxtbox.PasswordChar... | <p>You should be using <code>PasswordBox</code> instead of <code>TextBox</code>.</p>
<p>Note that you will need to use an attached behavior to enable binding of the value to a <code>ViewModel</code> property as described in this <a href="http://www.wpftutorial.net/PasswordBox.html">tutorial</a>.</p>
|
Replacing logback.xml file directory <p>I am using gradle build tool and standard logback.xml file. Now I want to move logback.xml file to different directory like 'src/main/dist/conf' and let slf4j to use this path instead of default one which is 'src/main/resources'. </p>
<p>Is there any opinion how to do that?</p>
| <p>It may help someone who may struggle with the same issue. </p>
<p>I overcome this by setting JAVA_OPTS as "-Dlogback.configurationFile=/path/to/config.xml". </p>
<p>Much more useful informations can be found here: <a href="http://logback.qos.ch/manual/configuration.html" rel="nofollow">http://logback.qos.ch/manual... |
Serialize form data of a certain form out ot many, if a certain field has value jQuery <p>I have a page with a couple of forms (number is different, as they are loaded dynamically). I am able to cycle through every form on the page and serialize its data to send to my server. I was wondering if it's possible to only se... | <p>You could filter it using <a href="https://api.jquery.com/has/" rel="nofollow">.has()</a>:</p>
<pre><code>$('body').on('click', '.saveStates', function() {
$('.states_list').has('.selected_state:checked').each(function(key, value) {
forms.push($(this).serialize());
});
});
</code></pre>
<p>But you code cou... |
Cannot Find Drawable Directory in Android Studio <p>I am trying to open Asset Studio in Android. My textbook says to right-click on the drawable directory. Where can I find the drawable directory? </p>
<p>Here is a link to a screenshot of the folders in my res directory</p>
<p><img src="http://i.stack.imgur.com/Rrr... | <p><a href="http://i.stack.imgur.com/3PfPx.png" rel="nofollow"><img src="http://i.stack.imgur.com/3PfPx.png" alt="sCREENsHOT"></a></p>
<p>1.Click on app folder
2.Then src
3.Then main
4.Then res
5.Then you can find the drawable folders</p>
<p>Make sure that <strong>Project</strong> is selected at the top.</p>
|
Angular Function not Called in <span> tag <p>I have a table of data loaded. But I need the data on a particular column be generated by a function. And that function is not being called. I don't know why</p>
<p><strong>Function</strong></p>
<pre><code>vm.itemName = '';
vm.getItemName = function (item) {
termServi... | <p>the "getter" are not called magically like when you work with SERVER SIDE rendering but we can me it work as you expect in this way:</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-html lang-html prettyprint-o... |
SFINAE to determine if a type has a potentially overloaded method <p>I was looking for an SFINAE solution to check at compile time if a type has a method. My goal is to check if a type is a valid <a href="https://en.wikipedia.org/wiki/Duck_typing" rel="nofollow">"duck type"</a>, but instead of a useless compile error, ... | <p>If all you're doing is checking if the <em>name</em> <code>xxx</code> exists within type <code>T</code>, then we can have the following approach that works for all non-<code>final</code>/<code>union</code> types <code>T</code>. We can create a new type that inherits publicly from both <code>T</code> and a fallback t... |
defining mysql table relationships <p>I have multiple tables named DrugProd, PlasticProd, FoodProd each with its own set of attributes. I have another table named ProdLot. I want a row attribute in this table to refer to a row (ID) in one of the three tables. What is the best way to identify the table and the ID in a r... | <p>The best way to do it is by adding three columns to <code>ProdLot</code>: </p>
<ul>
<li><p><code>DrugProdId</code> which is a foreign key, referencing <code>DrugProd(Id)</code>,</p></li>
<li><p><code>PlasticProdId</code> which is a foreign key, referencing <code>PlasticProd(Id)</code>, and </p></li>
<li><p><code>Fo... |
Android two TextInputEditText and two way addTextChangedListener <p>I have two TextInputEditText fields:</p>
<pre><code>TextInputEditText fromData = (TextInputEditText) view.findViewById(R.id.fromData);
TextInputEditText toData = (TextInputEditText) view.findViewById(R.id.toData );
</code></pre>
<p>Both fields has <... | <p>Override the listener and if the text it is being changed to is the same as it already is don't change it.</p>
<p>So text is changed in <code>fromData</code> and it calls the on text changed listener in on text changed check if the text being changed is equal to the text that already exists in the textview if it is... |
Angular 2 - Custom annotations <p>Is possible to create a custom annotation in Angular 2?. For example an annotation @LoginRequired, where after all it checks if user logged, if it is, continue with the component. In case the user is not logged navigate to a page error. </p>
| <p>The decorators or as you call them annotations are not part of Angular 2 itself, but of the TypeScript language. </p>
<p>The <a href="http://www.typescriptlang.org/docs/handbook/decorators.html" rel="nofollow">Typescript documentation</a> gives an introduction on how to write these decorators to decorate classes, m... |
How to Uninstall node-gyp on windows through command line <p>I want to uninstall node-gyp from windows 8.1 through command line is there any way to uninstall it i tried it using command</p>
<blockquote>
<p>npm uninstall node-gyp</p>
</blockquote>
<p>from below link I installed node-gyp </p>
<p><a href="https://git... | <p>use the following command </p>
<pre><code>npm uninstall node-gyp
</code></pre>
|
Deserialization in a CLR Function fails <p>I have written some routines for the phonetic conversion of a text in C#. These routines require a bunch aof defined rules for the conversion (search-string/replace-string). The idea was to store thes rules as an embedded ressource within the assembly and then read the rules f... | <p>Whenever there are security exceptions, you can first try setting the Assembly to <code>PERMISSION_SET = EXTERNAL_ACCESS</code>, and if that doesn't work you can try <code>UNSAFE</code>. However, if one is attempting to dynamically load an Assembly, then that is supposed to be forbidden even for Assemblies marked as... |
FileDiffEngine from FileHelpers Lib fails after upgrade <p>I have upgraded the FileHelpers Library from 2.0 to the latest 3.1.5 but now the FileDiffEngine does not work anymore.</p>
<p>Code:</p>
<pre><code>var engine = new FileDiffEngine(typeof(CustomClass));
</code></pre>
<p>Compiler Error:</p>
<blockquote>
<p>U... | <p>You <a href="http://www.filehelpers.net/docs/html/T_FileHelpers_FileDiffEngine_1.htm" rel="nofollow">now specify the type as a generic placeholder</a>:</p>
<pre><code>var engine = new FileDiffEngine<CustomClass>();
</code></pre>
|
IBM Integration Bus Java Compute Node: output a w3c.dom.Document or String <p>I have been working on a Java module to transform XMLs for the last few months. It is supposed to take a soap request and fill the soap:header element with additional elements from a metadata repository, for example. The module should be univ... | <p>You can cast your org.w3c.com.Document to byte array (<a href="https://stackoverflow.com/questions/11982753/converting-document-object-to-byte">example</a>). Then you can use the following code:</p>
<pre><code> MbMessage outMessage = new MbMessage();
//copy message headers if required
MbElem... |
Error parsing JSON in Swift2 <p>Hello I am having an error when parsing some JSON in Swift, my error is:</p>
<pre><code>'Invalid conversion from throwing function of type '(_, _, _) throws -> Void' to non-throwing function type '(NSData?, NSURLResponse?, NSError?) -> Void'
</code></pre>
<p>I think this is somet... | <p>It looks like you haven't taken care of all the throwing functions using do-try-catch method.
According to the Swift 3 Documentation at <a href="https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/ErrorHandling.html" rel="nofollow">https://developer.apple.com/librar... |
Warning: Task "shell" not found. Use --force to continue <p>I'm trying to install <a href="https://github.com/bitpay/copay" rel="nofollow">Copay</a> and they have defined the follow <code>Gruntfile</code></p>
<pre><code>'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
// Proj... | <p>First make sure you are loading the <code>grunt-shell</code> task:</p>
<pre><code>grunt.loadNpmTasks('grunt-shell');
</code></pre>
<p>Then make sure you register the task as well, something like:</p>
<pre><code>grunt.registerTask('shell', ['shell']);
</code></pre>
|
How to return complex types using spark UDFs <p>Hello and thank you in advance.</p>
<p>My program is written in java and i can not move to scala.</p>
<p>I am currently working with a spark DataFrame extracted from a json file using the following line:</p>
<p><code>DataFrame dff = sqlContext.read().json("filePath.son... | <p>Let's say you want to construct a datatype as <code>struct<companyid:string,loyaltynum:int,totalprice:int,itemcount:int></code></p>
<p>For this you can do the following: </p>
<pre><code> // I am just copying the json string as is but you will need to escape it properly for java.
DataType dt = DataType.fr... |
node / express REST API application - passing parameters to GET method <p><strong>Background</strong></p>
<p>I'm writing a sample nodejs / express REST interface or API for the purposes of learning. I've created a new route called "emergency". </p>
<p>In the file I have the following code: </p>
<pre><code>router.get... | <blockquote>
<p>Do I need to create two separate methods, one that accepts a parameter
and one that doesn't?</p>
</blockquote>
<p>I'm guessing you posted this before even trying that?</p>
<p>The answer is yes. </p>
<p>Your route that accepts parameters should look like this:</p>
<pre><code>app.get('/emergency/:... |
Highlight data point in chart control <p>I am building my first own graph and im getting to what i need step by step.
But i have a small problem that i can not figure out.
My Line Chart shows data and when i hover with my mouse over the data points it shows the value. But there are no real points or circles on the dat... | <p>In <strong>addition</strong> to the normal way of displaying the <code>DataPoints</code> for a given <code>ChartType</code>, in your case as <code>Lines</code>, you often can also ask to display <code>Markers</code>:</p>
<p><a href="http://i.stack.imgur.com/JoZbX.png" rel="nofollow"><img src="http://i.stack.imgur.c... |
Pandas groupby sum <p>I have a dataframe as follows:</p>
<pre><code>ref, type, amount
001, foo, 10
001, foo, 5
001, bar, 50
001, bar, 5
001, test, 100
001, test, 90
002, foo, 20
002, foo, 35
002, bar, 75
002, bar, 80
002, test, 150
002, test, 110
</code></pre>
<p>This is what I'm trying to get:</p>
<pre><code>ref, t... | <p>A solution using <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.pivot_table.html">pivot table</a> :</p>
<pre><code>>>> b = pd.pivot_table(df, values='amount', index=['ref'], columns=['type'], aggfunc=np.sum)
>>> b
type bar foo test
ref
1 55 15 190
2 155 55 ... |
Error converting data type varchar to numeric while updating column <pre><code>update policy
set EstimatedPremium = cast(etl.estpremium as Numeric(19,4))
from policy p join
etlpolicy etl
on p.policynumber = etl.policynumber
</code></pre>
<p>I am trying to update a column in one table <code>... | <p>Your query is fine, except for the <code>update</code>. You need to use the table alias:</p>
<pre><code>update p
-------^
set EstimatedPremium = cast(etl.estpremium as Numeric(19,4))
from policy p join
etlpolicy etl
on p.policynumber = etl.policynumber;
</code></pre>
|
Using curl within a Databricks+Spark notebook <p>I'm running a Spark cluster using Databricks. I'd like to transfer data from a server using curl. For example, </p>
<pre><code>curl -H "Content-Type: application/json" -H "auth:xxxx" -X GET "https://websites.net/Automation/Offline?startTimeInclusive=201609240100&end... | <p>In Scala, you can do something like:</p>
<pre><code>import sys.process._
val command = """curl -H "Content-Type: application/json" -H "auth:xxxx" -X GET "http://google.com" -k > /home/user/automation.json"""
Seq("/bin/bash", "-c", command).!!
</code></pre>
|
load jquery and bootstrap and pass google speed test mobile version <p>Trying to load jquery and bootstrap and pass mobile version. Google is saying: <em>Your page requires additional network round trips to render the above-the-fold content. For best performance, reduce the amount of HTML needed to render above-the-fol... | <p>Found a major issue with my .htaccess file that gave me a passing score! But still have to go through all the things i did above to pass googles speed test mobile version. Is there anything else I can do?</p>
|
Initializing a std::string with function return value, is there a copy? <p>I have the following code, I am using GCC and C++11:</p>
<pre><code>std::string system_call(const char *cmd){
std::string a;
...
return a;
}
std::string st = system_call("whatever code");
</code></pre>
<p>Is there an implicit copy th... | <p>In general, if the <code>std::string</code> is constructed in the call and then returned most modern compilers with apply the return value optimization (a special case of <a href="http://en.cppreference.com/w/cpp/language/copy_elision">copy elision</a>). Your case in particular is the Named RVO (thanks @NathanOliver... |
TFS 2015 build Configuration <p>I am trying to set up a TFS build server [on premise 2015]. The source is located on another server [TFS 2013]. While configurig build agent, an error occurs with below message. </p>
<p>Make sure you are using account server url
(ex. <a href="https://account.visualstudio.com" rel="nofo... | <p>First make sure you are using <code>/ServerUrl:ServerUrl</code> during the configuration.</p>
<p>For troubleshooting configuration errors, detailed <strong>logs</strong> can be found in the <code>_diag</code> folder under the agent installation directory.</p>
<blockquote>
<p>Before you begin, make sure your buil... |
Restrict Orientation change in Javascript <p>I am building hybrid mobile application. I need to restrict orientation to portrait mode for specific screen alone. The entire page is a single html. Is it possible to set portrait or landscape specific to div. I would like to know if there is possibility to handle such case... | <p>You can use <a href="https://github.com/apache/cordova-plugin-screen-orientation" rel="nofollow"><code>cordova-plugin-screen-orientation</code></a> to change (or lock/unlock) the app orientation programmatically:</p>
<pre><code>// set to either landscape
screen.lockOrientation('landscape');
// allow user rotate
sc... |
SSRS 2008 R2 Data Region Embedded in Another Data Region <p>I have two unrelated tables (Table A and Table B) that I would like to join to create a unique list of pairings of the two. So, each row in Table A will pair with each row in Table B creating a list of unique pairings between the two tables.</p>
<p>My ideas o... | <p>The first is called a <code>cross join</code>:</p>
<pre><code>select t1.*, t2.*
from t1 cross join
t2;
</code></pre>
<p>Whether you should do this in the application or in the database is open to question. It depends on the size of the tables and the bandwidth to the database -- there is an overhead to pulli... |
Access to a property in a specific resource via sightly <p>I want to access to a specific property in resource. </p>
<p>The main resource hat two children and the app is in the first one. I want to get a property from the second child.</p>
<p>Can i find something like : </p>
<pre><code> ${resource.parent.child[1].va... | <p>To start - note that <strong>the order of the children may not be guaranteed</strong>, unless you're using sling:OrderedFolder or some other ordered type. So trying to get the "second" child may not even make sense.</p>
<p>Having said that, there may some valid use cases that I am not thinking of for needing to get... |
Not able to reset foreman admin password using foreman-rake <p>I am trying to migrate database to mysql from sqlite. Database migrated successfully using foreman-mysql2. After restarting foreman, I wasn't allowed to login with admin/changeme. </p>
<p>I then tried to reset password using the below command</p>
<pre><co... | <p>I am posting answer for my own question</p>
<p>Its not permission....
Its <strong>permissions</strong></p>
<p>when we get errors like this, just type <code>--tasks</code> at the end of the command and see rake list, make sure the one you are trying exists in that list..,</p>
<p>correct command:</p>
<pre><code>... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.