Why is Vi is removing my quotations on save? - npm

I am trying to set up my _auth for npm.
I run npm config edit which pulls up the Vi editor. I update the token to include quotes around it
_auth="mytokenhere"
but then after saving and looking at the file again, it shows up like:
_auth=mytokenhere
Anyone know why it is not saving my quotes?
To save, I am doing the following:
'Esc' + ':' + 'x' + enter

Related

How can I run a bat file with spaces in the filepath?

I want to run a bat file used to compile sass to css from within a Kotlin program, on a Windows machine. I had everything working using Runtime.exec until I switched to a Windows account that had a space in the username. From what I read, I read that using ProcessBuilder would make this easier. It seems that even with ProcessBuilder I still can't get it to work, no matter what I try.
Here is my code so far
val commands = mutableListOf(
"cmd",
"/c",
"C:\\Users\\John Doe\\VCS\\test\\tools\\sass\\windows\\dart-sass\\sass.bat",
"--no-source-map",
"C:\\Users\\John Doe\\VCS\\test\\src\\main\\sass\\global.scss",
"global.css"
)
val processBuilder = ProcessBuilder(commands)
val process = processBuilder.start()
...
The error I get is 'C:\Users\John' is not recognized as an internal or external command, operable program or batch file. It doesn't help if I surround the strings that have spaces with \".
If I remember correctly, all windows files and folders that have a space in the name have a matching short name in the old 8.3 format replacing additional space and other characters with a tilde (~) and a number.
So whatever is returning you the path for the .bat and .sscs files could return the full filename in that format?
Doesn't solve the problem but avoids it instead, I admit.
Also means you won't get busted when someone puts a space in the filename (OK, unlikely, but still something better to deal with from the start).
Consider something along the lines of the top 2 answers on this superuser thread
This is actually a Windows cmd issue. The question here shows that in cmd, in addition to quoting the file paths, you also have to quote the entire part of the command line text after the /c switch.
I don't know if this is the best way to do it in ProcessBuilder, but I was able to get it to work with the following code.
"cmd.exe",
"/c",
"\"\"C:/Users/John Doe/VCS/test/tools/sass/windows/dart-sass/sass.bat\" "
+ "--no-source-map "
+ "\"C:/Users/John Doe/VCS/test/src/main/sass/global.scss\" "
+ "\"global.css\"\""

Error: Bad character (ASCII 0) encountered in BigQuery

I'm trying to upload a CSV file to Bigquery, but I get the following error:
Error: Bad character (ASCII 0) encountered (bigquery)
I've tried the following, but none of this are working:
a) Open the file as save it as "UTF-8" in notepad.
b) Open the file in notepad++ and use the option "Search characters by type" - Non ASCII. Didn't find any character
c) Use notepad++ with the followings regular expressions, didn't find any character:
[^\x00-\x7F] and [^\x1F-\x7F].
d) Use the following command:
gsutil cp gs://bucket_987234/compress_file.gz - | gunzip | tr -d '\000' | gsutil cp - gs://bucket_987234/uncompress_and_clean_file
Didn't work: "tr" is not recognized as a command (I'm using windows 10 and I don't have access to a VM of google.)
d) Open the file and deleted the first row, then it worked. But i've lost a line of data, and I have thousand of files.
The trouble is that I need to automate the "cleaning" of this files.
How can I clean this file in Windows, Any idea about what else can this "ASCII 0" character or how to get rid of it?
Thanks!!
You can use a GitBash on your machine? If you can, I would recommend you using this.
cat -v filename
For example, I have created a file called TESTINGCAT.txt with three lines, which visually has 7 empty spaces. However, if you count spaces with notepad++ you will find just 5 because 2 of those empty spaces are "non-breaking spaces" generated by typing ALT + 0160. Below you can see that I have on Notepad++
However, if I use cat -v TESTINGCAT.txt I can see M-BM- characters, which according to this are non-breaking spaces
Therefore, if you do not have access to a Linux machine, you should try using GitBash to see the hidden characters in your file.

cronjob not working, but working in browser

So I have this weird behaviour:
A customers runs an oxid-shop. He bought a module and in its documentation, it stated:
Add 3 cronjobs: < url >
So, nothing too special so far. I tried it in the browser and everything worked fine. My output was:
Convert complete! 0 articles. File: google.xml
So the Script seems to work. Then I tried to combine it with a cronjob.
*/02 * * * * curl http://www.example.org/index.php?cl=param1&fnc=param2&rto=param3
as you can tell, a complete valid url (no special chars or something like this in the vars)
However, the output is the following:
Warning: Smarty error: unable to read resource: "" in /usr/www/users/.../www2/core/smarty/Smarty.class.php on line 1094
I also tried it with lynx -dump URL. Same output. I can't modify the script, since it is encrypted.
Any idea what I could try? Might the be due to the params?
Tried it on 2 different servers with the same outcome.
The problem could in deed be that there are parameters in your URL.
When using [] or {} sequences when invoked from a command line prompt,
you probably have to put the full URL within double quotes to avoid
the shell from interfering with it. This also goes for other
characters treated special, like for example '&', '?' and '*'.
Source: https://curl.haxx.se/docs/manpage.html
So you should try to enclose your URL with double quotes.

Is there any way to set a shortcut for frequently issued commands in Cmder?

