灯角

文章 0 评论 0 浏览 23

灯角 2024-10-13 03:49:33

这必须是 Perl oneliner 吗?

perl -i -pe  's/\d+\./ /g' <fileName>

Perl 命令行选项:-i 用于指定输入文件发生的情况。如果你不给它一个文件扩展名,原始文件就会丢失并被 Perl munged 输出替换。例如,如果我有这样的:

perl -i.bak -pe  's/\d+\./ /g' <fileName>

原始文件将以 .bak 后缀存储,并且 本身将包含您的输出。

-p 表示将 Perl 程序包含在一个打印循环中,该循环看起来SOMEWHAT如下:

while ($_ = <>) {
    <Your Perl one liner>
    print "$_";
}

这是对正在发生的事情的稍微简化的解释。您可以通过从命令行执行 perldoc perlrun 来查看实际的 perl 循环。主要思想是它允许您像 sedawk 一样对文件的每一行进行操作。

-e 仅包含您的 Perl 命令。

您还可以进行文件重定向:

perl -pe  's/\d+\./ /g' < xyz.txt > xyz.txt.out

This HAS to be a Perl oneliner?

perl -i -pe  's/\d+\./ /g' <fileName>

The Perl command line options: -i is used to specify what happens to the input file. If you don't give it a file extension, the original file is lost and is replaced by the Perl munged output. For example, if I had this:

perl -i.bak -pe  's/\d+\./ /g' <fileName>

The original file would be stored with a .bak suffix and <fileName> itself would contain your output.

The -p means to enclose your Perl program in a print loop that looks SOMEWHAT like this:

while ($_ = <>) {
    <Your Perl one liner>
    print "$_";
}

This is a somewhat simplified explanation what's going on. You can see the actual perl loop by doing a perldoc perlrun from the command line. The main idea is that it allows you to act on each line of a file just like sed or awk.

The -e simply contains your Perl command.

You can also do file redirection too:

perl -pe  's/\d+\./ /g' < xyz.txt > xyz.txt.out

Perl 正则表达式从命令行作用于文件

灯角 2024-10-13 02:27:11

如果您正在构建调试应用程序或在源代码中的某个位置调用了 Debug.waitingForDebugger();,则会显示“等待调试器”对话框。

在 Android Studio 2.0 及更高版本中,有一个将调试器附加到 Android 进程的选项。它是“运行”菜单中的最后一个菜单项。

Android 中运行菜单选项的屏幕截图工作室

The Dialog Waiting for Debugger is shown if you are building a debug application or somewhere in your source code, you called Debug.waitingForDebugger();

Inside Android Studio 2.0 and above, there is an option of Attach Debugger to Android Process. It is the last menu item in the Run menu.

Screen shot of Run menu options in Android Studio

如何解决“等待调试器”问题信息?

灯角 2024-10-12 18:52:40

必须将框架文件夹“JSON.framework”添加到您要使用的每个 SDK 框架文件夹(iPhone Simulator、iPhoneOS 4.3)下,否则您的构建将失败并出现您报告的错误。或者,您可以将文件夹链接到项目文件夹之外,如 Bourne 提到的那样。无论哪种方式,Xcode 都需要知道您编译的每种构建类型的框架在哪里。

The framework folder 'JSON.framework' must be added under each SDK framework folder that you wish to use (iPhone Simulator, iPhoneOS 4.3), or your build will fail with the error that you reported. Alternatively you can just have the folder linked out of your project folder as Bourne mentioned. Either way it Xcode needs to know where the framework is for each type of build your compiling.

JSON.framework 在 xcode 中添加

