In my scriptable Mac app, I like to make the following syntax possible:
set preference with key <a key> to <a value>
Is that possible? How would I specify this in the Sdef?
The only way I can so far come up with is to define a command with the name set preference with key, but Apple's Scripting Interface Guidelines says that one should not begin a command with a reserved name such as set is here. Is there any other way? Or is it safe to use my idea in this case?
Currently, I avoid this by instead using this, but I don't like that syntax as much as I'd like the more common "set" terminology:
write preference with key <a key> value <a value>
Better suggestions are welcome.
Related
Is there a way to differenciate variable declaration and variable use by using two different colors with Sublime Text 2 syntax highlighting ?
Here is an example of what I'm trying to do : (screenshot from jsFiddle)
I didn't find anything helpful in any of the Sublime Text 2 color schemes xml files and on the web either. Is what I'm trying to do even possible ?
This is only possible if the syntax definition scopes the variable declarations differently to the uses. The JavaScript syntax that ships with ST doesn't do so.
Therefore, unless you alter the syntax definition, there is no way to change the color scheme to achieve what you want.
If you upgrade to ST3, you could update the syntax so that after it scopes the var keyword, it could push into another context where it would expect an identifier, and scope that uniquely. See the sublime-syntax documentation for details.
I have a site that will print out an article details to the user screen if the article has content.
So I am using
<#if article[0]?has_content>
Then the commands to display the content.
However if the article does not have content I want the screen to display something along the lines of 'The article contains no content'.
I am unsure of the best way to proceed with this, with best practise and what is the most efficient way.
Should I turn my if statement into a simple if-else statement? Or write a seperate if statement along the lines of -
<#if !article[0]?has_content>
(Im unsure of the placement of the !)
Thanks
An <#else> would be more efficient, and more straightforward.
Is it possible to display something other than the definition name in the variables view in Flex Builder for special types?
Basically, what I'd like to do is display the value of a complex member type instead of just showing it's qualified type name. Take a look at the following image:
(source: brightworks.com)
In the second column you can see the value of the member in the first column. What I'd like to to is to somehow make Flex Builder write an arbitrary string instead of foo.bar.MyClass (#0123456), is this possible?
There isn't a configuration setting in FlexBuilder (that I know of) so the only way I can think of to do it would be to replace whatever Java classes in Flex Builder plugin that deal with the variables pane and the debug output with custom ones that you've written to do what you are looking for. Since it's closed source it would have to be a clean room implementation, which would be tough. I've seen some examples of people replacing the java classes in Flex Builder to fix bugs (example) so it's not impossible to do if you have the time and knowledge.
I've got a situation where I need to alter the contents of a cached file based off of one of the query string arguments passed in. I'd love to use sed to do a simple regular expression replacement of a value based off of said argument but I can't figure that one out. I could use a ruby script to do the replacement for me but can't seem to access the query string for the request within the script. The documents for mod_ext_filter say:
In addition to the standard CGI environment variables, DOCUMENT_URI, DOCUMENT_PATH_INFO, and QUERY_STRING_UNESCAPED will also be set for the program.
Um yeah, can't seem to access those.
Has anybody any experience with this or does anybody have a better solution?
Doh! Looks like I simply need to access the ENV variable within ruby. Pretty dumb of me.
Using PHP scripting language server function we can able to get the query string values.
echo $_SERVER['REQUEST_URI'];
And pass the URL arguments as a variable to the file and make it dynamic.
Refer : PHP.net
I am writing my own shell and need to implement a history feature where up and down arrow keys show history of commands executed. I need to find out when up and down keys are pressed.
How do i do this?
you want to be capturing input in raw mode. this can get kinda complicated, but here's an example that should get you on the right path:
http://docs.linux.cz/programming/c/unix_examples/raw.html
i'm assuming you're writing your shell in c. if you're using a more high-level language, there might be an easy way to get raw input. in python, for instance, i would use the ncurses module.