input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
how split the array and save to database? <p>I parsed a file using <code>smarter_csv</code>: </p>
<pre><code>file = SmarterCSV.process(smarter_csv, file_encoding: windows-1251', col_sep: ';', verbose: true, convert_values_to_numeric: true, remove_zero_values: false)
</code></pre>
<p>And got this array:</p>
<pre><cod... | <p>Assuming you have Product model and attributes are code:string and name:string. And you store the parsed results in data variable.</p>
<p>You need to do the following:</p>
<pre><code>data = [{:code=>"1", :name=>"Pen"},
{:code=>"2", :name=>"Apple"}]
data.each{|row| Product.create(row) }
</code></pre>
... |
Dropbox API, Python3, Requests 400 Bad Request <p>I am able to authenticate and connect to the DropBox API and run <a href="https://www.dropbox.com/developers/documentation/http/teams#team-members-list" rel="nofollow"><code>team-members-list</code></a>.</p>
<p>But I get the following error when I attempt to run <a hre... | <p>Where I was going wrong was I was attempting to run the response.text through json.loads e.g.</p>
<pre><code>message = json.loads(response.text)
</code></pre>
<p>I changed this to </p>
<pre><code>print(response.text)
</code></pre>
<p>This way I was presented with the helpful error messages.</p>
<p>Code now look... |
Elasticsearch how to query on ID field higher than x <p>I am trying to apply pagination to results by querying multiple times to get past the 10k barrier of Elasticsearch. Since the results of Elasticsearch can differ during multiple queries I want to use the generated ID to get the next results. </p>
<p>So for exampl... | <p>The best way to achieve what you want is to use the scroll/can API. However, if you still want to proceed that way, you can do it like this:</p>
<pre><code>last_id = ...
search.filter('range', id={'gt': last_id + 1, 'lt': last_id + 1000})
</code></pre>
|
UWP Write (and read) file in a (from) folder from a string <p>I'm developing an application for UWP only for desktop. A user can select in a <em>Settings page</em> where he wants to create some files and folders. Usually I used <code>StreamWriter</code> like:</p>
<pre><code>using (System.IO.StreamWriter file = new Sys... | <p>You can let the user specify the folder he wants using the <a href="https://msdn.microsoft.com/library/windows/apps/br207881" rel="nofollow">FolderPicker</a> class.</p>
<pre><code>var folderPicker = new Windows.Storage.Pickers.FolderPicker();
folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocat... |
Spring-4 - Refactoring use of instanceof for calling appropriate method <p>I have below set of interfaces and classes.
Note the <code>doSomething</code> method. It has to check for the instance of the object before calling the interface method on it. I would like to avoid that, as it involves changing this method whene... | <p>Since none of the answers has a generic solution. Spring allows to inject all implementations of a type. The solution below is not tested I wrote it in a text editor. It can be improved by making VehicleRepairService an abstract class and use for example ResolvableType retrieve the generic type in this abstract clas... |
How to not get data to overwritten in firebase and store an attribute as a list of items? <p>Whenever I click on the SAVE Button to save the name and number, the skills field is being overwritten.</p>
<p><a href="https://i.stack.imgur.com/qh4La.png" rel="nofollow">Here the image of Activity while storing details</a></... | <p>Use Push()</p>
<pre><code>Firebase newsPush = new Firebase(Config.FIREBASE_URL);
final News news = new News();
news.setNewsTitle(newsTitleString);
news.setNewsDetails(newsDetailsString);
newsPush.push().setValue(news);
</code></pre>
<p>Create Getters and Setters for ... |
Why df[[2,3,4]][2:4] works and df[[2:4]][2:4] does not in Python <p>suppose we have a datarame</p>
<pre><code>import pandas as pd
df = pd.read_csv('...')
df
0 1 2 3 4
0 1 2 3 4 5
1 1 2 3 4 5
2 1 2 3 4 5
3 1 2 3 4 5
4 1 2 3 4 5
</code></pre>
<p>Why one approach is working and other returns syntax error?</p>
| <p>I think you need <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html" rel="nofollow"><code>ix</code></a>:</p>
<pre><code>print (df.ix[2:4,2:4])
2 3
2 3 4
3 3 4
4 3 4
</code></pre>
|
Runining xercesImpl on java 6 <p>I am using xercesImpl.jar to create instance of DocumentImpl,
when I am runing the application on java6 I get the following error : </p>
<blockquote>
<p>The java class could not be loaded. java.lang.UnsupportedClassVersionError: (myClass) bad major version at offset=6</p>
</blockquo... | <p>Try using xercesImpl jar wothversion 2.11.0. you can find maven details as below :</p>
<pre><code><dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
</code></pre>
<p>This should solve your co... |
The Button btnGet is not working, what should I do <pre><code> ProfileActivity.java;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationM... | <p>Place your initialization:</p>
<pre><code>//initializing views
textViewUserEmail = (TextView) findViewById(R.id.textViewUserEmail);
buttonLogout = (Button) findViewById(R.id.buttonLogout);
edtxtLati = (EditText)findViewById(R.id.edtxtLati);
edtxtLongi = (EditText)findViewById(R.id.edtxtLongi);
btnGet = (Button)find... |
Cannot find module './_apply' <p>If I run </p>
<pre><code>node index
</code></pre>
<p>I get: </p>
<pre><code>ERROR: Cannot find module './_apply'
</code></pre>
<p>I used npm install, and tried to manually install it</p>
<p>which node returns:</p>
<pre><code>/usr/bin/node
</code></pre>
<p>which npm returns:</p>
... | <p>Did you "npm install apply" and did you try doing require("apply")?</p>
|
how to set slide proportions with ReporteRs package <p>I started to play with the <code>ReporteRs</code> package and hanging at a simple problem. I am trying to get a specific format for ma slides, for example to present on a 1280x1024 projector without any bars... But the slides created by <code>ReporteRs</code> have ... | <p>I guess I just figured it out on my own. I saved an empty PowerPoint document with the expected ratios as <code>template.pptx</code> and used this when using function <code>pptx()</code>...</p>
<pre><code>myplot <- qplot(Sepal.Length, Petal.Length,
data=iris, color=Species,
size=P... |
Strange crash when using for loop <p>I have an app that is creating and filling entities inside a </p>
<pre><code>[[self managedObjectContext] performBlockAndWait
</code></pre>
<p>Inside this block I use a for loop to cycle through some data and create entities using this data. </p>
<p><strong>The strange part is :... | <p>try</p>
<pre><code>for ( Entity in array.length )
</code></pre>
|
Splitting text gathered using .text() <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> $(document).ready(function(){
var dates = "July 5, 2016July 12, 2016";
... | <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> $(document).ready(function(){
var dates = "July 5, 2016July 12, 2016";
var splitted = dates.split(/\... |
AngularGrid library produces empty space in some special cases <p>I am using Angular grid to achieve a Pintrest-like fluid layout of items on my page. It works fine in general but in soem special cases it produces an empty space on my page. It seems the position of item7 is not calculated correctly
<a href="https://i.s... | <p>Ok. a bit of research showed that this was actually cased by this css on some parts of the content of each item:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code> ove... |
Is there any simulator/tool to generate messages for streaming? <p>For testing purpose, I need to simulate client for generating 100,000 messages per second and send them to kafka topic. Is there any tool or way that can help me generate these random messages?</p>
| <p>There's a built-in tool for generating dummy load, located in <code>bin/kafka-producer-perf-test.sh</code> (<a href="https://github.com/apache/kafka/blob/trunk/bin/kafka-producer-perf-test.sh" rel="nofollow">https://github.com/apache/kafka/blob/trunk/bin/kafka-producer-perf-test.sh</a>). You may refer to <a href="ht... |
MySQL UNION returns ids that don't exist <p>I have a table <strong>t</strong> with 900 ids, 1-900. For the purpose of my task, I need to do something like (I think there is no meaning in try to reason behind this type of query, as it's something I'm experimenting on):
The id is NOT unique (as it is somewhat of foreign ... | <p>I'm not sure, but perhaps you need to add <code>as id</code> in the second select field, like this: </p>
<pre><code>SELECT DISTINCT(id) FROM ( SELECT DISTINCT(t1.id) **as id** FROM t t1 WHERE {...} UNION SELECT DISTINCT(t2.id) FROM t t2 WHERE {...} INNER JOIN t t3 ON t2.id=t3.id WHERE{...} UNION SELECT DISTINCT(t3.... |
SQL Query to Remove Double Quotes in PHP Script is Not Working <p>In my PHP script, I need to update fields to remove the double quotes in a particular column. When I execute my query, the fields are not stripped of the double quotes. I suspect that it has something to do with escaping the characters in the query. T... | <p>You are going to have to escape the slashes themselves so that they stick around when the SQL query is executed so I am suggesting you do it like so:</p>
<pre><code> $sql = "UPDATE `TNDB_CSV2` \n"
. " SET `Event` = TRIM(BOTH '\\\"' FROM `Event`)";
</code></pre>
<p>I also got rid of the backslashes around the ... |
Running the sample code in pytesseract <p>I am running python 2.6.6 and want to install the <a href="https://pypi.python.org/pypi/pytesseract" rel="nofollow">pytesseract</a> package. After extraction and installation, I can call the pytesseract from the command line. However I want to run the tesseract within python. I... | <p><code>tesseract_cmd</code> should point to the command line program <a href="https://github.com/tesseract-ocr/tesseract" rel="nofollow"><code>tesseract</code></a>, not <code>pytesseract</code>.</p>
<p>For instance on Ubuntu you can install the program using:</p>
<pre><code>sudo apt install tesseract-ocr
</code></p... |
UIWebview show previous loaded content for brief <p>I am loading html string with <strong>loadHTMLString</strong> method in <code>UIWebView</code> in <code>UICollectionViewCell</code> and reuse that cell.but <code>UIWebview</code> showing previous loaded content for brief and after that load new content.</p>
<p>anyon... | <p>Load the Webview in following method of <code>UITableViewDelegate</code>:</p>
<pre><code>- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
</code></pre>
|
Any suggestion on how to investigate css issue in bootstrap-designed page? <p>Any suggestion on how to check why I get this black box instead of standard bootstrap dropdown? I know, may sound like stupid question, but bear this me...</p>
<p>I checked, there are no referenced css files that could break this functionali... | <p><strong>UPDATE:</strong> Whoever voted to close the question - I dont understand the reason, dont you want other people to know it was <strong>Chrome bug</strong> ??</p>
<p><a href="https://i.stack.imgur.com/La57F.png" rel="nofollow"><img src="https://i.stack.imgur.com/La57F.png" alt="enter image description here">... |
Column being passed in as dataframe after naming arguments in user defined function <p>[Newbie here]Stuck at a very weird problem. I have a function to calculate lag, it works fine when the arguments are not named in function, but doesn't when I give them a name. </p>
<p>The following code doesnt work, and prints "dat... | <p>in your function argument:</p>
<pre><code>ind = a
</code></pre>
<p>means that the value per default of the argument <code>ind</code> will be a.
<code>ind</code> is the name of your argument so you must use it in the function instead of <code>a</code>.</p>
<p>try this:</p>
<pre><code>lagger <- function(ind,de... |
Forms firing ngSubmit twice on Angular 2.0.1 <p>For any form in Angular 2.0.1, whenever I press return or click on the submit button, the <code>ngSubmit</code> output is fired twice. I'm already including the <code>FormsModule</code> in the application module:</p>
<pre><code>@NgModule({
imports: [
BrowserModule,... | <p>After some some comments I tried to reproduce the error in a Plunker only to realize that the problem was something else entirely. What was being fired twice was not the <code>ngSubmit</code>, but the HTTP request.</p>
<p>I was subscribing twice to the same <code>http.post(args)</code>, what happens is that I need ... |
How to add class Angular 2 <p>I'm trying to override only a part of my default class (glyphicon-eye-...). </p>
<p>With this code :</p>
<pre><code><i [class.glyphicon-eye-open] = "isOpen" class="glyphicon glyphicon-eye-close"></i>
</code></pre>
<p>I get <code>class = "glyphicon glyphicon-eye-close glyphic... | <p>Use the <a href="https://angular.io/docs/ts/latest/api/common/index/NgClass-directive.html" rel="nofollow">ng-class</a> instead</p>
<pre><code><i [ngClass]="{'glyphicon-eye-close': !isOpen, 'glyphicon-eye-open': isOpen}" class="glyphicon"></i>
</code></pre>
|
How to move positions of divs using css <p>How can I make an element visually switch position with another element using CSS? For example, if I have this HTML markup:</p>
<pre><code><html>
<body>
<div class="div1">Div1</div>
<div class="div2">Div2</div>
<div class="d... | <p>You can do it using flexbox's <code>order</code> property:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.flex {
display: flex;
}
.flex > div {
width: 100p... |
Getting Error from Adding and Printing Linked Lists <p>Briefly, I want my code to add the given elements to the list and print it to the screen. The Problem is, it prints the last element of the list for 3 times and doesn't print the others. I spent so much time but I couldn't find the problem. </p>
<pre><code>public... | <p>Your Node Class also needs a Book instance variable:</p>
<pre><code>private static Book bk;
private Book book;
private Node link;
public Node root;
</code></pre>
<p>Then these methods need updated to use the instance variable over the class variable:</p>
<pre><code>public Book getBk() {
return book;
}
public ... |
Force some child elements to right side <p>There are four child divs. These are visible in desktop like this way:</p>
<pre><code>First Text | Second Text | Third Text | Fourth Text
</code></pre>
<p>In mobile, they will be like this way:</p>
<pre><code>First Text | Third Text
Second Text | Fourth Text
</code></pre... | <p>Yes, since you can use FlexBox, you can use the <code>order</code> to make it work:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {display: flex;}
.col {width: ... |
Negative subscripts in Bash arrays <p>After creating a simple bash stack script I encountered an error related to bash arrays.</p>
<p><em>From the Bash manual:</em></p>
<blockquote>
<p>An indexed array is created automatically if any variable is assigned
to using the syntax:</p>
<p><code>name[subscript]=valu... | <p>Guess what's in the <a href="http://tiswww.case.edu/php/chet/bash/CHANGES" rel="nofollow">Bash changelog</a>:</p>
<p>For: <em>changes between this version, bash-4.3-beta, and the
previous version, bash-4.3-alpha</em></p>
<blockquote>
<p>x. The shell now allows assigning, referencing, and unsetting elements of
... |
expressjs route methods before and after <p>How to add middleware functions to each of expressjs route functions ? Most of route functions which turn out to be CRUD on database have standard before and after statements - is there a way to have before and after for route functions.</p>
<pre><code> app.route('/api/reso... | <p>I think it's possible to make this:</p>
<pre><code>app.route('/api/resources').all(projectsPolicy.isAllowed)
.get(before,resources.list,after)
.post(before,resources.create,after);
</code></pre>
<p>where before and after are functions</p>
|
how to use Idioms in xamarin.forms using C# code and XAML <p>How to use idiom to set Grid (height, width) padding, margin and to set label font size in xamarin forms using C# and XAML code.</p>
<p>I have an example of use Rectangle with StackLayout. But i am not aware of using it with other controls.</p>
<pre><code>&... | <p>You can use it with virtually any property of any type of object you use in XAML.</p>
<p>Just use the right property and get the correct type of the argument it needs.</p>
<p>For instance, if you want to set the <code>Spacing</code> in a <code>Grid</code>, just do this:</p>
<pre><code><Grid VerticalOptions="Fi... |
if (isset) to hide an element until it is set <p>I am attempting to hide an image box until a file has been set within my file upload code. Right now it shows the <code>$preview</code> image box regardless if a file has been set.</p>
<p>What am I doing wrong?</p>
<pre><code><form action="" method="POST" enctype="m... | <p>If you want to do it with PHP only, your code should look like below ( except the security for $_POST htmlstrips, escapes):</p>
<pre><code><?php if (isset($_POST['file'])):?>
<?php $file = $_POST['file']; //#SECURE You should escape here ?>
File: <?php echo $file; ?>
Image: <img wi... |
EF - Cannot apply operator '==' to operands of type 'TId' and 'TId' <p>I have this generic class, which uses Entity Framework 6.x.</p>
<pre><code>public class GenericRepository<TEntity, TId> where TEntity, class, IIdentifyable<TId>
{
public virtual TEntity GetById(TId id)
{
using (var conte... | <p>This is a known issue with generics which normally is handled by using <code>EqualityComparer<T>.Default</code> instead of the <code>==</code> operator. However this approach doesn't work with LINQ to Entities.</p>
<p>One way to solve it is to build the predicate dynamically using the <a href="https://msdn.mi... |
npm install and deprecated warnings <p>I've started to use npm recently and sometimes during installations some warnings pop up.</p>
<p>For example, running</p>
<pre><code> npm install gulp-chimp --save-dev
</code></pre>
<p>yields the following warnings</p>
<blockquote>
<p>npm WARN deprecated to-iso-string@0.0.2:... | <p>To ensure that updating the dependencies doesn't break anything, version control is a must. Often you can update the deprecated dependencies without much trouble, but there are definitely times where doing so will cause breakage in the package using it. </p>
<p>What I don't recommend doing is ignoring the deprecati... |
the query is not using an index despite the columns joined are of the same type <p>The following query is taking too long and as the execution plan suggests it is scanning over a million rows on SPC and not using an index. I would like to understand if there is way to either use the index or modify the query to avoid s... | <p>You dont have index for <code>SPC</code>.<code>ENDS_ON</code> </p>
<p>You should create a composite index for <code>SAT_TABLE2( PCH, ENDS_ON)</code></p>
|
Mark as unseen on Gmail (imaplib) <p>I'm trying to mark email as unseen on Gmail server.</p>
<p>I'm using this command:</p>
<pre><code>res, data = mailbox.uid('STORE', uid, '-FLAGS', '(\Seen)')
</code></pre>
<p>Everything goes OK but when I check it using web browser it's still marked as seen.
When I check flags her... | <p>It appears you've misunderstood flags on APPEND a bit.</p>
<p>By doing <code>APPEND folder (-FLAGS \Seen) ...</code> you've actually created a message with two flags: The standard <code>\Seen</code> flag, and a nonstandard <code>-FLAGS</code> flag.</p>
<p>To create a message without the \Seen flag, just use <code>... |
When we use "left" property in an animate function in jquery, does it mean offset().left or position().left? <p>Here is it manipulating the <code>$("#mydiv").position().left</code> or <code>$("#mydiv").offset().left</code>?</p>
<pre><code>$("#mydiv").animate({"left":"-100"},1000,"swing");
</code></pre>
| <p><strong>Neither.</strong></p>
<p>You are simply animating the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/left" rel="nofollow"><code>left</code></a> property of the element. The <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/position" rel="nofollow"><code>position</code></a> of the element ... |
Angular directive without timeout service does not work <p>In angularJS, I have written a directive to display data. This data is fetched by a http service from remote database.</p>
<p>If I apply below <em>timeout</em> service in code, then result is displayed on the html page as http service returns in one second.</p... | <p>You should use Angular's <a href="https://docs.angularjs.org/api/ng/service/$q" rel="nofollow">promises</a> or <a href="https://docs.angularjs.org/api/ng/service/$http" rel="nofollow">$http</a> service which allows to return a promise.</p>
<p>After the promise, e.g. $http request, is resolved, you can populate <cod... |
TSQL trigger instead of insert <p>I need to replace, after an insert in a certain table, one of the column value if it match with a banned value.</p>
<p>example:</p>
<pre><code>INSERT INTO [dbo].[TEST_A]
([COL_A]
,[COL_B])
VALUES
('TEST'
,'TEST1')
</code></pre>
<p>TES... | <p>If you have more values than you want to put in a case statement, you can try using a table to store the banned words and the replacement for them. Then join to that in the insert, something like:</p>
<pre><code>CREATE TRIGGER [dbo].[TEST_NAME_INS] ON [dbo].[TEST_A]
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO TEST_... |
Autorefactor with intellij <p>Itellij keeps refactoring my code which is like this:</p>
<p>MY CODE</p>
<pre><code> public void setOwner(Owner owner) {
this.owner = owner;
}
</code></pre>
<p>into something like this: </p>
<p>AFTER DEFAULT REFACTOR:</p>
<pre><code>public void setOwner(Owner owner... | <p>By default IntelliJ is set to "fold" or "collapse" certain types of code for example, one-line methods.</p>
<p>If you want to change it, open Preference & go to Editor -> General -> Code Folding and un-select some or all the options.</p>
|
Sendgrid Unsub For Only Specified Group <p>I am using sendgrid unsub api's for who does not want the campaign e-mails.</p>
<p>But when I send request for unsub the email, the adress goes to global unsub list. </p>
<p>Here is my php code</p>
<pre><code>$parameters = array(
"api_user" => self::EMAIL_USER_NA... | <p>It looks like you're using the V2 API right now. Unsub groups are only available via the V3 API, using the <a href="https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/suppressions.html#-POST" rel="nofollow">suppressions endpoint</a>.</p>
<p>In V3, you POST addresses to the resource URL of the... |
Python cprofiler a function <p>How to profile one function with cprofiler?</p>
<pre><code>label = process_one(signature)
</code></pre>
<p>become</p>
<pre><code>import cProfile
label = cProfile.run(process_one(signature))
</code></pre>
<p>but it didn't work :/</p>
| <p>according to documentation (<a href="https://docs.python.org/2/library/profile.html" rel="nofollow">https://docs.python.org/2/library/profile.html</a>) it should be <code>cProfile.run('process_one(signature)')</code></p>
<p>also, look at the answer <a href="http://stackoverflow.com/a/17259420/1966790">http://stacko... |
Error saving a file on server <p>I am generating a Key and i need to record on server. When i tried locally, it Works ! The problem is when i try on the server...
The archive is generated but when ON THE SERVER the download finish,but i cannot open and cannot save. I don´t get an error...but i just cannot save...</p>
... | <p>Try to use </p>
<pre><code>string fileNamePrivate = "~/PASTA1/archive.txt";
Directory.CreateDirectory(Path.GetDirectoryName(HostingEnvironment.MapPath(fileNamePrivate)));
StreamWriter textWriterPriv = new StreamWriter(fileNamePrivate, false);
</code></pre>
<p>How is a Server you have to use HostingEnvironment.MapP... |
MsgViewer (Java) won't open .msg files - Batch file solution? <p>I've just downloaded MsgViewer from here:
<a href="https://sourceforge.net/projects/msgviewer/" rel="nofollow">https://sourceforge.net/projects/msgviewer/</a></p>
<p>I need it to be the default program for opening .msg files.
It required Java JRE so I'... | <p>Worked it out!</p>
<p>*.msg associated to batch file containing: </p>
<p>Java -jar MSGViewer.jar %1</p>
<p>"%1" being the magical answer. </p>
|
Bootstrap dataTable not sorting and searching in php table <p>I'm a site that has one controller page to run the mysql query. It outputs the results to a viewer page named <code>m_analitica.php</code>, with <code>include("header.php")</code> at top and <code>include("footer")</code> at the bottom. </p>
<p>code for <c... | <p>Remove the <code><tbody></code> tags from inside your loop. You only want to repeat the <code><tr></code> tags. Put the <code><tbody></code> tags outside of the loop.</p>
|
How to use nested loops <p>I'm learning php and I'm stuck with one task.. </p>
<p>I'm currently looping through an array holding sub arrays which looks like this:</p>
<pre><code>$data[1]["First"] = "Iva";
$data[1]["Last"] = "IviÄ";
$data[1]["Date"] = "2016-09-29";
$data[1]["Paid"] = "Yes";
$data[2]["Firs... | <p>There are plenty of loops you can use to achieve this, the easiest case here is the <code>foreach()</code> loop.</p>
<pre><code><!-- conditional loops -->
<?php foreach($data as $single): ?>
<!-- shorthand PHP statement to echo the result -->
<td> <?= $single['First']; ?> <... |
Filtering Elasticsearch Results - Nest <p>I currently want to write a query that matches 'name', from a class called entity, then filters out the results where a guid field (stored as a string in ES) is compared to a list of string guids. If the guid stored in the Elasticsearch record matches any in the list of guids t... | <p>I would check your mapping and make sure your guid field is not analyzed. As shown in elastic search's <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html#_term_query_with_text" rel="nofollow">Finding Exact Values</a>, if the field is analyzed, each group separated by a <c... |
Error: [ng:areq] Argument 'employerCtrl' is not a function, got undefined <p>I have one arguments undefined but i don't understand why.
If I put my controller in app.js folder but everything works as I intend to create a good structure nothing works.</p>
<p>structure:</p>
<pre><code>index
app
app.js
componen... | <p>You dont have to declare the module for the controller again,</p>
<pre><code>//remove this line
var app = angular.module('myApp.employerCtrl', []);
app.controller("employerCtrl", ["$scope", function($scope) {
$scope.title = "Fronteend Software Engineer";
$scope.company = "Bee Engineering";
$scope.city... |
How to union two ordered queries in the same table <p>I have events table with columns
'title',
'description',
'start_date',
'end_date'.</p>
<p>I want to get ordered list live and future events, depends on 'start_date' and 'end_date'. </p>
<p>I try </p>
<pre><code>(
select *
from `events`
where `start_... | <p>I think you do not need union in this one.
Just put a <code>OR</code> condition in your basic query.</p>
<p>Then, to split the result into <code>"this one is live"</code> and <code>"this one is future"</code> you can use a flag</p>
<pre><code>SELECT *, start_date < NOW() AS flag
FROM `events`
WHERE (`start_dat... |
How to differentiate color scheme <p>I would like to change color scheme <code>Eiffel</code> so that the keyword <code>class</code> in java files will be different color than keyword <code>int</code>? If I change <code>Storage</code> in Eiffel, both keywords change the color.</p>
| <p>You need to find out the exact scopes of <code>class</code> and <code>int</code>. The <a href="https://packagecontrol.io/packages/PackageResourceViewer" rel="nofollow">PackageResourceViewer</a> is a great way to open files inside <code>.sublime-package</code> files.</p>
<p>Once installed, launch *âPackageResource... |
How do I find out how many times each character of a string 's' repeats itself <p>I have searched and found some similar questions, but just can't seem to figure out how to apply them to my problem. Please bear with me, as this is my first post on the site.</p>
<p>I have to find out how many times a character of a st... | <pre><code>public void test() {
// The string to test.
String s = "launch at noon";
// Count them.
Map<Character, Integer> characterCounts = countCharacters(s);
// Print the results.
for (Map.Entry<Character, Integer> e : characterCounts.entrySet()) {
int count = e.getValue()... |
Storing multiple outputs from each iteration of a for loops in R <p>I can't find a solution to this problem:</p>
<p>Given a fix path and a very limited directories from year. I'm trying to obtain each combination of path between this initial combination (<em>fixPath - year</em>) and the different, <strong>non-fixed an... | <p>You might try to set up a vector beforehand and then use this part in your for loop:</p>
<pre><code>append(VectorName, pathFinal[i])
</code></pre>
<p>you might try to include it in your existing code like this</p>
<pre><code>pathFinal <- append(pathFinal, paste(pathVector[i], list.files(pathVector[i]), sep = "... |
HSQL Trigger generates SQL Error: -458, SQLState: S1000 / java.lang.ArrayIndexOutOfBoundsException <p>I have an HSQL version of an Oracle database schema to perform unit tests.</p>
<p>I need to update a column on update with current timestamp.</p>
<p>The trigger I have implemented is loaded without complaint by the h... | <p>When you run the CREATE TRIGGER in a SQL client you will see the following error message:</p>
<blockquote>
<p>attempt to assign to non-updatable column: LAST_UPDATE [SQL State=0U000, DB Errorcode=-2500]</p>
</blockquote>
<p>This is because you are trying to modify a column in an <code>AFTER</code> trigger. Chang... |
Android - ActionBar Up button not visible when using TextView as ToolBar title <p>I have added a <code>Toolbar</code> on top of all of my activities. But I wanted the title to be in the centre, so as per some suggestions on SO, I created a <code>TextView</code> inside the <code>Toolbar</code>and I was able to put it in... | <p>You need to set the getSupportActionBar().setHomeButtonEnabled(true); enable the Up Action button</p>
<pre><code>Toolbar toolbar = (Toolbar) findViewById(R.id.lifeline_toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeBut... |
cURL returns response but unable to get the same response when tried to access using selenium firefox webdriver <p>I am trying to extract some data from a website from Linux server using Selenium.</p>
<p>When the URL is pinged through cURL, we are able to see the response from the server but when the same URL requeste... | <p>The server might be responding differently based upon you User Agent string. Many extensions allow you to set this, including "User-Agent Switcher for Chrome."</p>
<p>You might also experiment with the Selenium <code>chromedriver</code> and look to see exactly what the request is inside the browser. You can find ... |
could someone tell me what is wrong with this? <p>Question: wow, you are given two things:</p>
<p>The calling order in which all the processes are called.
The ideal order in which all the processes should have been executed.
Now, let us demonstrate this by an example. Let's say that there are 3 processes, the calling ... | <p>Your <code>swap()</code> function has multiple issues:</p>
<p>1: It calls itself with <code>return swap(a,b);</code> in the last line of the function. This will result in infinite recursion and a stack overflow.</p>
<p>2: You need to declare the return type of the function. If it takes two <code>long long</code> p... |
c# how do you swap horizontal and diagonal <p>for example, given matrix like this:</p>
<pre><code>1 2 3
4 5 6
7 8 9
</code></pre>
<p>and it will be </p>
<pre><code>1 5 9
4 2 6
7 8 3
</code></pre>
<p>and i found matrix that horizontal and diagonal but i can't swap those
can you guys help me get a code in C# for ... | <p>While the first answer does work, this solution will account for cases where the dimension lengths are not 100% known. It will use the smallest dimension length as the for loop end point.</p>
<pre><code>int[,] arr = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, {13, 14, 15} };
int numDims = arr.Rank;
int... |
Javascript object value from string path <p>I have an object:</p>
<pre><code>var obj= {
hello:{
it:"ciao",
en:"hello"
}
}
</code></pre>
<p>Now the problem is that i can't access a value through <code>obj.hello[lang]</code>, neither <code>obj.hello.en</code>.</p>
<p>i have a <strong>stri... | <p>I don't understand... obj.hello.it should work</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>var obj= {
hello:{
it:"ciao",
en:"hello"
... |
Reading files with hdfs3 fails <p>I am trying to read a file on HDFS with Python using the hdfs3 module. </p>
<pre><code>import hdfs3
hdfs = hdfs3.HDFileSystem(host='xxx.xxx.com', port=12345)
hdfs.ls('/projects/samplecsv/part-r-00000')
</code></pre>
<p>This produces</p>
<pre><code>[{'block_size': 134345348,
'group... | <p>if You want any operation on files then you have to pass full File path .</p>
<pre><code>import hdfs3
hdfs = hdfs3.HDFileSystem(host='xxx.xxx.com', port=12345)
hdfs.ls('/projects/samplecsv/part-r-00000')
#you have to add file to location
hdfs.put('local-file.txt', '/projects/samplecsv/part-r-00000')
with hdfs.o... |
Adding foreign key fails unless data is first removed and reinserted after <p>I have an odd issue with foreign keys. I am trying to perform the following query:</p>
<pre><code>ALTER TABLE [GroupMember] FOREIGN KEY ([Group]) REFERENCES [Group]([GUID])
</code></pre>
<p>Which gives me the following error:</p>
<blockquo... | <p>If you are using Microsoft SSMS check whether unchecking "Prevent saving changes that require table re-creation" solves the problem. You'll find this in Options > Designers > Table and Database Designers.</p>
<p>I have had similar issues that have been resolved by this. Let me know if it works or not.</p>
<p>Good ... |
How to get title attribute of element and insert it after element using jquery? <p>I have a list with list elements like this...</p>
<pre><code><li class="first leaf">
<a href="/admin/store/orders/view" title="View and process the orders.">View orders</a>
</li>
</code></pre>
<p>And I wand to... | <p>Your first this in your loop is a reference to the anchor. You have to comb out of that to its parent element and append to that.</p>
<pre><code>$(this).parent().append('<div>' + $(this).attr('title') + '</div>');
</code></pre>
|
AJAX POST returns complete PHP instead echoed string <p>i created a js function which gets called by certain action,</p>
<pre><code>var getX3DListFromServer = function()
{
var dataList;
//var post = $.post('X3DHandling.php', {postState:"getList"},
//function(data){
// dataList = data;
//});
//console.log(data... | <p>Do Something like:</p>
<pre><code>$.ajax({
type: "POST",
url: "functions.php",
data: {
products: "products",
},
success: function (data) {
console.log("received data: " + data);
},
error: function (err) {
alert('error: ' + err);
}
}); //END AJAX CAL... |
Executing Sas Code in schedular <p>I use sas - exceed. I do batch submission with commands on Unix. It will be really helpful if any one can guide me on how will I schedule my task at particular day and time(Say Sunday). The steps that I used to run my query on batch mode are given below:
BATCH PROCESS:</p>
<p>Step-1:... | <p>Unless you have a separate utility for scheduling, the default scheduler in Unix is <code>cron</code>. I would be cautious about using it, however, if your level of understanding of unix is not very high; it is somewhat difficult to use correctly.</p>
<p>You can read one of many papers on scheduling SAS jobs on Un... |
find repeated element in list of list python <p>I have been struggling with this problem for two days and I need help with it. I need to find repeated element in a list of lists
<code>list_of_list = [(a1, b1, c1), (a2, b2, c2), ..., (an, bn, cn)]</code> where "a" and "b" elements are integers and "c" elements are float... | <p>You can count occurrences of specific list elements and take lists with counts > 1. Something like this, using <code>collections.defaultdict()</code>:</p>
<pre><code>>>> from collections import defaultdict
>>> count = defaultdict(int)
>>> for lst in list_of_list:
... count[lst[0]] += ... |
Ionic Serve: Displays code only for a split second <p>My code is only shown for a split second after returning ionic serve and goes blank. I've everything needed to run this like nodejs, cordova, ionic, jdk, etc.
I'm new to ionic and would appreciate if someone can help me solve this.
This was run on internet explorer.... | <p>really you are very lost.
if you try to show </p>
<pre><code><h1>asdf</h1>
</code></pre>
<p>well that disappear because is replaced by the angular app in your code</p>
<pre><code> <!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></s... |
angularjs http get from json url <p>I have problem with this code I have json data from my asp.net web api. I could not get this data by angularjs. as you can see the the code;</p>
<pre><code><!DOCTYPE html>
<html ng-app="myapp">
<head>
<title ng-bind="helloAngular"></title>
&... | <p>You have some typo errors: instead of <code>$htpp</code> use <code>$http</code></p>
<pre><code>myapp.controller('myController', function ($scope, $http){
$http.get({
method:'GET',
url:'http://localhost:50972/api/product'})
.... |
Why is my app not showing data, being fetched in JSON from an API, using retrofit, in recyclerview in android? <p>Before anything, let me tell you that I'm a beginner in android development. I've been developing a music streaming app, which fetches data in JSON from an API. I'm using
retrofit2 as HTTP client and GSON ... | <p>Need to update this to return the length of the list </p>
<pre><code>@Override
public int getItemCount() {
return 0;
}
</code></pre>
<p>As far as I can tell, everything else looks okay </p>
|
Return elastic search result as raw JSON <p>Sorry for duplicated question, but this does not seem to work with current Elastic Search 2.x version. Basically, I use NEST to send query to ES and would like to get response as plain JSON, just like using POST command on Sense. Similar problem exists here: <a href="http://s... | <p>The type <code>T</code> passed to <code>.Search<T></code> on the low level client specifies the return type of the result. In order to get json returned, you simply need to change this to <code>string</code></p>
<pre><code>var searchResult = _elasticClient.LowLevel.Search<string>(querytEST);
</code></pr... |
How to model REST api for authentication service that services two "apps"? <p>I'm building a solution that serves the sell and consuming side of the market which will require two apps. I will be building it on aws lambda with a microservice architecture.</p>
<p>There is alot of shared logic / model between the two. So... | <p>There are no hard and fast rules, it depends on the set of use-cases and how open a particular design is for future enhancements.</p>
<ol>
<li>Using a URL param follows the REST semantics literally, as <code>seller</code> is not necessarily a sub-resource of <code>users</code>, but more of a filter on the type. But... |
Excel.exe has triggered a breakpoint <p>my vs 2015 recently showed some strange behaviour and I was wondering whether on of you around here encountered similiar problems. I am creating a xll addin with c++ and the xll Lib of Keith Lewis (xll12).</p>
<p>The code ran well, but at some point the c++ debugger pops up with... | <p><code>int 3</code> is the i686 assembly instruction for a breakpoint.</p>
<p>In itself it's not particular useful but is signalling to you that something has gone awry.</p>
<p>If your xll is <em>really</em> that minimal, are you sure you're registering it correctly with Excel?</p>
|
UIButton inside UISegmentedControl action <p>I am continuing my calculation program to improve my skills in Swift code. Right now I have a problem: I want that an UISegmentedControl select the operator of my operations (+, - ecc..) and when one is selected a UIButton func calculate the values based on the decision of t... | <p>Try removing the lines with <code>@IBAction func ...</code> inside your switch cases.</p>
<p>I think your <code>@IBAction func operatorSelectorChanged</code> should look something like this:</p>
<pre><code>@IBAction func operatorSelectorChanged(_ sender: UISegmentedControl) {
switch operatorSelector.selectedSe... |
How replication works <p>Lets say that I have replication on master Solr server configured like this:</p>
<pre><code><lst name="master">
<str name="enable">true</str>
<str name="replicateAfter">optimize</str>
<str name="confFiles">solrconfig.xml,schema.xml,stopwords.txt... | <p>the replication is a pull mechanism - so to be able to support your scenario you need to do a bit of configuration.</p>
<p>For you questions:<br>
1. it does not - it pulls in intervals (or forced) from master which tells what version is ready to be replicated<br>
2. yes - 24 hours<br>
3. only if an optimize have be... |
Get Azure Sql serve port in ARM <p>I am using an ARM template to get an azure sql server name but I looking for a way to also get the port (1433) instead of providing a hardcoded value.</p>
<p>My ARM code:
<code>
[concat(reference(resourceId('Microsoft.SQL/servers/', parameters('database_server_name'))).fullyQualified... | <p>Do it the same as your database_server_name parameter:</p>
<pre><code>[concat(reference(resourceId('Microsoft.SQL/servers/', parameters('database_server_name'))).fullyQualifiedDomainName,':', parameters('port_number'))]
</code></pre>
|
C# Google Cloud Storage Get ListObjects in Folders <p>I'm storing all my application information in Google Cloud Storage. I've created a bucket and inside this bucket I've folders. With that code, I can get list of all my folders.</p>
<pre><code>public static IList<uFolder> ListFolders(string bucketName)
{
... | <p>I think what you want is to set the <a href="https://developers.google.com/resources/api-libraries/documentation/storage/v1/csharp/latest/classGoogle_1_1Apis_1_1Storage_1_1v1_1_1ObjectsResource_1_1ListRequest.html#ab1665c7589c52755d83720ec48665d85" rel="nofollow">Delimiter</a> property of the list request to <code>/... |
Bootstrap Validator to validate length of field correct syntax <p>I'm trying to validate the string's length with Bootstrap Validator. Unfortunately, the JavaScript does not work. I'm thinking maybe a syntax error.</p>
<p>HTML :</p>
<pre><code> <form id="ordertracking" role="form">
<div style="mar... | <p>You haven't included the Library:</p>
<p>Add this to your head section below all the other scripts and it should work. </p>
<p><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.3/js/bootstrapValidator.min.js"></script></code></p>
<p>if you check the console you wi... |
JS Canvas, images in animation stack instead of change after every turn <p>I have been stuck on this for a few days, and can't find a solution. What I am trying to make is that after every cycle the images change, and after all images get displayed in order it starts again with the first image again. Now the problem I ... | <h2>Use (%) modulo to cycle</h2>
<p>If you want to cycle through an array of items you can use % to get the array index. % returns the remainder of a divide. ie <code>0 % 4 == 0</code>, <code>3 % 4 == 3</code>, <code>4 % 4 == 0</code>, <code>7 % 4 == 3</code></p>
<p><a href="https://developer.mozilla.org/en-US/docs/W... |
Group values conditionally in data frame in R <p>Colleagues</p>
<p>I have the following problem. My data-set looks like this:</p>
<pre><code>Article = c("A","A","A","A","B","B","B","C","C","C","C")
Value = c(1,5,2,1,20,18,5,6,3,31,99)
df = data.frame(Article, Value)
</code></pre>
<p>My goal is to match the highest V... | <p>ok so you could then do something like this:</p>
<pre><code>library(dplyr)
high_and_low <- df %>%
group_by(Article) %>%
summarise(high = max(Value),
low = min(Value))
</code></pre>
<p>which just pulls out the high and low values for each block. if you needed other info associated with the ... |
How to add TextBlock text value from database object value <p>I'm working on WPF application which has one Window.xaml where I'm using dataGrid which is filled from Database (MSSQL 2008R2), In that dataGrid I'm loading orders from my Database.</p>
<p>I'm also grouping my orders by numberOfOrder, and its possible to e... | <p>Maybe you can put just another TextBlock in your DockPanel?</p>
<pre><code><DockPanel>
<Button DockPanel.Dock="Right"/>
<Button DockPanel.Dock="Right"/>
<TextBlock Text=""/>
<TextBlock Text"whatever you wan"/>
<TextBlock Text="{Binding Items, Converter={StaticResource... |
Swift 3 : Extra argument 'error' in call <p>I have tried all solutions like try catch. But not able to solve this error. Please help me out, I am new to ios.</p>
<pre><code>func apicalling () {
let headers = [
"content-type": "application/json",
"cache-control": "no-cache",
"postman-token"... | <p>In swift 3, it will be:</p>
<pre><code>do {
let data = try JSONSerialization.data(withJSONObject: parameters, options:[])
// do your works
} catch {
print("Got error: \(error)")
}
</code></pre>
<p>The API document is here: <a href="https://developer.apple.com/reference/foundation/jsonserialization/1413636-da... |
what is equivalent of "npm install --save" in yarn? <p>I am using yarn to install the dependencies,what will be the equivalent of "npm install --save " in yarn to update the entry in package json. I can use "npm install --save " here, but i want to use yarn as much as possible to improve performance & avoid confusi... | <p>The yarn equivalent to<code>npm install <name> --save</code> is:</p>
<pre><code>yarn add <name>
</code></pre>
<p><a href="https://yarnpkg.com/en/docs/migrating-from-npm#toc-cli-commands-comparison" rel="nofollow">Here's the link to the docs</a> for the full list of commands in comparison to <code>npm</... |
Why Adt plugin for eclipse doesnot work? <p>I am running windows and eclipse mars. I downloaded and installed the <a href="https://developer.android.com/studio/tools/sdk/eclipse-adt.html" rel="nofollow">ADT plugin</a> version 23.0.7. but nothing happens after I install it. I can't find the option to create a new androi... | <p>Open the Error Log view after installing ADT and see if there are any relevant errors reported there.</p>
<p>Also, since ADT is no longer supported, it may just be incompatible with Eclipse's Mars (and newer) releases. Try installing it into <a href="https://eclipse.org/downloads/packages/release/luna/sr2" rel="nof... |
Generate mapping.txt with Proguard <p>Ho to generate the mapping file with Proguard enabled ?</p>
<p>Here is my config file proguard.cfg :</p>
<pre><code>-keep class mono.MonoRuntimeProvider { *; <init>(...); }
-keep class mono.MonoPackageManager { *; <init>(...); }
-keep class mono.MonoPackageManager_Res... | <p><code>Xamarin.Android</code> includes a <code>-dontobfuscate</code> in it's <code>proguard_xamarin.cfg</code> and thus mapping for obfuscated Java stack traces would be turned off even if you include <code>-printmapping</code></p>
<h3><code>proguard_xamarin.cfg</code> (Xamarin.Android Version: 7.0.1.3)</h3>
<pre><... |
To find the overlapping of two date ranges and merge it into one date range in JAVA <p>We have blocks with specific no. of date ranges, and require to merge the date ranges of every block which are overlapping and add their overall quantity.</p>
<p>Consider the below given input and desired output:</p>
<h2>Input:</h2... | <p>Utility unknown, but you could compute your answers with an array of integers where the data representation of the index of the array is the offset of each day from a start point, and then you iterate over every range and increment the value of the range into the corresponding indices of the array, then when you're ... |
php urlencode returns different results when run in a class <p>I'm running PHP 5.3.3 and when using <code>$str=urlencode("£")</code>, the value of <code>$str</code> is <code>%A3</code>, as I would expect. However if I call the <code>urlencode</code> function from within a class, the value of <code>$str</code> is <code... | <p>There are very few reasons that <code>urlencode()</code> might return different values. Inside or outside the class is not the issue. We can rule that out very easily.</p>
<p>Create a file <code>test.php</code> with the following:</p>
<pre><code><?php
var_dump(urlencode("£"));
class x {
public function y()... |
In Qt how to add a file with a QFileDialog in a QLineEdit <p>I have one window which has a button named "..." which open an other window which has also a button named "..." which open a QFileDialog. Next to the button of the second window, there are 10 QLineEdit to get 10 files. With the QFileDialog, I can't take a mp3... | <p>Maybe you can try to emit the address of filename in one window and then receive this address in the second window by slot function</p>
|
Python/Flask: UnicodeDecodeError/ UnicodeEncodeError: 'ascii' codec can't decode/encode <p>Sorry for the millionth question about this, but I've read so much about the topic and still don't get this error fixed (newbie to all of this).
I'm trying to display the content of a postgres table on a website with flask (using... | <p>since in Python 2 bytecode is not enforced, one can get confused with them.
Encoding and Decoding works as far as i know from string to bytecode and reverse. So if your resultset is a string, there should be no need to encode it again.
If you get wrong representations for special characters like "§", i would try so... |
Java - copy items from one list to another using generics <p>I am trying to make a generic copy from one list to another for certain objects I know the are compatible each other, F can be an argument of T constructor</p>
<pre><code>public static <F,T> List<T> copyFrom(List<F> from){
List<T>... | <p>One solution is to pass something to <code>copyFrom</code> that knows how to make a <code>T</code> from an <code>F</code>. For example:</p>
<pre><code>public static <F, T> List<T> copyFrom(List<F> from, Function<F, T> converter) {
List<T> to = new ArrayList<T>();
if (from... |
Identify drive letter of USB composite device using Python <p>I have a USB composite device that has an SD card. Using Python, I need a way to find the drive letter of the SD card when the device is connected. Does anyone have experience with this? Initially it needs to work in Windows, but I'll eventually need to port... | <p>I don't have an SD card attached to a USB port. To get you started, you could <em>try</em> this on Windows. Install <a href="http://timgolden.me.uk/python/wmi/index.html" rel="nofollow">Golden's WMI</a>. I found that the Windows .zip wouldn't install but the pip version works fine, or at least it does on Win7. Then ... |
Output InnerHTML Perl LibXML <p>Please see MWE below</p>
<pre><code>use XML::LibXML;
my $content = "<tr>
<td class='title'>Synonym(s)</td>
<td>Automobile<br/>Car<br/></td>
</tr>";
my $parser = XML::LibXML->new({suppress... | <p>There is no built-in way to do that in XML::LibXML. Changing the xpath won't help. That xpath gives you a list of <code>td</code> elements. If you'd get the stuff inside of all <code>td</code> elements that fit the current xpath, you'd end up with a long list of things and no way to discern where the content of the ... |
Convert .fbx to .obj with Python FBX SDK <p>I have a ten frame .fbx file of an animal walking. This file includes a rigged model with textures, but I am only interested in the mesh of the model at each frame. </p>
<p>How can I use Python FBX SDK or Python Blender SDK to export each frame of the fbx file into an obj ... | <p>its a example for fbx to obj
import fbx</p>
<pre><code># Create an SDK manager
manager = fbx.FbxManager.Create()
# Create a scene
scene = fbx.FbxScene.Create(manager, "")
# Create an importer object ... |
cast numpy array into memmap <p>I generate some data in my memory and I want to cast it into numpy.memmap to save up RAM. What should I do? my data is in:</p>
<pre><code> X_list_total_standardized=np.array(X_list_total_standardized)
</code></pre>
<p>I know that I could initialize an empty numpy.memmap:</p>
<pre><... | <p>I found next example in numpy documentation :</p>
<pre><code>data = np.arange(12, dtype='float32')
data.resize((3,4))
fp = np.memmap(filename, dtype='float32', mode='w+', shape=(3,4))
fp[:] = data[:]
</code></pre>
<p>So your last command is ok.</p>
|
Can HTTP-header LAST-UPDATED be trusted? <p>I have been using <a href="http://www.rexswain.com/httpview.html" rel="nofollow">Rex Swain's HTTP Viewer</a> to verify that none of the texts on a certain webpage has been changed recently.</p>
<p>The response was: "Code last updated 21 January 2012", so as I understand it, ... | <p>A web server typically uses the corresponding file's <em>last updated</em> attribute as the value for the HTTP <code>Last-Modified</code> header, so in <strong>general</strong> it can be trusted, but it's always possible that the date is wrong, for whatever reason.</p>
<p>The <code>Last-Modified</code> header is us... |
Extract a single email address from Word doc and apply it to the TO: field of an Outlook email <p>The company I work for emails letters to hundreds of people a day. The letter templates vary, as does the location in the letter of the data that I want. I already have VBA code that handles most of the steps for the use... | <p>Try adding the following block to your code (preferrably in the beginning after you define <code>SourceDoc</code>) - it looks for the email using wildcards and returns a full string to the <code>EmAdr</code> variable, which you can use in the <code>.To</code> line of your outlook sender code</p>
<pre><code>Dim rng ... |
Notificatoin Intent to the app that is running <p>I recently added a notification to my test, It has a Countdown Timer in it and when I pick the time and tap the button, the notification is set to the timer and working. but when i hit the home button when the notification is still running, and tap the notification it g... | <p>you can set flags to intent for configuring its behavior,for your purpose you can use this</p>
<pre><code> notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
</code></pre>
|
How do I run my PHP code on the click of a button? <p>I'm trying to build a website for school project. I want the schoolResponse() function to happen after clicking the Submit button. If I remove the jQuery function it works but then it shows a default value when I load the page. </p>
<p>Here's my code:</p>
<pre><... | <p>You can't achieve it like this. Here is one solution:</p>
<pre><code> <?php
error_reporting(0);
$school = $_POST['school'];
function schoolResponse() {
if ($_POST['school'] == 'none'){
echo 'nothing';
} else {
echo 'someth... |
SQL Joining Diffrent Size Tables Together With Null Value Replacement <p>I am working on a query for a datatable and I can't seem to get it to display how I want, I don't know if this is even possible in SQL What I am looking to do is get a query to respond with ideally an extra column of Boolean type. </p>
<p>Curren... | <p>You're not going to run into too many scenarios for "Desired Results" that can't be produced with plain 'ol SQL. In this case you'll use a CASE statement to determine if the person has tried a beer. You'll also want a LEFT OUTER JOIN so you don't drop records coming from your <code>beer</code> table when your filter... |
Parameter Not Valid Error c# while retriving saved image from mysql <p>I have created image column in table as <code>mediumblob</code> </p>
<p>to save image i used following code </p>
<pre><code>byte[] ImageData;
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
ImageData = new byte[Convert.ToInt32(fs.Le... | <p>You don't saving image into DB correctly.
Line <code>string qry = "Update admin_info set ``img``='"+ ImageData + "' where id='AD001";</code> will result in
<code>qry = "Update admin_info set ``img``='System.Byte[]' where id='AD001</code> because you are converting byte array to string which will result in type name... |
Dropdown list to click item to display bold in textbox then type normal <p>When type text display dropdown list click it will display Bold letter in textbox then type continuously normal letter allowed only not bold letter without button.</p>
<p>Eg. <strong>Java</strong>world</p>
<p><div class="snippet" data-lang="j... | <p>Please look at my solution: <a href="http://jsfiddle.net/ionutmihai1995/32Bck/340/" rel="nofollow">jsfiddle</a></p>
<pre><code>$(document).ready(function () {
$("#suggest").autocomplete({
delay: 100,
source:["Java","Javascript","PHP","HTML","CSS","Angularjs","SQL",".Net"]
}).data( "autocomplete" )._ren... |
String formatting of floats <p>I would like to convert a number to a string in such a way that it only shows a certain number of significant digits, without superfluous zeros. The following is an example of some desired in/outputs, given that I want 5 significant digits:</p>
<pre><code>0.0000123456789 > 1.2346e-5
0... | <pre><code>'{:.4g}'.format(float(input)) if x<=1000 or x>=.0001 else '{:.4e}'.format(float(input))
</code></pre>
|
Implementing paging with hibernate envers <p>I have written an envers query as below;</p>
<pre><code>AuditReader reader = AuditReaderFactory.get(entityManager);
List<Object[]> changes = reader.createQuery()
.forRevisionsOfEntity(cls, true, true)
// Various conditions
.getResultList();
</code></pre>
... | <p>It appears that the <code>PageImpl</code> class expects the <code>List<T></code> you provide in the constructor to be the subset of the rows for the given page, already pre-sorted. Therefore, we'll need to apply the sort operations as a part of the Envers query. </p>
<pre><code>List<Object[]> changes... |
Why does my valueOf() method not return the value? <p>I'm having a little problem with the valueOf() method of an object.
I've got an Array with objects and object literals in it.
Say it's <code>var Books = [ {"name": "SomeBook"}, {"name": "SomeOtherBook"} ]</code>.
Now I want to write all the literals into some text-i... | <p><code>property</code> is a string containing the name of the property.</p>
<p><code>valueOf</code> gives you the primitive value of that, which is still a string containing the name of the property.</p>
<p>If you want to use that string to get the value of the property name which matches the string stored in <code... |
One recipe for multiple targets with static pattern rules? <p>what is the best way using make to achieve the following:</p>
<h2>input files</h2>
<pre><code>$PRJ/lib/foo.c
$PRJ/app/bar.c
$PRJ/app/baz.c
</code></pre>
<h2>output files shall be (using GCC):</h2>
<pre><code>$PRJ/obj/foo.o
$PRJ/obj/bar.o
$PRJ/obj/baz.o
<... | <p>Use <a href="https://www.gnu.org/software/make/manual/make.html#Selective-Search" rel="nofollow">the vpath directive</a>:</p>
<pre><code>SOURCES := $(shell find $(PRJ) -type f -name "*.c")
# $(PRJ)/lib/foo.c $(PRJ)/app/bar.c $(PRJ)/app/baz.c
SOURCE_DIRS := $(sort $(dir $(SOURCES)))
# $(PRJ)/app/ $(PRJ)/lib/
OBJEC... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.