灯角 2024-10-12 10:20:08
  • 在 Visual Studio 下,一种简单的方法是右键单击 #include 和“打开文档”:无论您的安装如何,IDE 都会为您搜索包含路径并打开文件目录
  • libstdc++ 的源代码是可用的,可以轻松地在线浏览(事实上,我经常将此站点称为文档):可以找到 set 的代码 此处
  • Under Visual Studio, an easy way is to right click on a #include <set> and "Open Document" : the IDE will search the include paths for you and open up the file regardless of your installation directory
  • The sources for libstdc++ are available and can be easily browsed online (as a matter of fact, I'm often referring to this site as a documentation) : the code for set can be found here.

集的实施

灯角 2024-10-12 09:44:08

您能解释一下为什么您想这样做吗?我能看到的唯一原因是使您的库的用户无法实现该界面。

我认为这不是一个好方法。只需添加一些 Javadoc 并解释为什么实现它没有意义。但最后,让用户决定是否有正当理由创建自定义实现。预见每一个用例总是很困难。

如果有人坚持他的方法,那肯定不是你的错 - 他不能说他没有被警告:)

举个例子,这就是你可以在 Apache Wicket 的源代码中找到的内容:

/**
 * THIS IS WICKET INTERNAL ONLY. DO NOT USE IT.
 * 
 * Traverses all behaviors and calls ...
 */

编辑:
只是另一个:你可以尝试这个,尽管我仍然不鼓励它 - 不要说你没有被警告过;)

public interface ExposedInterface {
  void foo();
}

// only default visibility
interface InternalInterface extends ExposedInterface {
  // nothing here
}

// and here some methods
ExposedInterface get(); // user can use it

void set(InternalInterface obj); // user is out of luck here

Could you please explain why you'd like to do that? The only reason I can see is to make it impossible to implement the interface for a user of your library.

I don't think that's a good approach. Simply add some Javadoc and explain why it doesn't make sense to implement it. But finally, leave it to the user whether there's a valid reason to create a custom implementation. It's always difficult to foresee each and every use case.

If somebody gots stuck with his approach it's certainly not your fault - he can't say he hasn't been warned :)

To give an example, that's what you can find all over Apache Wicket's source code:

/**
 * THIS IS WICKET INTERNAL ONLY. DO NOT USE IT.
 * 
 * Traverses all behaviors and calls ...
 */

EDIT:
just another though: you could try this, although I'd still discourage it - don't say you haven't been warned ;)

public interface ExposedInterface {
  void foo();
}

// only default visibility
interface InternalInterface extends ExposedInterface {
  // nothing here
}

// and here some methods
ExposedInterface get(); // user can use it

void set(InternalInterface obj); // user is out of luck here

如何在 Java 中不公开公共接口

灯角 2024-10-12 02:32:41

没有人提到 SQLExpress。您可以使用 SQL Management Studio,而且它是免费的。足够练习了。您可以直观地创建数据库并编写存储过程等。它还与Visual Studio Express集成。

No one mentioned SQLExpress. You can use SQL management studio, and it's free. Good enough for practicing. You can create databases visually and write stored procedures etc. It also integrates with Visual Studio express.

在 Windows 上练习 SQL 的好软件是什么?

灯角 2024-10-12 02:02:09

大多数编辑器都会自动缩进它们。对我来说,我将它们保留在小类或小文件或短 switch 语句中,但对于长文件或包含许多长 switch 语句的长文件,我使用更多缩进以便于阅读。

我有时会这样做,我觉得这是旧风格:

Class CClass
    {
            CClass();
            ~CClass();
        Public:
            int a;
        Private:
            int b;
     };
CClass::CClass
      {
           TODO code;
      }

当文件可能包含超过 20 或 50 个函数时,这有时会更容易,因此您可以轻松找到每个函数的开头。

Most editors indent them automatically. For me, I leave them as they are in small classes or small files or short switch statements, but for long ones or a long file with many long switch statements I use more indentation for easier readability.

I sometimes do this which I feel is as old style:

Class CClass
    {
            CClass();
            ~CClass();
        Public:
            int a;
        Private:
            int b;
     };
CClass::CClass
      {
           TODO code;
      }

This sometimes makes it easier when a file may contain more than 20 or 50 functions, so you can easily spot the beginning of every function.

为什么人们不缩进 C++访问说明符/case 语句?

灯角 2024-10-11 21:45:10

