input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How to properly do null checks using Kotlin extension functions on an Android Activity <p>I'm new to Kotlin and trying to convert one of the many Android Util methods we have in our existing codebase into a Kotlin extension function.</p>
<p>This is the Kotlin code:</p>
<pre><code>fun Activity?.isAlive(): Boolean {
... | <p>I suppose you get NPE not in the <code>isAlive()</code> function but somewhere after, when the <code>Activity</code> is referenced. This is likely caused by the fact that <code>.isAlive()</code> returns <code>true</code> on <code>null</code> receiver.</p>
<p>That's because if the receiver is <code>null</code>, <cod... |
R ggplot2: Add means as horizontal line in a boxplot <p>I have created a boxplot using ggplot2:</p>
<pre><code>library(ggplot2)
dat <- data.frame(study = c(rep('a',50),rep('b',50)),
FPKM = c(rnorm(1:50),rnorm(1:50)))
ggplot(dat, aes(x = study, y = FPKM)) + geom_boxplot()
</code></pre>
<p>The b... | <p>You can add horizontal lines to plots by using <code>stat_summary</code> with <code>geom_errorbar</code>. The line is horizontal because the y minimum and maximum are set to be the same as y.</p>
<pre><code>ggplot(dat, aes(x = study, y = FPKM)) +
geom_boxplot() +
stat_summary(fun.y = mean, geom = "errorba... |
Wrap integers in quotes from json data <p>I created <a href="http://stackoverflow.com/questions/40110706/regex-wrap-all-integers-in-double-quotes">this question yesterday</a></p>
<p>I've since realised there are actually a few other bits of data that cause issues with the solutions I received. Hence, I thought it best... | <p>By reading your both questions, what I understand is that you want to wrap in double quots some numbers that aren't, so for this I can come up with a simple regex like this:</p>
<pre><code>(?<=,)(\d+)(?=,)
</code></pre>
<p>With the replacement string: <code>"$1"</code></p>
<p><strong><a href="https://regex101.... |
How to create a subset of document using lxml? <p>Suppose you have an lmxl.etree element with the contents like:</p>
<pre><code><root>
<element1>
<subelement1>blabla</subelement1>
</element1>
<element2>
<subelement2>blibli</sublement2>
<... | <p>I am not sure there is something built-in for it, but here is a terrible, "don't ever use it in real life" type of a workaround using the <a href="http://lxml.de/api/lxml.etree._Element-class.html#iterancestors" rel="nofollow"><code>iterancestors()</code> parent iterator</a>:</p>
<pre><code>from lxml import etree a... |
How to set page size with rave report <p>I have a project in Delphi 2010 and I'm using RaveReport to generate PDF reports through the code, my question is I want to know if it is possible and how can I set the size (height and width) of my PDF page.</p>
<p>I tried it but did not resulted:</p>
<pre><code>var PWidth: D... | <p>Solution for my problem:</p>
<pre><code>procedure TfrmLogger.RvSystemBeforePrint(Sender: TObject);
begin
with Sender as TBaseReport do
begin
Units := unInch;
UnitsFactor := 1;
SetPaperSize(DMPAPER_USER, 21, 29.7);
Units := unCM;
UnitsFactor := 2.54;
end;
end;
</code></pre>
|
Keras getting wrong output shape <p>For the following CNN </p>
<pre><code>model = Sequential()
model.add(Convolution2D(64, 3, 3, border_mode='same', input_shape=(3, 256, 256)))
# now model.output_shape == (None, 64, 256, 256)
# add a 3x3 convolution on top, with 32 output filters:
model.add(Convolution2D(32, 3, 3, bo... | <p>It is a problem caused by the setting of <code>input_shape</code>. In your current setting, you want to input 256x256 with 3 channels. However, Keras thinks you are giving 3x256 image with 256 channels. There several ways to correct it.</p>
<ul>
<li><p>Option 1: Change the order in <code>input_shape</code></p></li>... |
Get attribute's name by it's value <p>I need to return the key with a known <code>value</code> from my model.</p>
<pre><code>f = Foo.find_by(name: "dave")
#= returned object: {id: 1, name: "dave", age: 32}
f.key("dave") # expected :name or name
</code></pre>
<p>This <code>value</code> will be unique. How to get the a... | <p><code>f</code> is an instance of <code>Foo</code> class, which inherits from <code>ActiveRecord::Base</code>, it is not a <code>Hash</code> instance.</p>
<p>To get the attribute's name by it's value (using <code>key</code>), you have to get a hash of <code>f</code>'s <a href="http://api.rubyonrails.org/classes/Acti... |
Set this for required arrow-functions <p>I'm trying to set <code>this</code> in various scenarios.</p>
<p>The following code executed in node.js <code>v6.8.1</code> will print what is commented at the end of each line: </p>
<pre><code>function requireFromString(src) {
var Module = module.constructor;
var m = new ... | <p>The reason is because "fat arrow functions" always take their <code>this</code> lexically, from the surrounding code. They <strong><em>cannot</em></strong> have their <code>this</code> changed with <code>call</code>, <code>bind</code>, etc. Run this code as an example:</p>
<pre><code>var object = {
stuff: 'face',... |
How do I display my Wordpress custom field attribute in the excerpt of my Algolia Search page results? <p>I'm currently using Algolia's Search plugin within Worpdress. I've managed to push some custom fields and their values to custom attributes within Algolia. Now, I'm trying to include a custom attribute named 'pro... | <p><code>Cannot read property 'matchedWords' of undefined</code> tells me that your custom parameter for <code>attributes</code> may not be defined in the scope of Algolia. </p>
<p>I would suggest initializing <a href="https://www.algolia.com/doc/api-client/php/parameters#attributestoindex" rel="nofollow"><code>attrib... |
How to tell Python to save files in this folder? <p>I am new to Python and have been assigned the task to clean up the files in Slack. I have to backup the files and save them to the designated folder Z drive Slack Files and I am using the open syntax below but it is producing the permission denied error for it. This s... | <p>To iterate over files in a particular folder, we can simply use os.listdir() to traverse a single tree.</p>
<pre><code>import os
for fn in os.listdir(r'Z:\Slack_Files'):
if os.path.isfile(fn):
open(fn,'r') # mode is r means read mode
</code></pre>
|
How to restrict IMEI number to only 15 digits without counting space after 4 digits <p>I have input field for imei number which should take only 15 digits that should only be numbers. Which I have done, my code below takes only 15 digits and leaves a space after 4 digits.</p>
<p>But the main problem I am facing here i... | <p>Change <code>keyup</code> to <code>keypress</code>:</p>
<pre><code>$(".imei").on('keypress', function() {
</code></pre>
<p><code>keyup</code> will only fire when you let go of the key, while <code>keypress</code> will fire every time the key is sent to the input.</p>
<p>Keep the <code>keydown</code> code as it's ... |
Enable/disable multiple textbox generated by row number of input data <p>Code:</p>
<pre><code><?php
include('conect.php');
$result = mysqli_query($conn,"SELECT * FROM `op` WHERE `type` = 2 ;");
echo "<table class='table table-striped table-hover'id='datatables-example'>
<tr>
... | <p>None of your <code><td></code> tags are closed in the second row.</p>
|
Redis for session handling of symfony applications deployed on Apache httpd <p>I am new to PHP, Symfony and Redis and have a query around integration of Redis with a symfony project deployed on Apache httpd as the server for session management.</p>
<p>The below is the software's and their versions that I am using</p>
... | <p>You have to change default session handler. To omit Symfony session handler and use PHP instead set the <code>handler_id</code> option to null in <code>settings.yml</code>:</p>
<pre><code>framework:
session:
handler_id: null
</code></pre>
<p><a href="http://symfony.com/doc/current/reference/configurati... |
Async Json feed finishing later than AyncTasks to load data from sqllite DB. How to sync them or better solution? <p>Async Json feed finishing later than AyncTasks to load data from sqllite DB. How to sync them or any better solution ?</p>
<p>I searched StackOverFlow but could not find this peculiar problems like mine... | <p>I am able to fix this by implementing Handler as talking mechanism between two Async tasks. I took help of this post. Once a DB inserts are over in Async Task then I am sending message to the called program to reset the Adapter of List.
Thanks to everyone for help in this.
<a href="http://stackoverflow.com/a/2613960... |
Entity Framework Code First navigation property through relational table <p>I'm trying to setup some navigation properties with some Entity Framework Code First models. I'd like them to look like this example:</p>
<pre><code>public class Course
{
[Key]
public int CourseId { get; set; }
public string Course... | <p>You need to construct your models as shown below when you have a <code>M : M</code> relationship. You don't need to construct junction table. EF will create one for you when you do the data migration.</p>
<p><strong>Model configuration using Conventions.</strong></p>
<pre><code>public class Student
{
public St... |
Read data from different directories using Firebase for Android <pre><code>/users:
- user1
- name: user1name
- /contacts
- user2
- user3
.....
- user2
- name: user2name
....
</code></pre>
<p>This is my current firebase database. When user1 is lo... | <p>Supposing that you already have the user selected, you can go about it in two ways:
1) Use <code>.child(String user);</code> in your database reference.
2) You may have declared a URL for your database. Add <code>+ "/" + String user;</code> to your URL.</p>
<p>You can further use these ways to parse through contact... |
check if an window closed in angularjs <p>I need to check if an window is closed or not.
Here is my example,</p>
<p>I have opened a new window by calling this function,</p>
<pre><code>$scope.openwind= function(){
$scope.popupWindow = $window.open("index.html#/channelintegration", "SOme Title", 'toolbar=no, locati... | <p>You can check if the <code>window is opened or not</code>, by taking <code>window.open</code> function in a scope variable and check using the scope.</p>
<pre><code>$scope.openwind= function(){
$scope.popupWindow = $window.open("index.html#/channelintegration", "SOme Title", 'toolbar=no, location=no, directorie... |
Run an executable file through a batch file which is situated in a remote location <p>Say, I am in directory <strong>D:\Users\S\Documents\ files\test_batch</strong> and now I want to create a batch file in this directory to run a .exe file named test.exe which is situated in location <strong>D:\Users\S\Documents\s\exam... | <p>Try this:</p>
<pre><code>pushd D:\Users\S\Documents\s\examples\c
test.exe
popd
</code></pre>
<p>The commands 'pushd' and 'popd' are used to maintain a "last in/first out" stack of current directories.</p>
|
Quadruple nested child elements in FactoryGirl <p>I'm trying to create dummy data with FactoryGirl. </p>
<p>User has many posts, post has many videos, video has many comments.
Comment belong to video and user.
Video belongs to post and user.
Post belongs to user.</p>
<p>I would like to create at least 20 users, each ... | <p>I think in factories hook should be <code>after(:create)</code> instead of <code>after(:build)</code>, e.g.:</p>
<pre><code>after(:create) do |video|
create(:comment, video: video)
end
</code></pre>
<p>Here is all updated factories:</p>
<p><strong>spec/factories/users.rb</strong></p>
<pre><code>FactoryGirl.def... |
Is there some feature in Visual Studio Team Services that can notify automatically when something has changed in files you monitor? <p>Is there some feature in Visual Studio Team Services (TFS) that can notify automatically when something has changed in files you work with? </p>
<p>Lets say I have client-side angular ... | <p>Yes, you can define Checkin alerts directly in the TFS configuration. These alert notifications are then sent out by mail.</p>
<p>For example you can set an alert if someone (perhaps other than yourself) does a checkin of specific files or in a specific directory. The possible criteria of the alert can be formulate... |
Ipython cv2.imwrite() not saving image <p>I have written a code in python opencv. I am trying to write the processed image back to disk but the image is not getting saved and it is not showing any error(runtime and compilation) The code is</p>
<pre><code>"""
Created on Wed Oct 19 18:07:34 2016
@author: Niladri
"""
i... | <p>As a general and absolute rule, you <em>have</em> to protect your windows path strings (containing backslashes) with <code>r</code> prefix or some characters are interpreted (ex: <code>\n,\b,\v,\x</code> aaaaand <code>\t</code> !):</p>
<p>so when doing this:</p>
<pre><code>cv2.imwrite('C:\Users\Niladri\Desktop\tro... |
Selecting nested Li elements <p>What am I doing wrong here I can't seem to target the nested list elements. I tried using a class called 'second-level' on the 2nd level of the unordered list, but it won't seem to work. Here's the bit of code that I want to effect my nested li elements: <code>.second-level li { backgr... | <p>The issue was that I had an extra <code>*/</code> before the css code that affected the nested li elements, which prevented the change. </p>
<pre><code>/*-webkit-transiton: opacity 0.2s; -moz-transition: opacity 0.2s; -ms-transition: opacity 0.2s; -o-transition: opacity 0.2s; -transition: opacity 0.2s;}*/ */
.se... |
Linking libraries opencv cmake <p>I am trying to link my library and opencv library. Cmake is working properly, solution is build but linker error occurs. It seems as cmake couldnt link opencv lib with my library. </p>
<p><a href="https://i.stack.imgur.com/aAulM.jpg" rel="nofollow">This is an error which visual studio... | <p>CMakeLists.txt I use for OpenCV apps configuring.</p>
<pre><code>cmake_minimum_required(VERSION 2.8)
set (PROJ_NAME YourAppName)
project(${PROJ_NAME})
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
FIND_PACKAGE(OpenCV)
s... |
What does T::* signify in the declaration of a function parameter list? <p>I declare a particular keyboard callback function as this inside my code:</p>
<pre><code>void keyboardEventCallback(const pcl::visualization::KeyboardEvent &event, void* viewer_void, void* widget_void);
</code></pre>
<p>The keyboard event ... | <blockquote>
<p>what is the meaning of T::* inside the registration function declaration</p>
</blockquote>
<p>This is the syntax of a pointer to member. Let's take a look at the whole type and name of the parameter:</p>
<pre><code>void(T::*callback)(const pcl::visualization::KeyboardEvent&, void*)
</code></pre>... |
How can I block or redirect traffic referred to my site by another site? <p>I have a domain that is being sent traffic from another domain with a similar name by a scammer who is trying to look legitimate. (the scammer is masquerading as my legitimate client) </p>
<p>How can I block or redirect traffic referred to my... | <p>There are a couple of methods you can use, <strong>IF</strong> you know the IP address you can use:</p>
<p><code>deny from xxx.xxx.x.xx</code></p>
<p>However, you can actually block directly from a referring website using:</p>
<pre><code>RewriteEngine On
RewriteCond %{HTTP_REFERER} example\.com [NC]
RewriteRule .... |
how do i find my ipv4 using python? <p>my server copy it if you want! :)
how do i find my ipv4 using python?
can i you try to keep it real short?</p>
<pre><code>import socket
def Main():
host = '127.0.0.1'
port = 5000
s = socket.socket()
s.bind((host,port))
s.listen(1)
c1, addr1 = s.accept(... | <p>That's all you need for the local address (returns a string):</p>
<pre><code>socket.gethostbyname(socket.gethostname())
</code></pre>
|
Symfony forms: does it omits a `false` `attr`? <p>I want to know in <code>JavaScript</code> if a particular feature is active or not.</p>
<p>I have a <code>PHP</code> class that has some <code>has*</code> methods.</p>
<p>So, in <code>Twig</code> I do this:</p>
<pre><code>{{ form_widget(form.plan.seo, {'attr': {'clas... | <p>Yep, that seems to be the normal behavior for assigning <strong>boolean</strong> values for the twig attrs values. An easy workaround would be to modify the code a bit:</p>
<pre><code>{{ form_widget(form.plan.seo, {'attr': {'class': 'feature', 'data-already-active': store.premium.hasSeo ? "1" : "0"}}) }}
</code></p... |
Minimum Required Node Version for GraphQL? <p>I am trying to get a reference implementation of GraphQL.js working in a Node.js environment as a server. Note that I have limited experience with Node.js. Right now, I am using <code>node</code> v4.2.6, which is the latest package from Ubuntu for Ubuntu 16.04.</p>
<p><a h... | <p>tThe <a href="http://graphql.org/graphql-js/#prerequisites" rel="nofollow">prerequisites</a> for that tutorial say:</p>
<blockquote>
<p>Before getting started, you should have Node v6 installed [...]</p>
</blockquote>
<p>Though to be fair it continues with:</p>
<blockquote>
<p>[...] , although the examples sh... |
Configure Spring 4 JDBC JDBCTemplate with Connection Provider class <p>Is there a way i can configure the spring 4 JDBCTemplate data source with a Connection provider class like the one hibernate provides? </p>
<p>I have connections managed by connection pool provided by a Java class. I can get connection through the ... | <p>One solution would be for you to extend <a href="http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/jdbc/datasource/AbstractDataSource.html" rel="nofollow">AbstractDataSource</a> and override getConnection() method and write new DataSource for you. Or to probably make easier by exten... |
AngularJS load ng-repeat into another ng-repeat with ajax call <p>I'm new to angular and would like some help in solving the following issue. This is the code I currently have, simply getting an array of results from the server using a post request and displaying them using the ng-repeat directive:</p>
<pre><code><... | <p>Firstly you should have a function in your controller with the name <strong>loadSubMedias</strong> and instead of simply taking media.id you can send whole media object to it (later on we will add new data into this object as an another property).</p>
<pre><code>$scope.loadSubMedias = function (media) {
$http({... |
how to make my initial workbook activate based on a full pathname <p>i have the following code, need it to work:</p>
<pre><code>Sheets("BigMaster").Range("A1:z999").Copy
Windows("Z:\Viewpoint\Viewpoint Import\Programs\SheetsForConstructionAndImportingIntoViewpoint - FROZEN.XLSM").Activate
Sheets("BigMaster").Range("A1... | <p>Assuming the destination workbook is open - if it's not then you first need to open it</p>
<pre><code>ActiveWorkbook.Sheets("BigMaster").Range("A1:z999").Copy _
Workbooks("SheetsForConstructionAndImportingIntoViewpoint - FROZEN.XLSM"). _
Sheets("BigMaster").Range("A1")
</code></pre>
|
Learn Python the Hard way ex25 - Want to check my understanding <p>total noob here confused all to hell about something in "Learn Python the Hard Way." Apologies if this has been covered; I searched and could only find posts about not getting the desired results from the code.</p>
<p>My question relates to the interac... | <p>How Python functions more or less work is the following:</p>
<pre><code>def function_name(parameter_name_used_locally_within_function_name):
#do stuff with parameter_name_used_locally_within_function_name
some_new_value = parameter_name_used_locally_within_function_name
return some_new_value
</code></p... |
Cannot debug C# RTD Server project in Visual Studio 2013 <p>As part of an attempt to figure out the various issues working with (previously) working .NET COM projects and Excel 2013 on my machine, I created a simple test C# RTDServer class in Visual Studio 2013. Creating the test RTD Server project helped me realize t... | <p>It turns out this problem was caused by an app config for Excel which we had to use when running with Excel 2003 (when we first developed this app).</p>
<p>The config contained the following:</p>
<p></p>
<pre><code> <startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v... |
How to tell what is causing seg fault when using pthread_create? <p>I'm having trouble finding the cause of this seg fault when calling pthread_create... </p>
<p>GDB is giving me <code>Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bc741d in pthread_create@@GLIBC_2.2.5 () from /lib64/libpthread.so.0<... | <p>The segfault is very likely because of passing uninitialized thread ID to <code>pthread_create()</code>. The array <code>lizard</code> isn't initialized. </p>
<p>Instead use an array:</p>
<pre><code> pthread_t lizard[NUM_LIZARDS]; // LK
...
// LK
for(i = 0; i < NUM_LIZARDS; i++) {
pthread_create(&a... |
ANTLR: How to write a rule for enforcing line continuation character while writing a string? <p>I want to write a rule for parsing a string inside double quotes. I want to allow any character, with the only condition being that there MUST be a line continuation character \, when splitting the string on multiple lines.<... | <h1>Solution</h1>
<pre><code>fragment ESCAPE
: '\\' .
;
STRING
: '"' (ESCAPE | ~[\n"])* '"'
;
</code></pre>
<h1>Explanation</h1>
<p>Fragment <code>ESCAPE</code> will match escaped characters (especially backslash and a new line character acting as a continuation sign).</p>
<p>Token <code>STRING</cod... |
How to create function (number, from, to) with a returning interval of boolean + input&print out <p>I've tried searching here on Stackoverflow and on Google search engine on creating a function(number, from, to) in a interval, that returns with boolean and get their data from an input source with having the possiblity ... | <p>If i understand it correctly, you want to check a number if it is inside of the given interval.</p>
<p>I have stripped the code a bit and now ther are only two function which makes the code working.</p>
<p>Please have a look to the button, ther is no value attribute. This is an attribute of input tag.</p>
<p><div... |
Creating two different objects through one Perl module <p>I'm writing Perl modules that allow users to create <code>file</code> and <code>directory</code> objects to manipulate the file system.</p>
<p><strong>Example:</strong></p>
<pre><code>use File;
use Dir;
my $file = File->new("path");
my $dir = Dir ->new... | <p>That's perfectly fine.</p>
<p>For example, Path::Class's <code>file</code> and <code>dir</code> functions return Path::Class::File and Path::Class::Dir objects respectively.</p>
<p>If that was the only constructor the class provided, it would prevent (clean) subclassing, but that's not the case here.</p>
<hr>
<p... |
Determine which surface mesh faces are visible <p>I am working with a triangle surface mesh in C/C++. I am looking for a surface mesh library (or a good algorithm I can implement) that would allow me to select the subset of the surface's faces that are visible from a specific origin point in space.</p>
<p>For simple g... | <p>Did you check the point cloud library (PCL)?
<a href="http://pointclouds.org/" rel="nofollow">http://pointclouds.org/</a></p>
|
Replacing strings in text files <p>I'm trying to replace some text in a file. I need to change the number in the below string (spacing included):</p>
<pre><code> "2016101901 ; serial number"
</code></pre>
<p>This number may vary, but the format is always the same (so it may be 2015100101, etc.).</p>
<p>I'm not sur... | <p>The <code>-replace</code> method is using <a href="/questions/tagged/regex" class="post-tag" title="show questions tagged 'regex'" rel="tag">regex</a>. So use this:</p>
<pre><code>{$_ -replace '^\d{10}(\s*;\s*serial number)', '2016101902$1'}
</code></pre>
|
this.props.enableEdit is not a function error while executing function <p>Trying to edit the entered text by edit button. Edit button invokes triggerEdit function that reads enableEdit property. My code goes like this:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
... | <p>With how your code is written it should just be: <code>this.enableEdit(i)</code>
enableEdit is a method on the component, not a prop you are passing into it</p>
|
Filter by a Reference Property in Appnengine <p>I am doing a blog in appengine. I want make a query to get the numbers of post by category. So I need filter by a Reference Property in appengine. Look my actual Code.</p>
<p>Those are my models :</p>
<pre><code>class Comment(db.Model) :
user = db.ReferenceProperty(... | <p>I haven't used <code>db</code> in a while, but I think something like this will work:</p>
<pre><code>count = 0
# Get all blogs of the desired category
blogs = Blog.all().filter("category =", cat.key())
for blog in blogs:
# For each blog, count all the comments.
count += Comment.all().filter("post =", blog.k... |
bash: sorting on same values gives different orders <p>I have the following two files:</p>
<p>file1:</p>
<pre><code>4 rs10000009 0 71048953 G A
4 rs10000010 0 21618674 C T
4 rs10000011 0 138223055 T C
2 rs1000001 0 50711642 T G
4 rs10000005 0 85161558 G A
12 rs100000... | <p>Use <code>-k 2,2</code> to sort based on 2nd column alone. <code>-k 2</code> means sort starting from 2nd column</p>
<pre><code>$ sort -f -k 2,2 file2
12 rs1000000 A G 0.2388 762
4 rs10000003 A G 0.2992 762
4 rs10000005 G A 0.4409 762
4 rs10000006 C... |
json to case class using multiple rows in spark scala <p>i have a json file with logs:</p>
<pre><code>{"a": "cat1", "b": "name", "c": "Caesar", "d": "2016-10-01"}
{"a": "cat1", "b": "legs", "c": "4", "d": "2016-10-01"}
{"a": "cat1", "b": "color", "c": "black", "d": "2016-10-01"}
{"a": "cat1", "b": "tail", "c": "20cm",... | <p>Assuming data has the unique properties for each cat (cat1, cat2). Apply some logic for duplicates. You can try something like this for your case class:</p>
<pre><code>#method to reduce 2 cat_output objects to one
def makeFinalRec(a: cat_output, b:cat_output): cat_output ={ return cat_output( a.id,
if(a.name=="" ... |
Merge map of maps(nested maps) by retaining all values of same keys es6 <p>I am trying to merge 2 maps which have keys and values(are maps again).</p>
<p>_.merge works fine for 2 regular maps but not working for map of maps or nested maps.</p>
<pre><code>map1 = {k1: {c1: v1, c2: v2}, k2: {c1: v1, c2: v2}};
map2 = {k1... | <p>Use <a href="https://lodash.com/docs/4.16.4#mergeWith" rel="nofollow"><code>_.mergeWith()</code></a> recursively.</p>
<p>ES6 solution:</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 set limits on rounded facet wrap y axis? <p>I have this plot and I need to round the y axis so what appears is acceptable EXCEPT for the fact that I would like to not just show 1 value on the y axis. I'd like to add the "limit" to the "scale_y_continuous" function so that the limits for each facet plot are uniqu... | <p>I don't have ggplot installed, but maybe a simple <code>if () else</code> could solve your problem. My first attempt would be this:</p>
<pre><code>if {
(dat$group =="y") c( floor( min(dat$A_low[dat$group =="y"]) /10)*10, ceiling(max(dat$A_up[dat$group =="y"])/10)*10 )
else c( floor( min(dat$A_low[dat$group =="z... |
Format parse exception âEEE MMM dd HH:mm:ss Z yyyyâ <p>My date string is: "Wed Oct 19 14:34:26 BRST 2016" and I'm trying to parse it to "dd/MM/yyyy", but I'm getting the following exception:</p>
<pre><code>java.text.ParseException: Unparseable date: "Wed Oct 19 14:34:26 BRST 2016" (at offset 20)
</code></pre>
<p>... | <p>Since the error message is complaining about offset 20, which is the <code>BRST</code> value, it seems that it cannot resolve the time zone.</p>
<p>Please try this code, that should ensure that the Brazilian time zone is recognized:</p>
<pre><code>SimpleDateFormat sdf = new SimpleDateFormat("EE MMM dd HH:mm:ss z y... |
Using jsp in Reactjs app <p>I have 2 questions which are related:</p>
<p>1.) I have a react app, which is loading using index.html
Can I do this index.html as index.jsp? When I simply change it like that, then run my npm server, go to localhost:8080/index.jsp, then this file doesn't open but downloads it. </p>
<p>2.)... | <ol>
<li><p>Yes, you can use React in a HTML page rendered from any source, including JSP.</p></li>
<li><p>No. This is why your attempt at 1) failed - JSP are <strong>Java</strong> Server Pages. You need a Java application server to execute JSP and serve the HTML output.</p></li>
</ol>
|
How to extend string with additional characters before and after special characters in string <p>A field on my form contains a string which is the formula for a math function. With this string I take data from database.</p>
<p>But the problem is, if some of this string in the database is NULL then my formula does not ... | <p>If I understand correctly, the different parts of the string from your form (amount_injuries, etc.) are column identifiers that you're using in a math expression in your query.</p>
<p>There are a few different ways to do this. The simplest way is to use a regular expression replacement on anything that is a valid c... |
NameResolutionFailure vs ConnectFailure issue <p>So a rather peculiar issue, but a pretty bad one nonetheless. When a user enters our app with no internet at all, we get back a <code>NameResolutionFailure</code> as the error message for trying to make a API call via <code>HttpClient</code>. Okay, that's fine. The issue... | <p>I just filed a bug on this recently:
<a href="http://bugzilla.xamarin.com/show_bug.cgi?id=45383" rel="nofollow">http://bugzilla.xamarin.com/show_bug.cgi?id=45383</a></p>
<p>This is a regression in Xamarin Android version >= 7.0. You can workaround it by downgrading to Xamarin Android 6.1.2.21. And since it is a re... |
Failed to install the ibm-mfp-push cordova plugin <p>Seems like a recent update to the <a href="https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-cordova-plugin-core" rel="nofollow">ibm-mfp-core</a> plugin (2 days ago) has lead to the impossibility to install the <code>ibm-mfp-push</code> plugin.</p>
<p>An ... | <p>The Plugin is currently being updated. I've contacted/escalated this issue to the Push team and will notify you when it is released.</p>
|
Training of chess evaluation function <p>I am about to write a chess engine based on reinforcement learning.
I'd like to train an evaluation function and figure out what are the weights of the board's most important features.</p>
<p>I'm not an expert of machine learning, I'm trying to learn from books and tutorials. I... | <p>You can't really do that directly. </p>
<p>A few approaches that I can suggest:</p>
<ul>
<li>Using scoring from an external source is not bad to at least kick start your algorithm. Algos to evaluate a given position are pretty limited though and your AI won't achieve master level using that alone. </li>
<li>Explo... |
How to keep nav menu highlighted after click using js in sidebar <p>I have created a nav menu in Wordpress and placed it in sidebar.php in my child theme. </p>
<p>My nav menu is in the correct location and functions and looks as it should with the exception of the JS, which I have tried to get right but seem to be fa... | <p>I assume that you don't use any router to remain on the same page. If so, then once a user clicks on any link, a browser will load completely new page and so this code of yours </p>
<pre><code>$('.main-nav-list').on('click', function () {
$('li.active').removeClass('active');
$(this).addClass('active');
})... |
Get values from a boost::multi_index <p>I have created a <code>boost::multi_index</code> successfully and inserted values too. I have two hashed indices to the multi_index. Both are member functions, but one is unique and the other one is non-unique. </p>
<p>I am trying to figure out the way to get the values from the... | <p>Here's how you'd retrieve from the string-based index:</p>
<pre><code>mi_storeMe container;
std::string needle = whatToSearchFor();
auto iterator = container.get<IndexByStringId>().find(needle);
if (iterator != container.get<IndexByStringId>().end())
found(*iterator);
else
notFound();
</code></pre>... |
angular2 & typescript & reactiveX : how to cast http get result <p>Lets suppose we have a rest api at this url <code>/api/stuffs/</code> where we can get a list of <code>Stuff</code>.</p>
<p>here is the code to http get the list of <code>Stuff</code>:</p>
<pre><code>getStuffs(): Observable<Stuff[]> {
return... | <p>Every time I am in a similar situation I do casting through a loop (which I guess you define manually).</p>
<p>This is an example with Customers instead of Stuffs</p>
<pre><code>getCustomers(code: string) {
let url = environment.baseServicesUrl + 'customer';
let jsonParam = {code: code};
re... |
npm install from a git repository not working <p>I am trying to install modules hosted on github using <code>npm install</code>.
For example </p>
<pre><code>npm install git+https://github.com/balderdashy/enpeem.git
</code></pre>
<p>But this is not placing the module in the <code>node_modules</code> folder.
If I run ... | <p>Updating node to v6.9.0 solved the problem.</p>
|
Back propagation of error in Feed forward neural network <p>**I am trying to develop a feedforward NN in MATLAB. I have a dataset of 12 inputs and 1 output with 46998 samples. while back propagating error,
1). I am getting NaN in Updated weight matrix between hidden and outer layer.
2). In the last equation of... | <p>You should try vectorize your algorithm. First arrange your data in a 46998x12 matrix X.Add bias to X like X=[ones(46998,1 X]. Then the weights leading from input layer to first hidden layer must be arranged in a matrix W1 with dimensions numberofneuronsinfirsthiddenlayer(24)x(input + 1). Then X<em>W1' is what you f... |
http0.0000000.000000www .. On Wordpress Log Out Redirect <p>I try to create a logout link which redirect to home url. I've tried this function:</p>
<p><code>wp_logout_url(site_url)</code></p>
<p>but, the output resulting strange prefix.</p>
<p><code>http://example.com/wp-login.php?action=logout&redirect_to=http0... | <p>I need to put <code>urldecode()</code> function. don't know why. So, it'll look like:</p>
<p><code>urldecode(wp_logout_url(site_url))</code></p>
|
SQLite - Return 0 if null <p>I have an assignment in Database Management Systems in which I have to write queries for given problems.
I have 4 problems, of which I solved 3 and stuck with the last one.</p>
<p><strong>Details:</strong></p>
<ul>
<li><em>Using version 1.4 of the Chinook Database</em>
(<a href="https:/... | <p>It often happens that it is simpler to use subqueries:</p>
<pre><code>SELECT EmployeeId,
FirstMame,
LastName,
Title,
(SELECT printf("...", ifnull(sum(Total), 0))
FROM Invoice
JOIN Customer USING (CustomerId)
WHERE Customer.SupportRepId = Employee.EmployeeId
... |
An image thats responsive but square as an <img> element <p>I am using Ionic 1.x and Angular 1.x, I display an avatar image thats usually square but not always, I want it to be full width, and then square, so if the screen is 720px wide, I want a 720px tall and wide image, if the image is larger than this size, it shou... | <p>One way to do this is to create a responsive square element and then use a CSS background image rather than an HTML img <code>src</code>:</p>
<ul>
<li><p>You can make a responsive element of any given <a href="https://en.wikipedia.org/wiki/Aspect_ratio_(image)" rel="nofollow">aspect ratio</a> with <code>height: 0</... |
How to count number of social shares on web page locally <p>I have a Facebook share button on a page,
And now the user shares a post on his/her timeline, Now what i want to do is count the number of times that specific user shares it in that session. </p>
<p>For Example the count will be initialized to 0 for all user... | <p>I'm not sure of the exact syntax without seeing the properties on the response object, but you should be able to do something like: </p>
<pre><code> document.getElementById('shareBtn').onclick = function() {
FB.ui({
method: 'share',
display: 'popup',
href: 'https://developers.faceboo... |
Boost intrusive pointer <p>I'm a little confused about boost's intrusive pointer. The definition says:</p>
<blockquote>
<p>"Every new <code>intrusive_ptr</code> instance increments the reference count by
using an unqualified call to the function <code>intrusive_ptr_add_ref</code>,
passing it the pointer as an ar... | <p>You <em>have to</em> provide these functions. This is how <code>boost::intrusive_ptr</code> operates.</p>
<p>Let's compare it with <code>boost::shared_ptr</code>. <code>shared_ptr</code> manages the reference count itself in the control block associated with the pointee. Creating a <code>shared_ptr</code> increment... |
rvest cannot find node with xpath <p>This is the website I scapre
<a href="http://www.cpppc.org:8082/efmisweb/ppp/projectLivrary/toPPPList.do" rel="nofollow">ppp projects</a></p>
<p>I want to use xpath to select the node like below
<a href="https://i.stack.imgur.com/hdIUl.png" rel="nofollow"><img src="https://i.stack.... | <p>It makes an XHR request for the content. Just work with that data (it's pretty clean):</p>
<pre><code>library(httr)
POST('http://www.cpppc.org:8082/efmisweb/ppp/projectLivrary/getPPPList.do?tokenid=null',
encode="form",
body=list(queryPage=1,
distStr="",
induStr="",
... |
Are implicits private? <p>Given the following code:</p>
<pre><code>class Foo[R](i: Int)(implicit ev: Ordering[R]) {
final type T = ev.type
}
</code></pre>
<p>I get the following error:</p>
<blockquote>
<p>Error:(13, 16) private value ev escapes its defining scope as part of
type Foo.this.ev.type
type T =... | <p>All parameters declared in a <code>class</code> constructor are <code>private</code> unless you tell the compiler they are not. This differs from a <code>case class</code> where all parameters in the first argument list are by default <code>public</code> unless you tell the compiler otherwise. </p>
<p>So, yes, unle... |
Cross browser vertical text alignment <p>Can anyone explain why vertical text alignment is so different between browsers?</p>
<p>See code below:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html pre... | <p>You can use this library to normalize their web pages across browsers.</p>
<p><a href="https://necolas.github.io/normalize.css/" rel="nofollow">Normalize</a></p>
<p>I have helped you in any way</p>
|
Wrong use of CSS content attribute? <p>I wanted to add an icon via the content attribute of CSS. I just copied the code written in the first answer here for a telephone icon:<br>
<a href="http://stackoverflow.com/questions/20782368/use-font-awesome-icon-as-css-content">Use font awesome icon as css content</a></p>
<p>B... | <p>The content tag is actually a reference to a webfont file, .woff. The empty square is occurs because the reference could not be resolved.</p>
<p>You should make sure that the css and woff resources found here - <a href="http://fontawesome.io/get-started/" rel="nofollow">http://fontawesome.io/get-started/</a> - are ... |
C# design related query (better refactoring) <p>I am working on a functionality where I feel there is room for improvement.</p>
<p><strong><em>Scenario:</em></strong></p>
<p>I have a different types of buttons in an physical instrument. Each button type has a certain functionality (say volume up or volume down etc).<... | <ol>
<li>Try to avoid "Magic numbers" like 1,2 etc. Use enum or constants instead.</li>
<li>Try to use explicit enum value like ShortPress = 0 ... It doing code more readable.</li>
<li>"InstrumentButtonType1" should be constant.</li>
<li>AddFunctionalityForMediumPress, AddFunctionalityForShortPress... have same behavi... |
Prevent TablewViewHeader to show when [tableView reloadData] is performed <p>does anyone know if there is a way to prevent my table view header to show (in this case a <strong>UISearchBar</strong>) when a <code>[tableView reloadData]</code> is performed.</p>
<p>I want to avoid this behaviour. The only way to show the ... | <p>After <code>[tableView reloadData];</code></p>
<p>Setting content offset(y position) of tableView might help.</p>
<pre><code>CGFloat nSearchBarHeight = 40;
CGPoint point = (CGPoint){0,nSearchBarHeight};
tableView.contentOffset = point;
</code></pre>
<p>Hope that helps.</p>
|
Capybara selenium xvfb throwing end of file error after recent update of Ubuntu 16.04 <p>Currently in my Ruby on Rails application cucumber test are being run with the <a href="https://github.com/jnicklas/capybara" rel="nofollow">capybara</a> gem and using selenium.</p>
<p>Recently after a system update to Ubuntu 16.0... | <p>Turns out I'm using a gem called <a href="https://github.com/flavorjones/chromedriver-helper" rel="nofollow">chromedriver-helper</a> that was using rbenv to override the version of chromedriver that was actually being used by capybara and selenium to run the tests. The gem readme said to try running <code>chromedriv... |
find/replace in SQL server <p>I have a query that I want to use every month, but the table it will point to will change slightly. I want to use a function analogous to find/replace to just update a portion of the table names referenced. Each table will just change its name by the Month_Year for the file. I have tried a... | <p>You need dynamic query</p>
<pre><code>exec ('alter table sp_panel_+'@file_name+' add LFDOB varchar(max)')
</code></pre>
|
Drawing on python and pycharm <p>I am a beginner on Python. I draw a square with this code.</p>
<pre><code>import turtle
square=turtle.Turtle()
print(square)
for i in range(4):
square.fd(100)
square.lt(90)
turtle.mainloop()
</code></pre>
<p>However, there is another code for drawing square with this code in t... | <p>You need to call the function so it will start:</p>
<pre><code>import turtle
def drawSquare(t, size):
for i in range(4):
t.forward(size)
t.left(90)
turtle.mainloop()
drawSquare(turtle.Turtle(), 100)
</code></pre>
|
ASP.Net MVC Authentication - Hide Element in View based on roles <p>Is there a possibility to hand over the Result of the Authorize-Attribute to the View?</p>
<p>Let's assume I want to hide 5 links in my Index view based on the memberships of a User.</p>
<pre><code>[Authorize(Roles = "Admin")]
public ActionResult Ind... | <p>You could use <code>ViewBag</code> and <code>ViewData</code> among other things, but I'd suggest passing a model back to the view with properties indicating whether to display the links or not.</p>
<pre><code>public class YourViewModel()
{
public bool ShowHiddenLinks { get; set; }
// ... whatever other prop... |
Work with a row in a pandas dataframe without incurring chain indexing (not coping just indexing) <p>My data is organized in a dataframe:</p>
<pre><code>import pandas as pd
import numpy as np
data = {'Col1' : [4,5,6,7], 'Col2' : [10,20,30,40], 'Col3' : [100,50,-30,-50], 'Col4' : ['AAA', 'BBB', 'AAA', 'CCC']}
df = pd... | <p>This should work:</p>
<pre><code>row_of_interest = df.loc['R2', :]
row_of_interest.is_copy = False
row_of_interest['Col2'] = row_of_interest['Col2'] + 1000
</code></pre>
<p>Setting <code>.is_copy = False</code> is the trick</p>
<p>Edit 2:</p>
<pre><code>import pandas as pd
import numpy as np
data = {'Col1' : [4... |
I am new to swift and I don't understand this function declaration <pre><code>public func computeAxis(var yMin yMin: Double, var yMax: Double)
</code></pre>
<p>what is a "var yMin yMin: Double" declaration?</p>
| <p>It's the old Swift 2, the <code>var</code> means the <code>yMin</code> can be changed in the function (which is deprecated and Swift 3 has <code>inout parameter</code> concept) and the first <code>yMin</code> is <code>argument label</code> you should use when calling <code>computeAxis</code> function which in this c... |
Bring another application into foreground when WPF XAML window is in Maximized <p>I have a WPF application in which the main window is set to full screen via <code>WindowState="Maximized"</code> in the <code>Window</code> tag. In the application, I'm opening PowerPoint through the Office Interop libraries with the inte... | <pre><code> [DllImport("user32.dll")]
public static extern bool ShowWindowAsync(HandleRef hWnd, int nCmdShow);
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr WindowHandle);
public const int SW_RESTORE = 9;
static void Main(string[] args)
{
Process... |
How to get Relative Path from Files of one choosen Folder? <p><a href="https://i.stack.imgur.com/Ij5yM.png" rel="nofollow">enter image description here</a></p>
<p><a href="https://i.stack.imgur.com/04F12.png" rel="nofollow">enter image description here</a>
I get only the relative path of the directory/folders but not ... | <p>From <a href="https://msdn.microsoft.com/en-us/library/07wt70x2(v=vs.110).aspx" rel="nofollow">MSDN</a> :</p>
<p>Directory.GetFiles Method (String)</p>
<blockquote>
<p>Returns the names of files (including their paths) in the specified directory.</p>
</blockquote>
<p>So you should do this:</p>
<pre><code>forea... |
JQuery and Ajax: How to store returned data in variables? <p>I have the following code:</p>
<pre><code> window.onload = function() {
var eMail = "<?php echo $log; ?>";
var aRticleid = "<?php echo $articleid1; ?>";
$.ajax({
type: "GET",
url: 'aquireLikes.ph... | <p>Your ajax would look like this:</p>
<pre><code> var liked;
$.ajax({
type: "GET",
url: 'aquireLikes.php?email='+eMail+'&id='+aRticleid+'',
type: 'json',
success: function(data){
liked = data.liked;
}
});
</code></pre>
<p>And in php you woul... |
Java input from text file with an unusual format <p>So I realize this text format may not be very unusual. However, I've been trying many ideas to read this correctly into the objects needed and know there has to be a better way. Here is what the file looks like:</p>
<pre><code>S S n
B 1 E 2
B N n
C 2 F 3
C N n
D 2 ... | <p>Actually your question is almost too broad and unspecific, but I am in the mood to give you some starting points. But please understand that you could easily fill several hours of computer science lectures on this topic; and that is not going to happen here.</p>
<p>First, you have to clarify some requirements (for ... |
Search for a combination in dataframe to change cell value <p>I want to replace values in a column if the a combination of values in two columns is valid. Lets say I have the following <code>DataFrame</code></p>
<pre><code>df = pd.DataFrame([
['Texas 1', '111', '222', '333'],
['Texas 1', '444', '555', ... | <p>You have all almost all your code, just create <code>dictionary</code> or <code>list</code> and iterate over it and you are done.</p>
<pre><code>import pandas as pd
combinations = [['key1', 'key2', 'msg']]
combinations.append(['Texas 1', '222', 'triple two'])
combinations.append(['Texas 1', '555', 'triple five'])
... |
'DataFrame' object is not callable <p>I'm trying to create a heatmap using Python on Pycharms. I've this code:</p>
<pre><code>import numpy as np
import pandas as pd
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
data1 = pd.read_csv(FILE")
freqMap = {}
for line in data1:
for item in line:
... | <p>You are reading a csv file but it has no header, the delimiter is a space not a comma, and there are a variable number of columns. So that is three mistakes in your first line.</p>
<p>And data1 is a DataFrame, freqMap is a dictionary that is completely unrelated. So it makes no sense to do data1[freqMap].</p>
<p>I... |
How to make two labels consecutively? Second label correctly show new line? <p>How to make two labels consecutively, so that the second end of the label at the screen moved the remainder of the text on a new line?</p>
<p>Example. First label - "I got it. Take me to the"
Second label - "Home Screen"</p>
<p><a href="ht... | <pre><code><Grid Padding="0, 10, -10, 10" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<Colu... |
Better way of passing data between pages: HTML5 storage vs Angular service <p>I am trying to pass data between two pages which are having Angular controllers. </p>
<p>Now I came across 2 different ways to pass data:</p>
<blockquote>
<ol>
<li>via Angular service (similar to <a href="http://stackoverflow.com/a/2018... | <p>This answer - <a href="http://stackoverflow.com/questions/28846266/ionic-local-storage-vs-using-service">Ionic local storage vs using service</a> - gives a good summary of the differences: local storage should be used primarily for data that will be used across a number of sessions or persists for a long time, where... |
Homebrew install the old version of flow <p>I cd to my react-native project directory, and run <code>flow</code>, it prompts me <code>Launching Flow server for /Users/... Wrong version of Flow. The config specifies version ^0.32.0 but this is version 0.33.0</code>. How do I install the previous version flow with Homebr... | <p>If you run <code>brew info flow</code> in the console, you'll see a line similar to the following:</p>
<pre><code>flow: stable 0.33.0 (bottled), HEAD
</code></pre>
<p>This means that the person managing the flow homebrew formula is removing old versions as the version gets updated, so it's impossible for you to ac... |
Why on iMac bash doesn't see some files <p>I have iMac and my bash on terminal has .bashrc, .bash_profile,.bash_login.
My questions are:</p>
<ol>
<li>what should be in each file</li>
<li>when I try <code>ls -ltr</code> or <code>grep something .bashrc</code> it says: <code>NO SUCH FILE OR DIRECTORY</code></li>
</ol>
| <ol>
<li>See the <a href="https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html" rel="nofollow">documentation</a>. In short, they are scripts to customize your command-line environment. Also, don't forget <code>.profile</code>.</li>
<li>The files do not exist by default. You need to create them.</l... |
MongoDB is not marshaling a value before storing it <p>I'm using a custom JSON marshaller/unmarshaller for a mapping between integers and strings in Go. The problem is that values are being stored in the database as integers instead of strings. In the example below, I would expect this to be stored in the MongoDB datab... | <p>The bson encoder does not use the JSON marshaling interfaces. Implement the <a href="https://godoc.org/gopkg.in/mgo.v2/bson#Getter" rel="nofollow">Getter</a> interface:</p>
<pre><code>func (intValue Const) GetBSON() (interface{}, error) {
return intValue.Code(), nil
}
</code></pre>
<p>You will also want to imp... |
ionic 2 ionicViewLoad() not firing <p>I am creating a mock ionic project, where I am using Google maps, the data is fetched from the remote server and the view is rendered only after the data is received so when I call the loadMap() method in ngOnInit() lifecycle hook It throws an error but it doesn't, when I use ionVi... | <p>API have changed. In Ionic 2 RC.1 it is changed to "<code>ionViewDidLoad</code>".
For more information, look <a href="https://ionicframework.com/docs/v2/api/navigation/NavController/" rel="nofollow">here</a>.</p>
|
How to compare versions of an Amazon S3 object? <p>Versioning of Amazon S3 buckets is nice, but I don't see any easy way to compare versions of a file - either through the console or through any other app I found.</p>
<p>S3Browser seems to have the best versioning support, but no comparison.</p>
<p>Is there a way to ... | <p>You can't view file contents at all via S3, so you definitely can't compare the contents of files via S3. You would have to download the different versions and then use a tool like <code>diff</code> to compare them.</p>
|
Creating growth series in R <p>Consider the Loblolly dataset in the MASS package.</p>
<pre><code>head(Loblolly)
height age Seed
1 4.51 3 301
15 10.89 5 301
29 28.72 10 301
43 41.74 15 301
57 52.70 20 301
71 60.92 25 301
</code></pre>
<p>For each seed I would like to create new variables heig... | <p>If I understand your question correctly, you should be able to do something like this:</p>
<pre><code># get data frame length
n <- dim(Loblolly)[1]
df <- NULL
# combine appropriate vectors
df$height1 <- Loblolly$height[1:(n-1)]
df$age1 <- Loblolly$age[1:(n-1)]
df$height2 <- Loblolly$height[2:n]
... |
How to embed video within a javascript slidetoggle <p>I'm attempting to achieve a javascript slide toggle with a youtube video embedded after the text once the button is clicked but it just won't work. Does anyone know what I'm doing wrong?</p>
<p>HTML:</p>
<pre><code><h2> What Is Black Ballad? </h2>
<... | <p>Its working in this code snippet i made.It seems you had a weird issue with the <p> tag wrapping the iframe.</p>
<p>Check it out.
</p>
<h2> What Is Black Ballad? </h2>
<p> This is some text. </p>
<p>
This is some more text and then an embedded video.</p>
<p><div class="snippet" data-lang="js" data-hide="fal... |
From which row a data.frame variable have a constant value <p>I would like to calculate the mean of a variable on a data.frame in R from the row which another variable start to have a constant value. I usually use dplyr for this database kind of task but I dont figure out how to do this, here is an example:</p>
<pre><... | <p><strong>Option 1:</strong> Using <code>rleid</code> from the <code>data.table</code> package:</p>
<pre><code>d %>%
group_by(rlid = rleid(Spc)) %>%
summarise(mean_size = mean(PSize), sd_size = sd(PSize)) %>%
slice(n())
</code></pre>
<p>gives:</p>
<pre><code># A tibble: 1 Ã 3
rlid mean_size s... |
executing multimatch ElasticSearch with boolean operations in query <p>Can I execute multimatch search with ElasticSearch and NEST in a way I can pass query with boolean operations inside the query? It appears all terms I passed to multimatch are by default linked with OR (which can be changed to other operator).</p>
... | <p>Yes you can <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#operator-min" rel="nofollow">https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#operator-min</a></p>
<pre><code>{
"multi_match" : {
"query": ... |
Passing Powershell argument to Provider=Microsoft.Jet.OLEDB.4.0 connection <p>I am trying to create a Powershell script that will be used to add a single table with two fields and add a value to one of those fields within a Access DB. I would like to be able to pass the DB path and value as an argument to the script. <... | <p>Nevermind... I rebooted and it worked. How ridiculous... plays automated recording from IT Crowd</p>
|
Android Java - Saving Object Lists to file <p>I'm newbie in programing, and I'm trying to save Object lists to a save file, but nothing seems to work. I get no errors or anything else, but values just won't save (For example : I click button "Money" and earn money, it need to be saved, but when I restart app, "money" a... | <p>I noticed that you are saving integer arrays, if you dont have a lot data, try to use sharedPreference to save and get data </p>
<pre><code>public void saveIntegerArray(Integer[] arr){
if (mSharedPreferences!=null){
mSharedPreferences.edit().putString(yourKey,Arrays.toString(arr)).... |
regex How to match duplicate attribute names inside a single element (<>) <p>I am trying to use regex to search for elements with duplicate style or class attributes. I can only get matching lines but I'd like more defined matching to the actual element (inside the <>). Anyone have an example? Below is some HTML ... | <p>A comprehensive solution would be this:</p>
<pre><code><[^>]+((class|style)(?:\s*=\s*("|')?(?(3)(?:(?!(?<!\\)\3).)*+\3|[\w{@#():,*!!\[\]}]*+)|(?=[^\w{@#():,*!!\[\]}])))[^>]+?(\2(?:\s*=\s*("|')?(?(5)(?:(?!(?<!\\)\5).)*+\5|[\w{@#():,*!!\[\]}]*+)|(?=[^\w{@#():,*!!\[\]}])))>
</code></pre>
<p>It will ... |
basic laravel route with other pages <p>I am making a blog in laravel. I set slug after my base url:</p>
<pre><code>Route::get('/{slug}',['as'=>'blog.single','uses'=>'blogController@getSingle'])
->where('slug','[\w\d-\_]+');
</code></pre>
<p>the problem is I want to open admin panel like this:</p>
<bloc... | <p>Try moving the declaration of your admin route above the route looking for a slug:</p>
<pre><code>Route::get('/admin', ['as'=>'admin.index', 'uses' => 'AdminController@index']);
Route::get('/{slug}',['as'=>'blog.single','uses'=>'blogController@getSingle'])
->where('slug','[\w\d-\_]+');
</code></p... |
How to upgrade my facebook Graph API app from v2.1 to v2.8 directly? <p>Facebook message :Currently you has access to Graph API v2.1 which will reach the end of its 2-year lifetime on 30 October, 2016. To ensure a smooth transition, please migrate all calls to Graph API v2.2 or <strong>higher</strong>.</p>
| <p>There is no way to do that, app will upgrade one step at a time but specify the API version explicitly in all calls. If SDK is being used , that should be configurable in one specific place. If not, modification is needed in multiple places.</p>
|
Is it possible to re-create AWS resources using CloudFormation? <p>Lets say an AWS stack was created using CloudFormation.
Now one of those resources was modified <em>outside</em> CloudFormation.</p>
<p>1) Is it possible to have CloudFormation specifically create those resources? Based on my understanding, we can't do... | <p>Unfortunately the answer for both your questions is <strong>NO</strong>.</p>
<ol>
<li>If you modify the resources in the stack after stack creation status is COMPLETE, there is nothing CF can do since it doesn't keep track of modification to resources</li>
<li>You have no option other than deleting the current stac... |
Radio & Dropdown to same observable - Knockout <p>I have same observable value assigned for radio list "checked" databind and for drop down list "value" databind</p>
<pre><code> <select name="controls" data-bind="options: cars(), optionsText:'make', optionsValue:'id', value: $root.selectedId, optionsCaption: 'Selec... | <p>For the provided fiddle I identify two different problems in your html</p>
<ol>
<li>Inside a <code>foreach</code> binding context is changed to current item, you need to use <code>$parent</code> to access to <code>selectedCar</code> property.</li>
<li>Input/radio was inside a label with a text binding, when this bi... |
Reformat JSON file? <p>I have two JSON files.</p>
<p>File A:</p>
<pre><code> "features": [
{
"attributes": {
"NAME": "R T CO",
"LTYPE": 64,
"QUAD15M": "279933",
"OBJECTID": 225,
"SHAPE.LEN": 828.21510830520401
},
"geometry": {
"paths": [
[
[
-99.818614674337155,
... | <p>Manipulating JSON in Python is a good candidate for the <a href="https://en.wikipedia.org/wiki/IPO_model" rel="nofollow">input-process-output model</a> of programming.</p>
<p>For input, you convert the external JSON file into a Python data structure, using <a href="https://docs.python.org/2/library/json.html#json.l... |
Git clone repo in Dockerfile lags <p>I'm trying to clone a private repo hosted by bitbucket to a docker container. My Dockerfile is as follow</p>
<pre><code>RUN git clone git@deploy:<blabla>.git /src/<blabla>
WORKDIR /src/<blabla>
RUN cd /src/<blabla>
RUN git pull --all --tags
RUN git checkout ... | <p>Try this:</p>
<pre><code>RUN git clone -b 'v1.1.2' --single-branch --depth 1 git@deploy:<blabla>.git /src/<blabla> \
&& cd /src/<blabla> \
&& pip install .
WORKDIR /src/<blabla>
</code></pre>
<p>Git clone can directly fetch the tag, and adding <code>--single-branch</c... |
Using Identity in SQL Server without race condition <p>So let's say you have a table of Patients with an IDENTITY(1,1) for the primary key. By using @@Identity, how do we avoid a race condition where two people may save a new patient at the same time? Obviously, duplicate ID's in the Patients table would not be creat... | <p>@@IDENTITY will not cause a race condition but it is NOT best practice either. You should instead be using SCOPE_IDENTITY.</p>
<p><a href="http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/" rel="nofollow">http://blog.sqlauthorit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.