2018-10-22         Barbara

R & dplyr: using mutate() to get yearly totals

Data like so:data <- read.table(text="year level items2014 a 122014 b 162014 c 7")Would like to run that through mutate() and I guess group_by so I have a year and a total, so a row that's just:year items2014 35Feel like it should be 101 simple but I can't quite figure this one out. library(dplyr)out <- data %>% group_by(year) %>% summarize(items= sum(items, na.rm=T)) [XXX]

 r                     1 answers                     39 view
 2018-10-22         Barbara

Extracting elements in dropdown using protractor

I am learning protractor f/w for automating Angular Application, currently I am facing difficulty in accessing elements (Action-1, Action-2, ..) from drop down,below is the DOM sample<div class="actions-menu ng-trigger ng-trigger-showAni" style="top: 97px; left: 1231px; display: block; opacity: 1; transform: scale(1);"> <!----><button class="action-item ng-tns-c11-12 ng-star-inserted" style=""> Action-1 </button><button class="action-item ng-tns-c11-12 ng-star-inserted" style=""> Action-2 </button>&l...

 protractor                     1 answers                     72 view
 2018-10-22         Barbara

python function doesn't return anything

I'm trying to solve this problem:Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array.I came up with this code:def almostIncreasingSequence(seq): count_2 = 0 for element in seq: count = 0 seq.remove(element) for i in range(len(seq)-1): if seq[i] < seq[i+1]: count += 1 else: break if count == len(seq): return True else: seq = [element]+ seq ...

 python                     2 answers                     64 view
 2018-10-22         Barbara

Access Model Data from Django Base Template

I have a model Category, and I want its objects to always be displayed in a navigation menu in my base.html template (which all of my other templates extend).I want to learn best-practices so would like to know what the correct/accepted way of providing this data to the template is. You could create a custom tag for the categories and place it in the base template. That way you wont have to send a "category" variable to the context on every view ..Good Luck [XXX]I would use a custom context processor:In context_processors.py:def categories(request): return { ...

 python                     3 answers                     59 view
 2018-10-22         Barbara

gets() function using getchar from assembly

I'm having some problems making a gets() function on a C code i'm doing for one of my classes. So i already have a getchar() function but on assembly and i'm calling it from C using extern The thing is that at the moment i'm running the code i enter a string and it doesn't show the complete string instead some characters.This is the code i have atm:C code:extern char getchar(void);extern void putchar(char data);void gets(char *str);void puts(char *str);void new_line();char string[20];int main(){ while(1){ gets(string); new_line(); puts(string); } ...

 c                     1 answers                     93 view
 2018-10-22         Barbara

Align the text to center in headerlabel in iphone

I am new to iphone development.I have displayed the text in the header label.Now i want to align the text to center. I using the following code- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0,300.0,44.0)];UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];headerLabel.backgroundColor = [UIColor brownColor];headerLabel.textColor = [UIColor whiteColor];headerLabel.highlightedTextColor = [UIColor whiteColor];headerLabel.font = [UIFont boldSystemFontOfS...

 iphone                     1 answers                     21 view
 2018-10-22         Barbara

Motion disable AVI Videos

My motion (running on raspberry) is storing .avi files.output_pictures off is set, so i don't know why motion does this.Anyone a idea how I can disable this? The generation of moving image files is controlled by the config setting ffmpeg_output_movies. Setting this to off should resolve the problem. [XXX]

 raspberry-pi                     1 answers                     60 view
 2018-10-22         Barbara

SQLite3- how can I speed up this SELECT query?

SELECT DISTINCT sid, usrname, errcode, msg, DATE, TIMEFROM ecode e, action aWHERE e.errcode = a.STATUS LIMIT 250;I am developing a tool to look through server logs, but this query is painfully slow, and I'm not sure why (I am fairly new to SQL, so it's probably something basic). I am running this query against a database of server logs. errcode and msg come from the ecode table, all other properties come from the action table (which has ~100k entries). The ecode table contains a list of certain status codes that we consider errors. This query takes around ...

 sql                     1 answers                     41 view
 2018-10-22         Barbara

Auto Increment selection SQLite

I have a column named id in my SQLite database which is auto-increment, Primary Key, Unique.Is the result of the following query guaranteed to be the smallest value of id in the database and does this correspond to the "oldest" (as in a FIFO) row to be inserted?SELECT id FROM table LIMIT 1 The SQLite documentation is quite explicit: If a SELECT statement that returns more than one row does not have an ORDER BY clause, the order in which the rows are returned is undefined. Or, if a SELECT statement does have an ORDER BY clause, then the list of expressions attached t...

 sql                     2 answers                     93 view
 2018-10-22         Barbara

