SublimeREPL Unable to Find R - r

Okay, this is driving my crazy. I had set this up before, deleted Sublime Text, and now I can't remember what the right configuration was.
Very simple: I'm running R through SublimeREPL and need to point the REPL to where R is installed.
I followed the directions at http://sublimerepl.readthedocs.org/en/latest/, which say to go into the user-defined REPL settings and add this:
{
...
"default_extend_env": {"PATH": "{PATH}:/home/myusername/bin"}
...
}
where the path points to the right directory. I tried replacing it with
{
...
"default_extend_env": {"PATH": "C:/Program Files/R/R-3.0.2/bin"}
...
}
and it's still unable to find R, plus now it's giving me the error:
Error trying to parse settings: Expected value in Packages\User\SublimeREPL.sublime- settings:2:2
I know this is an easy fix. Can anybody point out what I'm doing wrong here?
*I'm using Sublime Text 3. I previously had this working, but on Sublime Text 2.
I've been to http://tomschenkjr.net/using-sublime-text-2-for-r/ and the piece where he mentions "pointing SublimeREPL at R" ... he doesn't include the actual code, as far as I can see
I've also seen this thread Error 2 The system cannot find the file specified in Sublime Text 2, Windows 8, but I had it working before and didn't have to do anything along those lines

Go to Preferences -> Browse Packages... and create a directory tree User/SublimeREPL/config/R. In that directory, create a new file named Main.sublime-menu with the following contents:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{"command": "repl_open",
"caption": "Rterm",
"id": "repl_r",
"mnemonic": "r",
"args": {
"type": "subprocess",
"external_id": "r",
"additional_scopes": ["tex.latex.knitr"],
"encoding": {"windows": "$win_cmd_encoding"},
"soft_quit": "\nquit(save=\"no\")\n",
"cmd": {"windows": ["C:/Program Files/R/R-3.0.2/bin/x64/Rterm.exe", "--ess", "--encoding=$win_cmd_encoding"]},
"cwd": "$file_path",
"extend_env": {"windows": {"PATH": "{PATH}:/C/Program Files/R/R-3.0.2/bin"}},
"cmd_postfix": "\n",
"suppress_echo": {"windows": false},
"syntax": "Packages/R/R.tmLanguage"
}
}
]
}]
}
]
Save the file, and you should now have a Tools -> SublimeREPL -> Rterm menu option. Double-check that the path is the correct one to the Rterm.exe file. On my computer (32-bit XP) it's in the i386 subfolder of bin, so yours may be in bin/x64 or something like that.
I hope this helps, let me know if you still have issues.

I resolved this by adding the location of Rterm.exe to PATH

Related

Re-create openstack artifacts from previous command output?

Is there an easy way to convert Openstack show command outputs into openstack commands ?
The goal is to rebuild an openstack environment after a complete wipe.
(for example: openstack network show myNet > out.txt,
then somehow generate the Openstack CLI command with appropriate fields to re-create this same exact network, based on out.txt ?)
Thanks!
You can write the output of the show commands as json formated string into a file, so you can easily read the information of the output with python-script to create and execute your desired commands.
To print the output of an openstack-command as json, add a -f json at the end of your command.
Example:
openstack server show cirros -f json
{
"OS-DCF:diskConfig": "MANUAL",
"OS-EXT-AZ:availability_zone": "nova",
"OS-EXT-SRV-ATTR:host": "test-system",
"OS-EXT-SRV-ATTR:hypervisor_hostname": "test-system",
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",
"OS-EXT-STS:power_state": "Shutdown",
"OS-EXT-STS:task_state": null,
"OS-EXT-STS:vm_state": "stopped",
"OS-SRV-USG:launched_at": "2020-07-22T08:41:06.000000",
"OS-SRV-USG:terminated_at": null,
"accessIPv4": "",
"accessIPv6": "",
"addresses": "test-network=192.168.62.207",
"config_drive": "",
"created": "2020-07-22T08:40:46Z",
"flavor": "f1 (273a2179-ac85-4c54-a40a-2c0121b338ff)",
"id": "6d302fcf-4de3-45a5-93c0-eb95650e5952",
"image": "cirros (86dded1f-8e0f-4342-906e-8ff9fbd854e2)",
"name": "cirros",
"project_id": "cbba4b1f3cb4460ca63e8ddb87c9b5fb",
"properties": "",
"security_groups": "name='default'",
"status": "SHUTOFF",
"updated": "2020-08-17T13:26:55Z",
"user_id": "b6505d6801e84fb98d77d2461f9719c2",
"volumes_attached": ""
}

