input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Flink - Building the operator graph <p>Good morning everybody,</p>
<p>I have already used Apache Storm to build topologies and I found that a good thing about the API they expose is the possibility to "manually" connect the operators in the graph topology.<br>
You can create loops, for example.</p>
<p>I was wondering... | <p>Cyclic topologies are not supported in Flink. You can perform iterations through a specific operator. Except for cycles, you define your graph through the standard API and it's rather flexible compared to, for example, Spark. Many DataSet and DataStream API accept both functions and custom implementations of classes... |
replace method for python strings <p>I have a string S = 'spam'</p>
<p>When I use the method replace as S.replace('pa', 'xx')</p>
<pre><code>S.replace('pa', 'xx')
</code></pre>
<p>The output I get is -</p>
<pre><code>Out[1044]: "sxxm's"
</code></pre>
<p>Why then are the python strings known to be immutable ?</p>
| <pre><code>S = 'spam'
S.replace('pa', 'xx')
print S
</code></pre>
<p>You will get the same string <code>'spam'</code></p>
|
Laravel: How to create dynamic functions (methods) (using foreach loop) in class <p>I'm building some small cms in laravel and now I need dynamic named methods and variables in my controller based on created page in my cms. I create few pages: <code>news, world, sport, business</code>. and now I need methods and variab... | <p>Add a magic call method to your class, you're almost there the following example should be close to what you're thinking:</p>
<pre><code>class AjaxController extends Controller
{
public function test()
{
echo 'Hello world';
}
public function __call($name, $arguments)
{
$method ... |
how to set image inside framelayout <p>I want to set image inside the <code>FrameLayout</code> but is overlapping the framelayout's background </p>
<p><a href="http://i.stack.imgur.com/17CRU.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/17CRU.jpg" alt="right now how its looking"></a></p>
| <p>This is sample example, <a href="https://snag.gy/IrawbT.jpg" rel="nofollow">https://snag.gy/IrawbT.jpg</a></p>
<blockquote>
<p>item last put on the stack will be drawn on top of the items below it.
This layout makes it very easy to draw on top of other layouts,
especially for tasks such as button placement.</... |
Javascript HTML string - inject into document <p>This is the HTML I have:</p>
<pre><code> <ul id="myUL">
</ul>
</code></pre>
<p>This is what I'm doing:</p>
<pre><code>var myString = " &lt;li&gt;&lt;a href=&quot;www.google.comp&quot;&gt;Google&lt;/a&gt;&lt;/li&gt... | <p>Firstly note that you can't append a <code>div</code> to a <code>ul</code> as it's invalid HTML. <code>ul</code> can only contain <code>li</code> as children.</p>
<p>The issue itself is because your string contains escaped HTML. You can either use a plain string:</p>
<p><div class="snippet" data-lang="js" data-hid... |
How to change Add button to remove after adding in Angularjs <p>want to show only add button in first row ,
when i click add ,add new row and change or hide add button to remove.
continuously same. and first row should not remove and show add button</p>
<pre><code>div ng-app="ReceiptsApp">
<div ng-controller... | <p>A cheap & fast trick would be to make the Add button show only for the last element of <code>ng-repeat</code> like this:</p>
<pre><code><td ng-if="$last">
<button type="button" class="btn btn-default" ng-click="addRow($index,c)">Add</button>
</td>
<td ng-if="!$last"&g... |
Adding Xml Attribute to All elements except root Node <p>I am trying to add new attribute to my xml files in c#. my xml file format is shown below:</p>
<pre><code><Root MessageOfRoot="Welcome to Xml">
<Header Size="36">
<Parameter Name="ID" Index="0" Value="23" />
<Parameter Na... | <p>You can use the following command to load the XML file:</p>
<pre><code>XDocument doc = XDocument.Load(@"C:\Users\myUser\myFile.xml");
</code></pre>
<p>Then you can invoke a function that recursively accesses all nodes of the XML starting from the children nodes of the <code>Root</code> element:</p>
<pre><code>Add... |
React input text default value and onblur function make input text read only <p>guys, I am working on react js</p>
<p>I have created an input text and on blur of that input button I am calling a method and updating the state variable</p>
<p>but seem like if I use on blur instead of onChange then input text become rea... | <p>You need to add onChange listener otherwise it will not work.</p>
<p>Reason: When you specify value={this.state.value} it means you are binding input text value to the variable value and react takes over the control for updating value in input box. By adding onChange listener, you tell react to call a component fu... |
Wordpress add shortcode which sends parameters <p>On my wordpress page I have created a shortcode function which gets a parameters from the url of the post. So, I have created this simple function and added the following code to the theme's file function.php</p>
<pre><code>function getParam($param) {
if ($param !== ... | <p>A shortcode like this:</p>
<pre><code>[myFunc funcparam="param"]
</code></pre>
<p>Is not needed here, unless the called param is changing with the posts</p>
<p>let's say you have this URL:</p>
<pre><code>http://example.com?param=thisparam
</code></pre>
<p>To get the value of 'param' by using the shortcode descr... |
Grails 2.5 : Resource not found (404) for GSP file <p>I am upgrading my Grails application from version 1.x to 2.5 and facing this issue in version 2.5 which worked fine in version 1.x</p>
<p>In GSP file (connect.gsp) I am trying to open another gsp rename.gsp. This rename.gsp file is in the same location as that of c... | <p>I think grails is looking for an url mapping.</p>
<p>You should create an action in a controller, this action must render the gsp file.</p>
<p>Simple example :</p>
<pre><code>CustomcontrolController {
def renamedisplay()
{
render(view: '/user/rename')
}
}
</code></pre>
<p>then by default gra... |
How to count the number of instances a pattern is matched in Redshift/Postgresql <p>For demo purposes, say I have a large table (billion rows+) in Redshift, with two fields:
<code>id</code> and <code>win</code>. <code>win</code> can be <code>0</code> or <code>1</code>. </p>
<p>Is there an efficient way to count the nu... | <p>One method uses <code>lag()</code> or <code>lead()</code>:</p>
<pre><code>select t.*
from (select t.*,
lead(win, 1) over (order by id) as win_1,
lead(win, 2) over (order by id) as win_2,
lead(win, 3) over (order by id) as win_3
from t
) t
where win = 1 and win_1 = ... |
How to transfer data from sql to javascript? <p>I work with this example: <a href="https://www.sitepoint.com/dynamic-geo-maps-svg-jquery/" rel="nofollow">https://www.sitepoint.com/dynamic-geo-maps-svg-jquery/</a> But I need get data from MySql DB.</p>
<p>I have 2 main files:
1) map.php (connect to db and show svg map)... | <p>Normally you won't be modifying your js file. Instead you need to load your data from DB using i.e. an ajax call and then "give" it to the control you're using.
To do that you need i.e. a web service that returns your data and some javascript function that calls it. You can do something like this: </p>
<pre><code>... |
WordPress custom page templates reads from subdirectory <p>I need guides please, as I am new to this.</p>
<p>So I installed WordPress locally and managed to create my custom theme with just the basic theme content.</p>
<p>Theme Directory: <code>wp-content/themes/custom-theme/</code></p>
<p>In this directory I wish t... | <p>One of the tools that WordPress offers is <a href="https://developer.wordpress.org/reference/functions/get_template_part/" rel="nofollow"><code>get_template_part();</code></a></p>
<p>However, this requires you do use Wordpress' loop on the page calling this function.</p>
<h2>From the docs:</h2>
<blockquote>
<p>... |
Dropbox API v2 (and v1) "list" folder with recursive=true is missing Shared folders <p>What I did:
Using dropbox-sdk-2-1-1 for java.</p>
<p>Api url:
<a href="https://api.dropboxapi.com/2/files/list_folder" rel="nofollow">https://api.dropboxapi.com/2/files/list_folder</a></p>
<p>List folders in a dropbox folder. Set r... | <p>Found the solution.</p>
<p><a href="https://www.dropboxforum.com/hc/en-us/community/posts/206081056--SwiftyDropbox-client-files-listFolder-recursive-true-doesn-t-list-shared-folders" rel="nofollow">https://www.dropboxforum.com/hc/en-us/community/posts/206081056--SwiftyDropbox-client-files-listFolder-recursive-true-... |
How do you pass the element in Angular2 Typescript binding? <p>How do I get the specific HTML dom element passed through a binding. Sorry if this is hard to understand, here's the code.</p>
<blockquote>
<p>donut-chart.html</p>
</blockquote>
<pre><code><div class="donut-chart" (donut)="$element"></div>
<... | <pre><code><div #someElement></div>
<div class="donut-chart" (donut)="someElement"></div>
</code></pre>
<p>it can also be the current element</p>
<pre><code><div #someElement class="donut-chart" (donut)="someElement"></div>
</code></pre>
|
Return MYSQL query result via JSON array/object? <p>I have a table that contains a list of countries, i'm selecting all the countries from the table using</p>
<pre><code>$query = $conn->query("SELECT * FROM countries");
</code></pre>
<p>I now need to turn this result into a JSON array/object for use in my android ... | <p>You could use <a href="http://php.net/manual/en/mysqli-result.fetch-all.php" rel="nofollow">mysqli_fetch_all</a> like </p>
<pre><code>$response = array();
$response['country'] = mysqli_fetch_all($query, MYSQLI_ASSOC);
echo json_encode($response);
</code></pre>
|
elements generated with javascript or jquery not being posted in mvc 5 c# <p><strong>collection of elements not being posted if generated with jquery or javascript</strong><br/>
<br/>
i have read these articles <br/>
<a href="http://www.codeproject.com/Tips/855577/List-of-Model-Object-Post-to-Controller-in-ASP-NET" rel... | <p><strong>name</strong> attribute of <code>"formgroup-2"</code> and <code>"formgroup-3"</code> are not in correct order. That's why only one row of data is present.</p>
<p>Name of elements should be <code>[1].KmpName</code> for <code>formgroup-2</code>. Similarly it should be <code>[2].KmpName</code> for <code>formgr... |
Using line breaks in String.contains() <p>I have text like the following:</p>
<p><PRE>
Grad/Med School University of Osteopathic Medicine and
Health Sci.
</PRE>
this was read from a pdfFile into a String (Java) called pdfFileText. Actually, the above is just a small part of the total text.</p>
<p>I will also have a ... | <p>You're doing it backwards. Remove the line endings from the input first:</p>
<pre><code>pdfFileText.replaceAll("\\s+", " ").contains(institution)
</code></pre>
<p>If you cannot guarantee that <code>institution</code> will always be normalised, then pre-process that as well:</p>
<pre><code>pdfFileText.replaceAll("... |
jstree Reveal the selected child entry <p>I use</p>
<pre><code>$('#jstree-naf').jstree().check_node(value);
</code></pre>
<p>to selected the entry I need. But I need to reveal the tree until this.</p>
<p>Exemple (currently):</p>
<p><a href="http://i.stack.imgur.com/yMETJ.jpg" rel="nofollow"><img src="http://i.stack... | <p>Use <code>_open_to</code> method as below. Check demo - <a href="https://jsfiddle.net/ermakovnikolay/g7uxbaL1/" rel="nofollow">Demo Fiddle</a></p>
<pre><code>$("#jstree-naf").jstree()._open_to( value );
</code></pre>
|
How to get JSON Object, REST API, Jhipster, SpringBoot <p>I'm coding an API using Jhipster. Server side is programmed with SpringBot. I want to get JSON Object that i send with PostMan</p>
<pre><code>{
"user" : {
"name" : "name",
"surname": "surname"
}
}
</code></pre>
<p>I create a ressource a... | <p>I just find the mistake, the JSON Object I sent was incompatible. I change it with</p>
<pre><code>{
"name" : "name",
"surname": "surname"
}
</code></pre>
<p>and now it works.</p>
|
Manually setting AES key in openSSL? <p>I am writing a <code>SSL Client</code> using <code>openSSL</code> library. I am able to connect to <code>https://www.httpbin.org</code> using my C program. However, i want to manually set my own <code>AES</code> key for further symmetric cryptography and notify the server about k... | <p>This is not possible. The key used for encryption depends on data created by both server and client. This means it is not possible to for the client to have full control over the key value. See also <a href="https://tools.ietf.org/html/rfc5246#section-8.1" rel="nofollow">Computing the Master Secret</a> in RFC 5246 (... |
While loop keeps running but not printing <p>I've been searching, and nothing helped with my problem so far.
My goal is to rewrite a for loop to a while loop, and prime the while loop.
I've done this so far</p>
<pre><code> int i = -1;
while (i <= 10);
{
i = i + 1;
System.out.println("i=" + i);
}
<... | <p>Remove the semicolon at while end</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>int i = -1;
while (i <= 10)
{
i = i + 1;
System.out.println("i... |
iOS swift margin between tableHeader and cell's <p>I have a tableview with <code>tableHeaderView</code>. when I run the app the annoying margin is between cell's and tableHeaderView as you seen in image.</p>
<p><a href="http://i.stack.imgur.com/4LhlU.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/4LhlU.jpg" al... | <p>Write this line :-
<code>self.navigationController?.automaticallyAdjustsScrollViewInsets = false</code> in <code>viewDidAppear()</code> method.</p>
|
Why a PostgreSQL query ran 3 days as a scheduled Windows task? <p>I have a Windows scheduled task which has to run a batch file. The batch file is PostgreSQL query to insert some data. What we saw from the logs is that the task was triggered & got a process id too. But the task has no other update in the logs &... | <p>We found the problem which was in our <strong>batch file</strong>.
The line <strong>cmd \k</strong> which keeps the command prompt open was the reason the task was running until it timedout</p>
|
Libdx | Input Processor touchDown() not firing every click <p>I am using an input processor for touchinput on a flappy bird like game. <br>This works fine on my droid turbo, and a couple other newer phones. But with my two older tables, a xoom, and verizon tablet, touchDown occasionally doesn't fire. I should mention t... | <p>it is the issue with the viewPort. that is the different phone has different screen size. please check the below link which will help you</p>
<pre><code>http://stackoverflow.com/questions/39810169/libgdx-text-not-rendering-properly-on-larger-screens/39946652#39946652
</code></pre>
|
How do I execute multiple shell commands with a single python subprocess call? <p>Ideally it should be like a list of commands that I want to execute and execute all of them using a single subprocess call. I was able to do something similar by storing all the commands as a shell script and calling that script using sub... | <p>Use semicolon to chain them if they're independent.</p>
<p>For example, (Python 3)</p>
<pre><code>>>> import subprocess
>>> result = subprocess.run('echo Hello ; echo World', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>>> result
CompletedProcess(args='echo Hello ; echo... |
UUIDField has no attribute uuid4 <p>Here is my model</p>
<pre><code>from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
import uuid
class PiO(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) # surr... | <p>The problem is that your model field <code>uuid</code> is clashing with the module <code>uuid</code>. </p>
<p>One option would be to rename your model field, for example:</p>
<pre><code>class PiO(models.Model):
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
...
</code></pre>
<p>An... |
Group Chat with Signalr. How to send to specific users? <p>These are tables i added in database. </p>
<p><a href="http://i.stack.imgur.com/t44iJ.png" rel="nofollow">Database table 1</a></p>
<p><a href="http://i.stack.imgur.com/FK4R2.png" rel="nofollow">Database table 2</a></p>
<pre><code> //Group Chat Hub
pub... | <p>Clients.Group(groupName).[Method which should be called on this group](name, message);</p>
<p><a href="http://www.asp.net/signalr/overview/guide-to-the-api/working-with-groups" rel="nofollow">http://www.asp.net/signalr/overview/guide-to-the-api/working-with-groups</a></p>
|
Monad interface in C++ <p>I am currently learning a little bit haskell and started to figure out how monads work.
Since I normaly code C++ and I think the monad pattern would be (as fas as I understand it right now) be realy awesome to use in C++, too, for example for futures etc,</p>
<p>I wonder if there is a way to ... | <p>First note that being a monad is not a property of a type, but of a type constructor.</p>
<p>E.g. in Haskell you'd have <code>List a</code> as a type and <code>List</code> as the type constructor. In C++ we have the same functionality with templates: <code>std::list</code> is a type constructor that can construct t... |
Cannot save image from Bitmap <p>I get a warning stating that the result of <code>cachePath.createNewFile();</code> is ignored. Otherwise the following code does not save an image to my phone. What can I do? </p>
<pre><code>holder.messageImage.setOnLongClickListener(v -> {
v.performHapticFeedback(Haptic... | <p>to save an image I use the following code:</p>
<pre><code>try {
signature.setDrawingCacheEnabled(true);
Bitmap bm = Bitmap.createBitmap(signature.getDrawingCache());
// Define params for save
File f = new File(Environment.getExternalStorageDirectory() + "/Cassiopea/momomorez/" + File.sep... |
When it makes sense to use redux in angular2 <p>I read some articles about using redux and angular2. But I don`t understand what redux is supposed to bring to angular2. Services should not be enough?</p>
<p>For instance, using the todo example (usually provided with redux), why not just use a service, with a <code>Tod... | <p>Redux is a pattern to do state management. It makes your statemanagement more maintainable, and easier. For a simple todo application, that might be overkill. If you don't have to manage a lot of state than it might not be a great idea. It opens a few cool doors though:</p>
<p>It makes <a href="http://blog.brecht.i... |
About MongoDB Max size(16MB) <p>For a document in a collection, MongoDB max size is 16MB. How to deal with BSON which size over 16MB?
When use GridFS to deal with pictures, mp3, it looks easy .
But how to use it to deal BSON?</p>
| <p>MongoDB's specification for GridFS actually splits the file up into chunks <a href="https://docs.mongodb.com/manual/core/gridfs/" rel="nofollow">https://docs.mongodb.com/manual/core/gridfs/</a>, currently 255KB</p>
|
Redirecting page from Thymeleaf template <p>How to redirect the page from Thymeleaf (I have JSP code like below)</p>
<pre><code>out.println("REDIRECT=http://www.example.com/api/response?id="+id)
</code></pre>
<p>What is the equivalent in Thymeleaf? I want to do it from the template.</p>
| <p>Thymeleaf doesn't provide any mechanism for redirecting to another page from one of its templates -- and I wouldn't recommend doing it anyways (since this is something that should probably be handled at the controller level).</p>
<p>That being said, it's possible to do this using javascript. Something like this:</... |
Access return value from a Javascript in JavaFX <p>I have the following Javascript executed in a webengine.
Source: <a href="http://stackoverflow.com/questions/14029964/execute-a-javascript-function-for-a-webview-from-a-javafx-program/39722454#39722454">Execute a Javascript function for a WebView from a JavaFX program<... | <p>When using <a href="https://docs.oracle.com/javafx/2/api/javafx/scene/web/WebEngine.html#executeScript%28java.lang.String%29" rel="nofollow"><code>executeScript</code></a> the evaluation result is returned based on the rules written in the javadoc of the method. Also the <a href="https://docs.oracle.com/javafx/2/api... |
Enabling SSL on site and broken links <p>I have enabled SSL on my site and it has broken links like these, as they are still invoked on <code>HTTP</code> by the browser: </p>
<pre><code><script src="/some_JS_library/some_js_minified.min.js"></script>
<link rel="stylesheet" href="/some_JS_library/some_j... | <p>Try to use protocol relative links (two slashes in beginning):</p>
<p>//some_url.com/some_file.js</p>
<p>//somefolder/somefile.js</p>
|
Can you skip a line within a ul list? <p>I have an unordered list of multiple items. I want to put in a line break between sections in the list without breaking the <code>ul</code> group? Is this possible?</p>
<p>Let's say it looks like this:</p>
<pre><code><ul>
<li>item 1</li>
<li>item 2&... | <p>you can use <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child" rel="nofollow"><code>nth-child</code></a> or <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type" rel="nofollow"><code>nth-of-type</code></a>, setting <code>margin-top</code> to which <code>n</code> child you want</p... |
I want to build a JSON Object similar to following the structure in java using JSONObject and JSONArray. How can I do it? <p>This is the json.
Something similar to <a href="http://stackoverflow.com/questions/22042638/creating-nested-json-object-for-the-following-structure-in-java-using-jsonobject">Creating nested JSON ... | <p>You can try with <code>JSONSimple library</code> and form the object in this way-</p>
<p>You have to import <code>org.json.simple.JSONArray</code> and <code>org.json.simple.JSONObject</code> for using this code.</p>
<pre><code> JSONObject object=new JSONObject();
JSONObject holder=new JSONObject();
JSO... |
Ember.js acceptance test check inputs' values <p>I have a lot of logic in a big form, where input values depend on each other. I am trying to test values of these inputs.</p>
<p>In this case <code>find("#sales_price").val()</code> results in empty string:</p>
<pre><code>fillIn("#sales_price", 12345);
andThen(function... | <p>To make bindings work:</p>
<pre><code>fillIn("#sales_price", 123456);
find("#sales_price").change();
andThen(function() {
assert.equal(find("#sales_price").val(),123456);
...
</code></pre>
|
How to use multiple conditions in asp.net Eval function to enable and disable a button in a templatefield? <p>Please Help.
I want to enable and disable the select button conditionally on question type </p>
<p>my code is</p>
<pre><code><ItemTemplate>
<asp:Button ID="btn_EditSurveyQuestion" runat="serv... | <p>Just chain your conditions:</p>
<pre><code>Enabled='<%# Eval("QuestionType").ToString()!="long text" ? true: Eval("QuestionType").ToString()!="short text" ? true : false%>'
</code></pre>
<p>EDIT: Another way is to just add a method to the code behind of the form and bind to that:</p>
<pre><code>Public Funct... |
MongoDB connection with Pentaho Kettle (PDI) <p>I've just downloaded Pentaho Data Integration Community (<code>pdi-ce-6.1.0.1-196</code>) a.k.a. Kettle, with the goal of designing an ETL routine to make nightly migrations from MongoDB scheme into PostgreSQL.</p>
<p>I couldn't achieve the very first task: create a Mong... | <p>PDI handles Mongodb differently than other databases. </p>
<p>If working on a transformation (vs a job), go to the "Big Data" group of steps and there are two steps - one for MongoDB Input and one for MongoDB Output.</p>
<p>Within those steps you specify the connection information to your database.</p>
<p>Hope th... |
Powershell, WMI Methods <p>using WMI with PowerShell I found something I don't understand:</p>
<pre><code># Syntax 1
gwmi -Class Win32_Share | gm -MemberType Method
Output: Delete, GetAccessMask, SetShareInfo
# Syntax 2
$a = New-Object "System.Management.ManagementClass" "Win32_Share" :
$a | gm -MemberType Method
Out... | <p>Because they return two different types of objects.</p>
<pre><code>(gwmi -Class Win32_Share).GetType()
</code></pre>
<p>returns a <code>System.Array</code> instance while</p>
<pre><code>(New-Object "System.Management.ManagementClass" "Win32_Share").GetType()
</code></pre>
<p>returns a <code>System.Management.Man... |
Can We Rollback in Delete , Drop & Truncate? <p>Inmost places i found a point:<br>
1)We can rollback in delete query but cannot in truncate and drop.<br>
but when i execute queries then successfully done with rollback in delete, drop & truncate</p>
<p>We can rollback the data in conditions of Delete, Truncate &... | <blockquote>
<p>Can We Rollback in Delete , Drop & Truncate?</p>
</blockquote>
<p>You can rollback Delete,Drop,truncate in SQLServer ,but in Oracle You can't rollback truncate</p>
|
Write hex code to text file from integer value in python <p><strong>Details: Ubuntu 14.04(LTS), Python(2.7)</strong></p>
<p>I want to write hex code to a text file so I wrote this code:</p>
<pre><code>import numpy as np
width = 28
height = 28
num = 10
info = np.array([num, width, height]).reshape(1,3)
info = in... | <p>If you want big endian binary data, call <code>astype(">i")</code> then <code>tostring()</code>:</p>
<pre><code>import numpy as np
width = 28
height = 28
num = 10
info = np.array([num, width, height]).reshape(1,3)
info = info.astype(np.int32)
info.astype(">i").tostring()
</code></pre>
<p>If you want he... |
MVP-Mosby-Api10: NoSuchMethodError android.support.v4.app.FragmentActivity.isChangingConfigurations <p>I get this error on crashlytics panel:</p>
<pre><code>Fatal Exception: java.lang.NoSuchMethodError
android.support.v4.app.FragmentActivity.isChangingConfigurations
com.hannesdorfmann.mosby.mvp.MvpFragment.shouldInsta... | <p>yes the method <code>isChangingConfigurations()</code> has been introduced with API 11:
<a href="https://developer.android.com/reference/android/app/Activity.html#isChangingConfigurations()" rel="nofollow">https://developer.android.com/reference/android/app/Activity.html#isChangingConfigurations()</a></p>
<p>as par... |
sklearn NB classifier: How to get the actual probabilities of individual samples? <p>I am making a machine learning program which classifies words in one of the following categories: Hardware, Software, None_of_these. I make use of the Multinomial Naive Bayes classifier from sklearn.</p>
<p>The function predict() give... | <p>Nevermind, I found the solution.:</p>
<p>predict_proba(X) Returns probability estimates for the test vector X.</p>
|
Glassfish config http methods <p>I'm trying disable some http methods on my glassfish. </p>
<p>I would like know how I can does not provide a communication through "option" and "trace" http methods on glassfish v3. </p>
<pre><code>< Allow: TRACE, OPTIONS
</code></pre>
| <p>You can add the following security constraint to your web.xml:</p>
<pre><code><security-constraint>
<web-resource-collection>
<web-resource-name>Forbidden</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>OPTIONS<... |
Easy-webpack using additional loaders <p>I have a easy-webpack configuration (default one from Aurelia).</p>
<p>We have a library (autobahn) that we use, that tries to load a package.json.
When that happens, it errors out. </p>
<pre><code>./~/autobahn/package.json
Module parse failed: /media/aurelia_app/node_modules/... | <p>The solution is to add module for the loaders in the base config.</p>
<pre><code>const baseConfig = {
entry: {
'app': [/* this is filled by the aurelia-webpack-plugin */],
'aurelia-bootstrap': coreBundles.bootstrap,
'aurelia': coreBundles.aurelia.filter(pkg => coreBundles.bootstrap.indexOf(pkg)... |
How do I call a URL that has a text file, convert it to a string and display it in ionic 2? <p>All I want to do is call a URL that has text format data, convert it to a string variable and output it as a message or a toast in my ionc 2 app.
So far my app shows the button, but when I click it to activate the setMessage... | <p>You're returning a string but not doing anything with it. And you're setting the <code>message</code> but not showing it on your page.</p>
<p>Try setting a variable in your html f.e. <code><p>{{message}}</p></code> (if using this don't forget to initialize your message, <code>message:string = "no messa... |
How do I detect from my application that it was started with JProfiler? <p>I know that I "shouldn't do this", but I fiddle with the ClassLoaders a bit and JProfiler doesn't like that and it hasn't to do anything with what I want to profile, so just stick to the question, please :). </p>
<p>How do I detect from my appl... | <p>The answer is simple if you know how:</p>
<pre><code>public static boolean isStartedWithJProfiler() {
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
List<String> arguments = runtimeMxBean.getInputArguments();
for( String argument : arguments ) {
if( argument.contains("... |
Looking for Facebook Graph API to display audience name/info for campaign <p>I'm looking to get the audience name/info from a campaign, however I cant seem to find any information regarding this. </p>
<p>Their API documentation sucksss! Does anyone have any pointers they can throw to me?</p>
<p>Thanks!</p>
| <p>Looks like i was using the wrong thing. I was looking to use graph.facebook.com/[vers]/[act_id]/campaign? when I should have been using graph.facebook.com/[vers]/[act_id]/adsets?</p>
|
How to: Search for the domain in an email address and pass it to an validation api <p>I am currently building an login form</p>
<p>I want some kind of email validation so i googled and found this api.</p>
<ul>
<li><a href="http://mailtest.in/documentation/" rel="nofollow">http://mailtest.in/documentation/</a></li>
</... | <p>If you want to simply extract the domain from an email address with regular expressions, you could so something like</p>
<pre><code>var test = email.match(/^.+@([^@]+\.[^@]+)$/);
if (test) {
var domain = test[1];
console.log(domain);
}
</code></pre>
<p>This checks if there is at least one character before an @... |
Apache NiFi tuning issues <p>I've developed a NiFi flow prototype for data ingestion in HDFS. Now I would like to improve the overall performances but it seems I cannot really move forward.
â</p>
<p>âThe flow takes in input csv files (each row has 80 fields), split them at row level, applies some transformations t... | <p>It turned out the poor performances were a combination of both the custom processors developed, and the merge content built-in processor. The <a href="https://community.hortonworks.com/questions/58628/nifi-unable-to-improve-performances.html" rel="nofollow">same question mirrored on the hortonworks community forum</... |
Text alignment in gmail and yahoo <p>I have created one template. While opening in gmail account some of the text line is coming in center (basically Thank You Part) but when I am opening the same template in Yahoo it (Thank You Part) is properly left aligned. I did some analysis and came to know that it also depends u... | <p>Try something like...</p>
<pre><code><table cellspacing="0" cellspacing="0" border="0" width="100%" role="presentation">
<tr>
<td style="text-align: left;">
Your Thank You text
</td>
</tr>
</table>
</code></pre>
|
In Oracle, repeatedly assign values from a set to column <p>I have a table in Oracle that has a column that I would like to assign a value to from a set of possible values. I like to assign the values in order of the set, repeatedly, for the entire table. </p>
<p><strong>For example:</strong></p>
<p>If the set of val... | <p>Use Modulo to achieve desire result</p>
<pre><code>UPDATE TableName
SET valueCol= CASE WHEN rowNum % 3 == 1 then 1
WHEN rowNum % 3 == 2 then 2
WHEN rowNum % 3 == 0 then 3
END
</code></pre>
|
SQL Migration Assistant for MySQL <p>I want to convert my MySQL database to SQL Server, so that I can migrate my website into Azure. </p>
<p>I have two problems: </p>
<ol>
<li><p>I downloaded <strong>SQL Server Migration Assistant for MySQL</strong>. I expect to see a "Connect to SQL Server" button, but there is only... | <p>When you create a new project you specify the target database version in the <code>Migrate To</code> dropdown box. The default is <code>SQL Azure</code>. I suspect you didn't check the dropdown and created a project with the default value.</p>
<p>If you select another version, eg <code>SQL Server 2016</code> or <co... |
HTML in webpack bundle. Why? <p>Good day,
I'm building and angular 2 app based off of this <a href="https://github.com/AngularClass/angular2-webpack-starter" rel="nofollow">starter pack</a>. I'm trying to get a handle on what our build process will look like. I noticed when running:</p>
<pre><code>npm run build:prod ... | <p>Yeah basically that's what Webpack does. It <strong>bundles</strong> everything. Having your output file ~4MB is very likely to happen. What you need is to separate the file into <strong>chunks</strong>. Using the common chunk plugin this way you'll be able to bring let's say all your third-party libraries into one ... |
jquery has in if statement triggering in any case <p>I'm using jquery <code>.has()</code> to check if a <code>div</code> has an <code>ul</code> inside it. it's in a <code>if</code> statement but it fires in any case, even if the <code>div</code> doesn't have the <code>ul</code> inside it:</p>
<p><div class="snippet" d... | <p><code>$(".cs-error").has("ul")</code> will give you a <code>jQuery</code> object nonetheless - but an empty one.</p>
<p>So you should check if there was at least one element found:</p>
<pre><code>if ($(".cs-error").has("ul").length) {
</code></pre>
|
Converting EPOCH to Date in Elasticsearch Spark <p>I have a DataFrame that I am writing it to the ES</p>
<p>Before writing to ES, I am converting the <code>EVTExit</code> column to Date, which is in EPOCH.</p>
<pre><code>workset = workset.withColumn("EVTExit", to_date(from_unixtime($"EVTExit".divide(1000))))
workset... | <p>Let's consider the <code>DataFrame</code> example from your question : </p>
<pre><code>scala> val df = workset.select("EVTExit")
// df: org.apache.spark.sql.DataFrame = [EVTExit: date]
scala> df.printSchema
// root
// |-- EVTExit: date (nullable = true)
</code></pre>
<p>You would need to cast the column in... |
DNS solution for someuser.com -> domain.com/some-user <p>Let's suppose there is a webpage where someone can create his own profile page. </p>
<p>His profile page is then available at</p>
<pre><code>domain.com/some-user
</code></pre>
<p>Then, this user with profile domain.com/some-user, own his own domain</p>
<pre><... | <p>One possible solution is to redirect him to domain.com host, and via apache, redirect him to domain.com/some-user.</p>
<p>You can do it in several technologies as Java, Php, Ruby, Node, since it's a http header field (host), which you can read and do the processing that you want.</p>
<p>For instance, using apache ... |
creating custom callback validation rule in codeigniter 2.x <p>how can I create custom validation rule in codeigniter 2.x which can be commonly used throughout application?</p>
<p>I know we can create callback functions in controller, which can then be used in validation rule as - </p>
<pre><code>$this->form_valid... | <p>I too faced the same problem. So I came across a solution for creating validation function, common all around the controller. </p>
<p>Create a file <code>MY_Form_validation.php</code> in the directory <code>/application/libraries/</code> with following code - </p>
<pre><code><?php
if (!defined('BASEPATH'))
... |
RequestPermissions not showing a dialog box <p>I found a lot of similar topics with the same threat but I still can't find a solution for my problem. I wrote this code to grant the writing permission to the app but there is no dialog box showing. I get in the monitor the No writing permission messages. </p>
<pre><code... | <p>I had a similiar case. Do not try to call it with <code>ActivityCompat</code> from a Fragment. Instead use the given <code>requestPermissions</code> method from the Fragment e.g.</p>
<pre><code> requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 225);
</code></pre>
|
libhardware.so is failing to load in Android N. Is this due to new Android N policies? <p>My app uses libhardware.so from android system/lib. It is a native app. upto Android M It's working fine but when try to run it with Android N. It is showing dlopen failed library libhardware.so not found.</p>
<p>Recently I came ... | <p>Yes. The list of libraries that you're able to load from the system is <a href="https://android.googlesource.com/platform/ndk/+/cc508145a36939c74399a90b9092673cf54e67f4/build/core/build-binary.mk#61" rel="nofollow">https://android.googlesource.com/platform/ndk/+/cc508145a36939c74399a90b9092673cf54e67f4/build/core/bu... |
Activity - Intent sent info to MainActivity <p>I have a problem to recovery the data of the MainActivity from activity2.</p>
<p>The activity2 has this code:</p>
<pre><code>public class Activity2 extends Activity {
Button btnAcepta, btnCancela;
@Override
protected void onCreate(Bundle savedInstanceState)... | <p>You need to pass the proper <code>context</code> in the intent <code>i</code> since <code>this</code> refers to the anonymous class for you click listener. Change the following line:</p>
<pre><code>Intent i = new Intent(this, MainActivity.class);
</code></pre>
<p>to this:</p>
<pre><code>Intent i = new Intent(Act... |
401 error for tastypie for api_client <p>Hi I am trying to write a test case for my app. URL = '/api/project/'. I have enabled get, post and put methods along with authentication. But still i get 401 error for post request</p>
<pre><code>class EntryResourceTest(ResourceTestCaseMixin, TestCase):
class Meta:
... | <p>Use <code>BasicAuthentication</code> instead of <code>Authentication</code>.</p>
<p><code>self.create_basic(...)</code> create a headers for <code>BasicAuthentication</code>.</p>
<pre><code>def create_basic(self, username, password):
"""
Creates & returns the HTTP ``Authorization`` header for use with ... |
How to decrypt AWS S3 file during download? <p>Here is my download code :</p>
<pre><code> IAmazonS3 client;
string key = tenant_id + @"/files/" + filename;
try
{
using (client = new AmazonS3Client(Amazon.RegionEndpoint.USEast1))
{
... | <p>It depends on how the file was encrypted. S3 supports <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingClientSideEncryption.html" rel="nofollow">client-side encryption</a> and <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html" rel="nofollow">server-side encryption</a>.</p>... |
Excel RoundUp with IF statement not working. <p>I am trying to capture items that are > 80% to multiply by 3, IF not, to multiply by the percentage given, then round up<a href="http://i.stack.imgur.com/eTLLl.png" rel="nofollow">1</a>]<a href="http://i.stack.imgur.com/eTLLl.png" rel="nofollow">1</a>. However, I'm receiv... | <p>The RoundUP() requires two arguments. The second sets the place to which to round.</p>
<pre><code>=ROUNDUP(IF(H2>.79,G2*3*H2,IF(H2<.8,G2*3*H2,0)),2)
</code></pre>
<p>This will round up to the hundredth place. The 2 is the significant diggits in the decimal. To do it to the Tens it would be -1. To the int... |
Set cookie depending on domain in .htaccess <p>I have two domains and I want to set different languages for them. For domain.pl I want to set cookie lang=pl and for domain.eu I want lang=en, anyone know how to set it in .htaccess?</p>
| <p>You can use these rules to write cookie that depends on domain:</p>
<pre><code>RewriteEngine On
# set cookie lang=pl
RewriteCond %{HTTP_HOST} \.pl$ [NC]
RewriteRule ^ - [L,CO=lang:pl:%{HTTP_HOST}]
# set cookie lang=en
RewriteCond %{HTTP_HOST} \.eu$ [NC]
RewriteRule ^ - [L,CO=lang:en:%{HTTP_HOST}]
</code></pre>
|
Error while unmarshalling json with Jackson 2 <p>I am trying to unmarshal the following JSON file using Jackson 2 :</p>
<pre><code>{
"mapID": "123",
"objects": [
{
"mapID": "123",
"objectID": "12",
"properties": {
"type": "2",
"maxSpeed": "110",
"name": "name1",
... | <p>In json example <code>coordinates</code> is array of array of double, but in java code it's array of objects:</p>
<p>You need to adjust JSON to format like next:</p>
<pre><code>"coordinates": [
{
latitude : 4.54559326171875,
longitude : 45.754109791149865
}
]
</c... |
matplotlib 2D plot from x,y,z values <p>I am a Python beginner.</p>
<p>I have a list of X values </p>
<pre><code>x_list = [-1,2,10,3]
</code></pre>
<p>and I have a list of Y values</p>
<pre><code>y_list = [3,-3,4,7]
</code></pre>
<p>I then have a Z value for each couple. Schematically, this works like that:</p>
<... | <p>Here is one way of doing it:</p>
<pre><code>import matplotlib.pyplot as plt
import nupmy as np
from matplotlib.colors import LogNorm
x_list = np.array([-1,2,10,3])
y_list = np.array([3,-3,4,7])
z_list = np.array([5,1,2.5,4.5])
N = int(len(z_list)**.5)
z = z_list.reshape(N, N)
plt.imshow(z, extent=(np.amin(x_list)... |
Remove objects with a duplicate property from List in c# <p>I Have a list and I want to create a new one without records with duplicate values</p>
<pre><code>public List<links> results = new List<links>();
public List<links> final_results = new List<links>();
public class links
{
public str... | <p>If you want to suppress records with equality in 3 preperties <code>url</code>,<code>title</code>and <code>description</code>, you have to group by all of them:</p>
<pre><code>final_results = results.GroupBy(n => new {n.url, n.description, n.title})
.Select(g => g.FirstOrDefault()).ToLi... |
Finding all aliases for a server via Java code <p>I have faced with inability to find all aliases for a domain name using <a href="https://docs.oracle.com/javase/7/docs/api/java/net/InetAddress.html" rel="nofollow">InetAddress</a>. Is there any way to grep them through Java in order to accomplish matching the results ... | <p>It seems the only way to do this is to use native command line lookup though java Runtime class and further parse the cmd result string as in the below example </p>
<pre><code> private static String execCmd(String cmd) {
java.util.Scanner s = s = new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStre... |
npm WARN deprecated minimatch@2.0.10 but I have a newer version <blockquote>
<p>npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2
or higher to avoid a RegExp DoS issue</p>
</blockquote>
<p>I'm on windows 10 trying to install Cordova. I know that this question was asked a lot and if I look clos... | <p>It seems that a dependency uses an old version of minimatch. You can find it by using</p>
<pre><code>npm ls minimatch
</code></pre>
<p>See <a href="https://docs.npmjs.com/cli/ls" rel="nofollow">https://docs.npmjs.com/cli/ls</a></p>
|
Can you define multiple actions with the same name in Rails? <p>In asp.net MVC, you can define multiple action methods with the same name, as long as the arguments (the method signature in other words) is different. Can you do this in Rails, or do you have to settle with switch statements inside the same action?</p>
| <p>No you can not define multiple actions with the same name.</p>
<p>It is independent of Rails, it's Ruby thing - the latter definition of the method will just override the former.</p>
<p>One of the solutions is to make method accept more arguments (some might be optional, for example) and differentiate based on the... |
How can achieve uniform column content spacing with Bootstrap's grid? <p>i am trying to set a few elements with different types - in one row using Bootstrap, problem is the spaces are aligned incorrectly.... suppose i'm using the grid system, how can i tweak the spaces between the elements?</p>
<p>Thanks!</p>
<pre><c... | <p>It would be cumbersome and awkward to try and customize spacing between grid column contents, especially in a responsive site. Instead, use <a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/" rel="nofollow">flexbox</a> (if <a href="http://caniuse.com/#feat=flexbox" rel="nofollow">browser support</a> is... |
Why Shell script runs with dangling '}'? <p>I wrote this script to compile and run my C and java programs with a single command.</p>
<pre><code> 1 run(){
2 gcc -lm $1 && ( shift; ./a.out $* )
3 }
4
5 jrun(){
6 clas=`echo $1 | cut -d'.' -f1 `
7 javac $1 &... | <p>You need a semicolon after the <code>$*</code> to separate the brace. As it is, it's simply interpreted as an argument to <code>javac</code>.</p>
<p>As an aside, you are probably looking for</p>
<pre><code>run(){
gcc -lm "$1" || return
shift
./a.out "$@"
}
jrun(){
javac "$1" || return
local clas... |
Accessing object from list comprehensive search in Python <p>I am using a list comprehensive 'search' to match objects of my employee class. I then want to assign a value to them based on who matched the search.</p>
<p>Basically the code equivalent of asking who likes sandwiches and then giving that person a sandwich.... | <p>As I've learnt that the list comprehensive produces a list (stupid as that might sound :) ) I've added a for loop to iterate over the matchingEmployee list to give the sandwich to whoever wants it.</p>
<pre><code>if matchingEmployee:
print 'Employee(s) found'
for o in matchingEmployee:
o.food = b
</code></pre>... |
How to prevent this Cyclic polynomial hash function from using a type constraint? <p>I am trying to implement the <a href="https://en.wikipedia.org/wiki/Rolling_hash" rel="nofollow">Cyclic polynomial hash function</a> in f#. It uses the bit-wise operators ^^^ and <<<. Here is an example of a function that hash... | <p>In the implementation, you are converting the value in the array to an Integer using the <code>int</code> function as follows: <code>int pattern.[index]</code></p>
<p>This creates a constraint on the type of array elements requiring them to be "something that can be converted to <code>int</code>". If you mark the f... |
What kind of data are exponent and modulus in c# RSACryptoServiceProvider? <p>I have the public key generated in c# with RSACryptoServiceProvider: </p>
<pre><code><RSAKeyValue>
<Modulus>
4kKhD/FWAMtQTRifArfXjxZN+6bOXTkHrVpyz/1wODhSOBqDewoSOFAp5boBd3wFjXszHA+gpUxZNWHRTj898Q==
</Modulus>
... | <p>In the XML representation here the numbers are Base64-encoded Big Endian byte array representations of numbers. The most sensible string format for them (other than Base64) is Hexadecimal, since that aligns at the byte boundaries; and you might have a Hex to BigInt decode routine.</p>
<p>Exponent</p>
<pre><code>B... |
Dynamically added TextInputLayout is not shown in LinearLayout <p>I am adding a View in a LinearLayout, this way:</p>
<pre><code>LinearLayout ll=(LinearLayout)findViewById(R.id.linearlayout);
TextInputLayout til=new TextInputLayout(MainActivity.this);
til.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.Layo... | <p>I think what you are forgetting is to add an EditText or a TextInputEditText to the TextInputLayout.</p>
<p>The android documentation says:</p>
<blockquote>
<p>[TextInputLayout is a] Layout which wraps an EditText (or descendant) to show a floating label when the hint is hidden due to the user inputting text.</p... |
Error: Unknown authentication strategy "local" (Express & Passport) <p>I'm trying to use passport authentication within express app.</p>
<pre><code>router.get('/signup', (req ,res) => {
res.render('signup');
});
router.post('/signup', function(req, res, next) {
var username = req.body.username;
var password ... | <p>It looks like you haven't setup Passport to use your passport-local strategy yet.
You'll need to import it, instantiate it, and then instruct Passport to use it. Here's an example:</p>
<pre><code>var LocalStrategy = require('passport-local').Strategy;
passport.use(new LocalStrategy(
function(username, password, ... |
How to change port of Pentaho 5.1 <p>May I ask How to change port of Pentaho 5.1. I am using windows 10. Now the value is 8080 but I need to change, I have searched on the internet information, they asked me to modify some xml file, but the problem is, the files they mentioned does not exist in my Pentaho.<br>
Thank yo... | <p>According to this official 5.1 <a href="https://help.pentaho.com/Documentation/5.1/0P0/000/050" rel="nofollow">documentation</a>,</p>
<p>Edit this <code>/pentaho/server/biserver-ee/tomcat/conf/server.xml</code>.</p>
<pre><code><!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector port="... |
Node/Express Redirect After POST <p>I have an Express post route which updates a mongo db based on data sent to it from a DataTables Editor inline field. So far so good and the database is updating fine. Where it falls over is after the update query executes successfully and I want to then redirect back to the originat... | <p>I think, there is a misconception on how redirect is working. Redirect is a HTTP mechanism, which makes your browser to redirect the request (i.e. <strong>make the same request 2nd time to a different URL</strong>).</p>
<p>POSTs are not supposed to be redirected, cause user was submitting the data to a particular s... |
How to replace ties with NA in R <p>I am working on a function to return the column name of the largest value for each row. Something like:</p>
<pre><code>colnames(x)[apply(x,1,which.max)]
</code></pre>
<p>However, before applying a function like this is there a straight forward and general way to replace ties with N... | <p>Here's a simple approach to replace any row-wise duplicated values with <code>NA</code> in a matrix <code>m</code>:</p>
<pre><code>is.na(m) <- t(apply(m, 1, FUN = function(x) {
duplicated(x) | duplicated(x, fromLast = TRUE)}))
</code></pre>
<p>But consider the following notes:</p>
<p><strong>1)<... |
Convert Firebase timestamp in second? <p>I have a chat on my iOS and Android application, and I was using the local timestamp in the message.<br>
I know this is a huge mistake...<br>
I would like to use Firebase timestamp.</p>
<p>On iOS I was using <code>NSDate().timeIntervalSince1970</code>, which is in second.<br>
B... | <p>Isn't it simply to just divide it by 1000? Then you get seconds...</p>
|
Range(String) Excel VBA <p>I am trying to make this code running:</p>
<pre><code>Dim myrange As String
For i = LBound(lOffsets) To UBound(lOffsets)
myrange = "R" & CStr(2 * i + 4) & ":S" & CStr(2 * i + 5)
Set rangeT = Worksheets("ChartBuilder").Range(myrange)
Charts("overview").SeriesCollecti... | <pre><code>Dim myrange As String
For i = LBound(lOffsets) To UBound(lOffsets)
myrange = "R" & CStr(2 * i + 4) & ":R" & CStr(2 * i + 5) & "," & "S" & CStr(2 * i + 4) & ":S" & CStr(2 * i + 5)
Set rangeT = Worksheets("ChartBuilder").Range(myrange)
ActiveSheet.ChartObjects("ov... |
Watch for Promise completion, then exec next Promise. Observable vs Promise? <p>Basically I have calls to different SQL stored procedures that return Promises. Normally these would begin/end in random orders since they are asynchronous. I need to control the order each procedure is called. </p>
<p>I have tried using <... | <p>Yes, observables would be great in this scenario</p>
<pre><code>saveChanges(record) {
this.callCustomerIUD(record).take(1).subscribe((data: any) => {
// Observables can be subscribed to, like a .then() on a promise
// data will be the response from the http call
this.callCustFieldIUD(data).take... |
Dynamic partial arguments in AngularJS routing <p>I'm working with an angularjs site and have a background with working with routes in Rails and also Laravel in php. With routes in Laravel we could dynamically create a set of routes similar to:</p>
<pre><code> foreach($cities as $city):
Route::get($city.'/hotels'... | <p>How about defining a single route with a paramater ?
In angularjs v1.x you can defined as many routes you want with as many params xor query</p>
<pre><code>.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/city/:slug', {
templateUrl: 'book.html',
controller: 'BookController',... |
Parse Pandas Column to date from string with dashes <p>Trying to parse pandas columns <code>df['day']</code> into datetime type. Values are current written as strings, such as: <code>2016-9-1</code>. This corresponds to Year-Month-Day.</p>
<p>I'm following the formatting from this page:
<a href="http://strftime.org/" ... | <p>You need remove <code>-</code> in parameter <code>format</code>:</p>
<pre><code>df = pd.DataFrame({'day':['2016-9-1']})
print (df)
day
0 2016-9-1
print (pd.to_datetime(df['day'], format="%Y-%m-%d"))
0 2016-09-01
Name: day, dtype: datetime64[ns]
</code></pre>
<p>EDIT:</p>
<p>So it looks like some bad d... |
How do I write dynamic queries to implement this logic in plsql? <p>Code goes like this-</p>
<pre><code>If value = 1 then
logic1
elsif value = 2 then
logic1 + logic2
elsif value = 3 then
logic1 + logic2 + logic3.
endif;
</code></pre>
<p>Logic 1,2,3 has data from same table but columns are different.
In case of ... | <p>you can also use dynamic SQL statement like this example and adapt to your case if it is the kind of dynamic queries that you want.</p>
<pre><code>DECLARE
TYPE EmpCurTyp IS REF CURSOR;
v_emp_cursor EmpCurTyp;
emp_record employees%ROWTYPE;
v_stmt_str VARCHAR2(200);
v_e_job employees.j... |
Using many dynamic Google Maps on modals on the same page - Rails <p>I have a shops page with 12 stores. Each store has a button to show it's individual position on the map. The problem is it's not working <strong>(I get the same position on every map, it's supposed to be dynamic)</strong>.</p>
<p><strong>What I'm doi... | <p>Create a global function (perhaps in <code>app/assets/application.js</code>) that might look something like this:</p>
<pre><code> function addShopMap(shop_id, lat, lng, direction){
var mapOptions = {
zoom: 3
};
var map = new google.maps.Map(document.getElementById('map-canvas-'+shop_id),
... |
Looping through unique dates in PostgreSQL <p>In Python (pandas) I read from my database and then I use a pivot table to aggregate data each day. The raw data I am working on is about 2 million rows per day and it is per person and per 30 minutes. I am aggregating it to be daily instead so it is a lot smaller for visua... | <p>Here's an example: Suppose that you have a table</p>
<pre><code>CREATE TABLE post (
posted_at timestamptz not null,
user_id integer not null,
score integer not null
);
</code></pre>
<p>representing the score various user have earned from posts they made in SO like forum. Then the following query</p>
<... |
Python - Filename validation help needed <p>Bad Filename Example: <code>foo is-not_bar-3.mp4</code>
What it should be: <code>foo_is_not_bar-3.mp4</code></p>
<p>I only want to keep a <code>-</code> for the last bit of the string if it is a digit followed by the extension. The closest I have gotten thus far is with th... | <p>You can use regex replacement with a negative lookahead:</p>
<pre><code>import re
fname = 'foo is-not_bar-3.mp4'
f = re.sub(r'\s|-(?!\d+)', '_', fname)
print(f)
>> 'foo_is_not_bar-3.mp4'
</code></pre>
<p>This will replace every <code>-</code> and space with <code>_</code> <strong>unless</strong> it is follo... |
wit.ai capture free text from whatever the user gives you <p>I have the following problems.
I have several points into the conversation where I have to capture "free" text.
Ex: what are your thoughts on xyz ? why do you want xyz ?... They are opened questions and the user can answer whatever they want.</p>
<p>How to I... | <p>I got the same problem and ended up solving it client-side by setting a certain context. I have an older bot that doesn't have the "Stories" interface, so this solution may not apply to your case, but maybe it is of some help.</p>
<ol>
<li>When the bot sends an open question, it should also set a special context i.... |
Control run of depends target ant? <p>Based on whether a certain property is set I want to decide whether I want to run a target <strong>and its dependencies</strong></p>
<p>Now I know that the "if" attribute can only control the run of the target in which it is specified and not the dependencies.</p>
<p>Is there any... | <p>This has already been asked before in <a href="http://stackoverflow.com/questions/9376366/is-there-is-a-way-to-check-ant-target-condition-before-target-dependencies-get-e">this question</a>. The answer there applies very well. However, depending on how frequently the target is going to be invoked, another solution (... |
Create a .NET Core template in visual studio <p>When I make a template from a .NET Core console application and create a new project with the just made template it always seems to be empty. Is the template functionality simple not working for .NET Core projects yet?</p>
<p>My result: </p>
<p><a href="http://i.stack.i... | <p>You can try this. Open up the zipfile and edit the .vstemplate file. The line that is missing is</p>
<pre><code><CreateInPlace>true</CreateInPlace>
This line goes between
<TemplateData></TemplateData>
</code></pre>
<p>This solves the problem for .NET Core 1.0.1 Tooling Preview 2, VS2015 Up... |
Printing the current minute in a loop with python <p>I'm using python 3 and trying to create a script that runs constantly, and at some time, execute a specific code.
The code i have so far, verifies the current minute, and if it's above a given minute, it print's a message, otherwise, it prints the current minute and ... | <p>Some programming pointers: </p>
<p>1) To make a constant loop use the following construct:</p>
<pre><code>while (True):
if (...):
....
break
</code></pre>
<p>2) The time stored in your "now" variable is static must be updated with the new time within the loop:</p>
<pre><code>while (True):
no... |
Can't use mkdir in NPM script from Windows <p>I'm trying to have a script that looks like this:</p>
<pre><code>{
"scripts":
"setup": "mkdir -p ./my-dir"
}
</code></pre>
<p>And it fails, at least on Windows, even if I run it from a Git Bash prompt. Even trying just <code>mkdir ./my-dir</code> doesn't work.... | <p>This module possibly will solve your problem:
<a href="https://www.npmjs.com/package/mkdirp" rel="nofollow">https://www.npmjs.com/package/mkdirp</a></p>
|
Swift: Change Simulator Location programmatically <p>I am looking for a way to change the <code>Simulator</code> location programatically. </p>
<p>I know that I can Use a <code>GPX</code> file and then select it in the <code>Xcode</code> teleport option however this is not what I want. </p>
<p>There seems to be eithe... | <p>Im afraid there is no easy way to do this. This has been asked quite a lot and you can see other posts with the same answers. </p>
<p>The best way you can automate this is to:</p>
<ol>
<li><p>create all the <code>GPX</code> files you need with the different locations</p></li>
<li><p>create a build script that sele... |
Is there a way to find out any information about objects being released using chrome dev tools <p>I have the following code:</p>
<pre><code>var constructors=[];
var counter = 0;
function start() {
for (var i=100; i> 0; i--) {
constructors.push(new arrayValues());
}
if (counter < 10) {
... | <blockquote>
<p>The question is not how to find the information by analyzing the code,
but to find it using crhome-dev-tools</p>
</blockquote>
<p>If interpret Question correctly, you can use <a href="https://developers.google.com/web/tools/chrome-devtools/debug/console/console-reference?hl=en#profile" rel="nofollo... |
DateDiff in SSIS <p>I want to include a datediff into my SQL Command in SSIS but I am receiving the error below:</p>
<p><a href="http://i.stack.imgur.com/mJhct.png" rel="nofollow"><img src="http://i.stack.imgur.com/mJhct.png" alt="enter image description here"></a></p>
<p>I have done quite a bit of research but canno... | <p>As suggested by Martin, there is no DATEDIFF command for postgres. The workaround is using DATE_PART:</p>
<pre><code>((DATE_PART('day', created_at::timestamp - completed_at::timestamp) * 24 +
DATE_PART('hour', created_at::timestamp -completed_at::timestamp)) * 60 +
DATE_PART('minute... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.