escaping

Can't pass a script block as a parameter to powershell.exe via -Command

不羁岁月 提交于 2019-12-04 19:39:54
I'm trying this $Global:commandBlock={ Start-Transcript -path $projectFolder\gruntLog.txt; grunt $argList; Stop-Transcript } $cmdProc=start-process powershell -ArgumentList ('-command `$Global:commandBlock') -WorkingDirectory $fwd -PassThru -NoNewWindow:$NoNewWindow And keep getting $commandBlock : The term '$Global:commandBlock' is not recognized as the name of a cmdlet, function, script file, or operable program. My guess was it has to do with scope. But making variable global didn't help. Adding -args $commandBlock like that: -ArgumentList ('-command `$Global:commandBlock -args "

Read escaped quote as escaped quote from xml

爷,独闯天下 提交于 2019-12-04 19:27:12
I load xml file into DOM model and analyze it. The code for that is: public class MyTest { public static void main(String[] args) { Document doc = XMLUtils.fileToDom("MyTest.xml");//Loads xml data to DOM Element rootElement = doc.getDocumentElement(); NodeList nodes = rootElement.getChildNodes(); Node child1 = nodes.item(1); Node child2 = nodes.item(3); String str1 = child1.getTextContent(); String str2 = child2.getTextContent(); if(str1 != null){ System.out.println(str1.equals(str2)); } System.out.println(); System.out.println(str1); System.out.println(str2); } } MyTest.xml <tests> <test name

Use bash variable in AWK expression

限于喜欢 提交于 2019-12-04 19:12:30
问题 I tried the following snippet in a shell script but awk didn't find $REF REF=SEARCH_TEXT echo "some text" | awk '/$REF/{print $2}' 回答1: You question is worded really poor... Anyway, I think you want this: REF=SEARCH_TEXT echo "some text" | awk "/$REF/{print \$2}" Note the escaping of $2 and the double quotes. or this: REF=SEARCH_TEXT echo "some text" | awk "/$REF/"'{print $2}' Note the judicious use of double and single quotes and no escaping on $2 . You have to use shell expansion, as

Ormlite escape string method?

一笑奈何 提交于 2019-12-04 18:54:27
问题 Is there a native way of escaping strings for Ormlite for Android? For example, if I want to supply a string: ormlite's escape func, it needs to be supplied as ormlite\'s escape func. TestDao.queryForFirst(TestDao.queryBuilder().where().like("stats", stats) .prepare()) I tried using UpdateBuilder's escapeValue method, but it only makes the following change: 'ormlite's escape func'. It adds single quotes to beginning and end of the statement. Is there a native support for escaping strings to

Enable bash output color with Lua script

谁说我不能喝 提交于 2019-12-04 18:37:15
问题 I have several Lua scripts that run experiences and output a lot of information, in text files and in the console. I'd like to add some colors in the console output, to make it more readable. I know that it's possible to color the output of bash scripts using the ANSI escape sequences. For example : $ echo -e "This is red->\e[00;31mRED\e[00m" I tried to do the same in Lua : $ lua -e "io.write('This is red->\\e[00;31mRED\\e[00m\n')" but it does not work. I also tried with print() instead of io

find in directory that starts with dash

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 18:32:00
问题 find interprets a dash at the start of a filename as the start of an option. Using the familiar -- trick doesn't work since options are after the filename, quoting has no effect, and replacing the first dash with \- doesn't work either. Users are often encouraged to precede such filenames with ./ , but what can I do if I don't know whether the given path will be absolute or relative? Edit: One solution is to find "$(readlink -f -- "$test_filename")" , but it's ugly. Any better ideas? Edit 2 :

What is the difference between a single and double escape (backslash) in Javascript string?

此生再无相见时 提交于 2019-12-04 18:13:32
After attempting to answer the question to this post Another SO post I noted that this Function('return "\\101\\40\\171\\145\\154\\154\\157\\167\\40\\142\\165\\164\\164\\157\\156\\56"')() or Function('return "\101\40\171\145\154\154\157\167\40\142\165\164\164\157\156\56"')() both return the same string - "A yellow button." In regards to the question I linked to above, the JS code snippet is run in a tag. I have also noted in the past that when working on some JSON strings, that the '\' was needed over '\' When is it necessary? Why is it necessary? If it is not necessary, then why is it done?

When is it required to escape characters in XML?

不问归期 提交于 2019-12-04 18:07:48
问题 When should we replace < > & " ' in XML to characters like &lt etc. My understanding is that it's just to make sure that if the content part of XML has > < the parser will not treat is start or end of a tag. Also, if I have a XML like: <hello>mor>ning<hello> should this be replaced to either: &lthello&gtmor&gtning&lthello&gt &lthello&gtmor>ning&lthello&gt <hello>mor&gtning<hello> I don't understand why replacing is needed. When exactly is it required and what exactly (tags or text) should be

Forcing HTML Escaping in Rails 3

…衆ロ難τιáo~ 提交于 2019-12-04 17:49:32
问题 I'm running into an issue with the rails auto-escaping. It currently thinks a string is html_safe (which it is), but for display purposes I need it to still escape the html. Here's the steps the string is taking. my_string = render(:partial => "set_string", :locals => {:item => @item}) <%= my_string %> and the partial is basically <h2>Page Header</h2> <strong><%= item.name %></strong> <%= item.body %> etc My understanding is that because I'm displaying text in a view directly (the h2, etc) it

Does Facebook support Hash Bang #! Ajax Crawlable Urls?

99封情书 提交于 2019-12-04 17:46:00
问题 Does Facebook support Google's ajax crawling specification and, if so, what do you need to do to implement it? I am trying to get the Facebook "Like" button to work with AJAX crawlable urls as defined here: code.google.com/web/ajaxcrawling/docs/specification.html I have this url which I can go to directly and it loads. Note the "#!" in the url: http://www.idkshouldi.com/?#!idkDetails_idkKey