My vim keeps showing errors regarding diff and gzip - unix

I was trying to diff two files with gvimdiff a.txt and b.txt and vim shows
E97:Cannot Create diffs
and when i tried opening a .gz file it shows
Error detected while processing function gzip#read: line 44: Error:
Could not read uncompressed file
Just to make sure i did not mess up my .vimrc,.cshrc and .alias file i reverted back to empty .vimrc and .vim folder in my home directory, similarly i removed all my additions in .cshrc and .alias.
This issue is bugging me since a day and it was fine few hours before.
Is there a way that i can get this resolved without installing any files with sudo?
Please suggest some changes to get back to original.
vim used is vim7.4
Edit:
The issue keeps coming back again.
to check some vim help, I tried :help E97 and it shows the same error
Is the colorcheme file creating a issue here?
I am using solarized as color scheme picked up from github.

Related

How to specify where cronR saves output file

I have successfully run a simple cronR tutorial using the cronR add in within R Studio. Here is the following code that I have saved in a R script file:
library(glue)
current_time <- Sys.time()
print(current_time)
msg <- glue::glue("This is a test I am running at {current_time}.")
cat(msg, file = "test.txt")
The R script file is saved within a specific project directory. The log file when the job runs is also saved there. However, the output of the script file, test.txt, is saved in my home directory. I am on a Mac. In the tutorial, it was stated that this would happen, that cron would save any output in the home directory and that if I want to change the location that I have to "specify otherwise". However, the tutorial gives no instructions for how to do this and I am not sure if I am supposed to do this through the terminal in mac and if so how? Changing the file path in the script file (e.g. Documents/test.txt) changes nothing, as the test.txt file is still saved in the home drive. I suspect I have to make this change somewhere else but I am not sure where. Any help would be appreciated.
For anyone who runs into the same issue, I was able to solve my problem by using launchD. I followed this tutorial https://babichmorrowc.github.io/post/launchd-jobs/. It worked as anticipated and now my .txt file is saved to the correct place. There is also a tutorial there for cron jobs, though if you are on a mac, launchD is apparently the preferred method.

How to recover deleted iPython Notebooks

