这个问题更多的是关于开源礼仪,以及像github和gitorious这样的新方法给予协作和源所有权.您是否可以从其他地方(例如SourceForge,具有明确的项目团队和社区)获取任何开源项目并将其放入您自己的github存储库中,前提是您尊重原始许可的条款?如果是,您是否将您的版本保持为相同的名称,或更改它?
我不知何故有这种唠叨的感觉,这是粗鲁的,但它毕竟是开源的......
在Ubuntu上安装JRuby 1.6.7和Rails 3的博客或教程?
根据Groovy 文档:
范围允许您创建连续值的列表。这些可以用作列表,因为 Range 扩展了 java.util.List。
但是,就我而言,我需要列表以字符串形式结束,包括方括号。我尝试了以下方法:
def myRange = 1..5
def myList = [1, 2, 3, 4, 5]
// this passes
assert myRange == myList
// both of the following fail!
assert myRange.toString() == myList.toString()
assert myRange.subList(0, 5).toString() == myList.toString()
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
我有一个故事文本字段,并希望在快照页面中显示前几行 - 比如该字段的前50个单词.我怎么能在Ruby(在Rails上)做到这一点?
我读到了即时编译(JIT),据我所知,有两种方法 - Interpreter和JIT,它们都在运行时解释字节码.
为什么不准备将所有字节码解释为机器代码,然后才开始运行该过程而不再需要解释器?
我有两个型号:
class Solution < ActiveRecord::Base
belongs_to :user
validates_attachment_presence :software
validates_presence_of :price, :language, :title
validates_uniqueness_of :software_file_name, :scope => :user_id
has_attached_file :software
end
class User < ActiveRecord::Base
acts_as_authentic
validates_presence_of :first_name, :last_name, :primary_phone_number
validates_uniqueness_of :primary_phone_number
has_many :solutions
end
Run Code Online (Sandbox Code Playgroud)
我的路线看起来像这样:
map.resources :user, :has_many => :solutions
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试使用以下RSpec测试来测试我的解决方案控制器:
describe SolutionsController do
before(:each) do
@user = Factory.build(:user)
@solution = Factory.build(:solution, :user => @user)
end
describe "GET index" do
it "should find all of the solutions owned by a user" do
Solution.should_receive(:find_by_user_id).with(@user.id).and_return(@solutions)
get :index, :id => @user.id
end …Run Code Online (Sandbox Code Playgroud) 我对 OO 设计模式相当陌生,对 Java 也比较陌生。
我的问题是关于 Head First Designer Patterns Starbuzz 示例中的 Decorator 示例。
我无法理解外部包装器如何调用内部包装器,以及具体如何连接这些示例中的描述。
例如:
这是 Mocha 类(装饰):
public class Mocha extends CondimentsDecorator {
Beverage beverage;
public Mocha(Beverage beverage) {
this.beverage = beverage;
}
public String getDescription()
{
return beverage.getDescription() + " , Mocha";
}
public double cost()
{
return .20 + beverage.cost();
}
}
Run Code Online (Sandbox Code Playgroud)
这是饮料类(基础):
public abstract class Beverage {
String description = "Unknown Beverage";
public String getDescription()
{
return description;
}
public abstract double cost();
}
Run Code Online (Sandbox Code Playgroud)
深度烘焙等级: …
在 Java 中,要为多个目标定义注释,可以使用大括号:
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD})
public @interface AnnotExample {
String name();
}
Run Code Online (Sandbox Code Playgroud)
但是,这在 Groovy 中不起作用:
$ groovyc AnnotExample.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
AnnotExample.groovy: 8: expecting '}', found ',' @ line 8, column 26.
@Target({ElementType.TYPE, ElementType.FIELD})
^
1 error
Run Code Online (Sandbox Code Playgroud)
在 Groovy 中如何做到这一点?
此测试运行但失败。不知道为什么?有一个长度为 1 的 Submarine 类。
@Test
public void testShipConstructor() {
assertTrue(Submarine.length == 1);
}
Run Code Online (Sandbox Code Playgroud)
这是该类的代码:
public abstract class Ship {
private int size;
public static int length;
protected Ship(int size, String type, String shortForm) {
this.size = size;
this.setType(type);
this.shortForm = shortForm;
}
public static void setLength(int length) {
}
public int getLength() {
return length;
}
int getSize() {
return size;
}
}
public class Submarine extends Ship {
private final static int SIZE = 1;
/**
* * …Run Code Online (Sandbox Code Playgroud) 我试图做一个缓冲区来显示它并在一个中JLabel使用它JFrame.更改图像时出现问题:只有在调整窗口大小时图像才会发生变化.
package buffer;
import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class principal extends javax.swing.JFrame {
private JLabel person=new JLabel();
public static final int tCuadrito=60;
private URL url=Buffer.class.getClass().getResource("/imagenes/persona.png");
private ImageIcon imagenIcon=new ImageIcon();
private BufferedImage gato=new BufferedImage(120,60,BufferedImage.BITMASK);
public principal() {
initComponents();
dibujar();
}
public void dibujar(){
try{
gato=ImageIO.read(url);
}catch(IOException e){
System.out.print("ERROR imagen no leida: "+e.toString());
}
imagenIcon.setImage(gato.getSubimage(0, 0, 60, 60));
person.setBounds(0*tCuadrito, 0*tCuadrito, tCuadrito, tCuadrito);
person.setVisible(true);
person.setIcon(imagenIcon); …Run Code Online (Sandbox Code Playgroud) JavaScript部分:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
$('document').ready(function(){
setTimeout('slideback()', 1000);
function slideback()
{
$('body').css('background-image','url(http://sehirmedya.com/wp-content/uploads/2012/12/uluda%C4%9F.jpg)');
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
CSS代码:
body{
background-image:url('taksi.jpg');
background-size:100%;
background-attachment:fixed;
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(
src='taksi.jpg',
sizingMethod='scale')";
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
src='taksi.jpg',
sizingMethod='scale');
}
Run Code Online (Sandbox Code Playgroud)
在1000毫秒之后,它应该改变但不会改变.为什么不?我怎么解决这个问题?
我似乎无法克服heroku上面的错误.我在本地运行带有mysql2 gem的rails 3就好了,但是当移动到heroku时这似乎打破了.
首先,我使用的是ClearDB.
其次,当我部署并尝试运行时heroku run rake db:migrate,heroku告诉我需要添加mysql gem和activerecord-mysql-adapter.当我使用mysql2时,为什么会发生这种情况?
第三,当我将mysql和适配器添加到我的项目中时,我发现heroku的问题告诉我在项目中需要那些宝石.所以,我又跑rake db:migrate了,现在我得到了不同的错误......
rake aborted!
database configuration specifies nonexistent mysql adapter
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:133:in `establish_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:25:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `block in run_initializers'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:103:in `require_environment!'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:297:in `block …Run Code Online (Sandbox Code Playgroud) 我是Java新手,我编写了一个程序来接受用户的一些值并进行一些操作,但是我收到了一个错误,我不知道出了什么问题.
这是我的代码:
import java.util.Scanner;
public class Computronix{
public static void main(String[]args){
Scanner input = new Scanner(System.in);
int order;
double total;
double s_cost=1200000;
double l_cost=900000;
System.out.println("Enter number of laptop you need to purchase");
order = input.nextInt();
if(order<=0){
System.out.println("Please Order one laptop or more ");
}
elseif(order>0 && order<25){
total = order*s_cost;
System.out.println("The total cost is "+ total);
}
elseif(order>=25){
total = order*l_cost;
System.out.println("The total cost is "+ total);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
**C:\Users\Internally-root\Desktop\helow>javac Computronix.java
Computronix.java:17: error: ';' expected
elseif(order>0 && order<25){ …Run Code Online (Sandbox Code Playgroud) java ×4
groovy ×2
ruby ×2
annotations ×1
bytecode ×1
command-line ×1
controller ×1
css ×1
decorator ×1
github ×1
heroku ×1
interpreter ×1
jframe ×1
jquery ×1
jruby ×1
jrubyonrails ×1
junit ×1
jvm ×1
licensing ×1
mysql2 ×1
open-source ×1
rspec ×1
swing ×1
unit-testing ×1