How to add/edit code snippets in jupyer notebook?

I tried to follow the instructions given in the README file of the extension.
Im using Windows and to open my notebooks I use the jupyter-notebook.exe stored in the directory
..\Anaconda3\Scripts
Within the Anaconda3 directory I go to the subdirectory
Anaconda3\Lib\site-packages\jupyter_contrib_nbextensions\nbextensions\snippets
and there change the code of the file "snippets.json" from
{
"snippets" : [
{
"name" : "example",
"code" : [
"# This is an example snippet!",
"# To create your own, add a new snippet block to the",
"# snippets.json file in your jupyter data directory under nbextensions:",
"# $(jupyter --data-dir)/nbextensions/snippets/snippets.json",
"import this"
]
}
]
}
to
{
"snippets" : [
{
"name" : "example",
"code" : [
"# This is a test if something changed",
]
]
}
Then I restart my notebook and insert the example snippet. But my changes weren't adopted, I still get the original example snipped.
What I am doing wrong?
If you are using Anaconda, you don't necessarily need to go searching for directories. There is a template embedded in the "Nbextensions" tab.
Check "Snippets Menu" box
Scroll down to 'Parameters' and check the "Include custom menu...JSON string below" box
Insert whatever sample snippet you want
Refresh your notebook
Check out one of my snippets:
{
"name" : "My favorites",
"sub-menu" : [
{
"name" : "import packages",
"snippet" : ["# import various packages"
"import os"
"import scipy"
"import pandas as pd"
"import numpy as np"
"import seaborn as sns"
"import matplotlib.pyplot as plt"
"%matplotlib inline"
"# plot settings"
"from pandas.plotting import register_matplotlib_converters"
"register_matplotlib_converters()"
"plt.rcParams['agg.path.chunksize'] = 10000"]
},
{
"name" : "TeX can be written in menu labels $\\alpha_W e\\int_0 \\mu \\epsilon$",
"snippet" : ["another_new_command(2.78)"]
}
]
}
Also, be careful with the quotations and commas. Additional help on that can be found here.
In windows(os) jupyter notebook extension are hidden in programData folder (C:\ProgramData\jupyter\nbextensions\snippets)
To make changes in snippet just edit the snippets.JSON file accordingly:
I think you are searching in the wrong directory.
In windows, run command jupyter --paths in anaconda prompt
this will return the locations of config: data: & runtime:
search for the file snippets.json in the data: locations
in my case it is C:\ProgramData\jupyter\nbextensions\snippets
change and save the content in snippets.json and then restart your jupyter notebook
it will work!

How to make Arduino work and not give "cannot open source file "avr/pgmspace.h"" on vscode?

I'm trying to program arduino in vscode. The problem is that It's giving me weird header errors:
cannot open source file "avr/pgmspace.h" (dependency of "C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\Arduino.h")
This is my arduino.json:
"board": "arduino:avr:uno"
}
This is my c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:\\Program Files (x86)\\Arduino\\tools\\**",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**"
],
"forcedInclude": [
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
],
"intelliSenseMode": "msvc-x64",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
It should recursively include all of the required libraries, and even if imanually try to add the path to avr/pgmspace.h or its directory, it keeps giving me the same errors.
How do I solve this error?
Based on the responses to this issue, I added "c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\avr\\**" to my include path in c_cpp_properties.json:
"includePath": [
"c:\\Program Files (x86)\\Arduino\\tools\\**",
"c:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**",
"c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\avr\\**"
],
For anyone who stumbles here on a Mac, here is the config that works for me with the Uno:
{
"env": {
"arduino_path": "/Applications/Arduino.app/Contents/Java",
"arduino_avr_include_path": "${env:arduino_path}/hardware/arduino/avr",
"arduino_avr_include2_path": "${env:arduino_path}/hardware/tools/avr/avr/include",
"arduino_avr_compiler_path": "${env:arduino_path}/hardware/tools/avr/bin/avr-g++"
},
"configurations": [
{
"name": "Mac",
"defines": [
"ARDUINO=10810",
"__AVR_ATmega328P__",
"UBRRH"
],
"includePath": [
"${workspaceRoot}",
"${env:arduino_avr_include_path}/**",
"${env:arduino_avr_include2_path}/**"
],
"forcedInclude": [
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h"
],
"intelliSenseMode": "gcc-x64",
"cStandard": "c11",
"cppStandard": "c++11",
"compilerPath": "${env:arduino_compiler_path} -std=gnu++11 -mmcu=atmega328p"
}
],
"version": 4
}
The key to finding <avr/pgmspace.h> was the adding the hardware/tools/avr/avr/include path.
Defining ARDUINO=10810 was identified from the output of running Arduino: Verify with the verbose flag.
Defining __AVR_ATmega328P__ was added to allow proper IntelliSense completion of the raw register macros (e.g. _BV(), OCR0A, TIMSK0, etc.); the correct macro to define was identified based on the chip being an ATMEGA328P-PU and by inspection of the file hardware/tools/avr/avr/include/avr/io.h.
The compilerPath value looks wrong, although it is only used by the IDE and not for target compilation. The documentation says :
The absolute path to the compiler you use to build your project. The extension will query the compiler to determine the system include paths and default defines to use for IntelliSense.
In any case I recommend to configure it properly, I was able to remove
"${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/include",
"${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/include-fixed",
"${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/../../../../avr/include"
when setting
"compilerPath": "${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-g++ -std=gnu++11 -mmcu=atmega328p",
To figure out the exact compiler that is used turn on verbose logging in the output window:
File -> Preferences -> Settings -> Extensions -> Arduino configuration -> Log level -> verbose
which in this case also should help you figure out why the compiler does not pick up avr/pgmspace.h.
Here are my arduino.json
{
"board": "arduino:avr:uno",
"port": "/dev/ttyUSB0",
"sketch": "src/myproject.ino",
"output": "../build"
}
and c_cpp_properties.json
{
"env": {
"arduino.path": "${HOME}/.arduino15/packages/arduino",
"arduino.avr.include.path": "${env:arduino.path}/hardware/avr/1.6.23",
"arduino.avr.compiler.path": "${env:arduino.path}/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-g++",
"arduino.libraries.path": "${HOME}/arduino/sketchbook/libraries",
"dummy-last-line": "To allow the second to last line (e.g. the real last line) to always end with a comma"
},
"configurations": [
{
"name": "Linux",
"includePath": [
"./src",
"./test",
"../arduino_ci/cpp/unittest",
"${env:arduino.libraries.path}/SmartLCD",
"${env:arduino.libraries.path}/Chronos/src",
"${env:arduino.libraries.path}/Time",
"${env:arduino.libraries.path}/RTClib",
"${env:arduino.avr.include.path}/libraries/Wire/src",
"${env:arduino.avr.include.path}/cores/arduino",
"${env:arduino.avr.include.path}/variants/standard"
],
"browse": {
"path": [
"${workspaceFolder}/src"
],
"limitSymbolsToIncludedHeaders": true
},
"defines": [
"UBRRH"
],
"intelliSenseMode": "gcc-x64",
"compilerPath": "${env:arduino.avr.compiler.path} -std=gnu++11 -mmcu=atmega328p",
"cStandard": "c11",
"cppStandard": "c++11"
}
],
"version": 4
}
(the UBRRH define is for the Serial variable in HardwareSerial.h)