I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash).
Does anyone know how I can recover the notebook? I am using Mac OS X.
Thanks!
This is bit of additional info on the answer by Thuener,
I did the following to recover my deleted .ipynb file.
The cache is in ~/.cache/chromium/Default/Cache/ (I use chromium)
used grep in binary search mode, grep -a 'import math' (replace search string by a keyword specific in your code)
Edit the binary file in vim (it doesn't open in gedit)
The python ipynb should file start with '{ "cells":' and
ends with '"nbformat": 4, "nbformat_minor": 2}'
remove everything outside these start and end points
Rename the file as .ipynb, open it in your jupyter-notebook, it works.
The "delete" functionality now sends the file to OS trash rather than permanently deleting it, see this PR: https://github.com/jupyter/notebook/pull/1968. So you can just open your Trash (wherever that is on your system) and restore it.
I think the easiest way (until developers handle this issue) to retrieve your Ipython history is to write them all into an empty file.
You need to check by the date you created your last script. Obviously, it is going to be the last part of your Ipython history.
To write your Ipython history into a file:
%history -g -f anyfilename
On linux:
I did the same error and I finally found the deleted file in the trash
/home/$USER/.local/share/Trash/files
If you deleted it through the OS (rm file.ipynb) then you can probably get it from ~/.ipython_checkpoints/ However, if you deleted it from the browser menu option, it is gone (by design!).
See discussion here: https://github.com/jupyter/notebook/issues/405
If you use PyCharm, you can do the following.
Open the Local History view.
Select the version you want to roll back to.
On the context menu of the selection, choose Revert.
Worked for me!
Source: here
For the unlucky ones like me, that delete some files on JuliaBox(jupyter for julia), there is a solution. I successifly recovery all my deleted files.
The browsers strore cache information about the pages you visit. You have to find your cache browser folder (in ubuntu with crhome was ~/.cache/google-chrome/Default/Cache) and grep for some text of your notebook in the binarys. Then, cut the text part of the file that is correspond to your ipynb.
https://groups.google.com/forum/#!searchin/julia-box/delete%7Csort:relevance/julia-box/Rt9LG9RldrU/3s_vVSrivJEJ
If you're using windows, it sends it to the recycle bin, thankfully. Clearly, it's a good idea to make checkpoints.
As long as your Kernel is active, the code of each executed cell is stored in input history list. This will come in handy when you accidentally deleted a cell and want to retrieve its content.
_ih[-10:] *# code of the 10 most recently run cells (Even if those cells are deleted now)*
If you are running on Jupyterlab on linux like me. What I did is went into command prompt and went to my trash folder.
Trash directories on linux are typically
/home/$USER/.local/share/Trash
or
If you deleted something as root (e.g. deleted a file using Nautilus invoked via gksu), it is at
/root/.local/share/Trash
I ended up changing directories to /home/$USER/.local/share/Trash/files and my deleted notebook was there! depending on how you access your backend you could also try /home/jupyter/.local/share/Trash/
ps
If you are having issues changing directories from Trash to files due to permissions dont forget to become root:
sudo -i
then after sudo -i, go up with:
cd ..
and then
cd home/jupyter/.local/share/Trash
cd files
Best of luck,
Sadly my file was neither in the checkpoints directory, nor chromium's cache. Fortunately, I had an ext4 formatted file system and was able to recover my file using extundelete:
Figure out the drive your missing deleted file was stored on:
df /your/deleted/file/diretory/
Switch to a folder located on another you have write access to:
cd /your/alternate/location/
It is proffered to run extundlete on an unmounted partition. Thus, if your deleted file wasn't stored on the same drive as your operating system, it's recommended you unmount the partition of the deleted file (though you may want to ensure extundlete is already installed before proceeding):
sudo umount /dev/sdax
where sdax is the partition returned by your df command earlier
Use extundelete to restore your file:
sudo extundelete --restore-file /your/deleted/file/diretory/delted.file /dev/sdax
If successful your recovered file will be located at:
/your/alternate/location/your/deleted/file/diretory/delted.file
I had the very problem and I ended up solving it this way. It might be the case for some of the folks.

How to permanently set fix my working dir?

Every time I restart R I issue the following command:
setwd("C:/Users/avtarsingh/Downloads")
How do make this my permanent working dir
Create a file called ".Rprofile" and add that command. R will look for this file every time it starts and change to that directory accordingly. More info in the R documentation here
In order to change your working directory permanently, you can find the following file “Rprofile.site” that is located in your installation path “etc” folder and open it in your favorite text editor (i.e., VSCode). Then you can add your permeant working directory to the first line, like the following line of code:
setwd(“C:\your permeant working directory”)
and save it. Next time you open the R-CRAN, your working directory is set to what you have saved.
Any code which you wish to run every R session can be added to Rprofile.site.
On a Windows machine, this file is located for example in C:\Program Files\R\R-3.1.2\etc. On Windows you will need to run your favourite text editor as an administrator to make changes to this file, since it is in Program Files.
This is also a good place to set your local CRAN repository, etc.

Error in gzfile(file, "rb") - what should I do?

I'm going to write shortly, because my english is not perfect.
My code is:
explanatory=readRDS("explanatory_complete.Rds")
And I want knit pdf or word document, I receive this message:
Error in gzfile(file, "rb")- can't oppen connection
Where is problem? I set the right working directory.
Try with explanatory<-readRDS('filename.rds') this works for me.
Not sure if this is your case but I ran into
Error in gzfile(file, "rb")- can't open connection
when I tried to read a large file after it was downloaded using rsync. This was due to different file access permissions set by rsync than my Windows 10 system. The error was fixed in a local MobaXterm session using
chmod u+rwx filename
(change filename to your files)
The file likely doesn't exist in your working directory. This often happens to me when I have changed my working directory and forgotten to change it back.
Have you tried saving the new R/RMD file first?
I faced the same issue and problem was that, I was not saving the new file first therefore the R session was unable to understand the path for RDS file.
After I saved the file (in the same folder, but not a necessity) and ran the readRDS, it worked.
I had this issue. For me, it was being caused by an update.packages() call in a script my RMD document was sourcing. I'm sure there is a more elegant solution, but I just put a # in front of this line of code for knitting this RMD and then removed it again after
Check your exact file name and the working directly. it might be .rds missing in your saved file name.

Errno 2 No Such file or directory Sass not compiling in subilme text 2

I've found a few related posts but none match my specific problem and I think i've tried everything.
This is the error I get:
[Errno 2] No such file or directory
[cmd: [u'sass', u'--update', u'/Users/ryanwaters/Code/raw_portfolio/public/css/stylesheet.css.scss:/Users/ryanwaters/Code/raw_portfolio/public/css/stylesheet.css.css', u'--stop-on-error', u'--style', u'compressed']]
[dir: /Users/ryanwaters/Code/raw_portfolio/public/css]
[path: /usr/local/bin/sass]
[Finished]
When I put which sass in command line I get /Users/ryanwaters/.rvm/gems/ruby-1.9.3-p429/bin/sass
I've changed the pass several times and still can't figure out what the problem is
This seems pretty simple, but my problem was that I upgraded my mac's OS to Yosemite. I must've done something wrong, because my sass installation didn't carry over.
So, Sublime was throwing this error because it couldn't find sass. I reinstalled it, and everything worked as before.
This question is nearly an exact duplicate of SASS won't build in Sublime Text 2 [Errno 2] No such File or Directory from several days ago. If you look at my answer there, you'll see that you need to change the path to sass. You can either edit your SASS.sublime-build file and change the "cmd": line to point to /Users/ryanwaters/.rvm/gems/ruby-1.9.3-p429/bin/sass, or you can make a symlink to it in one of Sublime's default search directories, like /usr/local/bin or /usr/bin.
I had to manually specify the "path" and "gemPath" settings in the User Settings file for SassBeautify (e.g. "/Users/username/Library/Application Support/Sublime Text 2/Packages/User/SassBeautify.sublime-settings"). .
Here are the exact steps I followed to resolve the issue:
(derived from the documentation in the package repository).
Open up a terminal
Run: echo $PATH
Copy the entire output of that command
Open the SassBeautify settings file ("Preferences" -> "Package Settings" -> "SassBeautify" -> "Settings – User")
Paste the previously copied output wrapped in quotes into the 'path' setting (or add a "path" setting if it doesn't already exist)
Go back to your terminal and run: echo $GEM_PATH
Copy the entire output of that command
Go Back to the settings file
Paste the previously copied output wrapped in quotes into the 'gemPath' setting (or add a "gemPath" setting if it doesn't already exist)
Save the settings file and restart Sublime Text
Here's a screenshot of my SassBeautify settings file for reference:

Resources