Sublime text 3 plugin to get JSON path - json

I am after a plugin or technique in sublime text 3 to get what I will call the fully qualified path of the json element that is selected in the editor window.
Somethink like: http://jsonpath.com/
I want to get a result somewhere that I can copy, I just want to use this for documentation, not programmatically. It does not need to be the https://github.com/jayway/JsonPath standard, just something that produces a readable/meaningful path to an element.

For those who came here looking for ST3 implementation of jsonpath, there's an awesome Pretty JSON plugin.
It has jQ integration, which does the same same thing as jsonpath. jQ has different syntax, but it's much more convenient to have this functionality available inside ST3 than to switch to browser.

I was searching for the same and ended up creating a plugin myself: https://github.com/akirk/StatusBarJsonPath

Related

Which to use for Prismic project, prismic-javascript, #prismicio/client, prismic-dom, prismic-reactjs

Cant find a distinctive difference on their docs so asking here.
prismic-javascript or #prismicio/client or prismic-reactjs or prismic-dom
They all are npm packages.
Can someone explain the 4 separate packages and when to use one over the other.
My assumptions.
prismic-javascript is for connecting directly to the v2 api.
#prismicio/client is the same package as prismic-javascript. Still confused about this.
prismic-reactjs is just react components that you can pass data to
from prismic-javascript api results.
prismic-dom is used for plain vanilla JavaScript projects to render dom elements that you pass data to
from prismic-javascript api results.
Am I correct with the above assumptions ?
me, thanks for the question.
prismic-javascript is the old version, where #prismicio/client is version 4 of the library. I definitely see how that's confusing, I'm working on getting the references cleaned up so that's more straightforward.
prismic-dom contains helpers for things like rendering "Rich Text" fields to the DOM. They come from the API as JSON, so you need something like this to turn it into HTML.
prismic-reactjs is similar to prismic-dom, but turns Rich Text fields into JSX to work with React projects.
So if you're working on a vanilla JavaScript site, you'll use #prismicio/client + prismic-dom.
If you're working on a React app, you'll use #prismicio/client + prismic-reactjs.

How can I convert Wikitext Markup containing the double curly bracket functions, into plaintext or html?

I am creating a customized Wiki Markup parser/interpreter. There is a big task however in regards to interpreting functions like these:
{{convert|500|ft|m|0}}
which is converted like so:
500 feet (152 m)
I'd like to avoid having to manually code interpretations of these functions, and would rather employ a method where I query a string
+akiva#akiva-ThinkPad-X230:~$ wiki-to-text "convert|3|to(-)|6|ft|abbr=on}}"
and get a return of:
"3 to 6 ft (0.91–1.83 m)"
Is there a tool to do this? Offline is by far the most ideal solution, but I could live with having to query a server.
You could query the MediaWiki api to get a parsed text from wikitext. E.g. to parse the template Template:Done from the english wikipedia you could use: https://en.wikipedia.org/w/api.php?action=parse&text={{Template:done}}&title=Test (see the online docs for parse). You, however, need a MediaWiki instance that provides a template that you want to parse and which works in the exact same way. If you install a webserver locally, you can install your own MediaWiki instance and parse wikitext locally, too.
Btw.: There's the Parsoid project, too, which implements a node-based wikitext->html->wikitext parser. However, it, iirc, still needs to query the api of the wiki to parse templates.

Is there a way that I can verify if a file is json format(not missing comma or something) in a console?

That's it, i'm a careless guy, i always miss something or what if i'm writing a json.
I think maybe we can utilize irb.
Before looking at Node, look at your editor. Does it do plugins (say, Sublime Text)? If so, install a JSON linter/validator that won't let you save until you've fixed the errors. Problem solved.
No such luck? Look into using grunt or gulp with a simple JSON validator task (of the kind "look for **/*.json, check that"). e.g. https://www.npmjs.org/package/grunt-jsonlint or https://www.npmjs.org/package/gulp-jsonlint ...
Or, even just use plain old https://www.npmjs.org/package/jsonlint on its own to check individual files.
This is a solved problem, pick your favourite solution.
You could always create an alias:
alias jsonlint="echo \"try{JSON.parse(require('fs').readFileSync(process.argv[2])); process.exit(0);}catch(e){process.exit(1);}\" | node"
and use it like:
jsonlint some_file.json
or if you don't want the error output
jsonlint some_file.json 2>/dev/null
In spite of what Snowmanzzz said, require('some_json.json') isn't guaranteed to detect the file as JSON (especially if it doesn't have the .json extension).
I find a super simple one, just use node, then require this json file.

vim: project wide auto suggestion

When using eclipse upon pressing control space, it show a list of all possible matching function calls irrespective of the file locations.
Is there a similar plugin for VIM ?
I am using vim7.4 and shougo's neocomplete (https://github.com/Shougo/neocomplete.vim). I actually switched from shougo's neocomplcache to this plugin. I am so far satisfied with the auto-complete feature provided by the nice plugin.
I don't write php code though, I made two screenshots of one of my python project.
screenshot 1,
left side is a module tmux_cmd.py, right side I have imported the module, when I type the module name, the plugin suggested me all functions/variables in that module.
screenshot 2,
in same module, when I type keywords (load) in this case, the plugin shows me all possible functions. I opened tagbar on right side to show functions in the current module. I can press <TAB> to choose the one I want, or keep typing something else if I just want to have something else, like loadnothing.... In the screenshot I pressed <tab>
You only need to index your project with ctags (see :help tags and :help ctags) and vim's built-in omni completion will do what you want for PHP when you press <c-x><c-o>.
Vim doesn't do auto-completion, though, you'll need a plugin for that like the one cited by kent but there are others.

igraph for python

I'm thoroughly confused about how to read/write into igraph's Python module. What I'm trying right now is:
g = igraph.read("football.gml")
g.write_svg("football.svg", g.layout_circle() )
I have a football.gml file, and this code runs and writes a file called football.svg. But when I try to open it using InkScape, I get an error message saying the file cannot be loaded. Is this the correct way to write the code? What could be going wrong?
The write_svg function is sort of deprecated; it was meant only as a quick hack to allow SVG exports from igraph even if you don't have the Cairo module for Python. It has not been maintained for a while so it could be the case that you hit a bug.
If you have the Cairo module for Python (on most Linux systems, you can simply install it from an appropriate package), you can simply do this:
igraph.plot(g, "football.svg", layout="circle")
This would use Cairo's SVG renderer, which is likely to generate the correct result. If you cannot install the Cairo module for Python for some reason, please file a bug report on https://bugs.launchpad.net/igraph so we can look into this.
(Even better, please file a bug report even if you managed to make it work using igraph.plot).
Couple years late, but maybe this will be helpful to somebody.
The write_svg function seems not to escape ampersands correctly. Texas A&M has an ampersand in its label -- InkScape is probably confused because it sees & rather than &. Just open football.svg in a text editor to fix that, and you should be golden!