首先,AsyncTask 是实现此目的的好方法。我发现你的方法的问题是计时器等待观看某些东西死亡。当您调用 asyncTask 时,请保留它的引用。让它为您保留状态,以便您知道它是否正在搜索或已返回。当用户单击另一个字母时,您可以告诉 asyncTask 取消。像这样的事情:

public void onClick() {
   if( searchTask != null ) {
      searchTask.cancel();
   }

   searchTask = new SearchTask( MyActivity.this ).execute( textInput.getText() );
}

public class SearchTask extends AsyncTask<String,Integer,List<SearchResult>> {
    private boolean canceled = false;

    protected onPostExecute( List<SearchResult> results ) {
       if( !canceled ) {
          activity.handleResults( results );
       }
    }

    public void cancel() {
       canceled = true;
    }
}

这是安全的,因为 onPostExecute() 位于 UI 线程上。而且cancel()仅从UI线程调用,因此不存在线程安全问题,也不需要同步。您不必眼睁睁地看着线程死亡。只需让 GC 处理清理工作即可。一旦你删除了对 AsyncTask 的引用,它就会被清理掉。如果您的 AsyncTask 阻塞,那也没关系,因为它只会挂起后台线程,并且当超时时,它将通过调用 onPostExecute() 来恢复。这也可以在不使用计时器的情况下将您的资源保持在最低限度。

这种方法需要考虑的事项。每次输入新字母时发送新请求可能会使服务器超载,因为前几个字母将产生最大的搜索结果。要么限制从服务器返回的结果数量(例如最多 10-50 个结果),要么等到他们输入足够的字符以保留结果(例如 3 个)。让用户输入更多字符的缺点是,直到 3 个字符后才会出现反馈。然而,优点是它将大大减少服务器上的点击次数。

First yes, AsyncTask is a good way to do this. The problem I see with your approach is the timer waiting to watch something die. When you invoke the asyncTask hold onto a reference of it. Let it keep state for you so you know if it's out searching or it's has returned. When the user clicks another letter you can tell that asyncTask to cancel. Something like this:

public void onClick() {
   if( searchTask != null ) {
      searchTask.cancel();
   }

   searchTask = new SearchTask( MyActivity.this ).execute( textInput.getText() );
}

public class SearchTask extends AsyncTask<String,Integer,List<SearchResult>> {
    private boolean canceled = false;

    protected onPostExecute( List<SearchResult> results ) {
       if( !canceled ) {
          activity.handleResults( results );
       }
    }

    public void cancel() {
       canceled = true;
    }
}

This is safe because onPostExecute() is on the UI thread. And cancel() is only called from the UI thread so there is no thread safety issues, and no need to synchronize. You don't have to watch a thread die. Just let the GC handle cleaning up. Once you drop the reference to the AsyncTask it will just get cleaned up. If your AsyncTask blocks that's ok because it only hangs up the background thread, and when the timeout hits it will resume by calling onPostExecute(). This also keeps your resources to a minimum without using a Timer.

Things to consider about this approach. Sending a new request everytime a new letter is typed can overload your servers because the first few letters are going to produce the largest search results. Either limit the number of results you'll return from the server (say 10-50 results max), or wait until they've entered enough characters to keep results down (say 3). The cons of making the user type more characters is the feedback doesn't kick in until 3 chars. However, the pro is it will dramatically reduce the hits on your server.

“实时”使用 AsyncTask 进行搜索?

灯角 2024-10-11 20:22:12

您不能执行静态动态声明,例如:

int globalarray[n];

其中n是在运行时设置的变量。这是行不通的,因为数组是在程序开始运行之前初始化的。

一个好的替代方法是使用指向动态内存的指针:

int *globalarray;

int main (int argc, char **argv)
{
...
   int elements = atoi (argv [j]);  // parse out the program argument array size
   globalarray = malloc (elements * sizeof (globalarray[0]));
}

You can't do a static dynamic declaration like:

int globalarray[n];

Where n is a variable set at runtime. This doesn't work because the array is initialized before the program begins running.

A good alternative is to use a pointer to dynamic memory:

int *globalarray;

int main (int argc, char **argv)
{
...
   int elements = atoi (argv [j]);  // parse out the program argument array size
   globalarray = malloc (elements * sizeof (globalarray[0]));
}

