小编7st*_*tud的帖子

fe_sendauth:没有提供密码

database.yml的:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: postgresql
  encoding: utf8
  database: sampleapp_dev  #can be anything unique
  #host: localhost
  #username: 7stud
  #password: 

  #adapter: sqlite3
  #database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development …
Run Code Online (Sandbox Code Playgroud)

postgresql ruby-on-rails-4

63
推荐指数
3
解决办法
18万
查看次数

我的应用程序中默认的"欢迎登机"页面在哪里?

我搜索了我的应用程序的目录,我找不到默认的rails Welcome Aboard页面的html页面.我也找不到routes.rb中默认Welcome Aboard页面的路由.我的rails应用程序如何路由http://localhost:3000/到我的应用程序中不存在的页面?

rails服务器生成以下信息:

Started GET "/" for 127.0.0.1 at 2013-07-31 02:00:13 -0600
Processing by Rails::WelcomeController#index as HTML
  Rendered /Users/7stud/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/templates/rails/welcome/index.html.erb (0.1ms)
Completed 200 OK in 3ms (Views: 2.5ms | ActiveRecord: 0.0ms)
Run Code Online (Sandbox Code Playgroud)

因此,在我看来,有一个控制器埋在某处处理请求的宝石中.

ruby-on-rails ruby-on-rails-4

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

什么是:+和&:+在Ruby中?

我已经看过好几次,但我无法弄清楚如何使用它们.镐说这些是特殊的快捷方式,但我无法找到语法描述.

我在这样的背景下见过他们:

[1,2,3].inject(:+)
Run Code Online (Sandbox Code Playgroud)

以计算总和为例.

ruby

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

http.createServer(app)v.http.Server(app)

在socket.io网页上Get Started: Chat application,位于:

http://socket.io/get-started/chat/

有这个代码:

var app = require('express')();
var http = require('http').Server(app);
Run Code Online (Sandbox Code Playgroud)

可以像这样更清楚地重写:

var express = require('express');
var http = require('http');

var app = express();
var server = http.Server(app);
Run Code Online (Sandbox Code Playgroud)

socket.io示例使用http.Server()来创建服务器.然而,app.listen()的快速文档显示了使用http.createServer(app)以下命令创建服务器的示例:

app.listen()
绑定并侦听给定主机和端口上的连接.此方法与节点的http.Server#listen()相同.

var express = require('express');  
var app = express();  
app.listen(3000);
Run Code Online (Sandbox Code Playgroud)

express()返回的应用程序实际上是一个JavaScript函数,旨在作为回调处理请求传递给节点的HTTP服务器.这允许您轻松地为应用程序的HTTP和HTTPS版本提供相同的代码库,因为应用程序不会从这些继承(它只是一个回调):

var express = require('express');
var https = require('https');
var http = require('http');
var app = express();

http.createServer(app).listen(80);
https.createServer(options, app).listen(443);
Run Code Online (Sandbox Code Playgroud)

app.listen()方法是以下的便捷方法(如果您希望使用HTTPS或同时提供两者,请使用上述技术):

