我正在尝试阅读test.txt(它位于Javascript源的同一文件夹中)的内容并使用以下代码显示它:
var fs = require("fs");
fs.readFile("test.txt", function (err, data) {
if (err) throw err;
console.log(data);
});
Run Code Online (Sandbox Code Playgroud)
该内容test.txt创建于nano:
测试Node.js readFile()
我得到了这个:
Nathan-Camposs-MacBook-Pro:node_test Nathan$ node main.js
<Buffer 54 65 73 74 69 6e 67 20 4e 6f 64 65 2e 6a 73 20 72 65 61 64 46 69 6c 65 28 29>
Nathan-Camposs-MacBook-Pro:node_test Nathan$
Run Code Online (Sandbox Code Playgroud) 我正在构建一个具有如下if函数的Shell脚本:
if jarsigner -verbose -keystore $keyst -keystore $pass $jar_file $kalias
then
echo $jar_file signed sucessfully
else
echo ERROR: Failed to sign $jar_file. Please recheck the variables
fi
...
Run Code Online (Sandbox Code Playgroud)
我希望在显示错误消息后完成脚本的执行.我怎么能这样做?
我想删除所有现有的SDK版本以及Xcode 4.
Xcode 4指南说要这样做:
sudo /Xcode4/Library/uninstall-devtools --mode=all
Run Code Online (Sandbox Code Playgroud)
但是我在这个位置没有Xcode4,而且我看到它的唯一地方就在了 /Developer/Applications
我已经运行了之前找到的uninstall-devtools,/Developer/Applications然后重新安装.
我还能做些什么来完全删除所有内容并从头开始?
我的问题很简单!
就个人而言,我是Ruby on Rails程序员,我非常喜欢它.但是,我正在考虑Smalltalk,因为我阅读了各种博客,有些人正在将Ruby称为"Smalltalk Light".我对Smalltalk感兴趣的第二个原因是Seaside.
也许有人之前做过同样的过渡?
编辑:实际上,让我对Smalltalk/Seaside最感兴趣的是下面的WebDevRadio剧集:第52集:Randal Schwartz on Seaside(除其他外)
我有一个简单的"语言",我正在使用Flex(词法分析器),它是这样的:
/* Just like UNIX wc */
%{
int chars = 0;
int words = 0;
int lines = 0;
%}
%%
[a-zA-Z]+ { words++; chars += strlen(yytext); }
\n { chars++; lines++; }
. { chars++; }
%%
int main()
{
yylex();
printf("%8d%8d%8d\n", lines, words, chars);
}
Run Code Online (Sandbox Code Playgroud)
我跑了一个flex count.l,一切顺利没有错误或警告,然后当我尝试做一个cc lex.yy.c我得到这个错误:
ubuntu @ eeepc:〜/ Desktop $ cc lex.yy.c
/tmp/ccwwkhvq.o:在函数yylex': lex.yy.c:(.text+0x402): undefined reference toyywrap'/
tmp/ccwwkhvq.o中:在函数input': lex.yy.c:(.text+0xe25): undefined reference toyywrap中'
collect2:ld返回1退出状态
怎么了?
我正在学习C++,因为它是一种非常灵活的语言.但对于像Twitter,Facebook,Delicious等互联网来说,Python似乎是一个更好的解决方案.
是否可以在同一个项目中集成C++和Python?
我正在尝试将functionJavascript 转换为CoffeeScript.这是代码:
function convert(num1, num2, num3) {
return num1 + num2 * num3;
}
Run Code Online (Sandbox Code Playgroud)
但是我怎么能在CoffeeScript中做到这一点?
我正在尝试从这样的HTML源运行该函数:
<script type="text/javascript" src="../coffee/convert.js"></script>
<script type="text/javascript">
convert(6, 3, 10);
</script>
Run Code Online (Sandbox Code Playgroud)
但它不起作用,我得到一个错误说: ReferenceError: Can't find variable: convert
怎么纠正这个?
我正在尝试使用以下方式开始提供一些静态网页connect:
var connect = require("connect");
var nowjs = require("now");
var io = require("socket.io");
var app = connect.createServer(
connect.static(__dirname + '/public')
);
app.listen(8180);
Run Code Online (Sandbox Code Playgroud)
所以我在文件所在的同一目录index.html下的/public目录中添加了一个简单的app.js文件,但是当我尝试在浏览器上查看该页面时,我从节点获得了这个响应:
不能获取 /
我做错了什么以及如何纠正它?
我的一个新的家庭项目将是一个简单的窗口管理器,但在开始之前我需要知道一些事情:
javascript ×2
node.js ×2
bash ×1
bit.ly ×1
c++ ×1
coffeescript ×1
connect ×1
exit ×1
file-io ×1
flex-lexer ×1
http ×1
integration ×1
linux ×1
python ×1
seaside ×1
shell ×1
short-url ×1
smalltalk ×1
url ×1
web-services ×1
x11 ×1
xcode ×1
xcode4 ×1