小编Jas*_*son的帖子

在双引导系统上共享Eclipse项目

我最近将我的笔记本电脑转换为Ubuntu/Win7双启动系统,每个系统都有自己的分区,另外还有第三个共享分区.我想使用Eclipse并访问我的SVN存储库,无论我当时启动哪个系统.

如果我在共享分区上有我的本地SVN存储库,如何在Ubuntu和Windows上启用工作区到文件?

我提出的唯一其他选择是让每个操作系统都有自己的工作副本,并根据需要应用提交和更新.

编辑以澄清

我不是在问它是否可以为Linux和Windows提供单一工作区.我想到了共享分区中链接到每个工作区的单个源文件夹.因此,文件路径将是特定于操作系统的,并且仅访问源代码.

eclipse svn windows workspace ubuntu

3
推荐指数
1
解决办法
3564
查看次数

检查文件是否存在

我正处于项目的最后阶段,需要创建一个脚本,该脚本将使用不同的输入运行可执行文件一定次数.其中一个输入是保存在与可执行文件不同的文件夹中的文件.

在做任何事情之前,我想检查文件是否存在.可以给出两种可能的文件输入,因此我需要对它们进行比较.可能的输入是

  • execute cancer 9
  • execute promoter 9

where cancerpromoters是要在程序中使用的数据集,9是脚本循环必须执行的次数.

这是我想出的:

#!/bin/bash

#Shell script to execute Proj 4 requirements while leaving the folder
#structure alone separated.

file1= "Data/BC/bc80-train-1"
file2= "Data/Promoters/p80-train-1"

if [ "$1" == "cancer" ] then #execute command on the cancer dataset
    echo "Executing on the cancer dataset"
    if [ -f "$file1" ] then
        echo "$file1 file exists..."

    else 
        echo "$file1 file Missing, cancelling execution"
        echo "Dataset must be in ../Data/BC/ and file must be bc80-train-1" …
Run Code Online (Sandbox Code Playgroud)

bash file-io

3
推荐指数
1
解决办法
395
查看次数

执行Perl脚本时解决内存不足错误

我正在尝试基于英语维基百科转储中找到的前100K单词构建一个n-gram语言模型.我已经使用用Java编写的修改过的XML解析器提取出纯文本,但需要将其转换为vocab文件.

为了做到这一点,我找到了一个据说可以完成工作的perl脚本,但缺乏如何执行的指令.毋庸置疑,我是Perl的全新手,这是我第一次遇到它的使用需求.

当我运行这个脚本时,我在两个独立的双核机器上使用这个7.2GB文本文件时遇到内存不足错误,该机器有4GB RAM和runnung Ubuntu 10.04和10.10.

当我联系作者时,他说这个脚本在带有4GB RAM的MacBook Pro上运行正常,当使用perl 5.12在6.6GB文本文件上执行时,内存总使用量大约为78 MB.作者还说,该脚本逐行读取输入文件,并在内存中创建一个hashmap.

该脚本是:

#! /usr/bin/perl

use FindBin;
use lib "$FindBin::Bin";

use strict;
require 'english-utils.pl';

## Create a list of words and their frequencies from an input corpus document
## (format: plain text, words separated by spaces, no sentence separators)

## TODO should words with hyphens be expanded? (e.g. three-dimensional)

my %dict;
my $min_len = 3;
my $min_freq = 1;

