标签: local

udev .rules 文件以每个用户的本地身份运行?

我的代码会在每次 udev 检测到新 USB 时运行。

当我以本地用户身份运行它时,我的代码工作正常。

但是当我使用 udev.rules 文件时它失败了,因为它以 root 身份运行我的脚本。

如何以本地用户身份运行“.rules”?

linux rules local udev

5
推荐指数
0
解决办法
966
查看次数

OSX Swift webview加载本地文件

我知道这已经被问了很多次,我已阅读相当 一个 问题 ,并用Google搜索,但没有成功,到目前为止天。

我只想在桌面应用程序中加载一个本地 html 文件,事实是这个项目我需要一个 JS 库,其中大部分已经作为网页完成(css、js 和 html,不需要服务器端处理)。我不想强制应用程序从互联网服务器加载网页,以免强迫用户连接互联网。不用说,我在 Swift 和苹果开发方面完全没有经验。

现在这是我遇到的问题: 在此处输入图片说明 关于参数的 ide 抱怨,我似乎无法理解它们。

作为参考,这里是我最新代码的片段:

class AppDelegate: NSObject, NSApplicationDelegate
{
    @IBOutlet weak var window: NSWindow!
    @IBOutlet weak var webView: WebView!
    typealias NSSize = CGSize

    func applicationDidFinishLaunching(aNotification: NSNotification?)
    {
        self.window.title = "Chess Study Room"

        var try1 = "main.html";
        println(try1);

        var try2 = NSURL(string: try1)!;
        println(try2);

        var try3 =
        NSBundle.URLForResource("main", withExtension: "html", subdirectory: "web", inBundleWithURL: try2);
        println(try3);

        var try4 = NSBundle.pathForResource("main", ofType: "html", inDirectory: "web");
        println(try4);

        var …
Run Code Online (Sandbox Code Playgroud)

macos local webview swift

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

select2 使用查询词过滤本地 JSON 数据结果

我正在实施 select2 版本 3.5.0。我在我的文档就绪函数中使用了以下 jQuery:

jQuery.getJSON('/rest/call/to/retrieve/JSON').done(
  function( data ) {
     jQuery('#byProductName').select2({
         placeholder: 'Type any portion of a single product name...',
         allowClear: true,
         minimumInputLength: 0,
         multiple: true,
         id: function(data){ return data.product; },
         data: data,
         formatResult: function(data){ return data.product; },
         formatSelection: function(data){ return data.product; },
     });
  }
);
Run Code Online (Sandbox Code Playgroud)

HTML 隐藏输入元素:

<div id='freeForm'>
    <input name='Search Products' type='hidden' id='byProductName'>
</div>
Run Code Online (Sandbox Code Playgroud)

JSON 结果:

[{"product":""},{"product":" windows"},{"product":" mac"},
 {"product":" linux"},{"product":" RHEL"},{"product":"Test product list"}]
Run Code Online (Sandbox Code Playgroud)

下拉列表正确填充了我的值,我可以选择多个项目并成功删除它们。但是,当我在输入字段中键入字符串以过滤结果集时,它不会进行过滤。

我尝试将数据更改为:

data: function (data, term){
    return { 
        results: data,
        query: term }
    }, …
Run Code Online (Sandbox Code Playgroud)

json local filter jquery-select2

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

为什么不能在本地类中声明成员接口?

您不能在像下面这样的块内声明接口

public void greetInEnglish() {

        interface HelloThere {
           public void greet();
        }

        class EnglishHelloThere implements HelloThere {
            public void greet() {
                System.out.println("Hello " + name);
            }
        }

        HelloThere myGreeting = new EnglishHelloThere();
        myGreeting.greet();
}
Run Code Online (Sandbox Code Playgroud)

本 Oracle 教程中,我得到了“您不能在本地类中声明成员接口”。因为“接口本质上是静态的”。

我渴望用更合理的信息来理解这一点,为什么界面本质上是静态的?

为什么上面的代码没有意义?

提前感谢您的介绍!

java oop interface class local

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

Webdriver 从本地存储中获取项目

我正在尝试使用 Selenium Webdriver 从本地存储中获取一个项目。

我关注了这个网站,但是当我运行我的代码时,我得到了NullPointerException.

当我调试代码时,我看到了函数:getItemFromLocalStorage 由于某种原因返回 NULL。

这是我的代码:

public class storage
 {
    public static WebDriver driver;
    public static JavascriptExecutor js;

    public static void main(String[] args)
    {       
        System.setProperty("webdriver.chrome.driver", "D://chromedriver.exe");
        driver = new ChromeDriver();
        driver.get("http://html5demos.com/storage");
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.id("local")).sendKeys("myLocal");
        driver.findElement(By.id("session")).sendKeys("mySession");
        driver.findElement(By.tagName("code")).click(); // just to escape textbox

        String sItem = getItemFromLocalStorage("value");
        System.out.println(sItem);
    }

    public static String getItemFromLocalStorage(String key)
    {
        return (String) js.executeScript(String.format(
            "return window.localStorage.getItem('%s');", key));
    }
}
Run Code Online (Sandbox Code Playgroud)

java selenium storage local selenium-webdriver

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

为什么函数内的这个 DataFrame 修改会改变全局外函数?

为什么下面的函数会改变全局DataFrame命名df?它不应该只更改df函数内的局部变量,而不是全局变量df吗?

import pandas as pd

df = pd.DataFrame()

def adding_var_inside_function(df):
    df['value'] = 0

print(df.columns) # Index([], dtype='object')
adding_var_inside_function(df)
print(df.columns) # Index([u'value'], dtype='object')
Run Code Online (Sandbox Code Playgroud)

python global local pandas

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

无法使用 React 加载本地视频

我无法使用 React 加载本地视频。我已将视频放在我的文件夹“app/assets/video/concert.mp4”中。在我的 React 文件“search_bar.jsx”中,我有一个 HTML5 视频标签,我将视频来源为:

render(){ return (<video src="../../app/assets/videos/concert.mp4" controls />); }

这是我的文件结构:

