我只是看了一下twitter应用程序,它似乎在从一个屏幕移动到另一个屏幕时有一个很好的滑动过渡.我试图在我的应用程序中获得相同的行为.
目前我在屏幕之间移动:
startActivityForResult(new Intent(getApplicationContext(), MyActivity.class), 1);
Run Code Online (Sandbox Code Playgroud)
但这种方式屏幕之间没有过渡.在MyActivity刚刚弹出在屏幕上.
我试图将二进制数据(图像)保存到JCR节点.我正在使用这种方法从evernote获取图片注意:public byte [] getBody()然后尝试使用setProperty(string,Binary)设置属性jcr:data和文件内容
这就是我这样做的方式:
Node n;
byte [] fileContent = resrouce.getData().getBody();
....
n.setProperty("jcr:mimeType", "image/png");
n.setProperty("jcr:data", fileContent);
Run Code Online (Sandbox Code Playgroud)
但是,我收到一个错误
没有为setProperty找到合适的方法(java.lang.String,byte [])
jcr:data使用二进制文件内容设置属性的方法是什么?
我在python中有一个以下字符串:
Date: 07/14/1995 Time: 11:31:50 Subject text: Something-cool
Run Code Online (Sandbox Code Playgroud)
我想dict()通过以下方式准备一个key: [value]
{"Date":["07/13/1995"], "Time": ["11:31:50"], "Subject text":["Something-cool"]}
Run Code Online (Sandbox Code Playgroud)
如果我拆分字符串,:我得到以下内容.如何获得上述预期结果?
>>> text.split(": ")
['Date', '07/14/1995 Time', '11:31:50 Subject text', 'Something-cool']
Run Code Online (Sandbox Code Playgroud) 我正在倾倒一个像这样的大型 Postgres 表:
pg_dump -h myserver -U mt_user --table=mytable -Fc -Z 9 --file mytable.dump mydb
Run Code Online (Sandbox Code Playgroud)
以上创建了一个mytable.dump文件。我现在想将此转储恢复到名为mytable_restored.
我怎样才能使用pg_restore命令来做到这一点?
是)我有的
match "/home/markread/:id" => "books#markread"
Run Code Online (Sandbox Code Playgroud)
去
def markread
#mark params[:id] as read
end
Run Code Online (Sandbox Code Playgroud)
我想要的是
如果我想传递另一个参数,以便网址看起来像
/home/markread/1/didread=read或/home/markread/1/didread=unread
所以我的方法将改为
def marked
#mark params[:id] as params[:didread]
end
Run Code Online (Sandbox Code Playgroud)
题
对我routes.rb来说,我应该怎样才能实现这一目标?
我正在使用Struts2框架,并希望对execute下面的方法进行单元测试:
public String execute() {
setDao((MyDAO) ApplicationInitializer.getApplicationContext().getBean("MyDAO"));
setUserPrincipal(); //fetches attribute from request and stores it in a var
setGroupValue(); //
setResults(getMyDao().getReportResults(getActionValue(), getTabName());
setFirstResultSet((List) getResults()[0]);
setSecondResultSet((List) getResults()[1]);
return SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,大多数逻辑都与数据库相关.那么我该如何进行单元测试呢?我想通过模拟HTTPServletRequest其中的几个请求变量进行单元测试.
我的问题是:
我很欣赏任何展示如何真正实现这一目标的书/文章.
我正在从OpenCV中的URL加载图像。一些图像是PNG,具有四个通道。我正在寻找一种删除第四频道(如果存在)的方法。
这就是我加载图像的方式:
def read_image_from_url(self, imgurl):
req = urllib.urlopen(imgurl)
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
return cv2.imdecode(arr,-1) # 'load it as it is'
Run Code Online (Sandbox Code Playgroud)
我不想更改,cv2.imdecode(arr,-1)但我想检查加载的图像是否有第四个通道,如果有,请删除它。
像这样,但我不知道如何删除第四个频道
def read_image_from_url(self, imgurl):
req = urllib.urlopen(imgurl)
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
image = cv2.imdecode(arr,-1) # 'load it as it is'
s = image.shape
#check if third tuple of s is 4
#if it is 4 then remove the 4th channel and return the image.
Run Code Online (Sandbox Code Playgroud) 我在课堂上有一个类似下面的方法,我正在尝试测试:
class SomeHelper {
ByteArrayOutputStream fooBar (Request request) {
ByteArrayOutputStream baos = someParser.parseData(getRequestFileInputStream(request.filename))
return baos
}
InputStream getRequestFileInputStream(String filename) {
//return intputStream of object from S3
}
....
}
Run Code Online (Sandbox Code Playgroud)
在上面,getRequestFileInputStream是一种将参数作为文件名的方法.它从AWS S3获取该文件的输入流.虽然fooBar从Spock 测试方法,我想为该getRequestFileInputStream方法提供一个模拟,因为我不想使用该类中此方法的实现,因为它转到另一个存储桶名称.
是否有可能做到这一点?
以下是我尝试过的内容:
class SomeHelperSpec extends Specification{
//this is the implementation of getRequestFileInputStream I want to use while testing
InputStream getObjectFromS3(String objectName) {
def env = System.getenv()
AwsClientBuilder.EndpointConfiguration endpoint = new AwsClientBuilder.EndpointConfiguration(env["endpoint_url"], env["region_name"])
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard()
builder.setEndpointConfiguration(endpoint)
builder.setCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(env["ACCESS_KEY"], env["SECRET_KEY"])))
AmazonS3 …Run Code Online (Sandbox Code Playgroud) 我有一张如下表:
ID | text_field
----| ----------
1 | ABC-432
2 | ABC-1
3 | ABC-10
4 | ABC-5
Run Code Online (Sandbox Code Playgroud)
我想根据text_field数字部分得到前两个结果的列表
根据以上数据,查询输出将是:
ID | text_field
----| ----------
1 | ABC-432
3 | ABC-10
Run Code Online (Sandbox Code Playgroud)
由于432和10是此数据集中的两个最高数字.
java ×2
postgresql ×2
python ×2
aem ×1
android ×1
dao ×1
dictionary ×1
grails ×1
groovy ×1
jcr ×1
opencv ×1
osgi ×1
pg-restore ×1
png ×1
routes ×1
split ×1
spock ×1
spring ×1
sql ×1
string ×1
unit-testing ×1
url-routing ×1