我需要创建javascript库,它将从其他javascript代码调用.
是否可以使用GWT和Java类创建javascript库?没有入口点,没有UI - 只是一些带有公共静态和对象方法的实用程序javascript类(例如加密库,图像处理库,用户输入验证库等)?
任何其他java到javascript转换工具是很好的.
我会尽量保持清醒.
这是我想要做的
图像查看器,其中图像将在设备屏幕上显示尽可能大的图像.为了这个目的和更好的用户体验,我想到了一个画廊.直到那里一切都好!
问题
问题是在我的适配器的getView函数中,它只使用我在Gallery中的第一张Image的Gallery.LayoutParams.这意味着如果第一张照片是风景照片而第二幅照片是纵向照片,则第二张照片将显示为风景照片,尺寸与第一幅照片相同.我重置了Gallery.LayoutParams,但没关系,它仍然有第一个ImageView的LayoutParams.
代码
public View getView(int position, View convertView, ViewGroup parent) {
ImageView im = new ImageView(mContext);
Bitmap bm = BitmapFactory.decodeByteArray(gallery.get(position).mContent, 0, gallery.get(position).mContent.length);
im.setImageBitmap(bm);
int width = 0;
int height = 0;
if (bm.getHeight() < bm.getWidth()) {
width = getWindowManager().getDefaultDisplay().getWidth();
height = bm.getHeight() * width / bm.getWidth();
}
else {
height = getWindowManager().getDefaultDisplay().getHeight();
width = bm.getWidth() * height/ bm.getHeight();
}
Gallery.LayoutParams lp = new Gallery.LayoutParams(width, height);
im.setLayoutParams(lp);
return im;
}
Run Code Online (Sandbox Code Playgroud)
如果你们中的任何一个人明白为什么我真的应该知道答案,
我们知道,Postgresql的OFFSET要求它扫描所有行,直到它到达你请求的位置为止,这使得通过大量结果集分页变得无用,随着OFFSET的增加而变得越来越慢.
PG 8.4现在支持窗口功能.代替:
SELECT * FROM table ORDER BY somecol LIMIT 10 OFFSET 500
Run Code Online (Sandbox Code Playgroud)
你可以说:
SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY somecol ASC) AS rownum FROM table) AS foo
WHERE rownum > 500 AND rownum <= 510
Run Code Online (Sandbox Code Playgroud)
后一种方法对我们有帮助吗?或者我们是否必须继续使用标识列和临时表来进行大分页?
我提前为我的原始英语道歉; 我会尽力避免语法错误等.
两个星期前,我决定更新我对Scheme(以及它的启发)的了解,同时实现我手中的一些数学材料,特别是我所注册的自动机理论和计算课程的常规语言.
到目前为止,我一直把字母表作为符号列表而不是代表
我没经验,想知道你对这个特殊选择的看法.是否为某些特定任务保留了符号,这是因为我滥用了它们?对此我发表任何评论都非常感激,因为我正在寻求指导.
在进一步的范围内,还将有时间在字母表上实现所有可能的单词集,这是无限的.我正在考虑通过允许的单词的最大大小来限制集合.再说一遍,这是一个很好的做法,还是应该代替流?我觉得流是一种更好的方法,但我还没有学到它们,所以我真的不知道使用它们的含义.
无论如何,欢迎提出任何建议或评论.我非常感谢您花时间阅读我的疑惑.周末愉快!
我试图理解以下结果.测试用例代码是
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/variant/recursive_variant.hpp>
#include <boost/spirit/home/support/context.hpp>
#include <boost/spirit/home/phoenix.hpp>
#include <boost/foreach.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <vector>
namespace sp = boost::spirit;
namespace qi = boost::spirit::qi;
using namespace boost::spirit::ascii;
namespace fusion = boost::fusion;
namespace phoenix = boost::phoenix;
using phoenix::at_c;
using phoenix::push_back;
using phoenix::bind;
template <typename P>
void test_parser(
char const* input, P const& p, bool full_match = true)
{
using boost::spirit::qi::parse;
char const* f(input);
char …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个WPF数据库应用程序.我可以使用一些好的组件来显示数据库表中的数据.ListView并且GridView似乎很受欢迎.但对于新手来说,很难看出它们之间的区别.
ListView和之间有什么区别GridView?优缺点都有什么?
所以我想删除列表框中的空白项目,就像空白一样,所以我有这个代码.但是编译器给了我一个错误
for (int i = 0; i < listBox2.Items.Count; i++)
{
if (listBox2.Items[i].ToString = " "){//ERROR*
listBox2.Items.RemoveAt(i);
}
}
Run Code Online (Sandbox Code Playgroud)
*无法将方法组'ToString'转换为非委托类型'bool'.你打算调用这个方法吗?
我正在尝试检索对象的类名.当我尝试使用const_get时,我得到整个模型的表结构.所以我使用了以下代码.
码
def classname(object)
return object.class.to_s.split("(")[0]
end
def classrating(object_id)
classtype = classname(object_id)
return classtype
end
Run Code Online (Sandbox Code Playgroud)
脚本/控制台
>> q = Question.new
=> #<Question id: nil, question_info: nil, profile_id: nil, rating: nil, created_at: nil, updated_at: nil>
>> Question.classname(q)
=> "Question"
>> Question.classrating(Question.classname(q))
=> "String"
>> q.class
=> Question(id: integer, question_info: string, profile_id: integer, rating: integer, created_at: datetime, updated_at: datetime)
Run Code Online (Sandbox Code Playgroud)
如您所见,当调用Question.classname时,它返回Question,当我从Question.classrating调用相同的输入时,它返回String.我只是从Question.classname返回相同的输出.
你能否告诉我,我做错了什么,价值变了.
谢谢.
我有一个ogg vorbis视频.它在图腾和mplayer中表现很好.我想将它转换成图像的序列,每帧一个图像.我可以使用以下命令在ffmpeg上执行此操作:
ffmpeg -i video.ogv -f image 2 video-frames-%08png
Run Code Online (Sandbox Code Playgroud)
但是,这不适用于此视频.每个帧都是灰色的,好像有大量的解码问题.由于它在图腾中工作,我怀疑gstreamer能够比ffmpeg更好地解码视频.是否有gstreamer命令将接收ogg vorbis视频,然后创建一堆图像,每帧一个?
我正在使用Ubuntu Lucid桌面库存.
我正在编写一个关于iPhone音频的章节,并且遇到了一段我无法理解的代码:
while (aqc.playPtr < aqc.sampleLen)
{
select(NULL, NULL, NULL, NULL, 1.0);
}
Run Code Online (Sandbox Code Playgroud)
(完整代码示例在第163-166页).根据我对代码的理解,音频正在另一个线程上处理,而while循环就是为了防止主线程在音频仍在处理时终止.
我不明白的是为什么select()要用来代替sleep().
从我所读到select()的用于监视I/O的变化并传递它的NULL并没有做任何有意义的事情.我已经运行了代码sleep(),它按预期工作.(我对低级别POSIX的了解几乎不存在.)