How to copy to clipboard in Vim?

Question: Is it possible to copy to clipboard directly from Vim? yy only copies stuff to Vim's internal buffer. I want to copy to the OS's clipboard. Is there any such command in Vim or you can only yank stuff within Vim?
Comment: Please see the under-voted answer that clarifies an important fact: **you must have vim compiled with the +clipboard feature for ANY of the below suggestions to work in the first place!** This is NOT the default on most systems.
Comment: @NeilTraft, some answers suggest piping from vim to external programs, so the claim that ANY answer requires +clipboard flag, is wrong. Just pointing out to save future readers from confusion.
Comment: @Harnirvair For many sets of readers here, `vim-gnome` is probably overkill or simply unavailable in their OS/distro, whereas I suspect `vim-gtk` and preferably `vim-gtk3` are more likely to exist and pull fewer dependencies, while still providing clipboard integration (at least for those still on X11; I'm not sure how this all interacts with Wayland).
Comment: **Make sure you have done** ``sudo apt-get install vim-gnome`` **before applying these commands below** or you will get Invalid Register Error!
Comment: Possible duplicate of [How to make vim paste from (and copy to) system's clipboard?](http://stackoverflow.com/questions/11489428/how-to-make-vim-paste-from-and-copy-to-systems-clipboard) (Note: the other question is newer, but has better answers IMHO, which I why I marked this one as a dupe)
Comment: See also https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim
Comment: Checkout https://stackoverflow.com/a/65666057/9384511
Comment: i use ```cat file.filetype | clip``` on git bash in windows as i need to copy whole file as assignment in school. for sections of a file i have added ```set clipboard=unnamed``` in my _vimrc.
Comment: On Ubuntu make sure and install vim-gui-common even if only using the non gui version of vim, as this seems to also install the clipboard capable non gui vim
Comment: Besides vim-gnome, `"+y` is also supported by default in neovim on Ubuntu 20.04
Answer: The * register will do this. In Windows, + and * are equivalent. In unix there is a subtle difference between + and *:

Under Windows, the * and + registers
  are equivalent. For X11 systems,
  though, they differ. For X11 systems,
  * is the selection, and + is the cut buffer (like clipboard).
  http://vim.wikia.com/wiki/Accessing_the_system_clipboard

* is probably what you want most of the time, so I use * because it functions as I expect it to in both environments.
In Linux distros you have to install vim-gtk (aka gvim) first to gain clipboard functionality. This is because non-gtk vim is typically compiled without X11 support. This is to allow it to run on console only machines (often servers).
And for those confused about how to use registers when yanking or putting, you merely write " then the name of the register. So for copying something to the clipboard register you type "*y and then to put you type "*p (credit: Kyle Mathews)
Comment: If you are using Linux, you should `+` register. For example, if you wanna copy three lines into system's clipboard, use commands like `v3j"+y`, and then you can paste them into another application more another VIM. Using `*` register under Linux can only copy and paste between different VIM applications.
Comment: You have to also make sure that vim is compiled with support for the clipboard. The default vim in Ubuntu is not. Try `vim --version|grep .xterm_clipboard -o` and if it's `-` then you do not have support. Download a different version as per http://ubuntuforums.org/showthread.php?t=1686955
Comment: Doesn't work on mac osx lion. After pressing " then *, it makes that noise the mac makes when you can't do something. How do I do it on mac?
Comment: weberc2 and diabloneo, the * register is for the selection clipboard, accessible from middle clicking, not the menu paste or ^V
Comment: On Linux, the * register doesn't work for copying and pasting externally.
Comment: On Ubuntu, install vim-gtk will enable +clipboard and +xterm_clipboard features, and then you can use `"+y` to copy content to system clipboard. In other program like Chrome, you can use `Ctrl+v` to paste the content. You need to use middle button of mouse to paste content if you use `"*y` to copy content in vim.
Comment: Also, why is the system clipboard not used by default. You know, since it works in VIM and outside of it as well...
Comment: By the way, you need to check if VIM compile with +clipboard features. On Ubuntu you can install vim-gnome to get this feature.
Comment: @Sparhawk The Ubuntu forums thread post is now out of date - 'Huge vim' config on Ubuntu now comes with '-xterm_clipboard.
Comment: I have Ubuntu 16.04 with vim 8.1 (2018 May). `"+y` worked for me but not `"*y`.
Comment: For Ubuntu 18,04 found middle click often didn't work, especially when trying to paste passwords in chrome.   Using "+y always has worked.   For pasting into vim select then in vim "*p middle click works, no copy command needed for the source, only select.
Comment: @jamesc Thanks for the info. I've switched distros, but I seem to remember having `gvim` installed. I'm not sure if that works now.
Comment: Not a perfect place to ask but has anyone got it working for vim in a (gnu-)screen? I can't get it copied, the default screen copy method doesn't work for multiple lines in a split vim window :-/.
Comment: For easier use, I mapped this command with `nnoremap c "*y` and `nnoremap v "*p` on vimrc. This can be changed to what your system accepts. Made it easier to remember the command and interact with the outside world :)
Comment: Thanks for the hint with `vim-gtk` I always wondered why sometimes `y"*` failed to work! Maybe that rectifies emphasing this part a bit.
Comment: Answer good, but long story short, "vim-gtk" is must, it doesnt work without. " is a separate shortcut for a command input, similarly as the key :. "*y copies to the x-selection clipboard , "+y copies to the primary clipboard
Comment: My god this is difficult. Now I know why I don't use `:set mouse=a` (or dare I say XEmacs).
Comment: Default desktop Ubuntu should be compiled with this by default.
Comment: Good news for macOS users. I just tested on the default vim installed in macOS Ventura 13.3.1 and the `*` register works just fine with `:set mouse=a` enabled and all.
Comment: Working on Ubuntu 20.04. Clipboard support can be enabled by installing vim-gtk3: `sudo apt install vim-gtk3`
Answer: On Mac OSX

copy selected part: visually select text(type v or V in normal
mode) and type :w !pbcopy
copy the whole file :%w !pbcopy
paste from the clipboard :r !pbpaste

On most Linux Distros, you can substitute:

pbcopy above with xclip -i -sel c or xsel -i -b
pbpaste using xclip -o -sel -c or xsel -o -b
-- Note: In case neither of these tools (xsel and xclip) are preinstalled on your distro, you can probably find them in the repos
Comment: compatible with vim that is shipped with mavericks osx. add to your .vimrc ```vnoremap  :w !pbcopy
noremap  :r !pbpaste``` To use this mapping, if you want to copy, highlight text in visual mode and hit Ctrl-c to copy. To paste from the system clipboard, hit Ctrl-v.
Comment: On linux this works with :w !xclip -sel c or :w !xsel -b
Comment: For Linux Ctrl+C copy: in ~/.vimrc add:
`vnoremap  :w !xclip -i -sel c`
Comment: A far more helpful answer than the accepted one. Thank you!
Comment: I'm in Mac, vim shows +clipboard and either `:w !pbcopy` or `:%w !pbcopy` copies the entire file
Comment: This copies whole line for me
Comment: I've made an improved version which allows copying only part of the line here: https://vi.stackexchange.com/questions/26745/improve-copy-to-clipboard-using-xclip
Comment: +1 Works with Lion, though `vim --version` shows `-clipboard`
Comment: @davidtingsu's keybindings will conflict with `` in normal mode to enter visual block selection mode. Limiting it to insert mode only also conflicts with the insert literal char sequence.
Comment: @MortezaE for that to work you need a build of vim with clipboard support. on linux this can be `gvim`, `vim-gnome` or `vim-athena`
Comment: This is how you can verify clipboard support: http://vim.wikia.com/wiki/Accessing_the_system_clipboard#Checking_for_X11-clipboard_support_in_terminal
Comment: `xclip -o -sel -c` is supposed to be `xclip -o -sel c` and the command to copy a selection is not `:w !pbcopy` but instead `:'<,'>w !pbcopy`.
Comment: The only problem so far with this method is that pasting breaks formatting (mac osx mavericks). Seems like Mavericks messed up my Vim installation :-) if you use pbcopy and pbpaste in visual mode it's okay, but if you cannot use pbcopy and then Command + V without breaking formatting
Comment: hi, @Zeus77, thanks for the info. I'd like to update the answer. would you please tell me how to past from the clipboard on Linux? Or you can edit the answer by yourself if you want to :)
Comment: @Zeus77 xcopy & xsol don't work for me. They copy all content of file. I use vim 8.0 on ubuntu
Comment: @MortezaE add this to your vimrc `set clipboard=unnamed,unnamedplus`. this will use the OS clipboard for vim's yank operations. and then you can just select in visual mode and yank whatever you want.
Comment: @Zeus77 it doesn't work, but it's not so important. thanks
Comment: Oh I wasn't aware about it. I was using vim. thank you
Comment: This unfortunately does not work on mac (host) connected to a remote machine (per ssh).
Comment: Attaching a key combination to ```:w !xclip -i -sel c\n``` did the trick for me.
Comment: `:set mouse=` to reset mouse setting if someone made it impossible to do regular terminal-selection paste.
Comment: If you're getting the entire buffer copied, it's because you didn't first select the text you wanted to copy.  Use `v` or `V` to select the lines that will be copied.  Then `:w !pbcopy` copies only the selected text.
Comment: To avoid mapping Ctrl-C in your `.vimrc`, you can instead define a `leader` such as the space key.  For example: `let mapleader=" "` followed by `vnoremap c :w !pbcopy`
Answer: In your vimrc file you can specify to automatically use the system clipboard for copy and paste.
On macOS and Windows set:
set clipboard=unnamed

On Linux set (vim 7.3.74+):
set clipboard=unnamedplus

