Removing brackets from fully qualified table name using Toad - toad

I've just recently installed Toad and I'm trying to change the settings around because one thing I like doing is adding square brackets around the fully qualified table names since it's easier to look at for me, but when I type a fully qualified name, Toad auto-completes it and removes the brackets, eg:
[DB].[schema].[table]
becomes:
DB.schema.table
So, is there a way around the auto complete feature removing these brackets? I couldn't find anything in the settings.

Related

What is the name for the type of "loose" search/filter that allows for other characters in the middle?

I'm not sure which community this belongs in, feel free to suggest a better one if this doesn't fit here.
In Visual Studio Code, when searching for a file, you can CMD/Ctrl + P to bring up the Quick Open search box for finding a file by name. The search doesn't have to be the exact name and it filters as long as the search query contains the characters in that order, while being "loose" enough to ignore any characters between those.
Example:
Searching "cat" would show the following:
bigcat.txt
cat.txt
candlelight.txt
In the above, all the strings contain "cat" within it, even if there are other characters between it. The regex would probably be something like /.*c.*a.*t.*/.
Is there a name for this type of search/filter?
Fuzzy Filter/Search
After looking through VS Code's GitHub issues list, I found an issue that mentioned it.
I also found a node module that does this exact same thing.
There is also a Wikipedia entry on Approximate String Matching, which is similar to the above.

Use reserved keyword as alias in doctrine query builder

