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

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.

Related

How to parse Timber (twig) templates with poedit and detect quoted strings to translate

I want to parse twig templates for Timber with poedit and I need to translate quoted contents. The problem is that I can't find a parser that does not skip quoted content.
Example:
<htmltag attribute="{{ __('value','textdomain') }}" />
Does someone know of a parser for poedit that detects quoted content, like html attribute content?
The workaround I found is to set a variable and use it as my attribute value.
{% set attr_value = __('value', 'textdomain') %}
<a href='{{ attr_value }}'>link</a>
This way, the PHP and Python parsers work, as suggested in the Timber documentation.
Using Twig-Gettext-Extractor, I get a Twig-Error-Syntax because of unrecognized __() function.
Twig files are not automatically recognized when you use Poedit. To work around this, Timber’s documentation offers three options:
Either start each .twig file with {#<?php#}
Or use The Twig Gettext Extractor, a «poedit-friendly tool which extracts translations from twig templates».
Or use a Python parser. Refer to the documentation on how to set this up in Poedit.
I went with option 3 and it worked nicely.
Had the same problem with OSX Sierra, and none of the three solutions worked for me:
Using {#<?php#} on top of my .twig files caused poedit not to tecognize my strings
Using Twig-Gettext-Extractor throw many errors
Using python compile throw many errors too
I solved using the first option ( {#<?php#} on top of my .twig files ) but I also edited PoEdit PHP extractor in order it can search also in .twig files.
I hope this can help,
cheers!

Sublime text 3 plugin to get JSON path

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

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!

how to unpack a dll file which is UPX packed but also the headers are changed?

I have a file which is UPX packed. Is there any way I can change the headers and still find it as UPX packed? And how do I unpack it ?
I tried a lot of tutorials and I am fed up as all explain the same method which doesnt work for me.
the same problem is mentioned in the following :
http://www.reteam.org/board/showthread.php?t=2670
I am not a well versed reverse engg.. :( jst a noob .. any ideas will be really helpful.
To find the packing, I use PEID, protectionID etc.
For correcting the headers, you need to open up the file in a hexeditor and fix the offsets in the binary manually. Then you could use the upx.exe file to decrypt as
upx -d

Is there a way to tell Doxygen to ignore (all) namespaces?

Just about everything in my documentation ends up with the namespace:: prefix in front of it. (where namespace is the name of my namespace)
Is there a way to have the documentation generated without the namespace part?
For example:
my_namespace::myclass::member
becomes:
myclass::member
It would make everything more readable.
Turns out the answer was simple: you have to set HIDE_SCOPE_NAMES to YES in the configuration file.
I know this is old but if anyone comes looking again.
You can set SHOW_NAMESPACES to NO in configuration file.
It is also in DoxyWizard, Expert tab under Build topic.