Posts

Showing posts from September 24, 2018

How to load data in different servers

Image
Clash Royale CLAN TAG #URR8PPP How to load data in different servers I am designing an ETL project on SSIS and I want it to be dynamic. I will use this project for many customers therefore I will query these extractions against different servers. For example, I have this query in a step with "execute SQL task" component : INSERT DataWarehouse.schema.fact1 SELECT * FROM Database.schema.table1 My datawarehouse is always in localhost But "Database.schema.table1" could be in different servers therefore I will have Different linkservers in our customer's servers to retrieve its data. This means for example I will need the query change like this for customer1 : INSERT DataWarehouse.schema.fact1 SELECT * FROM [192.168.1.100].Database.schema.table1 And for customer2 I will need the query to be like this : INSERT DataWarehouse.schema.fact1 SELECT * FROM [10.2.5.100].Database.schema.table1 I've tried extract and loading with SSIS components but because...

How to sort to know sort data by completeness rate level on pandas

Image
Clash Royale CLAN TAG #URR8PPP How to sort to know sort data by completeness rate level on pandas Here's my dataset id feature_1 feature_2 feature_3 feature_4 feature_5 1 10 15 10 15 20 2 10 NaN 10 NaN 20 3 10 NaN 10 NaN 20 4 10 46 NaN 23 20 5 10 NaN 10 NaN 20 Here's what I need, I want to sort data based on completeness level (the higher percentage data is not nan, is higher the completeness level) of the dataset, the str is will be ascending so make me easier impute the missing value id feature_1 feature_2 feature_3 feature_4 feature_5 2 10 NaN 10 NaN 20 3 10 NaN 10 NaN 20 5 10 NaN 10 NaN 20 4 10 46 NaN 23 20 1 10 15 10 15 20 Best Regards, Can you explain more completeness rate level ? – jezrael Aug 6 at 6:37 completeness rate level Yes, I mean the percentage data not missing – Nabih Bawazir Aug 6 at 6:50 2 Answers 2 Try this: import pandas as pd import numpy as np d = ( 'A' : ['X',np.NaN,np.NaN,'X','Y',np.NaN,'X...

Verifying in Sequence

Image
Clash Royale CLAN TAG #URR8PPP Verifying in Sequence I am trying to verify a set of method calls in sequence. Here is a sample of what I would like to do. This test should fail, but it actually passes: public interface IMyInterface void Method(int i); public class MyClass : IMyInterface public void Method(int i) [TestMethod] public void MyTestMethod() var mock = new Mock<IMyInterface>(); var listOfThings = new List<int> 5, 4, 3, 2, 1 ; MethodUnderTest(mock.Object, listOfThings); mock.Verify(m => m.Method(1)); mock.Verify(m => m.Method(2)); mock.Verify(m => m.Method(3)); mock.Verify(m => m.Method(4)); mock.Verify(m => m.Method(5)); public void MethodUnderTest(IMyInterface myInterface, List<int> things) foreach (var i in things) myInterface.Method(i); This should fail, as the Verify calls expect a different order of parameters. Verify I have tried MockSequence like this: MockSequence [TestMethod] public void...

Trying to show the correct content for the clicked post

Image
Clash Royale CLAN TAG #URR8PPP Trying to show the correct content for the clicked post I have multiple posts (pulled from my DB) and I've added a modal to each of them so when the user clicks the post, a modal will appear displaying the contents. My problem is that I'm not able to show the proper contents for the proper modal. Ie. the contents are only shown for the first modal and not the rest. I'm not sure how to attach this function only to the modal that has been clicked. Is there a way to solve this? I've been playing a variable called text for testing purposes. text $(document).ready(function() $(".view").click(function() // The modal opens var text = "This could be the IPFS contents"; $("#content").append(text); ); ); 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 ...

XML content does not seem to be XML using read text: '/var/folders/_v/4fhshkb92kq_bnyv7dkxmh9c0000gn/T//Rtmp17F8m5/tmp.CBPLpCrO9L/word/document.xml'

Image
Clash Royale CLAN TAG #URR8PPP XML content does not seem to be XML using read text: '/var/folders/_v/4fhshkb92kq_bnyv7dkxmh9c0000gn/T//Rtmp17F8m5/tmp.CBPLpCrO9L/word/document.xml' I am currently working on a project in R where I collected a number of online news stories and saved them as pdfs in word. Then I attempted to upload the data into R and ran in to problems. The code I used is below: setwd("/Users/dk/Dropbox/Corpus") getwd() directory<-"/Users/dk/Dropbox/Corpus/nsle" directory library(quanteda) library(readtext) mydocs<- readtext(directory, encoding = "UTF-8", docvarsfrom = "filenames")` the error I am recieving is as follows: Error: XML content does not seem to be XML: '/var/folders/_v/4fhshkb92kq_bnyv7dkxmh9c0000gn/T//Rtmp17F8m5/tmp.CBPLpCrO9L/word/document.xml In addition: Warning message: In utils::unzip(i, exdir = td) : error 1 in extracting from zip file I am only asking the question on this website because...