$em->createQueryBuilder()
->select("MIN(m.price) AS min")
->addSelect('MAX(m.price) AS max')
->from('AppBundle:Sites', 'm');`
How can I escape min to make this work? I tried to change min Alias to something like _min instead but there should be a better way.
I tried both single quotes and backticks but neither worked.
You won't be able to use min or max as an alias since it is simply not available with the current grammar of the DQL. You can find this info in the section of the documentation that is defining the grammar of DQL. There you will find out the following:
In Select Expressions:
SimpleSelectExpression ::= (...) [["AS"] AliasResultVariable]
In Identifiers:
/* Alias ResultVariable declaration (the "total" of "COUNT(*) AS total") */
AliasResultVariable = identifier
And eventually, in Terminals:
identifier (name, email, …) must match [a-z_][a-z0-9_]*
As you can see, there is nothing in there to help you escape your keyword in anyway. Thus, as it is, when stumbling upon min, the Lexer will identify it as the MIN function (see this section of the code) and not as an identifier, hence the error.
Long story short, you will have to either rely on a native query or use an alias name that is not one of the reserved keywords listed here.
Note: Doctrine allows you to implement your own quoting strategy as discussed in this post but the issue is unrelated. Here, the problem with your alias is that it is matched as a function by the DQL parser which is unexpected at this position.
Using Mysql, you could escape it using the backtick `min`
Using Postgres, you could escape it using the doublequote "min"
You can use another word like minimum as an alias to avoid being database dependant

How to fix contacts whose First names were saved as Last names?

I'm trying to fix someone else's contacts (which I retrieved from their phone), but it seems that many, many contacts have their First names also written in the Last name field. Probably the phone was asking in turn for each piece of information and the Last name was the first.
Could someone please help me sort this database? I can export from Address Book a large .vcf, which I can open in Text Wrangler, but the application is quite new to me and I don't think Excel (can't use it with vcf) formulas help.
I haven't used Text Wrangler much but tried to look in the manual. Since I couldn't find something through "search", I gave up skimming the manual.
Could someone please help me make Text Wrangler detect the space between the first and last names and move the last name, if it's the case, before a semicolon?
Edit: There also are some cards without last names, but, again, the first name is written instead in there. So if there is one word (name) in the last name field, it should be moved instead to first name. If there are two (names/words separated by a space), then the first should be moved in another label.
This is what one such card (first name in last name)
BEGIN:VCARD
VERSION:3.0
N:Alex Instal;;;;
FN:Alex Instal
TEL;type=CELL;type=pref:nananana
X-ABUID:F9246772-nana-nana-nnana-nananana\:ABPerson
END:VCARD
And a correctly formatted one
BEGIN:VCARD
VERSION:3.0
N:Reynold;Adrian;;;
FN:Adrian Reynold
TEL;type=CELL;type=pref:nananan
X-ABUID:221697DB-3960-nana-nana-nanananana\:ABPerson
END:VCARD
Here is a regular expression with back-references that will work for the Alex Instal case you described. First make sure that the grep option on the TextWrangler search dialog is checked. Search for this:
^N:(\w*)(\s)(\w*);;;;$
and replace with this:
N:\1;\3;;;
Whether this will work for you of course depends on how consistent your file format is and whether there are any special cases like middle names, etc. But this will at least work for the case described and you could tweak it if necessary.

Highlighting Javascript Inline Block Comments in Vim

Background
I use JScript (Microsoft's ECMAScript implementation) for a lot of Windows system administration needs. This means I use a lot of ActiveX (Automated COM) objects. The methods of these objects often expect Number or Boolean arguments. For example:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:\\testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();
(CreateTextFile Method on MSDN)
On the second line you see that the second argument is one that I'm talking about. A Boolean of "true" doesn't really describe how the method's behavior will change. This isn't a problem for me, but my automation-shy coworkers are easily spooked. Not knowing what an argument does spooks them. Unfortunately a long list of constants (not real constants, of course, since current JScript versions don't support them) will also spook them. So I've taken to documenting some of these basic function calls with inline block comments. The second line in the above example would be written as such:
var a = fso.CreateTextFile("c:\\testfile.txt", /*overwrite*/ true, /*unicode*/ false);
That ends up with a small syntax highlighting dilemma for me, though. I like my comments highlighted vibrantly; both block and line comments. These tiny inline block comments mean little to me, personally, however. I'd like to highlight those particular comments in a more muted fashion (light gray on white, for example). Which brings me to my dilemma.
Dilemma
I'd like to override the default syntax highlighting for block comments when both the beginning and end marks are on the same line. Ideally this is done solely in my vimrc file, and not in a superseding personal copy of the javascript.vim syntax. My initial attempt is pathetic:
hi inlineComment guifg=#bbbbbb
match inlineComment "\/\*.*\*\/"
Straight away you can see the first problem with this regular expression pattern is that it's a greedy search. It's going to match from the first "/*" to the last "*/" on the line, meaning everything between two inline block comments will get this highlight style as well. I can fix that, but I'm really not sure how to deal with my second concern.
Comments can't be defined inside of String literals in ECMAScript. So this syntax highlighting will override String highlighting as well. I've never had a problem with this in system administration scripts, but it does often bite me when I'm examining the source of many javascript libraries intended for browsers (less.js for example).
What regex pattern, syntax definition, or other solution would the amazing StackOverflow community recommend to restore my vimrc zen?
I'm not sure, but from your description it sounds like you don't need a new syntax definition. Vim syntax files usually let you override a particular syntax item with your own choice of highlighting. In this case, the item you want is called javaScriptComment, so a command like this will set its highlighting:-
hi javaScriptComment guifg=#bbbbbb
but you have to do this in your .vimrc file (or somewhere that's sourced from there), so it's evaluated before the syntax file. The syntax file uses the highlight default command, so the syntax file's choice of highlighting only affects syntax items with no highlighting set. See :help :hi-default for more details on that. BTW, it only works on Vim 5.8 and later.
The above command will change all inline /* */ comments, and leave // line comments with their default setting, because line comments are a different syntax item (javaScriptLineComment). You can find the names of all these groups by looking at the javascript.vim file. (The easiest way to do this is :e $VIMRUNTIME/syntax/javascript.vim .)
If you only want to change some inline comments, it's a little more complicated, but still easy to see what to do by looking at javascript.vim . If you do that, you can see that block comments are defined like this:-
syn region javaScriptComment start="/\*" end="\*/" contains=#Spell,javaScriptCommentTodo
See that you can use separate regexes for begin and end markers: you don't need to worry about matching the stuff in between with non-greedy quantifiers, or anything like that. To have a syntax item that works similarly but only on one line, try adding the oneline option (:h :syn-oneline for more details):-
syn region myOnelineComment start="/\*" end="\*/" oneline
I've removed the two contains groups because (1) if you're only using it for parameter names, you probably don't want spell-checking turned on inside these comments, and (2) contained sections that aren't oneline override the oneline in the container region, so you would still match all TODO comments with this region.
You can define this new kind of comment region in your .vimrc, and set the highlighting how you like: it looks like you already know how to do that, so I won't go into more details on that. I haven't tried out this particular example, so you may still need a bit of fiddling to make it work. Give it a try and let me know how it goes.
Why don't you simply add a comment line above the call?
I think that
// fso.CreateTextFile(filename:String, overwrite:Boolean, unicode:Boolean)
var a = fso.CreateTextFile("c:\\testfile.txt", true, false);
is a lot more readable and informative than
var a = fso.CreateTextFile("c:\\testfile.txt", /*overwrite*/ true, /*unicode*/ false);

vim, ctags, and identically named identifiers

vim + ctags works well for C projects, since C does not allow function overloading and, in general encourages manual prefixing of symbols due to rudimentary scoping facilities.
In C++, functions are frequently overloaded, and overridden in subclasses. This makes vim always jump to the tag in the wrong class on "Ctrl + ]". Is there a way to make it behave a little more intelligently? I know I can bring a list with tag alternatives, but that's insanely annoying to always have to bring up this list, and find a needed tag by number whenever I want to jump to definition.
There is also "tagNext" to move to the next tag (or :tn<enter>)
I use tjump a lot. It supports tab completion which is helpful. If multiple tags are found, it will give a list for you to select from, if only one is found, it will jump right to the tag (unlike tselect).
Usage:
:tj foo
I know two workarounds for your porblem ( it seems you knew it too ):
Use :tselect and tag name or g] with cursor on tag for get list of matched tags and goto on tag by number from list;
map :tnext or :tprev on hotkeys ( I've mapped on F6 and F7 ) and find needed function manualy;
You can use my script which will help you to select tag you need by typing some letters of the class name or special tags like 'field', 'function', 'constructor', etc.
http://www.vim.org/scripts/script.php?script_id=2507