小编Mat*_*iby的帖子

如何在cmd批处理文件中运行另一个命令?

我有这个命令,我需要运行

cd /d C:\leads\ssh & C:\Windows\System32\cmd.exe /E:ON /K C:\Ruby192\bin\setrbvars.bat 
Run Code Online (Sandbox Code Playgroud)

这将打开命令提示符

但我需要在提示符中运行此命令

ruby C:\lead\leads.rb
Run Code Online (Sandbox Code Playgroud)

这将触发脚本.....但我不知道要添加到我的bat文件中要执行此操作

我尝试了-f标志告诉它运行命令,但没有去....任何想法,以使该运行

cd /d C:\leads\ssh & C:\Windows\System32\cmd.exe /E:ON /K C:\Ruby192\bin\setrbvars.bat -f ruby C:\lead\leads.rb
pause
Run Code Online (Sandbox Code Playgroud)

windows cmd batch-file

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

如何检查是否定义了prettyPhoto

我有这个片段在我的整个网站使用的主js文件上

$("a[rel^='prettyPhoto']").prettyPhoto({
        theme: 'light_square',
        showTitle: false,
        allow_resize: true
    });
Run Code Online (Sandbox Code Playgroud)

问题是,在某些页面上,prettyPhoto未定义并导致firebug出错,所以我想我会尝试这个

if(typeof prettyPhoto=="undefined"){
    //do nothing
}else{
    $("a[rel^='prettyPhoto']").prettyPhoto({
        theme: 'light_square',
        showTitle: false,
        allow_resize: true
    });
}
Run Code Online (Sandbox Code Playgroud)

但这总是执行为true,即使在prettyPhoto可用的页面上......任何想法

jquery jquery-plugins prettyphoto

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

jQuery变量范围超过函数调用?

我有这个功能

function update_prices(product_selector){
    //kind of a hack to account for the sometimes having a professional price and sometimes not
    var price_count = product_selector.find('small.rt').length;
    for (i=0;i<=price_count;i++)
    {
        if(i == 0){
            var standard_selector = product_selector.find('small.rt:eq('+ i +')');
            var standard_price = standard_selector.attr('data');
        }
        if(i == 1){
            var business_selector = product_selector.find('small.rt:eq('+ i +')');
            var business_price = business_selector.attr('data');
        }
        if(i == 2){
            var professional_selector = product_selector.find('small.rt:eq('+ i +')');
            var professional_price = professional_selector.attr('data');
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我有这个称之为的代码块

....
....
product_selector.find(".active_selector").removeClass('active_selector');
update_prices(product_selector);
....
....

standard_selector.text("something");
business_selector.text("something else"); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery scope

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

为什么.change不能用于IE8

好的,我有一个jQuery .change

$('#application').change(function(){
var selected = $(this).val().trim();
alert(selected);
if(selected == 'something') {
  $('#profile-info').show();
}
....
....
Run Code Online (Sandbox Code Playgroud)

我的HTML

<select name="application" id="application">
<option value="--select something--">--select something--</option>
<option value="first">first</option>
<option value="second">second</option>
<option value="third">third</option></select>
Run Code Online (Sandbox Code Playgroud)

警报会在所有浏览器上触发,但IE ..... ie8和7根本不起作用

任何想法我可能会失踪

javascript jquery internet-explorer

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

如何比较Ruby数组和哈希的内容?

我有一个Ruby数组,其内容如下:

my_array
=> ["MPA5534285", "MPA5534555", "MPA553asdf5", "MPA553asdasdfasdfaf5"]
Run Code Online (Sandbox Code Playgroud)

我有一个像这样的Ruby哈希:

1.9.2p290 :012 > hash
 => {"MPA5534555"=>"something", "MPA553sf"=>"something", "MPA55345asdf5adfads"=>"something", "MPA553asdasdfasdfaf5"=>"something"} 
Run Code Online (Sandbox Code Playgroud)

我需要将数组与散列进行比较,找到没有相应匹配的位置.

例如,在我的数组中,我有"MPA5534555",如果我查看哈希,密钥确实存在.但是,在数组"MPA5534285"中没有哈希键.

我想要一个只有散列中没有键的数组.

ruby arrays hash ruby-on-rails-3

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

我可以强调一个网址路径

我想动态设置一个url路径

  - application_path = @object.class.name.underscore + "_path"
  = link_to "<input type='button' value='Cancel' class ='bigbutton go_back'/>".html_safe, application_path(@application)
Run Code Online (Sandbox Code Playgroud)

但我一直在

 undefined method `application_path' for #<#<Class:0x00000103d11d80>:0x00000103d04a68>
Run Code Online (Sandbox Code Playgroud)

关于如何实现这种行为的任何想法

ruby ruby-on-rails polymorphic-associations ruby-on-rails-3

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

为什么我不能从网址中获取json对象

我有这个网址,它带回了雅虎的时间......我猜这个PST

所以我需要用javascript获取这个值...这是我的代码

$j.ajax({
    type: "GET",
    url: "http://developer.yahooapis.com/TimeService/V1/getTime?appid=YahooDemo&output=json",
    dataType: "jsonp",
    complete: function(data){
      console.log(data);
      }
  });
Run Code Online (Sandbox Code Playgroud)

但我似乎无法将时间戳从json中拉出来......我做错了什么

javascript jquery json web-services

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

有没有办法做一个http头请求,并获得没有服务器端语言的时间

好的,所以我试图从Javascript代码做一个http头请求,以获得服务器时间...我可以从JavaScript执行此操作或我需要一个服务器端语言来实现这一点

javascript jquery curl

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

如何在C#中的一个函数中传回一个字符串和一个布尔值?

所以我有这个功能

    public bool FileExists(string path, string filename)
    {
        string fullPath = Path.Combine(path, "pool");
        string[] results = System.IO.Directory.GetFiles(fullPath, filename, SearchOption.AllDirectories);
       return (results.Length == 0 ?  false : true);
    }
Run Code Online (Sandbox Code Playgroud)

它是否在目录及其所有子目录中找到文件返回true或false ...但我想传递字符串位置

这是我怎么称呼它

            if (FileExists(location, attr.link))
            {
                FileInfo f = new FileInfo("string the file was found");
Run Code Online (Sandbox Code Playgroud)

关于如何实现这一点的任何想法?也许改成列表或数组......任何想法

c# arrays list

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

如何在rails中找到左连接

我有这个

User.joins(:notifications).joins(:company_users).joins(:role_users).where("notifications.id = ? AND role_users.role_id != '1' AND (company_users.company_id = ? OR users.company_id = ?)", notification.id, p.company_id, p.company_id)
Run Code Online (Sandbox Code Playgroud)

=> []

哪个产生这个sql

SELECT `users`.* FROM `users` 
INNER JOIN `subscriptions` ON `users`.`id` = `subscriptions`.`user_id` 
INNER JOIN `notifications` ON `notifications`.`id` = `subscriptions`.`notification_id` 
INNER JOIN `company_users` ON `company_users`.`user_id` = `users`.`id` 
INNER JOIN `role_users` ON `role_users`.`user_id` = `users`.`id` 
WHERE (notifications.id = 1 
AND role_users.role_id != '1' 
AND (company_users.compcany_id = 67 OR users.company_id = 67))
Run Code Online (Sandbox Code Playgroud)

问题是我需要继续加入company_users并且不确定如何在rails中实现

我知道我可以用find_by_sql做到这一点,我听说这不是真的像......任何想法

ruby join ruby-on-rails ruby-on-rails-3

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