有红宝石版本管理等同于Java世界?
我正在寻找允许我轻松下载和安装新JVM并在它们之间切换的工具.例如:
jvm install <version>
jvm list //will list installed JVMs on my system
jvm use jdk1.6 //will switch my env to jdk 1.6 version, etc.
Run Code Online (Sandbox Code Playgroud) 我有一个包含数百个咖啡脚本文件的大型rails应用程序.
有时当我在coffeescript文件中进行微小更改或切换分支时,整个资产都被预编译,我必须等待很长时间才能加载页面:
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-11 19:39:45 +0100
Compiled sprockets/commonjs.js (0ms) (pid 18142)
Compiled jquery.js (2ms) (pid 18142)
Compiled jquery_ujs.js (0ms) (pid 18142)
Compiled underscore.js (0ms) (pid 18142)
Compiled backbone.js (0ms) (pid 18142)
Compiled backbone_rails_sync.js (0ms) (pid 18142)
Compiled handlebars.runtime.js (0ms) (pid 18142)
Compiled moment.js (0ms) (pid 18142)
...and so on
Run Code Online (Sandbox Code Playgroud)
我使用以下资产配置config/development.rb:
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = false
Run Code Online (Sandbox Code Playgroud)
当我设置时,config.assets.debug = false …
如何将简单的d3.js图表(例如http://bl.ocks.org/2579599)与jQuery.ui范围滑块组合?使用此滑块,我将控制x轴刻度(数据序列的乞讨和结束).我希望我的图表包含大量数据集,理想情况下应该在不重绘整个图表的情况下完成.
我必须等待很长时间(与我的朋友机器相比)在jRuby上执行脚本,特别是在我运行rake任务或测试时.我试过jRuby版本1.3.1和1.4.1有和没有ruby-debug gem,每个配置都出现同样的问题.
问题很简单:有没有办法改进jRuby加载过程?..或者我的jvm配置或jRuby安装有什么问题(我通过rvm使用jRuby - ruby版本管理器)?
有时我的规格可以挂起,我必须杀死相应的ruby过程.当我运行用capybara和webkit驱动程序编写的集成规范时,这很常见.
是否可以检查给定的红宝石过程并查看它挂在哪里?哪种方法,操作,文件,行号等
我有一个基于令牌的身份验证机制的API.成功登录后,我在浏览器的本地存储中存储了两个令牌 - 访问和刷新令牌.访问令牌包含在服务器端授权用户所需的所有必要信息,并且它具有到期日期.当访问令牌过期时,客户端可以使用刷新令牌请求新的访问令牌,并且在响应中它将获得一对新令牌.
在角度1.x中,实现非常简单明了.例如,我们可以使用拦截器:
httpInterceptor.$inject = ['$httpProvider'];
function httpInterceptor($httpProvider) {
$httpProvider.interceptors.push(handleStaleAccessToken);
handleStaleAccessToken.$inject = ['$q', '$injector', 'session'];
function handleStaleAccessToken($q, $injector, session) {
function logoutAndRedirect() {
var authenticationRedirect = $injector.get('authenticationRedirect');
session.destroy();
authenticationRedirect.toLoginPage();
}
return {
responseError: function(rejection) {
// Do nothing for non 403 errors
if (rejection.status !== 403) {
return $q.reject(rejection);
}
var errorCode = rejection.data.error && rejection.data.error.code;
if (errorCode === 'access_token_expired') {
var $http = $injector.get('$http');
// Refresh token
var params = { refreshToken: session.getRefreshToken() };
return $http.post('/api/auth/refresh', params).then(function(response) { …Run Code Online (Sandbox Code Playgroud) 我正在使用Recurly.js集成我的rails应用程序.
在我从我的服务器端应用程序发出重复请求之前,因此我能够将所有与优秀VCR gem(https://github.com/myronmarston/vcr)的集成存根,但Recurly.js直接向服务发出请求使用JSONP的javascript代码.
问题是:如何在集成测试中模拟这些jsonp调用?
目前我正在使用rspec + capybara + phantomjs驱动程序(https://github.com/jonleighton/poltergeist)
我正试图用robolectric测试日期选择器的行为.
@Test
public void shouldSetStartedOnDate() {
activity.findViewById(R.id.cruise_form_pick_started_on_button).performClick();
DatePickerDialog dialog = (DatePickerDialog) ShadowDatePickerDialog.getLatestDialog();
assertThat(dialog.isShowing(), is(true));
dialog.updateDate(2013, 3, 13);
ShadowDialog shadowDialog = Robolectric.shadowOf(dialog);
shadowDialog.clickOnText("Done");
assertThat(dialog.isShowing(), is(false));
TextView startedOnText = (TextView) activity.findViewById(R.id.cruise_form_started_on);
assertThat(startedOnText.getText().toString(), equalTo("2013-03-13"));
}
Run Code Online (Sandbox Code Playgroud)
不幸的是dialog.updateDate(2013, 3, 13)引发了java.lang.NullPointerException
java.lang.NullPointerException
at android.app.DatePickerDialog.updateDate(DatePickerDialog.java:142)
at net.lucassus.yachtexpenses.activities.CruiseFormActivityTest.shouldSetStartedOnDate(CruiseFormActivityTest.java:99)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
...
Run Code Online (Sandbox Code Playgroud)
在调试器中,我注意到dialog.mDatePicker实例变量是null.问题是我做错了什么?不幸的是,我找不到如何用robolectric v2.0测试日期选择器对话框的好例子.
在文档中我们可以找到The limits are based on a moving window that tracks the number of requests you send per hour.(https://developer.foursquare.com/overview/ratelimits),但在实践中,即使我等了好几分钟,我的速率限制也没有充电.
发生了什么?他们是否改变了API费率限制的实施?
我正在尝试编写一个可以在后台执行mongodb服务器的简单脚本.目前我用的Process.spawn方法.它工作但我必须等待一段时间mongod才能完全运行(启动过程完成,数据库正在等待新的连接).
def run!
return if running?
FileUtils.mkdir_p(MONGODB_DBPATH)
command = "mongod --port #{port} --dbpath #{MONGODB_DBPATH} --nojournal"
log_file = File.open(File.expand_path("log/test_mongod.log"), "w+")
@pid = Process.spawn(command, out: log_file)
# TODO wait for the connection (waiting for connections on port xxxx)
sleep 2
yield port if block_given?
end
Run Code Online (Sandbox Code Playgroud)
以下是完整的脚本:https: //github.com/lucassus/mongo_browser/blob/master/spec/support/mongod.rb#L22
是否有可能sleep 2从这段代码中删除这个丑陋的任意?
我的第一个猜测是将管道连接到生成的进程并等待"等待端口xxxx上的连接"消息写入管道.但我不知道如何实现它.
我可以用纯 C++ 编写自定义 Qt 小部件,编译它并在 PyQt 中使用吗?
我正在尝试将 ctypes-opencv 与 qt 一起使用,但我在使用 python 代码以 Qt 形式显示 opencv 图像时遇到了性能问题。