input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
angular 2: passing parameters from nodes <p>I would like to pass a parameter from a node, instead of a property. For example:</p>
<pre><code><!-- I would like to use this: -->
<navbar-comp>
<items>
<item label="Page 1" path="/page1" />
<item label="Page 2" path="/page2" />
&... | <p>you can access content of a component's node with ViewChild() or ContentChild() decorators. check out the docs</p>
|
Play a random sound on single button <p>First, I shall start off by saying I am the worst coder you will ever meet. I'm trying to make a Javascript that allows me to press a single button and have a random sound play. My idea was to do a math random and to have a number correspond with a sound that would then do an if ... | <p>You can use method play() as in the following link.
<a href="http://www.w3schools.com/jsref/met_audio_play.asp" rel="nofollow">W3 Schools</a></p>
<p>And I think it's better if you go with Math.random() method. As in the followoing code you can define a max and min value.</p>
<pre><code>function getRandomArbitrary(... |
xcode 8 provisioning profile error <p>I have an app that I created with xcode 7.3. I have updated to xcode 8 and I am trying to update my app. I see the provisioning profile I used before under provisioning profile (depreciated) but there is nothing under provisioning profile. Do I need to create a new iOS Distribut... | <p>No need to create new distribution profile as Xcode have option <strong>Automatically manage signing</strong> you only need to select the <strong>Team</strong> and if have already registered the bundle identifier xcode will create everything for now its very easy.</p>
<p>Please let me know if you have any further e... |
Check checkbox based on multiple table cell criteria <p>I have an html table full of data, the first column contains an input checkbox and a name. I want to check this checkbox when two criteria are met:</p>
<ol>
<li>the name is "Complete"</li>
<li>the date sent matches a string passed in "m/d/yyyy" i.e. "9/20/2016" (... | <p>To get the checkboxes, you can use:</p>
<pre><code>document.querySelectorAll('input[type=checkbox]');
</code></pre>
<p>or:</p>
<pre><code>jQuery('input[type=checkbox]');
</code></pre>
<p>You can use the following to get an array of the tds:</p>
<pre><code>document.querySelectorAll('td.yourClass');
</code></pre>... |
PasteSpecial - End of Statement Expected <p>I have this script that saves my selection to another page. I use cut as part of my tidying the page for the next input. </p>
<p>Anyway I have tried several variation on <code>xlPasteValues</code> however keep receiving end of statement expected.</p>
<p>From <a href="http:/... | <p>Excel doesn't support (AFAIK) Cut / PasteValues, so you will need to use:</p>
<pre><code>Newcastle_Shrinkage.Copy
ToSite_Shrinkage.Range("B" & ToSite_Shrinkage.UsedRange.Rows.Count + 1).PasteSpecial Paste:=xlPasteValues
Newcastle_Shrinkage.ClearContents
</code></pre>
<p>Note: The answer by Comintern is probab... |
How to connect NSLabel to CGPoint dragged with mouse? <blockquote>
<p>I have several rectangles made from CGPoints (Xcode 7.3, Swift 2.2). I want to create a label showing a number for any selected rectangle. So I made AppDelegate for array of CGPoints. But at runtime I see the label showing just <strong><em>0</em></... | <blockquote>
<p>Finally I found a solution. Wrong choice of <code>applicationDidFinishLaunching</code> method affected the performance of my dynamic label. So I changed the method to <code>applicationWillUpdate</code>. Now everything works as intended. Here is my corrected code:</p>
</blockquote>
<p><strong>AppDele... |
Git Fetch/Pull confusion <p>I am a newbie in git and currently trying out various combinations to understand git.</p>
<p>I have a repository with branch named 'dev'. Now initially i brought my local in sync with the remote. Then i changed the remote directly from Github.</p>
<p>Now if i use </p>
<pre><code>git fetch... | <blockquote>
<p>fatal: Refusing to fetch into current branch refs/heads/dev of non-bare repository</p>
</blockquote>
<p>This error generally means that you're fetching a branch that doesn't have a remote branch. I'm making some assumptions here that you want to fetch from the <code>origin</code> repo and merge in th... |
Android Error Installing APK <p>When I try to run my app in an emulator I get the error:</p>
<pre><code>The APK file C:\Users\PC\AndroidStudioProjects\AppProject\app\build\outputs\apk\app-debug.apk does not exist on disk.
Error while Installing APK
</code></pre>
<p>I'm not entirely sure what has happened after I just... | <p>Hey its to do with the Gradle version when running the application. For some reason its not installing the debugger. Just use the version 2.1.3 instead of 2.2.0 and it will work or you can go to File -> Project Structure -> Project -> Android Plugin Version. change to 2.1.3</p>
<p><a href="http://i.stack.imgur.com... |
How can I print the Truth value of a variable? <p>In Python, variables have truthy values based on their content. For example:</p>
<pre><code>>>> def a(x):
... if x:
... print (True)
...
>>> a('')
>>> a(0)
>>> a('a')
True
>>>
>>> a([])
>>> a(... | <p>Use the builtin <code>bool</code> type.</p>
<pre><code>print(bool(a))
</code></pre>
<p>Some examples from the REPL:</p>
<pre><code>>>> print(bool(''))
False
>>> print(bool('a'))
True
>>> print(bool([]))
False
</code></pre>
|
Xamarin Android.Support.V4 in VS 2013 not recognize in amxl.layout <p>I am working with VS 2013 and I have already installed Components and references.</p>
<p><a href="http://i.stack.imgur.com/nyNBS.png" rel="nofollow">The main.axml does not recognize that layout. The warning is: Invalid child element 'Android.Support... | <p>This might not be of great help for you, but I recently faced the same issue (with VS 2015), turns out that if you type the namespace from the support library correctly, it will give you this alerts but it will work anyway...</p>
<p>In <em>Tools</em> > <em>Extensions and Updates</em> you might find something that a... |
Serialize get-only properties on MongoDb <p>With C# 6 I can write:</p>
<pre><code>public class Person
{
public Guid Id { get; }
public string Name { get; }
public Person(Guid id, string name)
{
Id = id;
Name = name;
}
}
</code></pre>
<p>Unfortunately a class like this is not serial... | <p>I have tried to solve this problem by creating a convention that map all read only properties that match a constructor and also the matched constructor.</p>
<p>Assume that you have an immutable class like:</p>
<pre><code>public class Person
{
public string FirstName { get; }
public string LastName { get; }... |
Parameters not adding to ADO string for INSERT statement VBA <p>I am trying to learn how to avoid SQL injection and am using VBA connecting to a mysql DB via ADO in VB. </p>
<p>The problem I am having is that for the line </p>
<pre><code>Set rs = cmd.Execute
</code></pre>
<p>I get the following error that I have no... | <p>Remove the "qualifer=?" from the SQL statement. ODBC parameters are specified with a single <code>?</code>, and have to be added in the same order as they appear in the statement:</p>
<pre><code>INSERT INTO `NLVMerlinResults` (Year, Month, Day, Lab, Station, IP,
thisWeek, Week1, Week2, Week3, Week4, Week5, Weeks... |
Use date reference is a vlookup formula <p>I have attached a printscreen to make it easier to understand my question.</p>
<p>I'm creating a supply management woorkbook. Income will refer to the purchases and outcome the resale of this purchases. Because there will be price variations, I'm looking for a formula to inse... | <p>Assuming there will be no more than one entry for any given product on any given day, and assuming the data is ordered chronologically, try this in F3 and copy down</p>
<pre><code>=IF(E3>0,SUMPRODUCT($D2:D$3,--($A2:A$3=A3),--($B2:B$3=MAX($B2:B$3))),"")
</code></pre>
|
Change Background color to a Visual pattern based <p>I have a list of elements (simple buttons with plain textblock) which are color coded based on the list item content. User can update the Listitem and thus listitem color should change. For certain listitem background colors like "Red", I want to add a pattern as wel... | <p>Change <code>{Binding BackgroundClr}</code> to <code>{Binding BackgroundClr.Color}</code>.</p>
|
IPv6 support using Parse.com <p>My app was rejected today due to 'not supporting IPv6'. I've attached screenshots of the error they received which comes from a Parse.com API call.</p>
<p>I could really use some help on this, as I have no clue where to start with this. </p>
<p>Does anyone know if Parse.com supports IP... | <p>I have a parse server hosted on Heroku which doesn't support IPv6 yet (see <a href="https://kb.heroku.com/apple-has-rejected-my-application-because-heroku-does-not-support-ipv6" rel="nofollow">here</a>). But your server is not the reason why the app is rejected. It is your app which should support IPv6. </p>
<p>A p... |
IOS Push fails with error message: fwrite(): send of 474 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host <p>I'm using open source app "ProcessMaker" </p>
<p>All works fine except IOS push notification, when acctions that makes a push, this push crash only for IOS (in android... | <p>this issue was already fixed for processmaker 3.1 that is being released october 4th, if after updating you still see this issue please create a ticket on <a href="http://bugs.processmaker.com/" rel="nofollow">http://bugs.processmaker.com/</a> so it can be adressed accordingly.</p>
|
Perform Math per Column in CSV using Column Values <p>I'm attempting to use PowerShell to pickup a CSV file, subtract value of one column from another and put it in a third, then print the CSV to default printer. </p>
<p>I've got everything working except the math. It imports, sets up my headers, and prints. However i... | <p>The statement</p>
<pre><code>$FreqShopPrice = $hhsigns.FreqShopPrice
</code></pre>
<p>copies the value of the CSV field <code>FreqShopPrice</code> into the variable <code>$FreqShopPrice</code>.</p>
<p>The statement</p>
<pre><code>$FreqShopPrice = $Price - $FreqShopValue
</code></pre>
<p>updates the variable <co... |
Is the variety of keys a factor in performance? <p>Working with <strong>hadoop</strong> and <strong>map-reduce</strong> framework, i was thinking that the <strong>reduce tasks must be fine-grained</strong> so that the different nodes that processes them can do it separately. </p>
<p>I think that the number of keys can... | <p>All the same keys should end in the same reducer, then, if you have only one key, you will really use only one reducer not matter if you have set 10 reducers. The remaining reducers won't have any output (but they will be instantiated).</p>
<p>This is a big issue named "skew data" and you require to redefine (and r... |
Checking if property exists in object in JavaScript (browser compliance) <p>What is the most standards and best browser compatibility for checking if a given property of an object exists in JavaScript?</p>
<p>I can think of the following:</p>
<p><strong>1.</strong></p>
<pre><code>if(window && 'navigator' in ... | <p>The <code>window &&</code> check at the start of each of the checks is unnecessary. There's never a natural case where that will evaluate to false. (If you run the code in Nodejs or in a web worker where the <code>window</code> global isn't present, then the line will throw an exception, and not evaluate to ... |
htaccess rewrite remove trailing slash <p>I have the following rewrite rules which work perfectly</p>
<pre><code>RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\/$ /social/single_post.php?name=$1&t=$2&id=$3 [L]
RewriteRule ^([^/]*)\/$ /social/user.php?user=$1 [L]
</code></pre>
<p>Example: <a href="http:... | <p>Try this,</p>
<pre><code>RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\/$ /social/single_post.php?name=$1&t=$2&id=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)\/$ /social/us... |
How do I serialize compiled V8Script in Clearscript? <p>I am using ClearScript to compile some JavaScript and then I would like to serialize it to store it in SQL. But it is marked as not Serializable, what should I do?</p>
<pre><code>V8ScriptEngine engine = new V8ScriptEngine();
V8Script compiled = engine.Compile("v... | <p>A V8 compiled script is tied to the isolate instance that created it, so it makes no sense to serialize it. You can't reuse it in a different process, nor even with another isolate in the same process. There's more information <a href="https://clearscript.codeplex.com/discussions/560532" rel="nofollow">here</a> and ... |
asp.net mvc & Oracle Issue (Skip And Take) <p>I Use asp.net mvc and oracle database</p>
<p>I am using the expression below</p>
<pre><code>var displayedCompanies = filteredCompanies
.Skip(10)
.Take(5);
</code></pre>
<p>but for some reason the Take and Skip do not work, that is ...
he always puts the complete SQL stat... | <p>That's right..
I'm using Linq To Entities (Everything is working)
Thank you</p>
|
React modal reusing <p>I'm currently making a React application and I'm facing an issue.</p>
<p>I have a list with users, a button which displays a modal to add a user, and when you click a user from the list it shows you the same modal used to register users, but with the user information so you can modify it.</p>
<... | <p>I am not hundred percent sure but maybe you can do this</p>
<pre><code>class AppContainer extends React.Component {
constructor(props) {
super();
this.state = {
previousName: '',
name: 'Dan'
};
}
editName(newName) {
this.setState({
pre... |
Repeat an animation 2 or 3 times before easing it out <p>How can I repeat a spinning animation x times before easing it out ?</p>
<p>For instance : </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 p... | <p>Instead of repeating the animation infinite times, you can specify a number of repetitions like this: </p>
<pre><code>animation: spin 3s 3 ease-in-out; /* 3secs, repeat 3 times */
</code></pre>
<p>See <a href="https://developer.mozilla.org/en/docs/Web/CSS/animation-iteration-count" rel="nofollow">animation iterati... |
Convert a java string classpath into a wildcard where more than `N` jars from the same directory show up in the classpath? <p>I launch java from an agent launcher. The class path gets so large I need to use the manifest.mf file or Windows will run out of cmd line space (bash has a limit too but it's much higher so we d... | <p>Here is what i'm working out:</p>
<pre><code>public static String convertClasspathToWildcard(String cp) {
Set<String> parentCountMap = new HashSet<>();
for (String nextJar : cp.split(SystemUtils.IS_OS_WINDOWS && cp.contains(";") ? ";" : ":")) {
String substring = nextJar.substring(... |
Javascript: How did I get here? (Viewing data sent by server, non-AJAX.) <p>I've got a React-based app that works like this: The user makes a request for "foo", the server returns basic page info (applicable to all pages on the site), and when the client receives this (DOMContentLoaded), it does an AJAX call for the in... | <p>You could drop a script tag on your server-rendered page that includes a global var accessible by your script bundle. e.g., </p>
<pre><code><script>
var myGlobalVar = { ... server data ... } <!-- // note: this is rendered raw by your server
</script>
<script src="myScriptBundle.min.js">&... |
ERROR : Could not execute build using Gradle distribution <p>The full error message is</p>
<pre><code>Configured compileSdkVersion is invalid: 21 (C:/Users/Zachry/AppData/Local/Android/android-sdk/platforms/android-21
Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2... | <p>Thank you @L. Swifter for making me recheck this, it turns out I had installed android 23, not 21. For anyone having the same problem I did, make 100% sure you're using Android API 21 in your SDK Manager.</p>
|
How to get a Spring managed bean from jersey.servlet.ServletContainer managed bean? <p>I am learning to build a RESTful API using jersey and Spring </p>
<p>But get some problems when inject my Service bean into my resource handling class,</p>
<p>I can not get the bean using <code>@Autowired</code> or <code>@Resource... | <p>Use the Jersey-Spring3 dependency to bootstrap the spring components.</p>
<pre><code><groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.4.1</version>
</code></pre>
<p>You can configure context param in web xml to refer spring applicati... |
Compiler dropping my type conversion? <p>I'm puzzled by what I had to do to get this code to work. It seems as if the compiler optimized away a type conversion that I needed, or there's something else I don't understand here.</p>
<p>I have various objects that are stored in the database that implement the interface <c... | <p>This is a great question and goes into the nitty gritty details of the semantics of the ternary expression. No, your compiler is not broken or playing tricks on you.</p>
<p>In this case, if the types of the second and third operands of the ternary expression is <code>long</code> and <code>int</code>, then the resul... |
AWS Cloudfront and browser cache settings <p>Hi so I have AWS Cloudront running on my site. I also enabled browser caching through .htaccess file.</p>
<p>Soon after I enabled browser caching my Cloudfront hits went very low and misses very high.</p>
<p>My htaccess has following:</p>
<pre><code>ExpiresByType text/css... | <p>Depending on your specific <code>.htaccess</code> configuration - this could very well cause what you've seen.</p>
<h2>Cloudfront Behaviour</h2>
<p>If your backend doesn't nominate any specific cache headers, then cloudfront will cache according to your cloudfront configuration - but as there are no cache headers,... |
How do I use scrapy to scrape data between a start point and an end point on a webpage <p>I am working on an interest project in which I use a list of drug names to find the side effects of cancer treatment drugs. I want to store the side effects that occur in greater than 30% of the cases. I am a complete newbie to sc... | <p>You can use get all the elements in between the two paragraphs using the <em>Kayessian method</em> set intersection, : </p>
<pre><code>from lxml import html
import requests
# expressions to find the two p tags we want.
ns1 = "//p[contains(. , '(occurring in greater than 30%)')]"
ns2 = "//p[contains(., '(occurring ... |
How do I pull a recurring key from a JSON? <p>I'm new to python (and coding in general), I've gotten this far but I'm having trouble. I'm querying against a web service that returns a json file with information on every employee. I would like to pull just a couple of attributes for each employee, but I'm having some tr... | <p>Your JSON is the <code>list</code> of <code>dict</code> objects. By doing <code>j[1]</code>, you are accessing the item in the list at index <code>1</code>. In order to get all the records, you need to iterate all the elements of the list as:</p>
<pre><code>for item in j:
print item['name']
</code></pre>
<p>wh... |
File upload with Jersey 2 and Jetty <ul>
<li>Hello everyone.</li>
</ul>
<p>I developed a webservice which runs on Jetty with a RESTful API using Jersey 2.
I later had to create a file upload method (mainly for XLS/XML files) and I tried to use Jersey 2's Multipart libraries for it.</p>
<p>However, as the server star... | <p><code>jersey-media-multipart</code> depends on <code>jersey-common</code> , add </p>
<pre><code> <dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.23.2</version>
</dependency>
</c... |
Looking for a solution to link checkboxes <p>I need some help because Iâm not that experienced with checkboxes.</p>
<p>So, I have a list and each row have a checkbox, by the way this list is auto generated but whatever, what I want is to be able to create some group or a link between some of the checkboxes, that if ... | <p>Is it your expect? like follow code</p>
<pre><code> <script>
function f(vobj,vname){
if(vobj.checked){
checkoruncheck(vname,'checked');
}else{
checkoruncheck(vname,'unchecked');
}
}
function checkoruncheck(vname,vf){
var boxs=document.getElementsByName(vname);
for(i=0;i<... |
Get Pathway From PHP Upload <p>I have looked around for a solution and have found several of the same brand, but I can't seem to get an exact solution. </p>
<p>I want the image to display, which, in some sense works-partly. It uploads, but no image is displayed. What is the meaning of this? </p>
<p>Here is my PHP cod... | <p>your <code>move_uploaded_file($FILES['filename']['tmp_name'],$name);</code> should be <code>move_uploaded_file($_FILES['filename']['tmp_name'],$name);</code> .</p>
<p>Underscore is missing.</p>
|
How do I select and drag a different object than the one clicked in fabricjs? <p>I draw multiple objects on a canvas, but the top one has transparency. So you can see images behind it. It is unselectable. I want to be able to click on that image and then programatically select an image behind it and when I drag the mou... | <p>have you tried just setting the <code>selectable</code> and <code>evented</code> property to false? here is an example with a blue square over two other squares. you can only interact with the 2 objects below the blue square and not the blue square at all.</p>
<p><div class="snippet" data-lang="js" data-hide="false... |
How to pass comma separated multi select values to the url on form submit <p>I have a basic GET form in my project that is used to filter through posts created by users. When I submit the form the values from the multiple select input are appended to the url like so:</p>
<pre><code>project.dev/?maps[]=1&maps[]=2&a... | <p>Assuming you're trying to send an array, how about Array.prototype.join?</p>
<pre><code>var arr = [1, 2, 3];
console.log(arr.join(','));
// result: 1,2,3
</code></pre>
|
Notify/Update Fragment after Activity finishes - Android <p>So I have a fragment that uses a cardAdapter. When I click on a card, it shows the details of a object called Carona(ride), which is an activity. I have the option to CANCEL my proposal in this details activity, and if I do that, I go back to the previous frag... | <p>Did you override <code>onActivityResult</code> in your mainActivity? If yes, make sure to call <code>super.onActivityResult</code> in that method to get the call in the fragment also.</p>
<p>Change <code>context.startActivityForResult()</code> in the fragment with just <code>startActivityForResult()</code>.</p>
|
Do not fail test case if Driver initialization in beforeclass annotation fails <p>I have a situation where I wish not to fail my test case if driver initialization fails in beforeclass annotation. I am using appium driver setup in beforeclass and if appium driver fails to recognize connected devices or cannot instantia... | <p>You can catch the exception in the BeforeClass method and throw a SkipException for testng to skip all the tests. This would mark the testcases as <strong>skipped</strong> and not as <strong>failed</strong>.</p>
<p>eg.</p>
<pre><code>@BeforeClass
public void bc(){
try{
//init driver
}catch(WebdriverInitExcepti... |
How to have spring MVC app direct to generic .com url <p>So for example, if my project name is WebApp and my domain is www.google.com, when running locally I have to type in www.google.com/WebApp. That's not super easy for clients, so I was wondering if there is a way to direct to a home page when typing in www.google.... | <p>Where are you deploying? To get to <code>www.google.com</code> you have to deploy to the root context or point the root to where you deployed.</p>
<p><a href="http://stackoverflow.com/questions/5328518/deploying-my-application-at-the-root-in-tomcat">Deploying my application at the root in Tomcat</a></p>
<blockquot... |
untar through a list of .gz <p>in R, I want to download and untar all the .gz files from every directory from this site: <a href="ftp://ftp.dwd.de/pub/data/gpcc/GPCC_DI/" rel="nofollow">ftp://ftp.dwd.de/pub/data/gpcc/GPCC_DI/</a></p>
<p>I am having difficulty with this: I put all ~60 of the .gzs from here <a href="ftp... | <p>I would probably download and then unzip.</p>
<p>make sure you set a working directory.</p>
<pre><code>library(curl)
library(stringr)
list_gz = list("ftp://ftp.dwd.de/pub/data/gpcc/GPCC_DI//2014/GPCC_DI_201401.nc.gz",
"ftp://ftp.dwd.de/pub/data/gpcc/GPCC_DI//2014/GPCC_DI_201402.nc.gz")
sapply(list... |
Parsing ID issue FirebaseRecyclerAdapter <p>I am trying to parse following JSON using Firebase:</p>
<pre><code> {
"organizations" : {
"-KS5bLCjQmNSQZDIQkTE" : {
"about" : {
"address" : "teka",
"city" : "sns",
"country" : "South Afric... | <p>Try this:</p>
<pre><code>class DepartmentChild{
public String address;
public String name;
public String getName(){
return this.name;
}
}
public class Organizations {
public About about;
public Map<String,DepartmentChild> department;
public Map<String, DepartmentChild> get... |
Asp.Net Identity 2 not able to reset password clear text? <p>I'm building a admin piece for a club website. I need to be able to allow someone with Admin rights to reset a users password. I also want to have the admin to be able to see the user's password in clear text because in our scenario it's easier to just tell t... | <p>Storing a password in clear text is <strong>always</strong> a bad idea. I understand the temptation because it makes your (or the admin's) life easier, however you do have a responsibility to your users that use your site. </p>
<p>A lot of people are lazy and will re-use the same password in multiple places, if you... |
c# console app, process naming using a variable <p>I have a c# console app that creates a process for 15 digital cameras to takes and downloads pictures on command.
Currently it is hardcoded for 16 cameras and I would like to have it ask the user for the amount of camera's and then create that amount of processes/conne... | <p>You can't. Instead what you can do is put it in a List.</p>
<pre><code> var Cameras = new List<Process>()
for (int i = 1; i <= cameraQuantity; i++)
{
Process takepic;
//Process takepic+cameranumber;
takepic = new Process();
Cameras.Add(takepic);
</code></pre>
<p>then... |
python: why am I not exiting while loop? <p>Can't find anything applicable to the problem I have here. If there is, please point me toward it.
Anyway, as a new one to python, I can't understand why my output here keeps repeating indefinitely. </p>
<pre><code>from random import randint
dollars = int(input("How many do... | <p>Yes, like Karin said, you are not changing the value of dollars with these statements:</p>
<pre><code>if diceone + dicetwo == 7:
dollars + 4
else:
dollars - 1
</code></pre>
<p>since the amount of "dollars" never gets changed, your while loop will loop forever (dollars will always be greater than zero) assu... |
link to pdf not working on mobile browser <p>I have a basic html link to a pdf file on a page, when clicked is opens the pdf on PC but on mobile nothing happens when the link is clicked. I have</p>
<pre><code><a href="linktofile.pdf" target="_blank">Click to pdf</a>
</code></pre>
<p>Can someone help advis... | <p>try using the full link like <a href="http://example.com/linktofile.pdf" rel="nofollow">http://example.com/linktofile.pdf</a> . If still you get a problem, then try checking with your friends phone. I've just now checked with my website, it's working with Chrome built-in browser. Also check for default PDF Viewer.</... |
C# How to append only the end of text file and in specific position? <p>i want to change status from OK to NG, </p>
<pre><code>IPen ID Datetime Status
50 Wednesday, September 21, 2016 08:56:45 OK
IPen ID Datetime Status
50 Wednesday, ... | <p>Since you're already reading the entire file into memory, you could convert it to a list, remove from the end, and iterate in reverse to update the last two entries:</p>
<pre><code>var lines = File.ReadAllLines(Fullpath).ToList();
// Remove as many lines as you'd like from the end
if (lines.Count > 2)
{
lin... |
Ajax Event Listener and Google Analytics <p>I've implemented the script found on this site
<a href="http://www.lunametrics.com/blog/2015/08/27/ajax-event-listener-google-tag-manager/" rel="nofollow">http://www.lunametrics.com/blog/2015/08/27/ajax-event-listener-google-tag-manager/</a> to this website <a href="http://ww... | <p>It's complicated to know why the code is firing 3 times, i checked the domain and i cant found that implementation. the most possible cause is that you add 3 trigger rules on the tag, if that is the case, remember that the selected trigger have the or condition, not the and , and every condition is analized one by o... |
React Native: How to set background color for the whole app and individual scene in react-native-router-flux? <p>In React Native using react-native-router-flux, How can I set the background color for the whole app and also individual scene as well? </p>
<p>Here is my current set up:</p>
<pre><code>const RouterWithRed... | <p>In the <a href="https://github.com/aksonov/react-native-router-flux/blob/master/docs/API_CONFIGURATION.md" rel="nofollow">API documentation</a>, you can use <code>sceneStyle</code> or <code>getSceneStyle</code> on both <code>Router</code> and <code>Scene</code> (only <code>getSceneStyle</code> for <code>Router</code... |
syntax error, unexpected '$post_id' (T_VARIABLE) in Laravel <p>I have a problem with my function in laravel</p>
<p>I am trying to execute the following code:</p>
<pre><code>public static function likePost($value)
{
$post_id = $value['post_id'];
$user_id = $value['user_id'];
if($value['liked'] == "1")
{
... | <p>As @andrewsi said you have missing comma after <code>'='</code>. Also you can just use this code which will do the same job:</p>
<pre><code>Like::where('user_id', $user_id)->where('post_id', $post_id)->delete();
</code></pre>
|
Integrating CAS into Java Dynamic Web Project <p><b>SETUP</b></p>
<hr/>
<p>A "Hello World" servlet deployed in Tomcat (ROOT)<br/></p>
<p>(1) This is working without CAS and I can access my application at the following URLs:</p>
<ul>
<li>http://localhost:8090/hello</li>
<li>https://localhost:8443/hello</li>
... | <p>If I understand your question right, you are trying to casify your hello web application</p>
<p>I believe, to casify you application, it needs to run on secure port. </p>
<p>Having said that, you will be casifying the following service URL, <a href="https://localhost:8443/hello" rel="nofollow">https://localhost:84... |
how to solve this error: attempt to set 'rownames' on an object with no dimensions <p>I have a csv file with daily streamflow. I need to combine the daily values into monthly. I am trying to use the "daily2monthly" function of "hydroTSM" package.
sample data from the BRPT2.csv:</p>
<pre><code>_date,_time,_value,_flag... | <p>Try converting your <code>df</code> into a <code>zoo</code> object first:</p>
<pre><code>z <- zoo(df[, -1], df[, 1])
daily2monthly(z, FUN=sum, dates=1)
# 1959-10-01 1959-11-01 1959-12-01 1960-01-01 1960-02-01 1960-03-01 1960-04-01
# 31440.0 411.9 1199.3 4373.0 1466.0 1904.0 741.0
<... |
aggregator not aggregating splitted messages after amqp confirm <ol>
<li>I have a db query that get a list of IDs</li>
<li>I split them using splitter into a channel with a task executor </li>
<li>Then I publish amqp messages for every Id</li>
</ol>
<p>Requirement: I need to confirm that all the messages have been pub... | <blockquote>
<p>The number of published messages is always correct. </p>
</blockquote>
<p>What makes you think so?</p>
<p>Let's add <code>confirm-nack-channel</code> to see the "negative publisher confirms"!</p>
<p>And maybe <code>return-channel</code> as well to see how "returned messages will be sent" if that.</... |
How to implement `dry-validation` gem in a Rails form object? <p>I'm trying to substitute <code>ActiveRecord</code> validations with <code>Dry-validations</code>, but I've been unable to find any in-app implementation examples to follow.</p>
<p>Dry-validation docs: <a href="http://dry-rb.org/gems/dry-validation/" rel=... | <p>I would try to keep validation at the model level.</p>
<p>Have a ModelValidations model in your initializers, each method named after the model it validates.</p>
<p>config/initialize/model_validations.rb</p>
<pre><code>module ModelValidations
def position_form
Dry::Validation.Schema do
required(:title... |
More succinct initialization for SQLAlchemy instance <p>It's my first attempt at sqlalchemy. I have a json file with my usr information and I would like to put them in a sqlite3 database file. It works but I find the instance initialization verbose since there are many columns in the table, as you can see below.</p>
<... | <p>If you know the property names in the JSON object match the column names of the Python model, you can just change:</p>
<pre><code>a = User(id=usr['id'], bbs_id=usr['bbs_id'], name=usr['name'])
</code></pre>
<p>to:</p>
<pre><code>a = User(**usr)
</code></pre>
<p><a href="https://docs.python.org/3/tutorial/control... |
Ansible 2.0 backslash issue <p>I'm having issues with backslash in Ansible 2.0</p>
<pre><code> mysql_user: name=someName
password=somePassword
priv=db.*:DELETE,INSERT,SELECT,UPDATE,LOCK\\ TABLES
state=present
</code></pre>
<p>The error is:</p>
<pre><code>"msg": "invalid privileges stri... | <p>You can't use spaces in unquoted strings with <code>param=value</code> syntax in Ansible.</p>
<pre><code>mysql_user: name=someName
password=somePassword
priv="db.*:DELETE,INSERT,SELECT,UPDATE,LOCK TABLES"
state=present
</code></pre>
<p>Advice: use dict-like parameters passing fo... |
How to show DropdownList in EditMode of GridView in ASP.Net C#? <p>I have a gridview1 and it has a normal field.
After clicking edit link, I want to show a <code>DropdownList</code> that reads from my Database.
How can I achieve this?</p>
<p>this is my code for list template:</p>
<pre><code><asp:TemplateField Hea... | <p>It would go in your RowDataBound event. So you will have to check the row state (edit) and bind the dropdown.</p>
<p>Please refer-
<a href="http://stackoverflow.com/questions/833490/gridview-row-editing-dynamic-binding-to-a-dropdownlist">Gridview row editing - dynamic binding to a DropDownList</a>
<a href="https://... |
Retain Cycle: "Parent-Child" <p>"A common use case for the weak attribute is parent-child data structures. By convention, the parent object should maintain a strong reference with itâs children, and the children should store a weak reference back to the parent. Weak references are also an inherent part of the delegat... | <p>For question 1, if the parent is released, the weak reference in a child will become a reference to a deallocated object, and using it will cause an exception.</p>
<p>The way to avoid this circumstance is to make it the responsibility of the parent to release it's children upon it's deallocation. The child will ne... |
My lex pattern doesn't work to match my input file, how to correct it? <p>I've got a simple pattern to match: head+content+tail, I've got a lex file like below:</p>
<pre><code>$ cat b.l
%{
#include<stdio.h>
%}
%%
"12" {printf("head\n");}
"34" {printf("tail\n");}
.* {printf("content\n");}
%%
</code></pre>
<p>I h... | <p>(F)lex always matches the longest possible token. Since <code>.*</code> will match any sequence which doesn't contain a newline character, it will happily match <code>12sdaesre34</code>. (In (f)lex, <code>.</code> matches any character other than newline.) Thus the <code>34</code> is no longer available to be matche... |
Receive broadcast for activity not started yet? <p>I want to have a <code>Broadcast Receiver</code> to obtain location information for an activity that is not started yet. Basically I have some location that I obtain in one activity. When I click my FAB button, I want to take the location that I obtained in the first a... | <p>Just put the data in the Intent that starts the second activity. Then in the second activity, get the intent by calling getIntent(), and retrieve data from it. Something like this:</p>
<p>Pass the location details by</p>
<pre><code>private void startActivityWithData() {
Intent intent = new Intent(this, Second... |
Callback fires before iteration is complete <p>I'm using the <a href="https://caolan.github.io/async/docs.html" rel="nofollow">async</a> library in this project. One function (copied below) includes a nested loop to build a 2D Array. The callback is called before the array is completely built. I'd really like to unders... | <p>One way would be to just use native promises and wait for the async calls to finish</p>
<pre><code>function getStopTimesForTrips(cb) {
var promises = timeTable.listOfTripIds.map(function(id) {
return new Promise(function(resolve, reject) {
retrieveTimesByTrip(id, function(err, st) {
... |
How to use a paramater to determine a variable using a JavaScript function <p>Can anyone help me understand why this script won't update the iFrame panel when using the loadPages()? Haven't written code in ages and building a website. Is there a better way to swap the iFrame src? Thanks!</p>
<p><div class="snippet" da... | <p>your syntax is not proper, change to::</p>
<pre><code>function loadPages(a){
var loc1 = "http://jquery.com/";
var loc2 = "http://www.w3schools.com/";
if (a == 1){
document.getElementById('myFrame').src = loc1;
}
else {
document.getElementById('myFrame').src = loc2;
}
}
</code... |
Android: better to use a boolean? <p>I have a LongClick method that launches a Fragment and is working fine:</p>
<pre><code>@Override
public void onItemLongClick(int position, View view) {
Bundle bundle = new Bundle();
bundle.putInt("itemPosition",position);
android.app.FragmentManager fm = getFra... | <p>The official documentation says:</p>
<p>return true if the callback consumed the long click, false otherwise</p>
<p><a href="https://developer.android.com/reference/android/widget/AdapterView.OnItemLongClickListener.html" rel="nofollow">https://developer.android.com/reference/android/widget/AdapterView.OnItemLongC... |
Trouble with this if-statement <p>I am coding in Java and using TextPad editor.</p>
<p>I am trying to write code that sets "r" equal to a certain value depending on whether the user is male or female. I have already asked the user to put "1" if they are male and "2" if they are female.</p>
<p>I have set r as a double... | <p>The problem with your code is that in the first version, if it goes to the else block (which it will even if the user has entered 1) then <code>r</code> won't be initialized so at the next line it cannot find any value for it. The correct code would be something like this:</p>
<pre><code>if (gender == 1)
r = 0.... |
For loop works fine in Lua 5.1 but crashes in Lua 5.3.1 <p>The below for loop works fine in Lua 5.1 but crashes in Lua 5.3.1. After considerable search, but without any luck. <code>Pairs</code> is a table.</p>
<pre><code>num_pairs = #Pairs/2
for index = num_pairs, 1, -1 do
startIndex = Pairs[2 * index - 1]
en... | <p>I dont see most important part of your code, but if moteus and Paul said that your program works, in <code>Pairs[2 * index]</code> is something other than just number. Publish more code, we will try to help you to fix it.</p>
|
How To Make JFrame ..Jbutton to get the input in jtextfield? <p>Im making my project and I want to get the inputs in <code>jTextField</code> by pressing the <code>jButton</code> then display it it <code>jLabel</code>. Please help. Thanks.</p>
| <p>Add an action to the button and then in the action handler get the text from textfield element and set the retrieved text as in jlabel element .
Jlabel.settext(jtextfield.gettext().trim());</p>
|
Detect Pacific timezone with Javascript <p>I want to do a if statment if the current time in pacific time is 11am. how can i do that? here is what i have right now:</p>
<pre><code>var time = new Date().getHours();
if(time == 11) {
alert("this works");
}
</code></pre>
<p>but that only detects the user's time. how c... | <p>Combination of <code>getTimezoneOffset()</code> and PST (-7), currently Pacific Daylight Time!</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 offset = new Date().get... |
making the contents of div row centered in bootstrap <p>I have a problem in making my div row centered, i have 3 posts from wordpress which is equivalent to 3 columns inside the row, but it didn't centered after i add many css attributes to let it center. I am also using wordpress. </p>
<p><a href="http://i.stack.imgu... | <p>Try this:</p>
<p>Check demo <a href="http://codepen.io/jpI/pen/BLLvEV" rel="nofollow">HERE</a></p>
<p>CSS:</p>
<pre><code>.center-block {
display: flex;
flex-direction: row;
justify-content: center;
}
</code></pre>
<p>I hope it helps</p>
|
How to immeditaly end program with J.option in Java if validation is not correct <p>The following code ask for your name and age. If you enter age -99 the code still ask you for your Gender. I would like the code to immediately flash the error message if you do not enter a age between 0 and 100. Without asking for your... | <p>Just move the code that asks for gender inside the <code>if</code> branch corresponding to an acceptable age:</p>
<pre><code>public static void main (String[] args) {
final int DRINKING_AGE = 21;
final int ADULT = 18;
final String LEGAL_DRINKING_AGE_MESSAGE = "You are legally able to drink";
int age = In... |
How to get rid of a Sigbrt Error? Swift <p>Randomly whenever i click on the products tab of my application
I am getting a Sig Brt error stating there is an NsUnknownKeyException if anyone knows how to solve this i would be very greatful.</p>
<p><a href="http://i.stack.imgur.com/31VXK.png" rel="nofollow">Picture of th... | <p>SIGABRT (signal abort) is the code an app crashes with when an exception (a fatal error) is thrown and not handled. Most likely something is wrong with your storyboard or nib or info.plist.</p>
<p>My recommendation is to check carefully when it crashes if it´s on startup look at the initial viewController and wha... |
Why do my sql tables maintain deleted id's? <p>When I insert data into a brand new table, it will assign a new id via AUTO_INCREMENT. So the first time I perform an insert I get an id of 1. However, if I delete the row and insert new data, the table acts as if there is still a preceding row (the new row will have an ... | <p>Your data is not persisting. MySql maintains a separate table about your table containing, among other things, the next auto-increment value for your table. You can reset this with:</p>
<pre><code>ALTER TABLE tablename AUTO_INCREMENT = 1
</code></pre>
<p>However, be aware that if you are resetting to a value below... |
AJAX call not working in React once I change state <p>So I'm currently writing something due tomorrow in React. I have a component that looks like:</p>
<pre><code>var PartOne = React.createClass({
getInitialState: function() {
return {
month: 1,
day: 1,
year: 2016,
loading: false,
... | <p>Change the following:</p>
<pre><code><MonthSelector month={this.state.month} onSelect={this._onSelectMonth(event.target.value)} />
&nbsp;
<DaySelector day={this.state.day} onSelect={this._onSelectDay(event.target.value)} />
&nbsp;
<YearSelector year={this.state.year} onSelect={this._onSelectY... |
VBA get value from ComboBox to hide row <p>I have a little bit difficult in getting combobox value.
The properties of this combobox is already linked to "C10" cell. So I assumed the combobox value = C10 value.
The combobox values are supposed to be hide non-used row, if the value of C10 = CM or QM or QMC or CM </p>
<p... | <p>Try using the filter method on an array of the values.</p>
<pre><code>allowed = Array("QM", "PM", "QMC", "CM")
If UBound(Filter(allowed, Range("C10").Value)) > -1 Then
Worksheets("page2").Rows("43").EntireRow.Hidden = False
Else
Worksheets("page2").Rows("43").EntireRow.Hidden = True
End If
</code></pre>
|
Scope of Angular 2 app <p>In Angular 1, there was a <code>scope</code> for every component & we can access them from the html template as well.</p>
<p>So in Angular 2 we can declare components like this,</p>
<pre><code>(function(app) {
app.AppComponent =
ng.core.Component({
selector: 'my-app',
t... | <p>Angular 2 application is building up from isolated from each other components. You can think about that like directives with isolated scope in AngularJS. So you should always pass to component value if you need it from outside. </p>
<p>There are no scopes in Angular2 it has something different called zones. But as ... |
I want to print the names of files present in a directory as a list using ansible <pre><code>---
- hosts: localhost
user: root
tasks:
- command: "ls /root/Tmp/Deployment/script_files/Hotfix"
register: dir_out
- debug: msg="The hotfix ids are: {{dir_out.stdout_lines}}"
</code></pre>
<p>The out... | <p>I needed to change: <code>{{dir_out.stdout_lines}}</code> to <code>{{dir_out.stdout_lines|join(',')}}</code></p>
|
Load/Refresh only part of a page (View) using AJAX in ASP.NET MVC <p>I am trying to achieve the same result as mentioned by the OP <a href="http://stackoverflow.com/questions/21170064/how-to-refresh-only-part-of-the-index-page-in-mvc-5/39607240#39607240">in this post</a> However when I try to render partial view by che... | <p>This is just an example how you can load view from AJAX without page refresh, it may help you.</p>
<p>It send text value to controller by ajax call and load that value in other view which replace main view, if you don't want to replace main view then you can take other div instead same div to load content.</p>
<p>... |
How to use Bootstrap Glyphicons with @Ajax.ActionLink() Method? <p>In the following code I would like to include a Bootstrap glyphicons after the "Animal Name". </p>
<pre><code>@Ajax.ActionLink("Animal Name", "_Index", new { sortOrder = ViewBag.NameSortParam, searchString = Request["searchString"] }, new AjaxOptions
... | <pre><code> @Ajax.RawActionLink(string.Format("<i class='icon'></i>Click Me"), "ActionResultName", null, new { item.Variable}, new AjaxOptions { HttpMethod = "Post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "taget-div", LoadingElementId = "target-div" }, new { @class = "class" })
</code></p... |
custom attributes version of accepts_nested_attributes_for with reject_if <p>I am trying to create a custom version of this below</p>
<pre><code> accepts_nested_attributes_for :categories, :reject_if => proc { |hash| hash['title'].blank? }
</code></pre>
<p>So far what i got is </p>
<pre><code> def categories_at... | <p>Do as this way</p>
<pre><code>accepts_nested_attributes_for :categories, reject_if: :title_blank
def title_blank(attributed)
data = false
data = true if attributed.title.blank?
return data
end
</code></pre>
|
Typescript 2: how to add to existing interface or type? <p>In <code>typescript 2</code>, the <code>window</code> object is of type <code>Window</code> -- an interface.</p>
<p>My code makes use of <a href="https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext" rel="nofollow"><code>OfflineAudioContext</co... | <p>You can add declarations to existing types, that's covered in the <a href="https://www.typescriptlang.org/docs/handbook/declaration-merging.html" rel="nofollow">Declaration Merging part</a> of the docs.</p>
<p>In your case you can do:</p>
<pre><code>type OfflineAudioContextConstructor {
new (num1: number, num2... |
Disabling text field by Javascript <p>I have a inputing HTML page that have text field and a check box for disabling that input field. </p>
<p>This is the JavaScript code for disabling the text field in a <code>.js</code> file.<code>value</code> is passing the field name for check box.</p>
<pre><code> function disa... | <p>It looks like you're disabling the checkbox instead of the textbox. Change the code from:</p>
<pre><code>function disable_input_field(value){
if ($("#undefined_" + value).is(":checked")) {
document.getElementById("undefined_" + value).disabled = true;
document.getElementById(v... |
Given a string, find the longest substring with the same number of vowels and consonants? <blockquote>
<p>Given a string, find the longest substring with the same number of vowels and consonants.</p>
</blockquote>
<p><strong>CLARIFICATION:</strong> I am unsure, whether we can generate a new string, or the substring ... | <p>To find the longest substring where the number of consonants and vowels are equal, start finding substrings at the largest length, and steadily decrease the length needed until you find a substring that matches the criteria.</p>
<p>This will allow you to short-circuit the operation.</p>
<pre><code>public static St... |
Consecutive run programming <p>I want to show the sentence "Hello" that is after finish process of <code>main</code> method:</p>
<ol>
<li>input name and it's correct, </li>
<li>ask age, and </li>
<li>correct going to sentence "booting up"</li>
</ol>
<p>which means I want to run method consecutively.</p>
<p>I only co... | <p>I believe what you want to do is call the hello method at the end of your main method. Also you are missing a <code>}</code> after <code>System.out.println("Hello");</code></p>
<p>Something like this:</p>
<pre><code>public class YourClassName {
public static void main (String [] theArgs){
//your code h... |
Count the number of Occurrence of Values based on another column <p>I have a question regarding creating pandas dataframe according to the sum of other column.</p>
<p>For example, I have this dataframe</p>
<pre><code> Country | Accident
England Car
England Car
England Car
USA ... | <p><strong><em>Option 1</em></strong><br>
Use <code>value_counts</code></p>
<pre><code>df.Country.value_counts().reset_index(name='Sum of Accidents')
</code></pre>
<p><a href="http://i.stack.imgur.com/G0Gii.png"><img src="http://i.stack.imgur.com/G0Gii.png" alt="enter image description here"></a></p>
<p><strong><em>... |
MvxExpandableListAdapter SetItemsSource is not called <p>I have this code snippet to using <code>MvxExpandableListView</code></p>
<pre><code>public class ExpandView : MvxActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.ExpandView... | <p>You need to set the property <code>ItemsSource</code>.Looking at the source of <code>MvxAdapter</code>:</p>
<pre><code>[MvxSetToNullAfterBinding]
public virtual IEnumerable ItemsSource
{
get { return _itemsSource; }
set { SetItemsSource(value); }
}
</code></pre>
<p>The setter of <code>ItemsSource</code> ca... |
Create uniqueID based on id mysql laravel 5 <p>I want to create uniqueID for column <strong>transid</strong> like autoincrement. but I already have a column <strong>id</strong> (autoincrement).</p>
<p>column <strong>transid</strong> should be 01000001 and autoincrement, or follow column <strong>id</strong> number.</... | <p>Try this, Hope this help you</p>
<pre><code>$temp_str = '00000000';
</code></pre>
<p>Last inserted id</p>
<pre><code>$obj_fund = Fund::get()->last();
$last_inserted_id = $obj_fund->id;
$temp_index = $last_inserted_id + 1;
$id_length = strlen($temp_index);
$temp_id = substr_replace($temp_str, $last_inse... |
Is there another way to use hasNextInt() in Java without putting everything in the if-statement? <p>My objective is to make sure the user inputs an <code>int</code>. Else, exit the program. Then I do some coding that requires that int.</p>
<p><strong>Code Snippet :</strong></p>
<pre><code>Scanner input = new Scanner(... | <p>Here is a simple example of using hasNextInt () to validate a positive integer input</p>
<pre><code>Scanner input = new Scanner(System.in);
int number;
do {
System.out.println("Input Number ");
while (!input.hasNextInt()) {
System.out.println(" not a number!");
input.next();
}
numbe... |
Class 'Vinkla\Instagram\InstagramServiceProvider' not found Error <p>I am new to PHP and Laravel, my colleague installed InstagramServiceProvider in his project and he pushed it into git, after pulled the code i am getting this error</p>
<p><a href="http://i.stack.imgur.com/IatTC.png" rel="nofollow"><img src="http://i... | <p>It's <a href="https://github.com/vinkla/laravel-instagram" rel="nofollow">a package</a>, so you need to install it on your machine too. Try to run <code>composer update</code> command and composer will download and install the package for you.</p>
|
How to implement a generic Thrift Proxy? <p>In Apache Thrift is it possible to create a generic proxy? For e.g. in proxy I want to do request/response logging or measure performance. The flow should be like Client <-> Generic Proxy <-> Server for all RPC calls.</p>
| <p>Implement an custom Thrift "layered" protocol or a custom Thrift transport which intercepts your calls as needed. </p>
<p>A lot of languages have adopted the <a href="https://issues.apache.org/jira/browse/THRIFT-1915" rel="nofollow">multiplexed protocol</a> which uses a generic <a href="https://github.com/apache/th... |
Ambiguous reference in swift3 <p>Hi after migrating to swift3. I m having this issue? Do your guys know what wrong?</p>
<p>ambiguous reference to member "/"</p>
<pre><code>let rateForPeriod = interestRate! / Double(100) / Double(K.monthsEachYear)
</code></pre>
| <p>If I were you, I would use <strong>optional binding</strong> to check whether <strong>interestRate</strong> is <strong>nil</strong> or not.</p>
<pre><code>let interestRate: Double? = 0.4
if let interestRate = interestRate {
let rateForPeriod = interestRate / Double(100) / Double(1)
}
</code></pre>
|
how to find running script in raspberry pi 3 <p>I have raspberry pi 3 and i m running python script at startup of raspberry pi using /etc/rc.local. I want to find which python script running in background so login using putty and i had run following command:</p>
<pre><code>ps aux|grep mail
</code></pre>
<p>so it disp... | <p>Use <code>ps -alx</code> and look at the PID and PPID fields, you find that the 'sudo python' process is the parent of the 'python' process. Sudo is an executable program that runs it's arguments as a sub-process.</p>
|
Remove Trailing Whitespace from JSON (ASP.NET API) <p>I'm having an issue with my asp.net REST API that I've created. The JSON string that is returned from a Get request has these trailing whitespaces shown below. </p>
<p>While doing webserches I found this link (<a href="http://stackoverflow.com/questions/19386354/re... | <p>Trim the values before generating the JSON or you can apply a foreach on the collection and remove the trailing spaces.</p>
<p>Hope it helps!!</p>
|
AutoScale Watch brings incorrect data in Softlayer API <p>I am trying to get trigger data, but the value of watch data bring wrong data. </p>
<pre><code> "algorithm": "EWMA",
"id": 135609,
"metric": "host.network.frontend.in.rate",
"operator": ">",
"period": 3600,
"val... | <p>For the case of network rate the information in the API is being stored in bytes, and in the portal the information is being displayed in mega bits.</p>
<p>So do this:</p>
<pre><code>converting bytes to bites
10485760 * 8 = 83886080
converting bites to kilo bites
83886080 / 1024 = 81920
converting kilo bites t... |
Is it possible to know the memory being allocated by the method "CreateSharedMemoryAndSemaphores"? <p>I am a newbie to databases and Postgres and I am analyzing the memory being allocated by Postgres in the method "CreateSharedMemoryAndSemaphores". </p>
<p>Like variable "size" starts with a default value of 100000 and... | <p>To figure out the <em>exact</em> amount each line contributes to the total, you'd have to read the individual function definitions.</p>
<p>But normally by far the largest part comes from</p>
<pre><code>size = add_size(size, BufferShmemSize());
</code></pre>
<p>where the space for the <em>shared buffers</em>, the ... |
Android RelativeLayout.LayoutParams can not cast to AbsListview.LayoutParams (Error below 4.4.4) Working fine on 5.0 & 6.0.1 <p>I have used a <code>ListView</code> and the parent in the <code>xml</code> is <code>RelativeLayout</code>.
When I run the app on 4.4.4 it gives me <code>ClassCastException</code> but when I ru... | <p>Here you're replacing existing layout params of correct type <code>AbsListView.LayoutParams</code> with more generic <code>RelativeLayout.LayoutParams</code>. </p>
<pre><code> RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.getInstance().dpToPx(mCon... |
ActiveRecord query through multiple relations <p>I would like to make query where i get all class A which are in relations with class D, with particular name (class D has name column). But there are also class B and C between and actually i don't know how can i handle this with joins and merges.</p>
<p>The relationshi... | <p>You can try this:</p>
<pre><code>Appointment.joins(classes: [:teacher]).where(teachers: { name: "your_name" }) #"your_name" is the name to be matched with the value in name column of Ds table
</code></pre>
|
Can I get location access without generating the default popup in iphone? <p>I am working on an app that requires location access. I created a view controller asking the user to allow or not with 2 buttons. But when I click the allow button, device is generating it's own popup asking the user for location access. Can I... | <p>No you cannot avoid system popup. As per apple</p>
<blockquote>
<p>Always request authorization at the point where you actually plan to
use location services to perform a task. Requesting authorization may
display an alert to the user. If it is not clear to the user that your
app is using location services ... |
Check if image file is available in curl when save facebook profile image. PHP <p>In my project, when user log in from <code>Facebook</code>, the profile picture will be saved. It is working. But if there is no image, then also a <code>0 Byte</code> file is saving. </p>
<p><strong>How can I check the url contains imag... | <p>You can always check curl returned header info with <code>curl_getinfo()</code> (more at <a href="http://php.net/manual/en/function.curl-getinfo.php" rel="nofollow">php.net</a>)</p>
<p>So in your case you can <code>curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD)</code> to see how much bytes are returned. </p>... |
Google FooBar unexpected failed valuation <p>I am working on a Google FooBar challenge and the test case doesn't seem to be correct; below is the highlight.</p>
<pre><code>return the product of non-empty subset of those numbers. Example [2, -3, 1, 0, -5],
would be: xs[0] = 2, xs[1] = -3, xs[4] = -5,
giving the prod... | <pre><code>[-2, -3, 4, -5] = -120
</code></pre>
<p>so the subset which has a highest product is</p>
<pre><code> [-3,4,-5] = 60
</code></pre>
<p>, -2 should be excluded from subset to get the maximum product.</p>
|
How to untrack added file ending with certain character from git? <p>I accidentally added all files from my local folder into my git repository. I want to untrack some of files ending with certain symbol, like "~" etc. How can I do this? Since I already added them into the repository, any edit in .gitignore will not un... | <p>This is not exactly the same question, so I won't mark as duplicate, but the second answer <a href="https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore">here</a> should apply.</p>
<hr>
<h1>Quoted answer:</h1>
<p>The series of commands below will... |
interleave nested ist of vectors in r with string padding based on max nchar in innermost nest <p>I have a nested list of vectors in r where each vector has a different count of elements and each element contains a string of differing length as follows:</p>
<pre><code> x <- list(
A=list(
c("11","11","11111... | <p>It should be convenient to elongate each element with a sufficient number of <code>""</code> to conveniently find the maximum elementwise <code>nchar</code> and, later, <code>rbind</code> to interleave as in the linked post:</p>
<pre><code>n = do.call(max, lapply(x, lengths))
x2 = lapply(x, function(ab) lapply(ab, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.