while (<>) {

    chomp($_);
    my @words = split(" ", $_);

    foreach my …
Run Code Online (Sandbox Code Playgroud)

linux perl out-of-memory

3
推荐指数
1
解决办法
5395
查看次数

解决k分区变化的算法

对于我的算法设计课程的家庭作业来了这个脑筋急转弯:

Given a list of N distinct positive integers, partition the list into two 
sublists of n/2 size such that the difference between sums of the sublists 
is maximized.
Assume that n is even and determine the time complexity.
Run Code Online (Sandbox Code Playgroud)

乍一看,解决方案似乎是

  1. 通过mergesort对列表进行排序
  2. 选择n/2位置
  3. 对于大于的所有元素,添加到高数组
  4. 对于低于所有元素,添加到低数组

这将具有时间复杂性 O((n log n)+ n)

这个问题有更好的算法选择吗?

algorithm

3
推荐指数
1
解决办法
1081
查看次数

图像上传到Grails中的文件系统

我正在为Grails中的Web应用程序实现文件上传功能.这包括调整现有代码以允许多个文件扩展名.在代码中,我实现了一个布尔值来验证文件路径是否存在,但我仍然得到一个FileNotFoundException,/hubbub/images/testcommand/photo.gif (No such file or directory)

我的上传代码是

def rawUpload = {       
    def mpf = request.getFile("photo")
    if (!mpf?.empty && mpf.size < 200*1024){
        def type = mpf.contentType
        String[] splitType = type.split("/")

        boolean exists= new File("/hubbub/images/${params.userId}")

        if (exists) {
            mpf.transferTo(new File("/hubbub/images/${params.userId}/picture.${splitType[1]}"))
        } else {
            tempFile = new File("/hubbub/images/${params.userId}").mkdir()
            mpf.transferTo(new File("/hubbub/images/${params.userId}/picture.${splitType[1]}"))
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

我收到了异常消息

if (exists) {
        mpf.transferTo(new File("/hubbub/images/${params.userId}/picture.${splitType[1]}"))
}
Run Code Online (Sandbox Code Playgroud)

那么,为什么会发生这种错误,因为我只是简单地折叠有效的现有路径以及有效的文件名和扩展名?

grails filenotfoundexception image-upload

3
推荐指数
1
解决办法
1119
查看次数

将jFrame输出到jpeg或位图

我一直在做作业,并已完成所有要求。该项目将比较线性搜索算法和二进制搜索在运行时间上的差异。我有一个图类,将这些搜索的结果放在xy图中。

图对象是扩展JFrame的Turtle类。有什么方法可以将图形对象转换为位图并保存以供将来打印?

教授要求打印出结果。由于我不想每次运行该程序时都打印输出,因此我宁愿将图形结果保存在指定的文件夹中,而不是使用screen-grab。

不幸的是,我还没有在Google或此处提出任何答案。这样的事情可能吗?

java graphics

2
推荐指数
1
解决办法
1738
查看次数

Subclipse-更新工作副本

我在两台机器 - 我的笔记本电脑和台式机上工作我的学校项目.最近我开始使用subclipse进行版本控制,并在两台机器上插入Eclipse.

在单台计算机上工作时,我了解结帐/提交过程并在"团队同步"选项卡中进行同步.

那么,如何在subclipse中更新其他机器的工作副本而不必检查并覆盖本地机器上的整个项目?

eclipse subclipse svn working-copy

2
推荐指数
1
解决办法
3233
查看次数

获取事件目标-AS3的名称值

我正在应用程序中实现一个文本显示区域,当用户将鼠标悬停在四个元素之一上时,该区域显示所选文本.我想获取调用处理程序的实例的名称,而不是为每个元素创建一个处理函数,以实现switch语句.我尝试了两种方法,但两种方法都不起作用:

//install event handlers
initialText.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
timeText.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
withdrawalText.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);


//also tried without toString, same result
var name:String= evt.target.name.toString();
var name=String= evt.currentTarget.name.toString();
Run Code Online (Sandbox Code Playgroud)

这两个都为变量名返回undefined.但是,在调试器中,我可以通过currentTarget.name跟踪事件值,并显示触发处理函数的实例,无论是否withdrawalText, initialText or timeText.那么如何将名称值应用于变量以确定要显示的文本块?

event-handling actionscript-3

2
推荐指数
1
解决办法
6838
查看次数

在本地存储中更容易插入Django返回结果的方法

我有一个页面设置将Django数据库查询的结果加载到下拉列表中.在选择项目时,生成具有相关数据的表格.

鉴于视图方法

def index(request):
    parentorg_list = Parentorgs.objects.all()
    context = {'parentorg_list' : parentorg_list}
    return render(request, "app/index.html", context)
Run Code Online (Sandbox Code Playgroud)

{% for org in parentorg_list %}
  localStorage.setItem("{{org.parentorg}}", "{{org.parentorgName}}");
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

有没有办法将项目添加到localstorage而不使用Django生成约500行重复localStorage.setItem()?或者我最好将索引返回转换为JSON列表进行解析?

django local-storage

2
推荐指数
1
解决办法
4418
查看次数

注解是否适用于子类?

我一直想知道这个问题,但一直无法找到有关该主题的任何内容。

假设我正在使用 Spring MVC 并定义一系列Controllers。

@RestController
public abstract class AbstractController {

    @Resource
    private Environment env;

    ...
    ...
}
Run Code Online (Sandbox Code Playgroud)

对于以下,是否需要@RestController注解UserController才能注册?

@RequestMapping(value = "/user")
public class UserController extends AbstractController {

    @RequestMapping("value = "", method = RequestMethod.GET)
    public ResponseEntity<User> getUser() {
       ...
       return new ResponseEntity<>(user, HttpStatus.OK);
    }          
}
Run Code Online (Sandbox Code Playgroud)

java inheritance annotations spring-mvc

2
推荐指数
1
解决办法
1229
查看次数