Packr windows exe not working

Downloaded the packr from https://github.com/libgdx/packr &
Packr json is
{
"platform": "windows64",
"jdk": "C:/Program Files/Java/jdk1.8.0_72",
"executable": "myapp",
"classpath": [
"input/test-hello.jar"
],
"mainclass": "Main",
"vmargs": [
"Xmx1G"
],
"minimizejre": "soft",
"output": "out-windows64",
"verbose": true
}
test-hello.jar has Main.class which simply writes "Hello" on System.out.
There is no error reported while packaging the exe. However, when I run the exe, there is no output on the console. Is there anything in the json that I am missing? Does anyone have a simple working example?
You need to include the path to the main class, for example
"mainclass": "com.example.Main",

CSS Visual Regession Testing with BackdropJS - could not run grunt:reference or grunt:test

I tried following this tutorial link on setting up backstop.js
https://joe-watkins.io/css-visual-regression-testing-with-grunt-backstopjs/
I followed all the instructions as required.
But I'm running into this error onscreen.
andy.cmwong#ONLM4800GR8LN32 /c/backstop_test
$ grunt backstop:reference
Running "backstop:reference" (backstop) task
[12:16:30] Using gulpfile c:\backstop_test\bower_components\backstopjs\gulpfile.js
[12:16:30] Starting 'clean'...
bitmaps_reference was cleaned.
[12:16:30] Starting 'bless'...
[12:16:30] Finished 'clean' after 9.82 ms
[12:16:30] Finished 'bless' after 15 ms
[12:16:30] Starting 'reference'...
[12:16:30] Starting 'init'...
[12:16:30] Finished 'init' after 73 μs
[12:16:30] Starting 'test'...
Generating reference files.
[12:16:30] Finished 'test' after 4.03 ms
reference has run.
[12:16:30] Finished 'reference' after 5.24 ms
Testing script failed with code: 1
Looks like an error occured. You may want to try running `$ gulp echo`. This will echo the requested test URL output to the console. You can check this output to verify that the file requested is inde
ed being received in the expected format.
cp: cannot stat `./bitmaps_reference': No such file or directory
ERROR: Error: Command failed: C:\Windows\system32\cmd.exe /s /c "cp -rf ./bitmaps_reference c:\backstop_test\tests"
cp: cannot stat `./bitmaps_reference': No such file or directory
Earlier, there was an additional error which states the gulp.run() is deprecated thus it suggested I need to use another npm module to execute tasks in sequence, which led me to this.
https://www.npmjs.com/package/run-sequence
And I managed to resolved it like so
//under bower_components/gulp/tasks/reference.js
var gulp = require('gulp');
var runSequence = require('run-sequence').use(gulp);
//FIRST CLEAN REFERENCE DIR. THEN TEST
gulp.task('reference', ['clean','bless'], function() {
//gulp.run('test');
runSequence('test');
console.log('reference has run.');
});
It works.
However, I'm still not able to complete the grunt/gulp tasks execution thus I'm really stuck with this.
I'm wondering has anybody tried following the tutorial link above and managed to succeed in getting backstopjs to work?
Your input on this is greatly appreciated.
UPDATE
I forgot to show you what my grunt config setup looks like.
........................
grunt.initConfig({
backstop: {
setup: {
options : {
backstop_path: './bower_components/backstopjs',
test_path: './tests',
setup: false,
configure: true
}
},
test: {
options : {
backstop_path: './bower_components/backstopjs',
test_path: './tests',
create_references: false,
run_tests: true
}
},
reference: {
options : {
backstop_path: '/bower_components/backstopjs',
test_path: './tests',
create_references: true,
run_tests: false
}
}
}
});
......................etc
My backstop.json file
{
"viewports": [
{
"name": "phone",
"width": 320,
"height": 480
},
{
"name": "tablet_v",
"width": 568,
"height": 1024
},
{
"name": "tablet_h",
"width": 1024,
"height": 768
}
],
"scenarios": [
{
"label": "http://getbootstrap.com",
"url": "http://getbootstrap.com",
"hideSelectors": [],
"removeSelectors": [
"#carbonads-container"
],
"selectors": [
"header",
"main",
"body .bs-docs-featurette:nth-of-type(1)",
"body .bs-docs-featurette:nth-of-type(2)",
"footer",
"body"
],
"readyEvent": null,
"delay": 500,
"misMatchThreshold" : 0.1
}
]
}
I managed to get it working last night when I got onto my Linux box(VMWare build), redo the backstopjs setup and successfully perform some test runs.
I did have my original suspicion that it was my Window OS environment that wasn't set up properly so I may have to reinstall npm/node/backstop etc, and have it resolved from there.
All good now.

Resources