NOTE: You may need to use an up to date version of Vim for these to work.
http://vim.wikia.com/wiki/Accessing_the_system_clipboard
Comment: As an addendum to your note - you may also have to install extra packages to get this to work. If your vim lacks the `+xterm_clipboard` feature (visible when you run `vim --version`). This was the case for me (running Kubuntu 12.10). I had to install the `vim-gui-common` package to get the correct functionality.
Comment: `set clipboard=unnamed` works in Mac OS 10.11.6 (El Capitan) with vim 7.4
Comment: `set clipboard^=unnamed,unnamedplus` will solve it for Windows and Linux. Not sure about Mac.
Comment: You might wish to update your answer. It does not function on Ubuntu 18.04 with vim 8.0.
Comment: This works for me with nvim 0.4.4. Thanks! To copy a whole file I use ```ggvGGy```
Comment: 1. Copy on drag 2. mouse select,  works in Mac Sierra-10.12.6 and vim-version: 8.0.1800 by specifying following commands in ~/.vimrc file `set mouse=v` and `set clipboard=unnamed`
Comment: @LuísdeSousa `set clipboard=unnamedplus` works with Ubuntu 18.04 and Vim 8.0 when  `vim-gui-common` is installed as Jacob Dalton pointed out.
Comment: Working on Ubuntu 20.04. But requires to install vim-gtk3 to enable clipboard support: `sudo apt install vim-gtk3`
Answer: Use the register "+ to copy to the system clipboard (i.e. "+y instead of y).
Likewise you can paste from "+ to get text from the system clipboard (i.e. "+p instead of p).
Comment: The double quote character serves as the register selector in vi and vim.
Comment: @dash-tom-bang: the `+`/`*` difference is `SELECTION` vs `PRIMARY` copy buffers (can't recall which is which atm)
Comment: Yeah star is the selection, plus is the clipboard.
Comment: Two sets of shortcut to remember: `"+yy` (copy line to clipboard) and `"+yy` (copy line to selection); `"+p` (paste from clipboard) and `"*p` (paste from selection). `"` is to select register which is vim's own internal register by default (the way `yy` and `p` would work without referencing **any** type of register). PS: I wonder if there's a character for Vim's own internal register something like `"&yy` which turns to `yy` by default.
Comment: I use "*, but it seems that there's only a difference in X.
Comment: I also recall that in Vim you can have many internal registers and assign them to **letters** (I think it would be something like `"ayy` to copy into the `a` register) but I'm not very much informed about that :(
Comment: This is what I use (macOS v.10.12.6) and it works just fine. Wish this was higher up because it's a lot less complicated answer for mac users.
Comment: Is there any way to make `yy` copy things directly into the system buffer?
Comment: When people say "register" what do they mean? I find that term confusing :/ Sorry, I'm new to vim.
Comment: Any ideas why this solution might have stopped working? I always used `"+y` to copy to clipboard in nvim with Ubuntu, but recently it stopped working. Vim (and nvim) say `282 lines yanked into "+` when doing it, but then when I Ctrl+P somewhere, it does not paste it
Answer: @Jacob Dalton has mentioned this in a comment, but nobody seems to have mentioned in an answer that vim has to be compiled with clipboard support for any of the suggestions mentioned here to work. Mine wasn't configured that way on Mac OS X by default and I had to rebuild vim. Use this the command to find out whether you have it or not vim --version | grep 'clipboard'. +clipboard means you're good and the suggestions here will work for you, while -clipboard means you have to recompile and rebuild vim.
Comment: Or, instead of compiling yourself, you can install a vim package that has already been built with clipboard support. On OS X, Homebrew has this: `brew install vim`. On Ubuntu, you can use `sudo apt-get install vim-gnome`. On other (non-GNOME) Linux distros you may rather install `vim-gtk` or `vim-athena`.
Comment: Thanks, in Arch Linux I had to remove `vim` and install `gvim`
https://wiki.archlinux.org/index.php/Vim#Installation
Comment: Your answers is explaining why the yank doesn't work with clipboard, with your information alone i could do a better google search and make it work easily. And now it working. It would be better if you also include @NeilTraft comment to your answer so that people doesn't need to do google search.
Comment: On Mac, right after `brew install vim` I added `set clipboard=unnamed` to .vimrc. Run `source ~/.vimrc` in command line. In .bash_profile I added `alias vim="/usr/local/bin/vim"` then run `source ~/.bash_profile`. Now in vim just use `y` and `p` to copy/paste
Answer: Summing up and make it easier for newbies,
To copy the current line, in command mode type:
"*yy

To copy the whole file/buffer, in command mode, first go to the beginning via gg, then type
"*yG

As noted, this requires +clipboard out of vim --version, which indicate the availability of clipboard support, -clipboard means no.
Comment: I installed `vim-gtk` to turn `-clipboard` into `+clipboard`, than `"+yy` is working.
Comment: `"*5yy` says `5 lines yanked` but nothing in the clipboard?  os/x.
Comment: Yes i had verified +clipboard
Comment: The best solution, on Linux use `"+yG` instead.
Comment: `nnoremap c "*`  in `.vimrc` works quite well as a "copy" of sorts, followed by a motion to grab the text object you want to copy into your OS clipboard.
Comment: Thanks, you explained it exactly the way I needed it.
Comment: For mac users, you can install via homebrew to get +clipboard working. `brew install update` Then close the terminal and reopen. When you type `vim --version`, the +clipboard should now show.
Comment: I had always installed vim+otherbins to make it happen without knowing very well what was it. Thanks thanks!
Answer: For Ubuntu - July 2018
Use the register "+ to copy to the system clipboard (i.e. "+y instead of y).
Likewise you can paste from "+ to get text from the system clipboard (i.e. "+p instead of p).
You have to also make sure that vim is compiled with support for the clipboard. Try:
vim --version | grep .xterm_clipboard -o

and if it's -xterm_clipboard (a minus prefix) then you do not have support.
Here are some instructions for swapping out with a working version of vim that has clipboard support.
$ sudo apt-get purge vim
$ sudo apt-get autoremove (removes any extraneous vim dependency packages from system)
$ sudo apt-get install vim-gnome (or `sudo apt-get install vim-gtk3` for newer Ubuntu versions)

Check again with vim --version | grep .xterm_clipboard -o and you can confirm the clipboard is now available (ie. +xterm_clipboard)
Comment: You made my day, or maybe my month. After toiling with clipboardless vim on Ubuntu for years, this is an amazing feeling. **arcseldon, thank you!!**
Comment: Besides what was described above, I had to put `set clipboard=unnamedplus` in my `.vimrc` file for the yank to work. I am using Ubuntu 18.04.
Comment: Same as Elijah's comment above: I needed to follow this answer and also update .vimrc.
Answer: If you are using vim in and old version of macOS, unfortunately the shipped version of vim may and not be compiled with clipboard options. Luckily, homebrew can easily solve this problem.

Install vim:
brew install vim

Install gui verion of vim:
brew install macvim

Restart the terminal to take effect.

Append the following line to ~/.vimrc
set clipboard=unnamed

Now you can copy the line in vim with yy and paste it system-wide.

Updated Method:
I was never satisfied with set clipboard method for years. The biggest drawback is it will mess up your clipboard history, even when you use x for deletion. Here is a better and more elegant solution.

Copy the text [range] of vim into the system clipboard. (Hint: use v or V to select the range first, and then type the colon : to activate the Ex command):
:[line-range]yank +

E.g., to copy/yank lines 5-10 to the system clipboard * register use:
:5,10y *

Paste the content from the system clipboard into vim on a new line:
:put +

Note:

If you select a word range, the above will not work. use "*y or "+y to save this visual block to clipboard. However this is hard to type, I am still thinking about alternatives.
:help "* or :help *+ for more informations
brew info vim will be able to see other options for installing vim. Currently it does not have any other options.
Comment: `--with-override-system-vim` should be `--with-override-system-vi`
Comment: I'd like to try this to avoid installing lots of Xorg stuff on minimal systems, but I am missing something. I get "Not an editor command [range]yank +" after selecting in v mode and then hitting ":" .
Answer: I wasn't able to copy to my clipboard's system because I had this in my ~/.vimrc file:
 if has('mouse')
   set mouse=a
 endif

But if you add this line next, it will allow you to simply Ctrl+c to get whatever you have selected into your clipboard.
vmap <C-c> "+y

Original discussion and more details: Copy text out of vim with set mouse=a enabled
Comment: I didn't add the line to my .vimrc, but the link you provided was very useful. If you hold down SHIFT while selecting text in vim, you're able to copy text without entering visual mode. So thanks and +1.
Comment: Shift trick is what I needed. Works as well with editors like terminator that use Ctrl+Shift+c to copy while in the prompt, which is what I tried at first. I did have -xterm_clipboard installed with vim.
Comment: You can also use `set mouse=nvi`.  This omits command line mode. Then you can enter command mode (:) and use your mouse to copy.  Hit escape after.
Answer: This answer contains details specific to macOS users.
Append the following line to ~/.vimrc:
set clipboard=unnamed

If this does not work, check if your installed version maybe has the clipboard feature not enabled. When this answer was written (2019), the default vim shipped with macOS did not come with clipboard option enabled. You need that option to access the system clipboard.
To check if your vim has that option enabled use the below command
vim --version | grep clipboard

In the result, you should have +clipboard. If it is -clipboard, then your VIM does NOT have the option to access the system clipboard.
You need to MAKE and install your VIM with the option you need. Following are the commands.
# Create the directories you need
$ sudo mkdir -p /opt/local/bin
# Download, compile, and install the latest Vim
$ cd ~
$ git clone https://github.com/vim/vim.git
$ cd vim
$ ./configure --prefix=/opt/local
$ make
$ sudo make install
# Add the binary to your path, ahead of /usr/bin
$ echo 'PATH=/opt/local/bin:$PATH' >> ~/.bash_profile
# Reload bash_profile so the changes take effect in this window
$ source ~/.bash_profile"

The above will install the latest VIM with the option +clipboard enabled.
Now you can yank text to system clipboard. Below steps explains how to yank.

In vim command mode press v, this will switch you to VISUAL mode.
Move the cursor around to select the text or lines you need to copy.
Press y, this will copy the selected text to clipboard.
Go to any external application and CMD + v to paste.

I use MACBook Pro with macOS Mojave and the above works in it.
Answer: In vim under ubuntu terminal only,
press shift + drag mouse to select a text in vim then ctrl + shift + c on the terminal
then ctrl + v on other editor
Comment: This works to select only what is visual in vim, what if you want to select the entire file?
Comment: This copies line numbers, buffer borders of splits and all that is visible, instead of only the text / code.
Comment: @Gerep this method not work for entire file selection. it's a good to select a section of text on vim terminal only and where text displayed on the terminal screen.
Answer: This question already has a lot of answers. I am adding my way which I think is quick.
Quickly, you can press V (Shift + v) to active visual mode. In visible mode, you can use j and k to select the text you want to copy. After selection, use
"*y

Now, selected text is copied to clipboard.
Comment: For Mac OS X: works simple and perfect.
Make sure you have the "+clipboard" turned on, refer to gkb0986 answer for that.
Comment: This works out of the box - Big Sur, iTerm2
Comment: I like you method but, I am in tmux, and want to paste in another panel, you know how?
Answer: Keybindings to make it easier
I have been using these for many years now:
nnoremap Y "+y
vnoremap Y "+y
nnoremap yY ^"+y$

You can now just use upper case Y to copy to clipboard, and lowercase y won't be affected e.g. as by set clipboard=unnamed so you can still choose if the copy will go to the clipboard or not.
Tested on ubuntu 21.04, vim 8.2.
Comment: I was using `vim` on Manjaro Linux and the `clipboard` was not supported by the package, therefor keymaps did not work for me, so I replaced my `vim` package with `vim-clipboard` package then clipboard is available now and keymaps are working.
Answer: the solution for me was to install additional vim that has the clipboard option included:
sudo apt-get install vim-gnome

Comment: This is what I had to do for Ubuntu 16.04. I tried the other suggestions without success. This was the easiest and did what I expected with "+y.
Comment: Besides vim-gnome, this is also supported by default in neovim on Ubuntu 20.04
Comment: It works like a charm without any vimrc changes! still valid in Ubuntu 16.04
Comment: The `"+y` suggestion only worked with `vim-gnome`. Using Linux Mint 18.2.
Answer: You can find the answers here
Arch Wiki
For Linux:
First of all you have to enable Clipboard in your vim version by installing
gvim.

