当我将以下文本粘贴到在ruby-enterprise-2011.03下运行的IRB或PRY时,需要13秒.
# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Run Code Online (Sandbox Code Playgroud)
在同一台计算机上运行irb与其他ruby安装时,粘贴速度并不慢.
jruby-1.5.6
jruby-1.6.3
ruby-1.8.6-p420
ruby-1.8.7-p352
ruby-1.9.1-p431
ruby-1.9.2-p290
ruby-1.9.3-preview1
or Mac OS X's default system install of 1.8.7-p249
Run Code Online (Sandbox Code Playgroud)
这个问题与Rails控制台在编辑文本时运行速度非常慢有关,但我没有使用rvm,编写,编辑或删除文本时没有慢; 只有粘贴很慢.@ fl00r的建议有效,但这不是永久修复.
此外,如果粘贴文本中有硬换行,则只有最后一行很慢.例如,粘贴以下文本大约需要1.5秒
# Lorem ipsum dolor sit amet, consectetur adipisicing elit,
# sed do eiusmod tempor incididunt ut labore et dolore magna
# aliqua.
Run Code Online (Sandbox Code Playgroud)
我注意到REE加载了一个libreadline的副本,其他任何ruby安装都没有加载.有没有办法配置和编译REE以忽略MacPorts的libreadline文件?
require 'readline'
puts `lsof -p #{$$} | grep -i readline | awk '{print …Run Code Online (Sandbox Code Playgroud) 我正在构建一个加载32位COM dll的C#应用程序.编译的应用程序在32位Windows上正常运行,但在64位Windows上运行barfs,因为它无法加载32位COM.有没有办法在VC#2008 Express Edition中设置32位构建目标?
或者,有没有办法强制编译到AnyCPU构建目标的.NET应用程序在64位Windows上以32位模式运行?
注意这最初是作为一个关于404错误的问题开始的,但现在问题是为什么我应用的补丁会产生影响.
如何获得缓存操作以在所有引发ActiveRecord :: RecordNotFound异常的请求上返回404,而不仅仅是第一个请求?
例如,如果你启动一个空的rails项目,添加一个Product model和controller,设置你的database.yml,在production.rb中设置你的缓存后端,rake db:migrate,然后在生产中启动并点击该站点现有对象,例如http:// localhost:3000/product/show/1234
class ProductController < ApplicationController
caches_action :show
def show
@product = Product.find(params[:id])
render :text => "asdf"
end
end
Run Code Online (Sandbox Code Playgroud)
第一次点击页面时,它会按预期返回404页面.但是,对该URL的每次后续匹配都会返回一个200 OK的空白页面.你怎么得到它每次返回404?
以下是CURL请求,后跟日志
~ $ curl -I http://0.0.0.0:3000/product/show/1234
HTTP/1.1 404 Not Found
Connection: close
Date: Mon, 20 Apr 2009 22:49:18 GMT
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Content-Length: 14097
~ $ curl -I http://0.0.0.0:3000/product/show/1234
HTTP/1.1 200 OK
Connection: close
Date: Mon, 20 Apr 2009 22:49:19 GMT
X-Runtime: 6
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Content-Length: …Run Code Online (Sandbox Code Playgroud) 我尝试使用Formatter.format,但这似乎将尾数留在带有0尾数的数字上,而C版本却没有.在Java中是否有相当于C的%g格式说明符,如果没有,有没有办法伪造它?出于兼容性原因,我的目的是保持尾数与C完全相同.
foo.c的
#include <stdio.h>
int main (int argc, char const *argv[])
{
printf("%g\n", 1.0);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
Main.java
class Main {
public static void main(String[] args) {
System.out.printf("%g\n", 1.0);
}
}
Run Code Online (Sandbox Code Playgroud)
安慰:
$ javac Main.java && java Main
1.00000
$ gcc foo.c && ./a.out
1
Run Code Online (Sandbox Code Playgroud)
类似地,使用1.2作为输入,Java版本中的尾数较长
$ javac Main.java && java Main
1.20000
$ gcc foo.c && ./a.out
1.2
Run Code Online (Sandbox Code Playgroud) 从ActionMailer输出发送到日志的电子邮件的输出,我想知道我是否可以将该输出转换为变量,以便将其存储在文件中.
PS.我忘了提到这是在Rails 2上
我想尽量减少对Youtube API的调用,因为这些数据不会经常刷新.当我尝试缓存此时:
Rails.cache.fetch("youtube-#{@yt_name}", :expires_in => 1.day) do
@youtube_doc = Nokogiri::XML(open("https://gdata.youtube.com/feeds/api/users/#{@yt_name}/uploads"))
end
Run Code Online (Sandbox Code Playgroud)
我在heroku中收到错误:
Marshalling error for key 'youtube-NAME': no marshal_dump is defined for class Nokogiri::XML::NodeSet
You are trying to cache a Ruby object which cannot be serialized to memcached.
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我有一个.wav文件.我想从该声音文件中获取PCM数据,以便我可以从声音中获取单个数据块并对其进行处理.
但我不知道该怎么做.谁能告诉我怎么做?到目前为止我做到了这一点:
public class test
{
static int frameSample;
static int timeofFrame;
static int N;
static int runTimes;
static int bps;
static int channels;
static double times;
static int bufSize;
static int frameSize;
static int frameRate;
static long length;
public static void main(String[] args)
{
try
{
AudioInputStream ais = AudioSystem.getAudioInputStream(new File("music/audio.wav"));
AudioInputStream a;
int numBytes = ais.available();
System.out.println("numbytes: "+numBytes);
byte[] buffer = new byte[numBytes];
byte[] buffer1=new byte[numBytes] ;
int k=0;
int count=0;
while(count!=-1){
count=ais.read(buffer, 0, numBytes);
} …Run Code Online (Sandbox Code Playgroud) 所有规格都通过后,是否可以抑制guard-rspec通知?不过,当规格失败时,我想获得一个巨大的低吼声通知.那可能吗?
即堆栈的任何部分都存在这样的设置吗?