app.listen = function(){
  var server = http.createServer(this);
  return server.listen.apply(server, arguments); …
Run Code Online (Sandbox Code Playgroud)

node.js express

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

runghc和runhaskell有什么区别?

RWH突然开始使用runhaskell而不是runghc.有什么不同?据我所知,他们的工作方式相同.

haskell

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

使用cabal在Mac OSX上安装text-icu

我想用haskell尝试unicode,而Data.Text文档说我需要text-icu.这是我试过的:

Mac OS X 10.6.8

~/haskell_programs$ cabal update
Downloading the latest package list from hackage.haskell.org

~/haskell_programs$ cabal install text-icu
Resolving dependencies...
Downloading text-icu-0.6.3.5...
Configuring text-icu-0.6.3.5...
cabal: Missing dependencies on foreign libraries:
* Missing C libraries: icui18n, icudata, icuuc
This problem can usually be solved by installing the system packages that
provide these libraries (you may need the "-dev" versions). If the libraries
are already installed but in a non-standard location then you can use the
flags --extra-include-dirs= and --extra-lib-dirs= to …
Run Code Online (Sandbox Code Playgroud)

haskell

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

在Swift中将[NSObject,AnyObject]转换为[String,AnyObject]

我有以下行,曾经在Swift的iOS 8中工作.

 let placemark = placemarks![0] as? CLPlacemark

 let destinationPlacemark = MKPlacemark(

     coordinate: placemark!.location!.coordinate, 
     addressDictionary: placemark?.addressDictionary

 )
Run Code Online (Sandbox Code Playgroud)

但现在它给了我以下例外:

无法转换'[NSObject:AnyObject]类型的值?' 预期的参数类型'[String:AnyObject]?'

我怎样才能做到这一点?

casting ios swift

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

你如何验证/检查kivy版本?

这不起作用:

$ kivy --version
Python 2.7.6
Run Code Online (Sandbox Code Playgroud)

我已经Kivy.app安装了,它也没有提供任何版本信息.

kivy

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

config.active_record.default_timezone =:local ...似乎没有任何效果

active_record.default_timezone的配置似乎不像宣传的那样工作.我预计在设定之后:

 config.active_record.default_timezone = :local
Run Code Online (Sandbox Code Playgroud)

(在config/application.rb中)从数据库中检索的时间将转换为本地时区,即它将显示相同的偏移量,例如"+0200",作为本地时间.

config.active_record.default_timezone确定在从数据库中提取日期和时间时是否使用Time.local(如果设置为:local)或Time.utc(如果设置为:utc)... http://guides.rubyonrails.org /configuring.html

2.0.0p247 :016 > user = User.new name: "Tom", email: "tom@gmail.com"
 => #<User id: nil, name: "Tom", email: "tom@gmail.com", created_at: nil, updated_at: nil> 

2.0.0p247 :017 > user.save   
(0.3ms)  SAVEPOINT active_record_1
  SQL (0.8ms)  INSERT INTO "users" ("created_at", "email", "name", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["created_at", Sun, 08 Sep 2013 23:38:22 UTC +00:00], ["email", "tom@gmail.com"], ["name", "Tom"], ["updated_at", Sun, 08 Sep 2013 23:38:22 UTC +00:00]]
   (0.7ms)  RELEASE SAVEPOINT active_record_1
 => true …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails-4

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

为什么没有内存泄漏:@property(copy)NSString*name,当我不在dealloc中释放它时?

我关掉了ARC.

我在这样声明的类中有一个属性:

@property(copy) NSString* name
Run Code Online (Sandbox Code Playgroud)

name用常量字符串设置:

[greeter setName:@"Jane"];
Run Code Online (Sandbox Code Playgroud)

dealloc为我的班级实现了这样的:

-(void)dealloc{
    [super dealloc];
}
Run Code Online (Sandbox Code Playgroud)

我预计会有内存泄漏,因为我没有发布name.我正在使用Xcode 6.2并且Product>Analyze没有识别任何泄漏,仪器也没有:Product>Profile, choose Leaks, hit the red Record button.

这是相关代码:

//
//  Greeter.h
//  Flashlight2
//

#import <Foundation/Foundation.h>

@interface Greeter : NSObject

@property(copy) NSString* name; 

-(NSString*)description;
-(void)dealloc;


@end
Run Code Online (Sandbox Code Playgroud)

....

//
//  Greeter.m
//  Flashlight2
//

#import "Greeter.h"

@implementation Greeter


-(NSString*)description {
    NSString* msg = [[NSString alloc] initWithString:@"I am a Greeter"];
    return [msg autorelease];
}

-(void)dealloc{
    [super dealloc]; …
Run Code Online (Sandbox Code Playgroud)

memory-leaks objective-c ios8

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