spark streaming write data to spark-sql, but cann't query it

Image
Clash Royale CLAN TAG #URR8PPP spark streaming write data to spark-sql, but cann't query it I have submitted a streaming application, and write DataFram to spark-sql. df.show(5) df.write.mode(SaveMode.Append).saveAsTable(s"industy.test1") when i send some message to kafka, the line df.show(5) have printed in the log file, that means i have successfully consumed the data, but when i use the zeppelin and the spark-sql interactive command line to query industry.test1, there is no data that i have consumed. And the log file has not any errors, but when i reopened a spark-sql interactive command line to query table, i got the data. So i want to know why i need to reopen it. Thanks for any help. have you tried with just .saveAsTable("industy.test1") – Vijay Krishna Aug 6 at 20:25 @Vijay Krishna yes – Gaurav Aug 7 at 1:26 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and co...

Maya / Python, how to change display layer's colour?

Image
Clash Royale CLAN TAG #URR8PPP Maya / Python, how to change display layer's colour? After create a new display layer, how to set colour attribute to that layer? sel = cmds.ls(selection=True,fl=True) coneGroup = cmds.group(empty=True,name="cones_#") dGroup = cmds.createDisplayLayer(coneGroup, n = "cones_cam") cmds.color(dGroup, (0,0,0)) 3 Answers 3 Use need to use setAttr : setAttr sel = cmds.ls(selection=True,fl=True) coneGroup = cmds.group(empty=True,name="cones_#") dGroup = cmds.createDisplayLayer(coneGroup, n = "cones_cam") # Enable the layer's color. cmds.setAttr(".color".format(dGroup), True) # Enable the layer's color to use rgb. cmds.setAttr(".overrideRGBColors".format(dGroup), True) # Set the layer's color with values between 0-1. cmds.setAttr(".overrideColorRGB".format(dGroup), 1, 0, 0) Wow, it works!! Thank you very much!!! – user8972552 Feb 27 at 3:25 Don't forget to m...

How to disable Google Maps double tap zooming?

Image
Clash Royale CLAN TAG #URR8PPP How to disable Google Maps double tap zooming? How to disable Google Maps SDK double tap zooming (but not pinch zooming) in iOS SDK? Thank You 4 Answers 4 For Swift 2.1 You can do this on your GMSMapView object, GMSMapView mapView.settings.zoomGestures = false Same goes for disabling tilt gesture, rotate gesture, scroll gestures, mapView.settings.tiltGestures = false mapView.settings.rotateGestures = false mapView.settings.scrollGestures = false Read more here: https://developers.google.com/maps/documentation/ios-sdk/controls#map_gestures Unfortunately there is no way to disable double tap zoom while still keeping pinch zoom gestures. (I could be wrong, but I have went through their docs and haven't found a way to do so) try this : [googleMapView.settings setAllGesturesEnabled:NO]; he said that he wants to disable only double taps. this will disable all – Daij-Djan Nov 3 '13 at 9:45 install your own tapgesturerecognizer an...

Converting from hex to string

Image
Clash Royale CLAN TAG #URR8PPP Converting from hex to string I need to check for a string located inside a packet that I receive as byte array. If I use BitConverter.ToString() , I get the bytes as string with dashes (f.e.: 00-50-25-40-A5-FF). I tried most functions I found after a quick googling, but most of them have input parameter type string and if I call them with the string with dashes, It throws an exception. string byte BitConverter.ToString() string string string I need a function that turns hex(as string or as byte ) into the string that represents the hexadecimal value(f.e.: 0x31 = 1). If the input parameter is string , the function should recognize dashes(example "47-61-74-65-77-61-79-53-65-72-76-65-72"), because BitConverter doesn't convert correctly. string byte string string BitConverter Why not just remove the dashes? – 1800 INFORMATION Apr 7 '09 at 9:49 I found a good method at Code Review: codereview.stackexchange.com/questions/...

Hide element when all child values are all zeros

Image
Clash Royale CLAN TAG #URR8PPP Hide <div> element when all child <div> values are all zeros I have the following HTML that is dynamically generated. The number of "points__fees__value__item" div is variable. <div class="points__fees"> <div class="points__fees__label">Fees / Charges</div> <div class="points__fees__value"> <div class="points__fees__value__item" data-type="star$"> <span class="points__fees__text">63,000</span> Star $ <input class="points__fees__input" value="63000" type="hidden"> </div> <div class="points__fees__value__item" data-type="diamond$"> <span class="points__fees__text">50,000</span> Diamond $ <input class="points__fees__input" value="50000" type="hidden"> </div> <div class="points__fees__va...

