Change Sublime Text Bracket/Indent Rules - css

I'm trying to figure out how to change Sublime Texts auto bracket rules for css.
I get this by default:
.class {
#CURSOR
}
I would like to have this:
.class {
#CURSOR}
Any ideas on how to accomplish this?

You can add this shortcut to your Key Bindings - User:
{ "keys": ["enter"], "command": "insert", "args": {"characters": "\n\t"}, "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\{$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "source.css" }
]
}
to modify enter key behaviour with css files.
Or you can use a Snippet. Tools/New Snippet...:
<snippet>
<content><![CDATA[
{
${1}}
]]>
</content>
</snippet>
Save it as Packages/User/CSSBrackets.sublime-snippet.
Then, add a shortcut in your Key Bindings - User to trigger it when pressing { in css files:
{ "keys": ["{"], "command": "insert_snippet", "args": {"name": "Packages/User/CSSBrackets.sublime-snippet"},
"context":
[
{ "key": "selector", "operator": "equal", "operand": "source.css" }
]
}

Related

How to use ObjectSizeGreaterThan and ObjectSizeLessThan xml tags for AWS S3 command 'PutBucketLifeCycleConfiguration"?

Trying with a json input like this:
{
"Rules": [
{
"Expiration": {
"Date": "2023-01-01T00:00:00.000Z"
},
"ID": "id1",
"Filter": {
"And": {
"Tags": [
{
"Key": "k1",
"Value": "k1val1"
},
{
"Key": "k1u",
"Value": "k1vadl1"
}
],
"ObjectSizeGreaterThan": 100,
"ObjectSizeLessThan": 1000
}
},
"Status": "Enabled"
}
]
}
However, I am getting an error like this from the aws client:
Parameter validation failed:
Unknown parameter in LifecycleConfiguration.Rules[0].Filter.And: "ObjectSizeGreaterThan", must be one of: Prefix, Tags
Any idea why I get this error and how to correct it?
This seems to be working but only with the latest cli version aws-cli/2.7.30
I am getting the same error on aws-cli/1.19.39
{
"Rules": [
{
"Expiration": {
"Date": "2024-01-01T00:00:00.000Z"
},
"ID": "123",
"Filter": {
"And": {
"Prefix": "sricli",
"Tags": [
{
"Key": "ke",
"Value": "k1"
},
{
"Key": "je",
"Value": "k2"
}
],
"ObjectSizeGreaterThan": 102400,
"ObjectSizeLessThan": 204800
}
},
"Status": "Enabled"
}
]
}
Sri

Azure resource manager template - property loops is not working keep getting error as copyindex is not expected

I am trying to deploy the Arm template using the properties copy loop as per the documentation available https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/copy-properties for loadbalancer and its not working. Template validation failed error as " language Expression property 'protocol' cant be evaluated.
If I remove loadbalancer rules copy and try iterating the healthprobes property alone its working.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymenttemplate.json#",
"contentversion": "1.0.0.0",
"parameters": {
.......
"lbprobe": {
"type": "array",
"defaultValue": [
{
"name": "customAppPort",
"frontendPort": "8080",
"backendPort": "8888",
"protocolprobe": "tcp",
"protocol": "tcp"
},
{
"name": "httpsPort",
"frontendPort": "443",
"backendPort": "443",
"protocolprobe": "tcp",
"protocol": "tcp"
}
],
"metadata": {
"description": "description"
}
}
},
"functions": [],
"variables": {},
"resources": [
{
"name": "[parameters('lbname')]",
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2020-11-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard",
"tier": "Regional"
},
"properties": {
"frontendIPConfigurations": [
{
"name": "[parameters('lbfrontendip')]",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'testvnet-01', 'default')]"
}
}
}
],
"backendAddressPools": [
{
"name": "[parameters('lbbackendpool')]"
}
],
"copy": [
{
"name": "loadBalancingRules",
"count": "[length(parameters('lbprobe'))]",
"input": {
"name": "[parameters('lbprobe')[copyIndex('loadBalancingRules')].name]",
"properties": {
"frontendipconfiguration": {
"id": "[resourceid('microsoft.network/loadbalancers/frontendipconfigurations', parameters('lbname'), parameters('lbfrontendip'))]"
},
"backendaddresspool": {
"id": "[resourceid('microsoft.network/loadbalancers/backendaddresspools', parameters('lbname'), parameters('lbbackendpool'))]"
},
"protocol": "[parameters('lbprobe')[copyIndex('loadBalancingRules').protocol]]",
"frontendport": "[parameters('lbprobe')[copyIndex('loadBalancingRules').frontendPort]]",
"backendport": "[parameters('lbprobe')[copyIndex('loadBalancingRules').backendPort]]",
"enablefloatingip": false,
"idletimeoutinminutes": 5,
"probe": {
"id": "[resourceid('microsoft.network/loadbalancers/probes', parameters('lbname'),parameters('lbprobe')[copyIndex('loadBalancingRules')].name)]"
}
}
}
},
{
"name": "Probes",
"count": "[length(parameters('lbprobe'))]",
"input": {
"name": "[parameters('lbprobe')[copyIndex('Probes')].name]",
"properties": {
"protocol": "[parameters('lbprobe')[copyIndex('Probes')].protocolprobe]",
"port": "[parameters('lbprobe')[copyIndex('Probes')].frontendPort]",
"intervalInSeconds": 5,
"numberOfProbes": 2
}
}
}
]
}
}
],
"outputs": {}
}
We have tried the same code and can able to reproduce the above issue and identify the root cause.
Error Details:-
In your template in copy loadBalancingRules you are using the below:
"protocol": "[parameters('lbprobe')[copyIndex('loadBalancingRules').protocol]]",
"frontendport": "[parameters('lbprobe')[copyIndex('loadBalancingRules').frontendPort]]",
"backendport": "[parameters('lbprobe')[copyIndex('loadBalancingRules').backendPort]]",
Instead you should use the below:
"protocol": "[parameters('lbprobe')[copyIndex('loadBalancingRules')].protocol]",
"frontendport": "[parameters('lbprobe')[copyIndex('loadBalancingRules')].frontendPort]",
"backendport": "[parameters('lbprobe')[copyIndex('loadBalancingRules')].backendPort]",
OUTPUT DETAILS:-

