Match everythin between tag as comment - syntax-highlighting

I would like to highlight every thing between
!&
some explanation
&!
As a comment.
I know comment are match with
- name: comment.line.exclamation-mark.fortran
match: (?i)\!.*$
in my fortran.YAML-tmLanguage.
But I don't see how to extend this to the case above.

Since the comments are multiline, you need to split the regex into two expressions, one called begin and one called end.
This allows you to parse multiple lines.
I dont really use YAML, but this code from the C tmLanguage should get you started (Comment style is /* COMMENT */):
<dict>
<key>begin</key> <string>\s*/\*</string>
<key>captures</key>
<dict>
<key>0</key> <dict> <key>name</key>
<string>punctuation.definition.comment.c</string> </dict>
</dict>
<key>end</key> <string>\*/</string>
<key>name</key> <string>comment.block.c</string>
</dict>
So you could use \s\!\& for the begin-tag and \&\! for the end-tag.

I found the below work. Thanks #LinuCC.
# order matter: this block comment syntax should be before the line comment syntax
- name: comment.block.fortran
begin: (?i)\!&
end: (?i)&\!
captures:
'0': {name: comment.line.exclamation-mark.fortran}
- name: comment.line.exclamation-mark.fortran
match: (?i)\!.*$
To make comment toggling work you also need, in another file,
# [PackageDev] target_format: plist, ext: tmPreferences
---
name: Comments
uuid: 40e092f2-ee49-4cbd-8afb-4a5c4f581463
scope: source.fortran
settings:
shellVariables:
- name: TM_COMMENT_START
value: '! '
- name: TM_COMMENT_START_2
value: '!&'
- name: TM_COMMENT_END_2
value: '&!'

Related

Azure Pipelines - "While parsing a block mapping, did not find expected key" when setting variables

I have a strange problem that I can't seem to get my head around. I am trying to define some variables for use as part of the job that will deploy bicep files via Azure CLI and execute PowerShell tasks.
I get this validation error when I try and execute the pipeline: While parsing a block mapping, did not find expected key
The line that it refers to is: - name: managementResourceDNSPrivateResolverName
On the research that I have done on this problem, it sounds like an indentation problem but on the face of it, it seems to look fine.
jobs:
- job: 'Deploy_Management_Resources'
pool:
vmImage: ${{ parameters.buildAgent }}
variables:
- name: managementResourceDNSPrivateResolverName
value: 'acme-$[ lower(parameters['environmentCode']) ]-$[ lower(variables['resourceLocationShort']) ]-private-dns-resolver'
- name: managementResourceGroupManagement
value: 'acme-infrastructure-rg-management'
- name: managementResourceRouteTableName
value: 'acme-$[ lower(variables['subscriptionCode']) ]-$[ lower(variables['resourceLocationShort']) ]-route-table'
- name: managementResourceVirtualNetworkName
value: 'acme-$[ lower(variables['subscriptionCode']) ]-$[ lower(variables['resourceLocationShort']) ]-vnet-internal-mng'
Thanks!
The error message ...parsing a block mapping, did not find expected key is usually a side-effect of malformed yaml. You'll see if often with variables if you have mixed formats of arrays and property elements
variables: # an array of objects
# variable group reference object
- group: myvariablegroup
# variable template reference object
- template: my-variables.yml
# variable object
- name: myVariable
value: 'value1'
# variable shorthand syntax
myVariable: 'value1' # this fails because it's a property instead of an array element
While it doesn't appear that the sample you've provided is malformed, I am curious about the use of $[ ] which is a runtime expression. The expression $[ lower(parameters['environmentcode']) ] refers to parameters which is are only available at compile time.
Change:
$[ lower(parameters['environmentCode']) ] to ${{ lower(parameters.environmentCode) }}

how to retrieve user setting in iOS? [Xcode 7 + Swift 2]

I am using Xcode 7 + Swift 2.
I added a setting.bundle to the root of my app with a single text field.
Root.plist looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Controller Settings:</string>
</dict>
<dict>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Enter Text</string>
<key>Key</key>
<string>key</string>
<key>DefaultValue</key>
<string>Text</string>
<key>IsSecure</key>
<false/>
<key>KeyboardType</key>
<string>NumbersAndPunctuation</string>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
</dict>
</array>
</dict>
</plist>
I then try to:
Read the default value ("Text")
Change the text field in the iOS settings and then read the new String.
I used this two lines of code:
let settings = NSUserDefaults.standardUserDefaults()
let setting_value = settings.stringForKey("key")! as String
but all i get is this error and the app would not continue:
fatal error: unexpectedly found nil while unwrapping an Optional value
all I want is to read the setting and display the String to a label.
Thanks.
EDIT:
I Understand now that the error is because the value in not assigned yet.
to prevent the error I put 'if' before:
if let name = settings.stringForKey("key") {
print(name)
}
but how can I actually read the value inside "key"?

Alamofire request keeps coming nil

