问题标签 [header]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
perl - What is the smallest program possible to parse an email message header?
the homework: http://www.cs.rit.edu/~waw/networks/prob1.082.html
Ok, I am still confused why this question was asked for my data communications and networks class, but here is the question from my homework:
Write a computer program that reads the header on an e-mail message and deletes all lines except those that begin with
From:, To:, Subject: and Cc:.
CONTEST -- Who can write the shortest program that does this.
So after thinking for a bit I decided that the following Perl code was as small as I could do this.
All this does is act like a filter for which the only output is lines that start with From:, To:, Subject: and Cc: as specified in the question. Since there aren't any specific details I think that the above code works to at least correctly answer the question.
Now, I wonder how small a program could possibly written for this? I can understand if no one wants to post code because they think I will use it for the assignment, but I am more or less looking for suggestions and techniques that could help me write the shortest program possible.
Also, I am quite sure by shortest he is referring to actual code length. He did mention that scripting languages were the way to go so I doubt he is considering something like the overhead involved with an interpreter. This also means that he does not care which language is used.
Thanks for looking!
EDIT: Thanks for the suggestions! I had been reading questions here for quite a while, hopefully in the future I can contribute more. Also, some of the suggestions I trimmed my Perl code down to 55 bytes. I don't think we will need to deal with something like a multi-line header.
BONUS: Who can identify a good reason why this was asked in a class where we are discussing things like packet switching and client/server architectures?
EDIT2: For the record, my professor said that someone did this with something like 55 bytes. The only way I see that as being possible is if he was only asking for a simple implementation like the one above.
c++ - 将 C++ 头文件转换为 Python
我有一个包含#define 语句、枚举和结构的 C++ 标头。我尝试使用 Python 中包含的 h2py.py 脚本无济于事(除了给我转换的#defines)。任何帮助将不胜感激。
python - 如何在 HTTP 请求中发送带有 urllib2 的自定义标头?
使用 urllib2.urlopen(..) 时,我想在我的请求中发送一个自定义的“Accept”标头。我怎么做?
javascript - Javascript 在 Rails 应用程序中包含标签最佳实践
假设我需要在<head>
ERb 模板中调用 javascript 文件。我的直觉是照常做:
在我的应用程序的布局中。问题当然是这些 javascript 文件被加载到我的应用程序的每个页面中,无论正在查看的页面是否需要它们。
所以我想知道是否有一种将javascript加载到例如仅在特定目录中找到的所有ERb模板的标题的好方法。
c++ - Headers Including Each Other in C++
I'm a C++ newbie, but I wasn't able to find the answer to this (most likely trivial) question online. I am having some trouble compiling some code where two classes include each other. To begin, should my #include statements go inside or outside of my macros? In practice, this hasn't seemed to matter. However, in this particular case, I am having trouble. Putting the #include statements outside of the macros causes the compiler to recurse and gives me "#include nested too deeply" errors. This seems to makes sense to me since neither class has been fully defined before #include has been invoked. However, strangely, when I try to put them inside, I am unable to declare a type of one of the classes, for it is not recognized. Here is, in essence, what I'm trying to compile:
A.h
B.h
main.cpp
If it makes a difference, I am using g++ 4.3.2.
And just to be clear, in general, where should #include statements go? I have always seen them go outside of the macros, but the scenario I described clearly seems to break this principle. Thanks to any helpers in advance! Please allow me to clarify my intent if I have made any silly mistakes!
css - 通过 CSS 将图像更改为文本以进行打印?
假设我在要打印的网页上有一个标题横幅。与其浪费某人的墨水打印整个图像块,有没有办法通过 css 用 H1 大小的文本替换图像?
c++ - 如何在 MSVC++ 2005 或 2008 的大型解决方案中找到重复的标题?
在 Visual Studio (C++) 中,有没有办法轻松找到在 .cpp 文件中定义的重复标头?
我也在尝试寻找检测这种情况的方法:
- A 包括 B 包括 C
- A 包括 C
- => A 不需要包含 C
function - 在 Visual Studio 中自动生成函数文档
我想知道是否有办法(希望是键盘快捷键)在 Visual Studio 中创建自动生成函数头。
例子:
它会自动变成这样......
php - 为什么我的 PHP 应用程序不会发送 404 错误?
为什么这行不通?我得到一个空白页。
javascript - 在 HTML 中包含一个 js 文件
我在我的 HTML 中包含一个巨大的 javascript 文件(500K)。有没有一种聪明的方法可以知道它是否已加载。我能想到的一种方法是在其构造函数中有一个变量来初始化并通知我。加载是异步的,在包含该 JS 的 function 之前我无法继续。
谢谢