小编Joe*_*ano的帖子

IDE0006警告和许多其他新的Cross Platform Xamarin应用程序,全新安装Visual Studio

我刚刚在运行Windows 10的PC上安装了Visual Studio 2017,并创建了一个名为"trial"的Cross Platform Xamarin应用程序(Blank和PLC).马上,错误框中出现以下警告:

IDE0006 - Error encountered while loading the project. Some project pfeatures, such as full solution alaysisis for the failed project and projects that depend on it, have been disabled.

To see what caused the issue, please try below.

1. Close Visual Studio
2. Open a Visual Studio Developer Command Prompt
3. Set environment variable "TraceDesignTime" to true (set TraceDesignTime=true)
4. Delete .vs directory/.suo file
5. Restart VS from the command prompt you set the …
Run Code Online (Sandbox Code Playgroud)

visual-studio xamarin.android xamarin xamarin.forms visual-studio-2017

8
推荐指数
1
解决办法
1092
查看次数

在Windows 10机器上运行的应用程序无法找到文件

我在Linux机器上有一个使用chromedriver的应用程序,我将应用程序切换到Windows 10机器.现在突然它告诉我它找不到chromedriver文件.

这是错误:

Selenium::WebDriver::Error::WebDriverError in Static#home
Showing C:/Users/User/Documents/test_app/app/views/static/home.html.erb where line #4 raised:

    Unable to find chromedriver. Please download the server from        http://chromedriver.storage.googleapis.com/index.html and place it        somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.
Run Code Online (Sandbox Code Playgroud)

我将chromedriver文件放在我的Linux机器上的相同位置,就在应用程序的主文件夹中.在这种情况下,路径是C:\Users\User\Document\test_app.Windows解释路径的方式与Linux不同吗?

chromedriver是最新版本.它的标题是"chromedriver_win32.zip"."胜利"意味着Windows."32"是否意味着它适用于32位系统?我的机器是64位的.

windows selenium ruby-on-rails webdriver selenium-chromedriver

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

TypeError:$(...).selectize不是一个函数

我在我的rails应用程序中安装了"selectize-rails"gem,我正试图让它工作.我一直在我的Web控制台中收到此错误:

TypeError: $(...).selectize is not a function
Run Code Online (Sandbox Code Playgroud)

并且浏览器中没有任何反应.这是我到目前为止的代码,遵循此页面中的"电子邮件联系人"示例:http://brianreavis.github.io/selectize.js/


意见/电子邮件/ new.html.erb

