我的Rails开发环境是基于Windows的,我的生产环境是基于Linux的.
VirtualHost可能会被使用.假设需要在/public文件夹中引用一个文件名File.open('/tmp/abc.txt', 'r').
- 但在Windows中它应该是C:\tmp\abc.txt.如何进行正确的路径连接以处理两种不同的环境?
prefix_tmp_path = '/tmp/'
filename = "/#{rand(10)}.txt"
fullname = prefix_tmp_path + filename # /tmp//1.txt <- but I don't want a double //
Run Code Online (Sandbox Code Playgroud)
当prefix_tmp_path = "C:\tmp\"我得到C:\tmp\/1.txt
处理这两种情况的正确方法是什么?
我必须在我的Android应用程序中解析一些复杂的xml文件.像TouchXMl for iPhone那样有没有好的库?
Vim是我最喜欢的OSX编程工具,但我的团队伙伴都使用NetBeans.其中一些使用Eclipse Keymap.在NetBeans 6.5中启用VI命令的任何建议插件?
如果我有像这样的rspec
describe 'Foo' do
// init go here
describe 'Sub-Foo' do
it "should Bar" do
// test go here
// puts ... <-- need "Foo.Sub-Foo should Bar" here
end
end
end
Run Code Online (Sandbox Code Playgroud)
如何在测试环境中获得"Foo.Sub-Foo should Bar"// test在这里?
它类似于specdocs的格式,但是如何将其置于自身内部?
通常,当我在通知栏上有通知消息并单击它时.它打开该邮件的已注册应用程序.
在Startup的活动中,如何确定App是否从中打开?
更好的是如何在OnCreate()方法上检索通知的id?
更新:来自@Ovidiu - 这是我的putExtra推送代码
Notification notification = new Notification(icon, tickerText, System.currentTimeMillis());
notification.contentView = contentView;
Intent notificationIntent = new Intent(this, Startup.class);
notificationIntent.putExtra("JOBID", jobId);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.contentIntent = contentIntent;
mNotificationManager.notify(jobId, notification);
Run Code Online (Sandbox Code Playgroud)
并在主要活动"Startup.java"代码是
Intent intent = this.getIntent();
if (intent != null && intent.getExtras() != null && intent.getExtras().containsKey("JOBID")) {
int jobID = this.getIntent().getExtras().getInt("JOBID");
if (jobID > 0) {
}
}
Run Code Online (Sandbox Code Playgroud)
intent.getExtras()始终返回null.结果,我需要传递PendingIntent.FLAG_ONE_SHOT.它现在传递!!
存储多个用户数据的最佳方法是每个用户每个数据库.我正在使用同样的方法.
我在服务器上有couchdb,移动应用程序有pouchdb.我通过在pouchdb和couchdb中为用户创建单独的数据库来维护每个用户数据.那.这意味着我在couchdb中有多个数据库,在pouchdb中有一个数据库.
通常在sqlbase数据库中,用户数据存储在不同的不同表中.
所以在nosql pouchdb中我正在为每个表创建文档.
我面临的实际问题是:
我在每个数据库中都有一个文档来存储用户的事务.
客户端事务在他/她脱机时以及当应用程序将事务同步到couchdb用户数据库到事务文档时存储在pouchdb中.
数据存储在交易文件中如下
{
"_id":"transaction ",
"_rev":"1-3e5e140d50bf6a4d873f0c0f3e3deb8c",
"data":[
{
"transaction_id":"tran_1",
"transaction_name":"approve item",
"status":"Pending",
"ResultMsg":""
},
{
"transaction_id":"tran_2",
"transaction_name":"approve item",
"status":"Pending",
"ResultMsg":""
}]
}
Run Code Online (Sandbox Code Playgroud)
所有这些事务都在服务器端执行,结果在这些文档中更新.当执行任何新事务时,我将其存储在数据属性的事务文档中.
现在我在pouch和couchdb中有1个事务,两者都意味着两个都是同步的.
现在,当移动应用程序处于脱机状态时,它会执行存储在pouchdb事务文档中的脱机事务.
在服务器端,1个事务更新为成功.
现在当应用程序进入联机和同步执行时,我正在丢失我的服务器端更改,最后事务文档中的数据是客户端pouchdb.
在这里我丢失了服务器端数据.那么什么是好方法或如何解决它.

