An Nginx proxy pass example
As a quick note to self, as I configure my “Mini-Me” application, which has a client written with Sencha Touch 2, and a Play Framework server, I used this Nginx proxy pass configuration:
As a quick note to self, as I configure my “Mini-Me” application, which has a client written with Sencha Touch 2, and a Play Framework server, I used this Nginx proxy pass configuration:
I just got a new CentOS Linux server at Linode, and installed a bunch of software on it that I need to run a couple of Drupal websites and a Play Framework website, and here are my very cryptic notes from that installation process. (Sorry, these are more for me than for you.)
First, I installed all the necessary Linux stuff:
Linux find/grep FAQ: How can I combine the Linux find and grep commands to search a large collection of files?
A lot of times when I need to find a file I know the text in the file that I'm looking for, but I can't remember the filename, or can't think of what directory it might be in, other than somewhere below my home directory. When this happens, and other search means like the "locate" command don't help, my favorite way of searching for text strings in files that are spread through a bunch of directories and sub-directories is this:
vim tip: If you reopen a file with vim and want to go to your last position in that file, type '"
(That’s an apostrophe followed by a double-quote.)
I recently “made the switch” from MacOS to Linux Mint, and was lamenting the fact that I didn’t have Alfred on Mint. But then this morning I learned about Cerebro, which, if it’s not Alfred yet, at least it’s Spotlight for Linux. omgubuntu.co.uk has this good intro article on Cerebro.
Cerebro is written as an Electron app, and as a result it’s available not only for Linux, but Windows and MacOS as well.
As a quick note, this stackexchange.com page has some good background information on how to install a deb package file from the command line on Debian Linux (which in my case is Ubuntu 16.04). The short answer is that if you have a deb file named google-chrome-stable_current_amd64.deb, you’ll want to run these two commands, one after the other, as shown:
$ sudo dpkg -i google-chrome-stable_current_amd64.deb $ sudo apt-get install -f
To give you some more perspective on how this works, here are those two commands shown with all of the output that they produce. Note that I put my deb file in a temporary directory before running the commands:
/home/alvin/Desktop/tmp> sudo dpkg -i google-chrome-stable_current_amd64.deb [sudo] password for alvin: Selecting previously unselected package google-chrome-stable. (Reading database ... 258250 files and directories currently installed.) Preparing to unpack google-chrome-stable_current_amd64.deb ... Unpacking google-chrome-stable (56.0.2924.87-1) ... Setting up google-chrome-stable (56.0.2924.87-1) ... update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/x-www-browser (x-www-browser) in auto mode update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/google-chrome (google-chrome) in auto mode Processing triggers for man-db (2.7.5-1) ... Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ... Processing triggers for desktop-file-utils (0.22-1ubuntu5) ... Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160701-0ubuntu1) ... Rebuilding /usr/share/applications/bamf-2.index... Processing triggers for mime-support (3.59ubuntu1) ... /home/alvin/Desktop/tmp> sudo apt-get install -f Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic linux-image-4.4.0-31-generic linux-image-extra-4.4.0-31-generic Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
After I ran those commands to install the deb file I removed the tmp directory I used during the installation process.
For more information see that stackexchange page. This debian.org page also has a good list of apt
and dpkg
commands, and this debian.org page shows how to list installed packages.
Marius Eriksen has a good article titled Hints for writing Unix tools. Some key points: a) consume input from stdin, produce output to stdout; b) output should be free from headers or other decoration; c) output should be simple to parse and compose. There’s much more to it than that, and it’s a good read (or reminder).
Ubuntu is running great on my old 2008 iMac, but if you’re having Linux performance issues, here’s an ArchLinux page titled “Improving performance.”
As shown in the image, I just installed Ubuntu on my 2008 27” iMac. The UI is interesting, a combination of MacOS and Windows. From what I’ve seen, I think I’ll like the Ubuntu UI (Unity) more than Linux Mint, but I’m open. So far Ubuntu is also significantly faster than the latest versions of MacOS were on the same hardware, though that may be because MacOS had a few hundred thousand more files on it than Ubuntu has at the moment.
This image is from an article about Ubuntu named, How to make your desktop look like my desktop. makeuseof.com has another article on customizing the Ubuntu UI with themes.
This is a nice article on the best Linux laptops of 2016, including what to look out for in graphics chips and other hardware issues. As I become more disgruntled with Apple and the direction of Macs and MacOS, I thought I’d start looking for a Linux laptop.
vi/vim FAQ: I keep getting these vim swap/temporary/backup files in my current directory, the ones with the tilde (~) character at the end of the filename; how do I get these swap/temporary files to go into another directory?
One of the nice things about the vim editor is the ability to easily fire off one command that changes patterns throughout your entire file. For instance, as I was working on editing my Function Point Analysis tutorial the following HTML string pattern kept re-appearing throughout the entire document, and needed to be replaced:
vi/vim FAQ: Can you provide some examples of how to create vim macros?
Here's a quick example of how to define macros that you can use in the vim editor (or vi editor). As you can tell by looking at them, I use these particular vim macros when editing HTML files.
Step 1 in the process or creating vim macros is to edit the vi/vim startup file in your home directory. On Unix, Linux, and Mac OS X systems, this file is named .vimrc
.
So, move to your home directory like this:
vim/vimrc FAQ: Can you share an example vim vimrc configuration file?
Sure. I don't use vim for programming much these days, so I don't have the vimrc configuration commands I used to use with various programming languages, but I'll be glad to share my vimrc configuration file that I use every day, along with a few extra lines to demonstrate some of the vim configuration possibilities.
Here's an example vimrc file:
This is a dangerous Unix command, but if you want to move a bunch of files from their subdirectories into your current directory, this find
and mv
command works:
find . -type f -exec mv {} . \;
That command finds all files beneath the current directory, and moves them into the current directory. I just moved a bunch of files from their (iTunes) subdirectories into my current working directory, and that find and move command did the trick. (But again, it’s a dangerous command, be careful out there.)
If you’re interested in using speech recognition on the Raspberry Pi, check out this short tutorial on the CMUSphinx project website.
This ended up being a good Unix pipeline command to use to find the size of Apache 2 processes on an Ubuntu Linux system:
ps aux | grep 'apache' | awk '{print $6/1024 " MB";}'
The $6
variable refers to the RSS field in the ps
output. I found the command on this page.
As a quick note, if you need to drop the query string when configuring an Nginx rewrite
request, this syntax works:
rewrite ^/foo/bar.*$ /bar? permanent;
The key is to use the ?
character at the end of the URL/URI you are redirecting users to. That drops the query string, so the user will be redirected to the exact /bar URI.
For more information, see the Nginx rewrite module page.
Linux head/tail FAQ: Can you share some examples of the Linux head and tail commands?
Sure. The Linux head and tail commands are very similar, so I've included them here together. The head command command prints lines from the beginning of a file (the head), and the tail command prints lines from the end of files. There's one very cool extra thing you can do with the tail command, and I'll show that in the tail example commands below.