AWS Stepfunctions dynamodb States.Runtime catch fails

My Stepfunction is supposed to check whether an item exist in the dynamo. if it does, it needs to generate the presigned url, otherwise it has to update the dynamodb item.
When it matches the item, it works as expected where as it fails when dynamo getitem output is null fails with states.runtime error. It does not going through catch statement. appreciate any help.
Here is my code.
{ "Comment": "A Hello World example of the Amazon States Language using Pass states", "StartAt": "Hello", "States": {
"Hello": {
"Type": "Pass",
"Next": "Verify item from DynamoDB"
},
"s3_url": {
"Type": "Pass",
"Result": "Hello",
"End": true
},
"Verify item from DynamoDB": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "s3_table",
"Key": {
"etag": {
"S.$": "$.Records[0].s3.object.eTag"
}
}
},
"ResultPath": "$.DynamoDB",
"OutputPath": "$.DynamoDB.Item",
"Next": "s3_url",
"Catch": [
{
"ErrorEquals": [
"States.Runtime"
],
"Next": "DynamoDB Update"
}
]
},
"DynamoDB Update": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "s3_table",
"Item": {
"etag": {
"S.$": "$.eTag"
},
"filekey": {
"S": "mp3Files"
}
}
},
"End": true
} } }
solved this using choice state. Open to hear any suggestions on Catch state.
Here is the code.
{
"Comment": "A Hello World example of the Amazon States Language using Pass states",
"StartAt": "Hello",
"States": {
"Hello": {
"Type": "Pass",
"Next": "Verify item from DynamoDB"
},
"s3_url": {
"Type": "Pass",
"Result": "Hello",
"End": true
},
"Verify item from DynamoDB": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "s3_table",
"Key": {
"etag": {
"S.$": "$.Records[0].s3.object.eTag"
}
}
},
"ResultPath": "$.Records[0].DynamoDB",
"OutputPath": "$",
"Next": "Choice State",
"Catch": [
{
"ErrorEquals": [
"States.Runtime"
],
"Next": "DynamoDB Update"
}
]
},
"Choice State": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.Records[0].DynamoDB.Item.etag.S",
"IsPresent": true,
"Next": "s3_url"
}
],
"Default": "DynamoDB Update"
},
"DynamoDB Update": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "s3_table",
"Item": {
"etag": {
"S.$": "$.Records[0].s3.object.eTag"
},
"filekey": {
"S.$": "$.Records[0].s3.object.key"
}
}
},
"End": true
}
}
}

How to use "jagged" objects in Azure Resource Manger templates to iterate over them?