我还没有WP7设备.在模拟器上我的应用程序中的所有功能都可以正常运行,但是当我的客户测试它时,应用程序根本不起作用.例如,VDO没有播放.
有没有办法从Windows Phone 7获取崩溃日志?(像iPhone一样).
我想在AR模型上调用to_json时修改类名.
即
Book.first.to_json
#=> "{\"book\":{\"created_at\":\"2010-03-23
Book.first.to_json(:root => 'libro')
#=> "{\"libro\":{\"created_at\":\"2010-03-23
Run Code Online (Sandbox Code Playgroud)
有没有选择这样做?
在Perl for Ruby中,Crypt :: CBC的等价物是什么?
注意:此问题类似于stackoverflow上的PHP/Perl :655691.
Perl版本
use Crypt::CBC;
use MIME::Base64::Perl;
my $cipher = Crypt::CBC->new(
-key => "95A8EE8E89979B9EFDCBC6EB9797528D",
-keysize => 32,
-cipher => "Crypt::OpenSSL::AES"
);
$encypted = $cipher->encrypt("ABCDEFGH12345678");
$base64 = encode_base64($encypted);
print("$base64"); # output -> U2FsdGVkX18m1jVqRTxANhcEj6aADeOn+2cccDft2eYAMfOkYCvAAkTIOv01VHc/
$de_base64 = decode_base64($base64);
$decrypted = $cipher->decrypt($de_base64);
$c = $cipher->finish;
print("$decrypted \n");
Run Code Online (Sandbox Code Playgroud)
我的ruby版本看起来像这样:
require 'openssl'
require 'base64'
aes = OpenSSL::Cipher::AES128.new("CBC")
aes.encrypt
aes.key = "95A8EE8E89979B9EFDCBC6EB9797528D"
encypted = aes.update("ABCDEFGH12345678") + aes.final
base64 = Base64.encode64(encypted)
puts base64 # outout -> gx1K24LqlRUtNNTDNUJTyn7HrVKK6UkfNA9LNpNjZeE=
Run Code Online (Sandbox Code Playgroud)
我非常确定Base64在Ruby和Perl中的工作方式相同.有什么想法,正确的方法是什么?
更新(解决方案)
use …Run Code Online (Sandbox Code Playgroud) 我正在使用带有SSL配置的Amazon Load Balancer.一切都很好,除了在Firefox上显示异常页面.用户看起来不自我.
该文章建议把证书链的配置部分.

我的SSL提供商是Comodo(InstantSSL).它们仅提供两个文件.crt和.ca-bundle.
我如何生成证书链?
我在Fedora 14计算机上成功编译并安装了s3fs(http://code.google.com/p/s3fs/).我在指南中指定的/ etc /中包含了密码凭据.当我跑:
sudo/usr/bin/s3fs bucket_name/mnt/bucket_name /
它运行成功.(注意:存储桶名称与/ mnt /中的文件夹名称相同).当我在/ mnt /中运行ls时,我收到错误"ls:无法访问bucket_name:权限被拒绝".我跑的时候
sudo chmod 640/mnt/bucket_name
我得到"chmod:更改`bucket_name'的权限:输入/输出错误".当我重新启动机器时,我可以正常访问文件夹/ mnt/bucket_name,但它没有映射到s3存储桶.
所以,基本上我有两个问题.1)如何将文件夹(/ mnt/bucket_name)安装到s3存储桶后,如何正常访问文件夹(/ mnt/bucket_name)2)即使在机器重启后,如何保持安装状态.
问候