tcsh does some strange things, if you are using variables (in the example h in a one line while loop.
set h = 1; echo $h; while ( $h != 0 ) ; echo "Input please" ; set h = $< ; echo $h ; end ;
while? end
Input please
4
4
1
Input please
5
5
1
tcsh does some strange things, if you are using variables (in the example h in a one line while loop.
set h = 1; echo $h; while ( $h != 0 ) ; echo "Input please" ; set h = $< ; echo $h ; end ;
while? end
Input please
4
4
1
Input please
5
5
1
While using the default JavaScript functions escape/unescape to (un)escape strings for url parameters, you'll run into issues, since JavaScript threats + as valid character and so on.
At PHPBuilder-Forums I found an
implementation, which does not work, since it only replaces the first + and leaves all other unchanged. That is very much wrong.
A fixed, and working implementation for urlencode can be found here:
function urlencode(str) {
str = escape(str);
str = str.replace(/\\+/g,'%2B');
str = str.replace(/\\%20/g,'+');
str = str.replace(/\\*/g,'%2A');
str = str.replace(/\\//g,'%2F');
str = str.replace(/\\@/g,'%40');
return str;
}
Today I noticed that JavaScript doesn't provide an easy way to make/raise custom exceptions? while still providing an useful stacktrace.
Here is a code snippet used for the
GTA:T JavaScript interface to find the fitting stacktrace for a custom JavaScript Exception.
function Exception(name,msg) {
try {
throw new Error("")
} catch (e) {
e.stack = e.stack.split("@"+e.fileName+":").join(":");
full_stack = e.stack.split("\\n");
stack = [];
stack[0] = "Exception: "+name+"(\""+msg+"\")"
for (var i=2;i<full_stack.length-3;i++) {
entry = full_stack[i];
entry_detailed = entry.split(":");
entry_detailed[1] = entry_detailed[1] - 4; // THIS is to
// mark, that we'll "move" the source 4 lines higher,
// ... because it's eval code executed. Remove that for
// clear values.
if (i==2) lineNumber = entry_detailed[1];
stack[i] = entry_detailed.join(":");
}
return {
name:name,
message:msg,
stack:stack.join("\\n"),
lineNumber:lineNumber
};
}
}
You may use it that way:
try {
function a() {
throw new Exception("MyException","No permission!")
}
function b() {
a()
}
b()
} catch (e) {
alert(e.name+": "+e.message);
}
// Tested in Firefox
/* e:
Object {
[name] => MyException
[message] => No permission!
[stack] => Exception: MyException("No permission!")
a():3
b():6
execute():10
[lineNumber] => 3
}*/
Its quite simple to implement the function, you may know from
php, which concats all elements from an array as string and puts a seperator between those.
The following code snippet, takes all elements from inputArray (e.g. 1 2 and 3) and concat them to "1,2,3" and saves this into AsImplodedString.
String AsImplodedString;
if (inputArray.length==0) {
AsImplodedString = "";
} else {
StringBuffer sb = new StringBuffer();
sb.append(inputArray[0]);
for (int i=1;i<inputArray.length;i++) {
sb.append(",");
sb.append(inputArray[i]);
}
AsImplodedString = sb.toString();
}
This implementation uses a StringBuffer to be faster with big arrays.
While I performed apt-get dist-upgrade on my debian machine, to update from Etch to Lenny I had the issue, that the HAL-package was not able to be upgraded (which caused some other parts of debian not to be able to be upgraded).
I found out how to fix that problem, since I noticed that hal wasn't started properly.
If HAL hangs on upgrade, press CTRL+C to stop apt-get. Then type:
/etc/ini.d/dbus restart
And after that do the following again:
apt-get dist-upgrade
Now everything should work fine.