<script type="text/javascript">


  $(document).ready(function() {
    console.log( typeof $.fn.selectize === 'function'); // true
    console.log( $('#select-to').length === 1 ); // true

    var REGEX_EMAIL = '([a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@' + '(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)';

    $('#select-to').selectize({
      persist: false,
      maxItems: null,
      valueField: 'email',
      labelField: 'name',
      searchField: ['name', 'email'],
      options: [ 
        {email: 'brian@thirdroute.com', name: 'Brian Reavis'},
        {email: 'nikola@tesla.com', name: 'Nikola Tesla'},
        {email: 'someone@gmail.com'}
      ],
      render: {
        item: function(item, escape) {
          return '<div>' +
            (item.name ? '<span class="name">' + escape(item.name) + …
Run Code Online (Sandbox Code Playgroud)

javascript gem jquery ruby-on-rails selectize.js

6
推荐指数
1
解决办法
6927
查看次数

如何在执行操作之前让Selenium/Ruby bot等待?

我正在构建一个点击元素的Selenium/Ruby Web机器人.问题是,在僵尸程序决定无法找到该元素之前,有时没有足够的时间来加载页面.

在执行操作之前,让Selenium等待的Ruby方法是什么?我更喜欢明确的等待,但我也很好地隐瞒等待.


我试着用这个wait.until方法:

require "selenium-webdriver"
require "nokogiri"
driver = Selenium::WebDriver.for :chrome
wait = Selenium::WebDriver::Wait.new(:timeout => 15)
driver.navigate.to "http://google.com"
driver.wait.until.find_element(:class, "gb_P").click
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

Undefined method 'wait' for <Selenium::WebDriver>
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

require "watir-webdriver/wait"
...
driver.find_element(:class, "gb_P").wait_until.click
Run Code Online (Sandbox Code Playgroud)

但这也给了我一个未定义的方法错误:

undefined method `when_present' for #<Selenium::WebDriver...>
Run Code Online (Sandbox Code Playgroud)

ruby selenium bots webdriver selenium-webdriver

6
推荐指数
3
解决办法
9875
查看次数

Git push错误:目标文件为空/松散对象已损坏

我试图使用Git Gui执行git提交.我上演了几个文件,然后由于电量不足,我的电脑突然关闭了.我将其插入,重新打开,并提交了我想要的文件.然后我跑了git push,就像我之前做了一百万次没有任何问题,这次我得到以下错误:

Counting objects: 8, done.
error: object file .git/objects/b5/60c934f6bad40f4f246973afc0139ed91a2d32 is empty
Compressing objects: 100% (4/4), done.
error: object file .git/objects/b5/60c934f6bad40f4f246973afc0139ed91a2d32 is empty
fatal: loose object b560c934f6bad40f4f246973afc0139ed91a2d32 (stored in .git/objects/b5/60c934f6bad40f4f246973afc0139ed91a2d32) is corrupt
error: failed to push some refs to 'git@bitbucket.org:joemorano/app.git'
Run Code Online (Sandbox Code Playgroud)

这可能是由于计算机在我执行第一次提交之前关闭了吗?

在所有这一切发生之前,我显然通过bundle install在我的服务器上以root身份运行来破坏我的应用程序的生产版本,现在服务器上的所有内容都搞砸了,但我不知道这会如何影响本地版本.我从未做过git pull或类似的事情.

有没有人遇到此错误?

git

6
推荐指数
2
解决办法
1万
查看次数

Facebook身份验证数据返回nil,但名称和电子邮件除外

我使用Devise gem为我的应用程序设置用户模型.我正在尝试使用Omniauth进行Facebook身份验证.我可以检索NameEmail数据,但我无法获取任何其他public_profile数据.在这个例子中,我试图得到Gender,但其他数据都没有.当我访问此路径时:user_omniauth_authorize_path(:facebook),调用"controllers/registrations_controller.rb"中的"facebook"操作.但是对于创建的用户user.gender,以及除姓名和电子邮件之外的所有其他数据,都会返回零.

配置/初始化/ devise.rb

config.omniauth :facebook, "<ID>", "<SECRET>", scope: 'email', display: 'popup', info_fields: 'email,name,gender'
Run Code Online (Sandbox Code Playgroud)

应用程序/模型/ devise.rb

  devise :omniauthable, :omniauth_providers => [:facebook]
  def self.from_omniauth(auth)
    where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
      user.gender = auth.extra.raw_info.gender.to_s
    end
  end
Run Code Online (Sandbox Code Playgroud)

应用程序/控制器/ registrations_controller.rb

  def facebook
    @user = User.from_omniauth(request.env["omniauth.auth"])

    if @user.persisted?
      sign_in_and_redirect @user, :event => :authentication
      set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
    else
      session["devise.facebook_data"] = request.env["omniauth.auth"]
      redirect_to new_user_registration_url
    end
  end
Run Code Online (Sandbox Code Playgroud)

的Gemfile

gem 'devise'
gem 'omniauth-facebook'
Run Code Online (Sandbox Code Playgroud)

奇怪的是我甚至无法获得数据的类类型.Name …

facebook ruby-on-rails devise omniauth omniauth-facebook

6
推荐指数
1
解决办法
294
查看次数

如何在Xamarin.forms xaml中水平显示ListView中的项目?

我在a中显示了一个SQLite对象列表ListView,但我想让它们水平显示.所以不是这样的:

| longitem        |
| item            |
| evenlongeritem  |
| item            |
| longeritem      |
Run Code Online (Sandbox Code Playgroud)

我要这个:

| longitem item   |
| evenlongeritem  |
| item longeritem |
Run Code Online (Sandbox Code Playgroud)

重要的是,这些项目的宽度可以不同,因此只需将列表分成一定数量的列就可以得到改进,但并不理想.我也不知道物品的数量.

这是我目前的代码:

<ListView x:Name="inactiveList" VerticalOptions="Start" ItemTapped="PutBack">
    <ListView.ItemTemplate>
        <DataTemplate>
            <TextCell Text="{Binding Name}" TextColor="Black">
                  <TextCell.ContextActions>
                         <MenuItem Command="{Binding Source={x:Reference ListPage}, Path=DeleteListItem}" CommandParameter="{Binding .}" Text="delete" />
                  </TextCell.ContextActions>
              </TextCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud)

代码背后:

public ListPage()
{
    InitializeComponent();

    ObservableCollection<ListItem> activeItems =
        new ObservableCollection<ListItem>(
            App.ListItemRepo.GetActiveListItems());
    activeList.ItemsSource = activeItems;
    ...
Run Code Online (Sandbox Code Playgroud)

我尝试将其包裹ViewCell在横向StackLayout,但我收到此错误:

未处理的异常:System.InvalidCastException:指定的强制转换无效.

我不确定那个错误意味着什么,但我认为不可能在StackLayout …

c# xaml listview xamarin xamarin.forms

6
推荐指数
1
解决办法
1776
查看次数

iOS PWA 是否有与蓝牙设备通信的解决方法?

因此,iOS 不支持渐进式 Web 应用程序对蓝牙的本机访问。有什么解决方法吗?Youtube.com 绝对可以从蓝牙扬声器播放声音,因此在某种程度上是可能的。Safari 网站是否仍然可以以某种方式随意与蓝牙设备通话?

safari bluetooth ios bluetooth-lowenergy progressive-web-apps

6
推荐指数
2
解决办法
5085
查看次数

无法从获取请求中获取“Access-Control-Allow-Origin”标头

我正在 React 中构建一个 Chrome 扩展,该扩展连接到后端的 Rails 6 应用程序。我希望 Rails 应用程序充当 API 并存储来自扩展程序的数据,但我无法让它接受来自我的扩展程序的请求。

这是我的扩展中的获取代码:

    fetch('https://www.myapp.com/api/post_comment/test', {
     method: 'get',
     headers: {'Content-Type':'application/json'}
    });
Run Code Online (Sandbox Code Playgroud)

这是我在 js 控制台中不断遇到的错误:

从源“http://localhost:3000”获取“https://www.myapp.com/api/test”的访问已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:否请求的资源上存在“Access-Control-Allow-Origin”标头。如果不透明响应满足您的需求,请将请求模式设置为“no-cors”以在禁用 CORS 的情况下获取资源。

“https://www.myapp.com/api/test”的 FetchEvent 导致网络错误响应:将不是 Response 的对象传递给 respondWith()。

我尝试将rack-cors gem 添加到我的 Rails 应用程序中:

#Gemfile:

gem 'rack-cors'

#config/initializers/cors.rb:

Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins '*'
    resource '/api/*', headers: :any, methods: [:get, :post, :patch, :put]
  end
end
Run Code Online (Sandbox Code Playgroud)

我还尝试在 Rails 应用程序控制器中手动添加标头:

before_action :cors_preflight_check
after_action :cors_set_access_control_headers


def cors_set_access_control_headers
    headers['Access-Control-Allow-Origin'] = '*'
    headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails google-chrome-extension cors fetch-api

6
推荐指数
1
解决办法
6292
查看次数

如何使用 Active Storage 保留存储空间和加载时间?

我有一个包含图像的用户提交表单。最初我使用的是 Carrierwave,但是在将图像保存到谷歌云服务之前,首先将图像发送到我的服务器进行处理,如果图像/s 太大,请求超时,用户只需获取服务器错误。

所以我需要的是一种直接上传到 GCS 的方法。Active Storage 似乎是完美的解决方案,但我对压缩的难度感到非常困惑。

一个理想的解决方案是在上传时自动调整图像大小,但似乎没有办法做到这一点。

一个次优的解决方案是创建一个调整大小的变种在使用类似的上传@record.images.first.variant(resize_to_limit [xxx,xxx]) #using image_processing gem,但该文档似乎暗示着变体只能在网页加载时被创建,这显然是极其不利的加载时间,尤其是如果有很多图片。对此的更多证据是,当我创建一个变体时,它不在我的 GCS 存储桶中,因此它显然只存在于我的服务器的内存中。如果我尝试

@record.images.first.variant(resize_to_limit [xxx,xxx]).service_url

我得到一个网址,但它无效。当我尝试在我的网站上显示图像时,我得到一个失败的图像,当我访问 url 时,我从 GCS 收到以下错误:

指定的键不存在。没有这样的对象。

所以显然我不能创建一个永久的网址。

一个第三个最好的解决办法是写一个谷歌的云功能,可自动调整大小,谷歌云中的图像,而是通过阅读文档,看来我不得不创建一个新的URL的新调整大小的文件,我不知道我如何用我的数据库中的新网址替换原始网址。

总而言之,我想要完成的是允许直接上传到 GCS,但在用户下载文件之前控制文件的大小。我对 Active Storage 的问题是 (1) 我无法控制 GCS 存储桶上文件的大小,导致任意存储成本,以及 (2) 我显然必须在用户必须下载任意大文件之间进行选择,或者必须在页面加载时处理图像,这两者在服务器成本和加载时间方面都非常昂贵。

以这种方式设置 Active Storage 似乎非常奇怪,我不禁觉得我错过了一些东西。有谁知道解决这两个问题的方法?

file-upload ruby-on-rails google-cloud-storage google-cloud-functions rails-activestorage

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