  • 音乐家中心
    • 应用程序
      • 资产
        • 视频
          • 演唱会.mp4
    • 前端
      • 成分
        • search_bar.jsx

如果您加载外部视频,则视频标签有效。这是我的 webpack.config.js

 module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel',
        query: {
          presets: ['react', 'es2015']
        }
      },
      {
      test: /\.html$/,
      loader: 'html-loader?attrs[]=video:src'
    }, {
      test: /\.mp4$/,
      loader: 'url?limit=10000&mimetype=video/mp4'
    }
    ]
  }
Run Code Online (Sandbox Code Playgroud)

path local html5-video reactjs

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

如何在Android中获取当前语言?

在我的 Android 手机语言设置中,我将语言设置为English(United Kingdowm)

我使用以下代码来获取语言:

Log.d(TAG,"getDisplayLanguage = " + Locale.getDefault().getDisplayLanguage());
Log.d(TAG,"getLanguage = " + Locale.getDefault().getLanguage());
Log.d(TAG,"Resources.getLanguage = " + Resources.getSystem().getConfiguration().locale.getLanguage());
Log.d(TAG,"getResources.getLanguage = " + getResources().getConfiguration().locale);
Run Code Online (Sandbox Code Playgroud)

日志显示如下:

getDisplayLanguage = English
getLanguage = en
Resources.getLanguage = en
getResources.getLanguage = en_GB
Run Code Online (Sandbox Code Playgroud)

它没有显示Local.UK

我错过了什么吗?

android local

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

将 phpMyAdmin docker 镜像连接到仅在 127.0.0.1 上侦听的 HOST MySQL 服务器

我希望将在容器 (Docker) 中运行的 PhpMyAdmin 连接到在主机上运行并在 127.0.0.1 上侦听的 MySQL 服务器。

但是,当我为 docker 提供 varuable -e PMA_HOST=127.0.0.1 时,它只会查看它自己的 Docker 网络......我如何才能与我的主机 MySQL DB 服务器通信?

mysql networking local phpmyadmin docker

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

本地 javascript 网站 (file:///) 混淆了 Chrome、Edge 上的通知权限

我正在为我工​​作的呼叫中心构建一个配套网站/应用程序,它可以做很多方便的事情,包括跟踪休息时间,这就是我遇到问题的地方。

这个“站点”将作为 html 文件存储在用户的计算机上(出于安全原因,我无法将它托管在其他地方),这似乎是问题的核心,因为我正在尝试启用桌面警报。

这是我用于请求通知权限的内容:

    document.addEventListener('DOMContentLoaded', function () {
  if (!Notification) {
    alert('Desktop notifications not available in this browser.');
    return;
  }
  if (Notification.permission !== "granted")
    Notification.requestPermission();
});

function notifyMe() {
  if (Notification.permission !== "granted")
    Notification.requestPermission();
 else {
    var notification = new Notification('Notification title', {
      body: "Notification",
    });
  }
}    
Run Code Online (Sandbox Code Playgroud)

...这是我在另一个线程中找到的。

问题是,作为本地文件,Chrome 永远不会承认它具有权限:我可以单击“批准”或“阻止”,但没有任何反应。如果我手动将“file:///*”添加到 Chrome 允许的站点,它将收到通知(但是,如果我手动添加整个本地地址,则不会)。Edge 会将“文件:”添加到其批准的列表中,但这不起作用且无法编辑。

我可能只是不走运,因为我想通过单击按钮在 Chrome 中获得批准来获得通知(并且它们在 Edge 中根本不起作用)。

有没有办法指定您希望浏览器添加到批准列表中的地址?我可以看到这样做会带来许多潜在的安全问题,但这可能是唯一可以解决此问题的方法。

提前致谢!

javascript browser permissions notifications local

5
推荐指数
0
解决办法
192
查看次数