Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I know this may sound a little stupid, but one of my NGINX config files is a piece of crap when it comes to formatting. It works and all but that's about it.
I tried to find some kind of beautifier or formatter, like http://jsbeautifier.org/ but then for nginx config files instead of javascript, but no luck so far.
I hope anyone would have a suggestion. There are no requirements, as long as it can format quickly / lazily made NGINX config files!
Thanks!
I found a few projects which might suit your needs:
Nginx Formatter (python) by 1connect
you can get it here
Nginx beautifier (js/nodejs) by vasilevich
nginxbeautifier.com which lets you format configs quickly in a web browser.
you can get a command line tool also on the same site to run it locally.
If your block lines end with {'s and }'s, this simple indenter could help you a bit.
It does not format all your configs, it only fixes indentation.
Original in awk (source):
#!/usr/bin/awk -f
{sub(/^[ \t]+/,"");idx=0}
/\{/{ctx++;idx=1}
/\}/{ctx--}
{id="";for(i=idx;i<ctx;i++)id=sprintf("%s%s", id, "\t");printf "%s%s\n", id, $0}
Or rewritten in python:
INDENT = ' ' * 4
def indent(contents):
lines = map(str.strip, contents.splitlines())
current_indent = 0
for index,line in enumerate(lines):
if (line.endswith('}')):
current_indent -= 1
lines[index] = current_indent * INDENT + line
if (line.endswith('{')):
current_indent += 1
return ('\n').join(lines)
There is a fork of http://jsbeautifier.org/ for nginx here: https://github.com/vasilevich/nginxbeautifier
Related
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 days ago.
Improve this question
1752462448 1933193007 1667526190 1684632419 1869767777 1886400099 1869426529 1953784163 1751999854 1953705777 808924214 943272760 825768241 858992688 876162865 808924214 959918133 892810033 825832761 808726350 1162236485 1412330081 1912602624 there is the cipher.
i tried dcode.fr Cipher Identifier and it says this is base36. yes i found something with it like a another cipher. i tried to decode it too but got nothing.
Example in Python for its universal intelligibility:
c = '1752462448 1933193007 1667526190 1684632419 1869767777 1886400099 1869426529 1953784163 1751999854 1953705777 808924214 943272760 825768241 858992688 876162865 808924214 959918133 892810033 825832761 808726350 1162236485 1412330081 1912602624'
b = [bytes.fromhex(
f'{int(a):08x}').decode() for a in c.split()]
print(''.join(b).rstrip('\x00'))
https://cdn.discordapp.com/attachments/1074689381891330049/1074697055731195904/NEFRET.rar
Note that b is the following list (with the last element 'r\x00\x00\x00'):
['http', 's://', 'cdn.', 'disc', 'orda', 'pp.c', 'om/a', 'ttac', 'hmen', 'ts/1', '0746', '8938', '1891', '3300', '49/1', '0746', '9705', '5731', '1959', '04/N', 'EFRE', 'T.ra', 'r\x00\x00\x00']
Therefore, wee need to remove all trailing ␀ (U+0000, Null) characters (see .rstrip('\x00') in the last line of above code snippet).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 12 months ago.
Improve this question
I am using vi editor for UNIX. Sometimes I am experiencing an issue with getting out of vi editor, where I go to press esc then type ":wq" or "q!" to quit, but it is not escaping. vi editor just enters weird symbols/characters and I can't get out. What do I do to escape and exit when esc won't escape?
There are few more commands for that apart from the one you are using
Shift+zz to save (if modified )and exit
:cq quit without writing
EDIT :
I found some more commands that I just learned .
There are many ways to exit from vi editors, and you can use some of these commands to exit from other editors
Press F2, this will drop you in Insert Mode, now press: q and hit enter
another way is to press Ctrl + c or ctrl + z command to exit the vi editor forcefully.
press ZZ (shift+z+z). it will save and exit.
Ctrl + [ will also work like escape key.
the 3rd , and 6th command may or may not work on every system, as it depends on terminal's setting and system itself.
or you can do map certain keys to behave like escape, please refer this post , that will save you some keystrokes.
For me this worked:
CTL + c (this is equal to ESC in your case)
:wq! (to write save and quit) and then click enter
have you tried ESC then "ZZ"?
seems to work as a last result for me.
This can happen when vi is started with TERM=linux. You can use the set term command to solve this problem.
Set the TERM to vt100 with one of the following commands depending on the shell.
csh or tcsh: setenv TERM vt100
sh: TERM=vt100; export TERM
ksh, bash, or zsh: export TERM=vt100
vi should work without setting the terminal in kx mode(refer to this for a similar issue: https://unix.stackexchange.com/questions/86742/term-linuxxterm-vi-in-an-xterm-or-the-aaabbbbbbccddd-problem).
In order to save this, add the set TERM command to ~/.vimrc file so the option is loaded when starting vi.
Have you tried ^z followed by "kill" the process?
I just had this issue with editor of command line of Git Bash and what worked was press Esc and then :q!. When I typed only q!, it did not work.
press the following shift + esc
look at bottom left corner
write the following colon included :wq
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
When I run ls -lrt command on a Unix folder , I get the following output
MyServer> ls -lrt
total 10
drwxr-x--- 3 UnixUser other 512 Jul 22 2011 FolderA
lrwxrwxrwx 1 UnixUser other 46 Aug 23 2011 BEA -> ../../../Some/Folder/SOLARIS/BEA
I am not sure what is BEA in these folders. They do not seem to be files nor folders. Why is there a arrow besides them pointing to somewhere else?
BEA and Perlx.x in these folders are symbolic links. The symbolic link is another name that "points to" the real file.
The option -l tells the command to use a long list format. It gives back several columns wich correspond to:
Permissions
Number of hardlinks
File owner
File group
File size
Modification time
Filename
The first letter in the permissions (lrwxrwxrwx) column show the file's type. l here means a link, A d means a directory and a - means a normal file (there are other characters, but those are the basic ones). The next nine characters are divided into 3 groups, each one a permission. Each letter in a group correspond to the read, write and execute permission, and each group correspond to the owner of the file, the group of the file and then for everyone else.
[ File type ][ Owner permissions ][ Group permissions ][ Everyone permissions ]
The characters can be one of four options:
r = read permission
w = write permission
x = execute permission
- = no permission
Finally, the + at the end means some extended permissions.
These are called symbolic links in linux (shortcuts in windows)
When you work on them, for eg vim BEA , you will be editing the actual file in ../../../Some/Folder/SOLARIS/BEA
The file in question is a symbolic link. The symbolic link is another name that "points to" the real file.
When you do ls -l it also shows you which file is pointed to by the link. You can actually see:
lrwxrwxrwx
^
|________ `l` here means a link
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I know I can do a "page down" using keyboard "spacebar" while browsing "man" command output on unix terminal window. Is there a corresponding keyboard shortcut for "page up"? To be generic, is there a list of keyboard shortcuts for man command? I did "man man" with no luck.
It depends on the pager that the man command uses on your system.
If it is less (as in 'less is more'), then you can go backwards. (With less, b goes back a page, amongst other options for doing that; so does Control-B. The h command gives me several pages full of options that I seldom or never use.)
If the pager is more (as in ... oh, there isn't an inverse jibe), then the answer may well be 'No, you cannot go backwards'.
On Mac OS X (10.7.4), the man man command cites the environment variables MANPAGER and HTMLPAGER that can be set; the default MANPAGER is less.
You can type h for help.
Type Ctrl-f and Ctrl-b to scroll down and up.
Ctrl-d and Ctrl-u will scroll half window.
Page Up = CTRL + B
Page Down = CTRL + F
C-v (aka Ctrl-v or ^V) and M-v (aka ESC-v, Alt-v or Meta-v) also work with less (to scroll down and up, respectively), for those familiar with Emacs keybindings.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Is there a tool for converting MATLAB code to R?
I have a lot of code that needs to be converted from MATLAB to R. It doesn't have to be accurate, but it will be helpful in giving a head start.
Paul Gilbert provides a rough Bash script that could get you started (he claims it will convert about 80% of the way) on the R mailing list:
#!/bin/csh
cp $1 $2
ex -s $2 <<eof
g/%/s//#/g
g/function\(..*\)=\(..*\)(\(..*\)/s//\2 <-function( \3 { \1/
g/end/s// } #/
g/for\(..*\)=\(..*\):\(..*\)/s//for ( \1 in \2 : \3 ) {/
g/_/s//./g
g/;/s///g
g/==/s//##/g
g/=/s//<-/g
g/##/s//==/g
g/zeros(/s//matrix(0,/g
g/ones(/s//matrix(1,/g
g/eye(/s//diag(1,/g
g/\/s//solve(,)/g
g/fsolve('\(..*\)'/s//ms(~\1 /g
g/param(\(..*\))/s//param[ \1 ] /g
g/var(\(..*\))/s//var[ \1 ] /g
g/mod1(\(..*\)/s//mod1[ \1 /g
wq
eof
No there is no easy conversion. Some will translate nearly exactly, some will translate only with great pain and suffering. At least you'll be using R though! Start here to work out analogous functions and syntax:
http://cran.r-project.org/doc/contrib/R-and-octave.txt
http://cran.r-project.org/doc/contrib/Hiebeler-matlabR.pdf
When you get stuck please ask specific questions here. This is really too vague as it stands, though those reference cards will help with getting started.
An alternative to translating the code would be to call MATLAB from within R, using the RMatlab package.
I have not tried RMatlab, but the package description states:
This package provides methods to read
and write MAT files. It also makes it
possible to communicate (evaluate
code, send and retrieve objects etc.)
with Matlab v6 or higher running
locally or on a remote host.
Please see the comments on this issue:
URL:https://mandymejia.wordpress.com/2014/08/18/three-ways-to-use-matlab-from-r/
She mentions several options:
Option 1: Run a single MATLAB command at a time using system()
Option 2: Use R.matlab to send code to the MATLAB server
Option 3: Write an entire MATLAB program using writeLines() and run using system()