Identity Insert missing in all relevant SSIS Data Flow Transformation objects?

Am I the only person on this particular planet that is inconvenienced by the lack of Identity Insert, missing in all relevant SSIS Data Flow Transformation objects?Only the Bulk Insert Task supports Identity Insert, what about elsewhere in SSIS?Is there a technical change in SQL Server 2008 that makes this very, very limited support for Identity Insert in SSIS necessary?Because of this "little" detail, I prefer to use C# data procedures that call SQL Code wrapped in SET IDENTITY_INSERT [MyTable] ON and SET IDENTITY_INSERT [MyTable] OFF. See the link http://www.dosql.com/...

 sql-server                     3 answers                     97 view
 2018-10-22         Barbara

How to retrieve transaction from Hyperledger fabric network for Audit?

I would like to retrieve all transactions from the Hyperledger fabric netwrok for assurance. Please guide me to how retrieve transactions from all the peers to validate and completness of the transactions ?Thanks in advance. I think it depends on your business requirement. For audit purpose, it's more likely you want to know transactions about a specific asset(key/value). You can query history of a specific key using the GetHistoryForKey() shim API. A transactionId is contained in the response. Then you can query the detail by the transactionId. In addition, there are so...

 hyperledger-fabric                     1 answers                     4 view
 2018-10-22         Barbara

How to retrieve the clock type of std::filesystem::file_time_type in C++17

Since std::filesystem::file_time_type uses a trivial clock in C++17, is there a way to retrieve the actual clock type of file_time_type with C++17**?The goal is to convert the time to std::chrono::system_clock to use it e.g. in a stream.** In C++20, file_time_type will use std::chrono::file_clock, which has operator<< and can be casted to other clocks using std::chrono::clock_cast. You can retrieve the clock easily enough via file_time_type::clock. But converting from one clock to another won't really be possible until the changes from C++20 are available.The reaso...

 c++                     1 answers                     90 view
 2018-10-22         Barbara

How can I use Kryo to serialize an object and deserialize it again?

How can I use Kryo to serialize an object and deserialize it again? I am working in Kryo 2.23.0 Kryo's syntax is relatively similar to java serialisation. A kryo object is created as well as an output/input and one of kryos methods is used to perform the serialisation/deserialisationkryo.writeClassAndObject(output, object); //for if the concrete class isn't known (can be null)kryo.writeObjectOrNull(output, someObject); //if the object could be nullkryo.writeObject(output, someObject); //can't be null and concrete class is knownEach of the writes is paired with a readSome...

 java                     2 answers                     90 view
 2018-10-22         Barbara

Azure ARM Template Unit Test

How to test Azure ARM Templates and validate them whether these are written correctly or not from local VM.I have tried it from Power Shell but it just validate only. I want to Unit Test the ARM templates You can do unit test the ARM Templates with PESTER. If you are unfamiliar with pester, you can refer to this document.Example ARM TemplateThe example template being tested allows for the selection of whether managed or un-managed disk are used for the VM. The template can be found here https://github.com/bentaylorwork/azure-arm-templates/tree/master/disk-management-sele...

 azure                     1 answers                     18 view
 2018-10-22         Barbara

WPF How to use a ComboBoxes selected item as a xctk:PropertyGrid's SelectedObject in MVVM

I have a combo box that contains items of a different type so I can't bind to a list. I have set the items in the xaml individually as there will only ever be two items, so am not worried about the maintenance overheads in this situation. I also have a property grid (from Xceed) and would like to set the selectedObject of it to the selected item of my combo box. I am using the MVVM pattern and can't find a solution where you set the property grids selected object in the xaml. Here is the xaml for the combobox and property grid, there's not much to see, just the declaratio...

 c#                     1 answers                     80 view
 2018-10-22         Barbara

SyntaxError: multiple statements found while compiling a single statement

I'm in Python 3.3 and I'm only entering these 3 lines:import sklearn as skimport numpy as npimport matplotlib.pyplot as pltI'm getting this error:SyntaxError: multiple statements found while compiling a single statementWhat could I be doing wrong?Edit: If anyone comes across this question, the solution I found was to download Idlex and use its IDLE version, which allows multiple lines. Screenshot: http://imgur.com/AJSrhhD In the shell, you can't execute more than one statement at a time:>>> x = 5y = 6SyntaxError: multiple statements found while compiling a singl...

 python                     1 answers                     39 view

Page 1 of 145  |  Show More Pages:  Top Prev Next Last