input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
MainWindow from code from the main.cpp in Qt <p>Want to understand the difference in code between the <code>MainWindow</code> and the <code>main.cpp</code>. Specifically, how a chunk of code written exclusively in the <code>main.cpp</code> needs to be modified to be part of the <code>mainwindow.cpp</code> and <code>mai... | <p>You would want to separate out the user interface and the controller (business logic) into separate classes.</p>
<p>The body of <code>main()</code> instantiates the ui and the controller and connects them. A timer that fetches new results every 5 seconds. The timer could be rolled into the <code>Controller</code>, ... |
Remove Response Header - nuSOAP Server Side Instance <p>I need to be able to restrict what is being sent via send_response() method of nuSOAP at the server end. </p>
<p>When $server->service ( $HTTP_RAW_POST_DATA ) it automatically calls private method send_response()</p>
<p><a href="https://sourcecodebrowser.com/n... | <p>Okay.. The answer to this query is a small hack.. After</p>
<pre><code>$server->service ( $HTTP_RAW_POST_DATA );
//Call the following
header_remove('X-SOAP-Server');
header_remove('X-SOAP-Server:');
header_remove('X-Powered-By');
header_remove('X-Powered-By:');
</code></pre>
<p>Whatever header that needs to be... |
How do you display mongoose data in a pug template <p>I am exploring the PUG templates and have an exporess/mongodb/mongoose backend.</p>
<p>The Router for the index page is meant to display 'testimonials' and I have the following 'route':</p>
<pre><code>const Testimonial = require('../models/Testimonial');
exports.i... | <p>I think you may need to use the <code>#{}</code> between variables to interpolate its values with the template </p>
<p><a href="https://pugjs.org/language/interpolation.html" rel="nofollow">https://pugjs.org/language/interpolation.html</a></p>
<pre><code>.nk-box.bg-gray-4
.nk-gap-4
.row
.nk-carousel-2(data... |
{}.toString() Uncaught SyntaxError: Unexpected token <p>when I try it in chrome dev tools, it shows
<code>Uncaught SyntaxError: Unexpected token .</code>
However if when it assign to <strong>a</strong>:</p>
<pre><code>var a={}.toString();
a //[object Object]
</code></pre>
<p>what caused the difference?</p>
| <blockquote>
<p>what caused the difference?</p>
</blockquote>
<p>The state the parser is in. By default, the parser is in a state where it expects a <em>statement</em>. So in your example in the console, the <code>{</code> looks like the opening of a block to it, not the beginning of an object initializer. (You can ... |
Text inside element in desktop and outside in mobile <p>Good day I have been working in a responsive header which has a text inside an element but only in desktop screens, opening on mobile screens text should go after the element but with some formatting styles.</p>
<p>I'm aware "content" property doesn't support htm... | <p>I think you have to use CSS to style your element :</p>
<pre><code>.content:before {
content: "Title Outside";
font-weight: bold;
font-size: ...;
}
</code></pre>
|
what is effective way to send media like images,.. using my android application <p>i am new in android java programming and i need to create an activity which will help a user to send media like image,video, audio,.. to another user or to the group of users so that the action of sending would be super fast like whatsap... | <p>Try Firebase <a href="https://firebase.google.com/" rel="nofollow">https://firebase.google.com/</a></p>
<p>Use Firebase Storage and also Firebase Realtime Database</p>
<p>See <a href="https://firebase.google.com/docs/storage/android/upload-files" rel="nofollow">https://firebase.google.com/docs/storage/android/uplo... |
Apply Conditional Formatting to Cell on Left <p>I have a spreadsheet with 15,000 rows and 30 columns, and have applied a conditional formatting to column X to color it when it contains a certain text. This works as expected; however, I want to apply this same formatting to the cell immediately to the left (column W) as... | <p>Of course!</p>
<p>Your conditional format range will look something like this:</p>
<p><a href="http://i.stack.imgur.com/tOzRa.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/tOzRa.jpg" alt="enter image description here"></a></p>
<p>Just change the (highlighted) range to <code>$E$1:$F7</code> to apply the f... |
android how change size image in background xml <p>I'm making a layer-list for drawable...
I would like set stroke (2dp, color: #000000), corners (5dp), background (yellow) and add image on the right side, but i can't change image size.</p>
<p>What i want:
<a href="http://i.stack.imgur.com/MItYB.png" rel="nofollow"><i... | <p>A.J. thanks for help :)</p>
<p>Answer:
content_main.xml:</p>
<blockquote>
<p> </p>
<pre><code><RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/bg_tablerow">
<TextView
android:id="... |
Python appending from previous for loop iteration <p>I have a very simple but annoying problem. I am reading in a list of files one by one whose names are stored in an ascii file ("file_input.txt") and performing calculations on them. My issue is that when I print out the result of the calculation ("print peak_wv, peak... | <p>Based on your comment I believe the issue is that you are appending the data with each new file. You probably want to clear wv and flux for each new file. For example:</p>
<pre><code>for j in range(len(fits)):
wv = []
flux = []
f = open("%s"%(fits[j]),"r")
</code></pre>
<hr>
<p>Edit: I should also p... |
Pandas Label Duplicates <p>Given the following data frame:</p>
<pre><code>import pandas as pd
d=pd.DataFrame({'label':[1,2,2,2,3,4,4],
'values':[3,5,7,2,5,8,3]})
d
label values
0 1 3
1 2 5
2 2 7
3 2 2
4 3 5
5 4 8
6 4 3
</code></... | <p>I think you can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.loc.html" rel="nofollow"><code>loc</code></a> with condition created by function <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.duplicated.html" rel="nofollow"><code>duplicated</code></a>... |
Difference between MSAzure VM and APP <p>i'm beginning to research cloud computing options. What I'm trying to understand is what is the difference is between a server running an application on a virtual machine in Azure and using Azure cloud service to deploy an application. Any help? </p>
| <p>I'd recommend reviewing this document: <a href="https://azure.microsoft.com/en-us/documentation/articles/cloud-services-choose-me/" rel="nofollow">https://azure.microsoft.com/en-us/documentation/articles/cloud-services-choose-me/</a></p>
|
Marionette.js - Uncaught ReferenceError: text is not defined <p>I wonder if someone can help to find what's wrong in this case. I get "Uncaught ReferenceError: text is not defined" in line 6 app.js:</p>
<pre><code>((__t=( text ))==null?'':_.escape(__t))+
</code></pre>
<p><strong>driver.js:</strong></p>
<pre><code>va... | <p>You should take a look at the Marionnette's <a href="http://marionettejs.com/docs/v2.4.7/marionette.itemview.html#itemview-render" rel="nofollow">ItemView documentation</a> which explain how to render a template with custom data.</p>
<blockquote>
<pre><code>var my_template_html = '<div><%= args.name %>&... |
What's the difference between javax.persistence.Id and org.springframework.data.annotation.Id? <p>I'd be interested whether there is the difference between <code>javax.persistence.Id</code> and <code>org.springframework.data.annotation.Id</code>. </p>
<ol>
<li>If Spring has created that annotation only for support the... | <p><code>org.springframework.data.annotation.Id</code> is currently used by Spring to support mapping for other non relational persistence databases or frameworks that do not have a defined common persistence API like JPA. So, it is normally used when dealing with other spring-data projects such as spring-data-mongodb,... |
@Singleton @Startup @PostConstruct method guaranteed to return before EJBs made available for client calls? <p>In the context of a Java EE 6 application run on WebSphere 8.0, I need to execute a number of startup tasks before any business method can be executed. Using a @Startup @Singleton bean for this purpose seems ... | <ol>
<li>Yes, the container waits for the <code>@PostConstruct</code> method of all <code>@Startup</code> beans in the module ("EJB application") to return before allowing any client requests.</li>
<li>Yes, this is the case in WebSphere Application Server as implied by the <a href="http://www.ibm.com/support/knowledgec... |
Hidden references to function arguments causing big memory usage? <p><strong>Edit:</strong> Never mind, I was just being completely stupid.</p>
<p>I came across code with recursion on smaller and smaller substrings, here's its essence plus my testing stuff:</p>
<pre><code>def f(s):
if len(s) == 2**20:
inp... | <p>Your function is recursive, so when you call <code>f()</code>, your current frame is put onto a stack, and a new one is created. So basically each function call keeps a reference to the new string it creates to pass down to the next call.</p>
<p>To illustrate the stack</p>
<pre><code>import traceback
def recursiv... |
Laravel 5.2 or 5.3: How to Properly Implement a check to see if a session is Logged in already <p>I'm working on an application using Laravel 5.2.45, that interacts with an ionic front-end and with the server-side being tested using Postman. I'm a little stuck as to how to properly implement a check to see if the user'... | <p>I do following:</p>
<p>1) in <code>routes.php</code> I define middleware to route group:</p>
<pre><code>Route::group(['prefix' => 'auth'], function() {
Route::get('/', ['as' => 'auth', 'uses' => 'AuthController@index']);
Route::post('/', ['as' => 'auth.attempt', 'uses' => 'AuthController@attempt... |
Returning/Chaining variables vb.net <p>Id like to have VB.Net code written like this.</p>
<p>Module1.run(parameters,parameters)
">> Passing parameters to module2 >>"
Module2.run(parameters,parameters)</p>
<p>Essentially passing parameters between modules without running a module via a return statement, or multiple st... | <p>Ok I figured part1 out. The thing I'll have to do is pass the arguments by reference. By putting the ByRef keyword in the module header. And make an extra variable to store the bidirectional variable. "strange way to set the data direction if you ask me" </p>
<p>Anyway, is there a way I can use the variable supplie... |
Java SQL Querying With TextFields <p>I wrote a SQL query and used textfield for getting data. But when is a textfield empty, it gives all data. How can i stop that? Here is my code:</p>
<pre><code>String sql = "select * from boek where naam like '%"
+ txtNaam.getText() + "%' or auteur like '%"
+... | <p>How about -</p>
<pre><code>String sql = "select * from boek where ";
sql = addLike(sql, null, naam", txtNaam.getText());
sql = addLike(sql, "OR", auteur", txtAuteur.getText());
...
String addLike(String sql, String op, String col, String arg) {
if (arg != null && arg.length() > 0) {
return sql + " ... |
Maxif equivalent in excel? <p>Say I have the following table in excel:<br>
<a href="http://i.stack.imgur.com/Z9suy.png" rel="nofollow"><img src="http://i.stack.imgur.com/Z9suy.png" alt="enter image description here"></a></p>
<p>How would I go about creating a function that would select the Fruit with longest shelf li... | <p>How about the <strong>Array formula</strong>:</p>
<pre><code>=INDEX(A1:A100,SUMPRODUCT(--(C1:C100=MAX(IF(B1:B100="fruit",C1:C100,"")))*(B1:B100="fruit")*ROW(1:100)))
</code></pre>
<p><a href="http://i.stack.imgur.com/Nv2jB.png" rel="nofollow"><img src="http://i.stack.imgur.com/Nv2jB.png" alt="enter image descripti... |
How to launch url on "click_action" from GCM? <p>I am sending the following notification in a third part app using Amazon SNS and c#:</p>
<pre><code> { "collapse_key": "demo","default": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut en... | <p>When you implement <a href="https://developer.android.com/guide/topics/ui/notifiers/notifications.html" rel="nofollow">Notifications</a>, you can just set the appropriate click event depending on your use case. So yes, its possible.</p>
<p>I'm not sure about configuring multiple lines, but you can try escaping new ... |
Convert enumerated type and corresponding values into separate column in SQL <p>I would not be surprised if this is a duplicate, but I have not been able to find this variation on the theme.</p>
<p>I have a table with two columns: one indicates data type, and the other the corresponding value. I want to convert this u... | <pre><code>select
personid,
max(case when attributetype='email' then AttributeValue end) email,
max(case when attributetype='dept' then AttributeValue end) dept
from
table
group by personid
</code></pre>
|
Select a single file history out of Git? <p>I use Git to keep a version history of config files. For this purpose there are no branches. I keep a ton of these in the same repository, some of which have sensitive data. I need to zip up and send a history of a <em>single file</em> out of this repository to a vendor to di... | <ul>
<li><code>git log -p <file></code> generates all the patches used for a file.</li>
<li><code>git blame <file></code> shows what revision and author last modified each line of a file. <a href="https://www.git-scm.com/docs/git-blame" rel="nofollow">docs</a></li>
<li><code>gitk <file></code> gives y... |
automatically populate text box based on select entry <p>Is there a way within php to get a value picked up from database automatically?</p>
<p>Basically, If I have a select box & I select option "Laptop-01" , is there a way within PHP to check the database for that row and then automatically pick up the serial nu... | <p>Basically you want to do is :</p>
<p>When User select 'Laptop-01' you page must update all INPUTS with information related to user's laptop (like Serial number).This can be done by <strong>adding <a href="http://www.w3schools.com/ajax/default.asp" rel="nofollow">AJAX</a></strong></p>
<p>Please note : This answer ... |
Inno Setup: Directive or parameter "Check" expression error: Invalid symbol '.' found <p>At the top of my script I am defining a version number of a dependency for a program. </p>
<pre><code>#define ProductTestsVer "4.13.0.128"
</code></pre>
<p>I then use this identifier within the <code>Files</code> section in a <co... | <p>I do not think you are right. That syntax cannot (and does not) work even in the <code>[Files]</code> section. Tested with the latest Inno Setup 5.5.9 (both Ansi and Unicode).</p>
<p>If you check a preprocessor output, you will see that your syntax resolves to:</p>
<pre class="lang-pascal prettyprint-override"><... |
TypeScript Files Importing 'Path' Where There is No 'Path' Package <p>I have been working with Angular Universal for a couple of weeks and I have noticed that many instances of Angular Universal have a <strong>server.ts</strong> document that is located at the root directory.</p>
<p>This <strong>server.ts</strong> fil... | <p><code>path</code> is a part of <code>node</code>.</p>
<p>So <code>typings install node</code> is the key! :)</p>
<p><a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts#L2261" rel="nofollow">https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts#L2261</a></p... |
outlets renaming themselves? breaking geocodeAddressString()? <p><h1>Environment:</h1><ul><li>Xcode-8</li><li>iOS-10</li><li>Swift-3</li></ul>
<h1>Overview:</h1><ul>
I've got what, to me, is a bizarre issue with respect to <strong>Outlets</strong>, which seem to change the name of their target when being setup and, I b... | <p>I'd suggest getting rid of those various casts:</p>
<pre><code>func geocodeAddress() {
//...
geoCoder.geocodeAddressString(addr) { placemarks, error in
//...
}
}
</code></pre>
<p>It's easiest to let it infer the correct types for you. </p>
<hr>
<p>Regarding the naming of outlets, IB is trying... |
How to make EL relational operators to work on Tomcat 8/JSTL 1.2 <p>I'm having a strange behavior since our upgrade from Tomcat 6 to Tomcat 8.0.32.</p>
<p>Relational operators (<, >, <=, >=) are not working with variables defined with c:set</p>
<pre><code>public class ServiceConstants {
public static final In... | <p>If you use expressions when setting the variables it's less cumbersome:</p>
<pre><code><c:set var="a" value="${15}"/>
<c:set var="b" value="${127}" />
</code></pre>
|
Whats the difference between ref parameter and return value (methods) <p>I've been studying methods and i have stumbled across the "ref" method. However both codes seem to accomplish the same thing:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
int number;
number = 5;
... | <blockquote>
<p>Is there an advantage that ref parameter has over return value? personally i don't see a massive difference.</p>
</blockquote>
<p>Well <em>typically</em>, <code>ref</code> is used when there's already something else being returned - e.g. for <code>int.TryParse</code> (which uses <code>out</code>, but... |
Find distance between two points with longitude and latitude <p>I got an answer to this question from this website however the answer I get is wrong.</p>
<pre><code>DECLARE @orig_lat DECIMAL
DECLARE @orig_lng DECIMAL
SET @orig_lat=52.676 set @orig_lng=-1.6193
DECLARE @orig geography = geography::Point(@orig_lat, @orig... | <p>The answer is in meters, divide by 1000 and you have km.</p>
<p>I try to break it down to you:</p>
<pre><code>-- I assume you already know that this part is only declaring variables
-- and setting them.
-- In this case they are the variables for your starting coordinates.
DECLARE @orig_lat DECIMAL
DECLARE @orig_ln... |
Meteor check available versions available for atmosphere js package <p>Is it possible to check all available versions of an atmospherejs package?
For example, I am trying to install the <code>twbs:bootstrap@=4.0.0-alpha.4</code> following their <a href="https://github.com/twbs/bootstrap/" rel="nofollow">github page</a>... | <p>You can use </p>
<pre><code>meteor show twbs:bootstrap
</code></pre>
<p>or</p>
<pre><code>meteor show --show-all twbs:bootstrap
</code></pre>
<p>for older or pre-released versions. Latest available version is <code>4.0.0-alpha2</code></p>
|
how can i do to give background color to the headers using alasql? <p>what is the right key word to give the header a bgcolor ?<br>
<code>window.exportExcel = function exportExcel(listPersone) {
var fileName=prompt();
var opts = {
headers:true,
st... | <p>this is the solution to give the header a background color !</p>
<pre><code>var opts = {
headers:true,
column: {
style:{
Font:{
Bold:"1",
Color:"#3C3741",
},
... |
Java code cannot invoke method from scriptengine with new context <p>I am trying to implement example invoking method from Javascript in Java.</p>
<pre><code>private static final String JS = "function doit(p) { list.add(p); return true; }";
public static void main(String[] args) throws ScriptException, NoSuchMethodEx... | <p>I can reproduce this problem, and have found a way how to solve it.</p>
<p>I had a hunch that after casting to <code>Invocable</code>, the engines own scripting context is still being used, and not the temporary one you have passed to <code>eval</code>.</p>
<p>I can fix this by calling <code>engine.setContext(...)... |
Non Exhaustive Patterns in function <p>I'm writing a program in Haskell that can pretty print a table and do basic queries on it. The following function is a snippet of the code which prints a table:</p>
<pre><code>printTable :: Table -> [String]
printTable table@(header:rows) = [addLine] ++ addHeader ++ [addLine] ... | <p>When you pattern match on <code>(x:xs)</code>, it will only match if there is at least one item in the list.</p>
<p>You need to handle the case of an empty <code>Table</code> parameter.</p>
<pre class="lang-haskell prettyprint-override"><code>printTable [] = ...
</code></pre>
|
Get last record in mysql using php <p>How can I SELECT the last row in a MySQL table using php?
I have 3 columns id(AI), longitude and latitude.
DBName: fts
TableName: currentlocation</p>
<p>Thanks for the response guys,
I have acquired right results by using such query
SELECT longitude, latitude FROM currentlocati... | <p>You can add the following to the end of your query:</p>
<pre><code>order by id desc limit 1
</code></pre>
<p>Reference:</p>
<ul>
<li><a href="http://dev.mysql.com/doc/refman/5.7/en/order-by-optimization.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.7/en/order-by-optimization.html</a></li>
</ul>
|
Summarise transactions fulfilling a criterion in a sliding window <p>We have a table of transactions </p>
<pre><code>set.seed(1)
X <- data.table(id = 1:10,
time = c(1,2,5,6,9,12,14,20,21,23),
val = sample(0.1*10^(1:4), 10, replace=TRUE),
code = sample(c('A','A','C',... | <p>Using non-equi joins from the latest devel version (1.9.7+):</p>
<pre><code>X[, prev.time := time - 3]
X[, c("count_A_within_3", "sum_a_within_3") :=
X[X, on = .(time >= prev.time, time <= time),
.(sum(code == "A"), sum(val[code == "A"])), by = .EACHI][, .(V1, V2)]]
X
# id time val code pre... |
What are acceptCount, maxConnections and maxThreads in Tomcat HTTP connector configuration? <p>This is the configuration I'm using </p>
<pre><code> <Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" acceptCount="1000" maxConnections="500" />
</code></pr... | <p><code>acceptCount</code> -- The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.</p>
<p><code>redirectPort</code> -- if this Connector is supporting non-SSL requests,... |
Opening/editing a xib/storyboard in Xcode 8 GM results in layout crash <p>If I so much as open a xib or storyboard in <code>Xcode</code> 8 GM and choose a device/orientation to "View as" parts of my code involving custom <code>UIView</code> classes start crashing hard when I build and run my app. This applies to any ed... | <p>For the sake of anyone stumbling upon this in the future from Google I'm pretty sure the issue can be explained by these two posts:</p>
<p><a href="http://stackoverflow.com/questions/39631583/xcode8-initwithcoder-frame-size">XCode8 initWithCoder frame Size</a></p>
<p><a href="http://stackoverflow.com/questions/159... |
How do I establish a connection to dashDB from IDA? <p>I'm trying to generate a physical data model on Bluemix using InfoSphere Data Architect running on my local machine. I have a dashDB service up and running and know all the connection settings. I can't seem to set up a connection from IDA to my dashDB instance an... | <p>From a dashDB perspective here all the details one would need to know on how to connect with dashDB. I will leave the IDA side of things for someone else to answer.</p>
<p><strong><a href="http://www.ibm.com/support/knowledgecenter/SS6NHC/com.ibm.swg.im.dashdb.doc/connecting/connecting_applications_to_dashdb_databa... |
Best way to handle json streams <p>I have been evaluating dropwizard and wanted to know how to handle <code>application/x-json-stream</code> mime types. For eg. the client will send a file containing json documents in this format.</p>
<pre><code>{"name":"akshay","permissions": [ {"role": "db-reader", "access": "db"}, ... | <p>The best known library for parsing JSON is JSON-Jackson. It is very widely used and known for best performance. Here is a home page for the Library: <a href="http://wiki.fasterxml.com/JacksonHome" rel="nofollow">http://wiki.fasterxml.com/JacksonHome</a> And here the link to its github: <a href="https://github.com/Fa... |
How to get fields of DataGrid cell <p>In my WPF app, i have a Window(all code) that contains DataGrid. There's my DataGrid binding:</p>
<pre><code>using (var db = new CompanyEntities())
{
var stocks = db.Stock;
var query = from s in stocks
select new { s.Id_Product, s.Quantity };
dataGrid.I... | <p>Change your query like so:</p>
<pre><code>var query = from s in stocks
select new TableItem { Id_Product = s.Id_Product, Quantity = s.Quantity };
</code></pre>
<p>And then cast <code>SelectedItem</code> to <code>TableItem</code>, now that it actually IS one. In C#, just because it looks like another cl... |
Value Error: x and y must have the same first dimension <p>Let me quickly brief you first, I am working with a .txt file with 5400 data points. Each is a 16 second average over a 24 hour period (24 hrs * 3600 s/hr = 86400...86400/16 = 5400). In short this is the average magnetic strength in the z direction for an inbou... | <p>The problem was the selection of array creation. Instead of linspace, I should have used arange. </p>
<pre><code>Mag_time = np.arange(0,86400, 16, dtype = float)
</code></pre>
|
MAMP upgrade PHP ICU version in Symfony checker <p>I've just downloaded Symfony and I'm having a issue during the checking before starting a project.</p>
<p>After activating a php accelerator and disabling some extensions in php.ini, the system is displaying this message: intl ICU version installed on your system is o... | <p>I presume you get this when you run:</p>
<pre><code>php bin/symfony_requirements
</code></pre>
<p>This is just a warning and you can safely ignore the message. I've responded to <a href="http://stackoverflow.com/questions/39377132/icu-version-compatibility-symfony-3-1/39378273#39378273">similar questions</a> on th... |
Tableau: Plot percentage of binary column <p>Simplified example: column of 'measure' data is binary 0's and 1's. The sum of the column (all the 1's summed) is 3948. The length of the column is 4567. 3948 is 86% of 4567. How do I create a bar chart showing this percentage. All I can get is a bar adding up to 100%.</p>
... | <p>Two approaches: </p>
<ol>
<li>Right click on your measure field on whichever shelf you placed it. Choose Quick Table Calc -> Percentage of Total. Experiment with different settings for "Compute Using" and read about addressing and partitioning of table calculations to learn how to specify percent of "what".</li>
<... |
How do you create custom Polymer and PolymerDart annotations? <p>I was doing some research into PolymerDart and the various annotations which can be applied to the dart files. Be it: <code>@Property</code>, <code>@property</code>, <code>@observe</code>, <code>@reflectable</code>, <code>@PolymerRegister</code>, OR <cod... | <p>This is a big topic, but the brief answer is, yes, what you describe is technically possible but not trivial. </p>
<p>Dart annotations are available at runtime via reflection, but are most often used by <a href="https://www.dartlang.org/tools/pub/assets-and-transformers" rel="nofollow">pub transformers</a> during t... |
Wrong max length for char datatype in MySQL <p>When character encoding is <code>latin1</code> (single-byte character set), below <code>SQL</code> statement execute without error.</p>
<pre><code>create table chartype (chardata char(255));
</code></pre>
<p>But When character encoding is <code>UTF-8</code> (3 byte f... | <p>When you say <code>CHAR(255)</code> you're creating a fixed length field that can accommodate 255 characters. This is distinct from bytes. UTF-8 characters vary in length from 1 to 4 bytes depending on which character you're talking about but the default in MySQL is to accommodate only 3-byte length characters.</p>
... |
SDL library error: cannot find -lSDL_ttf cannot find -lSDL_image <p>I'm running a C++ program using sdl, my ubuntu version is 16.04.
After I sudo apt-get install libsdl1.2-dev and run the following displays :</p>
<p>g++ <code>sdl-config --cflags</code> -g -W -Wall -Weffc++ -Wextra -pedantic -O0 main.cpp -o run genera... | <p>You only installed SDL library. SDL_image and SDL_ttf are different libraries. You can download them via <code>sudo apt-get install libsdl-image1.2-dev libsdl-ttf2.0-dev</code>. There is also another popular SDL extension SDL_mixer: <code>libsdl-mixer1.2-dev</code></p>
|
Created activity in background and movable to foreground? <p>I've got an activity, which lags when opening first time. Because I want to avoid it, I'm trying to make situation like this:</p>
<ol>
<li>While whole app is opening, MyActivity (<strong>not</strong> main) is launching, but not showing;</li>
<li>After clicki... | <p>Okay, I think that problem is solved. I will use tutorial given to me by TGMCians in comments, it should make what I want. Here's the link:<br>
<a href="http://stackoverflow.com/questions/18343018/optimizing-drawer-and-activity-launching-speed">Optimizing drawer and activity launching speed</a><br>
Thanks for help! ... |
Mapping sums of defaultdict(list) to one list <p>I have a large collection of data formatted somewhat like the <code>d.items()</code> of a <code>defaultdict(list)</code>. See below:</p>
<pre><code>products = [(('blue'), ([2, 4, 2, 4, 2, 4, 2, 4, 2, 4], [2, 4, 2, 4, 2, 4, 2, 4, 2, 4], [2, 4, 2, 4, 2, 4, 2, 4, 2, 4])),
... | <p>From what I understand, you need to <em>zip</em> the sublists in the list and sum them up:</p>
<pre><code>>>> sums = [(key, [sum(value) for value in zip(*values)]) for key, values in products]
>>> for s in sums:
... print(s)
...
('blue', [6, 12, 6, 12, 6, 12, 6, 12, 6, 12])
('yellow', [3, 9, ... |
Using VectorAssembler in Spark <p>I got the following dataframe (it is assumed that it is already a dataframe):</p>
<pre><code>val df = sc.parallelize(Seq((1, 2, 10), (3, 4, 11), (5, 6, 12)))
.toDF("a", "b", "c")
</code></pre>
<p>and I want to combine the columns(not all) to one column and make it an rdd o... | <p>The correct solution (this assumes Spark 2.0+, in 1.x use <code>o.a.s.mllib.linalg.Vector</code>):</p>
<pre><code>import org.apache.spark.ml.linalg.Vector
output.map(_.getAs[Vector]("features").toArray)
</code></pre>
<ul>
<li><code>ml</code> / <code>mllib</code> <code>Vector</code> created by <code>VectorAssemble... |
Android Google Maps Marker Movement Issue <p>I am making an application where one person can watch all the other users of the app driving on the streets. I am using google maps and I am animating markers on the map, as the location of the users is changed in real time using socket.io.</p>
<p>The problem is that most o... | <p>I guess this can be done using google's direction API. You can request google direction api for the point you have to another point on the road. Google's response first point can be taken as on the nearest road point. I had look on the similar solutions people done on the web.
Have a look on <a href="http://stackove... |
How to upload multiple files in django rest framework <p>In django rest framework, I am able to upload single file using <a href="https://github.com/danialfarid/ng-file-upload" rel="nofollow">danialfarid/ng-file-upload</a> </p>
<p>views.py:</p>
<pre><code>class PhotoViewSet(viewsets.ModelViewSet):
serializer_clas... | <p>I manage to solve this issue and I hope it will help community</p>
<p>serializers.py:</p>
<pre><code>class FileListSerializer ( serializers.Serializer ) :
image = serializers.ListField(
child=serializers.FileField( max_length=100000,
allow_empty_f... |
I'm trying to create a dynamic menu on a HTML web page using JavaScript, but keep having trouble <p>Okay so here is my HTML code</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Menus</title>
<script type="text/javascript" src="Cities.js">
&... | <p>Like Andreas mentioned the problem lies with the quotes in optionsArray assigment in the first two its correct:</p>
<p><code>var optionArray = ["|", "dublin|Dublin"]</code></p>
<p>After that its like this:</p>
<p><code>var optionArray=["|", "liverpool"|"Liverpool"]</code></p>
<p>See the extra quotes</p>
<p><a h... |
How can I cause a legend to appear to the right of the pie (Chart.JS)? <p>I'm creating a fairly simple pie chart with Chart.JS like so:</p>
<pre><code>var data = {
labels: [
"Bananas (18%)",
"Lettuce, Romaine (14%)",
"Melons, Watermelon (10%)",
"Pineapple (10%)",
"Berries (1... | <p>You have to turn the default legend off in the options first with:</p>
<pre><code>legend: {
display: false
},
</code></pre>
<p>Also your <code>id</code> selector for your legend was wrong. <a href="http://www.bootply.com/KjsxnFMM5G" rel="nofollow">Fiddle</a>.</p>
<p>Wrap the chart in the <code><div>... |
how can I get the image from dynamically generated UITableViewCell and pass it with segue to the other View? <p>I have a <code>UITableViewController</code> with <code>UITableViewCell</code> dynamically generated there. Each cell contains an imageView that I'm filling with images fetched from my server. I'm using <code>... | <p>Why are you using <code>dequeueReusableCellWithIdentifier in your</code>didSelectRowAtIndexPath`?; instead you should get the cell directly using:</p>
<pre><code>let cell = yourTableView.cellForRowAtIndexPath(indexPath) as! TestDetailsCell
if let image = cell.testPhoto.image {
print(image)//this is what you wa... |
Tooltip working in localhost but not on a deployed site <p>I am using bootstrap tooltips in my site. When viewing it in localhost, the tooltip appears when hovered. However, when I view it on the deployed site, the tooltips do not work and I get the error "TypeError: f is not a function".</p>
<p>Here is my html:</p>
... | <p>The issue was being caused by the timing of the tooltip being created. I moved </p>
<pre><code>$("[data-toggle=tooltip]").tooltip({
template: '<div class="tooltip" id="CustomToolTips" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
}... |
Are configuration files in Node&Express supposed to be read asynchronously? <p>it is a naive question.
Say you have a config file storing all you need for making a connection to your db.
<strong>If you are reading asynchronously, is the connection done in the callback?</strong></p>
<pre><code>fs.readFile(pathToConfi... | <p>It's ok to so sync operations during app start up. However, do not do any sync stuff once the app has started, especially while handling requests.</p>
<p>Your app should be configured to start IF the database connectivity was successful.</p>
<pre><code>// set up your app
var express = require('express')
var app = ... |
SignalR force an application to be in a certain group <p>I have a SignalR application.</p>
<pre><code>////Server
public class ChatHub : Hub{
public override Task OnConnected()
{
string name = Context.QueryString["applicationName"].ToString();// Context.User.Identity.Name;
... | <p>If you wan't to secure your hubs please read <a href="http://www.asp.net/signalr/overview/security/hub-authorization" rel="nofollow">http://www.asp.net/signalr/overview/security/hub-authorization</a></p>
|
Boxplot error with a substitute command that works fine with hist() and plot() <p>I am asking your help to solve the following issue (and to help me understand the reasons the may have generated it).</p>
<p>I was trying to paste in a title of a boxplot some normal text, a symbol and the value of a variable.</p>
<p>I ... | <p>The difference between <code>plot</code>/<code>hist</code> and <code>boxplot</code> seems to be that <code>main</code> is passed directly inside <code>plot(..., main=)</code> but <code>boxplot</code> eventually goes through <code>bxp</code> which uses <code>do.call('title', list(main = ...)</code> to plot this text:... |
How to let python function pass more variables than what's accepted in the definition? <p>I have a very generic function call that looks like</p>
<pre><code>result = getattr(class_name, func_name)(result)
</code></pre>
<p>This function call updates <code>result</code>. This function call is very generic such that it ... | <p>The general solution for this is that when we want to provide a common function name such as this, that it is the responsibility of each class to implement its local definition of that function. This is why you see, for example, a method <strong>__init__</strong> in many different classes. The system standardizes ... |
Calling mpmath directly from C <p>I want to access mpmath's special functions from a C code.
I know how to do it via an intermediate python script.
For instance, in order to evaluate the hypergeometric function, the C program:</p>
<pre><code>#include <Python.h>
void main (int argc, char *argv[])
{
int npars=... | <blockquote>
<p>What? No! Literally do the things you did to access
GGauss_2F1.Gauss_2F1, just with the names changed. Why are you trying
to PyRun_SimpleString("from mpmath import *")? â user2357112</p>
</blockquote>
<p>Ok. Following your suggestions:</p>
<pre><code>#include <Python.h>
void main (int ... |
cors not working for my spring boot application <p>Here is my webConfig</p>
<pre><code>@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**");
}
}
</code></pre>
<p>I have a <co... | <p>I think you need to add cors origin filter , I am not sure but I think this below solution is works for you.</p>
<pre><code>import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.Servle... |
Divs are overlayed instead of stacked on top of another <p>I have two divs, <code>.instructions</code> and <code>.personal_info</code>, that I want stacked on top of another. <code>.personal_info</code> has top and bottom borders. The two divs seem to be overlaid on top of one another, which is not what I want. I want ... | <p>Better to use CSS display:flex
Code</p>
<pre><code><div style="display:flex;">
<div style="width:33%; background-color:wheat;">Left</div>
<div style="width:33%;">Center</div>
<div style="width:33%; background-color:snow">Right</div>
</div>
</code></pre>
|
Transition from darkened image to non-darkened on mouse over with CSS/Javascript? <p>I´m trying to get the inverse effect of this code (<a href="http://jsfiddle.net/35mghwu7/" rel="nofollow">jsfiddle-demo</a>):</p>
<pre><code>a.darken {
display: inline-block;
background: black;
padding: 0;
}
a.darken img... | <p>You just have to invert the opacity values :)<br>
(the "base" background must have opacity < 1, and the ":hovered" background must have opacity = 1)<br>
Here's a fork of you fiddle : <a href="http://jsfiddle.net/m1mcb66h/" rel="nofollow">http://jsfiddle.net/m1mcb66h/</a> </p>
<pre><code>a.darken img {
[...]
... |
std::regex, to match begin/end of string <p>In JS regular expressions symbols <code>^</code> and <code>$</code> designate <strong>start and end of the string</strong>. And only with <code>/m</code> modifier (multiline mode) they match <strong>start and end of line</strong> - position before and after CR/LF.</p>
<p>But... | <p>By default, ECMAscript mode already treats <code>^</code> as both beginning-of-input <em>and</em> beginning-of-line, and <code>$</code> as both end-of-input <em>and</em> end-of-line. There is no way to make them match <em>only</em> beginning or end-of-input, but it is possible to make them match <em>only</em> beginn... |
TFS server 2015: Email alerts not working <p>TFS email alerts is not working for some reason. Any possible reasons ? </p>
<p>I think tfs 2015(VSO) doesn't need SMTP server settings and should directly work. I created simple requests, none are working. what's possibly can go wrong ?</p>
<p><a href="http://i.stack.i... | <p>If you are using on-premise TFS server2015.</p>
<p>For feedback requests and alerts to work, you still need to <strong>configure an SMTP server</strong> for TFS.</p>
<blockquote>
<p>Details steps from MSDN: <a href="https://msdn.microsoft.com/library/ms400808.aspx" rel="nofollow">Configure an SMTP server to supp... |
What is the right way of passing array between scopes using two-way data binding in Angular? <p>Assuming that there is an angular custom directive which uses an isolated scope for <strong>array</strong> object with <strong>two-way</strong> binding:</p>
<pre><code>// scope values
this.scope = {
myArray: '='
};
</code... | <p>Reading the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice#Description" rel="nofollow">documentation</a> for <code>Array.slice</code>:</p>
<blockquote>
<p><code>slice</code> does not alter. It returns a shallow copy of elements from the original array. </p>
<... |
The matching wildcard is strict, but no declaration can be found for element 'neo4j:repositories' <p>i have a problem with big for me project written in java. My java knowledge is average so I need help. Log mentioned below lead to one xml file gorules-ontology-beans.xml . I found two such files in rulego\gorulespolsl\... | <p>Do you have the spring-data-neo4j jar on the classpath? The XSD referenced is included in the 2.x versions of that jar file:</p>
<ul>
<li><a href="https://github.com/spring-projects/spring-data-neo4j/tree/2.3.x/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/config" rel="nofollow">https://github... |
Ionic2 - How to push a new page in root component every time a user goes to root component? <p>I have a login page as root component with a function that checks if user is already authenticated therefore pushes a new view. The problem is that all the other views start to overlap like in the image below.
<a href="http:/... | <p>If I can suggest you something : you shouldn't push a view in your case, but directly changing the rootPage, this way your app will directly load the right view.</p>
<p>To do that it's pretty easy, go to your <code>app.js</code>.</p>
<pre><code>rootPage: any = null;
constructor(private platform: Platform) {
pla... |
Issue with Governance REST API of WSO2 Governance Registry <p>We are facing a serious issue with GREG's Governance REST API. Below are the exact issue scenario and other details for a quick resolution.</p>
<p>We wanted to add few custom fields in the "restservice" Artifact of RXT file hence we have added in the .rxt f... | <p>If you want to partially update the asset, relevant HTTP operation is <code>HTTP PATCH</code>. However, Governance REST API doesn't support <code>HTTP PATCH</code> operation yet. So first you have to get the asset data using <code>HTTP GET</code> and after that, you can update relevant attributes in given asset usin... |
Javascript - replacing a div with another random div (buttons not working in the new div) <p>My overall objective is to create a test based on images. But i am stuck at an early stage. The idea is that an image appears and the user has to click on a button to choose the correct answer. Which ever button they click, the... | <p>The way you wrote the codes, Only the buttons which are loaded by the document are known. the generated buttons wouldn't be known. you have to use <code>.on</code> or <code>.delegate</code></p>
<p>I write a sample here. You can change all of yours.</p>
<p>The way you can use <a href="http://api.jquery.com/on/" rel... |
Infinispan preload data from database table <p>How to preload data to infinispan local cache? I have a pre-existing application table that has key value pairs. I want infinispan to cache the data in the table and when i read/write data to cache, i want the underlying table to be in sync. Is it possible with infinispan?... | <p>Infinispan stores the entries in SQL DB in a marshalled form (as there is no generic mapping between POJOs and SQL), and also needs to keep some metadata along. That's why the JDBC stores can't access existing DB structure.</p>
<p>There's also the JPA store which uses Hibernate ORM to access the DB and "marshall" t... |
How to port ShaderToy to standalone OpenGL <p>I've been looking at <a href="https://www.shadertoy.com/" rel="nofollow">Shadertoy</a>.</p>
<p>I have questions regarding Shader code listed in examples. Are those fragment shaders? The syntax seem unfamiliar to me. I am confused about how examples are being rendered witho... | <p>The basic Shadertoy shader is just a fragment shader applied on a fullscreen quad. It has more advanced features (such as audio generation, VR-support and multi-pass rendering) but that is the basic idea.</p>
<p>So to convert into OpenGL program you would start with rendering a fullscreen rectangle with simple vert... |
Printing formatted floats in nested tuple of mixed type <p>I have a list of tuples where the entries in the tuples are mixed type (int, float, tuple) and want to print each element of the list on one line. </p>
<p>Example list:</p>
<pre><code> [('520',
(0.26699505214910974, 9.530913611077067e-22, 1431,
(0.2... | <p>This is not exactly what you need, but very close, and the code is pretty compact.</p>
<pre><code>def truncateFloat(data):
return tuple( ["{0:.4}".format(x) if isinstance(x,float) else (x if not isinstance(x,tuple) else truncateFloat(x)) for x in data])
pprint(truncateFloat(the_list))
</code></pre>
<p>For your... |
(Mac) How do I STOP Netbeans from automatically SELECTING a suggested keyword, BUT keep the POPUP open for me to select MANUALLY? <p>How can I stop Netbeans from automatically completing my code, but keeping the popup open so that I can select from its list?
Thanks for the read. :D</p>
| <p>I just changed the Completion Selectors.
That seems to do the trick.</p>
|
Get a list of methods that do not currently have a unit test method in VS 2013 or VS 2015 <p>I have inherited a rather large solution and I am using Visual Studio 2013.
There are hundreds of built test methods that have already been made. I also know that the coverage is not 100%. Is there a way to get a list of all ... | <p>You need a <strong>Code Coverage</strong> tool for this. <a href="https://www.ncover.com/" rel="nofollow">NCover</a> would be one example but there are many others which you can research by Googling something like "C# code coverage tools". <a href="https://github.com/sawilde/opencover" rel="nofollow">OpenCover</a> i... |
Sublime3 text can't ignore PEP8 formatting for Python <p>I installed Sublime for Python programming but I found that PEP8 error detection is pretty annoying and I couldn't get rid of it.</p>
<p>I tried this but it's not working:</p>
<p><a href="http://i.stack.imgur.com/119l5.png" rel="nofollow"><img src="http://i.sta... | <p>Try to add <code>"pep8": false,</code>. </p>
<p>If it does not work, add <code>"sublimelinter_disable":["python"],</code> to disable python's inspections completely. </p>
<p>And you would like to look <a href="https://github.com/SublimeLinter/SublimeLinter-pep8" rel="nofollow">https://github.com/SublimeLinter/Sub... |
pandas histogram: plot histogram for each column as subplot of a big figure <p>I am using the following code, trying to plot the histogram of every column of a my pandas data frame df_in as subplot of a big figure.</p>
<pre><code>%matplotlib notebook
from itertools import combinations
import matplotlib.pyplot as plt
... | <p>You need to specify which axis you are plotting to. This should work:</p>
<pre><code>fig, axes = plt.subplots(len(df_in.columns)//3, 3, figsize=(12, 48))
for col, axis in zip(df_in.columns, axes):
df_in.hist(column = col, bins = 100, ax=axis)
</code></pre>
|
Specifying Type Constraint Bound <p>Given:</p>
<pre><code>sealed trait F
sealed trait K extends F
case object K1 extends K
sealed trait L extends F
case object L1 extends L
</code></pre>
<p>Using the above hierarchy, how can I define a function that, at compile-time, has a List of type <code>A</code> that is either a... | <p>You can start with Miles Sabin's answer at <a href="http://stackoverflow.com/questions/6909053/enforce-type-difference/">Enforce type difference</a> and adapt:</p>
<pre><code>implicit def notSubtype[A, B]: >!>[A, B] = null
implicit def ambig1[A, B >: A]: >!>[B, A] = null
implicit def ambig2[A, B >... |
Store multiple inputs in multiple variables in bash <p>I need to make a loop about this script:</p>
<pre><code>#!/bin/bash
exec 3>&1;
result=$(dialog --inputbox "Scan S/N" 10 23 2>&1 1>&3);
result1=$(dialog --inputbox "Scan S/N" 10 23 2>&1 1>&3);
result2=$(dialog --inputbox "Scan S/N... | <p>Anytime you talk about a variable number of related variables, you want an array.</p>
<pre><code>n=3
for ((i=0; i<n; i++)); do
results+=( $(dialog --inputbox "Scan S/N" 10 23 2>&1))
done
# individual results can be accessed with ${results[i]} for i=0,1,...,n-1
for res in "${results[@]}"; do
echo "... |
MSACCESS DateTIme SQL QUERY <p>I am from India (it may has something to do with culture info here). I am building a desktop application in C#.Net 2010 Express with MS-ACCESS 2010 32 bit as backend. I am using OLEDB for db connectivity.
I have a column named dt as Date/Time which has following values:</p>
<p>20-09-2016... | <pre><code>b.com.CommandText = "SELECT * FROM srvtrans WHERE dt = @a ORDER BY sno DESC";
b.com.Parameters.Add(new System.Data.OleDb.OleDbParameter("@a", OleDbType.DBDate) {Value = dtp_srdmy.Value });
con.Open();
</code></pre>
<ul>
<li>You want to pass in the native types and not string representations of the types for... |
Copying & pasting range with Google Apps Script <p>I think I have some fundamental misunderstanding about how getRange or setValue works.</p>
<p>I want to copy the last row of data, columns 1-5, and paste them into another spreadsheet in the first row, columns 1-5.</p>
<p>When I run my script, it sets the value of th... | <p>Your code is just fine, correct <code>.getValue()</code> to <code>.getValues()</code> and <code>.setValue()</code> to <code>.setValues()</code> respectively and it should work:</p>
<pre><code>function myFunction() {
// Last Row
var ss = SpreadsheetApp.getActiveSheet();
var lastRow = ss.getLastRow();
// Assign last... |
Pandas DataFrame slicing based on logical conditions? <p>I have this dataframe called data:</p>
<pre><code> Subjects Professor StudentID
8 Chemistry Jane 999
1 Chemistry Jane 3455
0 Chemistry Joseph 1234
2 History Jane 3455
6 History S... | <pre><code>students_and_subjects = df.groupby(
['Professor', 'Subjects']
).StudentID.nunique().ge(2) \
.groupby(level='Professor').sum().ge(2)
df[df.Professor.map(students_and_subjects)]
</code></pre>
<p><a href="http://i.stack.imgur.... |
Is it possible to fusion adapt the base class? <p><strong>Is it possible to fusion-adapt the base class as if it where a member?</strong> </p>
<p>First this is the documentation example, side-by-side with the new case:</p>
<pre><code>#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/fus... | <p>Well, it looks (by experimentation) that one can put all sorts of valid expressions in <code>BOOST_FUSION_ADAPT_ADT</code>. I am not very sure if this is optimal (for example if fusion will make copies when accessing the elements), so other answers are welcomed.</p>
<pre><code>#include <boost/fusion/adapted/adt/... |
How can I show a subset of data on pie pieces in Chart.JS while still displaying the superset when hovering? <p>I've got a pie chart that looks like this when hovering over a piece of pie:</p>
<p><a href="http://i.stack.imgur.com/dF3ZI.png" rel="nofollow"><img src="http://i.stack.imgur.com/dF3ZI.png" alt="enter image ... | <p>The following solution is using the same calculation as <a href="http://stackoverflow.com/a/39652370/4864023">lamelemon's</a> but using <a href="http://www.chartjs.org/docs/#advanced-usage-creating-plugins" rel="nofollow">Chart.js plugins</a>, which brings <strong>additional benefits</strong> :</p>
<ul>
<li><p>Ther... |
Convert string type array to array <p>I have this:</p>
<pre><code>[s[8] = 5,
s[4] = 3,
s[19] = 2,
s[17] = 8,
s[16] = 8,
s[2] = 8,
s[9] = 7,
s[1] = 2,
s[3] = 9,
s[15] = 7,
s[11] = 0,
s[10] = 9,
s[12] = 3,
s[18] = 1,
s[0] = 4,
s[14] = 5,
s[7] = 4,
s[6] = 2,
s[5] = 7,
s[13] = 9]
</c... | <pre><code>import re
data = """[s[8] = 5,
s[4] = 3,
s[19] = 2,
s[17] = 8,
s[16] = 8,
s[2] = 8,
s[9] = 7,
s[1] = 2,
s[3] = 9,
s[15] = 7,
s[11] = 0,
s[10] = 9,
s[12] = 3,
s[18] = 1,
s[0] = 4,
s[14] = 5,
s[7] = 4,
s[6] = 2,
s[5] = 7,
s[13] = 9]"""
d = {int(m.group(1)): int(m.group(2... |
Android6.0 WebView shows blank page <p>I have tried to load a page with webView, and it just shows an empty page on my cellphone. Here are the codes and classes.<br><br>
AndroidManifest.xml</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/androi... | <p>Add <strong>internet permission</strong> in you manifest. Without it your application will not be able to access internet services.</p>
<pre><code><manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET" />
<application ...
</manifest>
</code></pre>
<p>Edite... |
Where to add addtional logic for a jQuery bookmarklet? <p><a href="https://mreidsma.github.io/bookmarklets/jquerify.html" rel="nofollow">https://mreidsma.github.io/bookmarklets/jquerify.html</a></p>
<p>Apologies in advance for this novice javascript question... The link above works very well to load jQuery. However I ... | <p>I determined that you couldn't guarantee if jQuery was loaded or not. So I decided to add the following after the showMsg(); function call.</p>
<pre><code>document.getElementById('mruSelect').style.display = 'none';
</code></pre>
|
Function inside .on() not firing on first click <p>This block works every click:</p>
<pre><code>$('body').on('click', '#searchButton', function(){
alert(studentInfo);
});
</code></pre>
<p>This one does not:</p>
<pre><code>$('body').on('click', '#searchButton', function(){
var studentInfo = myFunction();
buildHtmlTab... | <p>it is still firing, check the code that should execute in a separate function, run it on the console and you'll find the bug. </p>
|
Properly making requests to a 3rd party API with Laravel 5.3 <p>There are several questions on here that are <em>similar</em>, but not that are really providing exactly what I need.</p>
<p>I am creating a simple pet project in Laravel 5.3 that uses <a href="https://xboxapi.com/" rel="nofollow">https://xboxapi.com/</a>... | <p>Yes. Use Guzzle. The <code>PSR-7</code> spec has implemented 3 <code>RFC</code>'s that dictate how HTTP request objects should be handled.</p>
<p>Guzzle does have PSR-7 support, you can see the <a href="https://github.com/guzzle/psr7" rel="nofollow">git repository here</a>.</p>
<p>For API based CRUD requests, crea... |
Mysql: select value that matches several criteria on multiple rows <p>Good evening,</p>
<p>I have two tables t1 and t2</p>
<p>In t1, I have two variables, ID (which uniquely identify each row) and DOC (which can be common to several IDs)</p>
<p>In t2, I have three variables, ID (which does not necessarily uniquely i... | <p>If I could understand correctly the query is going to be something like that:</p>
<pre><code>select t1.doc, t1.id, t2.auth from t1
left join t2 on t2.id = t1.id
where t1.doc in( select t1.doc from t2
left join t1 on t1.id = t2.id
where t2.auth in('EP','US') );
</code></pre>
<p>Alt... |
Adding padding to drop down select active item <p>I'm trying to drop down items that are active, however it doesn't seem to be possible. They want me to move </p>
<p><a href="http://i.stack.imgur.com/AWMd8.png" rel="nofollow"><img src="http://i.stack.imgur.com/AWMd8.png" alt="enter image description here"></a>
to this... | <p>Use <code>padding</code>, like this</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>.input-select {
padding: 6px 24px 6px 12px;
font-size: 16px;
}</code></pre>
... |
Strong params on a hash or array <p>In rails I did this in <strong>a model</strong>:</p>
<pre><code> def update_user_ex(*attrs)
user.assign_attributes(*attrs)
# .............
</code></pre>
<p>where <code>attrs</code> is an <strong>array</strong> with of a hash(es), for simplicity let's say it's a single ha... | <p>It's possible to use strong parameters outside of controllers per the documentation at <a href="https://github.com/rails/strong_parameters" rel="nofollow">https://github.com/rails/strong_parameters</a></p>
<p>Example:</p>
<pre><code>def update_user_ex(*attrs)
params = ActionController::Parameters.new(attrs)
us... |
Convert byte[] to UInt16. <p>I have a 2d array of UInt16s which I've converted to raw bytes - I would like to take those bytes and convert them back into the original 2D array. I've managed to do this with a 2d array of doubles, but I can't figure out how to do it with UInt16.</p>
<p>Here's my code:</p>
<pre><code>UI... | <p>The program</p>
<pre><code> public static void Main(string[] args)
{
UInt16[,] dataArray = new ushort[,]{ {4,6,2}, {0,2,0}, {1,3,4}};
//This array is populated with this data:
long byteCountUInt16Array = dataArray.GetLength(0) * dataArray.GetLength(1) * sizeof(UInt16);
var ... |
Modules and variable scopes <p>I'm not an expert at python, so bear with me while I try to understand the nuances of variable scopes.</p>
<p>As a simple example that describes the problem I'm facing, say I have the following three files.</p>
<p>The first file is outside_code.py. Due to certain restrictions I cannot m... | <p><code>foo</code> has been imported into main.py; its scope is restricted to that file (and to the file where it was originally defined, of course). It does not exist within outside_code.py.</p>
<p>The real <code>eval</code> function accepts locals and globals dicts to allow you to add elements to the namespace of t... |
Copying row from one table to another? <p>I have these three tables for services, executed_services and a rating table, which rates the service. My rating table has a foreign key to executed_services, and so, I wanted to "copy" the service to be rated to the executed_services relation. I tried using the following proce... | <p>You can do it very easily in one step with a <a href="https://www.postgresql.org/docs/current/static/queries-with.html" rel="nofollow">CTE</a> with the following simple query:</p>
<pre><code>WITH deleted AS (DELETE FROM servico WHERE id = $1 RETURNING *)
INSERT INTO servico_executado (id, data_abertura, id_solicita... |
How can I make my code call each file in the correct sequence? <p>I have a folder with 38 files. The names are like this:
AWA_s1_features.mat, AWA_s2_features.mat......AWA_s38_features.mat
Each file is an array with 28 columns but with different # of rows. For example: AWA_s1_features.mat = (139,28), AWA_s2_features.m... | <p>The problem is that the default sorting is alphabetical, meaning that "11" comes before "2". You want numerical sorting and one way would be to use the sorted function with a key parameter, like so:</p>
<pre><code>import numpy as np
import scipy.io as sio
import glob
read_files = glob.glob('I:/2D/Features 2D/AWA_s... |
Prevent React Native from changing POST to GET request <p>For some reason when sending off requests from an actual android device using React Native as a POST the server only receives GET requests. Can someone explain why this is happening and how to prevent the protocol switching? I read somewhere that specifying the... | <p>Apparently for POST requests https is required rather than http...
I found the result from <a href="http://stackoverflow.com/questions/34570193/react-native-post-request-via-fetch-throws-network-request-failed">StackOverflow - 34570193</a></p>
<p>I don't recall experiencing any Networking Errors this is why I never... |
MySQL Non-monotonic query <p>Using the following database schema, find Bars which serve only beer(s) which Joe likes</p>
<pre><code>Beers(name, manf)
Bars(name, addr, license)
Drinkers(name, addr, phone)
Likes(drinker, beer)
Sells(bar, beer, price)
Frequents(drinker, bar)
</code></pre>
<p>Here is my attempt:</p>
<pr... | <p>could be these bars</p>
<pre><code>select bar
from Sells not in (
select bar
from Sells
where beer not in (select beer from likes where drinker = 'joe')
)
</code></pre>
|
JOOQ insert with type <p>I'm using jOOQ 3.8.4 and PostgreSQL 9.5 in a Spring 4 application. I have the following table and type definition</p>
<pre><code> CREATE DOMAIN shop.money_amount AS numeric(6,2) DEFAULT 0 NOT NULL CHECK (value > 0::numeric);
CREATE TYPE shop.money AS (
m_amount shop.money_amount,
m_... | <p>There seems to be a problem related to casting of nested array of types in jOOQ 3.8. I've created an issue for this: <a href="https://github.com/jOOQ/jOOQ/issues/5571" rel="nofollow">https://github.com/jOOQ/jOOQ/issues/5571</a></p>
<p>The problem is that your custom type array type needs to be fully qualified when ... |
Process parallel multiple read in spring Integration <p>I have one file which contains some record and i have second file which also contains same record but with more details , so i want to process in a way that read one record from first file and search in second.
How to read two files in parallel ?</p>
<p>Update :... | <p>All the parallel work in Spring Integration can be done via <code>ExecutorChannel</code>.</p>
<p>I'd suggest to use <code>FileSplitter</code> for the first file and an <code>ExecutorChannel</code> as an output. </p>
<p>As for the second file... Well, I'd read it once into the memory e.g. as a <code>Map</code> if y... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.