input_text_instruct
stringlengths
288
45.8k
output_text
stringlengths
37
33.2k
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: R regular expression: how to extract elements that contains two character in a certain order?<p>I'm trying to use regular expression to extract certain eleme...
<pre><code>grep('abc.*5', testvec, value = TRUE) # [1] "abc5" "aaabc3fs55" </code></pre> <p>Meanwhile your <code>.abc.5.</code> means: any single symbol, abc, any single symbol, 5, any single symbol.</p> <p>With <code>abc.*5</code> I specified that there can be multiple characters in between abc and 5, and it's...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Efficiently dropping rows from a DataFrame if some row-values are identical with row-values in a second DataFrame<pre><code>import pandas as pd df1 = pd.Dat...
<h3><a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html" rel="nofollow noreferrer"><code>merge</code></a></h3> <p>You can <code>merge</code> with <code>indicator=True</code> and include only those rows marked <code>'left_only'</code>.</p> <pre><code>res = df1.merge(df2.drop('va...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Angular getRawValue but only valid value<p>Hi I need get all value (disabled field too), so I use getRawValue() but I don`t want invalid field value. What ca...
<p>I would do something like that:</p> <pre><code>private function _getValuesNotInvalid(): any { const rawValues = this.form.getRawValue(); Object.keys(this.form.controls).forEach(item =&gt; { if(!this.form.get(item).valid) { delete(rawValues[item]) } }); return rawValues; } ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Optimize SQL query using `COUNT`<p>I have the SQL query (I am using MariaDB/MySQL) below which works fine. But I am wondering if I can simplify/optimize it. ...
<p>I like Barmar's answer, but because of the filtering on <code>b</code>, I suggest a small(?) change. (I rearrange the tables primarily to follow the Optimizer's likely order.)</p> <pre><code>SELECT DISTINCT a.* FROM ( SELECT field1 FROM bbb WHERE xxx = 'x' GROUP BY field1 HAVING COUNT(*) &l...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Issues with signing git commits with GPG<p>I'm having some trouble setting up GPG commit signing with github after performing a windows reinstall.</p> <h1>Is...
<p>I've managed to figure it out!</p> <p>I'm ultimately not quite sure what the issue was specifically, however, after uninstalling GPG4Win and Git, then only reinstalling Git and going through the GPG setup process, I'm now able to perform verified commits. this is using Gits bundled GPG program and no other GPG relat...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Using ASCIIMath, how can we align variables in proper order in a system of linear equations<p>For instance how can we display folliwing in MathJax using ASCI...
<p>This is as close as I could come:</p> <pre><code>{ [ -x_1, , , , ,+,x_4,=,\qquad 130], [ , , , ,x_3,-,x_4,=,\qquad\quad 60], [ , ,x_2,-,x_3, , ,=,-240], [\qquad x_1,-,x_2, , , , ,=,\qquad\quad 50] :} </code></pre> <p>The spacing is a bit <em>ad hoc</em>, but perhaps it is...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Wordpress heading <tag> Forbidden 403 Error (clean install)<p>I keep getting a Forbidden 403 error from <a href="http://mydomain/wp-admin/post.php" rel="nofo...
<p>It was mod_security that was somehow triggered. I contacted hosting provider and they resolved the issue. I'm guessing this occasionally happens with new site deployment.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: SWI-Prolog: Write predicate union(A,B,C) in form C = A ∪ B<p>Is their some way in SWI-Prolog to write predicates with three variables for example <code>union...
<p>No.</p> <p>Not directly. Prolog only supports defining unary operators (prefix/suffix operators such as <code>-- 32</code> or <code>32 ++</code>, both of which correspond to <code>'--'/1</code> or <code>'++'/1</code>) and infix operators (e.g. <code>X is Y</code> which corresponds to <code>is/2</code>).</p> <p>If yo...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Declare two custom blocks.<p>I know that in order to create a new custom block we have to add this part to the config.xml file: </p> <pre><code>&lt;blocks&g...
<pre><code>&lt;blocks&gt; &lt;products1&gt; &lt;class&gt;Company_Namespace_Block&lt;/class&gt; &lt;/products1&gt; &lt;/blocks&gt; </code></pre> <p>The above is: </p> <ul> <li>Namespace for all of your Module's block classes. </li> <li>Area where all of your block classes will reside.<br> <...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to efficiently get all elements along 3rd direction at specified locations in a matrix?<p><code>A</code> is an <code>M*N*S</code> matrix of values and <c...
<p>First of all, I would <em>strongly discourage</em> the use of <code>O</code> as a variable name. It looks like a zero. Similarly, avoid a lower-case <code>l</code> as it looks like a <code>1</code>. Below I will use <code>S</code> in place of your <code>O</code>.</p> <p>You can simply <code>reshape</code> your init...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: TypeError:unsupported format string passed to Series.__format__<p>I am trying to print time in 12 hour clock format but django throws TypeError. works fine f...
<p>Like I said, use strftime to do this dirty work, instead of doing it on your own.</p> <pre><code>from datetime import datetime, timedelta def solve(s, minutes): time_instance = datetime.strptime(s, '%I:%M%p') time_instance += timedelta(minutes=minutes) return time_instance.strftime('%I:%M%p').lower() ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to split a string column in GRAFANA (INFLUXDB)<p>I would like to visualize with GRAFANA some sensor data that I collect with INFLUXDB. The problem is tha...
<pre><code>function toHexString(bytes) { return bytes.map(function(byte) { return (&quot;00&quot; + (byte &amp; 0xFF).toString(16)).slice(-2) }).join('') </code></pre> <p>}</p> <pre><code>function Decode(fPort, bytes) { var tohex = toHexString(bytes); var toascii = hex_to_ascii(tohex); var a = toascii.slice(0).s...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Hibernate validations on save (insert) only<p>We encountered a problem with legacy code. There is a validation set for a "username" field, validating its len...
<p>After two days of research I found out how to make this work.<br> Apparently, specifying validations that would be validated on <code>INSERT</code> only is not that difficult. The only changes required are to set these validations to a specific validation group and to validate this group during <code>INSERT</code>/...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: What are the cons of importing only the application related schema (s) and leaving Oracle metadata (SYS, SYSTEM etc) out when migrating a database<p>I'd like...
<p>Migrating a single schema is normal, and migrating SYS/SYSTEM to a different version of Oracle is likely to cause problems, because part of the upgrade is changing the dictionary tables in those schemas.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: GridView.ItemsSource breaks when Creating a New Window<p>When I run the code while Navigating to a new page:</p> <pre><code>this.Frame.Navigate(typeof(Blank...
<p>Passing an <code>ObservableCollection</code> (or any other <code>INotifyPropertyChanged</code>- or <code>INotifyCollectionChanged</code>-based model) between two different views in UWP is <strong>not recommended</strong>.</p> <p>The reason is that each view in UWP has its own UI thread, which is also the reason you...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to get the origin(in the screen) of a image that placed in the tableviewcell?<p>How to get the origin of a image that placed in the <code>UITableViewCell...
<p><code>UIView</code> has a couple of methods that are very useful for that kind of stuff, they start with <code>convertRect:...</code> and <code>convertPoint:...</code> and end with <code>fromView:</code> and <code>toView:</code>.</p> <p>In your case, calling <code>convertPoint:CGPointZero toView:tableView</code> on...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Clarifying the use of maxReportLatencyUs in SensorManager.registerListener<p><a href="https://developer.android.com/reference/android/hardware/SensorManager....
<p>How do you compute 400000us?</p> <p>The samplingPeriodUs is the period when the sensor stores a sample in the hardware FIFO (Just a hint but typically values sensed within a small variation) without waking up the CPU.</p> <p>The maxReportLatencyUs is the interval when the sensor delivers the stored samples to the ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: unable to resolve "requests". IntelliSense may be missing for this module<p>I have this code: <code>import requests</code> <br> I get this error under reques...
<p>You have to install the requests package first.</p> <p>Simply run <code>pip install requests</code> in your terminal. Here's the <a href="http://docs.python-requests.org/en/master/user/install/" rel="nofollow">requests documentation</a>.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Update fragment from Activity from different thread<p>I'm very new to Androind, trying to figure how fragment and activity should be work together. I have a ...
<ol> <li>Should I try to find fragment using findFragmentByTag in my activity and update UI directly ? Is http volley response is in the same thread ? If no, it is ok to update UI from different thread ?</li> </ol> <blockquote> <p>findFragmentByTag will not be useful since as soon as replace is called, the previou...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: drf - trailing / in url throwing error while calling post api<p>views.py</p> <pre><code>class FurnitureViewSet(mixins.ListModelMixin, mixins.RetrieveModelMix...
<p>I solved the issue by using re_path in urls.py</p> <pre><code>router = ExtendedSimpleRouter() furniture_router = router.register('furnitures', FurnitureViewSet, basename='furnitures') furniture_router.register('tables', TablesViewSet, basename=&quot;tables&quot;,parents_query_lookups=['furniture_id']) urlpatterns =...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Resize list of images with scipy imresize<p>I got a list of images that I want to resize to a certain size.</p> <p>I want to use the imresize function of sc...
<p><code>img</code> variable is only valid in the <code>for</code> loop. so the result of the <code>imresize</code> function is lost after the loop.</p> <p>you have to build a new list with the results.</p> <pre><code>imgs = get_imgs() res = [] for img in imgs: res.append(imresize(img, (82, 100))) </code></pre> ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Place a small array into a big array<p>I have 2 arrays; one is small array and second is big array as follows,</p> <pre><code>import pandas as pd import nump...
<p>You can <code>update</code> <code>big_array</code> in-place:</p> <pre class="lang-py prettyprint-override"><code>big_array.update(small_array) print(big_array) </code></pre> <p>If you want to create a new DataFrame, you can use <code>combine_first</code>:</p> <pre class="lang-py prettyprint-override"><code>out = sma...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Checking a DataFrame string value contains words with certain prefixes<p>First time working with Pandas, and I'm struggling to query the DataFrame for this s...
<p>Pandas <code>str</code> operations aren't vectorised. You can use a list comprehension:</p> <pre><code>df = pd.DataFrame({'Comment': ['motorcycles are cool', 'motorhomes are cooler', 'i love motorbikes', 'nomotor test string', 'some other test string']})...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: t-sql get record where date is exact match or within specified minutes<p>I'm looking to get a record where the date is either an exact match or within 5 minu...
<p>Can use <a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/dateadd-transact-sql" rel="nofollow noreferrer">DATEADD</a> in this manner, to get the time 5 minutes ago:</p> <pre><code>AND (t.LastAccOnTime = @LastAccOnTime OR t.LastAccOnTime BETWEEN DATEADD(minute, -5, @LastAccOnTime) AND @LastAccOnTim...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Should I give my app write access to Program Files?<p>I've built a standalone desktop app using Dash by Plotly. To deploy it I'm using pyinstaller to create ...
<p>The answer, as stated by @PanagiotisKanavos in the comments, isn't to give write access to Program Files. The correct way to implement this is using the <code>tempfiles</code> module of python.</p> <pre class="lang-py prettyprint-override"><code>import tempfile def functionA(): temp_file = tempfile.TemporaryFil...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Unhandled Exception: FormatException: Invalid radix-10 number (at character 1) in Flutter<p>I am trying to convert string to int but it is throwing an except...
<p>The passed string is not a number as it contains non-digit characters like <code>a</code> or <code>f</code>.</p> <p>It seems that you like to parse the input string as a hexadecimal string, in that case provide a radix (number base) value in your code.</p> <p>The following snipped yields the output of <code>3.047725...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Unable to verify the element using protractor Chai<p>I tried to validate the element using the below format, but unable to execute.</p> <p>chai declaration ...
<p>If you are using CucumberJS + Protractor + Chai + Chai-as-promised you should write you expectation as following</p> <pre><code>expect(searchResult.isPresent()).to.eventually.equal(true); </code></pre> <p>You need to add the <code>eventually</code> because you are working with promisses</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Lumen API Upload File Work on Postman, not found on Android Multipart<p>I create api to upload image, it work on postman, but response not found on Android u...
<p>you should remove header (content-type: multipart/form-data) if you using it.</p> <p><a href="https://i.stack.imgur.com/adSKf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/adSKf.png" alt="enter image description here"></a></p> <p>I faced a problem like this once and i found this <a href="https...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to write sqlite transaction that rolls back on any error<p>I have searched extensively on this and I have found a lot of people asking the question but n...
<p>The <a href="http://www.sqlite.org/cli.html" rel="noreferrer"><code>sqlite3</code> command-line shell</a> is intended to be used interactively, so it allows you to continue after an error.</p> <p>To abort on the first error instead, use the <code>-bail</code> option:</p> <pre><code>sqlite3 -bail my.db &lt; mwe.sql...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: React Native - How to prevent full screen video mode in IOS?<p>I am creating a simple video app using the <code>react native</code> for <code>IOS</code>. But...
<p>Simply remove <code>webkit</code> prefix from <code>webkit-playsinline</code> because <code>webkit</code> prefix is no longer required nor it is supported.</p> <p>Following is the correct and modified code snippet of your code you shared in the question:</p> <pre><code>import React, { Component } from 'react'; imp...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I hide/show components by touching not button but screen on React Native?<p>I'm learning React Native for the first time. I want to implement a funct...
<p>Firstly I would highly recommend you use react native with functional components and React Hooks as they alternative will soon will be deprecated.</p> <p>Since <code>onPress</code> is not available on the <code>View</code> Component, you would need to replace it with <code>TouchableWithoutFeedback</code> as you have...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: window.Map is not a constructor in Google Maps API v3<p>I have a google map with a new key</p> <p>but it gets error in console</p> <p>error:</p> <pre><cod...
<p>Map is reserved word in EcmaScript, so you shouldn't use it as a variable name: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map</a></p> <p>The problem is this...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to use cut to separate dates into 1 hour bins<p>I have this list of dates for different days:</p> <pre><code>data = as.POSIXct(c("2017-01-03 06:14:08","...
<p>Here is one way to do it...</p> <pre><code>bucket &lt;- paste0(as.numeric(format(data-60*30,format("%H"))),"30") bucket [1] "530" "530" "630" "630" "630" "630" "730" "730" "830" </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Optimize the if else condition in the code<p>Below is my code.</p> <pre><code>String perfIdValtxt = &quot;&quot;; try { while (resultsOfS...
<p>A handy way</p> <pre class="lang-java prettyprint-override"><code>String perfIdValtxt = &quot;&quot;; try { while (resultsOfSecurityDetails.next()) { perfIdValtxt = Optional.ofNullable(resultsOfSecurityDetails.getString(1)).orElse(&quot;&quot;); } } catch (SQLException e) { e.printStackTrace(); }...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: combineLatest with arrays of observables<p>How would one go about using <code>combineLatest</code> with two or more arrays of observables?</p> <pre class="la...
<p>The <code>combineLatest</code> function expects an array of <code>Observable</code>(s), not an array of array of <code>Observable</code>.</p> <p>So what do you have to do is:</p> <ul> <li>Convert each array of <code>Observable</code>, to an <code>Observable</code>, by combining the inner <code>Observable</code>(s) o...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to add percentage (with) weights to the dict with radnom.choice?<p>I have asked a similar question yesterday, I was recommended to use weights but they u...
<p>Take a look <a href="https://stackoverflow.com/questions/3679694/a-weighted-version-of-random-choice">here</a></p> <p>In your case it's:</p> <pre class="lang-py prettyprint-override"><code>[z] = random.choices(list(operator.keys()), weights=[0.2, 0.8]) </code></pre> <p>or</p> <pre class="lang-py prettyprint-override...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: PHP - How to add a function that terminates form processing when a value is empty?<p>I have a form on my website with a simple PHP code that sends the values...
<p>Try this. </p> <pre><code>&lt;?php if(!empty($_POST ['name']) &amp;&amp; !empty($_POST ['email']) &amp;&amp; !empty($_POST ['subject']) &amp;&amp; !empty($_POST ['message'])){ $fullname = $_POST ['name']; $email = $_POST ['email']; $emne = $_POST ['subject']; $message = $_POST ['message']; $to =...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Create helper function for a (click handler) function to reuse in multiple React components<p>For a 'back' button I've created below (onClick) handler functi...
<p>I also don't see any issue with the code or using it as a utility callback.</p> <blockquote> <p>Is it a good approach make it e.g. a helper function and how exactly?</p> </blockquote> <p>Anytime you can make your code more <em><strong>DRY</strong></em> (<em>Don't Repeat Yourself</em>) it's generally a good thing. My...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to get cart badge in kotlin fragment?<blockquote> <p>I have already created a custom layout for badge counter and on inflating menu my cart icon is not w...
<p>Try this once-</p> <pre><code> override fun onViewCreated(view: View, savedInstanceState: Bundle?) { ... myToolbar.inflateMenu(R.menu.sample_menu) myToolbar.setOnMenuItemClickListener { when (it.itemId) { R.id.action_settings -&gt; { // Navigate...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How i set the data and update the data using array of objects in Flutter/Firebase?<p>I have being trying to update the data from/to Firebase, but i have some...
<p>You're using <code>.set()</code> without explicitly telling it to merge existing fields with the new updated ones.</p> <p>To fix it, tell Firestore to merge your new data with existing ones by passing <code>SetOptions</code>:</p> <pre class="lang-dart prettyprint-override"><code>return await atributteSheet.doc(uid)....
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: RXJS Emit first result and then wait for another observable<p>Currently I have two observables. One returns a list of clients and the other is fired when tex...
<p>You need to merge your observables together :</p> <pre class="lang-js prettyprint-override"><code>let obs = Observable.fromPromise(this.clientService.getClients()) .map((clients) =&gt; { return clients.map((c) =&gt; new Client().fromObject(c)); }).share(); let filtered = obs.switchMap((values) =...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Firebase: get children ordered by Date and Hour keys<p>I have stored in my Firestore DB data about Teachings and their relative Lessons, with Date and Hour. ...
<p>While the Firebase Realtime Database can order its results, the values to order on must be at a fixed path under each direct child node.</p> <p>In your case the value is under a <code>$date/$time</code> of each child node, so the database can't order on those values. You will have to load the into your application c...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Async function returning empty array, and then the desired data - causing app to crash<p>In my react project, I have a function <code>getDetails</code> that ...
<p>just add a check wherever you feel , it is undefined or null.</p> <pre><code> const extractRatings = () =&gt; { const foodRatings = [] !!filteredVenue &amp;&amp; filteredVenue.length&gt;0 &amp;&amp; filteredVenue[0].reviews.map((rating) =&gt; { foodRatings.push(rating.ratingFood) }) return ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to extract a couple of fields nested in response using python<p>I'm a python beginner. I would like to ask for help regarding the retrieve the response d...
<p>If <code>data</code> is your decoded json response from the question then you can do:</p> <pre class="lang-py prettyprint-override"><code># find group `blabla` in result: g = next(d for d in data[&quot;result&quot;] if d[&quot;group&quot;] == &quot;blabla&quot;) # get data from the `blabla` group: number = g[&quot;...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to define nested array in Mongoose Schema<p>I want to define the Model schema below:</p> <pre><code>var myLoc = Schema({ extent : { type: String, ...
<p>You can create a mongoose schema as follows</p> <pre><code>const MyLocationSchema = new Schema({ extent: { type: { type: String, }, coOrdinates: [[[Number]]] } }); module.exports = MyLocation = mongoose.model('MyLocation', MyLocationSchema); </code></pre> <p>Here, I am ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Reading TYPOscript fe_users does not work within a COA<p>I have just the following problem, I would like to spend via TYPOScript a specific FE_user in the te...
<p>Are you sure the username is <code>Safari</code>? Usernames are usually all lowercase in TYPO3. If you added it through the backend it will be cast to lowercase. So it would be <code>safari</code>.</p> <p>You should not have an enter between <code>cObject</code> and <code>{</code>. It should be <code>cObject {</cod...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to push existing docker image to google app-engine<p>I am currently using the app engine maven plugin, which seems to trigger a Google cloud build to bui...
<p>You can deploy to App Engine using a specific Docker image hosted on Google Container Registry by using the <code>--image-url</code> flag like this:</p> <pre><code>gcloud app deploy --image-url=[HOSTNAME]/[PROJECT-ID]/[IMAGE] </code></pre> <p>See doc <a href="https://cloud.google.com/container-registry/docs/pushin...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Pytorch lightning resuming from checkpoint with new data<p>I'm wanting to continue the training process for a model using new data.</p> <p>I understand that ...
<p>Yes, when you resume from a checkpoint you can provide the new <code>DataLoader</code> or <code>DataModule</code> during the training and your training will resume from the last epoch with the new data.</p> <pre class="lang-py prettyprint-override"><code>trainer = pl.Trainer(max_epochs=10, resume_from_checkpoint='./...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Get blob image from MySQL by using Node as json and print it into PHP<p>I'm trying to make a basic image like this :</p> <pre><code>&lt;img src='myImage' /&...
<p>Your array contains every single char as separate element as int. You must iterate by this array and convert it into char by <code>chr</code> function and concatenate in one string:</p> <pre><code>$string = ''; foreach ($yourArray as $el) { $string .= chr($el); } </code></pre> <p>And now you can do with <code>$s...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Omniauth_google_oauth2 Error: redirect_uri_mismatch<p>I am using Devise and Omniauth Google for Login Authentication in my application. Everything works fine...
<p>You need to <a href="https://developers.google.com/identity/protocols/OpenIDConnect#setredirecturi" rel="nofollow">add new redirect URI</a> to your credentials</p> <p>Visit <a href="https://console.developers.google.com/apis/credentials/oauthclient/355308797580-kv7a6sf2hqtr9692kdl3qjvc9vcgvjpi.apps.googleuserconten...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Warnings of Pointer to array of matrices In ANSI C GCC C90<p>I'm having strange warnings in Linux. In Visual Studio on Windows, the code compiles and works w...
<p>Due to this typedef declaration</p> <pre><code>typedef float mat[4][4]; </code></pre> <p>arrays declared like</p> <pre><code>mat MAT_A = { 0 }; </code></pre> <p>are implicitly converted to its first element in this declaration</p> <pre><code>mat *matrices[3] = {MAT_A, MAT_B, MAT_C}; </code></pre> <p>of the type <cod...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I compute the chance of going into a certain state, given the current state?<p>I am trying to compute the change of going into a certain state, given...
<p>The probability is the number of recorded occurrences relative to the total. This is easily done with <a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.value_counts.html" rel="nofollow noreferrer"><code>value_counts</code></a> using the <code>normalize=True</code> parameter:</p> <pre><code>df['Stat...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: I can't increment an unsigned number in VHDL<p>So I tried the main method that I came across on internet and it never worked, I tried many different things b...
<p>You have <code>counter</code> assigned in multiple processes, hence it has multiple drivers. Initially this works as they are both driving '0' on <code>counter</code> as you initialised it to 0, but when you add one, process <code>registre</code> is driving 0 from the reset and process <code>compteur</code> is now d...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Multiplying numpy 2d Array with 1d Array<p>I have a numpy 2d array:</p> <pre><code>[[1,1,1], [1,1,1], [1,1,1], [1,1,1]] </code></pre> <p>How can I get it s...
<p><code>*</code> in <code>numpy</code> does element-wise multiplication, for example multiply 1d array by another 1d array:</p> <pre><code>In [52]: np.array([3,4,5]) * np.array([1,2,3]) Out[52]: array([ 3, 8, 15]) </code></pre> <p>When you multiply a 2d array by 1d array, same thing happens for every row of 2d arra...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Efficiency of multiple chained str transformation and alternatives<p>I'm wanting to change a dataframe column so the values are lower case and also have thei...
<p>You can use a list comprehension:</p> <pre><code>df['col2'] = [x.lower().strip() for x in df['col']] </code></pre> <p>Doing this can be faster than chaining multiple <code>str</code>:</p> <pre><code>%%timeit df['col2'] = df['col'].str.strip().str.lower() # 344 ms ± 12.8 ms per loop (mean ± std. dev. of 7 runs, 1 loo...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to style the slider?<p>I found <a href="https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/xaml-styles" rel="nofollow noreferrer">this tu...
<p>There is a document about the default style and template for the Slider control. You can modify these resources and the default ControlTemplate to give the control a unique appearance. Please refer <a href="https://msdn.microsoft.com/en-us/library/windows/apps/mt299153.aspx" rel="nofollow noreferrer">Slider styles a...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to add animate icon menu dropdown open / closed<p>I built a dropdown menu with fade animation with the help of stackoverflow users. Everything works beau...
<p>You can add font-awesome icons (You have to import the font awesome cdn,https://fontawesome.com</p> <pre><code>&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css&quot; integrity=&quot;sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I take USD Forex Buying and EUR Forex Buying Rates with date from TCMB, using SQL and XML?<p>I want to take USD and EUR Rates from TCMB page.</p> <p>...
<p>Microsoft proprietary <code>OPENXML</code> and its companions <code>sp_xml_preparedocument</code> and <code>sp_xml_removedocument</code> are kept just for backward compatibility with the obsolete SQL Server 2000. Their use is diminished just to very few fringe cases.</p> <p>Starting from SQL Server 2005 onwards, it ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Make flex child to grow according to sibling's height<p>I have two article summaries contained in the same parent, and I need one of the child elements (the ...
<p>You can try using nested flexbox layout. See the demo and comments below.</p> <p><strong><a href="https://jsfiddle.net/t588gjxb/" rel="nofollow">jsFiddle</a></strong></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true"> <div class="snippet-code"> <pre class="snippet-code-css lang-css p...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Best tool for github and gitlab for Microsoft .net application<p>Please suggest best tool for committing the changes github and gitlab for C# .net applicatio...
<p>Most of the editors today already have git integration. Visual Studio Code has a simple <a href="https://visualstudio.github.com/" rel="nofollow noreferrer">extension</a> so you could describe that as "the best tool" (if you work with VS at the moment and would like to have similar UI). <a href="https://atom.io/" re...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How could I use a function thats inside a for loop in python<p>I have a function that prints out the students that has passed an exam. But if I do the functi...
<p>What about this :</p> <pre class="lang-py prettyprint-override"><code>csv_dict_reader = csv.reader(read_obj, delimiter=';',) next(csv_dict_reader) for row in csv_dict_reader: if row[11]: # allPassedStudents.append(row[0]) passedDate = datetime.strptime(row[11], '%d-%m...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How do I send multiple request to let the client know that upload and processing has finished?<p>I'm trying to figure out how I can send multiple requests to...
<p>You actually want to inform the client about updates that happen asynchronously on the server / in the backend.</p> <p>From the top of my head, there are a few ways to achieve getting asynchronous information to the client:</p> <ol> <li>Open a stream and push updates via the stream to the client (<a href="https://...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Combining 2 arrays into their own arrays React<p>I have 2 arrays that I used the map() function to add to an array, but the problem I'm having is they are be...
<p>It would be simpler to do this using an object instead of combining two arrays.</p> <p>Make each review an object that contains a review, name, and your stars like so:</p> <pre><code>{ name: 'a', review: 'good', stars: 5 } </code></pre> <p>This way you could just use one array and push that object instea...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: clickMapObject method in amCharts V4 maps<p>I need a hand to find a way to to replicate the following functionality from amcharts v3 in v4 without success:</...
<p>In v4 you would assign a <code>hit</code> event (<a href="https://www.amcharts.com/docs/v4/concepts/event-listeners/" rel="nofollow noreferrer">our Events guide</a>) on the <code>polygonSeries.mapPolygons.template</code>, e.g.:</p> <pre class="lang-js prettyprint-override"><code>// Open modal on click polygonTempla...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: React state doesn't work, it doesn't rerender components<p>I have problem with react updating state. Well, I didn't touch react for a while and I want to rem...
<p>I understand the issue , Put Navbar in the div or &lt;React.Fragment&gt; element</p> <pre><code> &lt;div onClick={onNavbarCartClcikHandler}&gt; &lt;Navbar onClick={onNavbarCartClcikHandler}&gt; &lt;h1&gt;React meals&lt;/h1&gt; &lt;NavbarCart onClick={onNavbarCartClcikHandler} /&gt; ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Concatenate or join of dynamic array when importing multiple ranges<p>I have a set of hyperlinks to other sheets that will change as new links are added or s...
<p>Google Sheets built-in functions can't convert a TEXT value into formula. This could be done only by using Google Apps Script or the Google Sheets API.</p> <p>The method to be used is <a href="https://developers.google.com/apps-script/reference/spreadsheet/range#setformulaformula" rel="nofollow noreferrer">setFormu...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to add months into a data frame? Python<p>I'd like to add a column into my data frame, the final version that I'd like to have is as follows,</p> <pre><c...
<p>Try adding this line:</p> <pre class="lang-py prettyprint-override"><code>df['Month'] = sorted(TotalMonth*3) </code></pre> <p>Output:</p> <pre class="lang-py prettyprint-override"><code>print(df) Plant Year Month 0 A 2021 1 1 B 2021 1 2 C 2021 1 3 A 2021 2 4 B ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Make position: absolute div the same width as the parent div<p>I have the following set up:</p> <p><div class="snippet" data-lang="js" data-hide="false" data...
<p>You need to use <code>position: relative</code> on <code>.nav-option-container</code>, so that when setting <code>left: 0; right: 0;</code> in the inner child, it will refer to the bounds of its parent:</p> <pre class="lang-css prettyprint-override"><code>.nav-option-container { /* Add this */ position: relative...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: getting a doc read count of a sub collection in firebase?<p>I am trying to change the structure of part of my Db, it a part that is getting called pretty fre...
<p>The nesting of a document doesn't affect how much it costs to read it. One document read is always going to cost the same, no matter what the collection it comes from.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Attempting to build out an extension, but keep getting an error about missing id's?<p>Here is the console error I am getting that is preventing me from acces...
<p>Facebook, which this error seems to be associated with, doesn't actually use the jQuery library. If you run <code>jQuery</code> in your console, you will get an error. The <code>$</code> shortcut is actually a selector for another library. This is why you are getting an error.</p> <p><a href="https://i.stack.imgur....
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: MS Access Form Controls Will Only Move Together, but Not Grouped or Stacked<p>I've been handed an access database that my company had a contractor build out ...
<p>That is simply a control with an associated label. Each can be moved independently by click and hold on the 'small grey box' and drag to desired location. Resize by click and drag on any of the anchor boxes.</p> <p>The 'surrounded by a dashed box' would indicate a Layout Group. Layout can be removed by selecting con...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Elasticsearch - how to bulk insert index + add index to alias?<p>I have a script that creates indices which are generated periodically using the _bulk API. F...
<p>You can use Templates to do this: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-templates.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-templates.html</a></p> <p>Templates allow you to apply settings to newly created indexes automa...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why are my routes not loading the right child?<p>I'm currently studying Angular (CLI v7.1.0) and I'm a little bit confused with routing/modules. I'm building...
<p>Basically the problem is that you need to use <code>lazy loading</code> (that's the easier way, but if you dont want to use <code>lazy loading</code> its also <a href="https://stackoverflow.com/questions/45447069/routing-to-sub-routing-module-without-lazy-loading">possible</a>) - and that's this <code>loadChildren</...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why does this method updates react state very slowly?<p>I have two components. Parent component: Board and child component Cell. I am rendering 9 Cells using...
<pre><code>let newBoard = board; newBoard[2] = &quot;0&quot;; setBoard(newBoard); </code></pre> <p>You are mutating the state. When you set state in a function component, react does a <code>===</code> between the old and new state. Since it's the same array, react thinks nothing has changed, and so the component does n...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Understanding the difference between object.function(argument) and object:function(argument) in Lua<pre><code>obj ={x=30} function obj:printpos() print(se...
<p><code>obj:printpos(other)</code> is equivalent to <code>obj.printpos(obj, other)</code>.</p> <p><code>function obj:printpos() end</code> is equivalent to <code>function obj.printpos(self) end</code>.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to replace part of a strings (multiple) in which, each have separate condition<p>I have a table named Employee which has following columns and values.</p...
<p>You can use REPLACE function as it searches for certain characters in a string and replaces them with other characters.Furtermore, you could use CASE expression to fulfill differnt condition of replacement.</p> <pre><code>UPDATE Employee SET CITY = (CASE WHEN FNAME = 'Mamunur' AND LNAME = 'Rashid' ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Best way to deploy node api on linux server for production<p>By the past, I always used the <a href="https://www.heroku.com/" rel="nofollow">Heroku</a> platf...
<p>First you need to have a persistent background service that will keep NodeJS processes (server instances) running, across crashes and reboots.</p> <p><a href="http://pm2.keymetrics.io/" rel="noreferrer">Pm2</a> is a popular node process manager. It's mostly operates via CLI:</p> <pre><code>npm -g install pm2 pm2 s...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to count an element that exceed our criteria in a list that is in a list that is also in a list (a list with a depth of 4 lists (?))?<p>I'm trying to cou...
<p>If you are allowed to use <code>numpy</code> this can be easily done, consider following example</p> <pre><code>import numpy as np data = [[[1,2],[3,4]],[[5,6],[7,8]]] arr = np.array(data) # create numpy.array print(np.sum(arr&gt;5)) # count elements &gt; 5 print(arr.size) # number of all elements </code></pre> <p>o...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Tensorflow Serving predictions mapped to labels<p>I am serving up the inception model using TensorFlow serving. I am doing this on Azure Kubernetes so not vi...
<p>i tried the approach suggested by @user1371314 but i couldn't get it to work. An other solution that worked is creating a tensor (instead of a constant) and map it with only the first element of the output layer when saving the model. When you put it together it looks like this :</p> <pre><code># get labels names a...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Using @addTagHelper in ASP.NET Core WebAPI. ASP.NET Prerendering<p>I am developing <strong>"ASP.NET Core Web API"</strong> with <strong>"Angular 4"</strong>....
<p>Tag Helpers render custom tags within Views, if you don't have a view there is no requirement for a tag helper or View to contain it. I you need to return html, you will probably need to return that via the API and create your own code to generate Html?</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Creating a Condition in Python that pops everything that doesn't have a certain starting<p>So, I'm trying to create a loop in python that will pop an element...
<p>If <code>clean</code> is a <code>list</code>, the <code>for i in clean</code> will iterate over <em>elements</em> of <code>clean</code> in <code>i</code>, not indices. Also, <code>pop</code> is a function, not a list or a dict, you can't use square brackets on it. Also, removing elements from a list while iterating ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: in another language, text typed in console is not the same as the text in the code<p>I'm trying to ask for input from the console in Hebrew and then compare ...
<pre><code>using System.Text; Console.InputEncoding = Encoding.Unicode; Console.OutputEncoding = Encoding.Unicode; string t = Console.ReadLine(); if (t == &quot;א&quot;) { Console.WriteLine(&quot;yes&quot;); } else { Console.WriteLine(&quot;no&quot;); } </code></pre> <p>Worked for me copy/pasting א in.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I run a postgresql query over array of strings?<p>I'm writing a script which will take all tables from my schema and perform some actions on them. Th...
<p><a href="https://dbfiddle.uk/?rdbms=postgres_9.6&amp;fiddle=d3472efce162375f83c7751b61493d2c" rel="nofollow noreferrer">demo:db&lt;>fiddle</a></p> <p>To get a match for an array element you have to use: </p> <pre><code>-- general case WHERE element = ANY(ARRAY['elem1', 'elem2']) -- your case WHERE table_name = AN...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: JS object and array selection and manipulation<p>When I get ajax data, it is an array:</p> <pre><code>[ {"ID" :"1", "Last":"SMITH", }, {"ID" :"2"...
<blockquote> <p>What do you guys suggest so that there is only one array with multiple ajax array addition? In other words, how I remove the extra [] syntax?</p> </blockquote> <p>You need to use one of the methods that adds multiple elements to the array rather than adds the array itself (see options below).</p> ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Is placement new on a const variable with automatic storage duration legal?<p>Is the following code legal according to the standard?</p> <pre class="lang-cpp...
<blockquote> <p>Is the following code legal according to the standard?</p> </blockquote> <p>The behaviour of the program is undefined:</p> <blockquote> <p>[basic.life]</p> <p>Creating a new object within the storage that a const complete object with static, thread, or automatic storage duration occupies, or within the ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Batch File rename in folder and subfolders adding current dir as prefix to filenames<p>I would like to have a windows batch file which gives prefix to all fi...
<p>...you are near. Add <code>/s</code> parameter to <code>dir</code> to include subdirectories and use <code>~nx</code> modifier for filename + extension for the <code>rename</code> command (<code>%%F</code> would be including the path and <code>rename</code> doesn't like that for the destination (needs <code>filename...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Modelling a Kafka cluster<p>I have an API endpoint that accepts events with a specific user ID and some other data. I want those events broadcasted to some e...
<p>You are correct that one topic per user is not ideal.</p> <p>Partition count is not dependent upon broker count, so this is a better design.</p> <blockquote> <p>If a single external location is failing, that shouldn't delay delivery to other locations.</p> </blockquote> <p>This is standard consumer-group behavior, n...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Client/server pattern to hold local objects?<p>I'm working on an Android application that uses data from a server. I have a singleton Application object hold...
<p>Caching pattern is the answer - look at <a href="http://kircher-schwanninger.de/michael/publications/Caching.pdf" rel="nofollow noreferrer">this</a> </p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I assign a specific maven profile to an intellij run configuration?<p>I have multiple projects loaded into my project structure and they all use diff...
<p>You can assign specific profiles via the dialog "Edit Run Configurations". See this screenshot:</p> <p><a href="https://i.stack.imgur.com/hiNn9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hiNn9.png" alt="enter image description here"></a></p> <p>AFAIK, this profile setting overrides the choice which ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Use a function loaded in a string<p>Okay this is a weird one but so image my code is,</p> <pre><code>$string = "Function Get-Something {Write-host 'You got ...
<p>Dot-source the defining function to have the inner function accessible in the calling scope subsequently:</p> <pre><code>. Validate-Something Get-Something </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Making work play2-auth standard sample<p>I'm trying to make work the <code>play2-auth</code> standard sample, excluding authorizations - just authentication/...
<p>You're currently passing to the form template helper the <code>Action</code> instance for <code>authenticate</code>, rather than the <a href="https://www.playframework.com/documentation/2.5.x/api/scala/index.html#play.api.mvc.Call" rel="nofollow"><code>Call</code></a> instance that should be generated by its <a href...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Pandas groupby cumulative count<p>How do I do a cumcount on two groupings, id and name? For example I have: </p> <pre><code>id name 1 name1 1 name1 1 ...
<p>You can use <code>groupby.cumcount</code>:</p> <pre><code>df['cumcount'] = df.groupby(['id', 'name']).cumcount() + 1 df # id name cumcount #0 1 name1 1 #1 1 name1 2 #2 1 name2 1 #3 2 name3 1 #4 2 name3 2 #5 2 name3 3 </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: pandas dataframe groupby apply multi columns and get count<p>I have a excel like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <t...
<p>For count matched rows chain both conditions by <code>&amp;</code> for bitwise <code>AND</code> and aggregate <code>sum</code>, <code>True</code>s are processing like <code>1</code> and <code>False</code> like <code>0</code>:</p> <pre><code>df1 = ((df.a&gt;=30) &amp; (df.b==0)).astype(int) .groupby(df['ye...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to read not my own bucket with python and boto3?<p>I know bucket name, I have access to it, I can browse it by web and by awscli.</p> <p>How access it b...
<p>If you have access to someone else's bucket and you know the name of that bucket you can access it like </p> <pre><code>import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('some-bucket-i-have-access-to') for obj in bucket.objects.all(): print(obj.key) </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: JHipster Using LDAP Authentification<p>I've started to use JHipster weeks ago and everything went find since now. I want to have a LDAP authentification with...
<p>Well I tried something that work, I don't know if this is how I should have done, but since I've found nothing about that, and it's not documented alot, I'll stick with that solution unless I find a better solution.</p> <pre><code>// PersistentTokenRememberMeServices.java protected void onLoginSuccess(HttpServletR...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: UrbanCode Deploy Export / Import of Components<p>Is it safe to create a new UrbanCode Deploy component by exporting the original component to a JSON file, ch...
<p>It is much safer and quicker to just use the "Copy" action for the component if you can. Is there some reason you can't? If you have to import, it should be ok, but you likely want to make sure you leave all of the Import Component options as the defaults (e.g. leave the Upgrade component checkbox empty) to avoid ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Filtering numbers above a certain threshold for multiple columns in R<p>I have a data set with with 600+ variables and I would like to only keep the rows whe...
<p>We need to specify the columns (<code>.cols</code>) within the <code>if_all</code>. By default it is <code>everything()</code>, so we change to match only the columns that starts with (<code>^</code>) 'variable' followed by a dot (<code>.</code>), four digits (<code>\\d{4}</code>)..., within the <code>matches</code...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Redirecting a list of folders with .htaccess<p>I recovered a project but it is not generic at all. I looked a bit what was on .htaccess but it is not obvious...
<p>What I used was something like this:</p> <pre><code>RewriteCond %{REQUEST_URI} !www/ RewriteCond %{REQUEST_URI} folderA RewriteRule (.*) /www/index.php [L] RewriteCond %{REQUEST_URI} !www/ RewriteCond %{REQUEST_URI} folderB RewriteRule (.*) /www/index.php [L] </code></pre> <p>This is a quick-n-dirty approac...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: imagemagick with grayscale not working<p>I am trying to change a file named "anvil_base.png" to grayscale so I am using imagemagick. What I am entering is <c...
<p>I suspect you are on Windows and you have not put the directory where ImageMagick is installed ahead of other directories in your PATH. You have three choices:</p> <p><strong>Option 1</strong></p> <p>As Glenn kindly points out, if you are using ImageMagick version 7 or newer, you can use the new name for <code>con...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Entire nav bar overlapping the content below<p>I'm having an issue with the CSS of the navigation bar.<a href="https://i.stack.imgur.com/fCIgO.png" rel="nofo...
<p>add following css</p> <pre><code>ul#nav { overflow: visible; } ul#nav li { position: relative; } .dropdown-content { position: absolute; left: 0px; top: 100%; } </code></pre>