小编Kas*_*sra的帖子

在kaggle笔记本中安装谷歌驱动器

在 google colab 中,我可以轻松地安装我的 google 驱动器:

from google.colab import drive
drive.mount('/content/gdrive')
Run Code Online (Sandbox Code Playgroud)

然而,在 kaggle 的笔记本中,它给出了这个错误:

KeyError                                  Traceback (most recent call last)
<ipython-input-14-2b128295b616> in <module>
      2 # !pip install google-colab
      3 from google.colab import drive
----> 4 drive.mount('/content/gdrive')
      5 # Set your own project id here
      6 # PROJECT_ID = 'your-google-cloud-project'

/opt/conda/lib/python3.6/site-packages/google/colab/drive.py in mount(mountpoint, force_remount, timeout_ms)
     80     return
     81 
---> 82   env = _env()
     83   home = env.home
     84   root_dir = env.root_dir

/opt/conda/lib/python3.6/site-packages/google/colab/drive.py in _env()
     41   home = _os.environ['HOME']
     42   root_dir = …
Run Code Online (Sandbox Code Playgroud)

python google-drive-api jupyter-notebook kaggle google-colaboratory

10
推荐指数
2
解决办法
4836
查看次数

在模拟器中测试本机 firebase 推送通知的反应

根据 React Native Firebase 文档,推送通知在模拟器中不起作用。当您在通过电缆连接到 PC 的真实 ios/Android 设备上运行应用程序时,即使是应用程序外通知(当应用程序在后台运行并且您在状态栏中看到通知时)也不起作用。(应用内通知可以通过使用messaging().onMessage

当前行为:我的 Firebase 推送通知在独立 apk/ipa 中的 Android 和 ios 上都能完美运行。但是,我无法在模拟器上开发期间对其进行测试。

期望的行为:当应用程序在后台模拟器上运行时,我希望收到推送通知(应用程序外通知),以便我可以messaging().onNotificationOpenedApp像往常一样使用方法。

为什么我需要这个? 当然,每次我对推送通知进行更改时,我都可以创建一个独立的应用程序,将其安装在手机上以查看其工作原理。这种方法有很多问题:

  1. 超级耗时而且完全没有意义
  2. 如果代码没有按预期工作,则无法检查出了什么问题
  3. 一般来说,没有console.log办法调试代码

push-notification firebase reactjs react-native

7
推荐指数
1
解决办法
5818
查看次数

在文件之间共享 mqtt 客户端对象

我以这种方式连接到 MQTT:

//mqtt.js

const mqtt = require('mqtt');

var options = {
    //needed options
};

var client = mqtt.connect('mqtt://someURL', options);

client.on('connect', () => {
    console.log('Connected to MQTT server');
});
Run Code Online (Sandbox Code Playgroud)

我想以这种方式导出客户端对象:

//mqtt.js

module.exports = client;
Run Code Online (Sandbox Code Playgroud)

这样我就可以将它导入其他文件并以这种方式使用它:

//anotherFile.js    

const client = require('./mqtt');
client.publish(...)
Run Code Online (Sandbox Code Playgroud)

但是,我们都知道这是行不通的!我怎样才能做到这一点?

更新

我尝试了promise并得到了一个非常奇怪的行为。当我像下面的代码一样在同一个文件 (mqtt.js) 中使用 promise 时,一切正常:

//mqtt.js
const mqtt = require('mqtt');

var mqttPromise = new Promise(function (resolve, reject) {

    var options = {
     //needed options
    };
    var client = mqtt.connect('mqtt://someURL', options);

    client.on('connect', () => { …
Run Code Online (Sandbox Code Playgroud)

export node.js mqtt node-modules

5
推荐指数
1
解决办法
789
查看次数

React Navigation 5.x 基于参数的导航过渡动画

是否可以根据特定传递的参数启用/禁用导航过渡动画?

navigation.navigate('SomeScreen', {
          data: someData,
          withAnimation: true,
        });
Run Code Online (Sandbox Code Playgroud)

在上面的示例中,withAnimation参数设置为true,因此我希望此处设置的动画 ( forRevealFromBottomAndroid) 处于活动状态:

<Stack.Screen
        name="SomeScreen"
        component={SomeScreen}
        options={{
          headerLeft: null,
          headerShown: false,
          cardStyleInterpolator:
            CardStyleInterpolators.forRevealFromBottomAndroid,
        }}
      />
Run Code Online (Sandbox Code Playgroud)

animation reactjs react-native react-navigation

5
推荐指数
2
解决办法
6508
查看次数

android studio 模拟器:单击面板按钮会导致模拟器关闭

Android Studio 3.5
Build #AI-191.8026.42.35.5791312, built on August 9, 2019
JRE: 1.8.0_202-release-1483-b49-5587405 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-64-generic
Run Code Online (Sandbox Code Playgroud)

模拟器

我已经更新了我的 android studio,之后,当我单击模拟器左侧面板上的任何按钮时,或者甚至当我按下ctrl + M打开开发人员菜单时,模拟器会突然关闭。

到目前为止我测试过的(没有一个有效):

1. installing previous version of android studio
2. choosing another avd
3. choosing another system image (api 28)
4. uninstalling android studio and installing again
5. invalidate/resetting cache  
Run Code Online (Sandbox Code Playgroud)

更新:

当模拟器关闭时,我会在事件日志中看到以下内容:

2:47 PM Emulator: [26918:26918:0924/144702.703700:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

2:47 PM Emulator: Process finished …
Run Code Online (Sandbox Code Playgroud)

android android-virtual-device android-studio avd-manager

4
推荐指数
1
解决办法
2138
查看次数

在 Seaborn PairGrid 中使用 lmplot

我试图PairGrid在对角线上绘制使用密度估计,在上三角部分绘制散点图,在下三角部分绘制成对线性回归模型。这是我的数据文件:

df.head()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 这是我的代码:

g = sns.PairGrid(df, hue="quality bin")
g = g.map_upper(sns.scatterplot)
g = g.map_lower(sns.lmplot)
g = g.map_diag(sns.kdeplot)
g = g.add_legend()
Run Code Online (Sandbox Code Playgroud)

但是我收到这个错误:TypeError: lmplot() got an unexpected keyword argument 'label'

python matplotlib scatter-plot seaborn lmplot

3
推荐指数
1
解决办法
806
查看次数