I have object with not equal number of properties (and would like to keep it like this), i.e. second object is missing property "routeTable" and properties repeat i.e. "NSG-AllowAll"
"value": [
{
"name": "GatewaySubnet",
"addressPrefix": "10.2.0.0/24",
"networkSecurityGroup": "NSG-AllowAll",
"routeTable": "UDR-Default"
},
{
"name": "UnTrusted",
"addressPrefix": "10.2.1.0/24",
"networkSecurityGroup": "NSG-AllowAll"
},
{
"name": "routed",
"addressPrefix": "10.2.2.0/24",
"routeTable": "UDR-Default1"
}
]
The solution to create vnet works fine but only if exisiting properties don't repeat i.e. the second NSG above has different name from the first one. In my scenario there will be a lot of repeating property names
In that case you just need to remove nsg\udr from that template I've created. I think thats what I've told you there as well. check the ps in my previous answer.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"deploymentPrefix": {
"type": "string"
},
"subnets": {
"type": "array",
"defaultValue": [
{
"name": "GatewaySubnet",
"addressPrefix": "10.2.0.0/24",
"networkSecurityGroup": "NSG-AllowAll",
"routeTable": "UDR-Default"
},
{
"name": "UnTrusted",
"addressPrefix": "10.2.1.0/24",
"networkSecurityGroup": "NSG-AllowAll"
},
{
"name": "routed",
"addressPrefix": "10.2.2.0/24",
"routeTable": "UDR-Default"
}
]
}
},
"variables": {
"copy": [
{
"name": "subnetsBase",
"count": "[length(parameters('subnets'))]",
"input": {
"name": "[concat('subnet-', parameters('subnets')[copyIndex('subnetsBase')].name)]",
"properties": {
"addressPrefix": "[parameters('subnets')[copyIndex('subnetsBase')].addressPrefix]"
}
}
},
{
"name": "subnetsUDR",
"count": "[length(parameters('subnets'))]",
"input": {
"routeTable": {
"id": "[if(contains(parameters('subnets')[copyIndex('subnetsUDR')], 'routeTable'), resourceId('Microsoft.Network/routeTables', parameters('subnets')[copyIndex('subnetsUDR')].routeTable), 'skip')]"
}
}
},
{
"name": "subnetsNSG",
"count": "[length(parameters('subnets'))]",
"input": {
"networkSecurityGroup": {
"id": "[if(contains(parameters('subnets')[copyIndex('subnetsNSG')], 'networkSecurityGroup'), resourceId('Microsoft.Network/networkSecurityGroups', parameters('subnets')[copyIndex('subnetsNSG')].networkSecurityGroup), 'skip')]"
}
}
}
]
},
"resources": [
{
"apiVersion": "2017-06-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[concat(parameters('deploymentPrefix'), '-vNet')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.2.0.0/16"
]
},
"copy": [
{
"name": "subnets",
"count": "[length(parameters('subnets'))]",
"input": {
"name": "[concat('subnet-', parameters('subnets')[copyIndex('subnets')].name)]",
"properties": "[union(variables('subnetsBase')[copyIndex('subnets')].properties, if(equals(variables('subnetsUDR')[copyIndex('subnets')].routetable.id, 'skip'), variables('subnetsBase')[copyIndex('subnets')].properties, variables('subnetsUDR')[copyIndex('subnets')]), if(equals(variables('subnetsNSG')[copyIndex('subnets')].networkSecurityGroup.id, 'skip'), variables('subnetsBase')[copyIndex('subnets')].properties, variables('subnetsNSG')[copyIndex('subnets')]))]"
}
}
]
}
}
]
}
I dont see any reason why this wont work if you have nsg\udr in place

How to use another brackets/tabs policy for my CSS?

Here is an example of what is happening now:
.class {
}
So when I'm typing .class { SublimeText automatically inserts } (which is correct).
Then I press Enter and get this:
.class {
#CURSOR_POSITION#
}
But what I really want is (attention to the closing bracket):
.class {
#CURSOR_POSITION#
}
I've even seen (ok, it was only once) in some editor special setting for this. Now I start using SublimeText (which is cool!) and I feel that it can be customized in a such way but I'm not quite sure how.
Ok! It's not really hard to do it but it was not simple to know how to do it =)
So my approach is:
Write a simple macro (I've edited the default Enter macro called Add Line in Braces.sublime-macro which lives in ~Data/Packages/Default) and save it with a new name.
I've called it CSS.Add Line in Braces.sublime-macro and put in ~Data/Packages/User.
[
{"command": "insert", "args": {"characters": "\n\n"} },
{"command": "move_to", "args": {"to": "hardbol", "extend": false} },
{"command": "insert", "args": {"characters": "\t"} },
{"command": "move", "args": {"by": "lines", "forward": false} },
{"command": "move_to", "args": {"to": "hardeol", "extend": false} },
{"command": "reindent", "args": {"single_line": true} }
]
Apply it for Enter key in CSS files. For that we need to fo to Preferences > Key Bindings - User (it will open ~Data/Packages/User/Default (YOUR_OPERATING_SYSTEM).sublime-keymap) and paste there the following code:
[
{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "Packages/User/CSS.Add Line in Braces.sublime-macro"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "source.css" },
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\{$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true }
]
}
]
It is copy-pasted from the defult keybinding file with one context addition:
{ "key": "selector", "operator": "equal", "operand": "source.css" }
which tells Sublime to apply it only for CSS ext.
Profit!

Resources