Next you have to put this line on your .vimrc file.
set clipboard=unnamedplus
Comment: +1, was surprised that this step is now required. In all of my previous Arch installation I didn't have to do it.
Comment: worked for ubuntu 18.04 too and running in tmux. Thanks!
Answer: If you are using GVim, you can also set guioptions+=a. This will trigger automatic copy to clipboard of text that you highlight in visual mode.
Drawback: Note that advanced clipboard managers (with history) will in this case get all your selection history…
Answer: If your vim happens to be compiled without +xterm_clipboard option like it is by default in Debian and I guess Ubuntu, you can pipe selection or entire buffer to external program that handles desktop clipboard. For xclip (which you may need to install previously), the command will be :w !xclip -sel clip
Comment: Thanks for this - it hasn't worked for me on Ubuntu (so confirming your Ubuntu guess is correct) for ages and I didn't know why. Now I can see `-xterm_clipboard` in the flags shown when I `vim --version`.
Comment: This helped me find a good source of clipboard support: http://vimcasts.org/blog/2013/11/getting-vim-with-clipboard-support/
Comment: You can also add a custom command in your vimrc: `command Xclip :w !xclip -sel clip`, then you can just type `:Xclip`
Answer: If you have xclip an easy way of copying text to the clipboard is as follows:

