Posts

Showing posts from July 28, 2018

Update/Replace Values in Dataframe with Tidyverse Join

Image
Clash Royale CLAN TAG #URR8PPP Update/Replace Values in Dataframe with Tidyverse Join What is the most efficient way to update/replace NAs in main dataset with (correct) values in a lookup table? This is such a common operation! Similar questions do not seem to have tidy solutions. Constraints: 1) Please assume a large number of missing values and bigger lookup table than the example given. So case-wise replacement operations would be impractical (no case_when , if_else , etc.) case_when if_else 2)The lookup table does not have all values of main dataframe, only the replacement ones. Tidyverse solution answer much preferred. Similar questions do not seem to have tidy solutions. library(tidyverse) ### Main Dataframe ### df1 <- tibble( state_abbrev = state.abb[1:10], state_name = c(state.name[1:5], rep(NA, 3), state.name[9:10]), value = sample(500:1200, 10, replace=TRUE) ) #> # A tibble: 10 x 3 #> state_abbrev state_name value #> <chr> <chr> ...

LEADER_NOT_AVAILABLE - docker container

Image
Clash Royale CLAN TAG #URR8PPP LEADER_NOT_AVAILABLE - docker container setting up docker containers (kafka, zookeeper) and trying to (publish and) consume from another, receive the following error: KafkaError{code=LEADER_NOT_AVAILABLE,val=5,str="Broker: Leader not available"} There is no additional error indication when publishing or consuming. When testing connectivity with telnet 172.18.0.3 9092 I receive the expected result. telnet 172.18.0.3 9092 In [2]: c.list_topics() Out[2]: ClusterMetadata(9ToJF8nPQC-rCTXGxuUalw) In [3]: l = c.list_topics() In [4]: l.brokers Out[4]: {1010: BrokerMetadata(1010, 172.18.0.3:9092)} In [7]: l.orig_broker_name Out[7]: u'172.18.0.3:9092/1010' In [8]: l.topics Out[8]: {'__consumer_offsets': TopicMetadata(__consumer_offsets, 50 partitions), 'item': TopicMetadata(item, 1 partitions), 'mytopic': TopicMetadata(mytopic, 1 partitions)} In [9]: i =l.topics['item'] In [10]: i.partitions Out[10]: {0: Partiti...

How to do a row wise count in Hive

Image
Clash Royale CLAN TAG #URR8PPP How to do a row wise count in Hive h1 h2 h3 h4 h5 h6 h7 h8 U U NULL U Y NULL Y X U NULL U U Y Y X X U U U NULL U NULL Y NULL NULL NULL NULL NULL NULL NULL NULL NULL X V U U Y NULL Z X Y X NULL X Y Z U X NULL U NULL NULL U Z Y NULL NULL NULL NULL NULL NULL NULL NULL Suppose, above data set is having 8 column h1,h2,h3......h8. if all the all the column is having NULL then the count is 0. if at least one column is having value then the count is 1. like first row has a count of 6.(donot consider null values). so, if a first row has 6 value then its count is 6 and next row has count of 7 and the last row has no value. so in this case the total count is 2 because only two row has information or values. because two row has values. just tell me the code how do i count those eight column values row wise?? i am confused s...

