input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
finish background activity from broadcast receiver <p>I launch a new activity "ActivityB" when keypad is locked.(ActivityA has been backgrounded before the keypad is locked).
ActivityB times out after 30 secs and supposed to close itself, so I called finish after 30 secs, though is not visible, after I unlock I see 2 s... | <p>you may have an intent in activity a which is creating the activity b;</p>
|
An algorithm where I find the min and max element value and then do it again after removing those elements <p>I have the methods to find the smallest and largest value, and also to place them where they need to be. I also have a method to call those methods, and shrink to a subarray. The problem is, even though it is s... | <p>Unfortunately your code is quite flawed, so I just rewrote everything. The below code will sort any int[] by placing the smallest int in the input array in the left most unfilled position of a new array and placing the biggest in the right most unfilled position of a new array, until the new array is a sorted versio... |
How can I set logging level for Heroku Postgresql? <p>Using Heroku with the Postgresql add-on. Upon reviewing my logs, it seems postgresql is logging every ... single ... transaction. I understand you can set the log level by doing something like (<a href="https://www.postgresql.org/docs/9.1/static/runtime-config-log... | <ol>
<li><p>You interpreted documentation wrongly. The <a href="https://www.postgresql.org/docs/current/static/runtime-config-logging.html#GUC-LOG-STATEMENT" rel="nofollow"><code>log_statement</code> parameter</a> doesn't allow the <code>error</code> value. Possible values are instead: <code>none</code>, <code>ddl</cod... |
get specific value from array to return in NSIndexpath.row <p>i want my collection view to return only specific array. i want it to return only from "AUDI" to "Chevrolet" or [2...9]. the car make and new car make array, both have value of 8. they both should be the same but it give me error <code>fatal error: Index out... | <p><code>carmake[2...9]</code> is not an array but an <code>ArraySlice</code>, and array slices
use the same indices as the array that they are created from.
So the valid indices for <code>carmake[2...9]</code> are <code>2...9</code>, and not <code>0...7</code>
as you probably expected.</p>
<p>One solution would be to... |
CSS Issues / HTML Issues Working fine in local host <p>I have made a website and my CSS is working fine on my localhost but when I upload it to my web server it bugs out. </p>
<p>Here is the bugged out version: <a href="http://gayming.xyz/about/" rel="nofollow">http://gayming.xyz/about/</a></p>
<p>Here is what it is ... | <p>You are using both flexbox and float. Take <code>v-align</code> class out of your left and right boxes and it should take you closer to what you want.</p>
|
floyd's cycle-finding algorithm while checks <pre><code>P=head;
Q=head->next;
while( (p!=null) && (q!=null) )
{
if(p==q) exit(0); // loop detected
P=p->next;
q=(q->next)?(q->next->next):q->next;
}
</code></pre>
<p><a href="http://i.stack.imgur.com/PtjSC.jpg" rel="nofollow">Floyd's... | <p>In principle, you're correct that it's possible to only check the <a href="https://en.wikipedia.org/wiki/Cycle_detection" rel="nofollow">"hare" and not "tortoise"</a> (by you, <code>q</code> and not <code>p</code>) for being <code>NULL</code>, as if the list is acylic, <code>p</code> is never ahead of <code>q</code>... |
Extending a long-lived (60 day) user access token <p>I'm using FB login, converting the access token to a long-lived one on a server and then storing it in a database. According to the docs <a href="https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension" rel="nofollow">here</a>, maki... | <p>All you have to do is to go <a href="https://developers.facebook.com/tools/debug/accesstoken" rel="nofollow">HERE</a> and paste your <strong>short token</strong>, then press the button <strong>Extend Access Token</strong> and a new token will be <strong>generated</strong>.
Than you have to use the <strong>new token<... |
dplyr grouped cumulative set counting using group_by and rowwise do <p>I have grouped data with ordering within the groups where each row contains a list of values and within each group I'd like to produce a count of new list values contributed by each row to the union of the lists in each group.</p>
<p>Here is an exa... | <p>You can use the <code>Reduce</code> function with the <code>accumulate</code> mode to create cumulatively distinct elements and then use <code>lengths</code> function to return the cumulative distinct counts, this avoids the <code>rowwise()</code> operation:</p>
<pre><code>library(dplyr)
testdf %>%
ar... |
TestNG or Spring Test framework? <p>I have used TestNG+Rest Assured for rest api service testing(application is written based on Spring framework) and just want to know if it is better to use Spring test framework alone or integration TestNG+Spring test. </p>
<p>Thanks.</p>
| <p>Use the <strong>combination</strong> of both.</p>
<p>TestNG will act as <strong>full featured test framework</strong> and Spring Test framework to <strong>mock spring beans</strong> (In other words, to get the out of the box spring support).</p>
|
Use mp3 metadata or HTML to display artwork and track name on iPhone lock screen <p>When you lock an iphone after using safari / chrome etc., when an mp3 file is playing, it displays blank artwork and a hard link to the mp3 file location, which looks quite ugly. Is there some alt tag/ meta data I can include to show ar... | <p>If you want to display image on lock screen from your page you cannot do this, only iOS apps can. If you want to play music in background(while safari is closed, not killed) you can do it like this</p>
<pre><code>var mp3 = document.createElement("audio");
mp3.setAttribute('src', 'http://example.com/track.mp3');
... |
zend framework2 captcha not render - plugin error <p>I've this code in my form</p>
<pre><code>$this->add(array(
'type' => 'Zend\Form\Element\Captcha',
'name' => 'captcha',
'options' => array(
'label' => 'Inserisci il codice riportato sotto',
'captcha' =>... | <p>i solved in this way</p>
<pre><code><?php
$captcha = $form->get("captcha")->getCaptcha();
$captcha->generate();
?>
<img id="captcha-image" width="<?php echo $captcha->getWidth() ?>" height="<?php echo $captcha->getHeight() ?>" src="<?php echo $captcha->getImgUrl() . $captch... |
$stateParams returning null object <p>I am trying to get latitude and longitude variables from the URL and assigning them to the 'center' property of Google Maps. I am not getting any errors but I alert my center object to the screen, and both 'lat' and 'lon' come up null. </p>
<p>Here is the webpage: <a href="http://... | <p>Your issue is you aren't using <code><ui-view></code> and have the template for that route right in the page using an <code>ng-controller</code>.</p>
<p>Then you use index.html as the template for the route. </p>
<p>In effect you have 2 instances of the controller and the app is not set up correctly at all r... |
Error regarding system.io in .net <p>my .net service application started crash occasionally. Once investigate in windows event viewer, I get the below message:</p>
<blockquote>
<p>Application: myapp.exe Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception... | <p>This exception will be thrown when an I/O errors occurs. When process can't read or write correctly. Maybe Its because of your threading,It can't be done correctly.</p>
<p>"And is it that because I didn't put a try/catch block on some of my code that's why it will have this error and crashes my app?" ->
And yes,you... |
In oozie workflow (HUE), how to pass parameter from shell action to HDFS fs action <p>In My workflow, I have one shell action and an HDFS fs action</p>
<ol>
<li><p>Shell action echos date. (date=2016-10-06)</p></li>
<li><p>I want to set the above date parameter in HDFS fs action mkdir path. Following is the action def... | <p>You need to concate the two strings to form the complete path.</p>
<pre><code>String concat(String s1, String s2)
</code></pre>
<p>It returns the concatenation of 2 strings. A string with null value is considered as an empty string.</p>
<pre><code><mkdir path='concat(${nameNode}/user/kylin/, ${wf:actionData("s... |
CSS width transition choppy in FireFox if element rotated <p>Try to animate width of element with text which was rotated.</p>
<p>Animation looks smoothly in Chrome, IE-11, Safari but choppy in FireFox.</p>
<p>How to make vertical div width animation more smoothly and clean?</p>
<p>SNIPPET</p>
<p><div class="snippet... | <p>Maybe you could use <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode" rel="nofollow"><code>writing-mode</code></a> instead <code>transform</code> :</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snip... |
Angular Material - Element overlay on images (in md-card) <p>I am trying to reproduce the following using angular material (that is to say, add dynamic text over an image) :
<a href="http://i.stack.imgur.com/K3xNC.jpg" rel="nofollow">text over image</a></p>
<p>I would like to use md-cards because there are convenient.... | <p>You can use a wrapper. Something like this:</p>
<p>HTML:</p>
<pre><code><div class="md-card-wrapper" ng-app="myapp">
<md-card>
<img src="http://i.imgur.com/OiqxTL1.jpg">
</md-card>
<span>Text over image</span>
</div>
</code></pre>
<p>CSS:</p>
<pre><code>.md-car... |
Java: Program randomly stopped working because of "java.lang.NoClassDefFoundError: Could not initialize class me.ryan.Resources" <p>I've been programming a game, and I've had a class called Resources for a while. For some reason, when I make almost no edits to the class, it stops working. This is my Resources class:</p... | <p>This message ....</p>
<blockquote>
<p>âjava.lang.NoClassDefFoundError: Could not initialize class me.ryan.Resourcesâ</p>
</blockquote>
<p>means that the initialization of the statics for your <code>Resources</code> class has failed. The exception message does not say why, but the stacktrace will probably sa... |
How to download a custom queryset in CSV format? <pre><code>class ExportPlacesView(TemplateView):
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super(ExportPlacesView, self).dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
p... | <p>Basic pseudocode to generate and return csv:</p>
<pre><code>import csv
from django.http import HttpResponse
def csv(self):
response = HttpResponse(content_type='text/csv')
filename = u"fizzer.csv"
response['Content-Disposition'] = u'attachment; filename="{0}"'.format(filename)
writer = csv.writer(
... |
C - Reading CSV file in char array <p>I have a very little experience in C programming, particularly File Handling. I am developing a project in which I'm supposed to create a Sign Up/Log In system. I have a .csv file in which the data are separated by ,
What I am trying to do is reading the first and second column in... | <p>In my case I have the expected results, but I don't know if there is a difference with the compiler or if my csv file is different (I've tried to recreate it). Here is another way to parse the file, check if you have the expected results:</p>
<pre><code>#include <stdio.h>
#include <string.h>
#define LI... |
Simple ListView project is crashing, but no errors are shown <p>There are no errors in the message console when I run my project but it keeps crashing. I couldn't spot the reason. I tried to go through some of the similar questions asked and did implement the given solutions but it still didn't help me. Here is my c... | <p>ListViews do not have an orientation attribute. </p>
<p>You should wrap the ListView in a Relative/Linear/Frame-Layout</p>
<p>Then, you need to use an <code>ArrayAdapter<Earthquake> adapter;</code> (<a href="https://github.com/codepath/android_guides/wiki/Using-an-ArrayAdapter-with-ListView#using-a-custom-ar... |
Liferay Login Hook, error pop up <p>I need to show the errors in login hook of liferay in popup, but the sentence is only a line of code, so I don't know how implement the popup.
the key line is the next:</p>
<pre><code><liferay-ui:error exception="<%= NoSuchUserException.class %>" message="This message is ed... | <p>In case you need to show errors in dialog box,I suppose you are using</p>
<pre><code>SessionErrors.add(actionRequest, "error");
</code></pre>
<p>to send error from action phase.You can check SeesionErrors for 'error' attribute and display your message in dialog box:</p>
<pre><code> <% if(!SessionErrors.i... |
Hide a config value for storm UI <p>Storm UI shows all the configuration value including the blowfish encryption key. Is there any way to hide some of the config value from public?</p>
| <p>No, there is no such option provided out of the box. </p>
<p>If you just need to hide a some value from UI there is a simple hack. Just edit:</p>
<p><strong>[storm_home]/public/index.html</strong></p>
<p>In the bottom of the code there is a call to configuration parameters. You just need a small change here to hi... |
__str__ returned non-string (type tuple) <p>I have a form that keeps throwing me an error in django, Ive tried searching online tried str() on my models but wouldnt work at all. Googled a couple of times tried a couple different methods but none worked still get the same django error page everytime i click the link to ... | <p>Those commas aren't actually doing what you think they do. The commas make your return value a <em>tuple</em> instead of a <em>string</em> which a <code>__str__</code> method is supposed to return.</p>
<p>You can instead do:</p>
<pre><code>def __str__(self):
return '%s %s %s'%(self.soi_l1, self.soi_l2, self.st... |
What is the TypeScript 2.0 / ES2015 way to import assert from Node.js? <p>I'm running TypeScript 2.0.3, configured to with <code>"target": "es2015",</code>. I started with</p>
<pre><code>/// <reference path="../../node_modules/@types/node/index.d.ts" />
import assert = require('assert');
</code></pre>
<p>But i... | <p>This works for me:</p>
<pre><code>import * as assert from 'assert';
assert.ok(true);
assert(true);
</code></pre>
<p>If you run typescript from the same directory where <code>node_modules</code> is, you don't even need to add <code>/// <reference ...</code></p>
<p>UPDATE</p>
<p>As @Ryan Cavanaugh noted in t... |
Visual Studio "15" Preview uninstall <p>I'm trying to install VS "15" Preview 5, I have launched the new installer and now it's saying that I must uninstall previous version (Preview 4).
When I click on remove button the uninstall process fails and this is the error on log file:</p>
<pre><code>2016-10-05T23:20:59 : Ve... | <p>You must uninstall all previous releases of Visual Studio â15â before you try preview 5, and you can uninstall the previous versions through the Visual Studio Installer or use âUninstall a programâ from Control Panel. When the Visual Studio Installer cannot work, we can manually remove Visual Studio as below... |
Can I run/debug files with babel-node in WebStorm? <p>I know there are Run/Debug configurations in WebStorm, but I don't know how to configure the context menu (when I right click in a file, it has Run... and Debug... in the menu, but I can't find where to configure this). </p>
| <p>Run configurations are created via <code>Run | Edit Configurations...</code> : press <code>+</code>, choose <code>Node.js</code>, in created configuration specify babel-node as Node Interpreter:</p>
<p><a href="http://i.stack.imgur.com/bbsLi.png" rel="nofollow"><img src="http://i.stack.imgur.com/bbsLi.png" alt="ent... |
How to permanently set an environmental variable in an existing docker container? <p>I have an existing docker container and I would like to set an environmental variable in that container. Can this be done in Docker? If so, how?</p>
| <p>Environment variables get set on a process when it starts, and are typically inherited by child processes. In Docker, you can set the environment variable on an image with an <code>ENV</code> command in the Dockerfile. And you can configure the default environment used to start the container when you call <code>dock... |
ReactJS: How to dynamically render Material-UI's <MenuItem/> inside <DropDownMenu/>? <p>Using ReactJS + Material-UI, I have an array called <code>colors</code> and contains strings of different colors. Say for example the array <code>colors</code> has 3 color strings: "white", "blue", "green. Then I would like to rende... | <p>You've almost got it right. You have to <code>map</code> over available colors and return a <code>MenuItem</code> for each color:</p>
<pre class="lang-js prettyprint-override"><code>const colors = ['white', 'blue', 'green'];
class ColorChanger extends Component {
constructor() {
super();
this.state = {
... |
protect a specific page with htaccess and htpasswd <p>when we use htaccess and htpasswd, </p>
<ul>
<li>How can we protect a specific index.html page if the htaccess is before all domaine folders, all these domaines have an index.html page, so how the htaccess can know that we talk about the index.html of a specific do... | <p>To protect multiple files inside the same folder you can use:</p>
<p><strong>Password Protection with htaccess</strong></p>
<p>With .htaccess it is very easy to password protect a folder or directory. The method is called <strong>htaccess password protection</strong> or htaccess authentication, and works by upload... |
Can you tell me how I remove this from SQL? <p>There is a character that is appearing in some of the html on our website. </p>
<p><a href="http://i.stack.imgur.com/a7kro.png" rel="nofollow"><img src="http://i.stack.imgur.com/a7kro.png" alt="enter image description here"></a></p>
<p>â¨Here is the SQL:</p>
<pre><code... | <p>This character is <code>UNICODE 8232</code> and is called <a href="http://www.fileformat.info/info/unicode/char/2028/index.htm" rel="nofollow">Line separator. Details here</a></p>
<p>As long as you are dealing with <code>NVARCHAR</code>, it should be easy to replace</p>
<p><code>DECLARE @string NVARCHAR(100) = N'... |
Convert several matrices (of differing sizes) into a single 1xN matrix and back again <p>It is very easy to collapse several matrices (of differing sizes) into a single 1xN vector:</p>
<pre><code>vec = [ A(:)', B(:)', C(:)' ];
</code></pre>
<p>... but how can I now go the other way, i.e. recover U,V,W from vec?</p>
... | <p>I'm not sure if this answers your question (i.e. if you consider this as clean), but here is a solution for 3 matrices:</p>
<pre><code>A = randi(10,3,1);
B = randi(10,1,4);
C = randi(10,5,1);
vec = [ A(:).', B(:).', C(:).' ];
sizes = [size(A).', size(B).', size(C).' ];
U = zeros(sizes(:,1).');
V = zeros(sizes(:,2... |
DBGrid - OnCellClick & OnDblClick, return a form/TBMemo containing cell/column value/s <p>I'm using the following code added to my DBGrid - OnCellClick event</p>
<pre><code>procedure TForm2.DBGrid1CellClick(Column: TColumn);
begin
if dbmodule.comenziDataSet.Active then
begin
if not Assigned(dbgridCelulaForm) the... | <p>The following code shows how to access the Column and Row coordinates of a dbl-clicked cell of a TDBGrid, and the string value of the cell contents.</p>
<p>As written, it displays the cell's Column and Row number + string contents on the form's caption. Up to you what you actually do with these values.</p>
<p>It ... |
Undefined object in Java Script Ionic framework <p>I wrote a service for playing Media on iOS and Android in Ionic framework. It use Media plugin of Cordova. I am init media object and play it with this code in Java Script,but it returns undefined object error.</p>
<pre><code>var self = {
'currentTrack': null,
'initP... | <p>If you are developing your app in browser, Cordova plugins does not work in browsers while development.
You need to build the app in order to work the plugin.
You can use the remote debugging tool to debug the ".apk" or ".ipa".
You can get more information about remote debugging over <a href="http://docs.ionic.io/t... |
Jasmine spyOn and how to use spies generally <p>I am starting out in JS unit testing and having a hard time getting my head around how to create meaningful tests with Jasmine spies.</p>
<pre><code>it('should take an array of shopping items', function() {
spyOn(checkObj, 'getTotal');
checkObj.getTotal([1, 2, 3]);
... | <p>Well, spies are useful for a bit different scenario. Much depends on how you yourself define the scope of your unit test as well. If you do the minimal possible unit (i.e. method) then lets imagine the following:</p>
<pre><code>var x = function() { }
x.prototype.f1 = function() {
//do something
},... |
R: undo ordering / unsort / switch back to initial order <p>Suppose I have a vector</p>
<p><code>test<-c("a","b","c","d","e")</code></p>
<p>I am changing the order using another vector of indexes (this is essential):</p>
<pre><code>sortvect<-c(2,3,5,4,1)
test2<-test[sortvect]
</code></pre>
<p>After that I ... | <p>It is not that difficult. <code>match(test, test2)</code> will give you the index for reordering back.</p>
<pre><code>test <- c("a","b","c","d","e")
sortvect <- c(2,3,5,4,1)
test2 <- test[sortvect]
sortback <- match(test, test2)
test2[sortback]
# [1] "a" "b" "c" "d" "e"
</code></pre>
|
Hi everyone, is it possible to set horizontal gradient to text via CSS? (left letter one colour, right - another colour) <p>is it possible to set horizontal gradient to text via CSS? (left letter one colour, right - another colour).</p>
| <p>Yes, it is.</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>h1 {
font-size: 72px;
background: -webkit-linear-gradient(left, red , yellow);
background: -o-lin... |
How can I mock an Angular service using Protractor? <p>I have some e2e tests written in Protractor.
Some of my tests execute stuff that causes an alert to show (uib-alert).
The tests run fine and can find and verify the alerts, but if I use the tag dismiss-on-timeout from uib-alert, the tests fail because protractor wa... | <p>I made it by extracting the AlertService to a whole new module and then mocking it.
I guess protractor can't mock a single service inside a modula, only the whole thing.</p>
|
Hide <li Class> through Body (No Header Access or CSS) <p>I do not have access to the header and I cannot apply any custom CSS, I am curious if there is a way to append "display none" or a value "hidden (or anything!) to an existing LI class so it does not appear when I am on a specific page?</p>
<p>Here is Header HTM... | <p>Try to hide the element using jQuery :</p>
<pre><code>$('li.class-2').hide();
</code></pre>
<p><strong>NOTE :</strong> the <code>hide()</code> function will add <code>style="display: none;"</code> to the element automatically.</p>
<p>Hope this helps.</p>
<p><div class="snippet" data-lang="js" data-hide="false" d... |
Custom Email validation directive not displaying the validation result <p>I am trying to verify whether the email exists in my db or not.</p>
<p>JS</p>
<pre><code>var app = angular.module('emailValidApp', [])
app.directive('validateEmail', function($http) {
return {
restrict: 'A',
scope: t... | <p>Use <code><span ng-show="signupForm.email_addr.$invalid"></code> instead of <code><span ng-show="signupForm.email_addr.$validEmail"></code>. It should resolve your problem. </p>
|
Swift 3 Migration: Generic parameter 'Element' could not be inferred <p>arrayOfDicts is declared as</p>
<pre><code>let accelManager = CMSensorRecorder()
let motionManager = CMMotionManager()
var arrayOfDicts:[NSDictionary] = []
</code></pre>
<p>The function is defined as</p>
<pre><code> func startMotionManager() ... | <p>The closure type <code>CMAccelerometerHandler</code> has been changed to:</p>
<pre><code>public typealias CMAccelerometerHandler = (CMAccelerometerData?, Error?) -> Swift.Void
</code></pre>
<p>(From the generated header of "CMMotionManager.h".)</p>
<p>Try changing the <code>NSError?</code> in that line to <cod... |
Retrieving data with Firebase Swift bug <pre><code>@IBAction func one_2(sender: AnyObject) {
if un_1.textColor == UIColor.blueColor() {
if aac == false {
var aa = [FIRDataSnapshot]()
DataService.ds.REF_ISSUELIKES.observeEventType(.Value, withBlock: { (snapshot) in
i... | <p>Observer initialization does not belong in <code>@IBAction</code> handlers.</p>
<p>Once they are set, they remain valid throughout the lifetime of the parent <code>UIViewController</code>, or perhaps the lifetime of the entire App -- check documentation. So you have many observers registered to the event, all dupli... |
jQuery scroll to ID on page A from page B (node, ejs) <p>this is my navbar </p>
<pre><code> <ul id="jump" class="dropdown-menu" role="menu">
<li><a href="/main_page#top_something">People</a></li>
<li><a href="/main_page">Main Page</a></li>
</ul>... | <pre><code>(function (){
if(location.hash === '#top_something'){
window.setTimeout(
function(){
$('html, body').animate({
scrollTop: $('#top_something').offset().top
}, 'slow');
},2000);
}
})();
</code></pre>
<p>This is what worked for me in this case :)</... |
what is the best piece of software to design a GUI <p>I'm a programmer. I like to design the interface of my software before I code. people tell me to use a pen and paper. but I like to have more then one copy.</p>
| <p>Why not Use window builder for eclipse, I use it all the time and it works great
<a href="https://eclipse.org/windowbuilder/" rel="nofollow">https://eclipse.org/windowbuilder/</a></p>
<p>Or if your talking outside of programming use paint.net, a free and comprehensive drawing software.</p>
|
Concatenate table of two columns into a single string with 2 delimiters <p>Let's say I have a table with two columns:</p>
<pre class="lang-sql prettyprint-override"><code>create table #counties(
state varchar(max),
name varchar(max)
)
insert #counties(state,name) values('Alabama','Autauga')
insert #counties(state,nam... | <p>Try it like this</p>
<pre><code>With NamesPerState AS
(
SELECT c1.[state]
,STUFF(
(
SELECT ';' + c2.[name]
FROM #counties AS c2
WHERE c1.[state]=c2.[state]
ORDER BY c2.[name]
FOR XML PATH('')
),1,1,'') AS names
FR... |
Freshly installed Angular Cli gives error rather than running <p>I have been trying to install the latest angular-cli in order to start a new project, but I've been encountering a very strange issue. When I run</p>
<pre><code>npm install -g angular-cli@latest
</code></pre>
<p>angular-cli will seem to install successf... | <p>Try running <code>ng --version</code> in a directory with no <em>node_modules</em> and <em>package.json</em>, which can affect the result.</p>
<p>Try do the following to update all your global packages:</p>
<pre><code>npm update -g
</code></pre>
<p>My OS X setup</p>
<pre><code>> ng --version ... |
Play Framework with Hibernate - how to Spring-like DAO/Service/controller <p>I have experience with Spring framework with Hibernate ORM. Now I'm trying to learn Play Framework. I would like to use Hibernate for ORM. But I do not know how to do that.</p>
<p>In Spring I use these classes:</p>
<p>Entity:</p>
<pre><code... | <p>Since PersonManager is an interface, @Inject annotation of private PersonManager personManager is not sufficient. You should specify, what class implements this interface. This what is doing @Service annotation in Spring. It is done differently in Play.</p>
<p>In case the interface has a single implementation, you ... |
How do I check whether the next number is going to be negative or not? <p>I'm having a little trouble completing an assignment for my class.<br>
The instructions are:</p>
<blockquote>
<p>Read from all 12 monthly files and print the starting balance for each
month. If the balance is ever negative, print a warning m... | <ol>
<li>The file contains both a transaction type (dep, wdr) and an amount. You need to deposit (dep) or withdraw (wdr) the amount depending on the type.</li>
<li>You are printing the balance after each transaction. You should only be printing after each file.</li>
<li>You should check after each transaction whether t... |
Does the bitwise operation (&, ^. | etc) provided as operator overloads in the std::bitset use AVX or SSE4 instructions? <p>Since this is implementation dependent, is the only way to find that out is through the disassembly?</p>
| <p>You can alway look at <code>STL</code> sources to see if it uses <code>SIMD</code>, but I believe it is compiler specific and <code>STL</code> library doesn't directly utilize <code>SIMD</code> & <code>AVX</code> . It is up to the compiler to do vectorization if possible as a part of optimization.</p>
<p>So I'd... |
Using For Loop to Check for duplicates - Error The error is: Object reference not set to an instance of an object <p>I have a problem that I and my limited experience cannot figure out. </p>
<p>I have a multi-display (form) program that is for a game show system which uses a (5) display system. As I am wrapping this ... | <p>Use string.Format() to generate your control names, because it is more readable. </p>
<p>Instead of <strong>Me.controls("lblName").Text</strong>
use <strong>DirectCast(Me.FindControl("lblName"), Label).Text</strong></p>
|
AngularJS and Google SEO Indexing <p>I am not a specialist in SEO, and some time talking to one told me that Google indexes, which is in the <strong>view-source</strong>, I wonder if this is really true?</p>
<p>I am developing an application and took Angle and quite advanced, and I remembered and I wonder if this is t... | <p>The google indexer is getting much better at handling JavaScript heavy sites that deal with a lot of AJAX actions to bring in content. It is true that the indexer used to only really deal in the textual representation of your site. However that has been updated. </p>
<p>See <a href="https://webmasters.googleblog.co... |
Graphics clipping, why not clip pixels <p>I have a question about graphics clipping.
The question is: why do we need line clipping or polygon clipping?
Can we just rasterize everything then clip the pixels out of the
clipping window?</p>
<p>Thanks</p>
| <p>You could do that, but as people in the comments have said, it is slower.</p>
|
Why .Net Core has its own claim types? <p>Based OpenidConnect specification the standard types for role claim and name claim is <code>role</code> and <code>name</code>. However in .net core <code>System.Security.Claims.ClaimsIdentity.NameClaimType</code> is set to "<a href="http://schemas.xmlsoap.org/ws/2005/05/identit... | <p>What are the standard conventions? You're only thinking of it from the context of the OpenId Connect specification which is not the only identity standard out there. Microsoft have made it generic enough to support all identity systems. </p>
<p>The fault here seems to be in the OpenId Connect authentication imple... |
How to reliably write and restore partitioned data <p>I am looking for a way to write and restore partitioned dataset. For the purpose of this question I can accept both partitioned <code>RDD</code>:</p>
<pre><code>val partitioner: org.apache.spark.Partitioner = ???
rdd.partitionBy(partitioner)
</code></pre>
<p>and <... | <p>It might be achieved by bucketBy in dataframe/dataset api probably, but there is a catch - directly saving to parquet won't work, only saveAsTable works.</p>
<pre class="lang-java prettyprint-override"><code>Dataset<Row> parquet =...;
parquet.write()
.bucketBy(1000, "col1", "col2")
.partitionBy("col3")
... |
Spring boot increase page number by 1 always <p>boot(1.4.0) "Pageable" for pagination.It works fine without any issue.But by default the page value starts from "0" but in the front-end the page value starts from "1". So is there any standard approach to increment value instead of manually increment the page number insi... | <p>Spring Boot will be using Spring Data under the covers.</p>
<p>The Spring Data class you need to configure is the following:</p>
<p>org.springframework.data.web.PageableHandlerMethodArgumentResolver</p>
<p>and in particular the following method:</p>
<p><a href="http://docs.spring.io/spring-data/commons/docs/curr... |
Excel: Creating Unique Indentifiers <p>I'm looking to create a unique identifier column for a table in excel based on a few criteria. I've attached a picture with an example table below for reference.</p>
<p>Example excel table</p>
<p><a href="http://i.stack.imgur.com/1PFio.png" rel="nofollow"><img src="http://i.stac... | <p>Assuming your data is located at <code>B2:C23</code> </p>
<p>To generate Unique Id's use these <em>Formulas Array</em></p>
<p><em>Enter the FormulaArray pressing</em> <code>[Ctrl]</code> <em>+</em> <code>[Shift]</code> <em>+</em> <code>[Enter]</code> <em>simultaneously, you shall see</em> <code>{</code> <em>and</e... |
How to extract bytes from an SSE2 __m128i structure? <p>I'm a beginner with SIMD intrinsics, so I'll thank everyone for their patience in advance. I have an application involving absolute difference comparison of unsigned bytes (I'm working with greyscale images).</p>
<p>I tried AVX, more modern SSE versions etc, but ... | <p>Least obvious question first:</p>
<blockquote>
<p>once I've done all my vector processing, how the heck do I extract the modified bytes from the <code>__m128i</code></p>
</blockquote>
<p>Extract the low 64 bits to an integer with <code>int64_t _mm_cvtsi128_si64x(__m128i)</code>, or <a href="https://software.int... |
How to sequentially download data on android <p>i am using rest services on my server with json response. In my android map i am using retrofit with gson to pull that data and store it in my custom list view. My question is what is the best way download data from my server sequentially, eg. first 10 items from the serv... | <p>It sounds like you're looking for pagination. This has more to do with your server than your client. </p>
<p>A typical way to implement pagination, is to have your server accept offset and limit parameters for a collection resource. </p>
<p>So for example, say you had a collection of items on your server that you ... |
Article published permission <p>I have two different user permission levels: editor and publisher (non-admin users) setup in my lib\modules\apostrophe-users\index.js definition:</p>
<pre><code>groups: [
{
title: 'editor',
permissions: [ 'edit-apostrophe-blog' ]
},
{
title: 'publisher',
permissions: [ 'edit-apo... | <p>As you know I'm the lead developer of Apostrophe at P'unk Avenue.</p>
<p>Apostrophe 0.5 had a full "workflow" mode that separated publish permissions from edit permissions. 2.x currently does not but is likely to have such features in the near future, as we're bound to encounter the requirement from our own clients... |
Firebase child added in realtime not updating in collection view <p>After reading through a bunch of other questions on SO about reloading Firebase observeEventType observers, I am pretty confused. I am adding my observer dictionaries to a variable accessible within the entire controller. I then assign that value to th... | <p>you are only adding feetpost into post array. So after reload collectionview, you should add newest feetpost in to your custom cell's label according to indexpath.row </p>
<pre><code>if indexPath.section == 1 {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(feedCellId, forIndexPath: in... |
Error using rascal Java15 grammar <p>I tried to parse some Java Code using the Java15 grammar of Rascal. However, it does not accept the declaration of local variable of parameterized types. In more details:</p>
<ul>
<li>it <strong>does not</strong> recognize <code>List<String> files = ...</code></li>
<li>it rec... | <p>I'm not one to say "works for me", but it does :-) See:</p>
<pre><code>rascal>import lang::java::\syntax::Java15;
ok
rascal>import ParseTree;
ok
rascal>parse(#LocalVarDec, "List\<String\> files = null")
LocalVarDec: (LocalVarDec) `List<String> files = null`
</code></pre>
<p>Could you provide t... |
Why when moving objects forward they are moving very slow ? How can i change the speed? <p>In <code>Update</code> function:
The <code>UpdateSpheres</code> create the objects and then move them, but they are moving very slow.</p>
<pre><code>private void Update()
{
UpdateSpheres();
MoveShips();
}
private void M... | <p>Calling <code>FindGameObjectsWithTag</code> in every frame is very slow. Call that once in the <code>Start</code> function. Also add a public speed variable you can use to multiple to change the speed. You can modify this speed variable from the Editor until you get the speed you want. Make sure to look in the rest ... |
HTML history.pushState isn't working properly <p>I'm trying to figure out how to make pushState work so I'm testing with a simple HTML page with a single button in it as follows, but it doesn't change the url or seem to do anything. </p>
<pre><code><html>
<body>
<div id="test">
<button id="btn... | <p>There is nothing wrong with that code.</p>
<p>I was able to reproduce the problem by trying to load the document directly from my local disk (via a <code>file:</code> URL). It gave this error message:</p>
<blockquote>
<p>x.html:9 Uncaught SecurityError: Failed to execute 'pushState' on 'History': A history state... |
Payroll in java is resulting 0 <p>The problem is: </p>
<p>Design a Payroll class that has fields for an employee's name, ID number, hourly pay rate, and number of hours worked. Write the appropriate accessor and mutator methods abd a constructor that accepts the employee's name and ID number as agruments. The class s... | <p>You create a new <code>Payroll</code> object</p>
<pre><code>Payroll pay = new Payroll(EmployeeName, IDnumber);
</code></pre>
<p>and call the <code>getGrossPay()</code> method on it in your print statement</p>
<pre><code>pay.getGrossPay()
</code></pre>
<p>that method does the following:</p>
<pre><code>return Hou... |
Access folder that a custom python function resides in <p>How do I access a folder that a python function resides in?</p>
<p>For example, lets say that I have a N by 2 array of data. First column is the independent variable, and second is the dependent variable. I need to interpolate this data with different array of ... | <p>Like this: </p>
<pre><code>import os
my_dir = os.path.dirname(__file__)
fname = 'file_path_in_the_function_folder.txt'
filepath = os.path.join(my_dir, fname)
</code></pre>
<p>As explained in the <a href="https://docs.python.org/3/reference/datamodel.html?highlight=__file__" rel="nofollow">data model</a>, you can... |
Rails & ActiveRecord: Save Formatting of text block <p>I am trying to save a long multi-paragraph text description in my database in a text attribute. The problem is that when I render this text, all the formatting is missing and it appears as one long string.</p>
<p>Is there any way to keep the line breaks?</p>
| <p>You can use the <a href="http://apidock.com/rails/ActionView/Helpers/TextHelper/simple_format" rel="nofollow">simple_format</a></p>
<p>It will adds formatting rules to the text.</p>
<p>In case if you want to use the formatted description in many places. You can add a method to the model.</p>
<p>For example if you... |
Does unique_ptr automatically destruct when not referenced? <p>Similar to the concept of GC in Java, when an object is not referenced anymore by something else, it gets marked for GC.</p>
<p>Does unique_ptr work similar to this?</p>
<p>If say I have a data structure (a tree) with nodes containing left/right <code>std... | <blockquote>
<p>if I go to the parent of the BSTNode containing val, and assign nullptr to the left or right child field (which is the std::unique_ptr containing val), would the smart pointer self destruct? </p>
</blockquote>
<p>The smart pointer will destroy <em>the thing it points to</em>.</p>
<p>It will not dest... |
How to run preview analysis locally, but disallow uploading to server? <p><strong>SonarQube 5.6.1</strong></p>
<p>I need to allow users to run SonarQube analysis locally in preview mode, but I do not want them to be able to push anything to the server.</p>
<p>I see that there is this assignable ability:</p>
<blockqu... | <p>With SonarQube 5.6.1, making it possible for users to run preview analyses but not push results to the server require the 2 following things:</p>
<ul>
<li>Those users don't have the global "Execute Analysis" permission</li>
<li>Those users have the "Browse" permission on their projects</li>
</ul>
<p>That's all the... |
How to return an iText PDF document to the client side <p>I am trying to return an iText generated PDF from the server side to the client side to enable the user to store it. I am following <a href="http://stackoverflow.com/questions/11897290/how-to-convert-itextpdf-document-to-byte-array">How to convert iTextPDF Docum... | <p><strong>Error #1:</strong></p>
<p>Let's start with a small test that doesn't involve iText in any way. Try this:</p>
<pre><code>byte[] test = "Test".getBytes();
System.out.println("Test " + test);
</code></pre>
<p>What is written to the output? In my case, it's:</p>
<pre><code>Test [B@3da3da69
</code></pre>
<p>... |
how to add microsoft bot framework api to android studio? <p>how to add microsoft bot framework api to android studio.
I have created my bot using nodejs and now i want to add it to my android app.
So how to do it using android studio.</p>
| <p>The Microsoft bot framework API is for C#, so you can't add it to Android Studio.</p>
<p>For an example of calling your bot from Android see my answer <a href="http://stackoverflow.com/a/40025504/810731">here</a>.</p>
|
How to update .NET Core on Azure Web App? <p>I have my Azure Web App configured to deploy from a local git repository - I just push my changes to the Web App git repo and it builds and deploys the site.</p>
<p>I just updated to my ASP .NET Core site to: <code>"version": "1.0.0-preview2-003133"</code>, previously it wa... | <p>Please try to use Kudu service and using Kudu console try to restore dependencies. Kudu console can be accessed via <a href="https://mysite.scm.azurewebsites.net/" rel="nofollow">https://mysite.scm.azurewebsites.net/</a></p>
|
Finding the max of each continguous subarray of a given size <p>I'm trying to solve the following problem in Python</p>
<blockquote>
<p>Given an array and an integer k, find the maximum for each and every contiguous subarray of size k.</p>
</blockquote>
<p>The idea is to use a double ended queue. This is my code:</... | <p>It looks like you are trying to implement the O(n) algorithm for this problem, which would be better than the other two answers here at this time.</p>
<p>But, your implementation is incorrect. Where you say <code>arr[i] >= arr[len(Q)-1]</code>, you <em>should</em> say <code>arr[i] >= arr[Q[len(Q)-1]]</code> ... |
Concurrent access to shared-mem DLL from multiple processes <p>I have a DLL that uses memory-mapped files to provide data sharing among multiple processes in Windows (C++). Processes that want to read/write data to each other register their window handles with the DLL. When one of them puts data into the share, the o... | <p>Use "virtuallock" WinAPI function.</p>
<p>The inputs are your mapped memory pointer and mapped memory size.</p>
<pre><code>BOOL WINAPI VirtualLock(
_In_ LPVOID lpAddress,
_In_ SIZE_T dwSize
);
</code></pre>
<p>You have <code>VirtualUnlock</code> to unclock the memory, whenever you want to (based on your busi... |
Does injecting a generic interface with concrete types defeat the purpose of dependency injection? <p>Consider the following scenario. </p>
<pre><code>public interface IRestaurant<IDinner, IDesert> { }
public class Pasta : IDinner {}
public class Cake : IDesert {}
public class Chef
{
// resolving a mix of... | <p>I think you are mixing concepts here- DI doesn't inherently have anything to do whether you use interfaces or concrete classes per se. You could (for example) inject a concrete class that was one of several subclasses of Pasta (<code>Linguini</code>, <code>Ravioli</code>, etc)., and the benefits of DI (low coupling,... |
Changing name of top-level directory when downloading a tarball from GitHub? <p>I am trying to download the latest version of a specific github branch with curl. </p>
<pre><code>curl -L https://github.com/nativescript/docs/tarball/production | tar zx
</code></pre>
<p>However, this creates a file such as <code>NativeS... | <p>Use the newer <code>.../archive/...</code> link rather than the <code>.../tarball/...</code> link in your question. The general format is:</p>
<pre><code>https://github.com/<group_or_organization>/<repo>/archive/<refspec>.tar.gz
</code></pre>
<p>So, for example:</p>
<pre><code>$ curl -L jttps:/... |
Silverstripe: Remove Viewer Groups Tab <p>I'm trying to remove the 'ViewerGroups' tab from the back end of the CMS. I've tried:</p>
<pre><code>$fields->removeByName("Root.ViewerGroups");
</code></pre>
<p>and </p>
<pre><code>$fields->removeByName("ViewerGroups");
</code></pre>
<p>but neither seem to be working... | <p>You need to access it in the existing tab object:</p>
<pre><code>$fields->removeFieldFromTab('Root.Settings', 'ViewerGroups');
</code></pre>
|
Convert mysql_escape_string code to mysqli_escape_string code <p>I am new to php and coding for mysql. I am upgrading php code which used deprecated <code>mysql_</code> code to <code>mysqli_</code>. I cannot get the format for this function converted to <code>mysqli_</code> correctly. This code is in a functions.php co... | <p>In the second function, you needed to pass <code>$con</code> into the, function.</p>
|
DataTables Requested Unknown Parameter <p>I've already researched everything I can. I still get the dreaded error </p>
<p><code>Requested the unknown parameter 'title' for row 0, column 0</code></p>
<p>for the following code embedded in my index.html:</p>
<pre><code>$("#cd-table").DataTable({
"render": { "_": "pl... | <p>Found my problem. It's a VERY subtle PHP mistake (to me).</p>
<p>While assembling my array of JSON objects, I was using this statement (in a <code>for</code> loop):</p>
<pre><code>array_push($cd_json, json_encode(array("title" => $cd_row[0], "description" => $cd_row[1], "location" => $cd_row[2], "date" =... |
Loading images in phonegap app with pixijs <p>I am having a trouble with setting up an small project with pixi and phonegap. </p>
<p>So I try to work with a sprite sheet. This is working on localhost from the computer and the image displays correctly. The problem is when I test it with the PhoneGap Developer app. The ... | <p>The problem was that path I used. When I was looking for solution I found <a href="http://stackoverflow.com/questions/28339389/how-to-get-path-for-local-mp3-file-from-www-in-phonegap-ios">this</a> and replaced the path with the example below and it happened to work. </p>
<pre><code>function getPhoneGapPath() {
... |
What does the gate-level circuitry of a Program Counter in a processor look like? Or the time step counter? <p>Computer architecture seems to be a very difficult area of computer engineering that I think needs further material. There are great conceptual explanations of how different units work with each other, particu... | <p>Here's a counter using logic gates <a href="http://www.northdownfarm.co.uk/rory/tim/logic.htm" rel="nofollow">http://www.northdownfarm.co.uk/rory/tim/logic.htm</a></p>
<p>Learn more: <a href="https://www.youtube.com/watch?v=ZiAbLltaz4A" rel="nofollow">https://www.youtube.com/watch?v=ZiAbLltaz4A</a></p>
<p>Bunch of... |
IOS Map user location not displayed <p>I am experimenting with apple mapkit <a href="https://developer.apple.com/library/prerelease/content/documentation/UserExperience/Conceptual/LocationAwarenessPG/MapKit/MapKit.html#//apple_ref/doc/uid/TP40009497-CH3-SW1" rel="nofollow">apple mapkit guide</a>, and i noticed that to ... | <p>Are you actually starting up the location manager and updating the location?</p>
<pre><code>self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];
</code></pre>
<p>And don't forget to ask the user for permission as well.</p>
|
Most efficient way to determine overlapping timeseries in Python <p>I am trying to determine what percentage of the time that two time series overlap using python's pandas library. The data is nonsynchronous so the times for each data point do not line up. Here is an example:</p>
<p><strong>Time Series 1</strong></p>
... | <p><strong><em>setup</em></strong><br>
create 2 time series</p>
<pre><code>from StringIO import StringIO
import pandas as pd
txt1 = """2016-10-05 11:50:02.000734 0.50
2016-10-05 11:50:03.000033 0.25
2016-10-05 11:50:10.000479 0.50
2016-10-05 11:50:15.000234 0.25
2016-10-05 11:50:37.000199 0.50
2016-10... |
improper url link in angularJs <p>I am working in MEAN stack. For my front-end, I am trying to render data of single item from my item list with angular. When I click the item, the URL changes to other than I have set and I don't get the data. I was able to see this only after using debugging mode. The expected link is... | <p>Remove the slash on this anchor 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-js lang-js prettyprint-override"><code><a href='#/item/{{ item._id }}'>{{ item.name }}</a></code></pre>
</div... |
How can I convert certain characters of a String into a Float in Java? <p>I've been webscrapping some some data from a web page, in this case I just need a exchange rate.</p>
<p>By webscaprapping I got a String with this info</p>
<blockquote>
<p>¢559.41</p>
</blockquote>
<p>But I just need a float number with thi... | <p>Kind of a duplicate of the question: <a href="http://stackoverflow.com/questions/7552660/java-convert-float-to-string-and-string-to-float">java : convert float to String and String to float</a></p>
<p>But to answer your question: If the web element always has a currency token/symbol prefixed before the float number... |
How do you add link and text on top of video background and make them responsive using html5? <p>Trying to create a page for my project using a video as background but can't seem to put a link and text on top of video... I was able to do only one or the other. any help would be much appreciated! thank you in advance! <... | <p>Here is a sample, the "testing" h1 is a link to google.com</p>
<p><a href="https://codepen.io/carlos27/pen/rrpAWz" rel="nofollow">https://codepen.io/carlos27/pen/rrpAWz</a></p>
<p>HTMTL</p>
<pre><code> <!-- Content -->
<article>
<h1><a href="http://www.google.ca" target="_blank">TES... |
How would i read this file into a map c++ <p>I am struggling to figure out how to read this file into a map. I started by reading the file into a vector. And then was trying to take the string value in the vector and inserting that into a map. I am completely lost.</p>
<p>The first value is the key and the ordered pai... | <p>You specified that the on each line the initial value is a consecutive key, and the remaining values on each line consist of whitespace-delimited tupled, which each tuple being two values separated by a comma, with the first value being some other identifier, and as such the first value of all tuples on the same lin... |
Form validation on same page or different page? <p>Consider these two simplified scenarios:</p>
<pre><code>Script Name: script1.php
Validate form fields and if validated; redirect user to another page...
<form action=script1.php>
form fields.....
</form>
</code></pre>
<p>Second Scenario:</p>
<pre><code... | <p>From a personal point of view, I find it cleaner to have separate files. This then allows me to later on extend the system and allow other services to submit requests for validation without being overly cluttered. (For things, such as an application later on).</p>
<p>If you want to have it submitting to itself, you... |
Get previous day in an Expression <p>Just need help on this as I am new at SSIS. I got an expression but I want yesterday, not today.</p>
<pre><code> "Daily "+ (RIGHT("0" + (DT_STR,4,1252) DatePart("yyyy",getdate()),4))+(RIGHT("0" + (DT_STR,4,1252) DatePart("mm",getdate()),2))+(RIGHT("0" + (DT_STR,4,1252) DatePart("dd... | <p>Here you go.</p>
<pre><code>"Daily "
+ (DT_WSTR, 4) YEAR(DATEADD("day",-1,GETDATE()))
+ RIGHT("0" + (DT_WSTR, 2) DATEPART("MM", DATEADD("day", -1, GETDATE())),2)
+ RIGHT("0" + (DT_WSTR, 2) DATEPART("DD", DATEADD("day", -1, GETDATE())),2)
+ ".CSV"
</code></pre>
<p>It looks like you are in Australia, so it is <code>... |
Add Rows to a SQL Table in Ruby on Rails <p>How do I add data to a table in Rails?</p>
<p>So far I have created a Rails app that pulls in data from an API. Next, I have ran the command</p>
<pre><code>rails generate model order
</code></pre>
<p>and I have /db/migrate/timestamp_create_orders.rb</p>
<pre><code>class C... | <p>You do not create database entries in migrations, you usually create schema or specify changes in the <code>schema</code> in migration files. You use <code>seeds</code> for creating seed data in the database. </p>
<p>To create new data in database through rails you can use either <code>create</code> or <code>new</c... |
Angularjs filter not working with ng-repeat <p>Angularjs filter not working with ng-repeat when I change filter value with a function... I am new to angularjs.</p>
<p>These are my html buttons from which the filter value must be changed with the function on 'ng-click';</p>
<pre><code><span>
<a class="but... | <p>What you should do is take a model to its filter option, I imagine that the divs with those numbers in particular.</p>
<p>Now I do not quite understand as a weapon profiles wishlist but, in their profiles, you must give ng-model such as <code>ng-model = "profileSelected"</code></p>
<p>And to your list, add</p>
<p... |
How to get element and its attribute which caret is positioned? <p>I'm making rich editor with contenteditable div and I create <code><p></code> in contenteditable div by using this.</p>
<pre><code>document.execCommand('defaultParagraphSeparator', false, 'p')
</code></pre>
<p>And I set id to each <code><p>... | <p>If you set the <code>tabindex</code> property for the <code><p></code> element, it will allow it to have focus. Once it has focus, the <code>document.activeElement</code> property will return the <code>p</code> element instead of the <code>div</code>.</p>
<p>Here is <a href="https://jsfiddle.net/mseifert/pt7z... |
Storing iterator on a map in Scala <p>I need to store an iterator on a Map to implement a traversal of a trie. In Java I did: </p>
<pre><code>class Node {
HashMap<Character, Node> children = new HashMap<>();
Iterator<Character> i = children.keySet().iterator();
public boolean hasNext() {
... | <p>HashMap in Scala also supports iterator()</p>
<p><a href="http://www.scala-lang.org/api/current/#scala.collection.immutable.HashMap" rel="nofollow">http://www.scala-lang.org/api/current/#scala.collection.immutable.HashMap</a></p>
<p><a href="http://www.scala-lang.org/api/current/#scala.collection.Iterator" rel="no... |
Detecting whether or not a word file contains a duplicate <p>I am trying to write code that will read a file and detect if the file has duplicates. </p>
<p>This is the code I currently have. It detects the duplicates but the output isn't what I want it do be. I want it to only output once.</p>
<pre><code>set<Strin... | <p>If you only want it to print once then use a boolean variable to store the result and then print it afterwards.</p>
<p>e.g.</p>
<pre><code>boolean isUnique = true;
for(String word : list){
if(set.add(word) == false){
isUnique = false;
// can break;
break
}
}
System.out.println ("isU... |
Golang assign values to multidimensional struct from sql query <p>I want to assign values returned from an SQL query to a multidimensional struct. I want to output this multidimensional struct as JSON to a Web frontend.</p>
<p><strong>Edit: SQL query is simple, 'SELECT * FROM policy'. It returns many key/values but fo... | <p>Probably something like this:</p>
<pre><code>// a map with policy name as key
ts := map[string]tables
defer rows.Close()
for rows.Next() {
p := Parameters{}
if err := rows.Scan(&p.Policy_id, &p.Class_id, &p.Name); err != nil {
log.Fatal(err)
}
// initialize the table, if not ... |
Stop gif on mover hover does not work <p>I want to show a GIF first and when the mouse hovers on the GIF it should show a different JPG picture â so that it looks like it stopped. </p>
<p>I tried this code but it didn't work.
I would like to know which part needs to be fixed. </p>
<pre><code><html>
<scrip... | <p>There are two problems here with your code: </p>
<ol>
<li><p>You are not loading jQuery - so you can't use it. And the console (F12) throws an error for that: <code>Uncaught ReferenceError: $ is not defined</code></p></li>
<li><p>You are registering the javascript-event before the dom-element is available</p></li>
... |
Unable to loop thru JSON array inside an object <p>This is how my JSON return object looks like:</p>
<pre><code>{
u'Policy': u'{
"Version": "2012-10-17",
"Statement": [{
"Sid": "xxxxx",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amaz... | <p>You should convert the JSON into a dictionary with</p>
<pre><code>import json
mydict = json.load(bucket_policy)
</code></pre>
<p>Then loop:</p>
<pre><code>for stmt in mydict['Policy']['Statement']:
print stmt
</code></pre>
|
Micro optimization on array keys <p>I have an array of which I am using some items to construct more arrays, a rough example follows.</p>
<pre><code>$rows = [
[1, 2, 3, 'a', 'b', 'c'],
[4, 5, 6, 'd', 'e', 'f'],
[4, 5, 6, 'g', 'h', 'i'],
];
$derivedData = [];
foreach ($rows as $data) {
$key = $data[0... | <blockquote>
<p>In other words - lets say I have variable $a, if I use that as a key in different arrays would the value of $a be used (and copied) for each array as key or the pointer in memory will be used, that is basically my question?</p>
</blockquote>
<p>Here comes the differences between PHP >=5.4 & PHP 7... |
If/Else In Regular Expression Scripting <p>I'm trying to script something to read parts of a report. I thought I knew how to use if/else logic inside of this, but I keep getting errors. </p>
<p>Code:</p>
<pre><code>printf "The report type is: "
egrep -o 'METAR|SPECI' metar1.txt
printf "Station: "
egrep -o 'K[A-Z]{3}... | <p>Replace the <code>if ... fi</code> block with:</p>
<pre><code>if egrep 'AUTO' metar1.txt ; then
echo "This is a fully automated report."
elif egrep -o 'COR' metar1.txt ; then
echo "This is a corrected observation."
else
echo "There is neither 'AUTO' or 'COR' in this report."
fi
</code></pre>
|
Multiple queries of related models in remote method <p>I'm new to nodejs and Loopback/Express . I'm trying to write a trivial application involving an API call that has multiple db requests of related models, but I coudln't find any relevant documentation or examples that show this.</p>
<p>Imagine 3 models: Author, Po... | <p>Well with a little refactoring and changes, it'll be very short and straightforward:</p>
<pre><code>Post.details = function(id) {
var app = require('../../server/server');
var Rating = app.models.Rating;
return Promise.all([
Post.findById(id, {include: 'author', where: {deleted: false}}),
Rating.cou... |
How to Set Equal Width or Equal Height in StackView? <p>I have six labels here, every two labels are stack in a horizontal view, and all horizontal views are stack in a vertical view, as show below</p>
<p><img src="http://i.stack.imgur.com/C2Qz0.png" alt="Labels layout detail"></p>
<p><img src="http://i.stack.imgur.c... | <p>IMO, Stack View wont allow to give some fix frame size of the views inside it, we can somewhat control it using available properties.<br/> Stack Views are meant for similar type content to be confined inside one view.</p>
<p><strong>Option:</strong></p>
<ul>
<li>Take your Labels inside one <em>View</em>(Content Vi... |
Google Chrome is not displaying chinese characters correctly <p>I am facing issues that Chinese characters are not displayed properly in chrome. Below is a screenshot of whats happening. </p>
<p><a href="http://i.stack.imgur.com/TAxgv.png" rel="nofollow"><img src="http://i.stack.imgur.com/TAxgv.png" alt="weird Chinese... | <pre><code><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>My Website</h1>
<p>Some text...</p>
</body>
</code></pre>
<p></p>
<p>have you tried using meta charset</p>
<pre><code><... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.