Yank text you want to copy. (y command in vanilla vim)
Type in :call system("xclip -selection clipboard", @")

:call system() runs a terminal command. It takes two arguments, the first the command, the second what to pipe to that command. For example :echom system("head -1", "Hello\nWorld") returns Hello (With some padding). echom returns the output of a command, call doesn't.
xclip -selection clipboard just copies text into the system clipboard as opposed to the default X clipboard, (Accessed by the middle moue button).
@" returns the last yanked text. " is the default register, but you could use any register. To see the contents of all registers, type :registers.
Comment: This is more robust, it works even when vim is not complied with support for the clipboard and on any OS. For example, on Mac run ``:call system("pbcopy",@")``. One can bind this command to a key.
Comment: it works fine, but can I put it in my vimrc, will it work. It is not working for me.
Answer: I've been struggling with this for months till now on MacOsX using keyboard shortcuts.
I know question isn't about using keyboard shorts. But this might help someone with the same concern.
I found that if you uncheck:

View -> Allow Mouse Reporting

from Terminal menu, you'll be able to copy to clipboard using

command + c

again.
Comment: `⌘ + R` = "View -> Allow Mouse Reporting"
Answer: I'm a Vim newby but, to copy all the text to system clipboard (e.g if you want to paste it to a word processor or another text editor like gedit, mousepad etc...), in normal mode:
ggVGy
or, more simply:
:%y
As suggested, I also installed vim-gtk and put
set clipboard=unnamedplus
in my .vimrc
and everything works fine
If you want to copy only a portion of text, use visual mode (v), select the text you want to copy and press y.
Finally, I suggest a clipboard program like Clipman (my favorite), Clipit, Parcellite or similar.
(I'm using vim 8.0 in Debian Stretch Xfce)
FORGIVE ME FOR MY ENGLISH! :-)
Answer: My solution was putting the following line to .vimrc:
map <C-y> :w !xclip -sel c <CR><CR>

The script copies the selected line (trough visual mode) or the file content (if none is selected) to the clipboard using Ctrl + y. I'm  using Manjaro Linux if that matters.
Comment: Nice one! Worked great for me.
Comment: Thanks, this works well! Just needed a way to quickly copy my selection to the clipboard as it spanned beyond the terminal view.
Comment: This one does work for `vi`/`vim` on _macOS_
Answer:
Put set clipboard=unnamed in your vimrc.
Select what you want to copy in Visual mode (Press v to enter).
Back to Normal mode (Press escape[esc]), press y to copy.
If you want to paste something from OS's clipboard, press p/P in Vim Normal mode.
Answer: Maybe someone will find it useful. I wanted to stay independent from X clipboard, and still be able to copy and paste some text between two running vims. This little code save the selected text in temp.txt file for copying. Put the code below into your .vimrc. Use CTRL-c CTRL-v to do the job.
vnoremap  :w !cp /dev/null ~/temp.txt && cat > ~/temp.txt
noremap  :r !cat ~/temp.txt
Answer: I'm on mac osx (10.15.3) and new to vim. I found this so frustrating and all the answers on here too complicated and/or didn't apply to my situation. I ended up getting this working in 2 ways:

key mapping that uses pbcopy: works on the old version of vim that ships with mac.

Add vmap '' :w !pbcopy<CR><CR> to your ~/.vimrc
   Now you can visually select and hit '' (two apostrophes) to copy to clipboard

Install newer version of vim so I can access the solution most recommended in other answers:

brew install vim  alias vim=/usr/local/bin/vim (should add this to your ~/.bashrc or equivalent)
   Now you can visually select and hit "+yy to copy to clipboard
Comment: very nice solution!
Answer: In case you don't want to use any graphical interface for vim and you prefer to just stick with terminal emulator there may be a much simpler approach to this problem. Instead of using yank or anything like this, first take a look at documentation of terminal you use. I've been struggling with the same issue (trying to use +clipboard and xclip and so on) and in the end it turned out that in my terminal emulator it's enough to just press shift and select any text you want to copy. That's it. Quite simple and no need for messing with configuration. (I use urxvt by the way).
Answer: I had issue because my vim was not supporting clipboard:
vim --version | grep clip
-clipboard       +insert_expand   +path_extra      +user_commands
+emacs_tags      -mouseshape      +startuptime     -xterm_clipboard

I installed vim-gnome (which support clipboard) and then checked again:
vim --version | grep clipboard
+clipboard       +insert_expand   +path_extra      +user_commands
+emacs_tags      +mouseshape      +startuptime     +xterm_clipboard

Now I am able to copy and paste using "+y and "+p respectively.
Answer: Besides vim-gnome, "+y is also supported by default in neovim on Ubuntu 20.04.
If you don't want to install a new program, you could always do the lazy method of cat file.txt or gedit file.txt and copy from there.
Answer: I wrote a simple line in my .vimrc to get copy working. Hope this helps someone. My vim is not installed with Clipboard support, unfortunately, so none of these suggestions worked for me. Basically, paste this line in your .vimrc:
map <C-c> y:e ~/clipsongzboard<CR>P:w !pbcopy<CR><CR>:bdelete!<CR>

If you'd like to read details about what this does, you can read about this on my blog
Comment: Buyer beware.  On mac, this has weird effects.
Comment: this does not seem to copy anything to the clipboard when using as instructed (on linux ubuntu 16.04, no clipboard support), and if multiple files are opened in a vim session, will close the tab where the actions were taken (visual select and C-c).
Answer: For some international keyboards, you may need to press "+Space to get a ".
So in those case you would have to press "Space+y or "Space*y
Answer: for OSX, like the 10342 answers above made clear, you need to make sure that vim supports the clipboard feature, said the the one that comes pre-shipped with OSX does NOT support clipboard, and that if you run
brew install vim it would work.
Except that running vi will still make you run the preshipped OSX version, not the one you installed from brew.
to get over this, I simply aliased my vim command to the brew version, not the OSX default one:
alias vim="/usr/local/Cellar/vim/8.0.1100_1/bin/vim"

and now i'm golden
Comment: The MacOS version of vim on Monterrey and Ventura is 9.0 and does support named clipboard. On Catalina, it's 8.1 and also supports clipboard. Except yanking to a named clipboard over ssh connection doesn't work. I disabled set clipboard=unnamed in my .vimrc file.
Answer: In my instance selecting text by highlighting (clicking and dragging) with my mouse was causing vim to enter into visual mode.
On a mac anyway, the easiest solution is to use fn + mouse click and drag to avoid entering into visual mode.
If you wish to avoid this behavior by default you can edit your vimrc
Answer: I have struggled a lot in copying to clipboard. Inside Vim it is quite simple using visual mode but if you want to copy to the clipboard things are quite messsed. I have simple method of copying using xclip utility. For this you must have to install xclip first.
for the whole file it is very simple
xclip -sel clip filename
but if you want to copy only a particular range of line numbers
tail -n +[n1]  filename  | head -n  [n2] | xclip -sel clip
you can make use of ~/.bashrc to simplify this
#rangecp copy lines from n1 to n2 from a given file to clipboard
function rangecp()
{
    if [ -f $1 ]
    then
        if [ ! -z $3 ]
        then
            diff=$(($3 - $2 + 1))
            #diff=`expr $3 - $2 + 1`
            tail -n +$2  $1 | head -n $diff | xclip -sel clip
        elif [ ! -z $2 ]
        then
            tail -n +$2  $1 | xclip -sel clip
        else
            echo "Provide a range from [n1] lines to [n2] lines"
        fi
    else
        echo "[ $1 ] file doesn't exist"
    fi
}

then
source ~/.bashrc
How to use
rangecp filename.txt 50 89
rangecp filename.txt 50

Answer: I saw many answers on this question and the way to make this work was a combination of many.
The steps I followed to make vim copy to system clipboard are

Uninstall vim using sudo apt remove vim. (I was too lazy to find how to re-compile it with the +clipboard support.
Install a different vim package called vim-athena using sudo apt install vim-athena that ships with +clipboard.
Add to ~/.vimrc the following line: set clipboard=unnamedplus.
Source the file by entering command mode and typing source %.
Save and exit.

Note:
I am using Ubuntu 20.04.
Answer: In linux with gnome (ubuntu, xubuntu etc) install vim-gnome and you will be able to use VISUAL to select and then Ctrl + C normally and paste in other applications with Ctrl + V
sudo apt install vim-gnome

Answer: selecting with the the help of the mouse and right-click copy worked in my case.
I didn't want the line numbers included so I :set nonumber before copying.
Comment: how can you do that in nerdTree
Comment: That has nothing to do with vim and is exclusively a terminal based copy to (X) clipboard.
Comment: I'm not sure @ji-ruh
Answer: Nothing above worked for me on my windows laptop.
Ctrl+C was fine for copying.. but I needed
Shift+Insert to Paste !
(A good reason to always get a laptop where Insert can always be accessed without pressing a secondary key)
Answer: For Mac OS X, in the terminal:

run vim --version | grep clipboard to check if the clipboard is enabled(with +)

add the code below into the .vimrc file

if has("clipboard")
  set clipboard=unnamed " copy to the system clipboard

  if has("unnamedplus") " X11 support
    set clipboard+=unnamedplus
  endif
endif

restart terminal & vim

reference: Setting up Vim to yank to clipboard on Mac OS X
Answer: if you connect to the unix system thru putty then follow the steps below to copy content of a file

Highlight text you want to copy ( you'll be able to copy page by page )
press ctrl+c ( it'll copy the text to clipboard
paste in any external editor
Done
Answer: I want to supplement a way to copy the line to the clipboard and use it on the function.
here is an example that you open the URL in the browser
let g:chrome_exe = 'C:/.../Google/Chrome/Application/chrome.exe'
function OpenURL()
    " copy the line and put it in the register *
    normal "*yy
    :execute "silent !start ".g:chrome_exe." ".getreg("*")
endfunction

map ,url :call OpenURL()<CR>

Answer: Shift+Ctrl+C
if you are in graphical mode of Linux, but first you need to select what you need to copy.

How to copy to clipboard in Vim?


closedness a subset of a Hilbert space

Question: Let $H$ be a Hilbert space that admits a countable orthonormal basis $\{e_i\}$. I know this means that $H$ is separable and so is $S$ (as a subset of it, defined below). Show that $S$ is a closed subset of $H$, where
$$
S=\left\{\frac{i+1}{i} e_i \, :\,  i\geq 1\right\}.
$$
Thanks for the help.
Answer: Hint: define $x_i:=\frac{i+1}ie_i$· Since $\lVert x_i-x_j\rVert_H\geqslant\sqrt 2$ if $i\neq j$, we can show sequential closeness.
Comment: Thanks. It is a good idea. This inequality shows that the sequence xn is not a Cauchy sequence unless it is a constant sequence  for n>= n0 for some n0. (i.e., after finitely many terms the sequence must be constant).
Comment: @Hamid Why is $x_n$ necessarily a Cauchy sequence?
Comment: Take x in cl(S). Then there exists a sequence (xn) in S such that (xn) converges to x( x is in X). Since (xn) is a convergent sequence (in X), then it is a Cauchy sequence. While any non-constant sequence in S is not Cauchy( because of the above inequality). This shows that (xn) must be a constant sequence and implies that x is in S. This proves the closedness of S.

closedness a subset of a Hilbert space


Asp.Net Identity usando procedure

Question: Estou precisando da valiosa ajuda de vocês, tenho um projeto web para fazer usando Asp.net e gostaria de usar o Identity para fazer o controle de acesso, usar todos os recursos existentes para fazer o login seguro.
Problema que na base de dados onde o projeto será implantado, apenas é permitido salva e alterar na base usando procedure, teria alguma forma de fazer o identity ser compatível com o uso de procedure?
Answer: O identity não seria compatível com essa modo de uso, porem vc pode usar um EntityFrameWork para criar o ORM dessa forma. Sendo assim ficaria transparente para você.

Assim ele geraria para voce o codigo mais ou menos assim:

Este exemplo é feito com uma consulta, mas pode ser feito para save e update.
Segue um link para te ajudar. link
Comment: Obrigado pela ajuda

Asp.Net Identity usando procedure


Prevent SwiftUI animation from overriding nested withAnimation block

Question: I have a screen with a draggable component (the "Springy" text) that springs back when released with a very prominent spring animation.
There is some text that comes in asynchronously (in this example, using a Timer), and I want that to fade in nicely while the Springy label moves up smoothly to make room for it.

I added an animation to the VStack, and it transitions as I want it to when the asynchronously-loaded text fades in. However, that breaks the spring animation on the "Springy" text.
There is an animation that's commented out here, and if switch the 1 second animation to that spot the asynchronously-loaded text fades in, but right at the beginning of the animation the "Springy" text jumps up instead of sliding up.
How can I get both animations to work as I want them to?
import SwiftUI
import Combine

class Store: ObservableObject {
    @Published var showSection: Bool = false

    private var cancellables: [AnyCancellable] = []

    init() {

        Timer
            .publish(every: 2, on: RunLoop.main, in: .common)
            .autoconnect()
            .map { _ in true}
            .assign(to: \.showSection,
                    on: self)
            .store(in: &cancellables)
    }
}

struct ContentView: View {

    @ObservedObject var store = Store()

    @State var draggedState = CGSize.zero

    var body: some View {
        VStack {
            Spacer()
            VStack(alignment: .leading) {
                VStack(spacing: 4) {
                    HStack {
                        Text("Springy")
                            .font(.title)
                        Image(systemName: "hand.point.up.left.fill")
                            .imageScale(.large)

                    }
                    .offset(x: draggedState.width, y: draggedState.height)
                    .foregroundColor(.secondary)
                    .gesture(
                        DragGesture().onChanged { value in
                            draggedState = value.translation
                        }
                        .onEnded { value in
                            // How can this animation be fast without the other animation slowing it down?
                            withAnimation(Animation
                                            .interactiveSpring(response: 0.3,
                                                               dampingFraction: 0.1,
                                                               blendDuration: 0)) {
                                draggedState = .zero
                            }
                        }
                    )

                    VStack {
                        if store.showSection {
                            Text("Something that animates in after loading asynchrously.")
                                .font(.body)
                                .padding()
                                .transition(.opacity)
                        }
                    }
                    // When the animation is here, it doesn't cancel out the spring animation, but the Springy text jumps up at the beginning of the animation instead of animating.
//                    .animation(.easeInOut(duration: 1))
                }
                // Animation here has desired effect for loading, but overrides the Springy release animation.
                .animation(.easeInOut(duration: 1))
            }
            Spacer()
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
            .preferredColorScheme(.dark)
    }
}

Expanded question, based on answer from Asperi.
Now, supposing I have multiple elements in this main VStack that I want to animate when they come in.

Is it a good solution to add a separate .animation modifier with a value for each section I want to animate?

In the expanded example below, that's the part with:
.animation(.easeInOut(duration: 1),
                       value: store.showSection)
.animation(.easeInOut(duration: 1),
                      value: store.somePossibleText)
.animation(.easeInOut(duration: 1),
                      value: store.moreInformation)

I am using 3 approaches here to determine whether to show a section or not. I used Bool in the initial example for simplicity, but in my real scenario I think it will make the most sense to use the String? approach instead of setting a separate Bool or checking for an empty string. Are there drawbacks to using that when it comes to animations, or is that fine? It seems to work well in this example given Asperi's solution.

Here's the full example again with the new modifications:
import SwiftUI
import Combine

class Store: ObservableObject {

    @Published var showSection: Bool = false
    @Published var somePossibleText: String = ""
    @Published var moreInformation: String?

    private var cancellables: [AnyCancellable] = []

    init() {

        Timer
            .publish(every: 2, on: RunLoop.main, in: .common)
            .autoconnect()
            .map { _ in true }
            .assign(to: \.showSection,
                    on: self)
            .store(in: &cancellables)

        Timer
            .publish(every: 3, on: RunLoop.main, in: .common)
            .autoconnect()
            .map { _ in "Something else loaded later" }
            .assign(to: \.somePossibleText,
                    on: self)
            .store(in: &cancellables)

        Timer
            .publish(every: 4, on: RunLoop.main, in: .common)
            .autoconnect()
            .map { _ in "More stuff loaded later" }
            .assign(to: \.moreInformation,
                    on: self)
            .store(in: &cancellables)
    }
}

struct ContentView: View {

    @ObservedObject var store = Store()

    @State var draggedState = CGSize.zero

    var body: some View {
        VStack {
            Spacer()
            VStack(alignment: .leading) {
                VStack(spacing: 4) {
                    HStack {
                        Text("Springy")
                            .font(.title)
                        Image(systemName: "hand.point.up.left.fill")
                            .imageScale(.large)
                    }
                    .offset(x: draggedState.width,
                            y: draggedState.height)
                    .foregroundColor(.secondary)
                    .gesture(
                        DragGesture().onChanged { value in
                            draggedState = value.translation
                        }
                        .onEnded { value in
                            // TODO: how can this animation be fast without the other one slowing it down?
                            withAnimation(Animation
                                            .interactiveSpring(response: 0.3,
                                                               dampingFraction: 0.1,
                                                               blendDuration: 0)) {
                                draggedState = .zero
                            }
                        }
                    )

                    if store.showSection {
                        Text("Something that animates in after loading asynchrously.")
                            .font(.body)
                            .padding()
                            .transition(.opacity)
                    }

                    if store.somePossibleText != "" {
                        Text(store.somePossibleText)
                            .font(.footnote)
                            .padding()
                            .transition(.opacity)
                    }

                    if let moreInformation = store.moreInformation {
                        Text(moreInformation)
                            .font(.footnote)
                            .padding()
                            .transition(.opacity)
                    }
                }
                .animation(.easeInOut(duration: 1),
                           value: store.showSection)
                .animation(.easeInOut(duration: 1),
                           value: store.somePossibleText)
                .animation(.easeInOut(duration: 1),
                           value: store.moreInformation)
            }
            Spacer()
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
            .preferredColorScheme(.dark)
    }
}

Answer: If I correctly understood your expectation, it is enough to bind last animation to showSection value, like below
}
// Animation here has desired effect for loading, but overrides the Springy release animation.
.animation(.easeInOut(duration: 1), value: store.showSection)

Tested with Xcode 12 / iOS 14.
Comment: Thank you. That's a simple solution that achieves exactly what I was looking for in my example. I expanded the question to a more complicated situation and would appreciate any additional insight you have about that.


Debian server is killing my network

Question: I have a Debian 6.0 server and everything was running fine with it. This server is my environnement so I can develop web application.
Since yesterday, the server is doing something to the network and I don't know how to find the source. Everytime the server is plugged in the network, the switch and the router go crazy and the network doesn't work fast anymore. I get 2654ms when I ping Google. However, when I ping another computer I still get 1ms. This only mean that the problem is between my server and Internet. The router is so busy that he don't answer when you contact it. If I unplug my server, everything goes back to normal. If I plug it back, I can see the LED on the switch flashing crazy like it's gonna blow.
Is there a way to isolate the problem ? I have no clue at all.
Thanks you.
Comment: First off, cool the hyperbole - your switch is not "gonna blow". You have a problem, troubleshoot it *logically and methodically* - you already determined this system is the culprit, so now put it on an isolated network and look at the traffic it produces. Run `nettop` or similar to see if it's a specific process causing the problem. Boot off a LiveCD to rule out a hardware issue. If you determine the box is compromised proceed per http://serverfault.com/questions/218005/how-do-i-deal-with-a-compromised-server
Comment: Is this running behind a firewall or NAT of some sort?  That may help to narrow things down.
Comment: Boot the Deb6 hardware off a livecd, and reconnect.  Do you still have problems?  If yes, then hardware/wiring is messed up.  If no then it is something running on the Deb6 box.  Login, and see what is running.
Answer: Sounds like the server has been infected and you need to reinstall it.
Comment: Is there a way to isolate the % of use of the network per process ?
Comment: Yes - see [Daniel's suggestion](http://serverfault.com/a/476464/2101) for nethogs or [voretaq7's suggestion](http://serverfault.com/questions/476448/debian-server-is-killing-my-network/476449#comment527899_476448) for nettop.
Answer: It's a shot in the dark, but does your Debian server have an Intel 82574L ethernet controller? If yes, take a look at http://blog.krisk.org/2013/02/packets-of-death.html
Answer: Try to identify the process which is generating all the traffic. One useful utility would be nethogs. Once you have identified the process, use lsof to see all the files opened by that program and look for any suspicious looking files, in case your server is infected.

Debian server is killing my network


Logistic family and chaos

Question: It is a well known fact that the map $f(x)=4x(1-x)$ is chaotic on $[0,1]$. By chaotic I mean the usual definition, i.e.:
a) the periodic points of $f$ are dense in $[0,1]$,
b) $f$ is topologically transitive,
c) $f$ exhibits sensitive dependence on initial conditions
One way to prove it is to show that the map:
$$T(x)=\begin{cases}
2x, & \text{if }x\in[0,1/2) \\
2-2x, & \text{if }x\in [1/2,1]
\end{cases}$$ is chaotic, and then to show that there is a conjugacy between $f$ and $T$, which implies that $f$ is chaotic.
According to Wikipedia for most values of $r>3.56995$ the function $f_r(x)=rx(1-x)$ is chaotic on a subset of $[0,1]$.
I am interested in proving that $f_{3.6}(x)=3.6x(1-x)$ is chaotic. By looking at the cobweb plot it seems that $f_{3.6}$ is chaotic on the interval $[0.324,0.9]$. I have tried to use a similar approach to the one described above to show that $f_{3.6}$ is chaotic, but I have not been able to find a conjugacy between $f_{3.6}$ and $T$. Does anybody know a way to show that $f_{3.6}$ is chaotic on $[0.324,0.9]$?
Comment: Since a conjugacy would imply an 'explicit' solution for the iterates of the map, it's very unlikely that you'll find one outside of some exceptionally special cases (the case $r=4$ being the only noteworthy one that I know of)
Comment: According to http://mathworld.wolfram.com/LogisticMap.html the only other known explicit solutions are for $r=-2$ and $2$ (I guess the trivial case $r=0$ should be added).
Comment: Ok so is there any other way to show that it is chaotic?
Answer: This map is certainly not chaotic on any invariant interval.  It's likely that $f^2$ is chaotic on an interval smaller than the one you mention, but I don't have a proof.
As is well known, the critical orbit (the orbit of the critical point $1/2$, in this case) dominates the dynamics. The most famous fact along these lines is that an attractive orbit must attract a critical point.  Even when the map is chaotic, the critical orbit is extra important through the kneading theory.  So let's start by iterating the function from the critical point $1/2$ and examine the output.  If I plot the first $2000$ iterates as points along the number line, I see something like so:

Thus, the orbit appears to be dense in the union of two sub-intervals.  We can see what's going on by plotting $f^2$.

Note that there are two, invariant sub-intervals for $f^2$ with endpoints labeled in red in that figure.  These are exactly the the first four iterates of $f$.
$$(d,a,c,b) = (f(1/2), f^2(1/2), f^3(1/2), f^4(1/2).$$
On these sub-intervals, has nearly the classic unimodal look that gives rise to chaos.  It's not quite there, though.
It should probably be pointed out that chaos on an entire interval is rare in the logistic family.  This is made precise in the paper Generic Hyperbolicity in the Logistic Family.  In fact, between any two $\mu$ values such that $f_{\mu}(x)=\mu x(1-x)$ has an attractive orbit, there is another such $\mu$ value.  It follows that the set of all $\mu$ values without attractive orbits is nowhere dense; this precludes the possibility that these $\mu$ values have chaotic intervals.  It is much more common that the chaotic set is a Cantor set, arises in my answer here.
Answer: OK it appears that my question was harder than I thought. Luckily, I have found a paper that answers a question close to mine:
http://pyu1.apmaths.uwo.ca/~pyu/pub/preprints/SY_DCDIS_B2007.pdf
They show that for any $r\in [3 + (2/3)^{1/2},4]$, there exists a compact and perfect invariant set $D ⊂ [0,1]$ such that $f_r$ is chaotic on $D$ (chaotic in the sense described in my question). In particular, they use the concept of snap-back repeller. It is not possible to use this approach for the case $r=3.6$ but it's still a proof that the logistic map is chaotic for values different from $r=4$, which was my main interest. Apparently, the claim that for most values of $r>3.569946$ the logistic map is chaotic has only been verified numerically.
Comment: Link's dead. Can u update?

Logistic family and chaos


Multiple urls of same node

Question: This seems duplicate content, how can i  send a header 410 for the incorrect version of the url and make sure only the correct url is used on the whole website.
This is the original URL: http://www.traveldudes.org/node/2504/
This is the alias: http://www.traveldudes.org/travel-tips/climate-and-best-time-visit-serengeti-tanzania/2504
But what's this URL? http://www.traveldudes.org/node/2504/gallery
Or what's this URL= http://www.traveldudes.org/node/2504/map
Answer: There are a couple of easy to use modules that will help you manage your URL aliases.  They include,

Pathauto
Redirect
Global Redirect

The first two aliases you have sounds like the 'default' ones.  You may have created (or one of the modules you have installed automatically) created the other aliases.
All the same, you can manage your aliases (and re-directs) using the modules I mentioned.

Multiple urls of same node


$X$ is $T_1$ if and only if every finite subset of $X$ is closed

Question: Hi I am supposed to show that $X \ is \ T_{1} \iff$ Any finite subset of $X$ is closed, I tried to show both directions, comments would be appreciated.
Let $X$ be $T_{1}$, and let $A$ be a finite subset of $X$. Now to show that $A$ is closed it suffices to show that $X - A$ is open.
Since $X$ is $T_{1}$ $\forall x \neq y \ \exists  $ an open set $U$ s.t. $x \in U, y \notin U$
for $X - A$ to be open in $T_{1}$ we must have $\forall x \neq y$
$\exists x \in X-A $ s.t. $y \notin X-A$ which is true since $X$ is $T_{1}$ Hence $A$ is closed
For the converse statement must show that
Any finite subset of $X$ is closed $\implies$ $X$ is $T_{1}$
Let $A$ be a finite subset of $X$. Since $X-A$ is open $\exists$ a NB around each point in $X-A$. Let $U$ be such a NB for $x \in X-A$. Since A is finite and assuming non empty, $\exists$ elements $y \in A$ s.t. $y \neq x$ which is not in $U$ $\square$
Answer: I cannot really follow your proof and I decided to give an alternative proof, enabling you to compare.

First observe that any finite subset of $X$ is closed if and only if every singleton-subset of $X$ is closed.
Here $\implies$ is immediate (singletons are finite sets) and $\impliedby$ follows from the fact that a finite union of closed sets is again closed, combined with the fact that a finite set is a finite union of singletons.
Based on this we conclude that it is enough to prove that $X$ is $T_1$ if and only if its singleton-subsets are closed.

$\implies$
Let $a\in X$ so that $\{a\}$ is such a singleton. Then for every $b\neq a$ an open set $U_b$ exists with $a\notin U_b$ and consequently $\{a\}^{\complement}=\bigcup_{b\neq a}U_b$. Then as a union of open sets $\{a\}^{\complement}$ is open, or equivalently $\{a\}$ is closed.
$\impliedby$
Let it be that $a\neq b$. Then $b\in\{a\}^{\complement}$ and $\{a\}^{\complement}$ is an open set that does not contain $a$ as an element.

P.S. Above $\{a\}^{\complement}$ denotes the complement of $\{a\}$.


Understanding proof why there can only be one triangle for $a^2 + b^2 = c^2$

Question: I'm following along the book "Basic Geometry" by Birkhoff and Beatley. It contains a proof for the Pythagorean Theorem:

In any right triangle the square of the hypotenuse is equal to the sum of the squares of the other two sides; and conversely.
Given triangle ABC in which $\angle C = 90°$. To prove: $a^2 + b^2 = c^2$
...
Converse: Given lengths $a, b, c$ such that $a^2 + b^2 = c^2$. To prove: there is one and only one right triangle having these lengths for sides.
Proof: Construct a triangle ABC such that $AC = b$, $\angle C = 90°$ and $CB = a$.
Then $a^2 + b^2 = c^2$. (Why?)
But $c^2 = a^2 + b^2$ (Given).
Therefore $(AB)^2 = c^2$ and $AB = c$
So there exists at least one right triangle with sides $a, b, c$. If more than one such triangle exists, these triangles must be equal, for it they are unequal, they violate Principle 8.

Principle 8 is SSS congruence.
I understand that if there is more than one triangle that fullfills $a^2 + b^2 = c^2$ for the same $a, b, c$ then these triangles must be equal.
What I don't understand is why the converse proof from above shows that there is at least one such triangle.
Comment: You can explicitly construct the triangle.  Given $a,b,c$ with $a^2 + b^2 = c^2$, this is saying: Construct a right triangle with leg lengths $a,b$.  Then the hypotenuse has length $\sqrt{a^2 + b^2}$ by the Pythagorean theorem, which then must be your $c$, since by hypothesis $a^2 + b^2 = c^2$.  So, you have a right triangle with lengths $a,b,c$.
Comment: @JairTaylor So as far as I understand, since we have three numbers $a, b, c$ which satisfy $a^2 + b^2 = c^2$. Now we draw two legs of the triangle a, b and with a 90 degree angle between them. Deriving from what was given, we find that $c = sqrt{a^2 + b^2}$ and now we know all three sides of the triangle. Thus this proofs that we can construct a right triangle from any $a, b, c$ if they satisfy $a^2 + b^2 = c^2$ - is my understanding correct?
Comment: Yes, that's correct.
Answer: Do you know that if $a,b,c$ are positive numbers such that $c < a + b$ (where $c$ is the largest of the three) then there is a triangle with sides $a,b,c$?
Then you can see that if you have $a,b,c$ with $a^2 + b^2 = c^2$ then $c^2 < a^2 + 2ab + b^2 = (a+b)^2$, so there is such a triangle.
Comment: I think that rule is only derived later in the book as a corollary. I'm mainly stuck at this line "Then $a^2 + b^2 = c^2$. (Why?)" because I can't answer that question _Why?_
Comment: You can construct a triangle with sides $a$ and $b$ that has a right angle between them, right? Then, by the Pythagorean theorem, the third side must be $c$ such that $c^2 = a^2 + b^2$.
Comment: @Max $a^2 + b^2 = c^2$ is true by hypothesis - you are given $a,b,c$ such that $a^2 + b^2 = c^2$.  So it does not need justification.  I don't know why they would include the parenthetical (Why?) in this case - it makes me wonder if there was an error in the transcription or the original text.
Answer: The claimed converse is the following statement: If the three sides of a triangle $\triangle$ satisfy $a^2+b^2=c^2$ then the triangle has a right angle at $C$.
For the proof we draw an auxiliary right triangle $\triangle'=A'B'C'$ with $|A'C'|=b$, $|B'C'|=a$, and a right angle at $C'$. There is no question that such a triangle exists. Using the already proven part of Pythagoras' theorem we then can say that $|A'B'|^2=a^2+b^2=c^2$, hence $|A'B'|=c$. This shows that $\triangle'$ has the same side lengths as $\triangle$. By "Principle 8" it is then congruent to $\triangle$. This implies that the angles are equal as well; in particular the angle at $C$ is $90^\circ$.


Accuracy measurement for sequential feature selector in Linear Discriminant Analysis

Question: One of the known issues with Linear Discriminant Analysis is it's tendency to overfit to high dimensional data. Although there's a wide range of methods to reduce this (PCA, bagging etc). I'm interested in looking at applying  sequential feature selector to reduce the number of dimensions down to a more reasonable dataset.
However, which evaluation measure is most suitable? Classic accuracy almost seems counter intuitive since we're not directly trying to optimize this but rather ensure the value is accurate (We are applying CV within the sequential feature selector) Would mean_absolute_error or F1 be better values, and if so why?
Notes:
I'm using the Mlxtend python library
This question is purely out of interest/thought experiment, I'm not interested in other methods
Answer: After doing some more research, and talking to a professor, I'm told cross validation error, or mean squared error would be the best evaluation metric.
Note: I will reopen this answer is someone responds in the future.


Building up stamina with my practice routine

Question: For reference I'm an electric bass player who played three or so years at age 20. I took four years of hiatus and restarted a couple of months ago. My problem has been lately my plucking hand cramping up probably from playing too hard and too much right away. I'm wanting to start up properly and not destroy my hands.
I was thinking of 15-20 minutes of physical practice a day at first, working on sight reading after a five minute warm up every few days, adding a two minute extention after a three to five day period.
That, however, leaves ear training. I'm using an app for now but want to move back to transcription of songs. My problem with that being I tend to lack discipline and keep going and going till I figure things out. That may have led to my hand cramping and being sore.
Anyway, sorry about the rambling nature of this post. I'm looking for input to see if my ideas are sound or how you might approach it.
Thanks.
Comment: Take 5- 10 min breaks from playing.  You can do different exercises or something else during the break.
Answer:
Always be relaxed and comfortable as possible. if that means getting lighter strings then do it. If that means practicing not 15 minutes per day, but for several 15 minute sessions daily, then do it.
Make a routine
Stick to the routine
Find someone within 100 miles whom you admire and contact them about lessons

Mine - warmup -
   scales up one down the next, focus a different mode each week, also include melodic minor modes, and arpeggios (min maj aug dim)
After warmup - Classical Study, I'm on Eduard Nanny Methode por la Contrabasse, and John Patittuci Melodic Etudes book
Standards - typically 3 standards or jazz songs per week, learn the walking line, melody, solo, trade 4s with yourself, different endings, chord subs, ect. try to memorize if i can, not the most important though.
Physical Exercises - 16th notes octaves at 120, slap, tap, or whatever crazy feat i'm trying to accomplish, this can be replaced with transcription (shudder).
I spent like 2 weeks on just bebop transcription and I also had a funk gig at the same time coming up so learning those songs. I lost my schedule actually I think that kind of hurt me because I burned out hard. I was able to do it and had stamina, but crashed HARD after, like a week no practice hard, so yeah stick to your schedule.
Comment: Nice structured answer!
Answer: Don't underestimate the ability to mentally relax your arms, forearms, and hands.
If your hand is feeling cramps, you definitely need to investigate your arms more with a relaxed mind, and also maybe get a few massages.  A lot of emotional energy can be pent up in your body, so don't slack on the sweaty exercise...
You want to get back into transcription... that part is really fun, but if it hurts your hands after a while on bass you can always get some Suzuki Sound Blocks (like a xylophone but each note is a separate block).  Then you can train your ears and harmonize even without your bass.
Music to me has a few levels:  left-brain / right-brain gotta crosstalk so things you can do to expand your mind shall help your playing, and vice versa.
Learn some good stretches for your fingers that are very gentle.  Those tendons are precious.
Make sure you are eating enough Potassium.  Cramps typically result from a lack of K+
Comment: I'm all ears on this can a stressed mind have an effect on the hands, that it can become strained pain and spasms? I have these same reactions when I'm at the piano.
Answer: If you can find someone knowledgeable to look at you play, please do.  If not, videorecord yourself playing.  This will be easier to do if you place the camera such that the top of the image aligns with your neck or chin.
You need to look at your set-up to see where you are introducing unnecessary tension.
The ideal would be to take a couple of lessons, so an expert can find where the tension is, and give you some ways of preventing it.
Even if you are happy working alone for the most part, this is the sort of situation where you can benefit enormously from one to three lessons with a really good teacher.  But it needs to be the sort of teacher who has a lot of awareness of how using the body incorrectly can really screw you up.  Perhaps a nicer way of saying that is -- see if you can find someone whose biographical blurb includes something like "Alexander Technique".
Comment: @GodofAtheism - Your proposed edits are actually quite compatible with what I was trying to say about the ergonomics.  The reviewers said your edit added too much material.  I'm not sure -- in different circumstances, we would just be co-authors.  I wouldn't like to see your additional thoughts get lost.  Could you please put them into comments or into another Answer?  I do think your ideas added to my answer.
Answer: The best thing you can do is to find a teacher, even if it's for just a few lessons. Please keep in mind that if you can't find a bass teacher, any musical instrument teacher knows you should not tense your hands when playing, even if they can't tell you if your technique is correct, they can check if your tensing up. Other musicians should also know that and be able to check it. Alternatively (if there are just no other musicians in your area), you could ask an ortopedist, physiotherapist, or occupational therapist to look at your playing (they might save your back while doing so as well).
If you want to do it on your own, first of all play slowly (even if you were able to go much faster before your hiatus). And check your hands (yes also your fretting hand even if it's not yet giving you trouble) for tension while doing simple exercises, where simple really means suitable for absolute beginners. Your hands and whole body need to get reacquainted to playing the instrument, also check on your back, neck, shoulders, etc. Check that there are no unneeded bends in your arms, and that your plucking arm is at least at first not resting on the instrument.
What can help when getting cramps is shaking your hands loose every so often.
Part of you can still play exactly the same stuff as you played before your hiatus, at exactly the same speed, and you can even now occasionally play that way for a few minutes, but most of your practice should at first be slow, focusing on relaxing, gradually speeding up. You can also add in more and more complex exercises, but again start by playing them really slow and totally relaxed, and only speed up once you have your hands not tensing up. This may all sound like your beginning from scratch, but you're not. You will be up to your old level of playing much faster than an absolute beginner.
Also keep in mind that all of this is just as much valid for any other musical instrument, not just electric bass guitar.


Developing $\exp z$ in a power series in $\pi i$

Question:

Develop $f(z)=\exp z$ in a power series in $\pi i$.

The task is fo find coefficients $a_n$ in such a way that
$$
f(z)=\exp z=\sum_{n=0}^{\infty}a_n (z-\pi i)^n.~~~~~~~~~~~~~~~~~~~(1)
$$
My idea is to develop $g(z):=f(z-\pi i)$ in a power series in $0$, because this power series does have the same coefficients $a_n$, because if (1), then
$$
g(z)=f(z-\pi i)=\sum_{n=0}^{\infty}a_n(z-\pi i)^n.~~~~~~~~~~~~~(2)
$$
Because one knows the exponential series, it is
$$
g(z)=f(z-\pi i)=\exp(z-\pi i)=-\exp z=\sum_{n=0}^{\infty}\frac{1}{n!}(z-\pi i)^n\\\Leftrightarrow\exp z=-\sum_{n=0}^{\infty}\frac{1}{n!}(z-\pi i)^n
$$
By comparing the coefficients in (1) and (2) it follows that the searched coefficients are
$$
a_n=-\frac{1}{n!}.
$$
It would be very kind of you if you gave me a short feedback whether this is okay.
With regards
math12
Answer: Your result is right, but the way you explained it is muddled. Because the series expansion$$\exp z=\sum_{n=0}^{\infty}\dfrac{1}{n!} z^n$$holds over the entire complex plane, it holds also under the replacement $z\leftarrow z-\mathrm i\pi.$ Hence$$-\exp z=\exp z\,\exp(-\mathrm i\pi)=\exp(z-\mathrm i\pi)=\sum_{n=0}^{\infty}\dfrac{1}{n!} (z-\mathrm i\pi)^n.$$So$$\exp z=-\sum_{n=0}^{\infty}\dfrac{1}{n!} (z-\mathrm i\pi)^n.$$


Getting xdebug to work with BrowserTestBase functional tests?

Question: I'm having a really difficult time trying to get XDebug working with my functional tests that extend from BrowserTestBase.
Does anyone have a working configuration in place for this?
I'm using PHPStorm (version 2016.2) for debugging and already have a working XDebug setup for standard unit tests. I've been initiating the tests from PHPStorm directly, but would certainly be happy running them from a terminal outside of PHPStorm if it works!
Here's what I've tried for running out outside of PHPStorm in a normal terminal:
export SIMPLETEST_BASE_URL=http://drupal8.dd:8083
export XDEBUG_CONFIG="idekey=PHPSTORM"
vendor/bin/phpunit --configuration core/phpunit.xml.dist /Users/bosborne/Projects/drupal8/modules/cas/tests/src/Functional/CasAdminSettingsTest.php

The tests run but my breakpoints are ignored.
Answer: BrowserTestBase and KernelTestBase use phpunit's 'run in separate process' feature which generates a new temporary php file from a template and then executes that. The output is provided as serialized php object which is then read back into the main thread an unserialized to yield the results.
So at present that makes using Xdebug fairly difficult.
We probably should open an issue to look at shipping our own template that support Xdebug.
In the meantime my suggestion would be to use outputting, you can use the standard approaches like var_export, print_r, echo etc or you can use $this->htmlOutput($something_you_need_to_debug); which then shows up amongst the other HTML output.
Then run your tests with -printer="\Drupal\Tests\Listeners\HtmlOutputPrinter"
This requires the BROWSERTEST_OUTPUT_DIRECTORY environment variable to be set, see core's phpunit.xml.dist for info on how to configure that.
Comment: Ok, thanks for verifying I'm not crazy, I appreciate the help and alternative approaches.
Comment: Actually BrowserTestBase and KernelTestBase aren't run in separate processes by default. run-tests.sh does that to enable concurrent test runs to speed things up. You want to use the phpunit runner instead, which won't run a test in a separate process unless you tell it to.


What does "unsupported operand type(s) for -: 'int' and 'tuple'" means?

Question: I got a error saying:

unsupported operand type(s) for -: 'int' and 'tuple'

How do I correct it?
from scipy import integrate
cpbar = lambda T: (3.826 - (3.979e-3)*T + 24.558e-6*T**2 - 22.733e-9*T**3 + 6.963e-12*T**4)*8.314
deltahbarCH4 = integrate.quad(cpbar,298,1000)
var = deltahbarCH4

hRPbar = hRPbar + (deltahbarCO2 + 2*deltahbarH2O - var -2*deltahbarO2)

Comment: It means that you are trying to use the subtraction operator `-` between a number and a tuple. It will be easier to debug if you tell us which line it is on.
Answer: integrate.quad() returns a tuple; deltahbarCO2 + 2*deltahbarH2O is an integer, you are trying to subtract the var tuple.
If you wanted just the integral y of the integrate.quad() result, use the first element of that tuple:
var = deltahbarCH4[0]

or use tuple assignment:
var, err = deltabarCH4

Answer: That error means that you are trying to use the subtraction operator - between a number and a tuple.
Based on the documentation, you probably want: var = deltahbarCH4[0], since that will give you the actual value of the integral, which you are computing with on a later line.
Answer: I got the same error below:

TypeError: unsupported operand type(s) for -: 'int' and 'tuple'

When trying to subtract tuple type from int type as shown below:
    # int
print(10 - (3,))
          # tuple

So, I changed tuple type to int type as shown below:
print(10 - 3)

Then, the error above was solved:
7


Kaplan-Meier for interval-censoring data

Question: I would like to ask if someone encountered the problem with a specific form of interval data in survival analysis.
How to perform the preliminary analysis (for instance Kaplan-Meier estimator) of survival time when each of my observations has its own time interval?
The first five examples:
+----+------+--------+----------+
| Id | Left | Right  | Censored |
+----+------+--------+----------+
|  1 |    0 |      1 |        0 |
|  1 |    2 |     17 |        1 |
|  2 |    0 |      7 |        0 |
|  3 |    0 |      3 |        0 |
|  3 |    4 |     34 |        1 |
+----+------+--------+----------+

Left - begining of compartment
Right -  end of compartment
Comment: For variable ``censored``, 0 = censored or 1 = censored?
Comment: @user158565, this is an abortive term: 0 = censored. Thanks
Comment: Then you just need to keep one record for each id. For example, keep 0 17 1 for id =1, 0 34 1 for id =3.
Answer: Since you talk about survival time, you'll need to compute the time interval (tInt = Right - Left) for each Id and use that new variable to obtain a Kaplan-Meier estimator.
Afterwards, if you want to do something like a Cox regression, besides the time interval tInt you may also use as one covariate either the middle time point mtp = (Left + Right) / 2 or the initial time (Left). The middle time point mtp might be a better covariate since it's usually less correlated with the time interval tInt.


Usando regex para converter coordenadas de latitude e longitude de graus/minutos/direcao para decimal em python

Question: Estou tentando converter dados de latitude e longitude no python que estao no seguinte formato:
Latitude    Longitude
27º59' N    86º55'E

Estes dados foram extraidos da seguinte pagina web e convertido em um arquivo csv: http://www.peaklist.org/WWlists/WorldTop50.html
Fiz o codigo para converter mas obtive o resultado como NaN. Tentei varias formas diferentes e o ultimo codigo que tentei foi o seguinte:
data['Longitude'] = data['Longitude'].str.extract('°\'([N|S|E|W])', expand=True)
(parts[0].astype(int) + parts[1].astype(float) / 60) * parts[2].map({'N':1, 'S':-1, 'E': 1, 'W':-1})

Os dados nas colunas latitude e longitude estao no formato string.
Obrigada
Comment: Tenta este regex `r"(\d{1,2})[º](\d{1,2}\.\d{1,2})*[']\s(\w)"` funciona para `"37º45.3' E"` por exemplo. Porém se vc não tiver o `.3` (no exemplo), terá que modificar o regex um pouco.
Answer: Usando isto como base: https://www.pgc.umn.edu/apps/convert
E tendo:
   Latitude Longitude
0  27º59' N   86º55'E

Acho que podes começar por criar uma função para converção de DDM para DD, nota que como não tens segundos então é assumido 0 nesse lugar:
import re

def convert(s):
    degrees, minutes, direction = re.split('[º\' "]+', s)
    dd = float(degrees) + float(minutes)/60
    return dd*-1 if direction in 'SW' else dd
...
data['Latitude_dd'] = data['Latitude'].apply(convert)
data['Longitude_dd'] = data['Longitude'].apply(convert)

Ficamos com:
   Latitude Longitude  Latitude_dd  Longitude_dd
0  27º59' N   86º55'E    27.983333     86.916667

Penso que bate certo pois o teu exemplo sendo o monte Evereste (http://www.peaklist.org/WWlists/WorldTop50.html) o resultado deu precisamente lá:
Comment: obrigada pela resposta. Infelizmente nao funcionou no meu codigo com o dataframe completo, tive como resposta: ValueError: too many values to unpack (expected 3). Estranho que fazendo so das linhas 1 a 10 do dataset deu certo... Os dados nas colunas estao no mesmo formato, da linha 1 a 50 entao nao entendi porque somente funcionou nas 10 primeiras linhas
Comment: Vou ver Mariana, em que linha mesmo deu o erro? Usa isto http://www.peaklist.org/WWlists/WorldTop50.html
Comment: Rodei agora a conversao para latitude e longitude em linhas separadas e a Longitude converteu as 50 linhas corretamente, mas deu erro na latitude. Os dados originais parecem ter uns espacos nas latitudes entao pode ser isso, estou vendo aqui (sou iniciante nisto mas o codigo que voce enviou ja ajudou bastante!)
Comment: Mas na minha resposta eu cobro esse cenário Mariana, copia exatamente a função que coloquei pf
Comment: @Mariana, copia e executa isto na integra: https://pastebin.com/raw/3BeYwU8u


Como filtrar objeto

Question: Quero simplesmente filtrar os alunos com notas acima ou igual a 7 e mostrar no console.log
const pessoa = (nome, idade, nota) =>{
    return {
        nome,
        idade,
        nota,
    }
}

const listalunos = [
 {aluno1: pessoa("maria", 20, 7)},
 {aluno2: pessoa("joao", 23, 5)},
 {aluno3: pessoa("pedro", 15, 10)},
 {aluno4: pessoa("eduardo", 24, 9)},
]

const notas = listalunos.filter(function(x){
    return x >= 7
})

console.log(listalunos.length)
console.log(listalunos.nota)
console.log(notas)

Comment: Poderia explicar por que a sua lista é uma lista de objetos onde cada objeto define uma chave diferente para guardar o objeto `pessoa`? Por que não é apenas uma lista de pessoas?
Comment: Essa definição da lista de alunos não tem sentido, e acaba complicando algo simples, que podia ser apenas `const notas = listalunos.filter(x => x.nota >= 7)`, desde que fosse definido como `const listalunos = [pessoa("maria", 20, 7), pessoa("joao", 23, 5), etc]; `
Answer: O x no seu filtro retorna cada objeto do listalunos, então não tem como saber se a nota dentro do objeto é maior ou igual a 7 apenas com x >= 7.
Você tem que acessar a chave nota dentro de cada objeto no x. Pode fazer isso usando Object.keys(x). Irá retornar arrays com os nomes dos objetos em x:
['aluno1']
['aluno2']
['aluno3']
...

Então basta pegar o primeiro e único índice de cada array:
Object.keys(x)[0]

E aplicar no filtro acessando a chave nota dentro de cada objeto de x:
return x[Object.keys(x)[0]].nota >= 7

Exemplo:

const pessoa = (nome, idade, nota) =>{ return { nome, idade, nota, } }

const listalunos = [ {aluno1: pessoa("maria", 20, 7)}, {aluno2: pessoa("joao", 23, 5)}, {aluno3: pessoa("pedro", 15, 10)}, {aluno4: pessoa("eduardo", 24, 9)}, ]

const notas = listalunos.filter(function(x){ return x[Object.keys(x)[0]].nota >= 7 })

console.log(notas)

Uma outra forma seria, caso os nomes dos objetos sejam na sequência (aluno1, aluno2, aluno3 etc...) é pegar o segundo argumento do filter que retorna o índice dos objetos (começando do 0), somar +1 e concatenar com o "aluno":

const pessoa = (nome, idade, nota) =>{ return { nome, idade, nota, } }

const listalunos = [ {aluno1: pessoa("maria", 20, 7)}, {aluno2: pessoa("joao", 23, 5)}, {aluno3: pessoa("pedro", 15, 10)}, {aluno4: pessoa("eduardo", 24, 9)}, ]

const notas = listalunos.filter(function(x,i){ return x["aluno"+ (i+1)].nota >= 7 })

console.log(notas)
Answer: Eu não vejo sentido em definir uma lista de objetos com as chaves aluno1, aluno2, aluno3, etc, justamente porque você não terá controle direto sobre qual chave ter que acessar em cada objeto.
Por exemplo, se eu precisar o nome do aluno na posição 5 da lista, como faria?
listalunos[5][???].nome

Ah, mas se é na posição 5, deve ser aluno5, então listalunos[5]["aluno5"].nome, mas e se não for? E se o objeto com "aluno5" nem estar mais na lista?
Você não precisa dessa chave, basta criar uma lista de pessoas:
const pessoa = (nome, idade, nota) =>{
    return {
        nome,
        idade,
        nota,
    }
}

const alunos = [
  pessoa("maria", 20, 7),
  pessoa("joao", 23, 5),
  pessoa("pedro", 15, 10),
  pessoa("eduardo", 24, 9),
]

E com isso fazer o filtro que deseja fica trivial:
const aprovados = alunos.filter(aluno => aluno.nota >= 7)

Não precisa de todo o esforço para resolver um problema que você mesmo inseriu.

const pessoa = (nome, idade, nota) =>{
    return {
        nome,
        idade,
        nota,
    }
}

const alunos = [
  pessoa("maria", 20, 7),
  pessoa("joao", 23, 5),
  pessoa("pedro", 15, 10),
  pessoa("eduardo", 24, 9),
]

const aprovados = alunos.filter(aluno => aluno.nota >= 7)

console.log(aprovados)

Como filtrar objeto


No solutions with three planes in $\mathbb{R}^3$

Question: Find the point in $\mathbb{R}^3$ that these three planes cross:

$-x+y+x=4$
$2x-y-4x=-2$
$-3x+2y+5z=0$.

I do Gauss-Jordan on this system of equation, and find $$0\ 0\ 0 \mid 6$$
So no solutions exist. The planes never cross a point.
Now, I asked myself the question: If I'd got $$0\ 0\ 0\ \mid 0$$
then, would the solution set be a line in $\mathbb{R}^3$? I think yes.
Comment: There are typos in the eq(s).
Comment: It might be a line. It could also maybe be a plane (all three equations could represent the same plane) and I think in that case in the gauss Jordan there would be *two* rows $0,0,0|0$.
Answer: The answer is yes. Let's consider the following system of equations:
$$\left\{
        \begin{array}{ll}
            x+2y-2z+3w=2 \\
            2x+4y-3z+4w=5 \\
            5x+10y-8z+11w=12
        \end{array}
    \right.
$$ which is equal to this one (after doing some manipulations on equations):
$$\left\{
        \begin{array}{ll}
            x+2y-2z+3w=2 \\
            ~~~~~~~~~~~~~~~~z-2w=1 \\
            0=0~~~~~~~~~~~~~~~~~~~~~ (*)
        \end{array}
    \right.
$$ The system is consistent but in second system the number of variables is more than the numbers of equations so the system has infinitely many solutions. Let $y$ and $w$ be our free variables and set $w=b$ and $y=a$ to find out if we can find the general solutions. According to last system we get $z=1+2b$ and $x=4-2a+b$ so $$(4-2a+b,a,1+2b,b)$$. Indeed, if you gave us the system you had in mind in which the third equation was $0=0$, then we would find that possible line.


How to change the existing images embedded in Views Twig template to S3 bucket URL

Question: I have embedded the images using views twig template,
file_url(row['content']['#row']._entity.field_future_program_image.entity.fileuri) %}

The output is public://2018-07/10a_0_0.JPG
Instead, I need the image URL from the s3 bucket: https://s3.bucketname/2018-07/10a_0_0.JPG
Note: I have configured amazon s3 and moved the local files to s3
Answer: Try adding
$settings['s3fs.use_s3_for_public'] = TRUE;

After that clear cache, now your site images will render form Amazon S3 bucket.
Comment: Hi Ajay,  I used as below {{ file_create_url(row['content']['#row']._entity.field_future_program_image.entity.fileuri) }}, but it throws error. as  Uncaught PHP Exception Twig_Error_Syntax: "Unknown "file_create_url" function."
Comment: Use it as `file_create_url(file_url(row['content']'#row']._entity.field_future_program_image.entity.fileuri) %})`
Comment: Hi Ajay,

I used both methods:

Step1:

      {% set photo = file_create_url(file_url(row['content']'#row']._entity.field_future_program_image.entity.fileuri) %})

Step2:
 {% set photo = file_create_url(file_url(row['content']'#row']._entity.field_future_program_image.entity.fileuri))  %}

But the below error is encountered.  Uncaught PHP Exception Twig_Error_Syntax: "Unclosed "("."
Comment: Can you post the error you are getting?
Comment: Uncaught PHP Exception Twig_Error_Syntax: "Unclosed "("."

I have used as below:
{% set photo = file_create_url(file_url(row['content']['#row']._entity.field_future_program_image.entity.fileuri))  %}
Comment: In step 1 missing closed bracket `file_create_url(file_url(row['content']['#row']._entity.field_future_program_image.entity.fileuri) %}))`
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/82293/discussion-between-ajay-reddy-and-user3613207).


Customizing views output- rewrite output to show an image based on key value

Question: I want to use a views template to customize the output of the gender field on my user profile.  The gender field is a select list, and the key values are as follows:

f (female)
m (male)
o (other)

I created a template file, views-view-field--field-acc-gender.tpl.php.  I have the images saved in my theme's directory.  I can write an if statement to check against the key value, but how do I get the value of the field?  (This is probably a straightforward question, but I just learned about views templates today.)
I tried the following in views-view-field--field-acc-gender.tpl.php:
<?php
if ($output == 'M') {
  print 'male';
}
else if ($output == 'F') {
  print 'female';
}
else {
  print 'other';
}

However, my view still simply prints out M or F instead of male or female.
Comment: Please show the all code in that template?
Comment: That is all the code that is in the template right now.
Comment: If you know that your getting a value out of $output then assign the replacement string to $output rather than print them. Should probably then print $output after your conditional.
Answer: You should be able to access the data from $row array from inside the template file. So:
$data = $row->field_field_acc_gender;

// This may not necessarily be the correct structure of your field's data.
// So you may want to do print_r($data) or dpm($data) to see correct structure.
$gender = $data[0]['raw']['value'];

switch($gender) {
  case 'M':
    print('Male');
    break;
  case 'F':
    print('Female');
    break;
}

Comment: I discovered my error-- I was not actually outputting the field, but rather rewriting the output and displaying the value of the field from another.
Answer: Ideally you want to be using a copy of 'views-view-fields.tpl.php'.
Before the foreach loop on the $fields object you can alter the output.
Example:
   if ( $fields['FIELD_NAME']->content == 'something' ) {
      // do something else...
   }

In your example it would be appear you've gone for the 'single field' option.
You might want to just assign some alternative value to $output then print it after your conditionals.


What is the difference between regulator and stabilization

Question: What is the difference between regulator and stabilization in control theory
don't they both minimize the disturbance to the system?
could answer be elaborated from the view of state and output?
Answer: There is a difference between the ability to stabilize a system, and an ability to control it.
Stability implies that the states and outputs of a system do not grow unbounded. A good discussion of stability can be found in the book: "Nonlinear Systems" by Hassan K. Khalil.
For autonomous dynamical systems (i.e. systems with no inputs: $\dot{x}=f(x)$) stability means that if the initial conditions of the system states, $x(0)$, lie near an equilibrium, then they will stay near that equilibrium.
For dynamical systems with inputs $u$, and outputs $y$ (e.g. $\dot{x}=f(x,u)$, $y=h(x,u)$), input-output stability means that for inputs of bounded magnitude, the outputs of the system will also remain bounded in magnitude. Internal stability implies the additional requirement that the states will also remain bounded.
Based on this definition of stability, it is clear that it is impossible to control the outputs of a system unless it can be stabilized. However, it should also be clear that stability alone doesn't provide any guarantees that the outputs of the system can be manipulated in a controlled manner, for instance to negate the effects of a disturbance.
Control systems that are designed to manipulate the outputs of a dynamical system, are in effect manipulating the system input to: (a) stabilize the system, and (b) make the system output behave in a desired way. The design of such systems can be broadly divided into two categories (this concise definition is from the book "Multivariable Feedback Control" by Skogestad and Postlethwaite):

Regulator problem: Manipulate the system input to counteract the effects of disturbances.
Servo Problem (i.e. tracking problem): Manipulate the system input to keep the output close to a given reference trajectory, e.g. minimize the difference between the output and the reference trajectory.
Answer: If I understand your question properly, we have two things to consider.
Stability
This is the ability for a system to operate under a variety of conditions without self destructing. There are two categories of interest; 1) the ability for the system to return to equilibrium after an initial displacement away from equilibrium and, 2) the ability for the system to produce a bounded output for a bounded input. There are differences between time-varying and nonlinear systems.
Regulator
In this system the reference input is zero (since it is missing). It is desired to keep the output as near to zero as possible in the system.
So, in both cases, we certainly want them to remain stable, but one allows two types of inputs, while the other wants to have a constant zero input. One can ask why they defined two different concepts for this and that is a valid question, but they needed a system that didn't have any inputs as opposed to the general case I suppose.
Comment: @CandC: By all means, if you have a better regulator definition, please share it. Regards
Comment: i believe stability is correct, however, you may misunderstand between regulator and tracking
Comment: $\displaystyle \large +\left[-\left(e^{i\pi}\right)\right]\;\;\land \;\; \color{green}{\bf \checkmark}$


Ionic 2: NavPop brings me to root rather than previous page

Question: I am having an issue with navigation in my app.  The page hierarchy works like so:

Top

VisitComponent (non-tabbed)
CheckInPage (non-tabbed)
ClientGenericPage (tabbed)
HelloIonicPage (non-tabbed)

Root

A standard flow of events would be:

Start at the HelloIonicPage
push() the ClientGenericPage
Select the tab corresponding to the CheckInPage
push() the VisitComponent from a button on the CheckInPage

The issue arises when I attempt to pop() from the VisitComponent.  I would expect to end up at the CheckInPage but instead I end up at the HelloIonicPage (root component).
When I call this.navCtrl.getViews() I see an array of 2 views: [CheckInPage, VisitComponent].
I am really at a loss as to why I would end up at the root after calling this.navCtrl.pop().
Answer: As it turns out, the ClientGenericPage header was displayed on top of the VisitComponent header, and thus clicking back was firing the event on the parent, not the child.


What would make Graph Neural Networks better than 'normal' Neural Networks?

Question: I am quite new to the area of artificial intelligence and deep learning, so I am exploring some of the available techniques and models. Throughout my readings, I noticed a growing trend towards using Graph Neural Networks (GNNs) in recent years, so I would appreciate having some feedback from experts:

What are the main differences between GNN and NN (apart from GNN has a graph as its input)?
Consequently, what is the potential in using GNN instead of NN, for example in knowledge graphs and bases?
Comment: I don't know much about about GNN's, but it would seem to me that one GNN's would *need* a sparse matrix implementation to scale up, as the size of the dense graph is $O(N^2)$ ($N$ = number of nodes), yet we rarely see moderate sized graphs with even 1% density.
Answer:
what are the main differences between GNN and NN? Apart from GNN has
  its input as a graph data?

Well, that is the main difference. Of course some corollaries of this fact is that GNNs can deal with variable sized graph inputs and typical NNs cannot, GNNs are not fully connected and typical (non-convolutional) NNs are, GNNs are usually invariant to permutation of the vertices and NNs are not.

In a bit more detail: Let $A$ be the adjacency matrix of some graph $G$, and let $X$ be an $n \times d$ matrix of features for each vertex, and let $W$ be a $d \times d'$ weight matrix. Then a graph neural network layer might compute something like $Y = \sigma(AXW)$. Inspired by spectral analysis, more sophisticated versions compute $Y = \sigma(\sum_i L^iXW_i)$ where $L^i$ is the $i$th power of the laplacian.
Just as in a convolutional network, the size of the weight matrix is independent of the graph -- you might interpret it as some sort of convolutional filter which can be slid over each vertex of the graph. Graphs with different sizes and connectivity simply alters $A$ and $L$, but not $W$.

Consequently, what is the potential in using GNN instead of NN, saying
  for eg in knowledge graphs and bases?

Applications are very wide, and include...
Language models which operate on parse-trees rather than just a linear sequence of words. Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks
Solving reading comprehension by maintaining a graph of the relationships between all the different entities in a story. Learning Graphical State Transitions
Learning a model of physics by inferring the graph of physical interactions between objects. Neural Relational Inference for Interacting Systems and Interaction Networks for Learning about Objects, Relations and Physics

Improving segmentation boundaries Efficient Interactive Annotation of Segmentation Datasets with Polygon-RNN++
 by modeling object boundaries as a graph.
A richer form of object detecion which not only detects objects in an image but reveals their relationship to each other. Graph R-CNN for Scene Graph Generation
Generating and predicting molecules with particular chemical properties. Junction Tree Variational Autoencoder for Molecular Graph Generation
Generating and learning patterns in real world road patterns. Neural Turtle Graphics for Modeling City Road Layouts

Since meshes are also graphs, you can generate / segment / reconstruct, etc. 3D shapes as well. Pixel2Mesh: Generating 3D Mesh Models from Single RGB Images Dynamic Graph CNN for Learning on Point Clouds
Neural networks are computation graphs, so you could use GNNs to learn to generate better network architectures. Graph HyperNetworks for Neural Architecture Search
Comment: "Of course some corollaries of this fact is that GNNs can deal with variable sized graph inputs and typical NNs cannot": can you explain this? If I just think of a GNN as NN that takes a graph as an input, I don't see why this would be true. If you could explain how this works, it would certainly help differentiate a GNN and a vanilla NN for me.
Comment: @CliffAB yes -- however this is just a very simple example, many (most?) GNN implementations use a more sophisticated "aggregation" function.
Comment: @CliffAB sure, i've added some details.
Comment: Ah, so in the context of using $AX$, we're basically just taking the sum of features of your friends (in a social graph) as your features plugging into the NN?
Comment: Okay, thanks, cleared up my confusion. +1.
Comment: Applications to 3D meshes and point clouds are among the most surprising, imo


What happens when we remove the SnapshotIdentifier from our Cloudformation config

Question: When we spun up our Cloudformation stack, we restored our DBCluster from a snapshot. We are now in the process of updating our stack.
What will Cloudformation do with our DBCluster if we remove the SnapshotIdentifier key from our config? Let's assume here that we are not using stack policies.
The docs show that updating that parameter would cause a replacement. However, that's not what we want, and we wouldn't be sure what to do exactly to prevent that.
Thanks!
Comment: What do you want to achieve with this change ?  By removing the snapshot identifier you are basically telling cloud formation that you want an empty db... Which it could only provide by doing a replacement.
Comment: Well we actually don't want to update the cluster at all, but rather update other resources. We don't have the original snapshot anymore. When we  tried to use that identifier anyway, Cloudformation started complaining since it couldn't find the snapshot. This also led us to think that supplying the initial snapshot would reset the database to that state..
Answer: This changing the attribute DBSnapshotIdentifier will indeed result in a replacement of the AWS::RDS::DBInstance.
Behind the scenes, CloudFormation (CFN) stores the current configuration of all resources. When you update a resource CFN does a describe call of those resources, and compares it to the stored values.
Only if values actually change, resources will be updated. That said, as long as you do not update the DBSnapshotIdentifier property, the database should not be replaced.
With RDS, this behaveour of CFN can cause annoying problems, especially if the RDS endpoints change.
This is what we currently consider good practice:

Establish an own RDS stack, which is seperated from the rest. Export the RDS endpoint as "RDSEndpoint-$Version". Set Version as a parameter.
Point your applications to the correct RDS endpoint. Using the export from the previous stack or using a Route53 entry for this would be easiest.
If you need make changes to the RDS instances that cause a replacement, do them on a new RDS stack, change $Version to something else.
Once everything is okay. Change the RDS endpoint in your applications (or change the Route53 entry, whatever suits you best).

Common problems are:

Duration of data migration between databases - if your application does not support this, you may run into problems.
RDS change operations are generally a bit slow. Often it is faster to just run mysqldump + mysql (in case of MySQL) instead of relying on AWS instances.
Loss of credentials when switching over to a new stack (you should have documented the credentials, but consider this anyway).

If you are looking for a one-time-solution for your specific problem, here is one (with possible downtime):

Take your application to read-only or maintenance mode (if the application does not support this, this might be causing the downtime).
(Manually or with RDS Snapshot) create a dump of your database.
Update your DB with your new CloudFormation template
Restore from your dump.
Switch your application to production. If the endpoint changed, switch that too.