how to use handlebars from shell? - handlebars.js

I know how to use handlebars from java, but if I'd like to register some extensions, and compile some template to generate file with some testing data. npm install -g handlebars gives me some command to precompile templates, but I cannot find anything to evaluate that templates. I found only some very old unmaintained tool, but is there some correct way, up to date, official?

Ok, I still don't know if it's the OK way, but after a lot of search, I found hbs-cli tool(https://github.com/keithamus/hbs-cli). So usage could be
Install:
npm install -g hbs-cli
invocation:
hbs --data <(echo '{"who":"world"}') <(echo 'Hello {{who}}!') --stdout

Related

How to pass flags to nvcc in google colab?

I want to use __device__ lambda but it said that I need to pass the flag '--expt-extended-lambda'.
I use this environment in colab.
!wget https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-
local_9.2.88-1_amd64 -O cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
!apt-get update
!apt-get install cuda-9.2
!nvcc --version
!pip install git+git://github.com/andreinechaev/nvcc4jupyter.git
%load_ext nvcc_plugin
And I write codes like this
%%cu
int main() {}
I have no idea to pass the flag.
My reading of the relevant code suggests that you can't. There appears to be no support for passing additional arguments to nvcc via that plugin.
You would need to fork and modify the plugin to taste or petition the authors of the plugin to do the same if you don't understand how to do this.
Alternatively, use this hack, which forces the plugin to write to a file and then hand compile that file by running nvcc yourself.

Compiling Jaeger gRPC proto files with Python

I'm currently playing around with Jaeger Query and trying to access its content through the API, which uses gRPC. I'm not familiar with gRPC, but my understanding is that I need to use the Python gRPC compiler (grpcio_tools.protoc) on the relevant proto file to get useful Python definitions. What I'm trying to do is find out ways to access Jaeger Query by API, without the frontend UI.
Currently, I'm very stuck on compiling the proto files. Every time I try, I get dependency issues (Import "fileNameHere" was not found or has errors.). The Jaeger query.proto file contains import references to files outside the repo. Whilst I can find these and manually collect them, they also have dependencies. I get the impression that following through and collecting each of these one by one is not how this was intended to be done.
Am I doing something wrong here? The direct documentation through Jaeger is limited for this. The below is my basic terminal session, before including any manually found files (which themselves have dependencies I would have to go and find the files for).
$ python -m grpc_tools.protoc --grcp_python_out=. --python_out=. --proto_path=. query.proto
model.proto: File not found.
gogoproto/gogo.proto: File not found.
google/api/annotations.proto: File not found.
protoc-gen-swagger/options/annotations.proto: File not found.
query.proto:20:1: Import "model.proto" was not found or had errors.
query.proto:21:1: Import "gogoproto/gogo.proto" was not found or had errors.
query.proto:22:1: Import "google/api/annotations.proto" was not found or had errors.
query.proto:25:1: Import "protoc-gen-swagger/options/annotations.proto" was not found or had errors.
query.proto:61:12: "jaeger.api_v2.Span" is not defined.
query.proto:137:12: "jaeger.api_v2.DependencyLink" is not defined.
Thanks for any help.
A colleague of mine provided the answer... It was hidden in the Makefile, which hadn't worked for me as I don't use Golang (and it had been more complex than just installing Golang and running it, but I digress...).
The following .sh will do the trick. This assumes the query.proto file is a subdirectory from the same location as the script below, under model/proto/api_v2/ (as it appears in the main Jaeger repo).
#!/usr/bin/env sh
set +x
rm -rf ./js_out 2> /dev/null
mkdir ./js_out
PROTO_INCLUDES="
-I model/proto \
-I idl/proto \
-I vendor/github.com/grpc-ecosystem/grpc-gateway \
-I vendor/github.com/gogo/googleapis \
-I vendor/github.com/gogo/protobuf/protobuf \
-I vendor/github.com/gogo/protobuf"
python -m grpc_tools.protoc ${PROTO_INCLUDES} --grpc_python_out=./python_out --python_out=./python_out model/proto/api_v2/query.proto
This will definitely generate the needed Python file, but it will still be missing dependencies.
I did the following to get the Jaeger gRPC Python APIs:
git clone --recurse-submodules https://github.com/jaegertracing/jaeger-idl
cd jaeger-idl/
make proto
Use the files inside proto-gen-python/.
Note:
While importing the generated code, if you face the error:
AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'
Do:
pip3 install --upgrade pip
pip3 install --upgrade protobuf

gulp-ruby-sass - 'sass' is not recognized as an internal or external command, operable program or batch file

I'm trying to run gulp-ruby-sass on Windows.
I've already installed Ruby and Sass like that:
$ gem install sass
My gulp.task looks like this:
gulp.task('styles', function() {
return sass('src/scss/**/*.scss')
.on('error', sass.logError)
.pipe(gulp.dest('css'));
});
When I cd into the root directory of my project and run $ gulp styles,
I get this:
[22:54:52] Using gulpfile c:\wamp\www\wordpress\
wp-content\themes\bootscores\gulpfile.js
[22:54:52] Starting 'styles'...
[22:54:52] 'sass' is not recognized as an internal or external command,
operable program or batch file.
Error in plugin 'gulp-ruby-sass'
Message:
Gem undefined is not installed.
[22:54:52] Finished 'styles' after 89 ms
I've been searching for a solution to this problem for about two hours now and still haven't found one that would help me.
I've finally found a solution.
I had to manually add a path to my Ruby bin folder in Control Panel > System > Advanced > Environment Variables. Here i added a new variable named path with a path to my Ruby bin folder (C:\Ruby22-x64\bin).
Then I restarted my Node.js command prompt and got the output I was looking for.
Thank you, CDF, for you answer and effort!
Even though I answered this question myself, I hope it will eventually help other people too.
I had the same error, only in my situation sass package wasn't installed in RubyGem.
You need to execute following command:
gem install sass
Use the Ruby installer and reinstall it. Then check the path checkbox. It should be resolved then.
Install Sass Using the Command Prompt
[CMD] + [R]
type cmd hit [ENTER]
Type gem install sass
If you get an error message then it's likely you will need to use the sudo command to install the Sass gem. It would look like:
sudo gem install sass
4 Reboot the NODE command line. In fact you might want to reboot the system, most users do not do enough of that.

How do you use csslint from the command line?

I'm new to Ubuntu, I'll be the first to admit that, but I need to integrate csslint into a CI build script and I found the about page on the csslint site unhelpful. It gave me two options for installing csslint but they require either node or rhino:
Node.js:
sudo npm install -g csslint
Rhino.js:
java -jar rhino.jar csslint-rhino.js --rules= ~ /* suppressed for simplicity */
After googling for either of these in a format I know how to work with, on google groups I found someone asking a similar question. The answer was that rhino is not a ready made product you install and run but a library you work with.
All I need to do is:
pass CSS files to csslint through bash with csslint args
get the response back
evaluate whether or not the build should fail due to violations
Is there anywhere I can find step-by-step instructions that include dependencies such as node or rhino?
Thanks everyone.
Found the answer myself and decided to put it here to help others.
sudo apt-get install npm
sudo npm install -g csslint
csslint pathtofile.css
have feelings hurt.

Trouble building sqlite 3.7.4 on CentOS 5.5 to include readline support

The readline library allows the CLI for sqlite to accept arrow keys to recall previously typed commands. I can build without this and sqlite works, it's just a hassle not having this nice capability. I've installed readline-devel from yum and /usr/lib64/libreadline.so.5 is present as well as it's header files. When I run ./configure to build sqlite, I see these lines:
checking for library containing readline... no
checking for readline... no
The library path is set to the correct path:
LD_LIBRARY_PATH="/usr/lib64:/usr/local/lib:/lib:/usr/lib"
By default, ./configure does try to include readline support so there are no special "--with-XXXX" options needed.
Anyone every seen this problem? I need to use this newer version to get latest foreign key support. It's hassle running on CentOS as is bundles pretty old versions of apps but we don't have a choice right now and I cannot find an updated RPM with newer version of sqlite.
=== UPDATE ===
Ok, I found a solution but I don't completely like it...
First, I tried with this option:
./configure CPPFLAGS="-I/usr/include/ -DHAVE_READLINE"
That causes the readline functionality to get compiled into shell.c which is what is needed for starters. But, the linking fails because it cannot find libreadline. The only 'kludgy' way I could figure out to get it to link was to manually edit the Makefile after running the above ./configure command. I changed this line:
LIBS = -ldl -lpthread
to this:
LIBS = -ldl -lpthread -lreadline -ltermcap
Then I ran "make clean all" and "make install" and the readline functionality works in the CLI.
I tried every way I could think of to pass in the extra libraries including exporting using LIBS, exporting using READLINE_LIBS, exporting using LDFLAGS, nothing would work. If you set LIBS to anything, like "export LIBS="-lreadline", it causes configure to fail. The --help on configure about using LIBS seems to contradict what happens when you actually set it to any value.
Anyway, this works so I can live with it - but I don't particularly like it! :(
==== THE RIGHT SOLUTION ====
Well, wouldn't you know it. Spend hours trying to figure it out, then stumble onto the right tip on Google. Just needed to install ncurses-devel first. So, to summarize all that is needed to built it 'unkludgily':
yum install ncurses ncurses-devel
yum install readline readline-devel
yum install libtermcap libtermcap-devel
./configure
make
make install
No special command line options or exports or Makefile edits needed! Readline support is automatically built in by default now.

Resources