问题列表 - 第18192页

从文件中删除前导空格

我的shell在我的.login文件中调用了"fortune",向我提供了当天的一些消息.然而,一些命运以一个前导空白行开头,一些以两个开头,有些则根本没有任何前导空白行.这让我烦恼.

我坐下来用我自己的shell脚本来包装财富,它将从输入中删除所有前导空格,而不会破坏实际财富的任何格式,这可能故意有空格行.

它似乎不是一个简单的单行两分钟修复,当我阅读(芦苇)通过sed和grep的手册页时,我想我会在这里问我们的好顾客.

whitespace grep sed

11
推荐指数
1
解决办法
4457
查看次数

用Java表示100K X 100K矩阵

如何在Java中存储100K X 100K矩阵?

我不能用正常的数组声明来做,因为它抛出了一个java.lang.OutofMemoryError.

java arrays

8
推荐指数
5
解决办法
3805
查看次数

GlassFish v3和glassfish-maven-plugin(Mac)

我正在尝试使用glassfish-maven-plugin(https://maven-glassfish-plugin.dev.java.net/)与GlassFish v3(我在Mac上并使用Eclipse),我似乎无法让我的Web应用程序部署.我一直遇到:

启动域需要主密码.没有控制台,没有提示可能.您应该使用--savemasterpassword = true创建域,或者使用--passwordfile选项提供密码文件.

这是我的POM文件的相关部分.

<profiles>
    <profile>
        <id>development</id>
        <activation>
            <property>
                <name>phase</name>
                <value>development</value>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.glassfish.maven.plugin</groupId>
                    <artifactId>maven-glassfish-plugin</artifactId>
                    <version>2.2-SNAPSHOT</version>
                    <configuration>
                        <glassfishDirectory>${glassfish.directory}</glassfishDirectory>
                        <user>${glassfish.user}</user>
                        <passFile>${glassfish.directory}/domains/${project.artifactId}/config/domain-passwords</passFile>
                        <domain>
                            <name>${project.artifactId}</name>
                        </domain>
                        <components>
                            <component>
                                <name>${project.artifactId}</name>
                                <artifact>${project.build.directory}/artifacts/${project.artifactId}.war</artifact>
                            </component>
                        </components>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <pluginRepositories>
            <pluginRepository>
                <id>ocean</id>
                <url>http://maven.ocean.net.au/snapshot</url>
                <releases>
                    <enabled>false</enabled>
                    <updatePolicy>never</updatePolicy>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)

这是Maven正在执行的start-domain命令.

asadmin --host localhost --port 4848 --user admin --passwordfile /var/folders/sk/skcc8rAVGSynOBBaOwWN3U+++TI--Tmp-/mgfp5377058868244877698.tmp --interactive = false --echo = true --terse = true start-domain --debug = false --domaindir/Applications/GlassFish/v3/glassfish/domains …

java maven-2 glassfish maven

7
推荐指数
1
解决办法
1万
查看次数

POSIX套接字和BSD套接字有什么区别?

有人可以解释POSIX套接字和BSD套接字之间的区别吗?

c c++ sockets posix

15
推荐指数
2
解决办法
9717
查看次数

使用std :: map <K,V>其中V没有可用的默认构造函数

我有一个符号表实现为std::map.对于该值,无法通过默认构造函数合法地构造值类型的实例.但是,如果我不提供默认构造函数,我会收到编译器错误,如果我使构造函数断言,我的程序编译得很好,但map<K,V>::operator []如果我尝试使用它来添加新成员,则会崩溃.

有没有办法让C++ map[k]在编译时禁止作为l值(同时允许它作为r值)?


顺便说一句:我知道我可以使用插入地图Map.insert(map<K,V>::value_type(k,v)).


编辑:有几个人提出的解决方案相当于改变值的类型,以便映射可以构造一个而不调用默认构造函数.这与我想要的完全相反,因为它将错误隐藏到以后.如果我愿意这样做,我可以简单地从构造函数中删除断言.我想要的是让错误更快发生; 在编译时.然而,似乎没有办法区分r值和l值使用,operator[]所以看起来我想要的不能这样做,所以我只需要免除一起使用它.

c++ stl map compile-time

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

Qt信号和槽的参数类型,const参考限定符是否重要?

适用于以下类型的信号和插槽

signals:
    void textChanged(const QString &);

public slots:
    void setText(const QString & text)
Run Code Online (Sandbox Code Playgroud)

textChanged和setText的参数类型似乎无法使用const&.与仅使用QString相比,常量和参考资格是否有任何区别?

QObject::connect(a,SIGNAL(textChanged(QString)),b,SLOT(setText(QString)));
QObject::connect(a,SIGNAL(textChanged(const QString &)),b,SLOT(setText(const QString &)));
Run Code Online (Sandbox Code Playgroud)

编辑:当SIGNAL或SLOT中使用不兼容的类型时,我没有注意到输出窗口显示错误消息.我认为信号槽机制能够在编译时检测参数类型错误.

connection qt types arguments signals-slots

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

如何抓取数十亿页?

是否可以在单个服务器上抓取数十亿个页面?

web-crawler

12
推荐指数
4
解决办法
1万
查看次数

当不期望时,在python中调用__del__方法

我是python的新手,并且一直在研究Swaroop CH的"A Byte of Python"中的示例.我看到一些__del__令我困惑的方法的行为.

基本上,如果我运行以下脚本(在Python 2.6.2中)

class Person4:
    '''Represents a person'''
    population = 0

    def __init__(self, name):
        '''Initialize the person's data'''
        self.name = name
        print 'Initializing %s'% self.name

        #When the person is created they increase the population
        Person4.population += 1

    def __del__(self):
        '''I am dying'''
        print '%s says bye' % self.name

        Person4.population -= 1

        if Person4.population == 0:
            print 'I am the last one'
        else:
            print 'There are still %d left' % Person4.population


swaroop = Person4('Swaroop')
kaleem …
Run Code Online (Sandbox Code Playgroud)

python object-lifetime del

6
推荐指数
2
解决办法
2139
查看次数

对文本文件进行排序,记录超过100,000,000条

我有一个5gig的文本文件需要按字母顺序排序什么是最好的算法?

限制:

速度 - 尽可能快

内存 - 运行Windows XP的1 Gig Ram的Pc

sorting algorithm

8
推荐指数
2
解决办法
4126
查看次数

如果(sz!= sz2)sz = sz2,为什么这个代码会这样做?

我第一次创造了一个linq to sql classes.我决定看看课程并找到了这个.

什么......如果(sz!= sz2){sz = sz2; }.我不明白 为什么生成的集合不是this._Property1 = value

    private string _Property1;
    [Column(Storage="_Property1", CanBeNull=false)]
    public string Property1
    {
        get
        {
            return this._Property1;
        }
        set
        {
            if ((this._Property1 != value))
            {
                this._Property1 = value;
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# linq-to-sql

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