So I am testing my code to see if i get connection with my php service, but I am still getting nil with this simple code:
<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
?>
The php output is: {"a":1,"b":2,"c":3,"d":4,"e":5}
but when I try it in the app, xcode console shows nil as result.
My alamofire request is:
Alamofire.request(.GET,url).responseJSON{ _,_, result in
print(result.value)
}
I had to override Info.plist because the server I am using is http instead of https with the following:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>primefitness.hostoi.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
I am new to swift, and I got no idea on how to debug or track the request. Any suggestions?
EDIT:
I changed "mysite" to the actual site, to avoid confusions
The answer was simple, the hosting im using, uses an analitics javascript that was putting garbage to the end of my json, as stated by Ashish Kakkad, so i just disabled it.

How can I apply basic html formatting to a sublime text syntax definition only within

Ok so by the following yaml definition, shouldn't only what's in between {blah} and {!blah} get text.html.basic syntax highlighting? And the {blah} tags themselves take the highlighting of a comment? Unfortunately it's not happening that way. HTML highlighting is anywhere in the document, and {blah} doesn't get comment highlighting.
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Test
scopeName: source.test
fileTypes: [test]
uuid: 3631aac6-ee25-4ec1-ab08-39f156235363
patterns:
- name: comment.number-sign
begin: \{blah\}
end: \{\!blah\}
patterns:
- include: text.html.basic
match: .
...
Sample Code:
{blah}
<input type="text"/>
{!blah} <----- these are not styled according to comment.number-sign
<input type="text"/> <----- this also has HTML highlighting and I don't want it to
This should get you started:
# [PackageDev] target_format: plist, ext: tmLanguage
name: Test
scopeName: source.test
fileTypes: [test]
uuid: 3631aac6-ee25-4ec1-ab08-39f156235363
patterns:
- name: html.test
begin: (\{blah\})
beginCaptures:
'1': {name: comment.blah.test}
end: (\{!blah\})
endCaptures:
'1': {name: comment.blah.test}
patterns:
- include: text.html.basic
The name is the base scope for the entire selector. beginCaptures and endCaptures assign the comment.blah.test scope to the {blah} tags, while the include rule assigns HTML highlighting to whatever is between the begin and end tags.
Using the Neon Color Scheme (full disclosure: I'm its maintainer), a sample file looks like this:
As you can see, {blah} and {!blah} are in gray italics, the comment scope. Markup outside the {blah} tags is not highlighted at all, while that enclosed in the {blah} tags is highlighted as HTML.
For more on syntax definitions, check the tutorial and the reference at the unofficial docs.

Mac OSX 10.9.2, launchd error: "launchctl: Dubious ownership on file (skipping)"

I'm getting the same error launchctl: Dubious ownership on file (skipping): ~.plist
nothing found to load from running a launchctl load command in three different locations as follows, and none of them is working:
sudo launchctl load /Library/LaunchDaemons/updates.novel.plist
sudo launchctl load /Library/LaunchAgents/updates.novel.plist
sudo launchctl load /Users/username/Library/LaunchAgents/updates.novel.plist
Below is my updates.novel.plist file, could you please take a look and let me know what is the problem? thanks
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>GroupName</key>
<string>admin</string>
<key>UserName</key>
<string>Username</string>
<key>Debug</key>
<true/>
<key>Label</key>
<string>updates.novel</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/AMPPS/php-5.3/bin/php</string>
<string>/Applications/AMPPS/www/files/allnovels/novel.php</string>
<string>--daemon</string>
</array>
<key>StandardErrorPath</key>
<string>/var/log/files/error.1.log</string>
<key>StandardOutPath</key>
<string>/var/log/files/error.2.log</string>
<key>RunAtLoad</key>
<true/>
<key>AbandonProcessGroup</key>
<true/>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>14</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
launchd services need to be started by the user who owns the plist file. If the owner is not root, then the service must not be launched with sudo.
Also, the permissions on the file must deny write access to all users except the owner.
Finally, the file must be a regular file (ie not a pipe or a socket or anything else).
In man launchctl we can read:
Note that per-user configuration files (LaunchAgents) must be owned by the user loading them. All sytem-wide daemons (LaunchDaemons) must be owned by root. Configuration files must not be group- or world-writable. These restrictions are in place for security reasons.
This is how launchctl.c checks that:
bool path_goodness_check(const char *path, bool forceload) {
if (forceload) {
return true;
}
if (sb.st_mode & (S_IWOTH|S_IWGRP)) {
fprintf(stderr, "%s: Dubious permissions on file (skipping): %s\n", getprogname(), path);
return false;
}
if (sb.st_uid != 0 && sb.st_uid != getuid()) {
fprintf(stderr, "%s: Dubious ownership on file (skipping): %s\n", getprogname(), path);
return false;
}
if (!(S_ISREG(sb.st_mode) || S_ISDIR(sb.st_mode))) {
fprintf(stderr, "%s: Dubious path. Not a regular file or directory (skipping): %s\n", getprogname(), path);
return false;
}
if ((!S_ISDIR(sb.st_mode)) && (fnmatch("*.plist", path, FNM_CASEFOLD) == FNM_NOMATCH)) {
fprintf(stderr, "%s: Dubious file. Not of type .plist (skipping): %s\n", getprogname(), path);
return false;
}
return true;
}
So in other words, correct the ownership, permissions or path of your .plist file or force the loading (-F).

Resources