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) 我搜索了我的应用程序的目录,我找不到默认的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)
因此,在我看来,有一个控制器埋在某处处理请求的宝石中.
我已经看过好几次,但我无法弄清楚如何使用它们.镐说这些是特殊的快捷方式,但我无法找到语法描述.
我在这样的背景下见过他们:
[1,2,3].inject(:+)
Run Code Online (Sandbox Code Playgroud)
以计算总和为例.
在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()相同.Run Code Online (Sandbox Code Playgroud)var express = require('express'); var app = express(); app.listen(3000);express()返回的应用程序实际上是一个JavaScript函数,旨在作为回调处理请求传递给节点的HTTP服务器.这允许您轻松地为应用程序的HTTP和HTTPS版本提供相同的代码库,因为应用程序不会从这些继承(它只是一个回调):
Run Code Online (Sandbox Code Playgroud)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);app.listen()方法是以下的便捷方法(如果您希望使用HTTPS或同时提供两者,请使用上述技术):
Run Code Online (Sandbox Code Playgroud)app.listen = function(){ var server = http.createServer(this); return server.listen.apply(server, arguments); …
RWH突然开始使用runhaskell而不是runghc.有什么不同?据我所知,他们的工作方式相同.
我想用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) 我有以下行,曾经在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]?'
我怎样才能做到这一点?
这不起作用:
$ kivy --version
Python 2.7.6
Run Code Online (Sandbox Code Playgroud)
我已经Kivy.app安装了,它也没有提供任何版本信息.
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) 我关掉了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) haskell ×2
casting ×1
express ×1
ios ×1
ios8 ×1
kivy ×1
memory-leaks ×1
node.js ×1
objective-c ×1
postgresql ×1
ruby ×1
swift ×1