input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
iOS segue.destinationViewController doesn't send information <p>I'm working on a <strong>storyboard app</strong> with the Spotify API. I used this (<a href="https://github.com/avazquezpr/SpotifyDemo" rel="nofollow">https://github.com/avazquezpr/SpotifyDemo</a>) Github project as 'base'. But the thing is; this isn't a <... | <p>Got the solution, just changed </p>
<pre><code>destinationViewController.currentSession = loginSession
</code></pre>
<p>to</p>
<pre><code>destinationViewController.currentSession = currentSession
</code></pre>
<p>and deleted the var loginsession in the PlaylistController.</p>
|
Cassandra availability penalty in strong consistency mode <p>as I got Cassandra has ALL consistency level. It provides: "the highest consistency and the lowest availability".
If this level provides strong consistency?
What availability penalty for it? I don't see a case when data won't be availabile. Could anyone give... | <p>If you use a consistency level of ALL then the coordinator must receive a response from all nodes. This means that:</p>
<ul>
<li>After a successful write, nobody will read the previous state (high consistency).</li>
<li>If even a single node fails to respond, the whole read/write operation will fail (low availabili... |
Accessing marshmallow decorators when using flask-marshmallow <p>I'm using flask-restful, flask-sqlalchemy and flask-marshmallow to build an API service. I define the following -</p>
<pre><code>ma = Marshmallow(app)
</code></pre>
<p>However, trying to access the @validates decorator using ma throws an error.</p>
<pr... | <p>The problem is that you are trying to reach <code>flask-marshmallow</code> decorators in its API, however there is none.</p>
<p>So you to understand if you need <code>flask-marshmallow</code> package, or only <code>marshmallow</code> is required.</p>
<p>Also to make things work, you need to use <a href="http://mar... |
AngularJS - How do I save text from an input area? localStorage? <p>So I am adding a notes area for the user. The user will be able to input whatever they want and hit save. Save works for the entire page, except for the input area it resets. The only other thing I can think of is <code>ui-tinymce</code> or <code>local... | <p>There is an Angular module, ngStorage that makes it a little simpler to use local storage - basically you can bind your data to a localstorage element.</p>
<p><a href="https://github.com/gsklee/ngStorage" rel="nofollow">https://github.com/gsklee/ngStorage</a></p>
|
How to Manage Multiple Spring Boot in the same project <p>Learning Spring Boot as a replacement for some C/C++ daemons. My goal was to have a single project compiled to a single jar/war. Then use multiple shell scripts to simply start the one I want via command line. I'm using Eclipse Kepler to develop and test the ... | <p>You could annotate your Spring Boot Application with <code>@ComponentScan's excludeFilters</code></p>
<pre><code>@ComponentScan(basePackages = "your.package",
excludeFilters = @Filter(SpringBootApplication.class))
</code></pre>
<p>You may have many dependency issues from this point on, you can res... |
405 Error $http post json file to a folder using IIS <p><strong>My Code looks like</strong></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 myApp = angular.module('... | <p>It looks as if it may be running the default document module via the static file handler. That would be an automatic 405 if so.</p>
<p>Are you expecting this upload to run your server code to capture the upload and save it on the server? If so, you'll have to rearrange the modules and the static file handler and tr... |
mysql query - date subtraction <ul>
<li>I am trying to query users who has been active in the last 3 years. </li>
<li>I am adjusting a query I have used for years that I know works fine. The only part of the query that I am trying to add on is the part below that is outside the grey code. I can't get this part correct.... | <p>if you are trying to get entries that were active within the last 3 years, your comparison should be a greater than:</p>
<pre><code>lastactivity2 > UNIX_TIMESTAMP(DATE_SUB(now(), INTERVAL 3 YEAR))
</code></pre>
<p>Time moves forward, newer times are a bigger number than older times.</p>
<p>What you probably t... |
Code crashes because of an uninitialized variable even if I don't actually use it <p>Why does the following code crashes at run-time in Visual Studio 2012?</p>
<pre><code>void foo(void* ptr)
{
}
int main()
{
void* ptr;
foo(ptr);
}
</code></pre>
<blockquote>
<p>Run-Time Check Failure #3 - The variable 'ptr' is... | <p>Even just passing a pointer to a function you are "using" it and it's technically undefined behavior if the value is not initialized.</p>
<p>The reason is that there are hardware platforms where pointers are passed in special registers and setting them with an invalid value will generate an hardware trap <strong>wh... |
How to use LINQ to perform a simultaneous search of all child items <p>My XML File is structured as follows:</p>
<pre><code><File>
<Setting1></Setting1>
<Setting2></Setting2>
<Options>
<Option>
<NameStartsWith>Br</NameStartsWith>
<Data>123... | <p>Use LINQ to Xml</p>
<pre><code>string name = "Brian";
XDocument doc = XDocument.Load(yourXmlFile);
var matches = doc.Root
.Descendants("Option")
.Where(option => name.StartsWith(option.Element("NameStartsWith").Value))
.Select(option => option.Element("Data")... |
How do I continue using AdMob and support SDK 4+? <p>I received an email informing me that I must update to Google Mobile Ads SDK 7. However this requires min-sdk to go up to 9. I previously had 4. Is there a way I can upgrade and still people with older android versions be supported. As it is now, everyone who use... | <p>You don't. And you don't worry about it.</p>
<p>API versions 9 and below are less than 0.1% of the market.
Give you app away for free to that mall portion as good will and spend your time increasing the value of your app for the rest of the market.</p>
|
How to set up percolator to return when an aggregation value hits a certain threshold? <p>Take the following aggregation query as an example:</p>
<pre><code>{
"query": {
"match_all": {}
},
"aggs": {
"groupBy": {
"terms": {
"field": "CustomerName"
},
"aggs": {
"points_sum... | <p>You can use the <a href="https://www.elastic.co/guide/en/watcher/current/index.html" rel="nofollow">Watcher</a> commercial product for that and define the following watch:</p>
<pre><code>PUT _watcher/watch/transaction_alert
{
"trigger": {
"schedule": {
"interval": "1m"
}
},
"input": {
"searc... |
Webpack module not found: Error: Cannot resolve module 'imagesLoaded' <p>I am trying to include sequence.js in my index.js file and I get the following error:</p>
<blockquote>
<p>ERROR in ./src/js/sequence.js Module not found: Error: Cannot resolve
module 'imagesLoaded' in /home/jdellaria/Desktop/Musicpack/src/js ... | <p>Sequence.js uses AMD modules, and its looking to resolve those in the node_modules directory. Instead of referencing script directly in the /js folder, install it as a node module:</p>
<pre><code>npm install sequencejs
</code></pre>
<p>Then require it like this in your index.js</p>
<pre><code>require("sequencejs... |
Smarter way to gather data or a way to sort the data <p>I'm pulling data from an sqlite table using <code>snip1</code>, this of course grabs each row containing the relevant <code>id</code> value. The <code>services</code> list now looks like <code>output1</code>.</p>
<p>I'd like to be able to sort the list of lists o... | <pre><code>d = {}
for item in data:
d[item[0][0]] = []
for i in item:
d[i[0]] = d[i[0]] + [int(i[1])]
</code></pre>
|
Unable to Archive Xcode Project: No such file or directory <p>So I am trying to Archive my Xcode project to upload to the app store however I am getting the following error; </p>
<blockquote>
<p>PBXp Error </p>
<p>error:
/Users/User/Library/Developer/Xcode/DerivedData/APPNAME-aurgdfrsdgrsdgwzxglhhaw/Build/Int... | <p>The problem is probably that the <code>Ensembles.bundle</code> is not being built in your Release build for archiving. </p>
<p>Add <em>Ensembles Resources iOS</em> as a dependency of your own app. That will ensure it builds before your app, including the Release build. You set that in the Build Phases tab of your a... |
Why am I failing to display a texture in OpenGL? <p>I'm trying to load a texture in OpenGL, but all I get is black. I've verified that the shaders are returning GL_TRUE when they compile. So, I don't think that is the issue...</p>
<p>Some things to note:</p>
<p>I have taken and modified code from <a href="https://ope... | <p>As you had already found, the <em>internalFormat</em> and <em>format</em> of your <code>glTexImage2D()</code> call are incompatible:</p>
<pre><code>glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, image);
</code></pre>
<p><code>GL_RED_INTEGER</code> is for integer texture ... |
Django app has a no ImportError: No module named 'django.core.context_processors' <p>Tried git pushing my app after tweaking it and got the following error.</p>
<pre><code>ImportError: No module named 'django.core.context_processors'
</code></pre>
<p>this was not showing up in my heroku logs and my app works locally ... | <p>Try removing <code>"django.core.context_processors.request"</code> from your settings.</p>
<p>In Django 1.10 <code>django.core.context_processors</code> has been moved to <code>django.template.context_processors</code>. See <a href="https://docs.djangoproject.com/en/1.10/releases/1.8/#django-core-context-processors... |
Postman with miltiple params on Web Api C# <p>I'm having a problem with this technology, </p>
<p>I already have created a entry in my web api controller that allows me to create users: </p>
<pre><code>public IHttpActionResult PostUser(User user)
</code></pre>
<p>and I can consume this rest service with postman like ... | <p>You should add attributes to your method, as such:</p>
<pre><code>public IHttpActionResult PutUser(int id, [FromBody] User user)
</code></pre>
<p>This indicates the <code>user</code> parameter is received from the request body. Next, you can use the following URL:</p>
<pre><code>http://localhost:15423/api/users?i... |
Gantt Chart python machine scheduling <p>I'm having some bad time trying to plot a gantt chart from a data set with python. I have a set of machines that work on different tasks during a time period. I want to make a gantt chart that shows by the y axis the machines and x axis the time spent on each task.
Each machine ... | <p>Seimetz,</p>
<p>If you are fine passing the entire data to the client and let a JS Gantt do it's thing, then the RadiantQ jQuery Gantt Package will be a better option for you. Here is an online demo of something similar:
<a href="http://demos.radiantq.com/jQueryGanttDemo/Samples/ServerStatusWithHugeData.htm" rel="n... |
How to iterate over a line in a file? <p>I have a file that contains integers organized into rows and separated by whitespace. Both the number and length of the rows are unknown.</p>
<p>I'm currently iterating over the file line-by-line, and I'm trying to iterate over each line character-by-character but I'm having so... | <p>You're almost there; you can use formatted stream extraction to read integers, using a string stream to represent each line:</p>
<pre><code>#include <fstream>
#include <sstream>
#include <string>
// ...
for (std::string line; std::getline(infile, line); )
{
std::istringstream iss(line);
... |
Ruby class variable example <p>I am trying to translate the below Python code to Ruby. I would like to access "a" and change it in the future.</p>
<pre><code> class c:
def __init__(self, a):
self.a = a
o = new c(2)
print(o.a)
</code></pre>
<p>I read about instance variables of Ruby, but the tut... | <p>Try to use the ruby convention of capitalizing the class names. It makes the code more readable.</p>
<p>The instance variables are only accessible in the body of the class, if you want to access them you have to write a method that returns their value</p>
<pre><code>class MyClass
def initialize(a)
@a =... |
Javaservlet RandomAccessFile errors <p>I'm receiving the error "HTTP Status 404-/servlet/FormPost
type Status report
message /servlet/FormPost
description The requested resource is not available
Apache Tomcat/7.0.72"</p>
<p>Can anyone see what is wrong with my code? I'm using Eclipse and Tomcat v7.0.
I'm trying to ge... | <p>The problem does not related to your implementation of methods.<br>
HTTP 404 tells you that tomcat http-server can not find any handler for your request.
In a simple case, your request should looks like <code>"localhost:8080/<your_war_file_/_app_name>/<string_matching_your_web_servlet_pattern>"</c... |
How do I go about putting a chunk of code into a Variable? <p>I've been trying to get chunks of code into variables so I could easily just place the variable and shorten the code by a lot. </p>
<p>Here's the code that I want to turn into a variable-</p>
<pre><code>set recipientName to "Joe"
set recipientAddress to "j... | <p>You probably want to wrap your Mail code in a reusable handler, like this:</p>
<pre><code>to sendEmail(recipientName, recipientAddress, theSubject, theContent)
tell application "Mail"
##Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:t... |
Getting a dataframe of logical values from a vector of statements <p>I have a number of lists of conditions and I would like to evaluate their combinations, and then I'd like to get binary values for these logical values (True = 1, False = 0). The conditions themselves may change or grow as my project progresses, and s... | <p>Looks like the dreaded <code>eval(parse())</code> does it (hard to think of a much easier way ...). Then use <code>storage.mode()<-</code> to convert from logical to integer ...</p>
<pre><code>res <- sapply(condition_combinations,function(x) eval(parse(text=x)))
storage.mode(res) <- "integer"
</code></pre... |
Angular 2 Http Request to Promise returns zone obj instead of actual data <p>I'm trying to have quick test of ng 2 http to return real data. I know there is a better/longer way to do it. This is meant to be quick and simple, not best practices. </p>
<p>I know the server returns data because I can see it in another ter... | <blockquote>
<p>In app.data.service.ts</p>
</blockquote>
<pre><code>public getItems(){
return this.http.get("http://......")
.toPromise()
.then(res => res.json())
.catch(this.handleError);
}
</code></pre>
<blockquote>
<p>In your component.ts call this method/subscribe to it</p>
</blockq... |
Why parameter screen_name of Twitter's API doesn't work? (NodeJS) <p>I want to pull down the first tweet from a given username. From twitter's APIï¼I guess I should use statuses/user_timeline and make screen_name a variable. But When I do this, I can only get my own tweet whatever screen_name is. Here is the code:</p>... | <p>"Kobe Bryant" is a user name. The screen name is <code>kobebryant</code>.</p>
|
ExpectedConditions is undefined in protractor <p>I am a newbie in protractor and using protractor <code>Version 4.0.2</code></p>
<p>But when I have below code I get error against <code>protractor</code> keyword</p>
<pre><code> import { browser } from 'protractor/globals';
let EC = protractor.ExpectedConditions... | <p>For version 4.0.2 - 4.0.8, ExpectedConditions has been exported via:</p>
<pre><code>import { ExpectedConditions } from 'protractor/globals';
</code></pre>
<p>It could also be accessed from the global protractor object:</p>
<pre><code>import { protractor } from 'protractor/globals';
let EC = protractor.EC;
</code... |
Postgresql in generating crosstab results <p>I have a table like below:</p>
<pre><code>| Email | Category | Amount | Post_date |
| 123@234 | ATM | 20 | 2016-09-20 |
| 234@345 | POS | 30 | 2016-09-21 |
| 345@567 | FOOD | 40 | 2016-09-22 |
| 567@789 | ENTE | ... | <p>I strongly suspect that you want a query like this:</p>
<pre><code>select email, category,
sum(case when post_date >= current_date - interval '1 day' then 1 else 0 end) as last_1,
sum(case when post_date >= current_date - interval '3 day' then 1 else 0 end) as last_3,
sum(case when post_d... |
How to use Javascript variables in PHP and PHP variable in Javascript? <h1>Self Answer</h1>
<p>I have a script that is supposed to use AJAX to retrieve a video from Youtube, but, it requires AJAX to grab a PHP file. This PHP file needs Javascript variable to work, however, I could not seem to find a way to do this on ... | <p>How to use PHP variable inside JavaScript code:</p>
<pre><code><script type="text/javascript>
var stack = <?php echo $overflow; ?>;
</script>
</code></pre>
<p>I mean it is pretty simple. This code must be near PHP code that have $overflow variable itself.</p>
<p>If you want JavaScript variab... |
Firebase Messaging - Create Heads-Up display when app in background <p>With FCM I receive push notifications in the system tray when the app is in the background or not running. When the app is in the foreground I can override onMessageReceived and create my own heads-up notification with <code>NotificationCompat</code... | <p>You will get heads up notification only if you are using some other app while your app is in background or not running. If your phone is not being used then you will receive system tray notification or lock screen notification. </p>
<p><strong>If you are using app server to send push notification via http protocol ... |
I have a gridview in my main activity but the app crashes when i tap an image of the grid after device orientation is changed <p>The app crashes only if the device orientation is changed.
Here is the main activity:</p>
<pre><code>public class MainActivity extends AppCompatActivity implements Listener {
boolean mT... | <p>When you rotate the device the savedInstanceState is NOT null. In your activity you ONLY set listener if the savedInstanceState is null. Therefore in the case of device rotation the mListener object in your fragment is NULL. Therefore invoking anything on it will produce NPI.</p>
<p>You need to find fragment by tag... |
Python and Tkinter root naming <p>I often see a GUI using root.mainloop() at the end.
Near the top sometimes they put:
root=tk.TK()
and sometimes they just put:
root=Tk()</p>
<h2>Do these two statements do something different? (examples below)</h2>
<pre><code>from Tkinter import *
class App:
def __init__(se... | <p>The difference is in the import statements. After <code>from Tkinter import *</code>, all of the names from Tkinter are directly incorporated into your namespace; in fact, you can't refer to <code>Tkinter</code> itself because that name wasn't imported. In contrast <code>import Tkinter as tk</code> ONLY imports <c... |
ruby match string or space/tab at the beginning of a line and insert uniq lines to a file <p>This is my code:</p>
<pre><code> File.open(file_name) do |file|
file.each_line do |line|;
if line =~ (/SAPK/) || (line =~ /^\t/ and tabs == true) || (line =~ /^ / and spaces == true)
file = File.open("... | <p>There's a lot of confusion in this code and it isn't helped by your habit of jamming things on a single line for no reason. Do try and keep your code clean, as the functionality should be obvious. There's also a lot of quirky anti-patterns like stringifying strings and testing booleans vs booleans which you should r... |
Push an item to the bottom of its parent, without overlap? <p>I have an element extending at least across the full viewport vertically (min-height of 100vh). This element has two childs, a menu item (basically a formatted list of links) and another element.</p>
<p>I'd like to push the latter element to the bottom of t... | <p>This is easy if you are using a <code>flexbox</code> on the parent container:</p>
<ol>
<li><p>Remove the absolute positioning for the <code>red</code> section.</p></li>
<li><p>Add <code>display: flex</code> to the <code>pushBottom</code> and use <code>flex-direction: column</code> to flex vertically.</p></li>
<li><... |
How to find control created by codebehind using name in WPF <p>I am currently attempting to create a MIPS emulator using WPF.</p>
<p>In a stack panel control called <strong>registerList</strong>; I created 32 stack panels (named C0 to C31) that each contain 2 textblocks (second textblock named R0 to R31).</p>
<p>I in... | <p>You have to use <a href="https://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.registername(v=vs.110).aspx" rel="nofollow">RegisterName()</a> , so that newly added <code>Control</code> can be part of the <code>NameScope</code> of parent control.</p>
<p>Add these lines at the end in your <code>dis... |
Making a pong game, encountering odd glitches <p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<meta charset="UT... | <p>You are reading the player width and player height in as <strong>text</strong>. You need to convert to integers. Do the same for player2.</p>
<pre><code>var player1 = {
x: null,
y: null,
score: null,
width: parseInt(playerWidth),
height: parseInt(playerHeight),
</code></pre>
|
IONIC2 Background image is resized when keyboard is open <p>Using ionic-2 when a background image is set and it's size (background-size) is set to 'cover' or '100% 100%' such as:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class... | <p>After a lot of time searching with no solution I decided to develop one using angular-2's ngStyle, and the solution is quite trivial actually:</p>
<p>In the page class, create shouldHeight member:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snip... |
Getting value of a nested object in JSON <p>I want to get the <strong>req1</strong> value in the JSON below, programatically.Here <strong>RequestTypeItem</strong> can be changed as well, so it is not fixed. Else I could have navigated it using <strong>object.subobject</strong></p>
<p>I was able to navigate till <stron... | <p>In your JSON your request does not have a property of <em>intent</em>, it does have a property <em>type</em>, so you then you can access the property you want with</p>
<pre><code>b.request.type.slots.RequestTypeItem.value
</code></pre>
<p>JSFiddle: <a href="https://jsfiddle.net/9cexbn54/" rel="nofollow">https://js... |
Difficulty installed Pod in Podfile <p>I'm trying to install the OpenTok pod to my pod file. I have a very big project with many pods installed from the previous developers.</p>
<p>The pod file looks something like this:</p>
<pre><code>source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
def common_p... | <p>Try to add use_frameworks!</p>
<p>So, result pod file (name of the my test project - <em>stackoverflow-39682480</em>):</p>
<pre><code>source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
def common_pods
pod 'TPKeyboardAvoiding'
pod 'Fabric'
pod 'Crashlytics'
pod 'FBSDKCoreKit', '~&... |
How to manually POST to an HTML form <p>How do I manually post to this HTML form:</p>
<pre><code><form method="POST" action="/dashboard/research_report">
<input type="hidden" name="verb" value="DELETE" />
<input type="hidden" name="file_id" value="11028" />
... | <p>I don't understand clearly, but if you want to submit without any javascript you should use the input element with type submit and value attribute with the text like the following example:</p>
<p><code><input type="submit" value="Submit"></code></p>
<p>Looking at your code you should replace the span element... |
Bluemix: how do I create a service? <p>I have a problem when creating a Bluemix service - when I select Create Service for either the language translator or any other service, the page stays loaded and never creates the service. What may be the problem? Appreciate any help you can give me.
<img src="http://i.stack.img... | <p>Looking at the URL in your screen cap, you are using the old Bluemix console, which is no longer supported. Log into <a href="https://new-console.ng.bluemix.net/" rel="nofollow">the new console</a> using your existing User ID and password, and try creating your service again.</p>
|
How can I instantiate multiple objects into a list? <p>I need to instantiate a list with multiple String objects. I am not allowed to manually add objects 1 by 1.</p>
<p>I tried multiple ways, cannot get method to accept it.</p>
<pre><code>scrambleOrRemove(["TAN", "ABRACADABRA", "WHOA", "APPLE", "EGGS"]);
</code></pr... | <p>Call it like this:</p>
<pre><code>scrambleOrRemove(
new ArrayList<String>(
Arrays.asList(
"TAN", "ABRACADABRA", "WHOA", "APPLE", "EGGS"
)
)
);
</code></pre>
<p>Now that you have your solution, read the manuals and explain why this works and why it was necessary for your case.</p>
|
Paypal Single Payout - 'Json request malformed' <p>I am trying to proceed single payout with Paypal Sandbox. The error I am getting is: </p>
<blockquote>
<p>'MALFORMED_REQUEST_ERROR' - 'Json request malformed.'</p>
</blockquote>
<p>After receiving the token successfully, I setup the single payment details array and... | <p>It took some time for me to notice it. The answer:</p>
<pre><code>$data = [
'sender_batch_header' => [
'email_subject' => "You have a payment",
'sender_batch_id' => $randId
],
'items' => [
[
'recipient_type' => "EMAIL",
'amount' => [
... |
New to Swift programing. Struggling with integer rounding <p>I need to figure out a way to round an integer up to its nearest thousand and down to it's nearest thousand. I've tries searching for solutions on here but they haven't seemed to work out for me.</p>
<p>The range of whole numbers will lye between 10000 and ... | <pre><code>func roundDownToNearestThousand(n: Int) -> Int {
return (n/1000) * 1000
}
func roundUpToNearestThousand(n: Int) -> Int {
if n % 1000 == 0 {
return n
} else {
return (n/1000) * 1000 + 1000
}
}
</code></pre>
<p>Of course, you can always modify and put these into an exten... |
node.js. Problems saving requested zip file to disk <p>I'm having trouble saving a remote zip file to disk with with node.
I'm using <code>request</code> library to make requests. I want to request a zip file,
if the request is succesful write it to disk. I can't get a good combination of
correct error handling and ... | <p>Instead of using <code>body.pipe()</code>, use <code>response.pipe()</code>.</p>
<pre><code>request.get('https://example.com/example.zip', {
auth: {
bearer: accessToken
}
}, (err, res, body) => {
if (res.statusCode !== 200) { // really should check 2xx instead
return handleError();
}
res.pipe(f... |
Laravel 5.2 - Login with only Email <p>I am trying to create a <a href="https://en.wikipedia.org/wiki/Social_login" rel="nofollow">Social Login</a> with <a href="https://laravel.com/docs/5.2" rel="nofollow">Laravel 5.2</a>.</p>
<p>I am getting <strong>user-email</strong>, so I need to log-in with <strong>only that ema... | <p>I believe what you should be using is:</p>
<p><code>Auth::login($user);</code> </p>
<p>instead of: </p>
<p><code>Auth::attempt(['email' => $user->email]);</code></p>
<p>In order to manually authenticate a user.</p>
|
How do I fill in the color for this triangle that I made from three lines? <p>So, my teacher wanted us to make a house for a project this weekend, and I can figure out how to fill in the color for my triangle that I am using for a roof. I am very new at java, so my code is rather ruff, but if anyone could help me, that... | <p>Ok, maybe is time to learn something new?</p>
<pre><code>/* Have a look over java.awt.geom.GeneralPath*/
// Draw the roof
GeneralPath shape=new GeneralPath();
shape.moveTo(300, 400)
shape.lineTo(800, 400);
shape.lineTo(550, 200);
shape.closePath(); // easier than shape.lineTo(300, 400);
g2.setColor(Color.RED);
g2.f... |
Using a custom function (ifelse) with dcast <p>I'm interested in reshaping a dataframe, but instead of using standard dcast functions like the mean, I'd like to use a custom function. Specifically, I'm interested in using an ifelse statement to assign binary values.</p>
<p>Here's a reproducible example:</p>
<pre><cod... | <p>I believe this has to do with the details of type coercion. The return of your custom function is being treated as double for some sets of observations, but logical in others. The code works when you make explicit the return type. </p>
<p>Example:</p>
<pre><code># Works
funx1 <- function(u){ifelse(mean(u)>... |
strings to arrays then print in c <p>I am trying to take a user inputted string and look at each code to see if it appears in another string of strings. So far my code works.
If the word is successfully found then the alpha representation is to be added to an array that will eventually be printed, but only if all codes... | <p>The problem you asked about is caused by the way <code>prntArr</code> is used in the program. It really should be an array of character pointers into the <code>alpha</code> array. Instead, it's manipulated as an array of characters into which the first character of each morse code element is stored. And when it's... |
Dropwizard logback async log rotation causing application threads to wait <p>The application threads get stuck whenever the log file rotates, this causes spike in latency of the API
I'm using an Async Appender, not sure why during rotation the application threads are waiting.</p>
<p>logback.xml</p>
<pre><code><co... | <p>In our logback.xml we have specified, </p>
<pre><code><property name="async.discardingThreshold" value="0"/>
</code></pre>
<p>Now a quick look at the source code suggests what possibly might be happening that is causing the delay at the time of rotation</p>
<pre><code> @Override
protected void append(E ev... |
How to pagination of JSON data???Thanks <p>How to pagination JSON data??? Thanks
I am sorry that I am a beginner, I want to show 3 records in one page, and click next button to see another 3 record.
I try to use jquery plugin easyPaginate to test this, but it is not work....... </p>
<h3>My HTML</h3>
<pre><code><sc... | <p>Okay, here you can achieve pagination without using any plugins. </p>
<pre><code>var data = json_result; //result from ajax request.
var offset = 0; //pagination start from 0.
max_length = data.length; //length your JSON data list.
function paginateNext(){
for(i=offset, i<offset+3;i++){
//check o... |
Getting the current user account's display name in UNIX-type operating systems <p>In Windows, the user account has both an account name and a "real name" associated with the account. This can be retrieved by <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms724435(v=vs.85).aspx" rel="nofollow"><code>G... | <p>I'd probably call <code>getuid</code>, then <code>getpwuid</code> or <code>getpwuid_r</code>, on Unix-like systems.</p>
<p>Something like:</p>
<pre><code>#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
int
main(void)
{
struct passwd *pw;
pw = getpwuid(getuid());
if (pw == 0... |
Cannot find python 3.5.x interpreter using .msi extension <p>I'm new to stack overflow. I was wondering if anybody knew if there was a .msi package for a python interpreter for python 3.5, I'm teaching a basic python class and wanted to be prepared for when it starts in a few weeks. There is a .msi packaged interpreter... | <p>After <a href="https://www.python.org/downloads/release/python-344/" rel="nofollow">Python 3.4.4</a> was released python.org stopped providing MSI installers for their Windows releases. Web-based, exectuable, and zipped installers are now provided for both 32-bit and 64-bit Windows releases. I'm not sure what the re... |
How to setup In-app purchase: 'metadata missing' <p>I am trying to setup in-app purchase</p>
<p>but I don't know how to get rid of <strong>missing metadata</strong> shown below. Only yellow dot i see from the page is the <strong>Localizations</strong> section, but I completed my <strong>Display Name</strong> and <stro... | <p>I had the same issue with a renewable subscription. Near the top of iTunes page, just below your image that says "Missing Metadata," I saw this:</p>
<p><a href="https://i.stack.imgur.com/x5xbQ.png" rel="nofollow"><img src="https://i.stack.imgur.com/x5xbQ.png" alt="Before you can submit.... Add localizations"></a><... |
Percentile calculation with a window function <p>I know you can get the average, total, min, and max over a subset of the data using a window function. But is it possible to get, say, the median, or the 25th percentile instead of the average with the window function?</p>
<p>Put another way, how do I rewrite this to ge... | <p>You can write this as an aggregation function using <code>percentile_cont()</code> or <code>percentile_disc()</code>:</p>
<pre><code>select district, percentile_cont(0.25) within group (order by sales)
from t
group by district;
</code></pre>
<p>Unfortunately, Postgres doesn't currently support these as a window fu... |
SASS (.sass) Why is does this variable mess everything up? <p>I am new to sass and I cannot, for the life of me, figure out why this particular instance of a variable is messing up my .css output. I am using Atom.io as my text editor and the plugin sass-autocompile as my sass compiler.</p>
<p><strong>Here's my code</s... | <p>Solution: There were spaces where there should have been tabs. Once I removed the spaces and replaced with them with tabs, everything compiled correctly.</p>
|
Specific Big O Questions <p>We're getting into Big O in my CS degree and am having a difficult time understanding it. There's two problems I'd like to post, one I tried to complete on my own and another I'm not sure how to start. Would it be possible for a member to tell me if my first one is correct or incorrect and... | <p>a)
For n = 2,
9*8 + 5*4 = 92 > 10 * 8 = 80. (n > 1 is incorrect)
You should solve for an n explicitly.</p>
<p>b)
Should be order of O(n^3/2). Check with a large number such as 2^50. log(n) grows much more slowly than n^1/2. </p>
|
Different induction principles for Prop and Type <p>I noticed that Coq synthesizes different induction principles on equality for Prop and Type. Does anybody have an explanation for that? </p>
<p>Equality is defined as</p>
<pre><code>Inductive eq (A : Type) (x : A) : A -> Prop := eq_refl : x = x
</code></pre>
... | <p><em>Note</em>: I'm going to use <code>_rect</code> principles everywhere instead of <code>_ind</code>, since <code>_ind</code> principles are usually implemented via the <code>_rect</code> ones.</p>
<h1>Type of <code>eqT_rect</code></h1>
<p>Let's take a look at the predicate <code>P</code>.
When dealing with induc... |
Is This Possible in a Browser? [JavaScript / HTML] <p>I have Javascript code that opens ISBNs of books on Amazon using hyperlinks (feel free to try, for example: 0133098648). I would like the URL to open up on a new window with all links clicked in a new tab on that same window. It appears one can only open in a new ta... | <p>No, this isn't possible. Web pages cannot dictate whether or not content opens up in tabs or new windows. It's up to the user/browser to decide.</p>
<p>At best, you can open a new window with <code>window.open()</code>, but that doesn't give you control over tabs in a specific window later.</p>
|
How to check if ajax cal was made and when it was completed <p>I have a following code to hide the page loader image when the page is completely loaded (including any pending ajax call). </p>
<pre><code>$('document').ajaxStop(function() {
// place code to be executed on completion of last outstanding ajax call he... | <p>If you hide the loader by default, and then use <code>ajaxStart</code> to show it, and hide again on <code>ajaxStop</code>, it should do what you want <em>(I think)</em></p>
<pre><code>.se-pre-con { display : none; }
</code></pre>
<p>and</p>
<pre><code>$(document).ajaxStart(function() {
$(".se-pre-con").show(... |
Xcode can't find audio file (swift 3)? <p>I'm trying to have a button play a sound when I push a button. I made the same app on my friend's computer and it worked fine, but now when I do it, it gives me an error saying "Unable to find sound file with name 'XD.mp3'" (XD is the name of the file I imported into Xcode) I'v... | <p>Make sure that you are copying your file inside <code>build phases/copy bundle resource</code> in your Xcodeproj file (the blue one).</p>
<p><a href="http://i.stack.imgur.com/NMYmC.png" rel="nofollow"><img src="http://i.stack.imgur.com/NMYmC.png" alt="enter image description here"></a></p>
<p><a href="http://i.sta... |
Is it okay to use .Query<table_name> when updating SQLite using Xamarin? <p>I have taken over some code and I see that database updates are performed like this:</p>
<pre><code>dbcon = DependencyService.Get<ISQLite>().GetConnection();
public void UpdateAnswered(string id)
{
lock(locker)
{
dbcon.Query... | <h2><code>Update<T></code></h2>
<p>This method allows you to pass in an instance of an object that this stored in the database which has a primary key. SQLite then recognizes the primary key and updates the rest of the object's values.</p>
<p>You would just call <code>connection.Update( phrase );</code> where t... |
Generating an HTML File [PHP] <p>So basically I have this "gallery" page of mine which works by having a mysql database that stores the references and file names of the images i'm uploading. I also have "albums" where similarly categorized pictures are in there. My question is, I would like php to generate me an html f... | <p>What you really want is a templating engine, such as <a href="http://www.smarty.net/" rel="nofollow">Smarty</a>.</p>
<p>Next, you can write static HTML files to disk if you want... but consider outputting them dynamically. Use rewrite rules to point your galleries at a single PHP scripts that generates these. It ... |
How to include "jquery_ujs" with disabled pipeline to be able to use "remote: true" for forms? <p>I'm not using assets pipeline. I included a normal jquery file by referring it as "jquery":</p>
<pre><code><script src="jquery.js"></script>
</code></pre>
<p>How can I do the same thing for "jquery_ujs", wh... | <p>If you don't include asset pipeline to your project, then adding jquery_ujs is required.When using asset pipeline, rails provides half of the javascript required through its helpers. </p>
<p>Now in your case we will have to add the following, either in your application.html or on top of the .html.erb file where you... |
How to call virtual function using pointer in C++ <p><a href="http://i.stack.imgur.com/DYsLo.png" rel="nofollow"><img src="http://i.stack.imgur.com/DYsLo.png" alt="enter image description here"></a></p>
<p>Above image shows a program that gives runtime error. Target is: how to call virtual function member using a poin... | <p>Create an instance for a and use it like</p>
<pre><code>A* a= new A;
</code></pre>
|
Is there a way I can avoid having to use hardcoded values in my code? <p>I have this code:</p>
<pre><code>public partial class SettingsPage : ContentPage
{
public SettingsPage()
{
englishSide.GestureRecognizers.Add(new TapGestureRecognizer
{
App.Database.UpdateCardFrontSide(true, "En... | <p>It sounds like you want something like this:</p>
<pre><code>enum Lang
{
English = 1,
Romaji = 2,
Kana = 3,
Kanji = 4,
}
</code></pre>
<p>Ideally, you will also change your <code>UpdateCardFrontSide()</code> method, and anywhere else these "magic values" are used, so that you use the <code>Lang</cod... |
How does SQL Server process the following query? <p>I was making some queries to the database called: Northwind that is available to make proves, if you download it from the official site, I performed the following query:</p>
<pre><code>SELECT C.CategoryName NAME,
P.CATEGORYID CODE,
COUNT(*) 'PIECES',
SUM... | <p>You will have to look at logical order processing of a query by Itzik Ben-Gan ,he <a href="http://tsql.solidq.com/books/tk70461/" rel="nofollow">dedicated a whole chapter</a> and explained in detail each step..The <a href="http://sqlmag.com/sql-server/logical-query-processing-what-it-and-what-it-means-you" rel="nofo... |
How can i know total number of index available in a Windows index.wim file using DISM on the command line <p>I want to know the total number of index available in a install.wim file located in windows source using dism and store that number in a numeric variable in same dos batch script. So far I have tried below comma... | <p>Ok. I got my answer and this is what i will do to get my desired result.</p>
<pre><code> @echo off
if exist %TEMP%\scm (RD %TEMP%\scm /S /Q)
md %TEMP%\scm
for /L %%A IN (1, 1, 25) Do (
dism /Get-WimInfo /WimFile:h:\research\Win7\InstallWin7_aio\sources\install.wim /index:%%A > %TEMP%\scm\%%A.txt
timeout ... |
Replacing first character after full stop in text file using Lex <p>I'm trying to implement Flex program which can detect below scenario:</p>
<p>Input.txt :</p>
<blockquote>
<p>Hi my name is kamalakar. so I'm happy.</p>
</blockquote>
<p>While reading above Input.txt file my program should detect there is simple gr... | <p>Eventually I find the answer..</p>
<pre><code>digit [0-9]
letter [A-Za-z]
%option noyywrap
%{
#include<stdio.h>
#include<unistd.h>
char *yytext2 ;
char* replace(char*);
FILE *ff,*fw;
%}
%%
({letter}|[\w])*"."[" "]+({letter}|[\w])* {
yytext2 = (char *) malloc(sizeof(yytext));
... |
iOS 10 - UITableViewController scrolls to the bottom on load <p>I have a subclass of <code>UITableViewController</code> that displays several rows (8 to be exact), where the top row is a custom cell that contains a <code>UITextField</code>. When the view is loaded, I have the keyboard popup immediately by calling <cod... | <p>deferring becomeFirstResponder() solved the issue for me</p>
<pre><code>dispatch_async(dispatch_get_main_queue(), {
userInfoCell?.nameField.becomeFirstResponder()
})
</code></pre>
|
Insert Custom Section Header Constraint Warning <p>When I am inserting an extra section to my project with a custom section header xib file, I get this problem where I get all sorts of constraint warning if the current view is at the very bottom of the screen. These warning does not appear if the view is not at the ver... | <p>When using Auto Layout for positioning views in your view hierarchy, you should avoid setting frame or some fixed dimensions as much as possible. The problem in your code is, you are giving a fixed height for header which is something Auto Layout doesn't like:</p>
<pre><code>func tableView(tableView: UITableView, h... |
How can I join a list of characters into strings of 8? <p>I have a python list of chars and want to join them to create a list of strings of 8 elements each, eg: </p>
<pre><code>x = ['0','0','1','a','4','b','6','2','2','1','4','1','5','7','9','8']
</code></pre>
<p>result</p>
<pre><code>['001a4b62', '21415798']
</cod... | <p>The <a href="https://docs.python.org/2/library/itertools.html" rel="nofollow"><code>itertools</code> documentation</a> contains a <code>grouper</code> recipe that groups consecutive items to fixed-sized groups:</p>
<pre><code>from itertools import *
def grouper(iterable, n, fillvalue=None):
"Collect data into ... |
How to output in multiple terminal windows with a c program <p>I am writing a simple chat-room application in c using posix sockets.
However I'll have this issue in sending messages.</p>
<pre><code>(client1)say something: Hello folks! what are
client2 said: xyzabc
client3 said: dsgh
</code></pre>
<p>Here above is ... | <p>One known good way is using the <a href="http://www.delorie.com/gnu/docs/readline/rlman_41.html" rel="nofollow">alternate interface</a> to GNU Readline:</p>
<blockquote>
<p>Some applications need to interleave keyboard I/O with file, device, or window system I/O, typically by using a main loop to select() on vari... |
Recursive display select option in angularjs <p>I have a html select tag with option tags like below:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><select>
&l... | <p>You can use <code><optgroup></code> with ng-select</p>
<pre><code> <select ng-model='theModel' ng-change="display(theModel)">
<optgroup ng-repeat='group in collection' label="{{group.Name}}">
<option ng-repeat='veh in group.Fields' value='{{group.Name}}::{{veh.Name}}'>{{veh.N... |
How to make CSV file as stream from ResultSet in Java? <p>I am making an ajax request to an endpoint to make <code>CSV</code> file from <code>ResultSet</code>. I am doing below code to do that.</p>
<pre><code> val statement = dbCon.createStatement()
val rs = statement.executeQuery(exportQuery)
val csvWri... | <p>Your server side code should look like this:</p>
<pre><code> @RequestMapping(method = RequestMethod.GET, value = "csv",
produces = { AdditionalMediaTypes.TEXT_CSV_UTF8, AdditionalMediaTypes.APPLICATION_CSV_UTF8 })
public void getCsvFile(HttpServletRequest request, HttpServletResponse response) throws Excep... |
To get 2 primary keys from different tables in mysql <p>I'm doing my final year project and planning to do comment feature on my system. The customer that have purchased the meal only can comment or give feedback about that particular meal. So, I need to get the Meal_ID and Cust_ID from table 1 and table 2 in order to ... | <p>Foreign Key:</p>
<p><strong>Example:</strong></p>
<pre><code>CREATE TABLE Orders
(
O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
PRIMARY KEY (O_Id),
FOREIGN KEY (P_Id) REFERENCES Persons(P_Id)
)
</code></pre>
<p>Description: The following SQL creates a FOREIGN KEY on the "P_Id" column when the "Orders" table... |
Passing of character array to a pointer and concatenation of string <p>I get the concatenation of both the strings when 'c' is printed inside the function.But when the address of the pointer is returned and "i" is printed inside main, the output is not proper.</p>
<pre><code>#include <stdio.h>
char* comp(char* ... | <p>Problems I see:</p>
<p><strong>Problem 1</strong></p>
<p>You are not null terminating the concatenated string in <code>comp</code>.</p>
<pre><code>char* comp(char* s,char* t)
{
int count=0;
char *c;
c=s;
while(*s!='\0')
s++;
for(;*t!='\0';t++,s++)
*s=*t;
// Need this
*s = '\0';
... |
How to draw half-opened line in CSS? <p>Right half-opened line segment picture:</p>
<p><img src="http://i.stack.imgur.com/gcvJg.png" alt="image"></p>
<p>How to draw this line in CSS? With responsive horizontal line part. I found <a href="http://stackoverflow.com/questions/18816486/how-can-i-make-a-pointy-arrow-with-a... | <p>You can create this with one elements and one pseudo-element <code>:before</code> using <code>Flexbox</code></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.line {
... |
Nested Loops calculation output is incorrect, but program runs <p>How am I able to get my program to display year 1 for the first 12 months and then year 2 for the next 12 months if the input value for years = 2?</p>
<p>Also I don't know where my calculation is going wrong. According to my desired output, the total ra... | <p>Before the print statement, you don't need to add rain value again for rainTotal. This is because grandTotal accounts for the rain per year. And it is being added twice for two years already. So what you're doing is essentially adding the last value of rain twice (2 in this case)
Make your print statement this and r... |
Sorting the list of JSONObjects on the basis of particular key <p>I need to sort list of JSONObjects on the basis of "id" key. I am sorting using collections.sort and a comparator. My ids are as follows that I need to sort - </p>
<p>9721df798198##-1-2</p>
<p>9721df798198##-1-2-4</p>
<p>9721df798198##-1-2-4-9-14-16<... | <p>Update your compateString method as follows:</p>
<p>u need to compare each step of the id alone.</p>
<pre><code>public static int compareString(String str1, String str2){
String subString = str1.substring(str1.indexOf("##")+3, str1.length());
String subString1 = str2.substring(str2.indexOf("##")+3, str2.... |
How import AdventureWorks to SQuirrel SQL <p>I downloaded AdventureWorks 2012 from <a href="http://msftdbprodsamples.codeplex.com/" rel="nofollow">Microsoft</a> but how to import the database (.mdf + .ldf) into SQuirrel SQL?</p>
| <p>SQuirreL is not a database server. It is a querying tool that connects to a database server.</p>
<p>You need a copy of MS SQL Server installed on a Windows PC. Then you need to import Adventure Works into it.</p>
<p>Once you've done that you can connect using SQuirreL and the appropriate JDBC driver.</p>
|
iOS safari random resize and scroll issue <p>I am developing a website for desktop and mobile view. but when I test my mobile view on iOS Safari I encounter the following error</p>
<ol>
<li>on the mobile page there is a dropdown for user to select to jump to certain section of the page, on iOS when user select on the ... | <p>i am able to fixed my auto zoom option by setting the min font size of the dropdown list to 16px since safari will auto zoom when font size is less than 16px</p>
<pre><code>#ddlNavigation,
#ddlNavigation:focus{
font-size:16px !important;
}
</code></pre>
<p>for my html table scrolling i used <a href="http://are... |
Iteration in while loop runs and ends without taking inputs? <p>I want to split string and store it in <code>result</code> deque according to current input and do this again <code>while (count-- > 0)</code></p>
<p>count = 3 in this case.</p>
<p>input string : <strong>abc def ghi</strong></p>
<pre><code> while (... | <p>Instead of this:</p>
<pre><code> while (count-- > 0){
cout << " start of while loop" << endl;
deque<string> result; // result created inside loop
</code></pre>
<p>you want this</p>
<pre><code> deque<string> result; // result created outside loop
while (count-- > 0){
... |
Can not get Spring OAuth SSO filter to trigger <p>I have a spring boot + angular web app that closely follow the setup of this <a href="https://spring.io/guides/tutorials/spring-security-and-angular-js/" rel="nofollow">tutorial</a>: I'm running Authorization Server, Resource Server, UI web app all in the same Spring Bo... | <p>The default <code>@Order</code> for <code>org.springframework.security.oauth2.config.annotation.web.configuration.ResourcererverConfiguration</code> is 3.</p>
<p>Your <code>TuangouConfiguration</code> is set with <code>@Order(6)</code>. So if you change it to <code>@Order(2)</code> the ssoFilter or <code>CompositeF... |
jsf: get id from rest url or rewrite url <p>Currently I rewrite url as below</p>
<pre><code>.addRule(Join.path("/users").to("/views/user/index.jsf"))
</code></pre>
<p>But now I need to rewrite url which includes numbers(user id). For example, if I have url as <code>/users/1</code> or <code>/users/200</code>, etc. I n... | <p>This is what is working for me now but not sure if this is the correct way of doing things.</p>
<p>First I rewrite the url as <code>.addRule(Join.path("/users/{id}").to("/views/user/show.jsf"))</code></p>
<p>and I make the url as </p>
<pre><code><h:column>
<f:facet name="heade... |
How can I make use of intel-mkl with tensorflow <p>I've seen a lot of documentation about making using of a CPU with tensorflow, however, I don't have a GPU. What I do have is a fairly capable CPU and a holing 5GB of intel math kernel, which, I hope, might help me speed up tensorflow a fair bit.</p>
<p>Does anyone kno... | <p>You can install <a href="https://software.intel.com/en-us/intel-distribution-for-python" rel="nofollow">Intel Python Distribution</a>, this comes packaged with optimized NumPy, SciPy etc. You can install Tensorflow post this installation, Tensorflow uses Eigen, which is optimized to use SIMD vector lanes on CPU well... |
Click on button, change user status to active in field and send this user automatically e-mail <p>I have the code to update the user in the application that updates the user in the database.
My problem is that when I click on the button aktivan = active (when the user is registered there status neaktivan = inactive, so... | <p>What is behind your </p>
<blockquote>
<p>neaktivan()
aktivan()</p>
</blockquote>
<p>function? </p>
<p>Js, background php code, etc</p>
<p>Try this before the form to handle the post: </p>
<pre><code> <?php
if (isset($_POST['status_racuna']) && isset($_POST['user_id'])) {
#do some validation... |
How to attribute the HashMap values of returned JSON to TextViews in RecyclerView rows <p>As a result from an API call, I receive a Hashmap <code><String,Integer></code>. Within the <code>onResponse</code> method, I can output it in the console as follows:</p>
<pre><code> public void onResponse(Call<UsersStac... | <pre><code>users.get(position).getBadges().entrySet()
</code></pre>
<p>that returns a Set containing all of the mappings in this Map. Each mapping is an instance of <em>Map.Entry</em>. As the Set is backed by this Map, changes in one will be reflected in the other.</p>
<p>i think this is how you Iterate through the ... |
Maximum element in array which is equal to product of two elements in array <p>We need to find the maximum element in an array which is also equal to product of two elements in the same array. For example [2,3,6,8] , here 6=2*3 so answer is 6.</p>
<p>My approach was to sort the array and followed by a two pointer meth... | <p>There is a slight better solution with O(n * sqrt(n)) if you are allowed to use O(M) memory M = max number in A[i]
Use an array of size M to mark every number while you traverse them from smaller to bigger number.
For each number try all its factors and see if those were already present in the array map.</p>
<p>Her... |
Doctrine retrieve indexes of selected columns only <p>I am currently refactoring an application written in Symfony 3 and relies heavily on Doctrine ORM and I'm stuck trying to get an object/array with indexes of my selected columns.</p>
<p>Now I am fairly familiar with PHP PDO and as I recall a basic fetch of query re... | <p>I have been able to solve this on my own after creating a custom Hydrator.</p>
<p>I will keep the solution here for anyone who might face a similar problem.</p>
<p>Below is a class for the custom Hydrator</p>
<p>
<pre><code>namespace AppBundle\Doctrine;
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
use P... |
Why python is low level? <p>I have one confusion as python generate </p>
<p><code>source code ->> byte code --> python virtual machine</code> </p>
<p>does c language also generate byte code or it compile directly ?</p>
<p>If c doesn't generate byte code that's why it's consider as Low level language? Beca... | <p>Byte codes are not natural to the CPU so they need interpretation (by a CPU native code called interpreter).</p>
<p><a href="http://i.stack.imgur.com/FIaXV.png" rel="nofollow"><img src="http://i.stack.imgur.com/FIaXV.png" alt="enter image description here"></a></p>
<p>The python code you write is compiled into pyt... |
Cannot load local file <p>Just started today learning Node.js + Electron. I' am having difficlties in figuring out what's wrong with the following code.</p>
<p>In the console I' am getting the following error</p>
<pre><code>Not allowed to load local resource: file://%24%7B__dirname%7D/index.html
</code></pre>
<p>Her... | <p>It looks like you're trying to use ES2015 functionality to print the URL. This needs backticks instead of normal quotes:</p>
<pre><code>win.loadURL(`file://${__dirname}/index.html`)
</code></pre>
<p>Or you could just use normal string concatonation:</p>
<pre><code>win.loadURL('file://' + __dirname + '/index.html'... |
How do I write to and read from a file in cordova (ionic) when I have the path of the file to be read? <p>Is there a function which takes the path as the parameter? The path is of the form <code>file: //storage</code>.</p>
| <pre><code> angular.module('starter', ['ionic','ngCordova'])
</code></pre>
<p>First Inject ngCordova module then in you run do something like this</p>
<pre><code>run(function($ionicPlatform,$cordovaFile) {
$ionicPlatform.ready(function() {
console.log(cordova.file);
$cordovaFile.readAsText(cordova.file.ext... |
How convert list from one to another type using lameda Expression java <p>I have a list of Entities Employee(Class) which has fields empid, empname, emprole.salary</p>
<pre><code>List<Employee>= getting from database
</code></pre>
<p>I want to convert it into model list Person(Class) having fields empname, emp... | <p>Assuming you've got a suitable constructor, it should be as simple as:</p>
<pre><code>List<Person> people = employees
.stream() // View the list as a stream
.map(e -> new Person(e.getId(), e.getName(), e.getRole().getSalary()))
.collect(Collectors.toList());
</code></pre>
<p>Note that if that'... |
Assigning subobject <p>What is the proper way to assign a subobject? For example:</p>
<pre><code>struct A {
int x = 2;
int y = 3;
};
struct B: A {
int z = 5;
};
int main() {
std::unique_ptr<B> bp{new B{}};
A a;
a.x = 12;
a.y = 13;
*(static_cast<A*>(bp.get())) = a; // happens to work, but ... | <p>Typically, you don't assign subobjects. It's conceptually wrong and violates how inheritance is supposed to work. If you need this, perhaps you have the wrong abstraction and really want composition:</p>
<pre><code>struct B {
A a;
};
std::unique_ptr<B> bp{new B{}};
A a{12, 13};
bp->a = a;
</code></pre... |
Get AJAX value and Store in a php variable <p>how do I get this ajax value #name and store it in a php variable? what i have done is put it in a HTML.</p>
<pre><code><p id="name"></p>
setInterval(function(){
$.ajax({
url:"count.php",
type:"GET",
async:true,
cac... | <p>Use <code>data</code> to pass the variable to server. i.e. to count.php </p>
<pre><code> <p id="name"></p>
setInterval(function(){
var name=$("#name").val();
$.ajax({
url:"count.php",
data:{name:name},
type:"GET",
async:true,
... |
how to put the image from mysql to php table cell <p>I have this code:</p>
<pre><code><?php
$images = 'image';
$sql = "SELECT image FROM items WHERE itemsID = '4';";
$result = mysqli_query($connection, $sql) or die(mysqli_error($connection));
?>
<div id="table1" style="position:absolute; overflow:hidden; ... | <p>If you need to display the image from the mysql which is storing the image name that you have uploaded you have to follow the steps in order to display it.</p>
<ol>
<li>Ensure under which folder you have saved the uploaded image.</li>
<li>Make sure that you store only the name of the image into the database so that... |
How should I store the first line that got from getline() in c? <pre><code>int main(){
char *input = NULL;
char *first = NULL;
size_t len = 100;
int count = 0;
while(getline(&input, &len, stdin)!= EOF){
if(count == 0){
first = input;
printf("------>%s, c... | <p>It's because you make <code>first</code> point to the same memory as <code>input</code>. Both variables are pointing to the same memory after the assignment <code>first = input</code>.</p>
<p>You need to <em>duplicate</em> the string instead, using e.g. <code>strdup</code>:</p>
<pre><code>first = strdup(input);
</... |
PHP: Get base URL of a page <h2>Scenario:</h2>
<p>User adds a <code>URL</code> <em>(Like <code>URLs</code> below)</em>. I want to return all links on the page that appears in <code>href</code> attribute. I can get all links using <a href="http://php.net/manual/en/class.domdocument.php" rel="nofollow">DOMDocument</a> c... | <p><strong>You can use parse_url method like this code:</strong> </p>
<pre><code><?php
$url = 'http://example.com/test';
//get base url from link
$base_url=parse_url($url, PHP_URL_HOST);
//get path from link
$path=parse_url($url, PHP_URL_PATH);
//print base_url
echo 'Base URL = '.$base_... |
Cant get SpatialReference to work(ArcGIS) <p>ive been trying to get SpatialReference to work in ArcGIS and no matter what i try i cant get it to work, any help is appreciated.
here is my code</p>
<pre><code>wgs84 = SpatialReference.create(SpatialReference.WKID_WGS84);
SimpleMarkerSymbol simpleMarker = new Simple... | <p>Two issues:</p>
<ol>
<li><strong>Specify coordinates in the correct order.</strong> Whenever you specify coordinates, you need to check the ArcGIS Runtime documentation (<a href="https://developers.arcgis.com/android/api-reference" rel="nofollow">10.2.x</a>, <a href="https://developers.arcgis.com/android/beta/api-r... |
Implementing PartialEq for a struct with From types <p>I am trying to implement <code>PartialEq</code> between a struct I created and other types for which my struct implements the <code>From</code> trait. The real code is more complex and implements <code>From</code> for other types, but this is a stripped down versio... | <p>The compiler is right: adding <code>where Data: From<&T></code> <em>is</em> the right thing to do. But as you already noticed, a lifetime specifier is required in this case. But <strong>how</strong> do we declare it?</p>
<p>What we want to say to the compiler:</p>
<blockquote>
<p><code>Data</code> shou... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.