Archiv

Archiv für Oktober, 2011

Applescript for generating Random UUID

31. Oktober 2011 1 Kommentar

I wrote my first Applescript today and I thought it could be useful, so I decided to share it with you :)

This script generates a random UUID and copies it to the clipboard.

set the clipboard to (do shell script "python  -c 'import uuid; print uuid.uuid1()'")
KategorienMac OS X Tags:

Allowed Characters for Javascript Variables

20. Oktober 2011 Keine Kommentare

I am playing with the JDK Javascript API (JSR 223) and I wanted to check out the replacement of variables in a String. Then I suddenly got this error:

javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: missing ; before statement (<Unknown source>#1) in <Unknown source> at line number 1

After some reseach I found out, that my variables did contain invalid characters in my case the variable contained a -.


So the Regular Expression for valid Javascript variable names is:

[a-zA-Z_$][0-9a-zA-Z_$]*

It is also possible to use any unicode characters for variables, but of course this is not recommended.