Converting EditText to TextView type in android studio [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP Converting EditText to TextView type in android studio [duplicate] This question already has an answer here: I'm trying to convert my EditText to String type and then evaluate a mathematical expression(given by user) to display it in a textView type but my app crashes every time a try to run it. package com.example.abhishek.edittexttrial; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; //import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import net.objecthunter.exp4j.Expression; import net.objecthunter.exp4j.ExpressionBuilder; public class MainActivity extends AppCompatActivity { private TextView txtScreen = (TextView)findViewById(R.id.txtScreen); private EditText etxt = (EditText)findViewById(R.id.editText); private double ans; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstan...

-bash: /.bash_profile: No such file or directory [on hold]

Image
Clash Royale CLAN TAG #URR8PPP -bash: /.bash_profile: No such file or directory [on hold] After installing Java SE Development Kit 10 When I try to check which version is activated on bash and when I do the same way as the way is teached on this MOOC and on this specific course: For starting to be sure I’m on the right dir I do: cd ~ /.bash_profile I receive this error: -bash: /.bash_profile: No such file or directory And then after what can I do if the file is empty what should i put in it? If you get the same error just check that edited post. This question appears to be off-topic. The users who voted to close gave this specific reason: 1. The links provided lead to websites which are not in English language. 2. Unfortunately questions asking for: books, tutorials, or other off-site resource are off-topic and should be closed. Stack Overflow is a Questions & Answers website for specific programming questions. – sɐunıɔןɐqɐp ...

Is it possible to check the version of an android app available in playstore programmatically

Image
Clash Royale CLAN TAG #URR8PPP Is it possible to check the version of an android app available in playstore programmatically I want to implement force update feature in my app which means, if any upgrade is available in playstore the user need to upgrade the app to its latest version thats the concept. For this, i need to know how can we check the version of an app available in playstore. And one other thing is when the user clicks the upgrade button the app page in playstore should show update instead of install. Thanks in advance 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.

Android: NavigationDrawer/multiple activities/same menu

Image
Clash Royale CLAN TAG #URR8PPP Android: NavigationDrawer/multiple activities/same menu What I am trying to do, is have a NavigationDrawer menu like this: NavigationDrawer I've figured out how to change layouts when menu items are clicked, but how do I load a new activity without losing the menu? My main question: For example let's say one of my menu options takes you to a layout where there are some buttons that do something. I need to load an accompanying activity/class, that will handle the actions and functionality of that specific "page" in the App. If another menu option takes you to a layout with only an image, for example, that would be another activity without all that code that handles the functionality of the buttons, since there are no buttons in this screen. I hope that makes sense! I followed many tutorials/videos online using several methods (Fragments etc.) but nothing quite answered my question. By the way, what I am doing n...

how to update domain with hql that has nested property?

Image
Clash Royale CLAN TAG #URR8PPP how to update domain with hql that has nested property? I have RaceRegistration class that has a property of type Participant which has attribute bibNumber. I would like to set all bibNumbers belonging to an event to null. The following hql doesn's work. It is giving the error. So it looks like it cannot recognize r.participant.bibNumber. node to traverse cannot be null!. Stacktrace follows: java.lang.IllegalArgumentException: node to traverse cannot be null! How can i update nested attribute of a domain class? RaceRegistration.executeUpdate("update RaceRegistration r set r.participant.bibNumber = null" + "where compositeEvent=:comp", [comp: compositeEvent ]) 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 subjec...

How Promise.resolve to resolve “then object”?

Image
Clash Royale CLAN TAG #URR8PPP How Promise.resolve to resolve “then object”? This is my code: var pr = Promise.resolve( { then:function(resolve,reject) { setTimeout( () => { reject(new TypeError('myError')); resolve('run'); },2000) } }) I don't know ,what is priority in run? guesse 1 : step1 : at first, setTimeout is executed and returns promise with result myError for then method. setTimeout promise myError then step2 : then method returns same Promise for resolve method. then Promise resolve guesse 2 : step1 : Promise.resolve( returns Promise that,its then method changes to: Promise.resolve( Promise then function(resolve,reject) { setTimeout( () => { reject(new TypeError('myError')); resolve('run'); },2000) } step2 : Finally pr.then(function(....){}) produce result. pr.then(function(....){}) I do not know how it works and what my guess is right. ...

Carrierwave: Encoding::UndefinedConversionError (“xFF” from ASCII-8BIT to UTF-8)

Image
Clash Royale CLAN TAG #URR8PPP Carrierwave: Encoding::UndefinedConversionError (“xFF” from ASCII-8BIT to UTF-8) I'm trying to upload multiple files to a record called Post , with a json attribute called images , using Carrierwave. But when I try to save the record, I get this error: Post images (0.5ms) ROLLBACK Completed 401 Unauthorized in 15ms (ActiveRecord: 0.8ms) Encoding::UndefinedConversionError ("xFF" from ASCII-8BIT to UTF-8): I've used Carrierwave before and I never got this error. I checked if anyone's had this problem, before, and I didn't find much. This question suggested the activesupport-json_encoder gem, but this gem isn't compatible with Rails 5. Also suggested were the force_encoding method and using a "wb" flag when saving the file, but the Carrierwave code has no place to implement those suggestions. activesupport-json_encoder force_encoding Here's the code I have: form <%= form_for @post, :html => {multipart: t...

Environment variables in Gogole Cloud build

Image
Clash Royale CLAN TAG #URR8PPP Environment variables in Gogole Cloud build We want to migrate from bitbucket pipelines to Google cloud builds to test, build and push docker images. How can we use environment variables without CryptoKey. Example: - printf "https://registry.npmjs.org/:_authToken=${NPM_TOKEN}nregistry=https://registry.npmjs.org" > ~/.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.

Query LOCAL Bitcoin blockchain with C# .NET

Image
Clash Royale CLAN TAG #URR8PPP Query LOCAL Bitcoin blockchain with C# .NET I am trying to check the balance of a given Bitcoin address by using ONLY the locally stored blockchain (downloaded via Bitcoin Core). Something similar to this (by using NBitCoin and/or QBitNinja), but without needing access to the network: private static readonly QBitNinjaClient client = new QBitNinjaClient(Network.Main); public decimal CheckBalance(BitcoinPubKeyAddress address) { var balanceModel = client.GetBalance(address, true).Result; decimal balance = 0; if (balanceModel.Operations.Count > 0) { var unspentCoins = new List<Coin>(); foreach (var operation in balanceModel.Operations) unspentCoins.AddRange(operation.ReceivedCoins.Select(coin => coin as Coin)); balance = unspentCoins.Sum(x => x.Amount.ToDecimal(MoneyUnit.BTC)); } return balance; } The example above needs access to the network. I need to do the same thing offline. I c...

How to send this data automatically to server on background when user opens website, using php and for function JavaScript can be used

Image
Clash Royale CLAN TAG #URR8PPP How to send this data automatically to server on background when user opens website, using php and for function JavaScript can be used This is my website. When someone open this website, as shown in the website these information should be sent automatically to SQL Server or these information should be saved in a directory in the form of html in background these information are invisible for user while opening website. The user will not be able to see these data but these ta will be sent to my server in background and i will see in future. The code i have written is enter link description here Please help me I am a beginner in programming language. I am making a website and when someone visit to my website i want to record which ip visited my website and every information about the user what are possible. stealing of user information its very Idea. – Geek Jun 29 at 9:53 ...

How to do FAB bottom container same this image in android?

Image
Clash Royale CLAN TAG #URR8PPP How to do FAB bottom container same this image in android? FAB bottom inset container how to do it? please 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.

i m trying to add Country code Picker in my android project , in component tree it is showing question mark at CCP

Image
Clash Royale CLAN TAG #URR8PPP i m trying to add Country code Picker in my android project , in component tree it is showing question mark at CCP This is XML code which I am using right now <com.hbb20.CountryCodePicker android:id="@+id/ccp" android:layout_width="wrap_content" android:layout_height="wrap_content" app:ccp_defaultNameCode="IN"> </com.hbb20.CountryCodePicker> CCP is not working.... – Sandeep Vishwakarma 15 mins ago 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.

On click of button, inrementation number by 1

Image
Clash Royale CLAN TAG #URR8PPP On click of button, inrementation number by 1 Trying to make the number increment by 1 on click event, wondering what's the right approach to this? In my render(): {this.state.posts.map(post => <div key={post._id}> <span>Votes: {post.votes}</span> <a href="" onClick={() => this.votePost(post._id)}> Click Me </a> </div> )} initial state: state = { posts: , }; on click function: votePost = async id => { await axios.put(`/posts/${id}`); .... }); this.setState({ posts: newPostData }); }; where are you getting newPostData form? If you are getting it from server then its fine but you need to update that particular post only, No need to reset entire posts. – Pawan Singh 20 mins ago ...

Firebase Storage video upload error Cross origin is NULL

Image
Clash Royale CLAN TAG #URR8PPP Firebase Storage video upload error Cross origin is NULL I am trying to upload store the videos on Firebase Storage .The code works for images ,but for videos it shows: Failed to load https://firebasestorage.googleapis.com/v0/b/resource-access-point.appspot.com/o?name=vid%2Fvideoplayback.mp4: The 'Access-Control-Allow-Origin' header has a value 'null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access. <html> <head> </head> <body> <progress value="0" max="100" id="uploadprog"></progress> <input type="file" id="upinput"/> <button onclick="mew()">get url</button> </body> <script src="https://www.gstatic.com/firebasejs/5.3.0/firebase.js"></script> <script> // Initialize Firebase var config = { apiKey: "", authDomain: "", ...