假设您有任何图像(PNG或JPG).此图像具有白色背景,我需要使此背景透明.
我试过这些例子:
convert original.png -background none transparent.pngconvert original.png -background white -flatten -alpha off transparent.png但没有理想的结果.
我该怎么做?
重要说明:使用convert命令行.
我正在使用OptionParserRuby.
我有其他语言,如C,Python等,有类似的命令行参数解析器,它们通常提供一种在没有提供参数或参数错误时显示帮助消息的方法.
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: calc.rb [options]"
opts.on("-l", "--length L", Integer, "Length") { |l| options[:length] = l }
opts.on("-w", "--width W", Integer, "Width") { |w| options[:width] = w }
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
end.parse!
Run Code Online (Sandbox Code Playgroud)
问题:
help消息如果没有传递参数(ruby calc.rb)?length是一个REQUIRED参数,用户不传递它或传递错误,如-l FOO?问题
我有一个Rails 3.0.4应用程序,我按照Railscast视频的说明升级到3.1.4 :"升级到rails 3.1".
现在我遇到资产问题,因为它们没有解决,在服务器日志中给出消息,如下所示:
Started GET "/assets/application.css" for 127.0.0.1 at 2012-04-08 03:57:13 -0500
Served asset /application.css - 404 Not Found (15ms)
ActionController::RoutingError (No route matches [GET] "/assets/application.css"):
Rendered /usr/local/rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.1.4/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (14.3ms)
Started GET "/assets/application.js" for 127.0.0.1 at 2012-04-08 03:57:13 -0500
Served asset /application.js - 404 Not Found (35ms)
ActionController::RoutingError (No route matches [GET] "/assets/application.js"):
Run Code Online (Sandbox Code Playgroud)
这些文件在assets目录中:
$ ls app/assets/*/application*
app/assets/javascripts/application.js app/assets/stylesheets/application.css
Run Code Online (Sandbox Code Playgroud)
并包含这个:
$ cat app/assets/javascripts/application.js
//= require jquery
//= …Run Code Online (Sandbox Code Playgroud) 假设我想应用于delete-trailing-whitespaceEmacs会话中的所有缓冲区.我怎样才能做到这一点?
我在这个会话中有很多缓冲区.因此,M-x delete-trailing-whitespace要手动应用于每个缓冲区,我需要一些方法来自动生成它.
非常感谢你
我已经编写了一些csv文件并使用以下代码对其进行压缩:
arr = (0...2**16).to_a
File.open('file.bz2', 'wb') do |f|
writer = Bzip2::Writer.new f
CSV(writer) do |csv|
(2**16).times { csv << arr }
end
writer.close
end
Run Code Online (Sandbox Code Playgroud)
我想读这个csv bzip2ed文件(用bzip2压缩的csv文件).这些未压缩的文件看起来像:
1,2
4,12
5,2
8,7
1,3
...
Run Code Online (Sandbox Code Playgroud)
所以我尝试了这段代码:
Bzip2::Reader.open(filename) do |bzip2|
CSV.foreach(bzip2) do |row|
puts row.inspect
end
end
Run Code Online (Sandbox Code Playgroud)
但是当它被执行时,它会抛出:
/Users/foo/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/csv.rb:1256:in `initialize': no implicit conversion of Bzip2::Reader into String (TypeError)
from /Users/foo/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/csv.rb:1256:in `open'
from /Users/foo/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/csv.rb:1256:in `open'
from /Users/foo/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/csv.rb:1121:in `foreach'
from worm_pathfinder_solver.rb:79:in `block in <main>'
from worm_pathfinder_solver.rb:77:in `open'
from worm_pathfinder_solver.rb:77:in `<main>'
Run Code Online (Sandbox Code Playgroud)
问题:
怎么了?我应该怎么做?
如何在emacs中删除一些与正则表达式匹配的文本?
我认为使用:
'(query-replace-regexp PATTERN EMPTY)
和:
'(replace-regexp PATTERN EMPTY)
但他们扔了:
perform-replace: Invalid regexp: "Premature end of regular expression".
事实:
我在浏览器上请求root应用程序,我的浏览http://localhost:8080/myapp器抛出了这个错误:Error 310 (net::ERR_TOO_MANY_REDIRECTS): many redirects.
环境:
我正在使用Java 6,Glassfish 2.1,Struts2,Spring和Hibernate.
校验:
然后我查看web.xml和welcome-list-files我有这个:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
所以,让我们检查index.jsp并有这个重定向:
...
<head>
<meta http-equiv="refresh" content="0;url=<%=request.getContextPath()%>/portal/home.do">
...
<link rel="shortcut icon" href="<%=request.getContextPath()%>/img/icono.png" />
</head>
...
Run Code Online (Sandbox Code Playgroud)
然后我们可以去struts.xml,我们可以看到这个块:
...
<package name="portal-action" extends="portal-base" namespace="/portal">
<action name="home" method="home" class="beginAction">
<result type="tiles">begin.home</result>
</action>
...
Run Code Online (Sandbox Code Playgroud)
我们来检查beginAction课程:
...
public String home(){
return SUCCESS;
}
...
Run Code Online (Sandbox Code Playgroud)
我们可以检查tiles.xml:
...
<definition name="begin.welcome" extends=".baseHome">
<put-attribute name="working.region" value="/jsp/common/welcome.jsp" />
</definition>
...
Run Code Online (Sandbox Code Playgroud)
最后我们可以查看welcome.jsp仅包含以下内容的整个文件:
<%@ taglib …Run Code Online (Sandbox Code Playgroud) 状态:我正在构建一个应用程序,其中需要一个可供用户选择颜色的字段,该字段将包含RGB颜色代码字符串.
我已经测试了一个看起来很漂亮的但是效果不好的.它是'挑剔的颜色',它托管在这个存储库中:https://github.com/Astorsoft/picky-color.在这里,我打开一个关于它的一些问题的问题.
问题:请建议我在Rails 3应用程序中使用一些颜色选择器.
当我想执行Rails 3控制台时,它抛出这个:
$ script/rails c
/usr/local/rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (Load Error)
Run Code Online (Sandbox Code Playgroud)
我试着安装libreadline-dev:
$ sudo wajig install libreadline-dev
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias
Leyendo la información de estado... Hecho
Se instalarán los siguientes paquetes extras:
libncurses5-dev libreadline6-dev
Se instalarán los siguientes paquetes NUEVOS:
libncurses5-dev libreadline-dev libreadline6-dev
0 actualizados, 3 se instalarán, 0 para eliminar y 6 no actualizados.
Necesito descargar 1799kB de archivos.
Se utilizarán 7266kB de espacio de disco …Run Code Online (Sandbox Code Playgroud) 我试图将我的master分支与另一个名为 的分支合并pull-stage,但是 Git 向我抛出了这个错误:
error: inflate: data stream error (invalid distance too far back)
error: corrupt loose object '5a63450f4a0b72abbc1221ccb7d9f9bfef333250'
fatal: loose object 5a63450f4a0b72abbc1221ccb7d9f9bfef333250 (stored in .git/objects/5a/63450f4a0b72abbc1221ccb7d9f9bfef333250) is corrupt
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我查看了其他帖子,但没有成功的结果:
ruby ×3
emacs ×2
bzip2 ×1
color-picker ×1
csv ×1
emacs23 ×1
git ×1
glassfish ×1
http ×1
imagemagick ×1
libreadline ×1
optionparser ×1
png ×1
readline ×1
redirect ×1
regex ×1
rgb ×1
struts2 ×1