<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<style type="text/css">
body {background: #fff;}
</style>
</head>
<body>
<h1>Hello World</h1>
<script type="text/python" src="test.py"/>
<script type="text/javascript">
window.onload=function(){
alert("python: " + hello());
}
</script>
</body>
</html>
test.py
#!/usr/bin/env python
def hello():
return "hello"
In TideSDK develop says:
[Error] An error occured while paring Python on the page:invalid syntax ,('',2,1,'\r\n')
but this worked!! Why?
<script type="text/python">
def hello():
return "hello"
</script>
<script type="text/javascript">
window.onload=function(){
alert("python: " + hello());
}
</script>
I am new to TideSDK, my pc is WIN7 x86 with python2.7.3, TideSDK 1.3.1-beta installed,
I have no idea of this problem,Please help.
And I tried change test.py encoding,that's not help
We are working on this problem. The newer php we are planning to release with 1.3.2-beta should fix this problem.
I have the same issue. Unfortunately, I have yet to find the best fix. However implementing the source code in every html file is completely out of the question for me.
The error is complaining about the line endings. I presume are working in windows like I am, so the line endings are as follows: \r\n. TideSDK wrote a some sort of parser for external python files, but completely neglected windows line ending for whichever reason (and maintained unix style line endings). The \r\n is coming up as strange unparsable grammer and stops reading the rest of the file. Until they fix this glitch, I can only see one option. Change your line endings for all external python files from \r\n to \n.
You can do this either with your favorite IDE if it supports new line replacement. Or if it doesn't support changing your newlines, then you can use a python file to replace all of them like so:
fn = 'main.py'
with file(fn, 'rb') as f:
data = f.read()
with file(fn, 'wb') as f:
f.write(data.replace('\r\n', '\n'))
However, if you choose the second route you will be forced to run this script every time you save the file.
If I find a better answer I will let you know.
Try removing the #! line from the python file, it's not really useful for TideSDK anyway.
The issue for me was having empty lines before the def action():
I had an import that came first but it didn't seem to like the empty line before the def
I ran into this problem while using eclipse on Windows. It appears TideSDK python interpreter requires Unix style line delimiters (i.e. the non-printable character(s) that tell the computer to put text on a new line)
Windows uses two characters "\r\n" (carriage-return and line-feed) where as unix uses just the line feed character. So, if you are using a text editor on Widows, most likely it will insert "\r\n" every time you hit "enter" or "return".
If you are using Eclipse as your text editor, the fix is
File -> Convert Line Delimiters To
and select Unix.
To make the text editor do this for all new files, select "Other" and "Unix" in
Window -> Preferences -> General -> Workspace -> New text file line delimiter.
Hope this helps
Related
I have recently adding a fix for atom-script package to resolve garbled text output in compile&run Java code in non-English Windows environment. (Issue #1166, PR #2471)
After this, now in release script package 3.32.1, javac has options -J-Dfile.encoding=UTF-8 and -encoding UTF-8 both. (diff is here) I have just realized that it is better to provide actual encoding of the current active editor which holds the target source code for -encoding option. After some research, I have learnt that the encoding can be acquired by
atom.workspace.getActiveTextEditor().getEncoding()
but, after I have tested in Japanese edition Windows, it returns shiftjis and this is not valid encoding name for javac command line option. (It should be MS932, SJIS or something similar.) I have no idea where I can get this type of encoding names without writing large conversion table for all possible encoding names. Is there any good utility for such purpose?
EDIT:
For demonstrating what I have supposed to do, I have created branch on my fork. Diff is here.
Getting current source code editor encoding by
const fileEncoding = getJavaTextEncodingName(atom.workspace.getActiveTextEditor().getEncoding())
and pass it to javac via
const cmd = `javac -encoding ${fileEncoding} -J-Dfile.encoding=UTF-8 -Xlint -sourcepath '${sourcePath}' -d '${tempFolder}' '${filepath}' && java -Dfile.encoding=UTF-8 -cp '${tempFolder}' ${classPackages}${className}`
And, function "getJavaTextEncodingName()" is the core of the question.
function getJavaTextEncodingName(atomTextEncodingName) {
switch (atomTextEncodingName) {
case "shiftjis" :
return "MS932"
}
return "UTF-8"
}
It is obvious that this is converting "shiftjis" to "MS932" but, it is not so beautiful if we implement all possible encoding name conversions here, so I am seeking better alternative.
I want to run simple go code directly from terminal/command line. For example:
go run "
package main
func main() {
println("hello")
}
"
hello
However golang allows code execution only from file. So maybe there are some ways how to emulate it? Like this:
go run file.go < echo "...."
But there should be no files after actions above.
In command-line, only a project like go-repl would compile/run a multi-line go source code without leaving any .go file behind.
An alternative: gore:
$ gore
Enter one or more lines and hit ctrl-D
func test() string {return "hello"}
println(test())
^D
---------------------------------
hello
(Other repl-like solution are listed in "Does Go provide REPL?")
Or you would need to develop a go wrapper which would internally create a source code and go run it, before deleting it.
Ubuntu has a gorun tool which works well for small scripts. It compiles scripts on the fly, caching the binaries in /tmp.
https://wiki.ubuntu.com/gorun
Although it's intended for scripting and not as a REPL, you could use it in various ways.
Although gorun has come from the Ubuntu community, it should work on any Linux distro because it uses vanilla Go source code via
$ go get launchpad.net/gorun
In my Qt application my source code files are encoded as UTF-8. For the following code...
QMessageBox::critical(this, "Nepoznata pogreška", "Dogodila se nepoznata pogreška! Želite li zatvoriti ovaj program ?", QMessageBox::Yes, QMessageBox::No);
...when I show that message box, the character "š" wouldn't be displayed as "š", but as something strange. This is because Qt converts all C-strings as if they are encoded using LATIN-1. To solve this I've been using:
QMessageBox::critical(this, QString::fromUtf8("Nepoznata pogreška"), QString::fromUtf8("Dogodila se nepoznata pogreška! Želite li zatvoriti ovaj program ?"), QMessageBox::Yes, QMessageBox::No);
Is there a way to get rid of all the calls to QString::fromUtf8()?
Have you tried using QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"))?
setCodecForCStrings() had been deprecated.
Try instead,
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
It worked for me.
Regarding the "guess" that "Qt5 assumes all source files are UTF-8 encoded": Thiago Macieira explains the decision made by Qt's developers here.
The assumption can be disabled with QT_NO_CAST_FROM_ASCII according to the documentation.
I recently switched from Aptana2 to version3.0.3, and the first thing i did was to install the sdomcl. file to get jQuery code assist.It works fine for jQuery, but there is no code assist for many keywords.For exymple there is no support for var,while,throw,try,break,case,catch etc.
Also there is no function, instead intellisense sugests Function.
The second problem is that i am constantly getting this warning '<' + '/' +letter not allowed here when typing something valid like this:
confirmDiv =$("")-sorry for this,but it wont let me type what i want, basically i am just creating a new div with the correct syntax.
Could it be something with Html Tidy?Anyways, big thanks in advance!
Aptana Studio 3.0.4 includes code assist for JavaScript keywords.
I've read that for Javascript the slashes / must be escaped with backslashes \ as it says here
Doing so the warning dissapears ;)
I have a compressed CSS file (all whitespace removed) that I want to inspect, but it's a huge pain inspecting it as-is. Is there any utility (preferably linux command line) that I can run the file through to format it nicely?
The online service that Dave Newman mentioned has been converted into a Node.js script, which you can run on the command-line. If you have NPM installed you can just do:
npm install -g cssunminifier
And it’s pretty versatile how you can use it. Here are 3 different examples:
cssunminifier style.min.css style.css
cssunminifier --width=8 style.min.css
curl http://cdn.sstatic.net/stackoverflow/all.css | cssunminifier - | less
Here’s more info on the command-line css unminifier
Try this online service.
You can also inspect any compressed file in Firebug.
I wrote a little formatter in Ruby for you. Save it as some .rb file and use it via CLI like ruby format.rb input.css input-clean.css:
#Formats CSS
input, output = ARGV
#Input
if input == nil or output == nil
puts "Syntax: #{$0} [input] [output]"
exit
end
#Opens file
unless File.exist? input
puts "File #{input} doesn't exist."
exit
end
#Reads file
input = File.read input
#Creates output file
output = File.new output, "w+"
#Processes input
input = input.gsub("{", "\n{\n\t")
.gsub(",", ", ")
.gsub(";", ";\n\t")
.gsub(/\t?}/, "}\n\n\n")
.gsub(/\t([^:]+):/, "\t" + '\1: ')
#Writes output
output.write input
#Closes output
output.close
These programs are called 'beautifiers'. You should be able to google one that fits for you.
If you're looking for a locally-executable utility, as opposed to a web service, you want CSS Tidy.
This also indents: styleneat
Here's a free windows app to "beautify" your file. I haven't used it so I don't know how well it works.
http://www.blumentals.net/csstool/
It is specific, but Visual Studio does this on that file type. (by no means a generic solution to which you alude)
take a look at the vkBeautify plugin
http://www.eslinstructor.net/vkbeautify/
It can beautify (pretty print) CSS, XML and JSON text,
written in plain javascript, small, simple and fast