小编smh*_*way的帖子

':'(冒号)在JavaScript中有什么作用?

我正在学习JavaScript,在浏览jQuery库时,我看到:(冒号)被大量使用.这在JavaScript中用于什么?

// Return an array of filtered elements (r)
// and the modified expression string (t)
   return { r: r, t: t };
Run Code Online (Sandbox Code Playgroud)

javascript

170
推荐指数
11
解决办法
13万
查看次数

什么是"|" (单管)用JavaScript做什么?

console.log(0.5 | 0); // 0
console.log(-1 | 0);  // -1
console.log(1 | 0);   // 1
Run Code Online (Sandbox Code Playgroud)

为什么0.5 | 0返回零,但任何整数(包括负数)都返回输入整数?单管("|")做什么?

javascript

138
推荐指数
4
解决办法
7万
查看次数

performFetchWithCompletionHandler永远不会被触发

1)我的plist配置提供backgroundmode:

<key>UIBackgroundModes</key>
<array>
    <string>fetch</string>
</array> 
Run Code Online (Sandbox Code Playgroud)

2)didFinishLaunchingWithOptions我有:

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:1.0];
Run Code Online (Sandbox Code Playgroud)

3)我UIApplicationDelegate在代表中宣布了协议.

4)我实现了以下方法,但它永远不会被触发.(仅当我使用"XCode-> Debug-> Simulate Background Fetch"模拟获取时才有效.)

-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
Run Code Online (Sandbox Code Playgroud)

为什么?这是DP5 beta错误吗?我应该雷达吗?

objective-c ios ios7

56
推荐指数
6
解决办法
4万
查看次数

Rails路由 - :on =>:集合

Rails的路由指南没有明确规定什么:on => :collection意思.

我无法找到:on关键是什么的解释,也不能解释:collection那个背景中的含义.

routing rails-routing ruby-on-rails-3

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

rails找不到database.yml

我刚刚删除了我,database.yml因为我正在尝试使用Mongoid,现在我得到以下内容:

$ rails server           
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application/configuration.rb:88:in `read': No such file or directory - /home/chris-kun/code/thirsty/config/database.yml (Errno::ENOENT)
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application/configuration.rb:88:in `database_configuration'
        from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
        from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
        from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/railtie.rb:57:in `block in <class:Railtie>'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `block in run_initializers'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:49:in …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails mongoid

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

逗号在JavaScript中的赋值语句中做了什么?

我在一段代码中找到了这个,我想知道它是做什么的?将b分配给x ...但是有什么用,c

var x = b, c;
Run Code Online (Sandbox Code Playgroud)

javascript

10
推荐指数
3
解决办法
336
查看次数

背景中的本地通知

任何人都可以告诉我如何让UILocalNotification我的应用程序在后台一段时间.

我在这里发布我的代码.提前致谢.

UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
    return;
localNotif.fireDate =[startDate addTimeInterval:60];
NSLog(@"%@",localNotif.fireDate);

localNotif.timeZone = [NSTimeZone defaultTimeZone];     
localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;

NSString *notifStr=[NSString stringWithFormat:@"Hey looks like you're meeting up with %@, why don't you let your other friends know what fun they're missing out on? Share a photo :)",[itemDict objectForKey:@"fname"]];

NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:notifStr ,@"notifKey",nil];
localNotif.userInfo = infoDict;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
Run Code Online (Sandbox Code Playgroud)

iphone notifications objective-c ios uilocalnotification

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

在django中添加一个变量来请求

在Django中,我想在请求中添加一个变量.即

def update_name(request):
    names = Employee.objects.filter()
    if names.count() > 0:
        request.update({"names": name })
    return render_to_response('chatlist/newchat.html',
        context_instance=RequestContext(request, {'form': form,'msg': msg}))
Run Code Online (Sandbox Code Playgroud)

这是向请求添加变量的正确方法吗?如果没有,我该怎么办?

另外,如何在模板页面中检索相同的值?即

alert ("{{request.names['somename']}}");
Run Code Online (Sandbox Code Playgroud)

python django django-templates django-models django-views

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

在rshd.c源代码中缺少pam_appl.h和pam_misc.h

我正在研究centOS 5.5操作系统.

它显示缺少/security/pam_appl.h和/security/misc.h文件的错误.

实际上我的rshd.c没有加载PAM模块,可能是通过放置这个库,它帮助我工作我的rshd罚款.这就是我发布这个问题的原因.

错误:-

rshd.c:90:31: error: security/pam_appl.h: No such file or directory
rshd.c:91:31: error: security/pam_misc.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我搜索了很多但没有获得任何有用的rpm来提供这些文件.

有些链接在这里.但不适合centOS.

帮我.告诉我如何克服这个问题.

编辑没有1

你的第三个链接似乎很有用 当我尝试安装pam-devel时,它会显示一些错误.

我跑的时候

./configure --prefix=/usr \
            --sysconfdir=/etc \
            --docdir=/usr/share/doc/Linux-PAM-1.1.6 \
            --disable-nis &&
make
Run Code Online (Sandbox Code Playgroud)

它检查一些变量,然后它生成目标文件,但最后显示,

make[3]: *** [pam_xauth.lo] Error 1
make[3]: Leaving directory `~/Linux-PAM-1.1.6/modules/pam_xauth'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `~/Linux-PAM-1.1.6/modules'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `~/Linux-PAM-1.1.6'
make: *** [all] Error 2
Run Code Online (Sandbox Code Playgroud)

编辑第2号

当我按照你的命令时,它会在最后显示错误.

我跑的时候出现了这个错误 make && …

c linux rsh centos pam

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

WebView不会在Android 2.x中滚动

我有WebView的问题.我在这个WebView中打开一个网页,它不会在Android 2.x中滚动,但它会在Android 3.x +中滚动.

任何想法我能做些什么来解决这个问题?

这是我用于此WebView的配置:

wView = (WebView) findViewById(R.id.webView1);
wView.getSettings().setJavaScriptEnabled(true);
wView.setHorizontalScrollBarEnabled(true);
Run Code Online (Sandbox Code Playgroud)

在布局中:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#00000000"
    tools:context=".MainActivity" 
    android:orientation="vertical">

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="horizontal" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

java android android-webview

8
推荐指数
2
解决办法
1157
查看次数