Posts

Showing posts from September 23, 2018

Minus operation of data frames

Image
Clash Royale CLAN TAG #URR8PPP Minus operation of data frames I have 2 data frames df1 and df2 . df1 df2 df1 <- data.frame(c1=c("a","b","c","d"),c2=c(1,2,3,4) ) df2 <- data.frame(c1=c("c","d","e","f"),c2=c(3,4,5,6) ) > df1 c1 c2 1 a 1 2 b 2 3 c 3 4 d 4 > df2 c1 c2 1 c 3 2 d 4 3 e 5 4 f 6 I need to perform set operation of these 2 data frames. I used merge(df1,df2,all=TRUE) and merge(df1,df2,all=FALSE) method to get the union and intersection of these data frames and got the required output. What is the function to get the minus of these data frames,that is all the positions existing on one data frame but not the other? I need the following output. merge(df1,df2,all=TRUE) merge(df1,df2,all=FALSE) c1 c2 1 a 1 2 b 2 Do you want to get lines in df1 that are not in df2 and lines in df2 that are not in df1 ? – juba Apr 22 '13 at 9:39 @juba, I believe this is more of setdiff b

How to reset the npm registry in global npm config

Image
Clash Royale CLAN TAG #URR8PPP How to reset the npm registry in global npm config Is there any way to change or reset the global npm registry. Appreciate your assistance. stackoverflow.com/questions/22385092/… – Dinuka De Silva Dec 14 '16 at 7:27 3 Answers 3 Run the following command in your terminal to revert back to the default regsitry npm config set registry https://registry.npmjs.org/ NPM CONFIG DOCS Yes... You can use this $(npm config get globalconfig) npm config --global edit If you are on windows, other than setting the registry, you can also delete the .npmrc file to reset the registry. .npmrc You can find this file at C:Users<Your User Name>.npmrc C:Users<Your User Name>.npmrc By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Does Ajax.BeginForm Support File Uploading?

Image
Clash Royale CLAN TAG #URR8PPP Does Ajax.BeginForm Support File Uploading? I use HttpPostedFileBase as model for the file, but the files comes Null to the controller, I want to use the AjaxForm tha Asp.net provides not the regular BeginForm i need to post this throw ajax ? @using (Ajax.BeginForm("UploadImg", "Controller", Object, new AjaxOptions HttpMethod ="Post", OnComplete = "Something();" , new enctype = "multipart/form-data" )) @Html.AntiForgeryToken() <div class="form-horizontal"> @Html.ValidationSummary(true, "", new @class = "text-danger" ) <div class="form-group"> <div class="col-lg-7"> @Html.TextBoxFor(model => model.File, new type = "file", @class = "form-control", required = "required" ) <input type="submit" value="Upload" class="btn-primary" /> </div> </div> <

Save to engine camunda( version 7.9) variable type 'Date'

Image
Clash Royale CLAN TAG #URR8PPP Save to engine camunda( version 7.9) variable type 'Date' I want to save variable 'beauftragungsdatum' type 'Date' to engine : inject(['$http', 'Uri', function($http, Uri) camForm.on('store', function(evt) evt.retrieveVariables() var varManager = evt.variableManager; var vars = varManager.variables; var dataVar = $scope.beauftragungsdatum; varManager.variableValue('beauftragungsdatum', dataVar); var variableData = ; for(var v in vars) if(varManager.isDirty(v)) var val = vars[v].value; if(varManager.isJsonVariable(v)) val = JSON.stringify(val); variableData[v] = value: val, type: vars[v].type, valueInfo: vars[v].valueInfo ; var data = modifications: variableData ; var config = headers : 'Content-Type': 'application/json' ; $http.post(Uri.appUri('engine://engine/:engine/task/' + camForm.taskId + '/variables'), data, config); evt.storePrevented = tr

'Error: could not find function runmean' from an installed package: caTools?

Image
Clash Royale CLAN TAG #URR8PPP 'Error: could not find function runmean' from an installed package: caTools? I installed 'caTools' R package through the command line: $ R $ install.packages("caTools", lib="~/R/library") Then, did this command: INPUT=/home/user/file.bam OUTPUT=/home/user/file_cor.bam Rscript run_spp_nodups.R -c=$INPUT -savp -out=$OUTPUT And got the error: Error: could not find function "runmean" Execution halted The function 'runmean' belongs to package I installed, 'caTools'. The R version is appropriate, as R in my machine is version 3.3.2 and 'caTools' depends on R (≥ 2.2.0). The R code of 'run_spp_nodups.R' is to big to paste here. I show only the part with runmean: # Smooth the cross-correlation curve if required cc <- crosscorr$cross.correlation crosscorr$min.cc <- crosscorr$cross.correlation[ length(crosscorr$cross.correlation$y) , ] # minimum value and shift of cross-correla

