input
stringlengths
51
42.3k
output
stringlengths
18
55k
Bash scripting - Complex MYSQL statements <p>So I am trying to take this:</p> <pre><code>SELECT 'cran_juniper' AS `set`, c.* FROM cran_juniper c WHERE ROW(c.device_fqdn, c.device_ip, c.interface, c.admin_state, c.link_state, c.description) NOT IN ( SELECT device_fqdn, device_ip, interface, admin...
<h3>1st solution using <em>here-doc</em> :</h3> <pre><code>mysql -h 127.0.0.1 &lt;&lt;'EOF' SELECT 'cran_juniper' AS `set`, c.* FROM cran_juniper c ... ; EOF </code></pre> <h3>2nd solution using a separate file</h3> <pre><code>mysql -h 127.0.0.1 &lt; file.sql # you will put all of your query within this file </c...
Swift Console Output to Text Label <p>I am trying to take console output from a json request and post it as a text label for the user. I can't seem to get it to work. Any advice? Thanks! It prints fine in the console, but won't work for the "self.resultLabel.text = json"</p> <pre><code>do { let json = try NSJSONSe...
<p>I am not sure why exactly you want to show raw json to users in UILabel but you should convert json to a string if you want to assign it to UILabel's <code>text</code> property.</p> <p>There is a <code>description</code> method, which is always used in Objective-C whenever you print an NSObject subclass via NSLog. ...
How to Filter Data with D3.js? <p>I've been searching all online but I can't really find what I'm looking for. I think maybe I'm not using the right terminology. </p> <p>I have a simple scatterplot in D3.js. My csv file is like: </p> <pre><code>Group, X, Y 1, 4.5, 8 1, 9, 12 1, 2, 19 2, 9, 20 3, 2, 1 3, 8, 2 </code>...
<p>You have a good start here! To make this even better, you need three things. A UI component for selecting the group, an event listener for detecting a change in this component, and a function for handling the update to the visualization.</p> <p>In the code I added, I've created three new functions for each part of ...
Jquery displays link text instead of image <p>for my wordpress site I have replaced the bottom paging-navigation with a load more function.</p> <p>This used to say the text "load more" but I have replaced it with an image, or at least that is the plan.</p> <p>The jquery is just showing the link to the file, instead o...
<p>You have <code>display: none;</code> style for img with class <code>load_more_img</code>. That's why loading image isn't showed (As I understand you want to show it after click "show more"). Also you render <code>_load_more.plus</code> value which is path of the image to the content of <code>&lt;a&gt;&lt;/a&gt;</cod...
Google Analytics Destination Goal not Being Tracked <p>I'm trying to set up a Google Analytics Goal using the following settings(this is a simplified version of what's being used):</p> <p>Goal setup: custom, Goal type: destination, Destination: "Equals to" /en-us/industries/chemical-petrochemical , Value=Off, Funnel=O...
<p>It turns out a filter was preventing the goal from being reached. The filter was pre-appending the hostname of the URL.</p>
How to extend Spree::Adjustable::Adjuster? <p>I’m trying to extend Spree::Adjustable::Adjuster as documented in the guide (<a href="http://guides.spreecommerce.org/developer/adjustments.html" rel="nofollow">http://guides.spreecommerce.org/developer/adjustments.html</a>). The directions aren't to hard to follow and I ...
<p>What version of Spree are you using?</p> <p>This feature was added in 3.1.</p> <p><a href="https://github.com/spree/spree/blame/3-1-stable/core/app/models/spree/adjustable/adjuster/base.rb" rel="nofollow">https://github.com/spree/spree/blame/3-1-stable/core/app/models/spree/adjustable/adjuster/base.rb</a></p> <p>...
ABI Split failed in NativeScript 2.3.0 <p>I’ve asked for help in the general group but most people didnt get it work as well. Im having a huge problem ridiculous apk size of my simple app. I used @markosko nativescript filter to reduce the app to 14MB from 17.2MB, even <code>nativescript-snapshot</code> couldn't help...
<p>ABI splits can be useful if you use them one at a time. Here's an example: </p> <pre><code>android { ... splits { abi { enable true reset() include 'armeabi-v7a' } } ... } </code></pre> <p>The resulting .apk file will only contain the libraries necessa...
jQuery toggle doesn't work in my page <p>I want to toggle a div with jQuery toggle function.</p> <p>Here is my code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(docum...
<p>You are right, its the reload. If the onliest thing you want to do by button-click is to toggle then add an preventDefault like this. Or are there other events you want to trigger by the button-click?</p> <pre><code>$("#removeSongButton").click(function (e) { e.preventDefault(); $("#radioButton1").toggle(...
Itext5 program get troubles with charset when executed on Windows? <p>I'm developing an application which modifies some PDF on java. The application is finished and it work on my computer (using Linux) but now, I'm trying to execute it on a friend's computer (which use Windows) and it does not work properly. It seems t...
<p>You have to set the charset in <code>InputStreamReader</code> otherwise it will use a default charset whatever that may be.</p>
Switching between docker tags <p>I have an apache,wsgi based python application on ubuntu machine. Application is inside a docker container. Developer fix issue 1, deploy it and gives to tester. Developer fixed issue 2 but can`t deploy since tester is still testing issue 1. Is it possible if developer can create tags i...
<p>Each time you commit a container you will get a different image ID. Each of this images can be tagged independently. Example:</p> <pre><code>docker images REPOSITORY TAG IMAGE ID CREATED SIZE python ...
any way to make the map scrollable/moveable = false? <p>I'm looking for a way to set my map scrollable/moveable to false.</p> <p>I can use</p> <pre><code>map.setMaxZoomLevel(15); map.setMinZoomLevel(15); </code></pre> <p>to set the zoomlevel to 15. But I found no way to set the map not scrollable/moveable</p>
<p>One trick is to put a transparent view on top of the map view. Then you can toggle it on and off to pass through touch events or not.</p>
define operator[] for assignment and for reading <p>Is it possible to have two definition of <code>operator[]</code> for the following two cases?</p> <ul> <li><p><code>My_bit_array[7] = true;</code></p></li> <li><p><code>bool x = My_bit_array[0];</code></p></li> </ul> <p>This is useful because reading a bit and toggl...
<p>It's quite simple. It should be implemented using proxy object, as it was already mentioned in comments. Something like this, I suppose:</p> <pre><code>#include &lt;iostream&gt; #include &lt;cstddef&gt; using namespace std; struct proxy_obj; struct my_bit_array { uint8_t bit_array_; proxy_obj operator[]...
Running fifo pipe from single terminal <p>I was wondering if there is anyway to run two programs using named pipe i.e. fifo, by executing only one program. For example, solution mentioned here [Sending strings between two pipes][1] can it be ran using one terminal only? Is there anyway to call writer.c from reader.c an...
<p>Use the popen() function to run writer.py from inside your reader program:</p> <p><a href="https://linux.die.net/man/3/popen" rel="nofollow">https://linux.die.net/man/3/popen</a></p> <p>The popen function returns a FILE * which you can then use with any C buffered I/O function. Eg:</p> <pre><code>#include &lt;st...
How to Find and Fix Memory Leaks in Nested Classes in Java? <p>I'm finding the concept of memory leaks within inner classes fairly difficult to grasp. Most of the answers I find are within the context of java which further confuses a beginner like myself. </p> <p>Most answers to similar questions here redirected to th...
<blockquote> <p>Why do memory leaks occur with the inner classes?</p> </blockquote> <p>Because the inner class maintains a reference to the outer class.</p> <p>If the inner class doesn't actually <em>need</em> that reference, which is quiet common for anonymous classes, and the outer class is otherwise unreachable,...
MS Excel VBA - Looping through columns and rows <p>Hello stackoverflow community,</p> <p>I must confess I primarily code within MS Access and have very limited experience of MS Excel VBA.</p> <p>My current objective is this, I have an "Expense Report" being sent to me with deductions, this report has many columns wit...
<p>The following code may do what you are after:</p> <pre><code>Sub LoadIntoPayrollTemplate() Dim currRowIn As Long Dim currColIn As Long Dim currRowOut As Long Dim wb As Workbook Dim wb2 As Workbook Set wb = ActiveWorkbook '"Expense Report" Set wb2 = Workbooks.Open(Filename:=MyFilepath &a...
AEM CQ5 Query Builder: How to get result by searching for 2 different values in same property? <p>I want to get result matches with all nodes contains property 'abc' value as 'xyz' or 'pqr'.</p> <p>I am trying in below ways:</p> <ol> <li><p><a href="http://localhost:4502/bin/querybuilder.json?path=/content/campaigns/...
<p>The query looks right and as such should work. However if it is just <code>xyz</code> or <code>pqr</code> you would like to match in the query, you may not need the <code>/</code> in the values.</p> <p>For eg.</p> <pre><code>path=/content/campaigns/asd path.self=true //In order to include the current path as well ...
MySQL select since sum >= 3? <p>Table:</p> <pre><code>+++++++++++++++++++++++++ + id | event | group_id + + 1 | '+1' | 1 + + 2 | 'pt' | 1 + + 3 | 'pt' | 1 + + 4 | '+1' | 1 + + 5 | 'pt' | 1 + + 6 | '+1' | 1 + + 7 | 'pt' | 1 + + 8 | '+1' | 1 + +++++...
<p>You want the number of all +1 events <strong>since</strong> the moment you get at least 3 'pt' events.</p> <p>For 'since', I guess you want to order the events by ID.</p> <p>For pt, you need a <em>running total</em>. To achieve this in MySQL there are several answers on Stack Overflow (<a href="http://stackoverflo...
load google map with no marker <p>i have a google map that is loaded from web service if there is no data, i need to clear all markers. i tried to set an IF on the success()</p> <pre><code>success: function (data) { if (data.d.length &gt; 0) { </code></pre> <p>but it gives me an error,...
<p>How about:</p> <pre><code>// if data exists and data.d exists and has a length of &gt; 0 if ((data &amp;&amp; data.d &amp;&amp; (data.d.length &gt; 0)) </code></pre>
PHP bindParam variable error <p>In my web service I have a problem with <code>bindParams</code>. Here is my code:</p> <pre><code>$stmt = $this-&gt;db-&gt;prepare("SELECT data FROM sless WHERE ST_CONTAINS(data.area, Point(:query))"); $stmt-&gt;bindParam(':query', $queryText, PDO::PARAM_STR); </code></pre> <p>but <code...
<p>Try both coordinate separately</p> <pre><code>list($lat, $lng) = split(',', $queryText); $stmt = $this-&gt;db-&gt;prepare("SELECT data FROM sless WHERE ST_CONTAINS(data.area, Point(:lat,:lng))"); $stmt-&gt;bindParam(':lat', $lat, PDO::PARAM_STR); $stmt-&gt;bindParam(':lng', $lng, PDO::PARAM_STR); </code></pre>
Float value casted to char <p>In the below code,</p> <pre><code>#include&lt;stdio.h&gt; int main(){ char array[] = {'1', 2, 5.2}; char* my_pointer = array[2]; printf("%c", *my_pointer); } </code></pre> <p><code>5.2</code> is stored in IEEE 754 representation in memory, <code>char</code> picks 8 bits(first) from...
<p>In your program change <code>char *my_pointer = array[2];</code> to <code>char *my_pointer = &amp;array[2];</code> as pointer should store the address.</p> <pre><code>#include&lt;stdio.h&gt; int main(){ char array[] = {'1', 2, 45.2}; char *my_pointer = &amp;array[2]; printf("%c", *my_pointer); } </code></pre>...
Combine values in all rows when column header is the same <p>Another tricky problem. I have a cleaned data set with another macro, where I need to loop over the column headers and for each row, combine the values of the columns with the same header name in the first column, separated by <code>;</code></p> <p>Sample da...
<p>After a nice chat as agreed ... </p> <pre><code>Sub ForLoopPair() Dim lastRow As Integer: lastRow = Cells(xlCellTypeLastCell).Row ' or w/e you had Dim lastCol As Integer: lastCol = Cells(xlCellTypeLastCell).Column ' or w/e you had For DestCol = 1 To lastCol For ReadCol = DestCol + 1 To lastCol If C...
Getting Microsoft Graph Drive items by path using the .NET SDK <p>As it is <a href="https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_list_children" rel="nofollow">documented</a>, using the Microsoft Graph REST API you can (among other options) get an item by Id or Path. This works fine, as expected:</p...
<p>This is how:</p> <pre><code>var items = await graphClient.Me.Drive.Root .ItemWithPath("/this/is/the/path").Children.Request().GetAsync(); </code></pre> <p>Use just the plain path. Don't include the ":", and don't include the "/drive/root:/".</p> <p>it was obvious, now that I see it...</p>
php pdo prepares query but does not execute it <p>I'm really new to php and pdos. A friend of mine basically created a pdo class and a couple of examples of how to use it and that's been working great for me. But now I want to do a query that uses the <code>BETWEEN</code> mysql keyword and returns anything that matches...
<p>First when things are going wrong add these 2 lines after your <code>&lt;?php</code> tag as far to many people develop on LIVE servers where error reporting will of course be turned off, and assume there is nothing wrong with their code when in reality it is generating lots of errors.</p> <pre><code>&lt;?php error_...
A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column 'Id' in TPT inheritance <p>I'm using EF code first, I have following entities:</p> <p><a href="http://i.stack.imgur.com/nZL4C.png" rel="nofollow"><img src="http://i.stack.imgur.com/nZL4C.png" alt="enter image description here...
<p>In Entity Framework, a one-to-one mapping with a required principal is implemented by giving the dependent a primary key that's also a foreign key to the principal. The dependent copies its primary key from the principal.</p> <p>In your case, EF wants <code>ProductionInstruction.Id</code> to be a foreign key to <co...
Bootstrap centering menu element <p>I have troubles centering the logo and menu in the md and sm view.</p> <p>I want to animate margin of brandlogo and li in menu so margin auto and position absolute is nogo</p> <p>TransformX and col-offset is kinda centering but not pixel perfect and when animatin margin the logo an...
<p>Instead of this:</p> <pre><code>&lt;a class="navbar-brand" id="brand-logo" href="#"&gt; &lt;img alt="BrandLogo" class="brandlogo" src="/wp-content/themes/kdproduction/logo.png"&gt; &lt;/a&gt; </code></pre> <p>try and put this:</p> <pre><code>&lt;div style="width:100%; display:flex; justify-content:center; ali...
How do I build a matrix using two vectors? <p>So I need to build a matrix of <code>x</code> and <code>y</code> coordinates. I have the <code>x</code> stored in one matrix called <code>vx=0:6000;</code> and <code>y</code> stored in <code>Vy=repmat(300,1,6000);</code>.</p> <p>Values in <code>x</code> are <code>0,1,2,......
<p>You can just use horizontal concatenation with <code>[]</code></p> <pre><code>X = [Vx(:), Vy(:)]; </code></pre> <p>If you want to compute the distance between another point and every point in this 2D array, you could do the following:</p> <pre><code>point = [10, 100]; distances = sqrt(sum(bsxfun(@minus, X, point)...
Horizontal Bar Chart on Pandas Data Frame with Dynamic Column Names <p>I have the following source data (which comes from a csv file):</p> <pre><code>ABC,2016-6-9 0:00,95,"{'//Purple': [115L], '//Yellow': [403L], '//Blue': [16L], '//White-XYZ': [0L]}" ABC,2016-6-10 0:00,0,"{'//Purple': [219L], '//Yellow': [381L], '//B...
<p>in order to loop through a certain number of columns to the right of the 'code' column I would do something of the form</p> <pre><code>for col in df.columns[3:]: plot(col) </code></pre> <p>However this only works if you can guarantee that your columns will always be in the same order. Alternatively you could m...
Getting verify error when working with asm java <p>So basicly Im trying to add a simple <code>System.out.println("hey");</code> at the end of a method. I used the tree API. I do however keep getting this error:</p> <blockquote> <p>java.lang.VerifyError: Expecting a stackmap frame at branch target 38</p> </blockquote...
<p>If you are adding code at the end of a method, you are adding it after its last instruction which is always a goto, switch, throw or return statement when compiling Java code. Even when compiling a method without an explicit return statement like</p> <pre><code>void foo() { } </code></pre> <p>you are actully compi...
converting string to data in swift 3.0 <p>I'm trying to convert a string to a data type. I thought this was all I needed but if I try to print it it just prints "12 bytes"</p> <pre><code>let tString = "Hello World!" if let newData = tString.data(using: String.Encoding.utf8){ print(newData) self.peripheral?.wri...
<p>You are not doing anything wrong. That's just how Data currently does its debug printout. It has changed over time. It has at times printed more like NSData. Depending on the debug print format is pretty fragile, I think it's better to just own it more directly. I have found the following pretty useful:</p> <pre><c...
Laravel 5.3 Error : Creating default object from empty value <p>The code below has an error. I am using Laravel 5.3 and php 7.0.</p> <p>I google it but still not clear, any help would be greatly appreciated. </p> <p><strong>ActivationService.php</strong></p> <pre><code>&lt;?php namespace App; use Illuminate\Mai...
<p>The problem is most likely because <code>$user = User::find($activation-&gt;user_id);</code> returns <strong>null</strong> or <strong>false</strong>.</p> <p>When you end up in these kinds of situations always try dumping the variable where the problem is occurring, in this case <code>dd($activation-&gt;user_id)</co...
Knockout Mutliple Dropdowns that adds new items <p>Is it possible for me to have multiple dropdown menus (not a specific amount) that has Items and a New Item option that adds a new Item to the dropdown list.</p> <p>For example there would be ~5 dropdowns and the user selects the Item number. When they select New It...
<p>One way of accomplishing this would be to subscribe to the <b>selectedChoice</b> observable and update the array anytime 'New Item' is selected:</p> <pre><code>self.selectedChoice.subscribe(function(newValue) { var lastItem = self.items()[self.items().length - 1]; if (newValue === lastItem.id()) { /...
Using $ notation in middle of C-Shell statement <p>I have a bunch of directories to process, so I start a for loop like this:</p> <pre><code>foreach n (1 2 3 4 5 6 7 8) </code></pre> <p>Then I have a bunch of commands where I am copying over a few files from different places </p> <pre><code>cp file1 dir$n cp file2 d...
<p>In this respect behavior is similar to POSIX shells:</p> <pre><code>cp -r "dir${n}step1" "dir${n}" </code></pre> <hr> <p>The quotes prevent string-splitting and glob expansion. To observe what this means, compare the following:</p> <pre><code># prints "hello * cruel * world" on one line set n=" * cruel * " print...
How to convert array to UnsafeMutablePointer<UnsafeRawPointer?> Swift 3.0? <p>Here was my workable code in the previous version of Swift:</p> <pre><code> let imageOptionsDictKeys = [ kCVPixelBufferPixelFormatTypeKey, kCVPixelBufferWidthKey, kCVPixelBufferHeightKey, kCVPixelBufferOpenGLESCompatibilityKey, kCVPixelBuff...
<p>I just solved a similar issue converting arrays to <code>UnsafeMutablePointer&lt; UnsafeMutablePointer&lt;T&gt;&gt;</code> which you can find here: <a href="http://stackoverflow.com/questions/40128275/swift-3-unsafemutablepointer-initialization-for-c-type-float/40135482#40135482">Swift 3 UnsafeMutablePointer initial...
Java - how can I get the text from TextField <p>I'm a bloody beginner. I wanna make a login-screen but I encounter a compiler error:</p> <pre><code>package passwordmanager; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; @SuppressWarnings("serial...
<p>This:</p> <pre><code>String myusername = user.getText(); String mypassword = new String(pass.getPassword()); </code></pre> <p>Has to be in a method or constructor...You can't place that code there. You can declare variables there but can't perform operations.</p> <p>This part:</p> <pre><code>myusername = user.ge...
Xcode 8 - Memory debugger doesn't work <p>I'm using Xcode 8 with Swift 3 to develop my app, but I noticed the Memory Debugger isn't working for some reason. Here the screenshot : <a href="http://i.stack.imgur.com/d5fPd.png" rel="nofollow"><img src="http://i.stack.imgur.com/d5fPd.png" alt="xcode 8 memory debugger"></a> ...
<p>I had the idea to check if NSZombie was enabled and yes, it was. Disable it make everything works. </p>
Creating a while loop to run a select statement against a list of DBs within the same server <p>We have servers with 100 DBs each. I want to run a select statement on approximately 50-75 of the databases on each server.</p> <p>I can write a select statement to put the necessary DBs into a temp table.</p> <p>From the...
<p>When trying to run the same query across multiple databases, cursors actually will be a good option. </p> <pre><code>DECLARE @Databases Table (DBName varchar(256)) DECLARE @Name varchar(256) DECLARE @SQL Nvarchar(max) DECLARE @userlogin varchar(50) SET @userlogin = 'dmarch' INSERT @Databases select name from ...
Pig Join by using OR conditional operator throws error <pre><code>child = load 'file_name' using PigStorage('\t') as (child_code : chararray, child_id : int, child_precode_id : int); parents = load 'file_name' using PigStorage('\t') as (child_id : int, child_internal_id : chararray, mother_id : int, father_id : int); j...
<p>The below syntax is incorrect,there is no conditional join in Pig</p> <pre><code>childfirst = JOIN mainparent by (child_id_source), parents by (mother_id OR father_id); </code></pre> <p>If you would like to join a relation with one key with another relation on 2 keys then create two joins and union the dataset.No...
combobox dependent on another combobox - JavaFX <p>I have three combo box: Country, state and city</p> <p>How can I become a dependent on another? For example, if I select Brazil appears their states and later the cities of selected state. But if I select United States in the country will show their states</p> <p>I a...
<p>Register a listener with the country combo box and update the state combo box when the selected item changes:</p> <pre><code>cbxCountry.valueProperty().addListener((obs, oldValue, newValue) -&gt; { if (newValue == null) { cbxState.getItems().clear(); cbxState.setDisable(true); } else { ...
Flask blueprint cannot read sqlite3 DATABASES from config file <p>I would like Python Flask to read from configuration file the location of the sqlite3 database name <strong>without explicitly writing database name</strong>. Templates used are: <a href="http://flask.pocoo.org/docs/0.11/patterns/sqlite3/" rel="nofollow...
<p>Your <code>my_cool_app</code> is an instance of <code>Blueprint</code> which doesn't have a <code>config</code> attribute. You need to use <code>current_app</code>:</p> <pre><code>import sqlite3 from flask import Flask, g, current_app from .views import my_cool_app # create application def create_app(debug=True): ...
Node JS multiple http request missing response <p>Hello I am working on node js http request with a loop and its size is 1728 and its response is missing like it stuck at 1727 kindly help me I am trying to fix this problem for three days.</p> <pre><code>for ( let i = 0 ; i &lt; playerLength ; i++ ) { for ( let j = sta...
<p>The problem you are having is that your function is returning before all the http requests have been completed.</p> <p>Consider promisifying <code>me.request</code> via <code>bluebird</code> and then return a <code>Promise.all</code>. Here's an example: <a href="http://bluebirdjs.com/docs/api/promise.all.html" rel=...
How do I convert this over to an .ascx page? <p>I have this code working fine in a web app .cshtml file. However, I need to be able to convert this over to an .ascx file.</p> <p>It's the @using expressions and the ajax.beginform that are causing me the issues. </p> <p>Thank you.</p> <pre><code>@{ ViewBag.Title =...
<p>Ok. Instead of fighting this and trying to make it work inside DotNetNuke, I took a different approach.</p> <p>The ultimate goal behind this was to have an asynchronous file upload function in DNN so the user had some sort of feedback while a file was being uploaded. These are fairly big files -- 50-200mb -- and wi...
Extra white space at the bottom of the page <p>I have some extra space appearing at the bottom of a website and not sure how. Does anyone know what is causing this?</p> <p><a href="http://192.99.37.125/~maggiemcflys/our-story/" rel="nofollow">http://192.99.37.125/~maggiemcflys/our-story/</a></p> <p>The goal is to rem...
<p>Change your CSS to the following:-</p> <pre><code>#content { bottom: -5px; padding: 0 10% 0 30%; position: relative; vertical-align: middle; width: 100%; } </code></pre> <p>Ive added bottom: -5px to remove the space.</p> <p>The issue is to do with the follow line of code:-</p> <pre><code>&lt;...
Obtaining field's object for displaying validation error message in redux-form <p>I would like to do sync validation, but I have no ideas how to obtain the field's object</p> <p><em>validate.js</em></p> <pre><code>const validate = (values) =&gt; { const errors = {}; if (!values.firstName) { errors.fi...
<p>There is a <a href="http://redux-form.com/6.0.5/examples/syncValidation/" rel="nofollow">good example</a> of how to do this on the redux-forms website. The gist is that you should render a component for your <code>Field</code> which will then have access to that input's data. For example, here's one of mine using so...
CSS VW and VH - maintain ratio <p>I have a page that contains a DIV which maintains an aspect ratio. I have some text within the div that uses VW on the font size which maintains the text size when the page width changes - which is great.</p> <p>But when the user changes the window height - I cannot get it to respond ...
<p>I ended up doing some Jquery to get this to work, it works pretty smoothly</p> <p>I added an attribute to the DIV to tell the Jquery a font size, then did some calculations on the height of the parent container to get it to scale depending on the height of the DIV</p> <pre><code>$(window).on("resize", function () ...
$(window).height() not working <p>JQuery Links being used:</p> <pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.cs...
<p>Check this code (with the correct jquery lib):</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() { var windowHeight = $(window).height(); var menuBarHeig...
Return by reference PHP <p>In documentation i see how we set 2 <code>&amp;</code>, why?</p> <p>And can say me please what difference beetween</p> <p><em>this 1:</em></p> <pre><code>function &amp;func() { static $static = 0; $static++; return $static; } $var1 = func(); echo "var1:", $var1; // 1 </code>...
<p>There is only a difference between the first <code>this 2</code> and the second <code>this 1</code>. All others are wrongly tried <code>return by reference</code>. </p> <p>The second <code>this 2</code> even throws a PHP notice (<code>Notice: Only variables should be assigned by reference in ... on line ...</code>...
Combining 2 SQL statements into 1 <p>I want to select employees who earns more than their managers. I have these SQL statements I wrote below, but how exactly would I combine these to make one statement?</p> <pre><code>SELECT E.Salary FROM Employee E WHERE E.ManagerId = E.Id SELECT * FROM Employee M WHERE M.Salary &g...
<pre><code>SELECT E.Salary, M.* FROM Employee E inner join Mamanger M on E.ManagerId = M.Id and E.Salary &gt; M.Salary </code></pre>
output of fmod function c++ <p>Given:</p> <pre><code>#include &lt;iostream&gt; #include &lt;cmath&gt; #include &lt;limits&gt; using namespace std; int main() { // your code goes here double h = .1; double x = 1; int nSteps = abs(x / h); double rem = fmod(x, h); cout&lt;&lt;"fmod output is "&l...
<p>The problem you're seeing is that the version of <code>fmod</code> you're using appears to follow the implementation defined at <a href="http://en.cppreference.com/w/cpp/numeric/math/fmod" rel="nofollow">cppreference</a>:</p> <pre><code>double fmod(double x, double y) { double result = std::remainder(std::fabs(...
How to scrape in Ruby when the page elements keep changing and shifting. <p>I'm writing a program to download the images from an imgur album: I had just begun to write the actual image-link-code:</p> <pre><code>#The imports. require 'open-uri' require 'nokogiri' url = ARGV[0] #The title. open(url) do |f| $doc = No...
<p>It's dynamic HTML. Mechanize and/or Nokogiri can't help you unless you can build the final version of the page then pass it to them.</p> <p>Instead you have to use something that can interpret JavaScript and apply CSS, such as a browser. The WATIR project would be the first thing to investigate. "inspect" and "view...
Why can't I deploy UWP app on a new Lumia phone? (developer mode enabled) <p>I created an app and I could run it on my Lumia 640 for testing. I have not submitted my App to Windows Store yet, as the debugging is unfinished. I just deployed it on my phone with <code>Developer Mode</code>enabled and it ran just fine.</p>...
<p>I'm missing the files in <code>Dependencies</code> folder which will create with the .appx file. I need to install these files first, and now all fine.</p>
JSONSimple Overwriting <p>I am attempting to iterate through a hash map and create a json string from the values. Im using the JSONSimple library to do so. I have the structure I want, but the values are being overwritten. The structure I am ending up with is </p> <pre><code>{ "new_id":{ "coordinates_list":...
<p>You are always using "new_id" as the key on the "obj.put" line. For the first map entry, you set the value for that key on the JSON object. For each subsequent entry, you are replacing the value for that key, not adding a new key. That is why only the last entry in the map is represented in the JSON.</p> <p>I'm ...
Migrating from EJB with Spring to POJO <p>While migrating from EJB with spring to POJO , I read every where that just changing this configuration will work :</p> <pre><code>&lt;bean id="sapFeedBean" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean" lazy-init="true"&gt; &lt;propert...
<p>This is a kind of <strong><code>deprecated approach</code></strong> to create a bean..</p> <p>Its better if you use <strong>JavaConfig</strong>.. Have a look at the following link </p> <p>It will give you a clear idea</p> <p><a href="https://dzone.com/articles/consider-replacing-spring-xml" rel="nofollow">https:/...
Change type of calculated field in select query (sqlite) <p>im sure i am not the first one to ask this but i can't find the answer to this: I haver a select query on a datatable in a sqlite database. </p> <pre><code>select *, ((int_EndTime)-(int_StartTime))/60 as dou_usage_min FROM tbl_unautho_usage; </code></pre> <p...
<p>Try multiplying a value used within the arithmetic operation by <code>1.0</code>.</p> <pre><code>select *, ((int_EndTime*1.0)-(int_StartTime*1.0))/60 as dou_usage_min FROM tbl_unautho_usage; </code></pre> <p>Probably only one value multiplied will be sufficient.</p>
Controller redirection doesn't change view <p>I'm doing a simple RedirectAction in my controler and in this new Controller i'm calling the new View, however in the Browser the View is not changing, i can see in the cshtml the code getting there, but i don't know what i'm missing.</p> <pre><code>public ActionResult Exe...
<p>You need to return something like a <code>PartialView</code> in your redirect to action call. However, the call needs to be scoped to a parent view that can display the partial properly. You can't just load what you send over like that.</p>
Xcode error NSException <p>I'm currently trying to run on Xcode an app I ve made with Qt, but when I try to run it on Xcode i get this Exception :</p> <pre><code> dyld: warning, Ignoring DYLD_IMAGE_SUFFIX because DYLD_ROOT_PATH is used. 2016-10-10 15:37:04.777 CMP[2206:654538] *** Assertion failure in void _UIAppli...
<p>In your app's info.plist, make sure you change the NSPrincipalClass key to the name of your subclass. This'll make Cocoa instantiate the correct class when the applications loads - you shouldn't have to do anything other than that to get your subclass working. Also, take a look at this link it may also add some insi...
Trouble registering a custom taxonomy for my Custom Post Type <p>I have a custom post type of 'Employees' and am trying to register custom categories for this custom post type. Here is my php:</p> <pre><code>//---------------------------------------------------// //---- REGISTER CUSTOM POST TYPES ------------------//...
<p>You should give the proper name on this line: register_post_type( 'post_type', $args ); Shouldnt it be <code>employees_custom_post_type</code>?</p>
Android SQLite: Replace old database with a new one or use migration scripts <p>I have an Android app that uses a SQLite database and <a href="http://www.activeandroid.com" rel="nofollow">Active Android</a> as ORM. On each app update I need to ship my database with new/updated data. This is what i've been doing</p> <o...
<p>You dont need to do that (renaming stuff or anything)</p> <p>You just need to change your database version and write a sql command to alter your previous table to migrate from version A to B.</p> <p>Look at this link: </p> <p><a href="http://stackoverflow.com/questions/8133597/android-upgrading-db-version-and-add...
The request has exceeded the allowable time limit & Java Heap Space Null errors <p>I know this topic seems to be discussed many times, but I have tried all the methods mentioned to no avail.</p> <p>I am keeping getting the errors:</p> <blockquote> <p>The request has exceeded the allowable time limit Tag: CFQUERY ...
<p>With 20-40k products per category at 20 categories with an unknown row size, you have some real architectural decisions to make on your data caching (if you do use a cache). Currently, each category id parameter will be a unique cache of that query with a time to live of five minutes consuming some amount of heap sp...
What's wrong with this class method? <pre><code>class Person: def __init__(self, name): self.name = name def greet(name, other_name): return "Hi {0}, my name is {1}".format(other_name, name) </code></pre> <p>Why doesn't this work? I am trying to access my name in the class and say hi my name is [myname] [...
<p>Your actual problem is that you are defining your instance method <code>greet</code> as:</p> <pre><code>def greet(name, other_name): </code></pre> <p>Instance methods in Python take the <code>instance</code> as first argument in your method definitions. What you are doing here now, is calling that instance <code>n...
How to array_push unique values inside another array <p>I have two arrays:</p> <pre><code>$DocumentID = array(document-1, document-2, document-3, document-4, document-5, document-4, document-3, document-2); $UniqueDocumentID = array(); </code></pre> <p>I want to push the unique objects inside of ...
<p>You could <code>foreach()</code> through <code>$DocumentID</code> and check for the current value in <code>$UniqueDocumentID</code> with <code>in_array()</code> and if not present add it. Or use the proper tool:</p> <pre><code>$UniqueDocumentID = array_unique($DocumentID); </code></pre> <p>To your comment about w...
What is the best way to composite several rectangle structs together into one large rectangle <p>Say I have 2 rectangles (originX, originY, width, height)</p> <p>0,0,100,100</p> <p>100,100,100,100</p> <p>What is the best way to get the rectangle that contains both?</p> <p>i.e: 0,0,200,200</p> <p>Here is a crappy p...
<p>No matter what, you will have to look at each rectangle to achieve you answer. If you fail to look at even one, you could miss a point that is outside of your bounds. So no matter what the best solution you can find will be O(n).</p> <p>Since we are looking for an O(n) solution, it is pretty simple: just iterate ov...
date & time not loading on page load <p>I have an html page with a date and time input on it, just straight HTML5</p> <pre><code>&lt;input type="date" id='date' name='date' style='text-align:center' required /&gt; </code></pre> <p>and</p> <pre><code>&lt;input type='time' id='time' name='time' style='text-align:c...
<p>Make sure that jQuery is included, below code snippet works just fine, check developer console in your web browser to check for errors.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-ov...
How to make push, unshift, pop and shift to work only with local array in javascript? <p>I have a function to describe my problem:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override">...
<p>When you assign an array to a variable (or passing it as an argument to a function), you are only storing a <em>reference</em> to that array. If two or more variables are referencing the same array, making changes to one will affect all the others as well:</p> <p><div class="snippet" data-lang="js" data-hide="false...
Jmeter csv config for file upload <p>I'm using Jmeter for testing file uploads. This works great when I upload just one file, but I want to be able to loop through a list of files. I see Jmeter has a CSV based config capability, but I can't figure out how to include a file as one of the params.</p> <p>How can I ...
<p>You need to pass:</p> <ul> <li>either relative or full path to the file being uploaded</li> <li>upload input name</li> <li>file MIME type</li> </ul> <p>So if your CSV file will look like:</p> <pre><code>c:/testfiles/test.txt,upload,text/plain c:/testfiles/test.jpg,upload,image/jpeg etc. </code></pre> <p>And CSV ...
Linking 'muted speaker' icon to volume slider when value = 0? <p>I have a speaker icon besides my volume slider, and I would like the icon to change when the volume value is at 0, to a second (muted) speaker icon. I've tried different variations which didn't work. How do I do that? Thanks!</p> <p><div class="snippet" ...
<p>Use JQs attr method to just swap the image source. Also, make sure the src path to the images is relative to the HTML document if you are using an external JS document. </p> <p><strong>JS:</strong></p> <pre><code> volumeslider.addEventListener("mousemove", checkMute); </code></pre> <p>//check for mute each time ...
WPF DataTemplate.Triggers don't evaluate <p>Trying a simple DataTemplate implementation that doesn't work for some reason. It seems like the Bindings inside the conditions are never evaluated, even on the initial load. Any input is appreciated. </p> <pre><code> &lt;DataTemplate x:Key="ReadinessCellTemplate"&gt; ...
<p>I ended up taking the easy out and put the triggers in the style of the element I tried to manipulate:</p> <pre><code> &lt;Path x:Name="PART_ShapePath" Height="14" Width="16" Fill="#FF1B468A"&gt; &lt;Path.Style&gt; &lt;Style TargetType="Path"&gt; &lt;Style.Triggers&g...
How to readjust Constraint Layout <p>In my app, I have a custom layout that use Constraint Layout to display two views as follow.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:to...
<p>The problem you encounter is simply that your second view is constrained by the guideline -- as is the first view. The guideline itself is constrained to the container.</p> <p>What that means is that it doesn't matter that you mark your first view as <code>GONE</code> -- yes, it will disappear, but this will not im...
Videos Not auto playing on mobiles and tablets <p>I have created a website, first proper website, with bootstrap. Almost got the website to where i want it to be. I have a video on the main page (.mp4 1080p), which i have set to loop and auto play. Works perfect on laptops, but cant seem to get it to work on properly o...
<p>This is a very common problem, and it's an encoding issue. You will need to encode your video using <strong>H264</strong> as the video codec, and <strong>AAC</strong> as the audio codec.</p> <p>When you use H264 as your video codec, you will also need to choose a profile. Higher profiles require more CPU power to d...
Elseif returns #VALUE <p>Ok, so all I want to do is create a function to optimize how I can segment my PivotTable data. This data comes in different forms like "245896321 - Name", "name" or "name23123" and I want it to return the persons full name if the cells contains specific texts (person last name), but it only ret...
<p><code>Application.WorksheetFunction.Search</code> will throw a runtime error if there's no match: try instead something like:</p> <pre><code>If Application.WorksheetFunction.IsNumber(Application.Search("*Ormelli*", Line)) Then '... </code></pre> <p>Omitting the <code>WorksheetFunction</code> switches the behavior ...
ZF2, controller doesn't fill the form elements from hydrated objects that are attached to the form <p>In ZF2, I have a form that has two fieldsets. The 2 fieldsets are basically for party-related info (party = person or company) and phone-related info. The fieldsets are called using the init method of the form like thi...
<p>THIS IS NOT A REALLY GOOD SOLUTION, PLEASE FEEL FREE TO SUGGEST BETTER VARIANTS! I WILL MAKE YOUR ANSWER ACCEPTED IF IT'S BETTER.</p> <p>After a day of trials and errors still couldn't figure out why the form inputs don't get filled based on the objects attached to the fieldsets. I found, though, a workaround for t...
Where to Add text file on an Android Sudio Project to place internal comments that won't be deployed on APK <p>I want to add a text file on Android Studio where to place internal comments, ideas, development status, pendings, etc. </p> <p>The issue is that I don't want this file to be part of deployment APK's, but I w...
<p>Create a <code>notes/</code> directory off of the project root. Or a <code>docs/</code> directory. Or whatever you want. </p> <p>Everything inside of <code>src/</code> for a module is a candidate for being included in an APK. Conversely, stuff in directories that Android Studio does not know about (e.g., <code>note...
Android - Set Image by 2 Constrained Variables <p>First off, I've been coding for all of a few months, so I'm sorry if any of the following is very basic... I'm pretty terrible with Java.</p> <p>I'm looking to pick an image from an imaginary "grid/array" based on two variables (x and y, to keep it simple) and display ...
<p>This here:</p> <pre><code>String seatNumber = "R.drawable.seat" + x + y; int seat = Integer.valueOf(seatNumber); </code></pre> <p>Is trying to convert the string to a number, but that won't work as the string does not contain a number. What you're looking for is this:</p> <pre><code>int seat = getResources().getI...
Propagating arguments to decorator which combines other decorators <p>I have a scenario like:</p> <pre><code>@decorator_one(1) @foo @bar def my_decorated_func(): pass </code></pre> <p>I am trying to condense this into something like:</p> <pre><code>@my_custom_decorator(1) def my_decorated_func(): pass </code...
<p><code>@decorator_one(1)</code> means that there is a callable that returns a decorator; call it a decorator <em>factory</em>. <code>decorator_one(1)</code> returns the decorator that is then applied to the function.</p> <p>Just pass on the arguments from your own decorator factory:</p> <pre><code>def my_custom_dec...
Virtualenv within single executable <p>I currently have an executable file that is running Python code inside a zipfile following this: <a href="https://blogs.gnome.org/jamesh/2012/05/21/python-zip-files/" rel="nofollow">https://blogs.gnome.org/jamesh/2012/05/21/python-zip-files/</a></p> <p>The nice thing about this i...
<p>You can create a bash script that creates the virtual env and runs the python scripts aswell. </p> <pre><code>!#/bin/bash virtualenv .venv .venv/bin/pip install &lt;python packages&gt; .venv/bin/python script </code></pre>
Android GridView Height Autofill the Remaing Space <p>Is it possible for a GridView to auto adjust to occupy the remaining empty space of its parent layout? If yes how ? </p>
<p>Yeah. It is possible.</p> <p>Let's consider following xml,</p> <pre><code>&lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"&gt; //First View or layout &lt;RelativeLayout android:id="@+id/first_layout" android:layout_width="match_par...
Elm Http Request on Init <p>I'm pretty new to Elm, but slowly getting familiar with it. I'm doing some simple Http Requests, which are successful in every aspect (I get the data to display, etc.)</p> <p>For the moment I can only get my fetchData to trigger onClick, I would like to initialize this on init, but I'm havi...
<p>When you use <a href="http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html-App#program">Html.App.program</a>, your <code>init</code> returns the initial data for your Model and some kind of Command to be executed.</p> <p>Commands are side-effects, like HTTP requests.</p> <p>Try changing <code>init</code> ...
Configuration from Spring Config Server overrides server port vm argument <p>I have the following services:</p> <ol> <li>Spring Cloud Config Server</li> <li>Eureka Discovery Service</li> <li>Event Service (spring boot app)</li> </ol> <p>I use "Config First" mode. It means I start Config Server first and after that I ...
<p>The order of your command line arguments is wrong: the <code>system variable</code> must be before the jarfile:</p> <pre><code>$ java -jar -Dserver.port=8082 event-service.jar </code></pre> <h1>3 ways to override properties from the command line</h1> <ul> <li>Environment variable: <code>$ server_port=8082 java -j...
Python elif not working in order I want <p><code>Transaction_Code</code> == <code>"W"</code>, <code>"w"</code>, <code>"D"</code> or <code>"d"</code></p> <p>if not, it should be running <code>Process_Invalid_Code(Previous_Balance)</code></p> <p>What is happening, however is if input for <code>Transaction_Code</code> !...
<p>Since all of your desired actions need <code>Previous_Balance</code> you must ask for it in any case:</p> <pre><code>def main(): # never used, lets ask anyway Name = input("What is your name? ") # we need this information at a minimum Previous_Balance = float(input("What is your previous balance? ...
How to enable the select option text to go to the next line in firefox? <p>How to enable the select option text to go to the next line in firefox?</p> <p>In chrome, the text goes to the next line for the option element but it does not go in firefox. I have tried a lot of css classes but does not work. I have provided ...
<p>For me it works using only CSS but it has a bug that the last word is covered by the scroll bar in Firefox. You specify the width and also add display:inline-block</p> <pre><code> white-space: -moz-pre-wrap; /* Firefox */ white-space: pre-wrap; /* other browsers */ width:150px; display:inline-block </co...
Using Pandas to Create DateOffset of Paydays <p>I'm trying to use Pandas to create a time index in Python with entries corresponding to a recurring payday. Specifically, I'd like to have the index correspond to the first and third Friday of the month. Can somebody please give a code snippet demonstrating this?</p> <p>...
<p>try this:</p> <pre><code>In [6]: pd.date_range("2016-10-10", periods=26, freq='WOM-1FRI').union(pd.date_range("2016-10-10", periods=26, freq='WOM-3FRI')) Out[6]: DatetimeIndex(['2016-10-21', '2016-11-04', '2016-11-18', '2016-12-02', '2016-12-16', '2017-01-06', '2017-01-20', '2017-02-03', '2017-02-17', '2017-03-03'...
overriding a method in UICollectionViewLayout in Swift with an error <p>I need to make a change to an app that we are developing and am not a full-time iOS dev. I'm trying to get a pinterest like interface for an iOS app and am working through the tutorial here: <a href="https://www.raywenderlich.com/107439/uicollectio...
<p>You have the wrong method signature. This is actually the reason the <code>override</code> keyword exists. It ensures an API change will be caught like this, rather than the override silently not occurring, leading to hard to diagnose issues.</p> <p>It should be</p> <pre><code>override func layoutAttributesForElem...
Log4net ADONetAppender - View parameter values? <p>Is it possible to view the AdoNetAppenderParameter values when debugging log4net?</p> <p>If so, how?</p> <p>Thanks!</p>
<p>In the sourcecode from <a href="https://github.com/apache/log4net" rel="nofollow">https://github.com/apache/log4net</a> you will find the file AdoNetAppender.cs:</p> <p>In the <code>virtual public void Prepare(IDbCommand command)</code> the parameters are assigned:</p> <pre><code>IDbDataParameter param = command.C...
does groupby concatenate the columns? <p>i have a "1000 rows * 4 columns" DataFrame:</p> <pre><code>a b c d 1 aa 93 4 2 bb 32 3 ... 1000 nn 78 2 **[1283 rows x 4 columns]** </code></pre> <p>and I use groupby to group them based on 3 of the columns:</p> <pre><code>df.groupby(['a','b...
<p>you can do it this way:</p> <pre><code>df.groupby(['a','b','c'], as_index=False).sum() </code></pre> <p>or:</p> <pre><code>df.groupby(['a','b','c']).sum().reset_index() </code></pre>
How to write a function of type a-> b -> b -> b for folding a tree <p>Some background: I have a foldT function (like foldr but for trees) of the following type in Haskell. </p> <pre><code>foldT :: (a -&gt; b -&gt; b -&gt; b) -&gt; b -&gt; Tree a -&gt; b </code></pre> <p>This foldT only takes type (a -> b -> b -> b) ...
<p>As you haven't posted it, I will assume your tree is...</p> <pre><code>data Tree a = Leaf | Node a (Tree a) (Tree a) </code></pre> <p>... and that the <code>a -&gt; b -&gt; b -&gt; b</code> argument to <code>foldT</code> takes the fields of the <code>Node</code> constructor in the same order they were declared.</p...
PyQt5: Access to QClipboard (or app object) from inside a widget <p>I'm trying to access the clipboard (via QClipboard) in a PyQT5 application, but from a widget a few layers deep. The app object usually provides the clipboard via <code>app.clipboard()</code> but I don't have access to the app object that deep. Is ther...
<p>There are two ways to do this:</p> <pre><code>from PyQt5.QtWidgets import qApp </code></pre> <p>or:</p> <pre><code>from PyQt5.QtWidgets import QApplication qApp = QApplication.instance() </code></pre> <p>The latter is a static method which is inherited from <code>QtCore.QCoreApplication</code>. But then again, ...
Exposing a class with a constructor containing a nested private class in constructor using Boost Python <p>I'm new to Boost Python and I'm looking to expose a class that looks like this: </p> <pre><code>///Header File structure class A { public: A(); ~A(); void B(); private: class Impl; st...
<p>The whole point of the pimpl idiom is that it's private and completely transparent to the users of the class. You don't expose it.</p> <p>What you do need to do is make it clear that <code>A</code> isn't copyable:</p> <pre><code>class_&lt;A, noncopyable&gt;("A", init&lt;&gt;()) .def("B", &amp;A::B) ; </code></...
Python - Selenium : Scroll down not working because of PopUp <p>I am writing a python script using selenium to login to Facebook and then do some scrapping. For that purpose, <strong>I have to scroll down to the bottom of the page. I think the pop that you can see in the picture is the cause of this.</strong> Here is t...
<p>Solved.</p> <p>Adding this will resolve and woulndt allow any such pop ups.</p> <pre><code> chrome_options = webdriver.ChromeOptions() prefs = {"profile.default_content_setting_values.notifications" : 2} chrome_options.add_experimental_option("prefs",prefs) #driver = webdriver.Chrome(chrome_options=...
Swift FBSDK Get user country <p>I am currently implementing Facebook login for my app, and I am trying to fetch the following info from the profile:</p> <p>first name, last name, gender, and country.</p> <p>However, I can only seem to fetch everything except the user country. I have tried to set my parameters to my F...
<p>Your readPermissions <code>user_location</code> is correct but the parameter name for country/location is not <code>user_location</code>.<br> It is <code>location</code>. <br></p> <pre><code>let parameters = ["fields": "id,location,name,first_name,last_name,picture.type(large),email,birthday,gender,bio,relationship...
How to count number of occurrences of a chracter in a string (list) <p>I'm trying to count the occurrence of each character for any given string input, the occurrences must be output in ascending order( includes numbers and exclamation marks) I have this for my code so far, i am aware of the Counter function, but it ...
<p>Just call <a href="https://docs.python.org/3/library/collections.html#collections.Counter.most_common" rel="nofollow"><code>.most_common</code></a> and reverse the output with <a href="https://docs.python.org/3/library/functions.html#reversed" rel="nofollow"><em>reversed</em></a> to get the output from least to most...
Cannot convert NUMBER to SEQUENCE in Changefeed on SUM operation in RethinkDB <p>I am getting an error when listening on changes event while doing a SUM query, without the changes() method it works fine</p> <p>What I expect this code to do is SUM each 'length' attribute on this table that matches the filter, and when ...
<p>This will be possible only in version 2.4 as Daniel said <a href="https://github.com/rethinkdb/rethinkdb/issues/1118" rel="nofollow">here</a>.</p> <p>Just for now you can try to use <code>fold</code>:</p> <pre><code>r.db("buckets").table("fs_files").filter({metadata: data})('length')("num").changes({"includeInitia...
Is it possible to change the Menu in real time? <p>Depending on whatever arbitrary criteria I decide, is it possible to change the contents of the Menu (the triple-dot thing you click in the upper right, which drops down whatever settings you'd like to include).</p> <p>Can this be done? Right now I don't know how to b...
<p>Thats the way I do it: </p> <pre><code>@Override public boolean onPrepareOptionsMenu(Menu menu) { if(condition1){ MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_1, menu); }else{ MenuInflater inflater = getMenuInflater(); inflater...
Best Way to Set Day to the First of the Month Using DateTime Without Inherent WithDayOfMonth Method <p>So, I'm trying to basically take 2 DateTime objects and set them to the first day of their respective months so that I can ultimately calculate the months between the two dates.</p> <p>Example of the code:</p> <pre>...
<p>Calculate months from difference of the two month values. For example if <code>newDate</code> is 1st July 2016 and <code>oldDate</code> is 31st May 2016, <code>newDate.getMonth()</code> will return 7 and <code>oldDate.getMonth()</code> will return 5, and the difference will be rounded up as required.</p> <pre><code...
how to write typescript definition file for this javascript library? <p>I need call the following javascript:</p> <pre><code>var jslib = jslib || (function() { var publicMethods = { encrypt: function (algorithm, keyHandle, buffer) { // implementation } }; return publicMethods; })(); </code></pre> <p>...
<p>I'm assuming the following directory structure</p> <pre><code>├── lib │   ├── jslib.d.ts │   └── jslib.js ├── src    └── t.ts </code></pre> <p>jslib.js</p> <pre><code>var jslib = jslib || (function () { var publicMethods = { encript: function () { return } ...
Changing int array to char array <p>Hello all I'm having difficulty running some code under various circumstances. I have code that finds how many prime numbers there are, of all the numbers in an array, times how long it takes, and prints how many prime numbers there are. This all works fine, but then I need to run th...
<p>The problem is that you're storing <code>i</code> into <code>a[i]</code>. When <code>a</code> is a <code>char</code> array, the maximum value of an element is <code>127</code> (if <code>char</code> defaults to <code>signed</code>) or <code>255</code> (if it's <code>unsigned</code>), assuming a typical system with 8-...
Plotting drc model in ggplot2; issue with seq( ) <p>My model does not continue towards the asymptotes when plotted in ggplot2, though it does in R base graphics. In ggplot2, it stops at certain points on the X axis (images included below), <strong>I am 90% certain this is related to <code>seq()</code>, data it posted a...
<p>This is a long comment. I think you mistook <code>dose</code> values to give <code>predict()</code> or <code>aes(x)</code> values.</p> <pre><code>log10000 &lt;- exp(seq(log(0.5), log(10000), length=200)) log1000 &lt;- exp(seq(log(0.5), log(1000), length=200)) log10000df &lt;- as.data.frame(cbind(dose = log10000, p...
swift share with function on completion <p>My app can share files with other apps, but the problem is that I need to delete the files after sharing them... I tried using the onCompletion function as below:</p> <pre><code>let activityVC = UIActivityViewController(activityItems: objects, applicationActivities: nil) vie...
<p>It's far too soon to do anything in the completion handler of presenting the controller.</p> <p>Set the <code>completionWithItemsHandler</code> property of the <code>UIActivityViewController</code>. This will get called when the sharing process is complete.</p> <pre><code>activityVC.completionWithItemsHandler = { ...
Reading and analyzing string data for AI <p>I just wrote string reading and analyzing for a Jarvis AI that has been taught to remember certain phases.</p> <p>My problem is that it has so many that the substrings within other phrases that are uncountable. I want to be able to say a certain phrase then for the AI to cha...
<p>To attack your immediate problems ... NLP (natural language processing) generally processing the input with a lexicon (vocabulary), not string search. One popular tactic is to give each word or word family an index number, often simply the word's position (line number) in a dictionary file. The initial reading sim...
Office 365 oAuth verify user is member of organization <p>I am building a web application for a client and logging in with Office 365 is a requirement for the client. I am having a difficult time deciphering what exactly I need to do to make it so that only users with an email address belonging to their Office 365 orga...
<p>The tenant id (<code>tid</code>) claim in the identity token would identify which organization (tenant) they belong to. But even easier than just checking the <code>tid</code> for every user would be to use the tenant-specific logon URL. So instead of the <code>/common/oauth2/v2.0/authorize</code> endpoint, use <cod...
Avoid backreference replacement in php's preg_replace <p>Consider the below use of <code>preg_replace</code></p> <pre><code>$str='{{description}}'; $repValue='$0.0 $00.00 $000.000 $1.1 $11.11 $111.111'; $field = 'description'; $pattern = '/{{'.$field.'}}/'; $str =preg_replace($pattern, $repValue, $str ); echo $str; ...
<p>Escape the dollar character before using a character translation (<code>strtr</code>):</p> <pre><code>$repValue = strtr('$0.0 $00.00 $000.000 $1.1 $11.11 $111.111', ['$'=&gt;'\$']); </code></pre> <p>For more complicated cases (with dollars and escaped dollars) you can do this kind of substitution <em>(totally wate...
How to use counters and zip functions with a list of lists in Python? <p>I have a list of lists :</p> <pre><code>results = [['TTTT', 'CCCZ'], ['ATTA', 'CZZC']] </code></pre> <p>I create a counter that stores number number of characters in each element in each list, only if the characters are ATGC [NOT Z]</p> <pre><c...
<p>The first part can be done like this:</p> <pre><code>BASES = {'A', 'C', 'G', 'T'} results = [['TTTT', 'CCCZ'], ['ATTA', 'CZZC']] counts = [[sum(c in BASES for c in s) for s in pair] for pair in results] &gt;&gt;&gt; counts [[4, 3], [4, 2]] </code></pre> <p>Once you have the counts, the correction factor can also ...