input
stringlengths
51
42.3k
output
stringlengths
18
55k
Add border to ImageView Android for cropping <p>I want to add a rectangular border on my <code>ImageView</code> which allow users to change it's size from 8 directions to provide them a preview for cropping purpose.</p> <p>Which way I can implement to achieve my purpose best, defining a custom <code>ImageView</code> a...
<p>Here's how i solved, by defining a custom image view and make some change in OnDraw method, i also added code to reduce brightness of image so it looks nice with a background image behind the real when you resize the rectangle:</p> <pre><code>import android.content.Context; import android.graphics.Bitmap; import an...
One process writing while the other one reads the shared memory <p>I have 2 programs (processes). One process writes to shared memory while the other reads it. So, my approach was like this: Initially, value of shared memory is 0. So, process 1 writes only when value is 0. Now process 1 has written some other value to ...
<p>Mentioned problem known as Process Synchronization problem and given logic is nothing but Busy Waiting approach of the problem which is very primary solution.</p> <p>Read <a href="https://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem" rel="nofollow">Producer-Consumer Problem</a> which is similiar to given...
Score variable won't update, and must be final? <p>The issue I'm having is that my score counter variable 'score' cannot go higher than 1 in my program. If the user inputs a value equal to the random number displayed (LoadG1), they are awarded a point. This is then outputted at the end, as shown in the longer timer. In...
<p>Because you are not reading the random value that you have generated, just the first one. So the first time the answer is correct, but next time you answer different, but the <code>if</code> compares to the firstly generated random number, so it is not counting as valid answer (if you enter same first number all tim...
Iterating through tables in Excel mac using office js is not working <p>I am trying to iterate through tables in Excel using office js</p> <p>Here is the code sample(same as one in the docs here <a href="https://github.com/OfficeDev/office-js-docs/blob/master/reference/excel/tablecollection.md" rel="nofollow">https://...
<p>We tried to repro the issue, but are not getting the "General Exception". We are getting an error in the first example of "PropertyNotLoaded", though that's understandable in the sense that the sample is slightly incorrect, the load statement should be <code>tables.load('name, count')</code> instead of <code>tables...
Redirect visitor to his/her SO profile from my profile <p>I want to add a link in my profile which will redirect the visitor to his/her profile when it will be <code>clicked</code>.</p> <p>I came across a profile few week ago(tried to find account but no luck ) which has the same implementation like as written below</...
<p>I been trying since from two days and finally i just managed to do this by just making a small amendment to my code , no <code>javascript</code> required. Hurrraah!</p> <p>All i needed to do was, add <strong><code>/current</code></strong> at the end of my URL's <strong><code>href</code></strong> link which will tak...
Swift - Predicate to filter an array by a property of member array <p>I need to filter out an array of MyClass3 Objects. An array of MyClass2 Objects is a member of MyClass3 object(Please refer to code below). MyClass2 object has an id. I have an idArray at hand. I need to filter out those MyClass3 objects in which all...
<p>You can do using perform intersection operation instead of NSPredicate:</p> <p>Refer below link for this </p> <p><a href="http://stackoverflow.com/questions/24589181/set-operations-union-intersection-on-swift-array?answertab=votes#tab-top">Set operations (union, intersection) on Swift array?</a></p>
Issues while trying to collect nested lists in Drools <p>I am facing some difficulties while trying to write a rule with Drools (6.4.Final). Either my rule is not completely correct, or I am ending up writing several rules for the same goal but without conviction. I'd like to get your opinions based on your experience...
<p>A simple approach would be to collect all sums per year in one pass over all E and R and return a <code>Map&lt;YearType,BigDecimal&gt;</code> where <code>YearType</code> combines a year and a type, and you can extract the Entry objects to inspect the BigDecimal etc. etc.</p> <p>I'm not sure whether you can write a ...
Unable to save merged articles <p>So I'm trying to create a feature for Typo (blogging app) that merges two articles in one. For some reason, I can't manage to save the merged article. I have followed several threads here, read over and over Rails and Ruby docs... And Can't figure out why it doesn't work</p> <p>Beside...
<p>You did not mentioned what problem you are facing while saving, you just said you could not manage to save so I can't help you with that unless you provide some stack trace. I will mention a few things though:</p> <p>first is in your controller method you have multiple redirection code like <code>redirect_to :actio...
Validation error An invalid form control with name='' is not focusable <p>I had a html form with set of input fields for each of which I am giving <code>required="true"</code> for validation. But when I click on submit after entering the mandatory fields it is give an error:</p> <blockquote> <p>An invalid form contr...
<p>The answer is very simple name and ID has to match for the angular, or it won't be able to find it</p> <pre><code>&lt;form name="customerForm" id="customerForm" </code></pre> <p>here is the plunker which is just copy paste of your code but with the fields adjusted <a href="https://plnkr.co/edit/z8WaJF6QetQZxMR5pwa...
avoid daemon running in dedicated cpu cores <p>I have grub set isolcpus=2 in my linux 3.10.0-327.el7.x86_64 , what I want is avoid the kernel scheduler not to schedule task to cpu core 2 , then I have the</p> <pre><code>perf record -e sched:sched_switch -C 2 </code></pre> <p>to see what is going on in core 2 and...
<p>The program 'schedtool' maybe helpful, it can limit the process to run on specified cpu(s). according to the help of that utility. To set a process' affinity to only the first CPU (CPU0): #> schedtool -a 0x1 replace the parameters 0x1 and PID according your exactly requirement.</p>
Update button text through inputfield <p>Is there a way to update button text dynamically while some value is being entered in an input field.</p> <pre><code>&lt;input class="paymentinput w-input" type="tel" placeholder="0" id="amount-field"&gt; &lt;button id="rzp-button1" class="paynowbutton w-button"&gt;Pay Now&lt;/...
<p>is this something you want done ?</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>$('.myName').keyup(function(){ if ($(this).val()==""){ $('button').text("Pay Now"...
How does the framework know that `ModelState.IsValid` must be true in HTTPGET but false in HTTPPOST when the form fields are invalid? <p>Consider a simple data model <code>Student.cs</code> as follows,</p> <pre><code>class Student { [Required(ErrorMessage="Please enter your name.")] public string Name {get;...
<p>When you make a request (either GET or POST), the <code>DefaultModelBinder</code> reads values from the request (query string parameter, route values, form values etc), initializes any parameters in your method, and attempts to set their values.</p> <p>In the case of your GET method, you do not have a model as a pa...
ruby on rails marketplace and stripe <p>I am building a two side marketplace with RoR, and i want to use stripe to handle the payment.</p> <p>I want the user to do a request and pay, (but using capture false, to charge later), and charge (or cancel) when the user providing the service accept or deny the request.</p> ...
<p>First, you'd <a href="https://stripe.com/docs/api#create_charge" rel="nofollow">create the charge</a> with <code>capture</code> set to <code>false</code>:</p> <pre><code>charge = Stripe::Charge.create({ amount: 1000, currency: 'usd', destination: 'acct_...', application_fee: 200, capture: false, }) </code...
O(1) Constant time solution example? <p>I have a task which requires calculating a frog jumping from position X to a position greater than or equal to Y, given a fixed distance each jump (D).</p> <p>E.g X = 10; Y = 85; D = 30; Answer = ((Y-X)/D) = 3;</p> <p>The solutions complexity must be <strong>O(1)</strong>.</p> ...
<p>Obvious solution would be to round it up.</p> <pre><code>int diff = Y-X; int jumps = std::ceil((double)diff/D); </code></pre> <p>This is an O(1) operation and avoids looping to find the required number of steps.</p>
Inherited constructors, default constructor and visibility <p>As stated by <a href="http://eel.is/c++draft/namespace.udecl#18" rel="nofollow">[namespace.udecl]/18</a>:</p> <blockquote> <p>[...] A using-declaration that names a constructor does not create a synonym; instead, the additional constructors are accessible...
<pre><code>class B { protected: B() { } }; class D: B { using B::B; }; int main () { D d{}; } </code></pre> <p><code>D</code> has no user-defined constructor in this case, so the compiler generates one (public) for you that calls <code>B::B</code> (but not because of the <code>using</code>, that has no effect in this ...
Saving image in python <p>I'm new to python. What I want to do is to read in an image, convert it to gray value and save it.</p> <p>This is what I have so far:</p> <pre><code># construct the argument parser and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-i", "--image", required=True, help="Pa...
<p><strong>Method 1: save method</strong></p> <pre><code>im_grey.save('greyscale.png') </code></pre> <p>Use Image_object.save() method</p> <p><strong>Method 2: imsave method</strong></p> <pre><code>import matplotlib.image as mpimg mpimg.imsave("greyscale.png", im_grey) </code></pre>
MySQL Function IF() do not return the value that i declare <blockquote> <p>i want my function to return "INC" when put "INC" inside the function parameters</p> </blockquote> <pre><code>SELECT getEquivalentGrade('INC'); </code></pre> <blockquote> <p>Output: INC</p> </blockquote> <pre><code>DELIMITER $$ USE `nmsc...
<p>You should move the INC to the TOP </p> <pre><code>IF (grade='INC') THEN SET equivalent_grade = grade; ELSEIF (grade &gt; 100) THEN SET equivalent_grade = '1'; ELSEIF (grade &lt; 69) THEN SET equivalent_grade = '5'; ELSE SET equivalent_grade = (SELECT equivalent_grade.`equivgrade` FROM equivalent_grade WHERE equ...
Execute a Program with arguments <p>I want to build a PowerShell script for invoking Python3. Now in shell this would be pretty simple but I cannot seem to get the following converted to PS:</p> <pre><code>../py/python3 myscript.py $@ </code></pre> <p>I am lost somewhere in the maze of <code>Start-Process</code>, <co...
<p>PowerShell is a shell, so for the most part, running programs is what it does well. I'm guessing you're converting a Unix shell script which is where <code>$@</code> comes from. The equivalent in PowerShell for that would probably be <code>$args</code> or <code>@args</code>:</p> <pre><code>../py/python3 myscript.py...
State design pattern in compliance with Liskov <p>I am designing an order system and the state design pattern seems appropriate because the order can change its state and thereby the allowed functionalities for the order. Below is my basic class diagram:</p> <p><img src="https://i.stack.imgur.com/QRbP5.jpg" alt=""></p...
<p>What you are showing is not State pattern. State pattern alters object behavior when its internal state changes. For example, a light switch can turn on or turn off the light when you toggle it, depending on its state (different behavior on the same method).</p> <p>With this Order interface (4 diff methods) I don't...
Invalid syntax error at end <p>I am getting invalid syntax error for end in below line </p> <pre><code>print("\t" **end** = " ") </code></pre> <p>Below is the code -</p> <pre><code>def print_lol(the_list,level): for each_item in the_list: if isinstance (each_item,list): print_lol(each_item,l...
<p>it should be like these:</p> <pre><code>print("\t", end = " ") </code></pre> <p>also please note that for good practice make the indentation of your <code>else</code> statement the same with the <code>if</code> statement indentation.</p>
Where is define codeigniters rewrite rules for recognizing controller,method,id in segment? <p>how codignitetr recognzes controllername,methodname,id from url like:</p> <p><a href="http://stackoverflow.com/controllername/methodname/id">http://stackoverflow.com/controllername/methodname/id</a></p>
<p>The most used method for this is <code>CI_URI-&gt;segments();</code> </p> <p>Read more here: <a href="https://www.codeigniter.com/userguide3/libraries/uri.html#CI_URI::segment" rel="nofollow">https://www.codeigniter.com/userguide3/libraries/uri.html#CI_URI::segment</a></p> <blockquote> <p>So, each / after your h...
How to change entity name in flash message <p>After editing an object I got this flash message</p> <blockquote> <p>L'élément "P\BOBundle\Entity\Distributeur:0000000037396bc6000000006e8ad34e" a été mis à jour avec succès.</p> </blockquote> <p>So I need to change the entity name in this message: <code>P\BOBundl...
<p>the best solution is to override </p> <blockquote> <p>__toString</p> </blockquote> <p>methode in the entity class and make it return the name of object. </p>
Read HBase table with where clause using Spark <p>I am trying to read a HBase table using Spark Scala API.</p> <p><strong>Sample Code:</strong></p> <pre><code>conf.set("hbase.master", "localhost:60000") conf.set("hbase.zookeeper.quorum", "localhost") conf.set(TableInputFormat.INPUT_TABLE, tableName) val hBaseRDD = sc...
<blockquote> <p><strong>Q : How to add where clause if i use <code>newAPIHadoopRDD</code> ? Or we need to use any Spark Hbase Connector to achieve this?</strong></p> </blockquote> <p>Answer</p> <ul> <li><p>SparkOnHBase project in Cloudera provide support for spark hbase integration on RDD level.</p></li> <li><p>If ...
Uploading blob to Azure with Unity <p>I am trying to upload data to a blob service on Azure portal. </p> <p>I have been trying to use this page: <a href="https://msdn.microsoft.com/library/azure/dd179451.aspx" rel="nofollow">https://msdn.microsoft.com/library/azure/dd179451.aspx</a></p> <p>The code I have is the foll...
<p>Can't tell why this is happening but you can use <a href="https://github.com/dgkanatsios/AzureServicesForUnity" rel="nofollow">this</a> plugin to communicate with your Azure service. It will solve your problem.</p> <p><strong>EDIT</strong>:</p> <p>After reading the MS link you posted, the problem is that you are m...
Some server garbled when use UrlConnection? <p>I use below code to post some data,but i find In some server the response string is garbled(not all servers).</p> <pre><code> URL url = new URL("http://url"); HttpURLConnection connection = (HttpURLConnection) url .openConnection(); connection.setDoOutput(true)...
<p>Don't use <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#getBytes--" rel="nofollow"><code>String#getBytes()</code></a> it will decode your <code>String</code> using the <strong>platform's default charset</strong> which means that it is <strong>platform dependent</strong>. Moreover as you ha...
How to implement an infix calculator with precedence and associativity <p>I'm testing the example of writing an infix calculator using bison flex. I found that everything is right except for the brackets "()". I find that when I input a calculation with brackets, the calculation result is incorrect. Here is the code fo...
<p>It looks like you have to declare <code>(</code> and <code>)</code> as tokens for this to work.</p> <p>Add the following two lines before the final <code>%%</code> in your lex file:</p> <pre><code>"(" return LEFT; ")" return RIGHT; </code></pre> <p>Then add</p> <pre><code>%token LEFT RIGHT </code></pre> <...
Dynamic Textarea/Input Character Counter <p>I have a basic HTML form with multiple dynamic textareas and input field in them. Some of these fields already have information stored being pulled out from a database.</p> <p>What I need is a character counter that can detect the amount of characters <strong>remaining</stro...
<p>just like @MayankPandeyz code some editing</p> <p>var text_length,text_remaining;</p> <pre><code>$(document).ready(function() { var text_max = 99; $('#textarea_feedback').html(text_max + ' characters remaining'); function whenLoad (){ text_length = $('#textarea').val().length; text_remaining = text_max ...
Jenkins cannot find the external Jars added for the selenium project through Eclipse <p>I have a Maven project in Eclipse. My project is for Automation Testing. So in my pom.xml I've all dependencies added.</p> <p>For example: Testng, Cucumber, Selenium-java etc..</p> <p>I have installed Jenkins and configured my aut...
<p>You have set up a jar only with the eclipse build path so it only accessible for eclipse</p> <p>while with the Jenkins you only setup a maven project so Jenkins is trying to find it's required dependency from POM.xml. it is not able to find the jar that is from eclipse build path.</p> <p>You have to find maven dec...
Wants copyright information of OSS components <p>I want ot take copyright information of all open source components which are used for embedded system.Is there any short way to get the copyright information of OSS components?</p>
<p>That <strong>very</strong> much depends on your concrete setup; which of course you completely fail to describe here. How should we know which OSS components you are using in your embedded system?!</p> <p>But the general answer is: there is <strong>no</strong> detour. When your product is using OSS components, and ...
Orientation change in cordova mobile app <p>Please can suggest the below questions</p> <ol> <li>How can i maintain the server data(JSON) while mobile has changed the orientation like portrait to landscape and landscape to portrait using cordova in android, iOS and WP.</li> </ol> <p>I don't want reload again the if th...
<p>To display many records in mobile phone or web, I recommend using a table called DataTables (<a href="http://www.datatables.net" rel="nofollow">www.datatables.net</a>). It is developed in JavaScript and has MIT license. It is very simple to use and it can be customized.</p> <p>Best regards!</p>
DataTrigger RelativeSource WPF XAML <p>The thing I want to make When mouseover in grid Border <em>Visibilty</em> property value must change.</p> <p>I have a grid with a 3 ColumnDefinition.</p> <p><a href="https://i.stack.imgur.com/nqQId.png" rel="nofollow"><img src="https://i.stack.imgur.com/nqQId.png" alt="enter ima...
<p>one thing is that you should not use <code>IsReadOnly</code> property in DataTrigger when MouseOver is required.</p> <p>another one is that local value <code>Visibility="Hidden"</code> has higher priority than DataTrigger setter <code>&lt;Setter Property="Border.Visibility" Value="Visible" /&gt;</code> and will not...
ng-if in select option selected tag <p>I am developing Angular JS application and I want to make a select option like below.</p> <pre><code>&lt;select class="form-control" ng-model="rc.status" ng-init="rc.status=1"&gt; &lt;option value="1" selected="selected"&gt;Active&lt;/option&gt; &lt;option value="0" selec...
<p>Here is example that select dropdown value as per <code>rc.status</code></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/a...
Angular2 need to know things to learn and create demo with database connectivity <p>I need to know the process and fundamental flow of angular2 and what things I should to know before start angular2, I want to create two demo one is simple demo without database connectivity and another is with database connectivity Ple...
<p>I started Angulra by using the angular tutorial itself: </p> <p><a href="https://angular.io/docs/ts/latest/tutorial/" rel="nofollow">https://angular.io/docs/ts/latest/tutorial/</a></p> <p>"Database connectivity" depends on the kind of webservice you implement to get your data. I used asp.webservices and now moved ...
OnCurrent event firing when moving from first record to the last but not from last to the first <p>I have the code below which is supposed to enable and disable the amount field on the main form and the purchases and sales subforms based on the value in the transaction type field. Now it works perfectly on the forward ...
<p>You never enable that field, so you may need this modification:</p> <pre><code>Select Case Me.transactionType.Value Case 1 Me.Amount.Enabled = True Me.PurchaseOrderDetails_subform.Enabled = False Me.SalesOrderDetails_subform.Enabled = False </code></pre>
How to use ajax in codeigniter? <p>I am trying to make a very simple php chat for my website with CodeIgniter and Ajax. The messages are saved in a html file, not in a database table. Whenever I click the send button, the page refreshes, even though it's not supossed to and I don't know what's wrong. Here is my code: ...
<ol> <li><code>var postData = $(#message).serializeArray();</code> should be:<br> <code>var postData = $("#message").serializeArray();</code></li> <li>If issue still not get resolved then try to debug by putting <code>alert()</code> or <code>console.log()</code> before <code>e.preventDefault()</code> and then debug you...
Recording locations in time domain with AVFoundation <p>I followed a lot of tutorials and every tutorials about recording in AVFoundation covers only recording Video or Audio or both of this things.</p> <p>I would like to record some location in the same time domain like Video/Audio on separate track. This location wa...
<p>Sure, this is possible.</p> <p>AVFoundation is a collection of higher and lower level libraries with lots of options to tap into the processing pipeline at various stages. Assuming you want to capture from the Camera, then you're going to be using some combination of AVCaptureSession, its delegate <a href="https:/...
HTTP ERROR: 404 solr not running <p>Yesterday if was opening <a href="http://my-ip:3000/solr" rel="nofollow">http://my-ip:3000/solr</a> then the home page is opening of Solr. But today I restarted VM after that is showing me like that.</p> <pre><code>HTTP ERROR: 404 Problem accessing /solr. Reason: Not Found P...
<p>You may need going to the Solr directory: <code>cd solr-6.2.0/</code> and launching it: <code>bin/solr start</code> The Solr admin UI will run on the port 8983 by default: <code>http://localhost:8983/solr/</code>. However, the support for deploying Solr 5.0 and newer on Jetty is <a href="https://cwiki.apache.org/con...
Javascript: add function as parameter to predefined callback function <p>I have this code that uses a cordov/phonegap plugin:</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...
<p>Try this</p> <pre><code> var app = { init: function() { sensors.getState(app.callback); }, test: function() {}, setCallback: function(callback) { app.test = callback; }, callback: function(state) { app.test(); }, firstFunction() { alert("firstFuncti...
Count doesn't give back 0 <p>I have a table where I must recover for each month the count of Groups that will be taking lessons, this check has to be done every three months, the final output should be this:</p> <pre><code>Gruppi A nel mese di Luglio 20 Gruppi A nel mese di Agosto 18 Gruppi A nel mese di Settemb...
<p>I think you may rewrite your query like that. </p> <ol> <li>If you want see groups without REVIEW you should yse left join. </li> <li>Why you get data twice with the equal param (I delete it from my query)</li> <li>For total you may use group by rollup()</li> <li>IMHO/ You may use trunc(date.'mm') for comparing dat...
VBA Word : Error 5174 when Documents.Open with filename including pound sign # <p>In Microsoft Word 2010 VBA</p> <p>I am getting a runtime error 5174, when trying to open a document which file name includes a pound sign "#", with a relative file path.</p> <pre><code>Sub openPoundedFilename() Dim doc As Object ...
<p>To open the file using a relative path you need to URLEncode the filename. There is no built-in support in VBA for doing so (besides in <a href="http://stackoverflow.com/a/24301379/40347">newer Excel versions</a>), but you can use @Tomalak's <strong><a href="http://stackoverflow.com/a/218199/40347"><code>URLEncode</...
Unit tests are failing when run from dotCover <p>I have a TFS 2015 build which builds one of our applications (it's an ASP.NET Web API application). As part of the build process it runs our unit tests.</p> <p>I have a <em>Visual Studio Tes</em>t build step which runs these unit tests and they all pass okay.</p> <p>I ...
<p>Make sure your build service account have enough permission to run the dotcove.exe. According to your <code>E:\JetBrains\Installations\dotCover05\dotCover.exe</code> Seems you didn't install for <strong><em>all users</em></strong> on the build agent. Which should installed under <code>%ProgramFiles(x86)%</code> no...
Remove rows of a csv file which are in another csv file <p>I have two Excel files, I want to remove rows from the first file excel1 who are not in the second file excel2 with an R insctruction.</p> <p>Here is my escounted result. What should I do ?</p> <p><a href="https://i.stack.imgur.com/R55pq.png" rel="nofollow"><...
<p>You can read the csv files first</p> <pre><code> excel1&lt;-read.csv("excel1.csv", header=T) excel2&lt;-read.csv("excel2.csv", header=T) excel1.excel2&lt;-setdiff(excel1, excel2) </code></pre> <p>You can also refer to this post to help you prepare reproducible examples: <a href="http://stackoverflow.com/question...
Count consecutive values in groups with condition with dplyr and rle <p>My question is very similar to the one posed below, however I want to add an additional command to return only cases when a sequence has more than 2 consecutive values. </p> <p>How do I count the number of consecutive "success" (i.e. 1 in $consec)...
<p>We need to create a logical index with <code>lengths</code> and get the <code>sum</code> of it</p> <pre><code>df %&gt;% group_by(Era, Year) %&gt;% do({ tmp &lt;- with(rle(.$consec), sum(lengths &gt; 2)) data.frame(Count = tmp)}) # Era Year Count # &lt;dbl&gt; &lt;dbl&gt; &lt;int&gt; #1 1 1 ...
Selecting different columns from databases <p>Hello I have two databases and each has the same tables. For example I have table called <code>world</code> and it has 4 columns: <code>pkey1</code>, <code>pkey2</code>,<code>companyid</code>, <code>company_name</code></p> <p>I made a query which searches for rows which ha...
<p>If your databases are linked, you can join both tables and with "case" statement check if the value has changed:</p> <pre><code>select a.pkey1, a.pkey2, case when a.companyid &lt;&gt; b.companyid then a.companyid else null end as companyid, case when a.company_name &lt;&gt; b.company_name then a.company_name else...
Django 1.10.2 error "NoReverseMatch at " ,"Reverse for 'django.contrib.auth.views.login' with arguments '()' and keyword arguments '{}' not found." <p>I am new to python &amp; Django. I am getting one error and have absolutely no idea how to solve it. Any help will be appreciated. <a href="https://i.stack.imgur.com/4Cw...
<p>Add a <code>name</code> to the login <em>url pattern</em>:</p> <pre><code>kwargs = {'template_name': 'login.html','authentication_form': LoginForm} ... url(r'^login/$', auth_views.login, kwargs=kwargs, name='login'), # ^^^^ </code></pre> <p>and then use that <code>n...
R - Convert Date Time as character into Seconds (numeric) <p>I am reading data time value from csv file stored as below</p> <pre><code>"2013-08-01 00:10:46" "2013-08-01 00:10:51" "2013-08-01 00:10:53" "2013-08-01 00:11:04" "2013-08-01 00:11:06" </code></pre> <p>While reading it is read as character and i want to conv...
<p>You can use <code>lubridate</code>.</p> <p>According to the following test, it can be around 12 times faster:</p> <pre><code>library(lubridate) ttt &lt;- c( "2013-08-01 00:10:46", "2013-08-01 00:10:51", "2013-08-01 00:10:53", "2013-08-01 00:11:04", "2013-08-01 00:11:06" ) t &lt;- Sys.time() q ...
Connecting Apache Spark with couchbase <p>I am trying to connect spark application with Couchbase. For this i am applying the following code.</p> <pre><code>double[] val=new double[3]; SparkContext sc = new SparkContext(new SparkConf().setAppName("sql").setMaster("local").set("com.couchbase.nodes", "url").set("com.cou...
<p>Below are the minimum dependencies you need to connect to Couchbase using Spark 1.6</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.apache.spark&lt;/groupId&gt; &lt;artifactId&gt;spark-core_2.10&lt;/artifactId&gt; &lt;version&gt;1.6.2&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;g...
Insert multiple rows into mysql database (items separated by comma) <p>need help...!!! i have 2000 number of values like (3458,1356,....n) i want to post them from html input field as $_POST['roll']; along with few other columns which has similar values like board (dhaka,dhaka,dhaka) .. i want to insert them into data...
<p>At first, you can use php <code>explode()</code> function to make an php array. Then you INSERT your data using loop depending on Array size.</p> <p>Code Example :</p> <pre><code>$roll = array(); $board = array(); $roll = (explode(",",$_POST['roll'])); $board = (explode(",",$_POST['board'])); $arraySize = sizeof...
How can i use environment variable in systemd timer unit? <p>A have a systemd service to execute some shell. I want to start this systemd service with a systemd timer. I need to make the value for OnCalendar configurable for devops.</p> <p>My first attempt was to provide a config file with key TIMER_ONCALENDAR, load i...
<p>If you aren't sure about a directive, like <code>Environment=</code>, you can use <code>man systemd.directives</code> to find which man page the directive is documented. </p> <p>In this case, it's documented in <code>man systemd.exec</code>, which explains that <code>Environment=</code> works in 4 types of unit fil...
Nodejs persist a sqlite in-memory database <p>I'm using the nodejs sqlite library (<a href="https://github.com/mapbox/node-sqlite3" rel="nofollow">https://github.com/mapbox/node-sqlite3</a>). How can i persist an in-memory database to disk? Since in the c/c++ implementation there are the backup api how can i persist in...
<p><a href="http://stackoverflow.com/q/1437327/11654">Using the backup API</a> is the only way. And Node.js does not implement this API.</p> <p>Just use a normal, on-disk database. You can make it as unsafe as an in-memory database with <a href="http://www.sqlite.org/pragma.html#pragma_synchronous" rel="nofollow">PRAG...
Minimum time to shift given weight boxes from one position to other when capacity of machines are given <p>Given n boxes of different weights and m machines of different weight carrying capacity. Find the minimum time required to move all boxes. </p> <p>Machines Capacities : C[0] , C[1] , C[2],........C[m-1].</p> <p>...
<p>Sort the machines in descending order of weight carrying capacities.</p> <p>Sort the boxes in increasing order of weights.</p> <p>Now, add boxes one by one to each machine until the weight carrying capacity of the machine exceeds.</p> <p>When it exceeds then move to the next machine.</p> <p><strong>Pseudocode:</...
Receive POST information from callback, Android WebView <p>My scenario is this: we point the user to a form where they fill in the data (3DSecure) and then POST, the website then POSTS the response to a callback URL - this response is what I want to capture. <code>WebView.shouldInterceptRequest()</code> can get the hea...
<p>I used this gentleman's library: <a href="https://github.com/LivotovLabs/3DSView" rel="nofollow">https://github.com/LivotovLabs/3DSView</a></p> <p>If one was looking to do this with something other than 3DSecure they could use it as a template.</p>
How to insert into type text <p>I wish to insert into an SQL table in a field whose data type is text. However I am informed of an error saying ' check datatype' my Name field is of type nvarchar and my job field is of type text.</p> <pre><code>INSERT INTO Table1 (Name, Job) VALUES ('John', 'Clerk') </code></pre>
<p>In MS SQL Server, you wont be able to insert string values(with more than 1 characters) in table if the column of type nvarchar. You can only insert only one character using nvarchar. </p> <p>If you wish to insert some text, please specify the some size with nvarchar.</p> <p>For example in your case: </p> <pre><...
Programatically tell the difference between data <p>Im converting mass files to XML and each file is either XML, JSON, CSV or PSV. To do the conversion I need to know what data type the file is without looking at the file extension (Some are coming from API's). Someone suggested that I try parse each file by each of th...
<p>You can have some kind of "pre-parsing":</p> <ul> <li>Either it starts with an XML declaration, or directly with the root node, first character of an <a href="https://en.wikipedia.org/wiki/XML" rel="nofollow">XML file</a> should be <code>&lt;</code>.</li> <li>First character of a <a href="http://json.org/" rel="nof...
How to calculate hours worked in month <p>I made a program in C# windows forms application, that you input the day, and hour and minutes you start work, and hour and minutes you finish work on this day. (for example: day 15, hour1: 8, min1: 0. hour2: 17, min2: 40). and it calculate the hours you worked in the current ...
<p>The <a href="https://msdn.microsoft.com/en-us/library/system.timespan.aspx" rel="nofollow">TimeSpan</a> type provides the <a href="https://msdn.microsoft.com/en-us/library/system.timespan.op_addition.aspx" rel="nofollow">TimeSpan.Addition Operator</a>:</p> <blockquote> <p>The Addition method defines the addition ...
Horizontal and Vertical navigation inside div using arrows along and down the text <p>I have a HTML <strong>div</strong> with multi line(more than one line) of text. I need to enable horizontal and vertical navigation using keyboard arrows(<strong>up, down, left , right</strong>) as in html input fields(text-area, text...
<p>You can make a div editable by adding contenteditable attribute to true</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id='enabled_arrow_navigation' contente...
Adding items to a dictionary using a function <p>I'm trying to add items to a dictionary using a function, I'm not getting any error message but when I want to display the dictionary items nothing is shown, I'm always getting "Empty".</p> <pre><code>Function Store_Params() Dim aDictionary Set aDictionary = CreateO...
<p>This section of your code doesn't make any sense.</p> <blockquote> <pre><code>For irow = 1 To 10 If InStr(1, objExcel1.Cells(irow, 1).Value, "#") = 0 And InStr(1, objExcel1.Cells(irow, 2).Value, "#") = 0 And InStr(1, objExcel1.Cells(irow, 3).Value, "#") = 0 And InStr(1, objExcel1.Cells(irow, 4).Value, "#") = 0 Th...
Enable autocomplete when loaded by AJAX <p>trying to get my head around this problem:</p> <p>I often load fragments of page via .load() function such as:</p> <pre><code>&lt;div class="fragment_load"&gt; &lt;form&gt; &lt;input id="typeaway" type="text" class="autocomplete"/&gt; &lt;label&gt;Test Type&lt;/l...
<p>In this case you could put the <code>autocomplete</code> initialisation code within the callback of the <code>load()</code> method, something like this:</p> <pre><code>$('#foo').load('bar.html', function() { $("#typeaway").autocomplete({ serviceUrl: "/restaway", minChars: 3, paramName: "...
Bonus points system <p>Here is my circle touch code:</p> <pre><code>scoreLabel.run(SKAction.sequence([SKAction.wait(forDuration: 1.0), SKAction.fadeIn(withDuration: 1.0)])) let positionOfTouch = touch.location(in: self) let tappedNode = atPoint(positionOfTouch) var nameOfTappedNode = tappedNode.name if nameOfTappedN...
<p>You have to get the touch position and check how many 'circle views' are in that point.</p> <p>you can get the touch location using </p> <pre><code>override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) { var touch = event.allTouches()!.first! var location = touch.location(inView: ...
tornado.locks.Lock release <p>The tornado example gives the following example for locks:</p> <pre><code>&gt;&gt;&gt; from tornado import gen, locks &gt;&gt;&gt; lock = locks.Lock() &gt;&gt;&gt; &gt;&gt;&gt; @gen.coroutine ... def f(): ... with (yield lock.acquire()): ... # Do something holding the lock. ... ...
<p>Right, the <code>with</code> statement ensures the Lock is released, no need to call <code>release</code> yourself.</p> <p><code>release</code> is naturally non-blocking -- your coroutine can complete a call to <code>release</code> without waiting for any other coroutines -- therefore <code>release</code> does not ...
What is the best for develop front end of java EE application (JSF or angular js)? <p>I want to develop application using java spring,strut and hibernate.So I want to make front for this application.Now I have two options to make front.They are angular 2 or JSF.Therefore i want to clarify what is best for my applicatio...
<p>*AngularJS is client side HTML and Javascript, JSF is server side Java and XML *JSF and RichFaces is ok for simple solutions like forms, tables, simple pages. But when requirements are more complex like dynamic rerender part of the page or some fancy features then things get more cumbersome if you try to do not stan...
Why INTO Clause is expected in select statement? <p>I didn't declare a variable to assign value from query, then why code below throws error for INTO clause? </p> <pre><code>create or replace PROCEDURE Disp_of_IPC_Crime_Case( startDate DATE, endDate DATE) IS BEGIN SELECT * FROM ( SELECT CO...
<p>If the aim of the procedure is to provide a report, you can do this by <a href="https://oracle-base.com/articles/misc/using-ref-cursors-to-return-recordsets" rel="nofollow">passing back a ref cursor</a>, or if you have Oracle 12.1 or later you can use the new <a href="https://oracle-base.com/articles/12c/implicit-st...
How to check if Play Service is installed with Firebase? <p>I know how to check it with GoogleApiAvailability (by GCM). But this function is not supported be FireBase core library.</p> <p>my dependencies are:</p> <pre><code>compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:design:24.2.1' ...
<p>I believe what you're looking for is this:</p> <pre><code>compile 'com.google.android.gms:play-services-auth:9.6.1' </code></pre>
PHP SimpleXML select elements <p>I'm trying to extract information from an ncx file via SimpleXML. The file looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"&gt; &lt;head&gt; &lt;meta name="dtb:uid" content="http://www...
<p>The XML has a namespace. Try with</p> <pre><code>$ncx = simplexml_load_file('test.xml'); $ncx-&gt;registerXPathNamespace('x', 'http://www.daisy.org/z3986/2005/ncx/'); foreach ($ncx-&gt;xpath('//x:content/@src') as $src) { echo $src, PHP_EOL; } </code></pre> <p>Without XPath:</p> <pre><code>$ncx = simplexml_lo...
How to remove function pointer from std::deque by val? <p>I am using <code>std::deque</code> to keep callback functions.</p> <p>Everything works perfectly except removing a specific callback.</p> <pre><code>typedef std::function&lt;void(void)&gt; cb_Action; std::deque&lt;cb_Action&gt; actionCallbacks; </code></pre> ...
<p>If you deal with usual functions you can do something like this based on <a href="http://en.cppreference.com/w/cpp/utility/functional/function/target" rel="nofollow">std::function::target</a>:</p> <pre><code>void callback_1(void) {} void callback_2(void) {} actionCallbacks = { std::function&lt;void(void)&gt;(c...
Invalid child context `store` of type `function` supplied to `Provider`, expected `object` <p>I am trying to connect the state in the reducers to the components in my react components. Here is the code of the reducer is in <code>reducer_books.js</code>:</p> <pre><code>export default function(){ return [ {title...
<p>In your example I don't see where you <a href="https://github.com/reactjs/redux#the-gist" rel="nofollow"><strong>configure <code>Store</code></strong></a>, I suppose that you missed this step </p> <pre><code>import reducers from './reducer/index'; import { Provider } from 'react-redux'; import { createStore } from ...
Excel Copy certain values of Column to another sheet <p>I'm trying to copy certain values of column to another sheet, but it's not working.</p> <p>The code I am using is:</p> <pre><code>Worksheets("Report").Range(".Cells(x, 1)", ".Cells(x, 2)", ".Cells(x, 4)", ".Cells(x, 6)", ".Cells(x, 9):.Cells(x, 13)").Copy </cod...
<p>You are using <code>Range</code> wrong in two ways:</p> <p>1) <code>Range</code> has only one or two arguments. The usage is either</p> <pre><code>Range(someAddress) </code></pre> <p>where <code>someAddress</code> is a String like <code>"A1"</code>, <code>"A1:B2</code> or even unions like <code>"A1:B2,C3"</code> ...
How to add attributes in input element with Beautifulsoup <p>I use BeautifulSoup to find a specific element on my html page. I want to add an attribute "value" to this element and save it to the original html. How can I do this with Beautifulsoup? Right now I do this to get the whole html and find the specific element...
<p>Try this instead:</p> <pre><code>bs.find('input')['value'] = ''#Whatever you want the value to be. </code></pre> <p>Because <code>bs.find</code> returns a dictionary, so to set an item in a dicionary use subscript notation.</p>
Combining firebase observables with angular2 <p>I'm working on an angular2 - firebase app, and was wondering on some best rxjs practices, that I find difficult to google. </p> <p>Say I have a class "Project" with properties like "name", "$key", etc. And then also arrays of "Note[]" and "Task[]"</p> <p>"Note" and "Tas...
<p>I don't understand your structure exactly but if you have "Projects" "Notes" and "Tasks" as three separate streams (I guess this means you have three Observables). You can use <a href="http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-merge" rel="nofollow"><code>merge()</code></a> or <...
Convert Java objects to JSON with specific fields <p>I want to create two different JSON documents and each contains 5 fields. I have a POJO class with 10 attributes. I want to form json1 with 5 attributes and json2 with 5 attributes using that POJO class. Is there any way to construct these objects?</p>
<p>Consider writing two separate wrapper classes which each expose the fields you want for the two cases, and pass the pojo as a constructor arg.</p> <p>So, one of them exposes one set of properties and might look like this:</p> <pre><code>public class JsonObject1 { private MyPojo myPojo; public JsonObject1(M...
Can any one explain scope of c-macro's defined local to function and global? <p>I don't know why this output appears and behavior of pre-processor.</p> <p>Output:</p> <pre><code>the value in main 10 the value in fun 20 the value in 2 main 10 </code></pre> <p>Source</p> <pre><code>#include&lt;stdio.h&gt; #define MAX...
<p>A macro is not checked at runtime. It is checked during before compilation, in a stage called pre-processing. </p> <p>So, the compiler processes the <code>main</code> function first and replaces <code>MAX</code> with 10 in all lines. Then when it reaches the <code>fun</code> function, it undefines <code>MAX</code> ...
Meteor.js icons are missing after update <p>I have updated my meteor and now no icons are displayed - before the update all worked fine.</p> <p>folder structure:</p> <p>-public</p> <p>--fonts</p> <p>---tablet</p> <p>---monitor</p> <p>and I access the tablet icons with following code:</p> <pre><code> @font-fa...
<p>You may need to add a leading slash ('/') to all of your icon paths.</p> <p><code>src: url("fonts/tablet/Flaticon.eot");</code></p> <p>maybe should be:</p> <p><code>src: url("/fonts/tablet/Flaticon.eot");</code></p>
Is this a C++ Semaphore? <p>I have a thread-save-resource (a OpenCl-Command Queue to a device),but i want restrict the number of threads that have access to this ressource at the same time(i want to calculate on my cpu if the gpu command-queue is 'to full'). Unfortunately i'm relatively new to c++11 atomic operations. ...
<p>No, that won't behave as expected - consider the situation where 2 threads get to <code>int cnt = _cnt.load();</code> at the same time. They will both read the same value, and both set the counter to the same value, even though it might be that only 1 of them should've got though.</p> <p>That might be considered ...
How to get Angular 2 element through class name in Jasmine <p>I can get element with using the </p> <pre><code>fixture.debugElement.query(By.css('h1')); </code></pre> <p>But what I should to do when I want get element through class name. Something like this </p> <pre><code>fixture.debugElement.query(By.css('class="n...
<p>You use <code>By.css</code> to pass a css selector. So any selector you can use with css, you can use with <code>By.css</code>. And a selector for a class is simply <code>.classname</code> (with period).</p> <pre><code>By.css('.classname') // get by class name By.css('input[type=radio]') // get input by ...
Printing the CONTENT of a nested hash map is mixing characters on the same line <p>I'm trying to print a hashtable content, that hashtable contains a map inside it, the table is declared just like this:</p> <pre><code> Map&lt;String, Map&lt;String,Integer&gt;&gt; mapSD = new HashMap&lt;String, Map&lt;String, Integer&g...
<p>Solved, the problem was the buffer size of the console, that's why it mixed the characters at the same line, the bufer was being overwritted. Thanks for your answers!</p>
RavenDB: Search with whitespace, behaving like String.Contains <p><strong>TL;DR</strong> how to run exact equivalent of <code>.Where(x =&gt; x.Name.Contains(value))</code> query in RavenDB, even when <code>value</code> string contains spaces (whitecharacters)?</p> <hr> <p>We're querying RavenDB with LINQ. We want to ...
<p>You need to set the <code>Index</code> option of the field to <code>Analyzed</code></p> <pre><code>public class YourObject_ByName : AbstractIndexCreationTask&lt;YourObject&gt; { public YourObject_ByName() { Map = objs =&gt; objs .Select(x =&gt; new { x.Name }); Indexes.Add(x =&gt; x.Name, F...
Can not search mail on Exchange IMAP server by javamail api? <p>I can not search mail on Exchange(2013) IMAP server by Javamail API. I have done a tcpdump found that javamailAPI send the command: <code>"A5 SEARCH TO xxx@eyou.net all "</code>,exchange server return nothing.</p> <p>I sent a command: <code>"A5 SEARCH HEA...
<p>Ya, Exchange is broken. You can use <a href="https://javamail.java.net/nonav/docs/api/javax/mail/search/HeaderTerm.html" rel="nofollow">HeaderTerm</a> instead.</p>
How to know if touch position is in a specific area - Android <p>I want to call a method if a specific area of screen (my <code>RelativeLayout</code>) has been tapped. I'm devveloping a <strong>tic-toc-toe</strong> game, I want to make the <code>alpha</code> value of every circle or cross in each tapped square.<br> he...
<p>apply on focus change listner to the imageview and do your code where the image view will get the focus like:- </p> <pre><code>if(hasFocus){ // do your code }else{ } </code></pre>
Align text to the bottom of a div with inline-block <p>I'm having trouble aligning some text to the bottom of a div which as a display of inline-block.</p> <p><a href="https://i.stack.imgur.com/Z19ga.png" rel="nofollow"><img src="https://i.stack.imgur.com/Z19ga.png" alt="Right Now it looks like this"></a></p> <p>but ...
<p><strong>Flexbox</strong> can do that:</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>* { box-sizing: border-box; margin: 0; padding: 0; } .header { displ...
Word document to python-docx <p><strong>Objective:</strong> I use a word template to which I want to pass paragraph values from python. </p> <p><strong>Pipeline:</strong> The pipeline involves using python-docx and sending output paragraph to python docx;thus, creating a docx file.</p> <pre><code>from docx import Doc...
<p>I think the approach you'll find most useful is to define <strong>paragraph styles</strong> in your template document that embody the paragraph and character formatting for the different types of paragraphs you want (heading, body paragraph, etc.), and then apply the correct style to each paragraph as you add it.</p...
Delete line from grid in axapta <p>I'm quite new in Axapta and I didn't get how I can to delete selected line from grid, actually my problem is that I cant get selected line, so how should I do this?</p>
<p>In your form you have a <code>Data source</code> node, here you have your <code>Data source</code> to use to display data in <strong>form</strong> in methods you have <code>Delete()</code> method. This method is called when you delete record. Also you can override this method.</p> <p>If you press <strong>ALT + F9</...
Getting Junk Characters while reading AppName programmatically on Android <p>My Sample code to get the AppName.</p> <pre><code>public static String getApplicationName(Context mContext) { String applicationName = mContext.getResources().getString(R.string.app_name); if (applicationName != null) { return...
<p>Why don't you tried the below code?</p> <pre><code>int stringId = this.getApplicationInfo().labelRes; String appName = this.getString(stringId); Log.e(TAG, appName); </code></pre>
Wrong time since.. from timestamp <p>I added timestamp to Firebase database formatted like: <code>1476700050.83933</code>. </p> <p>So I wanted to calculate the time since this timestamp was created however as an output I get something like this: <code>1969-12-31 23:32:04 +0000</code>. </p> <p>It sees somehow correct ...
<p><code>NSDate().timeIntervalSinceNow</code> return value close to <code>0</code>.</p> <p><code>NSDate()</code> — creates date with current timestamp, you can call it <code>now</code>. <code>timeIntervalSinceNow</code> here will be difference between time of creating data and method call, miniscule value.</p> <p>S...
Clearing chrome's cache on server side <p>I have big problem with chrome's cache. I'm building system for my clients. All are build on angular so at the begining there is always one index.html file. With new version I'm changing js scripts tag to ex. <code>scripts.2.1.1.js</code> in index.html file. I have also:</p> <...
<p>You could try to set "no-store" in the header: <a href="http://stackoverflow.com/questions/866822/why-both-no-cache-and-no-store-should-be-used-in-http-response">Why both no-cache and no-store should be used in HTTP response?</a></p> <p>But Implementing ETag headers is a more robust way to do so:</p> <p><a href="h...
Java Bulk Import <p>Will java bulk import sub packages inside one package?</p> <p>For example I have this directory:</p> <pre><code>- PackageA - PackageB - anotherClass.java - PackageC - myClass.java - app.java - someClass.java </code></pre> <p>If I use this following java code will my classe...
<p>Two things here:</p> <p>A) no, these imports are not "recursive"; you only import the classes from the specific package, not of its sub-packages</p> <p>B) bulk imports are considered "bad style" by most coding style conventions and tools</p> <p>(eclipse for example will automatically turn them into specific impor...
MySQL returns always Error <p>I have a check for max letters. If the check is not true the first time, its working. But if i have a insert with 200 characters or more it always returns <code>Message cant have more than 200 characters.</code> Even with 10 characters after the test return error. Can't see what I'm doing ...
<p>This is not mysql error but your php validation error</p> <p>1) More than 200 is <code>&gt;200</code> not <code>&lt;200</code></p> <p>2) You need to check length of text not text</p> <pre><code>if (strlen($_POST['message']) &gt; 200) { echo "Message can't be more than 200 characters"; } </code></pre...
Split string by brackets <p>I am trying to split a string by brackets but my array has some extra empty values.</p> <p>I tried using the code of a similar question that was answered and it splits the string but also adds empty values.</p> <pre><code>// faq data $faq = "SELECT * FROM `web_content` WHER...
<pre><code>$line = '[This] is a [test] string, I think [this] answers [your] question.'; preg_match_all("/\[([^\]]*)\]/", $line, $matches); var_dump($matches[1]); </code></pre>
does not want grouping symbol in google chart numbers <p>I am google chart to draw tables. I have a column of numbers but numbers are printed as "1,222,322" but i don't want grouping symbol(comma) between digits. i tried</p> <pre><code>var formatter = new google.visualization.NumberFormat({ groupingSymbol: ' '}); form...
<p>seems to work fine here </p> <p>make sure to format the column before drawing the chart </p> <p>see following working snippet... </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-ove...
How to get difference between current date and given date from cell in VBA? <p>I am new in VBA. I want to get the difference between current date and given date from user. How can I solve this? <a href="https://i.stack.imgur.com/kdV95.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/kdV95.jpg" alt="enter image d...
<p><code>Range("F6:F" &amp; LastRow).Formula = "=Text(Now()-C6, "y")"</code> should do it. </p> <p>Refer to the <a href="https://support.office.com/en-gb/article/TEXT-function-20d5ac4d-7b94-49fd-bb38-93d29371225c" rel="nofollow">text function</a> for other formatting options.</p> <p>In particular:</p> <p><a href="ht...
How to smooth lines in a figure in python? <p>So with the code below I can plot a figure with 3 lines, but they are angular. Is it possible to smooth the lines? </p> <pre><code>import matplotlib.pyplot as plt import pandas as pd # Dataframe consist of 3 columns df['year'] = ['2005, 2005, 2005, 2015, 2015, 2015, 2030...
<p>You should apply interpolation on your data and it shouldn't be "linear". Here I applied the "cubic" interpolation using scipy's <code>interp1d</code>. Also, note that for using cubic interpolation your data should have at least 4 points. So I added another year 2031 and another value too all weights (I got the new ...
Find pd.DataFrame cell that has the value of None <p>I have a <code>pd.DataFrame</code> that looks like this:</p> <pre><code>index A B 0 apple bear 0 axis None 0 ant None 0 avocado None </code></pre> <p>and my goal is to simple drop those row if they have <code>None</code> in ...
<p>You could try this:</p> <pre><code>df.dropna(subset=["B"]) </code></pre>
Tomcat server unavailable from JEE7 <p>I have created a gradle webapp project in IntelliJ.</p> <p>I have set Tomcat 8.5.6 to execute the project.</p> <p>In file <code>webapp/WEB_INF/web.xml</code> i have defined a servlet</p> <pre><code>&lt;servlet-mapping&gt; &lt;servlet&gt; &lt;servlet-name&gt;RestServlet&lt;/...
<p>Tomcat is web container and not an application server. </p> <p>So your:</p> <ul> <li><code>@Stateless</code> does nothing </li> <li><code>@Named</code> does nothing as well </li> <li><code>@ApplicationPath("rest")</code>/<code>@Path</code> does nothing unless you've provided a JAX-RS implementation either as apart...
What is the most readable way to replace multiple strings with replacements in a string in postgresql. <p>My usecase is something like this :</p> <pre><code>String = "INDIA CANADA ITALY", String Post Repacement = "IN CA IT" </code></pre> <p>I'm looking for something like this : </p> <pre><code>replaceMultiple(String...
<p>There are many ways to do it.</p> <p>You could use temporary tables and <code>regexp_replace</code>, or you could use a JSON dictionary like this:</p> <pre><code>SELECT string_agg( COALESCE( '{ "INDIA": "IN", "CANADA": "CA", "ITALY": "IT" }'::jsonb-&gt;&gt;s, s ), ...
PHP regex pattern to extract string like [3,4,aAn] <p>With the following peace of code I want to extract values like <code>[3,6,AN]</code> from a given string:</p> <pre><code>$custom='[4,100,A]@erric.com'; $regexIpAddress = '/\[\d{1,3}\,\d{1,3}\,[a|A|Aa|aA|aN|Na|AN|NA|ANa||AaN|NAa|NaA|aAN|aNA]\]/'; preg_matc...
<p>Use the following regex pattern with <code>i</code>(case-insensitive modifier):</p> <pre><code>$re = "/\[\d{1,3},\d{1,3},[an]{1,3}\]/i"; $matched = preg_match($re, "[20,5,AaN]"); print_r($matched); // 1 $matched = preg_match($re, "[2,5,1]"); print_r($matched); // 0 </code></pre>
No applicable action for totalSizeCap in logback spring boot logging <p>I am trying to limit maximum number of log files using "totalSizeCap" element from logback. I am using sprong boot application, so included logback as follows,</p> <p>logback.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;con...
<p>My guess is that the <code>logback.xml</code> isn't the right place to specify what you want. Instead you should be using the <code>logback-spring.xml</code> file. This is due to the fact that the Logback framework is loaded before the ApplicationContext (so that the context can log some initial things) then the con...
Multiply the rows in ten columns, by the values in one column <p>I have the following data:</p> <pre><code>ID &lt;- c("CB1", "CB2","CB3") size &lt;- c(10, 40, 4) Year.1 &lt;- c(10, 6, 15) Year.2 &lt;- c(12, 7, 20) Year.3 &lt;- c(14, 8, 25) data &lt;- data.frame(ID, size, Year.1, Year.2, Year.3) </code></pre> <p>I wan...
<p>Why not this simple in base R:</p> <pre><code>yr &lt;- grep("Year", names(data)) # finds year columns data[,yr] &lt;- data$size*data[,yr] # ID size Year.1 Year.2 Year.3 #1 CB1 10 100 120 140 #2 CB2 40 240 280 320 #3 CB3 4 60 80 100 </code></pre>
How to get the selected row value in aspxgridview <p>I have a aspxgridview and use the popup edit form. In the gridview there is a column "Unitname". In the popup edit forms header I would like to show this Unit name of the currently edited row.</p> <p>i am using StartRowEditing event is used to show this.</p> <p>al...
<p>The selected row values can be accessed both in the server-side code and in the browser.</p> <p>To access selected values on the server side, use the <a href="https://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridBase_GetSelectedFieldValuestopic" rel="nofollow">GetSelectedFieldValues</a> method of the A...
How to Convert a String into a user defined object reference <pre><code>public class Country { public static void main(String[] args) { String country_name; String capital; String iso_numeric; String iso2; String iso3; String[] name = new String[] {"united_...
<p>You appear to want this: </p> <pre><code>public class Country { private final String name; // Add these later // private final String capital; // private final String iso_numeric; // private final String iso2; // private final String iso3; public Country(String name) { this.na...
Centre ImageView horizontally inside a TableViewCell <p>I am having a bit of a problem putting my image view in the middle of the cell.</p> <p><strong>I have a tableView cell with:</strong> a label which is left aligned a UIImageView (which is to be in the middle of the screen but not overlap the AccessoryView or Acce...
<p>Change imageView frame x origin after your cell layout subviews. Just add this to your cell definition. </p> <pre><code>override func layoutSubviews() { let screenWidth = UIScreen.main.bounds.width let imageViewWidth = self.imageView?.frame.width let imageViewOriginX = (screenWidth - imageViewWidth!) / ...
Why z3c.RML ignores the pageSize Attribute of <template> <p>I am trying to get an A4-Landscape output file. The Document i am modifying is A4-Portrait, so i thought simple switch: <strong><em>pageSize="(21cm, 29.7cm)"</em></strong> to <strong><em>pageSize="(29.7cm, 21cm)"</em></strong>, but nothing happend.</p> <p>I t...
<p><a href="https://github.com/zopefoundation/z3c.rml/blob/master/RML-DIFFERENCES.rst" rel="nofollow">https://github.com/zopefoundation/z3c.rml/blob/master/RML-DIFFERENCES.rst</a></p> <p><strong>RML2PDF and z3c.rml Implementation Differences</strong></p> <p>This document outlines the differences between ReportLab Inc...