How can I average every 5 rows specific column and select last data from another column in Pandas

Image
Clash Royale CLAN TAG #URR8PPP How can I average every 5 rows specific column and select last data from another column in Pandas I have pandas df with say, 100 rows, 4 columns. I want to calculate mean in specific columns("Value") every 5 rows and select last data(Fifth) of another column("Date") to keep in new dataframe. My dataframe that looks like this : >>df DateTime Product Location Value 0 12-07-2018 A S1 1.313 1 12-07-2018 B S1 3.089 2 12-07-2018 C S1 1.890 3 12-07-2018 D S1 3.136 4** 12-07-2018 E S1 3.258 5 13-07-2018 F S1 3.113 6 13-07-2018 G S1 2.651 7 13-07-2018 H S1 2.135 8 13-07-2018 I S1 1.555 9** 14-07-2018 J S1 2.009 10 14-07-2018 K S1 1.757 11 14-07-2018 L S1 1.808 12 14-07-2018 M S1 1.511 13 15-07-2018 N S1 2.265 14** 15-07-2018 O S1 2.356 15 15-07-2018 P S1 2.950 16 15-07-2018 Q S1 3.300 Now I can average every 5 rows by this code : > new_df = df.groupby(df.index // 5).agg('DateTime':'last', 'Value':'mean&

i18n for Angular 6 using angular cli

Image
Clash Royale CLAN TAG #URR8PPP i18n for Angular 6 using angular cli I've been reading Angular documentation for i18n using the ng tool xi18n . It looks like an impressive tool but I didn't get the following line. xi18n When you internationalize with the AOT compiler, you must pre-build a separate application package for each language and serve the appropriate package based on either server-side language detection or url parameters. does it mean I need to build 100 apps & do the serve depending on the detection I do on server side? Question is, Is it even possible in production scenarios? blog.danieleghidoli.it/2017/01/15/i18n-angular-cli-aot – Chellappan Aug 6 at 7:32 Yes you build one app for every language and need to serve the correct app depending on the language setting. This is because during the compiling process the app gets translated. Using aot means it is pre compiled consequently you need a pre compiled version for every language. Alternativel

How to query secondary replicas in Azure Cosmos DB

Image
Clash Royale CLAN TAG #URR8PPP How to query secondary replicas in Azure Cosmos DB As per this article, https://docs.microsoft.com/en-us/azure/cosmos-db/distribute-data-globally, each partition consists of four replicas for high availability. Also, I understand that Stored procedures always run against the primary replica (where all writes go). When we use DocumentClient to issue client side queries, there are options to set to query across specific regions. But I am not able to find how to query the secondary replicas. You don't query the secondary replicas. CosmosDB does this for you. You can however provide the ConsistencyLevel as part of you DocumentClient initialisation which will affect the replica querying – Nick Chapsas Aug 5 at 19:08 ConsistencyLevel DocumentClient @NickChapsas Do the queries from Stored procedures also hit the secondary or just the queries from the client side? – vmn Aug 5 at 22:35 I don't think it is done on the client side but

How to POST direct message using Twitter REST API in SWIFT 4

Image
Clash Royale CLAN TAG #URR8PPP How to POST direct message using Twitter REST API in SWIFT 4 I want to implement to send direct message to my twitter friends using Twitter REST API. I am getting all my friends id and put invite button for sending a message from my app. Following is the function call I am using - func sendInviteMessage(_ client: TWTRAPIClient, recepientID: String) let statusesShowEndpoint = " https://api.twitter.com/1.1/direct_messages/events/new.json" let params = ["recipient_id": recepientID,"message_data":"Hello","type":"message_create"] var clientError : NSError? let request = client.urlRequest(withMethod: "POST", urlString: statusesShowEndpoint, parameters: params, error: &clientError) client.sendTwitterRequest(request) (response, data, connectionError) -> Void in if connectionError != nil print("Error: (String(describing: connectionError?.localizedDescription))") do

Simple Android grid example using RecyclerView with GridLayoutManager (like the old GridView)