Let a MainPage.cs create in Xamarin in Visual Studio

Image
Clash Royale CLAN TAG #URR8PPP Let a MainPage.cs create in Xamarin in Visual Studio I am currently doing a visual studio xamarin course and I noticed that when, in the videos, a new Blank Forms App is created, the IDE creates an App.cs and MainPage.cs. When I create one, the IDE creates a App.XAML with App.Xaml.cs and MainPage.XAML with MainPage.Xaml.cs. XAML is where the design is done are XAML.CS where the logic is done or I am wright. My question is, why or where come this change from? Why doesnt create XAML files in the course videos? An update or just a configuration difference? 1 Answer 1 This is just a difference in the templates provided in Visual Studio, when the video was shot, versus today. It is up to you whether you create your view in the XAML file or not. However, it would be the usual place to design the UI. However, it is very opinion based, whether you should put any logic into the xaml.cs file. Some people would say you should follow the MVVM pattern and ...

How to pass an integer value using ViewData in asp.net mvc and then use value stored in ViewData to compare with another integer value in the view?

Image
Clash Royale CLAN TAG #URR8PPP How to pass an integer value using ViewData in asp.net mvc and then use value stored in ViewData to compare with another integer value in the view? For eg. I want to do something like this in the controller : ViewData["dummy"] = 100; and then in the view I wish to compare its value like : @if(ViewData["dummy"] = 100) // do some stuff Currently if I do this, I get an error saying - Operator "==" cannot be applied to operands of type 'object' and 'int' Replace @if(ViewData["dummy"] = 100) to @if(Convert.ToInt32(ViewData["dummy"]))==100 – Ole EH Dufour 8 mins ago @OleEHDufour It still gives me a run-time exception saying - InvalidCastException: Unable to cast object of type 'Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[System.Int32]' to type 'System.IConvertible'. – oneinaminion 4 mins ago 1 Answer 1 Try if((int)ViewData["dummy...

The type or namespace name could not be found [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP The type or namespace name could not be found [duplicate] This question already has an answer here: I have a C# solution with several projects in Visual Studio 2010 . One is a test project (I'll call it " PrjTest "), the other is a Windows Forms Application project (I'll call it " PrjForm "). There is also a third project referenced by PrjForm, which it is able to reference and use successfully. C# Visual Studio 2010 Windows Forms Application PrjForm references PrjTest , and PrjForm has a class with a using statement: using using PrjTest; using using PrjTest; The type or namespace name 'PrjTest' could not be found (are you missing a using directive or an assembly reference?) I've tried the following to resolve this: VS 2010 I have done my homework and spent far too long looking for an answer online, none of the solutions has helped yet. What else could I try? This question has been asked before and alr...

mvn spring-boot:run vs java -jar

Image
Clash Royale CLAN TAG #URR8PPP mvn spring-boot:run vs java -jar I know it may sound silly question but I am unable to understand the difference between mvn spring-boot:run and java -jar (.jar file generated with mvn install) mvn spring-boot:run java -jar I have a spring boot application with jsp pages in /src/main/resources/META-INF/resources/WEB-INF/ . If I use mvn spring-boot:run these pages are served. But If I use java -jar these pages are not found by application. /src/main/resources/META-INF/resources/WEB-INF/ mvn spring-boot:run java -jar The application that I am working on is at https://github.com/ArslanAnjum/angularSpringApi UPDATE: It works with spring boot 1.4.2.RELEASE while I intend to use the latest version i.e., 1.5.8.RELEASE. UPDATE: Well I solved the problem by putting jsps in src/main/webapp/WEB-INF/views/ and changing packaging type to war and then running this war using java -jar target/myapp.war and its working fine now. can you post your spring appli...

Count Datatable rows with specific String

Image
Clash Royale CLAN TAG #URR8PPP Count Datatable rows with specific String How to count datatable rows with specific text? I try to use filter() but is not working. $("#buttonAlert").on("click", function (event) var count = $("#example1").DataTable.rows .column(4) .data() .filter(function (value, index) return value = "OK" ? true : false; ).length; alert('Total OK is: ' + count); ); The error like below: ssar:391 Uncaught TypeError: Cannot read property 'column' of undefined at HTMLButtonElement.<anonymous> (ssar:391) at HTMLButtonElement.dispatch (jQuery-2.1.4.min.js:3) at HTMLButtonElement.r.handle (jQuery-2.1.4.min.js:3) 2 Answers 2 Try the below one, I am pushing the rows to matchedRows array based on the column value equality... matchedRows var matchedRows = ; var table = $('#table_id').DataTable(); var data = table.data().toArray(); data.forEach(function(row) row.forEach(function (column) ...