Sublime binding sequences in JSON keymap files - sublimetext2

According to this old documentation of Sublime, it has supported sequence key bindings like "ctrl+t,u" for XML based keymap files.
Is this still supported in JSON keymap files?

Found it:
[
{ "keys": ["ctrl+e","ctrl+f"], "command": "reindent"}
]

Related

How can we tell Prettier to ignore a specific JSON file?

I am using VS Code and would like to exclude a specific json file data.json from being formatted by Prettier on save. Say it's in the root, then I create a file .prettierignore and add a line data.json (according to the docs).
This works fine with other types of files, but not with json files. In fact, even writing *.json will still format the json files.
There is a setting in VS Code
JSON > Format:Enable
Enable/disabled default JSON formatter
which is enabled. When I disabled it, however, no json file will be formatted on save. This is not what I want. I only want to exclude a specific json file. How can I achieve this?
I have already seen the related question 46409892.
I think your VS Code formatter is not Prettier by default for JSON (or maybe not your default formatter for all documents ?)
To define a formatter by default, according to Prettier doc, you have to set your VS Code settings file like this :
{
// For all files
"editor.defaultFormatter": "esbenp.prettier-vscode",
// For JSON specifically
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
Then, you can define ignored files in your .prettierignore using same syntax as .gitignore.

Visual Studio Code JSON completion

I'm making my first videogame in Unity and I was messing around with storing data in JSON files. More specifically, language localization files. Each file stores key-value pairs of strings. Keys are grouped in categories (like "menu.pause.quit").
Now, since each language file is essentially going to have the same keys (but different values), it would be nice if VS code recognized and helped me write these keys with tooltips.
For example, if you open settings.json in VS code, if you try to write something, there's some kind of autocompletion going on:
How does that work?
The auto completion for json files is done with json schemas. It is described in the documentation:
https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings
Basically you need to create a json schema which describes your json file and you can map it to json files via your user or workspace settings:
// settings.json
{
// ... other settings
"json.schemas": [
{
"fileMatch": [
"/language-file.json"
],
"url": "./language-file-schema.json"
}
]
}
This will provide auto completion for language-file.json (or any other file matched by the pattern) based on language-file-schema.json(in your workspace folder, but you can also use absolute paths)
The elements of fileMatch may be patterns which will match against multiple files.

How can I find out what is contained in a saved Docker image tar file?

Let's say that I have saved one or more Docker images to a tar file, e.g.
docker save foo:1.2.0 bar:1.4.5 bar:latest > images.tar
Looking at the tar file, I can see that in addition to the individual layer directories, there is a manifest.json file that contains some meta information about the archives contents, including a RepoTags array for each image:
[{
"Config": "...",
"Layers": [...],
"RepoTags": [
"foo:1.2.0"
]
},
{
"Config": "...",
"Layers": [...],
"RepoTags": [
"bar:latest",
"bar:1.4.5"
]
}]
Is there an easy way to extract that info from the tar file, e.g. through a Docker command - or do I have to extract the manifest.json file, run it through a tool like jq and then collect the tag info myself?
The purpose is to find out what is contained in the archive before importing/loading it on a different machine. I imagine that there must be some way to find out what's in the archive...
Since I have not received any answers so far, I'll try to answer myself using what I have tried, and it's working for me.
Using a combination of tar and jq, I came up with this command:
tar -xzOf images.tar.gz manifest.json | jq '[.[] | .RepoTags] | add'
This will extract the manifest.json file to stdout, pipe it into in the jq command, and jq combines the various RepoTags arrays into a single array:
[
"foo:1.2.0",
"bar:1.4.5",
"bar:latest"
]
The result is easy to read and works for me. Only downside is that it requires an installation of jq. I would love to have something that works without dependencies.
Still looking for a better answer, don't hesitate to post an answer if you have something that's easier to use!

How can I use drill-embed with file extensions different from the default ones?

I'm trying to test apache drill via drill-embed but all my json files are jsonline files with the jl.gz file extension.
If I rename them to json.gz it works but this is undesirable in my case.
How can I tell drill that jl.gz files are actually json?
PS: I tried adding a bootstrap-storage-plugins.json to $CP but drill-embed doesn't seem to read it.
Yes, do not use bootstrapping. That is only for distributed environments and using the Web Console or REST API is recommended. It probably goes without saying that the gz file must be zipped, not an unzipped JSON file with a gz extension. Create a new storage plugin configuration, for example myplugin, based on the default dfs storage plugin.
Start the Drill shell and go to http://<IP address or host name>:8047. Select Storage in the toolbar. The dfs storage plugin configuration appears in the list of default configurations.
On the Storage tab, under Enabled Storage Plugins, click UPDATE to copy the dfs storage plugin configuration.
The configuration of the plugin appears.
Copy the configuration and go back (just cancel the configuration).
On the Storage tab, enter a name in New Storage Plugin. For example, enter myplugin. Each configuration registered with Drill must have a distinct name. Names are case-sensitive.
Click CREATE.
In Configuration, in the formats section, change the json format to specify extensions: "gz"
"json": {
"type": "json",
"extensions": [
"gz"
]
},
Click CREATE.
Now, in the Drill shell, you can query the JSON file named something.gz:
use myplugin;
select * from `/Users/me/donuts.gz` limit 2;

Cannot display JSON file created and saved in Visual Studio Code

When I create a file in Visual Studio Code (on a Windows 7 box), add some content, then save it, the content is replaced with the following message:
The file cannot be displayed in the editor because it is either binary
or uses an unsupported text encoding.
My workaround is to create and save the file in Sublime Text, then I can open it, edit it, and save it in VS Code.
What do I need to do to get the file to save with the proper encoding?
Here are the steps I'm taking:
Create a new file in VS Code
Set the language of the file to JSON (bottom-right of editor)
Enter the following
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
Save the file as test.json
This is a bug in VS Code that has been fixed and will be available in the next update. Sorry for that! It does not happen for all file types, but for JSON unfortunately.
Update
Meanwhile new versions have been released that fix the issue.
This is a bug in VS Code. If you are running into it, rather than setting the language of the file, save the file with the .json extension, and VS Code will detect the language and correctly display the file.
I've submitted the bug here:
https://code.visualstudio.com/issues/detail/16781