Image
Clash Royale CLAN TAG #URR8PPP Simple Android grid example using RecyclerView with GridLayoutManager (like the old GridView) I know that RecyclerView has replaced the functionality of the old ListView and GridView . I am looking for a very basic example that shows a minimal grid setup using RecyclerView . I am not looking for long tutorial style explanations, just a minimal example. I imagine the simplest grid that mimics the old GridView would consist of the following features: RecyclerView ListView GridView RecyclerView 2 Answers 2 Short answer For those who are already familiar with setting up a RecyclerView to make a list, the good news is that making a grid is largely the same. You just use a GridLayoutManager instead of a LinearLayoutManager when you set the RecyclerView up. RecyclerView GridLayoutManager LinearLayoutManager RecyclerView recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns)); If you need more help than that, then check out the

for loop that replaces element based on its value

Image
Clash Royale CLAN TAG #URR8PPP for loop that replaces element based on its value I have a list of integers and I am trying to define a function which loops through every element to check if they are less than 5 and returns the list in string according to their contents. intlist=[12, 10, 11, 23, 25, 2] def clear(x): for i in x: if i < 5: x[i] = 0 return str(x) else: return str(x) print clear(intlist) My code is not working as intended, could anyone enlighten me? If they are, I am to change all elements in the list to '0'. The outcome should look something like this. intlist=[0, 0, 0, 0, 0, 0] However if none of the elements are less than 5, the output should remain the same. intlist=[12, 10, 11, 23, 25, 2] What's the error message? As I can see in your code your indentations are not valid for if-else block. – Akshay Nevrekar 8 mins ago if-else In condition, there should be if x[i]<5 instead of i<5... – Sapan Zaveri 6 mins ago 4 Answers

How to know row number when typing in input field in table

Image
Clash Royale CLAN TAG #URR8PPP How to know row number when typing in input field in table In my XML view, I have a Table, in that Table I have Input field at a particular column, and I have a function for liveChange event of that Input field. Code is like below: <Table ...> <columns> ... </columns> <items> <ColumnListItem> <cells> ...... <Input type ="Number" value="..." liveChange="qtyChanged"/> </cells> </ColumnListItem> </items> </Table> In qtyChanged() , I need to know the row number on which user is editing. How to achieve it? qtyChanged() Use the getParent() and reach the row and the row index. – inizio Aug 6 at 7:37 getParent() 2 Answers 2 You can achieve it using indexOfItem() of sap.m.Table indexOfItem() sap.m.Table qtyChanged: function(oEvent) var oRow = oEvent.getSource().getParent();//Get Row var oTable = oRow.getParent();// Get Table var iRowIndex =

Consumer group member has no partition

Image
Clash Royale CLAN TAG #URR8PPP Consumer group member has no partition I launch two consumers on the same consumer group, i subscribe to 20 topics (each has only one partition) Only on consumer is used : kafka-consumer-groups --bootstrap-server XXXXX:9092 --group foo --describe --members --verbose Note: This will not show information about old Zookeeper-based consumers. CONSUMER-ID HOST CLIENT-ID #PARTITIONS ASSIGNMENT rdkafka-07cbd673-6a16-4d55-9625-7f0925866540 /xxxxx rdkafka 20 arretsBus(0), capteurMeteo(0), capteurPointMesure(0), chantier(0), coworking(0), horodateur( 0), incident(0), livraison(0), meteo(0), metro(0), parkrelais(0), qair(0), rhdata(0), sensUnique(0), trafic(0), tramway(0), tweets(0), voieRapide(0), zone30(0), zoneRencontre(0) rdkafka-9a543197-6c97-4213-bd59-cb5a48e4ec15 /xxxx rdkafka 0 What i do wrong ? Can you check if both are subscribed to same set of topics? Also, update the result by adding --verbose at the end of your command, if possible. – Bitswaz

In queue-triggered Azure Webjobs can an Azure Storage Queue message be modified after webjob function failure but before poisoning?

Image
Clash Royale CLAN TAG #URR8PPP In queue-triggered Azure Webjobs can an Azure Storage Queue message be modified after webjob function failure but before poisoning? I've got queue-triggered functions in my Azure webjobs. Normal behavior of course is when the function fails MaxDequeueCount times the message is put into the appropriate poison queue. I would like to modify the message after the error but before poison queue insertion. Example: MaxDequeueCount Initial message: "Name":"Tom", "Age", 30" "Name":"Tom", "Age", 30" And upon failure I want to modify the message as follows and have the modified message be inserted into the poison queue: "Name":"Tom", "Age", 30", "ErrorMessage":"Unable to find user" "Name":"Tom", "Age", 30", "ErrorMessage":"Unable to find user" Can this be done? 2 Answer