从命令行定义全局数组的大小

灯角 2024-10-11 19:10:02

因为 PHP 认为您正在检查字符串“test”的“something”位置。请记住,字符串是字符数组。尝试回显 $array['a']['b']['c']['something']。

::编辑::

我解释了它,我并没有说它有道理。 :P

Because PHP thinks you are checking the 'something'th place of the string 'test'. Remember, strings are arrays of characters. try to echo $array['a']['b']['c']['something'].

::EDIT::

I Explained it, I didn't say it made sense. :P

数组:第四维,isset 返回不可靠

灯角 2024-10-11 10:23:07

由于您没有对数字进行任何数学运算(因为它只是一个唯一的键),为什么不将其存储为字符串。

$someID = "124234454288758";

另外,值得一提的是,像这样的 SQL 查询创建通常会对 SQL 注入开放。您可能应该考虑使用 PDO,它是 prepare 功能。

Since your not doing any math with the number (since it's just a unique key), why not just store it as a string.

$someID = "124234454288758";

Also, it's worth mentioning that SQL query creation like that is often open to SQL injection. You should probably consider using PDO and it's prepare functionality.

PHP字符串转换时如何保留long int?

灯角 2024-10-11 06:56:48

C++ Builder(和 Delphi)使用 OMF 格式的 obj 文件。有关详细信息,请参阅此维基百科链接

其他信息: Microsoft Visual C++ 使用不兼容的 COFF,这就是为什么C++ Builder 有一个实用程序来转换它们。

另请参阅: 之间有什么区别OMF 和 COFF 格式?

C++ Builder (and Delphi) use OMF format obj files. See this wikipedia link for details.

Additional information: Microsoft Visual C++ use an incompatible COFF, that's why C++ Builder have a utility to convert them.

See also: What's the difference between the OMF and COFF format?

OBJ文件的内容是什么?

灯角 2024-10-11 00:27:17

您可以在 Eclipse 中通过多种方式执行此操作

首先打开 Eclipse 并执行以下操作

File->Dynamic Web Project->NewWebProject

将上一个项目的内容复制到 NewWebProject 文件夹中,然后右键单击“New Web Project”

Properties->Project Facets 

并检查是否选中了动态 Web 模块

You can do this several ways in eclipse

Firstly open eclipse and do the following

File->Dynamic Web Project->NewWebProject

copy the contents of the pervious project into the NewWebProject folder then right click on New Web Project

Properties->Project Facets 

and check if dynamic web module is checked

无法将 JSP 项目作为动态 Web 项目导入到 Eclipse 中

灯角 2024-10-10 22:43:28

您可以尝试在发布的数据中使用单引号而不是双引号

You could try to use single quotes in the posted data rather than double

PHP 有没有自动转义双引号的配置?

灯角 2024-10-10 20:26:59

是的...只要你这样设计它就可以工作:

input[type="submit"], button, .button, a.actionlink {
    cursor: pointer;
    display: inline-block;
    font-family: "Arial","Verdana","Helvetica","sans-serif";
    font-size: 12px;
    font-weight: bold;
    min-width: 85px;
    -moz-outline: 0 none;
    outline: 0 none;
    padding-bottom: 7px;
    padding-top: 7px;
    text-align: center;
}

Yes... it does work provided you style it this way:

input[type="submit"], button, .button, a.actionlink {
    cursor: pointer;
    display: inline-block;
    font-family: "Arial","Verdana","Helvetica","sans-serif";
    font-size: 12px;
    font-weight: bold;
    min-width: 85px;
    -moz-outline: 0 none;
    outline: 0 none;
    padding-bottom: 7px;
    padding-top: 7px;
    text-align: center;
}

`min-width` 不适用于表单 `input[type="button"]` 元素吗?

更多

推荐作者

泪是无色的血

文章 0 评论 0

yriii2

文章 0 评论 0

1649543945

文章 0 评论 0

g红火

文章 0 评论 0

嘿哥们儿

文章 0 评论 0

旧城烟雨

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文