I use Cmder as my command prompt/console.
I find myself using the same commands many times a day. For example
git merge --no-ff my-long-branch-name
Is there any way I can store these commands in shortcut keys, like maybe, CTRL + G, instead of typing it each time?
Maybe it is a bit late, but still, here's the solution:
1) Open your Cmder folder and go to the config directory;
2) In \config\ open the file called aliases in any text editor;
3) Add this line at the end of the file:
my_alias_name=git merge --no-ff $*
4) Save the file and restart your Cmder;
5) Now you can type in your Cmder command line something like this:
my_alias_name my-long-branch-name
That's it :)
PS: Also, some information here can be useful for you.

How to auto-indent code in the Atom editor?

How do you auto-indent your code in the Atom editor? In other editors you can usually select some code and auto-indent it.
Is there a keyboard shortcut as well?
I found the option in the menu, under Edit > Lines > Auto Indent. It doesn't seem to have a default keymap bound.
You could try to add a key mapping (Atom > Open Your Keymap [on Windows: File > Settings > Keybindings > "your keymap file"]) like this one:
'atom-text-editor':
'cmd-alt-l': 'editor:auto-indent'
It worked for me :)
For Windows:
'atom-text-editor':
'ctrl-alt-l': 'editor:auto-indent'
The accepted answer works, but you have to do a "Select All" first -- every time -- and I'm way too lazy for that.
And it turns out, it's not super trivial -- I figured I'd post this here in an attempt to save like-minded individuals the 30 minutes it takes to track all this down. -- Also note: this approach restores the original selection when it's done (and it happens so fast, you don't even notice the selection was ever changed).
1.) First, add a custom command to your init script (File->Open Your Init Script, then paste this at the bottom):
atom.commands.add 'atom-text-editor', 'custom:reformat', ->
editor = atom.workspace.getActiveTextEditor();
oldRanges = editor.getSelectedBufferRanges();
editor.selectAll();
atom.commands.dispatch(atom.views.getView(editor), 'editor:auto-indent')
editor.setSelectedBufferRanges(oldRanges);
2.) Bind "custom:reformat" to a key (File->Open Your Keymap, then paste this at the bottom):
'atom-text-editor':
'ctrl-alt-d': 'custom:reformat'
3.) Restart Atom (the init.coffee script only runs when atom is first launched).
Package auto-indent exists to apply auto-indent to entire file with this shortcuts :
ctrl+shift+i
or
cmd+shift+i
Package url : https://atom.io/packages/auto-indent
I prefer using atom-beautify, CTRL+ALT+B (in linux, may be in windows also) handles better al kind of formats and it is also customizable per file format.
more details here: https://atom.io/packages/atom-beautify
You can just quickly open up the command palette and do it there
Cmd + Shift + p and search for Editor: Auto Indent:
This works for me:
'atom-workspace atom-text-editor':
'ctrl-alt-a': 'editor:auto-indent'
You have to select all with ctrl-a first.
This is the best help that I found:
https://atom.io/packages/atom-beautify
This package can be installed in Atom and then CTRL+ALT+B solve the problem.
On Linux
(tested in Ununtu KDE)
There is the option in the menu, under Edit > Lines > Auto Indent or press Cmd + Shift + p, search for Editor: Auto Indent by entering just "ai"
Note: In KDE ctrl-alt-l is already globally set for "lock screen" so better use ctrl-alt-i instead.
You can add a key mapping in Atom:
Cmd + Shift + p, search for "Settings View: Show Keybindings"
click on "your keymap file"
Add a section there like this one:
'atom-text-editor':
'ctrl-alt-i': 'editor:auto-indent'
If the indention is not working, it can be a reason, that the file-ending is not recognized by Atom. Add the support for your language then, for example for "Lua" install the package "language-lua".
If a File is not recognized for your language:
open the ~/.atom/config.cson file (by CTRL+SHIFT+p: type ``open config'')
add/edit a customFileTypes section under core for example like the following:
core:
customFileTypes:
"source.lua": [
"conf"
]
"text.html.php": [
"thtml"
]
(You find the languages scope names ("source.lua", "text.html.php"...) in the language package settings see here)
If you have troubles with hotkeys, try to open Key Binding Resolver Window with Cmd + .. It will show you keys you're pressing in the realtime.
For example, Cmd + Shift + ' is actually Cmd + "
You could also try to add a key mapping witch auto select all the code in file and indent it:
'atom-text-editor':
'ctrl-alt-l': 'auto-indent:apply'
I was working on some groovy code, which doesn't auto-format on save. What I did was right-click on the code pane, then chose ESLint Fix. That fixed my indents.
If you are used to the Eclipse IDE or the Netbeans, you can use the package eclipse-keybindings (https://atom.io/packages/eclipse-keybindings):
This Atom package provides Eclipse IDE key mappings for Atom. Currently, the Eclipse shortcuts are directly mapped to existing Atom commands.
To format all lines from a file, just use: Ctrl+Shift+F.
Ctrl+Shift+i worked for me in PHP under Windows ... but some files did not react. Not being the brightest it took me a while to work out that it was the include files that were the problem. If you are using echo(' ... PHP ...') then the PHP does not get re-formatted. To get over this, create a temporary PHP file, say t.php, copy the PHP part into that, reindent it (Ctrl+Shift+i ... did I mention that?) and then copy the newly reformatted PHP back into the original file. Whilst this is a pain, it does give you correctly formatted PHP.