我有一个javascript函数,它作为查询字符串值传递另一个查询字符串.
换句话说,我希望查询字符串为:
http://www.somesite.com/?somequery=%3fkey%3dvalue1%2520%26%2520key2%3value3
Run Code Online (Sandbox Code Playgroud)
但是,如果我像这样重定向:
var url = 'http://www.somesite.com/?somequery=';
url += escape('?key=value1&key2=value2');
window.location = url;
Run Code Online (Sandbox Code Playgroud)
它最终http://www.somesite.com?somequery=?key1=value1&key2=value2在firefox和IE7中,这意味着我无法正确解析查询字符串.
我也试过使用encodeURIComponent也没用.
是否有另一个函数或黑客强制重定向保持somequery值逃脱?
我想从delayed_job运行一个rake任务(apn:notifications:从apn_on_rails gem传递).换句话说,我想将一个延迟的工作排入队列,这个工作将调用apn:notifications:提供rake任务.
我发现这个代码http://pastie.org/157390从http://geminstallthat.wordpress.com/2008/02/25/run-rake-tasks-with-delayedjob-dj/.
我将此代码作为DelayedRake.rb添加到我的lib目录中:
require 'rake'
require 'fileutils'
class DelayedRake
def initialize(task, options = {})
@task = task
@options = options
end
##
# Called by Delayed::Job.
def perform
FileUtils.cd RAILS_ROOT
@rake = Rake::Application.new
Rake.application = @rake
### Load all the Rake Tasks.
Dir[ "./lib/tasks/**/*.rake" ].each { |ext| load ext }
@options.stringify_keys!.each do |key, value|
ENV[key] = value
end
begin
@rake[@task].invoke
rescue => e
RAILS_DEFAULT_LOGGER.error "[ERROR]: task \"#{@task}\" failed. #{e}"
end
end
end
Run Code Online (Sandbox Code Playgroud)
一切运行良好,直到delayed_job运行,它抱怨:
[错误]:任务"apn:notifications:deliver"失败.不知道如何构建任务'apn:notifications:deliver'
我如何让它知道apn_on_rails?我试过在DelayedRake的顶部要求'apn_on_rails_tasks',它没有做任何事情.我还尝试将rake任务目录更改为./lib/tasks/*.rake …
我正在使用范围和一些条件运行查询.像这样的东西:
conditions[:offset] = (options[:page].to_i - 1) * PAGE_SIZE unless options[:page].blank?
conditions[:limit] = options[:limit] ||= PAGE_SIZE
scope = Promo.enabled.active
results = scope.all conditions
Run Code Online (Sandbox Code Playgroud)
我想在查询中添加一个计算列(当我现在调用scope.all时).像这样的东西:
(ACOS(至少(1,COS(0.71106459055501)*COS(-1.2915436464758)*COS(RADIANS(addresses.lat))*COS(RADIANS(地址.lng))+ COS(0.71106459055501)*SIN(-1.2915436464758)*COS (RADIANS(addresses.lat))*SIN(RADIANS(addresses.lng))+ SIN(0.71106459055501)*SIN(RADIANS(addresses.lat))))*3963.19)as accurate_distance
有没有办法在不使用find_by_sql并重写整个现有查询的情况下做到这一点?
谢谢!
我基本上是在尝试用 mini_magick 编写这个命令。
gm composite -compose Copy -geometry +0+210 note-transparent1.png note-rugby.png note-rugby-e.png
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
image = MiniMagick::Image.open("note-transparent1.png")
result = image.composite(MiniMagick::Image.open("note-rugby.png") do |c|
c.compose = "Copy"
c.geometry = "+0+210"
end)
result.write "note-rugby-e.png"
Run Code Online (Sandbox Code Playgroud)
图像被合成并写入新文件;但是不尊重几何。图像没有偏移。
我还尝试将 mini_magick 处理器设置为 ImageMagick 而不是 GraphicsMagick,但我得到了相同的结果。
有任何想法吗?
我试图使用J/Link从Mathematica获取图像到Java.我可以在Mathematica中打印图像,如下所示:
Print[ Graphics[Raster[ img[[1]] ], AspectRatio->Automatic, ImageSize->530 ] ];
Run Code Online (Sandbox Code Playgroud)
我试过以各种方式从Mathematica函数返回数据:
Return [ Image[Graphics[Raster[ img[[1]] ], AspectRatio->Automatic, ImageSize->530 ]] ];
Return [ Graphics[Raster[ img[[1]] ], AspectRatio->Automatic, ImageSize->530 ] ];
Return [ Raster[ note1[[1]] ] ];
Return [ note1[[1]] ];
Run Code Online (Sandbox Code Playgroud)
我的Java代码:
ml.evaluate("tmp = renderImageGeneric[" + sampleId + ", noteText," + sizeX + "," + sizeY + ", margin," + dpi + "," + lineStep + "," + tabStep + "," + ligatureMatch + "," + maxLigHeightDiff + "," + mmSearch + "," …Run Code Online (Sandbox Code Playgroud) 我正在创建一个应用程序.我想要一个减少免费版本和完整付费版本.显然,他们将共享大量代码和一些xib文件.如何分享这些而不仅仅是复制它们?
activerecord ×1
architecture ×1
delayed-job ×1
encoding ×1
imagemagick ×1
iphone ×1
java ×1
javascript ×1
jlink ×1
minimagick ×1
query-string ×1
rake ×1
ruby ×1
sql ×1