Docker for GUI-based environments?

Question: Problem
I have a set of client machines that are a part of an enterprise web application. Each machine runs identical software, which is a PyQT-based web client that connects to a server. This client software is updated regularly and I would like to have some configuration/provisioning tool that allows to have the same environment on each machine and hence provide easy deployment and configuration of the software onto each of the clients' machines.
The problem is that I have tried to use Chef, but it takes a lot of effort to actually maintain Chef knowledge and skills (we do not have a dedicated Ops guy) and moreover a Chef recipe can fail if some third party repository is no longer available (this is a main stopper).
I would like to try Docker to solve the problem, but I still do not know if it is possible to set up images/containers that allow for some GUI based software to operate.
Question
Is it possible to use Docker to have a development/production environment for a GUI-based application (PyQt/QT)? If yes, what would be the first steps to approach that?
Comment: possible duplicate of [can you run GUI apps in a docker container?](http://stackoverflow.com/questions/16296753/can-you-run-gui-apps-in-a-docker-container)
Comment: @HenkLangeveld, I would prefer to have a 'configure once run always' approach to be available to us. I'd better write some code for the app instead of writing Ruby DSL for Chef.
Comment: Deal with third party stuff by caching all resources, if necessary as locally maintained packages. Otherwise, keep refactoring and maintaining your deployment code and you'll get better at it.
Comment: That will be fine if you can predict the exact runtime environment in production, including all future requirements. Nor you, nor a dedicated ops geek wiil know that. Make it run now, simply. Then adapt when app and runtime need change.
Comment: This question may be related to http://stackoverflow.com/questions/23967283/is-it-possible-to-have-gui-for-docker-container.
Comment: [LXC 1.0: GUI in containers](https://www.stgraber.org/2014/02/09/lxc-1-0-gui-in-containers/)
Answer: Currently this question is not answered, but it is very highly ranked on Google. The other answers are mostly correct, but with some caveats that I have learned the hard way, and I would like to save others trouble.
The answer given by Nasser Alshammari is the simplest (and fastest) approach to running GTK applications inside a Docker container - simply mount the socket for the X server as a Docker volume and tell Docker to use that instead.
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY TheImage

(I would also recommend passing the -u <username-within-container> flag, as running X11 applications as root does not always work, and is generally not recommended, especially when sharing sessions).
This will work for applications such as xterm, as well as GTK-based applications. For example, if you try this with Firefox (which is GTK-based), it will work (note that if you are already running Firefox on the host, it will open a new window in the host rather than open a new instance of Firefox from within the container).
However, your answer asks about PyQT specifically. It turns out that Qt does not support sharing of X sessions in this way (or at least does not support it well).
If you try running a QT-based application this way, you will probably get an error like the following:
X Error: BadAccess (attempt to access private resource denied) 10
  Extension:    140 (MIT-SHM)
  Minor opcode: 1 (X_ShmAttach)
  Resource id:  0x12d
X Error: BadShmSeg (invalid shared segment parameter) 148
  Extension:    140 (MIT-SHM)
  Minor opcode: 5 (X_ShmCreatePixmap)
  Resource id:  0xb1
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x2c0000d
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x2c0000d

I say "probably" because I have not tested this approach with enough Qt applications to be sure, or dug into the Qt source code enough to figure out why this is not supported. YMMV, and you may get lucky, but if you are looking to run a Qt-based application from within a Docker container, you may have to go the "old-fashioned" approach and either

Run sshd within the container, turn on X11 forwarding, and then connect to the container using ssh -X (more secure) or ssh -Y (less secure, used only if you fully trust the containerized application).
Run VNC within the container, and connect to it from the host with a VNC client.

Between those two options, I would recommend the first, but see which works best for your situation.
Comment: _export QT_X11_NO_MITSHM=1_ will fix your QT error.
Comment: Understood, but I wanted to document the Qt behavior specifically, since it was a key part of OP's question. If anybody else stumbles across this page while debugging (as I did earlier in the day!), I just want to make sure they don't have to duplicate the effort. :)
Comment: if you get an error "Gtk-WARNING : cannot open display: unix:0.0" try this: xhost +local:docker https://hub.docker.com/r/meertec/firefox/
Comment: "Doesn't have an accepted answer" != "is not answered". Not a big deal, but I had to check if I'm still looking at the same question.
Comment: `export QT_GRAPHICSSYSTEM=native` will also fix the *X Error: BadAccess (attempt to access private resource denied) 10* error
Comment: if not, `export QT_X11_NO_MITSHM=1` also works. What it does is telling Qt to not use MIT-SHM (shared memory), so should be safer security-wise in any case
Answer: There are many solutions to have GUI apps running in a docker container. You can use SSH, or VNC for instance. But they add some overhead and delay. The best way that I found is just to pass in the file used by the X server in the host machine as a volume to the container. Like this:
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY TheImage

Then all your GUI apps will run from container.
Hope This helps!
Comment: What happens if I'm running docker on windows or mac?. Can I use the same solution?. Because I don't think I can bind the display in the same way.
Answer: SOLVED - PyQt5-GUI in Docker Container:
Enable Qt-Debug $ export QT_DEBUG_PLUGINS=1  ==> reproduce error ==> re/install the No such file or directory-library listed in debug message ==> repeat!
I also could not run PyQt5-GUI-app in a Docker container without receiving errors & first read all the posts that it would not be possible to run Qt in Docker containers. But I could solve it (at least for me)...
System
I am running my PyQt5-application in a Docker container with shared /tmp/.X11-unix/ socket and display for GUI visualization:
$ nividia-docker run --interactive --tty --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix/:/tmp/.X11-unix/ <docker_iamge>

Error
Initializing PyQt5.QtWidgets.QApplication always led to following error:
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5.QtWidgets import QApplication
>>> app = QApplication([])
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)

In PyCharm Debug mode the error returned:
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Solution
General method:

set Qt-debug environement variable in docker container terminal:

   $ export QT_DEBUG_PLUGINS=1

reproduce error in the docker terminal (or in the IDE), e.g.:

$ python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>>
KeyboardInterrupt
>>> from PyQt5.QtWidgets import QApplication, QLabel
>>> app = QApplication([])

read debug messages printed to the terminal, e.g.:

QFactoryLoader::QFactoryLoader() checking directory path "/conda/envs/rapids/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/conda/envs/rapids/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqeglfs.so"
Found metadata in lib /conda/envs/rapids/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
...
...
...
Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/conda/envs/rapids/bin/platforms" ...
Cannot load library /conda/envs/rapids/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/conda/envs/rapids/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /conda/envs/rapids/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)

find the <No such file or directory>.so.* and <coud not be loaded>-packages, here e.g. libxkbcommon-x11.so.0 and libxcb. Then re/install the corresponding packages/libraries (finding the packages works with apt-file --package-only search <filename> or conda/pip search ...). In my case the following libs were required:

### lib no.1 ###
$ sudo conda install --name <env_name> --force-reinstall libxcb    # or pip install ...
### lib no. 2 ###
$ apt-file --package-only search libxkbcommon-x11.so.0
libxkbcommon-x11-0
$ sudo apt install libxkbcommon-x11-0

After repeating this process for all sequentially reproduced debug messages and installing the 2 libs I can now run PyQt5-apps from inside the Docker container on my local machine desktop.
Comment: @just_learning that's the just name of your conda environment in case you are using conda as a virtual python environment in which you install all the python packages, see [documentation](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).
Comment: What do I put on  ? Is it the name of the docker image?
Answer: I managed to run xeyes in a container and see the "window" in a X server running outside of the container. Here's how:
I used Xephyr to run a nested X Server. This is not necessary, but most linux desktops do not allow running remote apps on them by default (here's how to "fix" this on ubuntu).
Install Xephyr:
$ sudo apt-get install xserver-xephyr

Run Xephyr:
$ Xephyr -ac -br -noreset -screen 800x600 -host-cursor :1

This creates a new 800x600 window, which acts as a X server.
Find an "external" address of your machine. This is where the X server is running:
$ ifconfig

docker0   Link encap:Ethernet  HWaddr 56:84:7a:fe:97:99
          inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::5484:7aff:fefe:9799/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:133395 errors:0 dropped:0 overruns:0 frame:0
          TX packets:242570 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:9566682 (9.5 MB)  TX bytes:353001178 (353.0 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:650493 errors:0 dropped:0 overruns:0 frame:0
          TX packets:650493 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2506560450 (2.5 GB)  TX bytes:2506560450 (2.5 GB)

wlan0     Link encap:Ethernet  HWaddr c4:85:08:97:b6:de
          inet addr:192.168.129.159  Bcast:192.168.129.255  Mask:255.255.255.0
          inet6 addr: fe80::c685:8ff:fe97:b6de/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6587370 errors:0 dropped:1 overruns:0 frame:0
          TX packets:3716257 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7405648745 (7.4 GB)  TX bytes:693693327 (693.6 MB)

Don't use 127.0.0.1! You can use any of the others. I'll use 172.17.42.1.
Create a Dockerfile with the following content:
FROM ubuntu

RUN apt-get update
RUN apt-get install -y x11-apps

CMD ["/usr/bin/xeyes"]

Build it:
$ docker build -t xeyes .

And run it:
$ docker run -e DISPLAY=172.17.42.1:1.0 xeyes

Note, that I'm setting the DISPLAY environment variable to where I want to see it.
You can use the same technique to redirect the display to any X server.
Answer: Here are the basic steps you need to follow get things working fine,

To create and run the Docker container
sudo nvidia-docker run -it -d --privileged  -e DISPLAY=$DISPLAY --name wakemeeup -v -v /dev:/dev  -v /tmp/.X11-unix:/tmp/.X11-unix:rw  nvidia/cuda:9.1-cudnn7-devel-ubuntu16.04 bash
To start the docker container
sudo docker start wakemeup
To attach to the docker container
xhost +local:root 1>/dev/null 2>&1
docker exec -u $USER -it wakemeup /bin/bash
xhost -local:root 1>/dev/null 2>&1
The MIT-SHM is an extension to the X server which allows faster transactions by using shared memory. Docker isolation probably blocks it. Qt applications can be forced not to use the extension. Inside the docker container,
nano ~/.bashrc
 export QT_X11_NO_MITSHM=1
Source .bashrc
source ~/.bashrc

Hope this will help
Comment: That last flag together with the following answer fixed it for me. Thanks! https://stackoverflow.com/a/35040140/543720
Answer: Recently I tried to run PyQt5 application in docker. What I learned is that you can not run application as root (you have to create normal user). When you want to play audio/video in application you have to run docker container with group "audio" and mount sound device. So to run my application I use this:
docker run -it \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -v $(pwd)/test:/app \
    -e DISPLAY=$DISPLAY \
    -u myusername \
    --group-add audio \
    --device /dev/snd \
    fadawar/docker-pyqt5-qml-qtmultimedia python3 /app/hello.py

I spend some time until I figured out what packages I need to add to my container to run PyQt application in it so I created few Dockerfiles (with simple demo app) to make it easier for others:
Python 3 + PyQt5: https://github.com/jozo/docker-pyqt5
Python 3 + PyQt5 + QML + QtMultimedia: https://github.com/jozo/docker-pyqt5-qml-qtmultimedia
Answer: You can use subuser to package your GUI applications.  It also has good support for updating applications.  You can put your Dockerfiles in a git repo once, and then just run subuser update all on each client to rebuild the images when they need to be changed.
Answer: For Mac Catalina, had to install install XQuartz, then...
xhost 127.0.0.1
export DISPLAY=:0
ssh -Y
docker run -e DISPLAY=host.docker.internal:0 -it ros

Answer: Check this repo as well. It's runs GUI applications inside docker

Docker for GUI-based environments?


Danger when using UPS with static

Question: I just bought a UPS Neo 650A, I managed to install it and it works correctly, but I have a doubt, sometimes I have static and I usually get shocked with the keyboard or the mouse, so if I touch the power button of the UPS to turn it on or off, If I touch it with static to the UPS, can it electrocute me in a dangerous way or burn the UPS?
Comment: `I usually get electrocuted` ... that means that you are now dead ... the word you want is `shocked`
Comment: There is no manual, no installation instructions, or no description how you installed it.
Answer: The most common source of electrical leakage currents is from a floating charger floating on the secondary DC.  The Line filter conducts RF noise ~ 1mA to PE gnd.
This current can make you feel from your skin to the metal edge of a laptop if your skin is near a grounded surface ( e.g. socks on some floors)
I suspect your UPS PE gnd is inadequate or you have equipment conducting excess current on PE ground.
Answer: Static charge on your body can have a high voltage (thousands of volts) but very little energy.  This can be painful and unpleasant but is generally harmless to humans.  However it can cause damage to electronic circuits, so it's better to discharge yourself by touching an earthed metal object before handling electronic devices.  If this is a common problem for you, there are various anti-static devices available to mitigate this.

Danger when using UPS with static


Password storage best practices

Question: We have a system (.NET application + sql server) where in addition to regular user passwords we need to store passwords that are used by the application processes to access various other subsystems or 3rd party services, for example sftp or external interfaces.
What are the best practices from security standpoint, dos and don'ts, for storing passwords? We can't "simply" store hashes like we do for user passwords because the passwords ultimately need to be passed to other systems without user intervention.
Is storing them in sql server with some sort of encryption (column, table) with additional user restrictions adequate? If not, what are other options we should be looking at?
Answer: Correct assumption, if you have to pass them via cleartext, you have to store them either in cleartext, or reversible to cleartext. Best practice would be to store them encrypted, but the application then has to decrypt the passwords. Access to the stored passwords should be restricted via database permissions to the application only, and in the application via user privileges.
The issue is then where to store the secret key for the encryption. If it is stored in the database, a leaked dump would contain both the encrypted passwords and the key to decrypt them. If you store them in a config file on the application side you have to backup these configurations too. If you lose them, you lose the access, or at the very least have to re-set the passwords in the application with a new encryption key.
Honestly, the best way to do this would probably be via a dedicated software, i.e. a password manager with an API for the application. This way the stored passwords stay up to date (since everyone should use the password manager) and the application has access via the API and you don't have to roll out your own crypto.
Comment: The best way to generate and store the encryption key is an HSM - Hardware Security Module.  It's also expensive.

Password storage best practices


Removing kaspersky free antivirus fails

Question: I'm trying to remove kaspersky antivirus free from my computer but I'm not able to - if I go to apps & features and try to remove it there, I'm receiving error as on screenshot below:

I tried running kaspersky installer to remove it but when I choose 'uninstall' in installer window it shows similar error and just crashes, how could I remove it?
Answer: Try to remove it from Control Panel > Programs and Features, and follow the prompts.
See the documentation
How to remove a Kaspersky Lab application.
If this does not work, try the
Kaspersky Kavremover:

Kavremover is a free tool for removing Kaspersky Lab applications from your device safely and in full.
Comment: apps & features in windows 10 is exactly same thing as programs and features in control panel, already tried control panel too and it seems to display same error
Comment: Do you have another anti-virus installed?
Comment: nope, only kaspersky, I installed it because I was buying parental control software from them and I was like, hm, why not, I'll install AV, everybody reccomends it, and then it litearlly broke my ubuntu subsystem so it cannot connect to internet, maybe this kaspersky release is corrupted or something, because even though I disabled everything I could in it it's still blocking internet connections and is un-uninstallable
Comment: I added the Kaspersky remover tool. Reboot when it finishes.
Comment: works perfectly fine, every software that was non functioning properly because of kaspersky works fine aswell, thanks! kaspersky remover is way to go
Answer: Have you considered 'overwriting' it with a new installation of Kaspersky? Post that just try unistalling it.
That would just install it once again on top of the existing version and perhaps fix any installation problems that is preventing you from uninstalling it.
I'm guessing you're doing this on admin rights.
Another option I could think of would be to use the Safe Mode and then uninstalling it from there.

Removing kaspersky free antivirus fails


Can somebody explain me this Kalachakra print?

Question: I would like to understand this image.

Can someone explain each part of this image? Not only the part in the middle, but also the figures all around.
Comment: Generally speaking, what is shown is Kalachakra with his consort Vishvamatha, mother of all beings, in union of great bliss and profound wisdom. The many heads, arms and ritual implements represent the ability to handle all situations at all times. They trample figures representing ignorance, anger and greed. Kalachakra is associated with the cycle of time.
Comment: Incidentally someone once tried to flag this question for deletion, because it's related to highest yoga (secret) tantra, and someone who wants teaching on this topic should get them from his or her guru. I didn't or wouldn't delete the question because it's on-topic for this site (see also [e.g. this meta-topic](http://meta.buddhism.stackexchange.com/q/85/254)); I don't know whether you'll want to answer it.
Answer: This is what I have been able to determine. It does not answer all of the symbolism or identify all objects from this particular image, but it is a good start.

"...Shri Kalachakra shining forth with stainless light rays of five
  [colours], with a body blue in colour. Having three necks the central
  is blue, right red and left white. The main face is black and fierce
  with bared teeth. The right face is red and desirous. The back face is
  yellow and in samadhi. The left face is white and very peaceful. Each
  face has three eyes.
The hair is tied in a tuft [along with] a vishvavajra, crescent moon,
  and Vajrasattva as a crown, a vajra jewel, vajra earrings, vajra
  necklace, vajra bracelets, vajra belt, vajra anklets, vajra scarf,
  vajra mala, and a loose tiger skin skirt.
The first [two] shoulders on the right and left are blue, second red,
  third white, for a [total] of six [pairs] of shoulders, twelve upper
  arms and twenty-four hands. The first four [right and left] are black,
  second four red, third four white. The thumbs of all the hands are
  yellow, index finger white, middle finger red, ring finger black, and
  little finger green. The first knuckle is black, second red, third
  white. All of the fingers are beautiful and radiant.
The first four black right hands hold a vajra, sword, trident and
  curved knife.
The four red [hold] a flaming arrow, vajra hook, a rattling damaru and
  hammer.
The four white [hands hold] a wheel, spear, stick and a battle axe.
The first four black left [hands] hold a vajra bell, shield, katvanga
  and a skullcup filled with blood. The four red [hold] a bow, vajra
  lasso, jewel and a white lotus. The four white [hold] a conch, mirror,
  vajra chain and the four-faced head of Brahma adorned with lotus
  [flowers].
Above a moon, sun and rahu, standing in a very playful manner, the
  right red leg is extended atop red Kamadeva having one face and four
  hands, holding five flower arrows, a bow, lasso and a hook. Under the
  left white leg is Rudra, white with one face, three eyes and four
  arms, holding a trident, damaru drum, skullcup and a katvanga. The
  demon [consorts] Rati and Uma in a woeful [manner] hold the soles [of
  Kalachakra's feet].
Vishvamata, yellow in colour, embraces [Kalachakra] from the front.
  The faces, from the right are yellow, white, blue and red, each with
  three eyes. There are eight arms. The [first] right hands hold a
  curved knife, hook, a rattling damaru and bead mala. The left [hands
  hold] a skullcup, lasso, white lotus with eight petals and a jewel.
  Vajrasattva [appears] as a crown. Adorned with the five mudras. The
  left leg is extended - standing together with the Bhagavan."

-- (Buton Tamche Kyenpa Rinchen Drub, 1290-1364. dus 'khor sgrub thabs bsdus pa rin po che'i snying po. gsung 'bum rin chen grub [zhol par khang] Volume 5, Pages 163-176. [TBRC W1934])

Semi-wrathful in appearance, blue in colour, he has four faces,
  twenty-four hands and two legs. The main face is blue, right red, left
  white and the back face is yellow. Each has three eyes and an open
  mouth with slightly bared fangs. The first set of eight hands are blue
  in colour, second (middle) red and third (upper) yellow. The first
  pair of hands hold a vajra and bell crossed at the heart embracing the
  consort. The remaining right hands hold a sword, curved knife,
  trident, three arrows, vajra hook, damaru drum, hammer, wheel, spear,
  club and axe. The left hands hold a shield, katvanga staff, skullcup,
  bow, lasso, jewel, lotus, conch shell, mirror, vajra chains and the
  four-faced yellow head of Brahma. The Lord wears a long green scarf
  and a tiger skin as a lower garment. The consort, Vishvamata, is
  yellow, with four faces and eight hands. They are both adorned with
  crowns, necklaces, earrings, bracelets and various ornaments. The
  right leg of the Lord is straight and red, standing atop the figure of
  red Kamadeva. The left is bent and white, standing atop white Rudra.
  Above the layered discs of a white moon, red sun and dark blue Rahu
  (eclipse) they stand on a multi-coloured lotus blossom seat wreathed
  by the circular orange rays of pristine awareness fire.
At the top center is the primordial buddha Vajradhara, blue, with one
  face and two hands holding a vajra and bell at the heart. At each side
  are two kings of Shambhala wearing long garments and elaborate
  headdresses. Slightly below are two lamas wearing orange and red
  monastic robes. Two celestial figures, white in colour, soar against
  the dark blue sky.
At the left side is Sahaja Heruka Kalachakra, blue, with one face and
  two hands holding a vajra and bell embracing the consort. Vishvamata,
  yellow, holds a curved knife and skullcup. At the right is the
  tutelary deity Mahamaya, blue, with four faces and four hands holding
  a skullcup and katvanga staff and in the second pair a bow and arrow.
  The consort, Buddha Dakini, is light blue in colour, with one face and
  four hands holding the same objects as the Lord. Adorned with wrathful
  vestments, above a corpse, sun disc and pink lotus flower they stand
  in a dancing posture against an orb of red wisdom fire.
At the bottom center is the special protector for the Kalachakra cycle
  of Tantras, Vajra Vega (Tib.: dor je shug, Eng.: Vajra Strength). Very
  wrathful, blue in colour, with four faces, twenty-six hands and two
  legs he displays the same colours as Kalachakra. At the left is the
  tutelary deity form of Vajrapani, wrathful, blue, with one face and
  two hands holding an upraised vajra in the right and a bell in the
  left. Embracing the consort, green, they stand surrounded by fire. At
  the right is Hayagriva, red, with one face and two hands holding a
  stick and lasso.
The Kalachakra Mandala belongs to the non-dual anuttarayoga tantra
  practiced to a greater or lesser degree by all schools of Tibetan
  Buddhism. The concept of 'time' is used as the special metaphor to
  symbolize the process of transformation from mundane existence to
  complete enlightenment. From amongst the numerous lineages to enter
  Tibet the Rwa and Dro are the most famous. The Sakya school maintains
  seven distinct lineages of transmission. (See Guhyasamaja and
  Yogambara from the same set).
Rwa Lineage: Buddha Shakyamuni-Kalachakra, the Shambala king
  Suchandra, a line of 8 Shambhala kings ending with Manjukirti and
  Pundarika, a Manjushri emanation, Chilu Pandita, Pindo Acharya,
  Kalachakrapada the younger (Naropa), Manjukirti, Samantashri, Rwa
  Chorab, Rwa Yeshe Sengge, etc.

-- Jeff Watt 3-99
Himalayan Art
https://theoldmonkeymind.files.wordpress.com/2012/01/kalachakra.jpg


How to configure a second IP address (to bind it to a VBoxHeadless virtual machine then)?

Question: I've requested my ISP to dedicate me a second Internet IP address and have got it. Now I need to configure it (I've never had any experience with using multiple IP addresses on one network interface) on my Ubuntu 10.04 server so that it will be a public address of a VirtualBox (VBoxHeadless) machine (running Ubuntu 10.04 Server as well). Would you be so kind to tell me how can I do so, or at least what docs to read and what specific subjects to google for?
Answer: The simple manual way looks like this:
ip address add 192.168.0.200/24 broadcast + dev eth0

If you want to make this a permanent configuration in /etc/network/interfaces you will have to use the older alias interface syntax (e.g., eth0:1), because that configuration file doesn't support multiple addresses per (primary) interface yet.  Add something like this:
auto eth0:1
iface eth0:1 inet static
    address 192.168.0.200
    network 192.168.0.0
    netmask 255.255.255.0


What are deeds of heart?

Question: Assalamualaikum, i actually wanted to know what is deeds of heart? I heard a lot of scholars say that if a person doesn't have deeds of heart, he basically doesn't have faith, so what is good deeds of heart, and what are bad deeds of heart, do they mean a person's intention or his believe it things like a person's believe in islam, and things like that, are they called deeds of heart?
Comment: Honestly the only scholars I've read so far using this term are ibn Taymiyyah, his student ibn Qayyim al-Jawziyyah and of course salafi scholars. I'm not aware whether this term is used by any others or earlier scholars. However the meaning or importance of the heart's impact on deeds is agreed upon.
Answer: You may be referring to al-Ghazali's
The Marvels of the Heart
He describes the deeds of the heart as a process in four steps:

an involuntary intention, an impulse that has not yet come into contiousness.
an inclination, as comming into contiousness, but without a decision
conviction, where it is considered whether something should be done.
decision to act
Thes stages are "deeds of the heart". He writes about the decision:

The Fourth of these stages is a decision to act, and one is held
accountale for it, But if it is not carried out, the case is to be
considered. If the men has given it up through fear of Allah and
contrition for his decision, then this is reckoned to him as a good
deed. His decision was evil, but his abstaining from it and struggle
with himself against it were good. A decision in accord with nature
does not indicate a complete heedlessness of Allah, but abstinence
through struggle against the nature requires great power. So his
effort in going contrary to nature, which is a work done for Alleh, is
stronger then his effort to agree with Satan through agreeing with his
own nature, Thus it is reckoned to him as a good deed, because his
effort in abstaining end his decision thereto outweighed his decision
to do the deed. But if the act is stopped by some hin- drance, or if
he gave it up for any reason other then the fear of Allah, it is
reckoned to him as an evil deed. His decision was voluntery act of the
heart.

Ghazhali places the action of faith acting mainly in the fourth, decision-making period, as a concious act, regulating unconscious impulses and exposes how to train this institiution in belief, and qualifies the mere intention to sin not as a sin but counts the unrevised sinful decision that was prevented from bein done only by external influence as a sin.
You may read his entire book (see link above) to understand his thoughts. I quoted from chapter 13, p.165 in the linked document.
A different approach is found parting from faith, making the believer become eager to do good deeds as in the context of Al-Hasan Al-Basrî:

Faith (îmân) is not by embellishment or wishful thinking, but it is
what settles in the heart and is verified through your works. Whoever
says good but does not do good will have his words compared to his
deeds by Allah. Whoever says good and does good will have his words
raised by his deeds. This is because Allah 'azza wa jalla said: To Him
ascends the good word, and the righteous deed raises it. [Sûrah Al-Fâtir: 10]

In likeliness, a good deed of the heart is equally not valuable until it is done or, in analogy, speaking with al-Ghazali, it was hindered by outer circumstances.
Answer: Allah's Messenger (ﷺ) said: "Beware! There is a piece of flesh in the body if it becomes good (reformed) the whole body becomes good but if it gets spoilt the whole body gets spoilt and that is the heart."
(Sahih Bukhari: 52).
We know that good and evil are coupling to make this universe. Same is the case with human nature or inner personality, which has strong connection with our heart. Our physical organ, heart circulates and connects us to human emotions, beliefs as well as experiences of love, joy, loss, grief, drama, sadness, inspiration and motivation as well. Spiritually provides us a context and tells us how we have to use all these attributes to build a better life. So, the heart is the basic, central point for our intentions, actions and life. Most of our stories belong to it.
However, good deeds of hearts belong to the purity of heart, intentions, thoughts and emotions and bad deeds occur due to the corruption of these attributes. Satan, our Nafs and Fitnas around us corrupt these attributes whereas, our Fitra (Natural inclination), Allah's messengers, Quran, hadith, scholars, and every person or sign who guides towards Allah are all present to enable us for doing good deeds.
Let's talk in detail.
<code>             **Bad deeds of heart:**
</code>
Firstly, we are all sent in this world for a test. Our first test is to keep ourselves away from Satan's waswasas, he insinuates in our hearts.
Satan said to Allah Subhan Tallah:
"Because you have made me go astray, I shall certainly try to seduce people into straying from the right path"
"Then I will certainly come to them from before them and from behind them, and from their right-hand side and from their left-hand side; and You will not find many of them giving You thanks"
(Al Araf: 16, 17)
These Ayats suggest that evil intentions, arrogance, ungratefulness, jealousy, forgetting Allah Subhan Tallah and getting astray from Siratay Mustakeem are related to the bad deeds of hearts. They are all included in Satan' mission as he said all this out of the above-mentioned attributes.
Allah Subhan Tallah has granted him permission that's why
"Satan reaches everywhere in the human body as blood reaches in it,"
(Sahih Bukhari: 2035)
But at the same time, Allah Subhan Tallah has favored us as mentioned in a hadith:
"Every son of Adam sins, and the best of the sinners are the repentant."
(Tirmidhi: 2499)
So, any human being can be subject to errors, Allah being the only perfect one. Thus, the sole authority for the forgiveness of any human being corresponds to Allah.
Secondly, if we succeed in keeping ourselves away from Satan mission, then we have our Nafs as a test.
"And if we have willed, we would surely raised him by their means but he clung to the earth and followed his desires."
(Surah Araf: 176)
Al-Tabari reported:
"Hasan Al Basra, May Allah be blesses with him said: your true enemy is not the one you are relieved from if you killed him, Rather, your true enemy is your Nafs, between your two sides."
(Tahdhid al Athar Musnad 'Umar2/812).
But Allah Subhan Tallah has favored us at the same time by saying:
But as for the one who fears to stand before his lord and restrains himself from low desires
The gardens (of bliss) shall surely be (his permanent) abode.
(Naziat: 40, 41)
Prophet Muhammad Pbuh said:
"The actual Mujahid is the one who strives against his self in obedience to God, The Mighty and majestic."
(Tirmidi: 1621, Musnad Ahmad: 23997, Ibn Hibban: 4706.)
It means lack of self-control and following low desires are also related to the bad deeds of hearts. Whereas, the obedience of Allah Subhan Tallah develops Taqwaa (every deed which makes Allah happy) and self-control against all the evil deeds of heart
Thirdly, we have lots of Fitnas (temptation) in our surrounding.
"And We test you by evil and by good by way of trial [fitna]…."
(Surah Al Anbiya: 35).
" ….Henceforth if there comes to you a guidance from Me, then whosoever follows My guidance shall neither go astray nor suffer misery."
(Taha: 123).
……so if they repent and amend (keeping their conduct good) then turn aside from them, For Allah is always ready to accept repentance. He is All-Compassionate
(Nisa: 16).
<code>      ***Good deeds of Heart***
</code>
Allah has made all the arrangements to provide us guidance and Hidayat. As He has created us upon his fitrah.
"Abu Huraira reported Allah's Messenger (may peace be upon him) as saying: No child is born but upon Fitra. He then said. Recite: The nature made by Allah in which He created man, there is no altering of Allah's nature; that is the right religion."
(Sahih Muslim: 6425).
It is the fitrah (natural inclination/sound human nature) which is instilled in our souls and hearts, that drives us to believe in and obey Allah Subhan Tallah whole heartedly.
Allah Subhan Tallah has also placed some of His attributes in us like modesty, forbearance, kindness, Sabar, assuming goods of other, forgiveness and natural goodness for all etc.
"And when your Lord said to the angels: I am going to place on the earth a vicegerent"
"And He taught Adam all the names, then presented them to the angels; then He said: Tell me the names of those if you are right."
(Al Baqarah:30, 31)
Here the names mean realities and knowledge which guide us to do good deeds of heart. That's why, Humans have the greatest capacity for knowledge on account of having divine element in them, which makes man a worthy being. The angels were commanded to prostrate before Adam (a.s.) only after Allah had breathed life into him-that is instilling the Divine Spirit into Adam. All the capabilities of this species originate from this endless and everlasting source-the Divine Spirit.
Along with these attributes, He has also given us a tool kit in the form of Quran and hadiths to fight against Satan, Nafs, and Fitnas.
Except them:
And He shows you His signs, and then which of the signs of Allah will you deny?
(Ghafir:81)
These signs also lead us towards the recognition of Allah Subhan Tallah. And whoever recognizes Him, will surely follow his commands which are based upon the good deeds of hearts.
I end here with this hadith:
Mu'adh (bin Jabal) (May Allah be pleased with him) reported:
Messenger of Allah (pbuh) held my hand and said, "O Mu'adh, By Allah, I love you and advise you not to miss supplicating after every Salat (prayer) saying:
اللهم أعني على ذكرك وشكرك، وحسن عبادتك
(O Allah, help me remember You, expressing gratitude to You and worship You in the best manner)"
(Abu Dawood, An Nasa'i, Riyad as-Salihin:384)
May Allah Subhan Tallah protects our hearts from deviation and doubts and always guide us to the path of the truth. Ameen

What are deeds of heart?


For which values of $d<0$ , is the subring of quadratic integers of $\mathbb Q[\sqrt{d}]$ is a PID?

Question: The "integers" of quadratic field $\mathbb Q[\sqrt{d}]$ , for a squarefree integer $d$ , forms an integral domain . I know that for $d<0$ , the quadratic integers of the quadratic number fields satisfy Euclidean algorithm only for $d=-1,-2,-3,-7,-11$ . I want to know , for which $d<0$ , it is true that every ideal of the integral domain of quadratic integers of $\mathbb Q[\sqrt{d}]$ is a principal ideal , that is when is the subring of quadratic integers of imaginary quadratic number fields is a PID ? I want to know this as PID do not imply ED but does imply UFD . Please help . Thanks in advance
Comment: http://en.wikipedia.org/wiki/Heegner_number
Answer: With $d<0$, the ring of integers of $\mathbb Q(\sqrt d)$ is a PID exactly when
$$d= −1, −2, −3, −7, −11, −19, −43, −67, −163$$
Checking that these rings are PIDs is not too hard, but checking that no other values give  an integer ring that is a PID requires some heavy machinery - see the class number 1 problem.
Comment: @SaunDev The ring of integers of a number field is a Dedekind Domain. It is a general theorem that a Dedekind domain is a UFD if and only if it is a PID. The key fact is that a UFD is a PID in which every non-zero prime ideal is maximal.
Comment: I know that these are UFD 's , but are they also PID ?
Comment: I'm looking specifically at the example Q(sqrt(-67)) and trying to show it is a PID
So I should be looking at the ring of integers first and then determining whether it is a dedekind domain, then using the theorem you metioned above showing it is a UFD and the hence a PID.
Is this correct or am I looking at this the wrong way?
Comment: @Padraic all rings of integers of number fields are Dedekind domains. It might be possible to manually show that this is a UFD, but the best way will be to try to compute the class number
Answer: The $d < 0$ such that $\mathcal{O}_{\mathbb{Q}(\sqrt{d})}$ is a principal ideal domain are: $$-1, -2, -3, -7, -11, -19, -43, -67, -163.$$ Multiplied by
$-1$, these are the Heegner numbers (see Sloane's A003173).
If $\mathcal{O}_{\mathbb{Q}(\sqrt{d})}$ is a Euclidean domain, then it is also a principal ideal domain, and if it is a principal ideal domain, it is also a unique factorization domain. But it can be non-Euclidean and still be a principal ideal domain. For example, $\mathcal{O}_{\mathbb{Q}(\sqrt{-19})}$ is not Euclidean: try for example to compute $$\gcd\left(\frac{3}{2} + \frac{\sqrt{-19}}{2}, 10\right)$$ using the Euclidean algorithm. Frustrating, right? But it is a principal ideal domain.
Sloane tells us Gauss discovered the nine $d$ listed above (and also listed in other answers to your question) but "Heegner proved the list is complete." Well, he had a little help from Tony Stark. The proof exists, has been published and has been verified. But it's too long to include here.
I can at least show you why $-2$ is the only even value. Suppose $n$ is positive, odd and squarefree. Then, in $\mathbb{Z}[\sqrt{-2n}]$, we can be sure the following numbers are irreducible: 2, $n$, $\sqrt{-2n}$. So $2n$ has at least two factorizations: $2n = (-1)(\sqrt{-2n})^2$. Therefore the prime ideal that properly contains $\langle 2 \rangle$ and $\langle n \rangle$ can't be a principal ideal.


Linux - Squid on local machine to control outgoing traffic

Question: I'm trying to setup squid on my computer to control the outgoing traffic from the same computer only. If my understanding is correct, squid runs as user "squid" on on most Linux distributions (mine is Fedora if it matters?).
I have setup iptables to drop all outgoing packets except those from uid 0 and uid 23 (root & squid).
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -j DROP
-A FORWARD -j DROP
-A OUTPUT -m owner --uid-owner 0 -j ACCEPT
-A OUTPUT -m owner --uid-owner 23 -j ACCEPT
-A OUTPUT -j DROP
COMMIT

I then want to have to manually enter the squid proxy information into the browser for each local user account (so I don't think I'm after a transparent setup). If possible I would like a user/pass required to be able to connect to squid, so to prevent users having any access to the internet except via the squid proxy?
My current squid.conf is as follows, but it doesn't work at all, and obviously doesn't incorporate a user/pass requirement:
acl ssl_ports port 443
acl safe_ports port 80      # http
acl safe_ports port 21      # ftp
acl safe_ports port 443     # https
acl safe_ports port 70      # gopher
acl safe_ports port 210     # wais
acl safe_ports port 1025-65535  # unregistered ports
acl safe_ports port 280     # http-mgmt
acl safe_ports port 488     # gss-http
acl safe_ports port 591     # filemaker
acl safe_ports port 777     # multiling http
acl CONNECT method CONNECT
http_access deny !safe_ports
http_access deny CONNECT !ssl_ports
http_access allow localhost manager
http_access deny manager
http_access allow localhost
http_access deny all
http_port 3128
coredump_dir /var/spool/squid
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern .

Is what I'm trying to do achievable, and am I going about it the right way?
Will what I've done with iptables work?
I realize this is not something I'm going to learn to setup correctly in 10 minutes so any help/pointers to guides or even alternate solutions as to how to achieve this are all welcome?
Answer: You will likely need to open access to at least DNS for other programs.
Squid does have an authentication module, but you shouldn't need it in your case.  As only squid can access the web all users will be force to use it.
Check the environment variables used to set up proxies and configure them globally.  You should set http_proxy at least.
There is a wpad.dat mechanism for configuring proxies, but I haven't used it as you are intending.
I think you will find a lot of services use ports not listed, and the browsing experience will not be very good.
As you don't seem to be blocking any sites, it may be simpler just to limit the ports using iptables.


How can I serialize dynamic object to JSON in C# MVC Controller action?

Question: I want to serialize dynamic object to JSON. I tried using ExpandoObject, but the result is not what I need:
public JsonResult Edit()
{
    dynamic o = new ExpandoObject();
    ((IDictionary<string,Object>)o)["abc"] = "ABC"; //or o.abc = "ABC";
    return Json(o);
}

I want JSON to look like: {"abc": "ABC"} but instead it looks like [{"Key":"abc","Value":"ABC"}]
Obviously ExpandoObject will not do, but can I inherit from DynamicObject and somehow override its methods to achieve JSON format I want?
Comment: Answer is to flatten according to: http://stackoverflow.com/questions/5156664/how-to-flatten-an-expandoobject-returned-via-jsonresult-in-asp-net-mvc
Comment: @JoeTuskan btw its worth voting to close things like this
Answer: I had this same problem and ended up fixing it by using the JSON.net (Newtonsoft.Json) serializer instead of using the JsonContent result. It then serialized my dynamic objects with normal properties versus the "key" "value" weird list.
//In my usage I had a list of dynamic objects
var output = new List<dynamic>();

//Change this
return JsonContent(new {Error = errorMessage, Results = output});

//to this
return Content(JsonConvert.SerializeObject(new {Error = errorMessage, Results = output}));

Comment: Please consider copying your answer to http://stackoverflow.com/questions/5156664/how-to-flatten-an-expandoobject-returned-via-jsonresult-in-asp-net-mvc
Answer: This will return what you want.
public JsonResult Edit()
{
    return Json(new {abc = "ABC"});
}

Comment: This is a class with abc property. I want the class to have properties added at run time.
Answer: This may not be useful to you, but I had a similar requirement, but used a SerializableDynamicObject
I changed the name of the dictionary to "Fields" and then this serializes with Json.Net to produce json which looks like:
  {"Fields":{"Property1":"Value1", "Property2":"Value2" etc.

where Property1 and Property2 are Dynamically added properties - i.e. Dictionary Keys
It would be perfect if I could get rid of the extra "Fields" property which encapsulates the rest, but I've worked around that limitation.
Comment: Can you move this over to http://stackoverflow.com/questions/5156664/how-to-flatten-an-expandoobject-returned-via-jsonresult-in-asp-net-mvc and VTC this please? I'll even throw in a +1 in the deal :D
Answer: You can always serialize a HashTable, its not dynamic but it supports object key value pairs.
Answer: This worked for me perfectly. You have to use Json.NET.
 [HttpGet]
    public string GetJson()
    {
        List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();

        List<DataEntry> properties = new List<DataEntry>();

        for (int i = 0; i < 10; i++)
        {
            properties.Add(new DataEntry { Column = "column" + i.ToString(), Value = "value" + i.ToString() });
        }

        list.Add(properties.ToDictionary(x => x.Column, y => y.Value));
        string test = JsonConvert.SerializeObject(list);

        return test;
    }


Why namespace can't be created in an org when devhub is enabled?

Question: I am trying to understand the rationale behind this from a technical design perspective. why would creating namespace be limited in an org that's been marked as devhub? wouldn't the other way easier for developers to have the namespace and devhub in one org?
Answer: It would be convenient, except that you can link one Namespace to multiple Dev Hub orgs, and you can link multiple Namespaces to a single Dev Hub org. A developer would be able to link the Dev Hub's Namespace to the Dev Hub's Namespace Registry. I'm pretty sure this would make the Namespace unusable in that org, because packages have to be registered to a Namespace, by name, if they're going to be a First Generation Package (1GP) or a Second Generation Package (2GP). Because the API uses the Namespace's name, and not its Id, this could cause problems when creating packages, especially when you start building dependencies. Overall, this restriction is to prevent weird packaging scenarios.
Comment: Thanks sfdcfox for replying. however, I am not quite following your thought process. I wonder if you can help further with these questions so I can follow your thoughts.
1.  can a namespace be linked to multiple devhub and multiple devhub be linked to a namespace? if so, namespace and devhub are many to many relationship? If not, namespace and devhub are 1 to 1 relationship?
2. both 1GP and 2GP have to be registered to a namespace by name, correct?
3. surppose the namespace and devhub are in the same org, what would be an example of weird packaging senario?
thank again.@sfdcfox


Is there some upper limit in the moon size distribution?

Question: The planets range hugely in sizes, Jupiter is more than 300 times as massive as Earth. But the sizes of the large moons seem to be uncorrelated with the sizes of the planets they orbit. Why doesn't Jupiter have a giant moon with a mass hundreds times larger than the Earth's Moon's?
Among gas giants, Saturn at a third of Jupiter's mass has the largest of all moons and Triton way out at 30 AU Neptune is the 7th largest of all moons. The theories of the origin of the moons seem to vary much too, without explaining any upper size limit. The Moon was formed by an impact. Triton and maybe Titan were captured. Other large moons were formed along with their planet. Is this upper size limit on moons imaginary, coincidental or is there some reason for it to be this way? I of course mean a hypothetical expected upper size limit for exomoons in general, not only statistics about the Solar System moons.
The wonderful illustration here is from Emily Lakdawalla at The Planetary Society, it is now my desktop background.
Answer: Small point, but Ganymede is slightly larger than Titan as moons are measured by their solid surface, though with atmosphere, Titan appears slightly bigger.   The drawing is probably accurate, but slightly misleading.
It's worth adding that Titan is out-gassing so it may have, quite some time ago, been larger than Ganymede.
Source
According to wikipedia, the larger, close to Jupiter and Saturn moons are unlikely to have been captured moons.
https://en.wikipedia.org/wiki/Formation_and_evolution_of_the_Solar_System#Moons

Jupiter and Saturn have several large moons, such as Io, Europa,
  Ganymede and Titan, which may have originated from discs around each
  giant planet in much the same way that the planets formed from the
  disc around the Sun.[76] This origin is indicated by the large sizes
  of the moons and their proximity to the planet. These attributes are
  impossible to achieve via capture, while the gaseous nature of the
  primaries also make formation from collision debris unlikely. The
  outer moons of the giant planets tend to be small and have eccentric
  orbits with arbitrary inclinations. These are the characteristics
  expected of captured bodies

and the 3 listed methods of moon formation are:
Co-formation
Impact
Capture.
The largest co-formation ratio is Titan to Saturn, about 1 to 4,000 in terms of mass.   Ganymede to Jupiter, less than 1 to 12,000.   The wiki article points out that ratios of 100 to 1 are likely giant impacts and you're unlikely to see that kind of ratio in co formation, so a conservative estimate, the largest co-formation you mgiht see might be around a few hundred to 1.   If you figure the largest planets are about 12-12.5 Jupiters (more than that, they become brown dwarfs, though a cool brown dwarf orbiting a sun might get called a planet too at greater than 13 Jupiter masses), but lets say, 12 Jupiters.  That's about 4,000 earth masses.    If we look at a co-formation ratio of a few hundred to perhaps over a thousand to 1 as about the maxiumum, there's a possible ballpark answer of a handul of earth masses might be about as big as a co-formation moon is likely to get in a perfect formation situation, And those would probably be pretty rare.
Giant impacts are different.  Pluto-Charon could be an impact generated dwarf planet/moon system and Charon is 1/8th the mass of Pluto.    How likely that kind of impact is to happen on a super earth is hard to say, but theoretically a super-earth with a giant impact could have a large moon too - a bigger earth with a bigger impact and bigger moon, but there's problems here.  Giant planets are likely to form close to the sun and the orbital sphere of influence gets smaller closer to the sun.   Also, giant planets might tend to form thick gaseous atmospheres, retaining all their hydrogen and helium, so too big, it might begin to resemble a gas giant, which aren't as good at creating debris when impacted, so there's a few limiting factors here and we might be limited to, certainly several times larger than our moon, but perhaps not as large as co-formation moons, further from the sun.
Finally, moon capture.    While there's no examples of this in our solar system, I see no reason why a large planet couldn't capture another planet, though you then have to determine whether it's a co-planet orbit, which I think a captured planet should be considered, or whether the captured object is a moon. - personally I think a captured planet that orbits a planet would be a co-planet system, so I don't like the capture as a method for getting as large a moon as possible, though I suppose it could be looked at either way.
We know almost nothing about moons in other solar systems (exomoons).  The observations are just barely possible with current technology, but very difficult.  That's likely going to change in the next few years, but for now we know virtually nothing in other solar systems, so, any present predictions on the largest possible moons would have to be modeled or estimated.
A few articles on exomoons:
http://www.astrobio.net/news-exclusive/new-exomoon-hunting-technique-could-find-solar-system-like-moons/
http://discovermagazine.com/2012/jul-aug/06-hunting-moons-outside-the-solar-system
http://www.space.com/25438-exomoon-around-alien-planet-discovery.html
http://phys.org/news/2014-10-exomoons-abundant-sources-habitability.html
http://blogs.scientificamerican.com/life-unbounded/has-an-exomoon-been-found2/
Comment: Great answer! But you could maybe more directly address the question about why planet mass (1-318 Earth masses), solar distances (1-30 AU) and process (co-formation, impact, capture) all seem to be uncorrelated with maximum moon size in absolute terms. And I've heard that Titan might be a "recently" captured KBO, to explain why it is still outgassing. Is that unlikely?
Comment: I could try, but I'd end up doing a lot of guessing if I tried to answer those.  Would need to do some research.   And I didn't know that about Titan.  That's interesting.    Will have to read up on that as well.
Comment: Only if it motivates you, of course, I'm just curious. I don't hear much about moon formation, other than Luna which seems to have been an unusual event.
Answer: I saw this presentation of the National Academy of Science 2015 where Dr. Robin Canup explains, illustrated by simulations, that many large moons formed sequentially around giant planets. But their growing mass thru accretion caused perturbations in the gaseous planetary disk ("type I interaction") that drew them inwards to collide with the planet within a million years. The total mass of all the satellites to the planet's mass remains fairly constant given (partly) the density of the Solar Nebula. The larger moons crash into the planet while new moons are growing larger. The process stops when the Solar Nebula has been exhausted. So I suppose speculatively that different exoplanetary systems might have different moon size ceilings.
Impact formation size of Earth's Moon, in the middle of the Jovian moons, is a coincidence according to this model.


How to change item Permission on Sharepoint Online Powershell

Question: I want to ask a question, how to change permission to the element by Sharepoint Online ? How could I identify user. Could I Identify user by email ? Or it should be done only by account ?
Answer: Since the OOB powershell commands for SharePoint online don't include changing permissions, this is something that will have to be done via CSOM. You can code it yourself, see here for an example, or you can use the SharePoint PnP project, and use the code that others have already written and tested. This page lists all the available PowerShell commands that are in the PnP project. Just do a find on the page for the word "permission" to find the applicable cmdlets. This page has the installation instructions for getting started with it.


How to get a circle to snap its size to a specific radius?

Question: I have a diagonal line and I want it to be the radius of a circle. I can snap the centre of the circle to the first cusp node fine and extend it out from there, but for some reason it won't snap the path of the circle to the other cusp node. What am I doing wrong here and how can I circumvent it?
Comment: disclaimer: not an Inkscape user, so suggesting my Illustrator workflow. Can't you measure the length of the line, and then have Inkscape draw a circle with that exact size as the radius?
Comment: @Vincent This workflow isn't needed in Inkscape. The software has comprehensive snapping options to enable exactly what the OP wants.
Answer: In the Snapping Controls bar, make sure you select the following options.

Enable Snapping
Snap Nodes Paths and Handles
Snap to Paths
Snap other Points
Snap rotation centres

With the Bézier Tool selected, When you approach the circle's path, it will snap to it displaying "Handle to Path".
Example (snapping options shown right)

If you need to do this in reverse, and already have a line, then you could use the Measure Path extension to measure it, then draw a circle from one of the end nodes, holding down Ctrl+Alt as you click and drag, then edit the Rx and Ry values in the Tool Controls Bar to match the line length.
Example
Comment: Nice answer, but the question wasn't how to snap a line given a circle: it was how to snap a circle given a line. Usually the snap affects the mouse cursor, and while we are drawing a circle this works only when the given line is horizontal or vertical. For other angles, I cannot see an immediate way to snap the circle (e.g. you can rotate the line until is vertical, draw the circle, re-rotate the line). A tricky question.
Comment: @PaoloGibellini If the OP needs to do it in reverse, then there's a Measure Path extension, which can measure a line at any angle, then it would be possible to draw a circle holding down Ctrl+Alt while you drag from one of the end nodes, and then edit the Ry and Rx values in the Tools Control Bar to be the same as the line length.
Comment: @PaoloGibellini I've added that to my answer.
Comment: This doesn't help me--the measure path tool gives a rounded off precision number to what has been specified. I'm looking for it to be as precise as possible (hence why I'm interested in a snap).
Comment: @Nicholas If you are looking for that level of precision, then Inkscape or similar vector graphics software is probably not the software for you. Maybe have a look at using some actual CAD software instead.
Comment: @Nicholas well you do understand that the value gets rounded on save. SVG just works that way.
Answer: In Inkscape 1.0, you can use a path effect for it, no snapping required:
Option 1:

draw the diameter instead of the radius, then
Path > Path effects > + > Ellipse from points : dropdown 'force circle'.

Option 2:

select the radius
Path > Path effects > + > Show experimental > Circle (by center and radius)
Answer: Just in case the radius is already drawn but you must insert a circle like in your example try this:

Have all snaps to point and guides ON, but keep snap to grid and bounding box OFF.

Drag from the top a horizontal guide to the center of the wanted circle. It snaps.

Duplicate (=select, press Ctrl+D) the radius. Drag duplicate's (=green) rotation center to the center of the wanted circle. It snaps. Rotate the duplicate to horizontal. It snaps, too.

Draw a vertical line (blue) starting from the end oft the rotated duplicate

Draw a circle from the wanted center point (=hold Shift and Ctrl) until it snaps to the vertical line.
Comment: I was already answering, but your answer is more simple. You can also use a guideline instead of the vertical blue line.
Comment: How do you rotate the duplicate to be exactly horizontal? The program only wants to rotate it a specific number of degrees *relative to the object itself*, without regard for what angle the line is starting in.
Comment: @Nicholas  You have revealed an error. I had switched from the move tool to the node tool and of course it snapped. The wrong radius cannot be seen in the small screenshot. I have fixed the answer. Fortunately snap to guides works when rotating.


How do I change the GRUB boot configuration from within Windows?

Question: I currently dual boot Windows 7 and Fedora 14, using GRUB, with Windows 7 as my default. I know that from Fedora, I can set GRUB to boot into Fedora, overriding the default, on the next reboot. Is there a way to do this from Windows? That is, can I change the GRUB configuration permanently or semi-permanently from Windows so I don't have to be in front of my computer to boot into Fedora?
Comment: This is a thanks to Michael and an extension. There is a free driver by Paragon in public interest, which can access (with read and write permissions) to Ext2, Ext3, Ext4 partitions from Windows: https://www.paragon-software.com/home/extfs-windows/
Answer: The hard part is editing your Linux filesystem from Windows. FS Driver supports writing ext2, but I don't know of any good tools for ext3 or 4 (and these SU and SF questions aren't encouraging), let alone any other filesystems you may have used on your boot partition
But if you do manage to get write support for your boot partition from Windows, actually changing the saved default is easy. First you need to do some prep work in /boot/grub.conf. Change default to saved, and add savedefault 0 (where 0 is Fedora's index in the GRUB configuration) to the Windows block so booting into Windows will reset the saved default back to Fedora
Then from Windows you can edit /boot/grub/default. Delete the line that's there (it'll be default or 0 most likely), and change it to 1 or whatever the index of your Windows install is. When you restart, GRUB will read that file (since your default is saved) and boot into Windows, and the savedefault line will change that file back to 0 for future boots
Comment: Someone's written a GUI for that: [grub-choose-default (Grub 1)](http://de.mcbf.net/david/grubchoosedefaultlegacy/), [grub-choose-default (Grub 2)](http://de.mcbf.net/david/grubchoosedefault/).
Comment: This worked for me. I had to set my `/boot` partition as `ext2` (it was `ext4`) and my limited experience doing that made that process take longer than it should have. It looks like these instructions set Fedora as the default (which I don't really want, I just want the ability to control the next boot) so I didn't follow them to the letter, but being able to edit `/boot/grub.conf` is good enough.
Answer: You can use Grub2Win or other similar programs as listed
here.
They offer an easy user interface.
You could also completly remove Grub and boot both systems from the Windows bootloader. In order to do so you need to use tools such as EasyBCD.
Comment: I assume you mean Grub2Win? :)
Comment: Oh, yes, a typo.
Answer: If you have a /boot partition formatted as FAT32, you'll be able to edit grub's config file from both OS(es).
Answer: Mixing different hints:

Under Ubuntu I changed GRUB_DEFAULT=0 to GRUB_DEFAULT=saved and ran update-grub, thus making GRUB use /boot/grub/grubenv file, but I am not setting GRUB_SAVEDEFAULT=true (as it serves another purpose)
I checked available GRUB entries using this command:
awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg
Later I ran grub-editenv - set saved_entry="Windows 10 (on /dev/sdb1)" choosing one of the available options, so I made Windows start next time as default
Under Windows I mounted Linux (ext4) filesystem using Ext2Fsd
I edited /boot/grub/grubenv manually, commented out with # the previously created line # saved_entry=Windows 10 (on /dev/sdb1) and added a new one saved_entry=Ubuntu.
Under Ubuntu I do it vice-versa, switching between the settings, commenting out the respective line.

I think it's a neater solution than manually editing grub.cfg file directly and menu.lst has been deprecated already some time ago.
Comment: this worked fine for me except the Ext2Fsd with my Ext4 partition. I installed the 0.70 beta 3 Ext4 filesystem driver for Windows from http://www.accum.se/~bosse/, enabled the testsigned driver, rebooted windows and boom: read/write Ext4 access. :)
Answer: Find the 'grub' folder in the hard disk and then open menu.lst with notepad now edit default=0 to default=x, where x is one less than the position of the os you want to make default. For Ex. there are three os in a system and you wanted to make the third in the list as default so you will edit it as default=2, as 3-1=2. For second os, default=1.
Answer: I created a /boot device and selected it as Device for boot loader installation  and it worked.


ESRI JavaScript 4 - Shouldn't the editor widget honor definition expression?

Question: If a feature layer has a definition expression defined, as in the code pen example, shouldn't you only be able to see and edit (select for editing) features that meet the definition expression?
It seems that the widget tool doesn't honor the definition expression and its quite confusing.
I need a work around.
Example: You have a feature layer in a web map, there are two features in the data source that over lap, the definition expression is true for 1 and false for the other (so you can't see the second in the web map),  if you select the edit tool and click on the one that is visible, both are queried from the feature service and both are displayed in the edit widget results.
Is there something I'm not configuring correctly?
Here is a code pen example.  Click on the pink zigzag patrol line with the edit tool active
https://codepen.io/AliWieck/pen/ExaMWJq?editors=1000
Line 91 of this codepen example applies a definition query that should limit display of any police route lines like so
<code>layer.definitionExpression = "PatrolType = 'Segway patrol'"
</code>
yet when I click on a location where I know there are Segway and other types of routes that are overlapping, I get all features returned  and displayed in the editor widget even though only one  is visible on the map.  Click the button for any feature that doesn't meet the definition expression does nothing.
Answer: Esri confirmed it's a bug.  Should be fixed in 4.17 release scheduled for March.


why do they use NULL in VHDL code

Question: From times to times I see different code examples that have " ... else Null" strings in if-statements and it's something I don't get. I've learned and I stick to the idea that the best way to model nothing is write no code.  But is there any difference in these aproaches? if not then why do people write this "else null"?
Comment: Basically QA. `else null;` means `I didn't just forget this bit, there really is nothing to do here;`. As VHDL tends to be used in high integrity applications and some customers insist on critically reviewing every line of code, it really is the simplest and cheapest way to do the job.
Comment: Are you talking specifically about if-then-else structures or also switch cases with when others => null; ?
Comment: Apart from the good answer about QA, it may be to be able to place a breakpoint on that line in a VHDL simulator.
Comment: Please provide one or more concrete code examples you would like explained. Null can be used in several different ways in VHDL.
Comment: (A null statement can be labelled, see the answer referencing 10.14 in the standard. However neither breakpoints nor simulator user interactivity are defined in IEEE Std 1076-2008.)
Answer: As @BrianDrummond stated... From IEEE 1076:

10.14 Null statement
A null statement performs no action.
null_statement ::=
      [ label : ] null ;
The execution of the null statement has no effect other than to pass on to the next statement.
NOTE—The null statement can be used to specify explicitly that no action is to be performed when certain conditions
  are true, although it is never mandatory for this (or any other) purpose. This is particularly useful in conjunction with the
  case statement, in which all possible values of the case expression shall be covered by choices; for certain choices, it
  may be that no action is required

why do they use NULL in VHDL code


Tapped vs. Coupled Inductor

Question: I have reverse engineered a sounder circuit which appears to be using a center tapped inductor. Since then, I have tried to find center tapped / 3-pin inductors and cannot find them from a reliable source, the only place I manage to find was from Huizhou Haicheng Electronics Factory on Alibaba, see below.

After some research, I have found that things such as auto-transformers or coupled inductors can also be used in sounder resonating circuits.
As I understand it, the difference between a center tapped inductor and a coupled inductor is that the CT is a single coil around a core with a wire 'tapped' at some point in the middle of the coil, and a coupled inductor is two separate coils sharing a common core, if the end of one of the coils is connected to the beginning of the next, this essentially, at least in my mind, makes a tapped inductor.
Now, it is very easy for me to source coupled inductors from reliable suppliers such as Mouser, Farnell, and RS, etc, so it is much more preferable if I would be able to use these as a replacement.
So the question is: Can coupled inductors be used in place of a tapped inductor?
If yes, what would the advantage be of using one over the other, other than the fact one is much easier to find?
Or am I way off the bat and they are two completely different things?
Thanks in advance.

Side Question:
Would two inductors in series act similarly, or not due to the fact they do not have a common core like the above two components?
Answer: TL;DR : YES
You are right regarding the fact that connecting two coils of a coupled inductor (transformer) in serie makes a center tapped inductor (autotransformer).
(the words in the parenthesis are the generic terms, while the ones you use are more specific to sound/signal processing)

Tapped vs. Coupled Inductor


Running mono-service in linux as non-root

Question: I need to run a .net C# application (developed on a Windows system) as a service/daemon on an embedded system with a minimal Ubuntu installation (no X, no servers except ssh, only relevant software).  I created an /etc/init.d script containing the line
mono-service my-.net-app.exe service

and this worked well.  There is also an option to start the application interactively (for debugging purposes) with
mono my-.net-app.exe interactive

The last argument is an argument for the .NET application telling it if it's running as service.  This was implemented roughly this way:
private static void Main(string[] args){
  if(args.Any() && args[0] != null && args[0] == "service"){
    ServiceBase.Run(new[] {(ServiceBase) new MyService()});
  }else{
    try{
      Console.Write("starting app");
      if(StartWork()){
        Console.Write("press any key to exit");
        Console.ReadKey();
      }else{
        Console.WriteLine("starting app failed");
      }
    } // end try
    finally{
      StopWork();
      Console.WriteLine("finished app");
    }
  } // end else
...
} // end Main

public class MyService : ServiceBase{
  static private Thread _worker;

  protected override void OnStart(string[] args){
    _worker = new Thread(() => Program.StartWork(asService: true)); // this asService tells StartWork to not produce console output
    _worker.Start();
  }

  protected override void OnStop(){
    Program.StopWork();
    _worker.Join(1000);
  }
}

The purpose of this implementation was to allow the application to die gracefully (i.e. to execute StopWork()) upon sending SIGTERM on the linux machine.
For security reasons, I need to be able to run the service as non-root.  I created a new user and made it owner of the directories where the application writes its log files and added it to various groups to give it access to required device files.  Then, root would start the application as
sudo -u newuser mono-service my-.net-app.exe service

or
sudo -u newuser mono my-.net-app.exe interactive

The second option with mono works well, but the first one with mono-service doesn't (see error message below).  Since it works with mono, I'm confident that the user newuser has appropriate rights to access all relevant files and devices.  I wonder whether mono-service has been conceived as a root-only application.
I could also live with using the mono option and suppressing the console output, like this:
private static void Main(string[] args){
  try{
    Console.Write("starting app");
    if(StartWork(consoleoutput)){ // true or false depending on whether the service argument was given
      Console.Write("press any key to exit");
      Console.ReadKey();
    }else{
      Console.WriteLine("starting app failed");
    }
  } // end try
  finally{
    StopWork();
    Console.WriteLine("finished app");
  }
...
} // end Main

but then, when I kill the service (i.e. send SIGTERM to the mono process), it stops the .net application immediately without allowing it to execute the finally block.
Finally, my question is whether someone has an idea why mono-service is failing when not started as root.  The error message is the following and, as I mentioned before, it doesn't exist when I use mono instead of mono-service.
ERROR Program [4] [15:03:06.795 01/12/14] Error in Main!
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

---> NHibernate.HibernateException: Could not create the driver from SAFEmine.DataStore.Database.MonoSqliteDriver, SAFEmine.DataStore, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly Mono.Data.Sqlite could not be found. Ensure that the assembly Mono.Data.Sqlite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
at NHibernate.Driver.ReflectionBasedDriver..ctor (System.String providerInvariantName, System.String driverAssemblyName, System.String connectionTypeName, System.String commandTypeName) [0x00000] in <filename unknown>:0
at NHibernate.Driver.ReflectionBasedDriver..ctor (System.String driverAssemblyName, System.String connectionTypeName, System.String commandTypeName) [0x00000] in <filename unknown>:0
at SAFEmine.DataStore.Database.MonoSqliteDriver..ctor () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0

Alternatively, if I settle for mono instead of mono-service, is there a way to catch a SIGTERM from within the .net application and to die gracefully?  I tried this: https://github.com/ServiceStack/ServiceStack/wiki/Run-ServiceStack-as-a-daemon-on-Linux , but the code wouldn't compile on Visual Studio saying that the using Mono.Unix; and using Mono.Unix.Native lines were invalid.  I also installed Mono on Windows and tried to use the Mono compiler, but it complained about the same thing.
Comment: `Mono.Unix` is in [Mono.Posix.dll](http://stackoverflow.com/a/8408723/85785).
Answer: The mono-service.exe creates a new AppDomain with ApplicationBase being the current directory. This might influence assembly loading. Since you are seeing such an error, I would try to enable MONO_LOG_LEVEL=debug MONO_LOG_MASK=asm and/or strace -e file to see if they provide any hints.
Also note that you can pass -d switch to mono-service to have it change directory for you.


LIN bus ESD protection

Question: I need advise about LIN bus ESD protection. Here a four LIN connectors on board but only one LIN driver (master), is it mean that ESD protective diodes also must be 4? placed close to each connection? And take into account capacitance of these four ESD diodes?
Comment: I couldn't understand how the system is. Maybe a scheme would be quite helpful. ESD diodes' capacitances are not that important, because LIN is a low-speed system (You know that it is UART based).
Answer: I would strongly recommend putting an ESD diode on the LIN line near each connector. The reason is that you don't want the ESD currents to flow into your PCB where they may couple into unprotected internal tracks. This can cause no end of confusing issues that can be extremely hard to track down. If you just shunt the ESD pulse away at the connector, you keep the high voltages and currents away from the rest of your system.
On a low speed bus like LIN the extra capacitance is not going to be an issue, so I can't really see why you wouldn't do this unless cost was an extreme issue. If that is true, you can always put footprints for five TVS diode clamps on the board and then verify on the final hardware exactly what is required.
Comment: Thank you for advise, yes I'm agree ESD diodes must be placed at each connector, and I was worry about capasitance of these diodes, but after reading https://www.nxp.com/docs/en/application-note/AN00093.pdf I found that Cmaster has take into account number of LIN slaves, bus length and so on... finaly it becomes in nano farad order - which compare to diodes 17pF capasitance is nothing
Answer: I think you might benefit from a better understanding of ESD. If you understand it it becomes clear what needs to be done.
ESD is a pulse-like electrical discharge onto a conductor.
A bad ESD pulse can be 4 Amps or more.
ICs are rated and tested to handle a certain ESD level, for example 2 kV HBM (Human Body Model).
ESD does not distinguish between inputs and outputs.
ESD can damage sensitive components.
You only need to protect the conductors that are connected to a point which can get an ESD pulse. So internal lines on a PCB: no protection needed. Connector on your product: all pins need ESD protection.
So I would add protection diodes to all 4 lines.
I do not think the capacitance will be an issue since the LIN Bus uses quite low frequency signals. The capacitance of the wires (the bus) will be much more than the capacitance added by the protection diodes.
Comment: @MattYoung *Nobody that cares tests that way.* Maybe not in your world/environment. I'm at the IC design side and our customers expect HBM model based levels. There is indeed also CDM (Charged device model) and MM (Machine model) which can be tougher to meet. I guess that HBM is still there for historic reasons.
Comment: Why do all you IC manufacturers still spec everything relative to HBM? Nobody that cares tests that way.
Comment: All I know is that 2kV HBM spec has been in almost every IC datasheet I've ever seen. On the other hand, almost every protection device has been spec'd to IEC61000-4-2, which actually makes sense, since that's the only standard you ever hear people system testing against. Some of the things that are normal in this industry are funny...
Answer: ESD protection is a sub-nanosecond clamp, so it needs to be close to IC. If there is inductance between clamp and IC then the clamp diode sees a delayed pulse and is less effective.  We call this a low ESL connection, like low ESR but for inductance.(L)
ESD rise time of ionization between a key held by hand  and connector or simply connecting a loose charged cable, can be as small as few picoseconds with some charge voltage.  So low ESL is important for clamp protection and series R for current limiting.  So result looks like pulse with ringing somewhat like standard lightning test but much lower (nano) Coulombs but much faster rise time due to smaller gap. (<1ns vs ~1us)
So if discharge is say 1A in 100 ps rise time and ESL is 100nH what is voltage rise on conductor path?   V=LdI/dt
What does it need to need to prevent CMOS Latchup?
ESD actually has low negative resistance (ESR) and conductor interface has positive ESR, so effect on clamp voltage rise with any discharge results in rapid discharge of small C into series RL then diode then path to IC input pin must not exceed rails by +0.3V.  as far as I recall...
Now you should be able to answer your own question.
Comment: I guess those who voted -1 have no expertise in this area and should not vote until they appreciate experience. If you understand inductance, the simple answer is Yes for each port.

LIN bus ESD protection


Alternative of finding theta when sin $\theta$ and cos $\theta$ are given

Question: For example, we're given a problem in which sin $\theta = \sqrt3/2$ and cos $\theta = -1/2$. To find out the angle $\theta$, I look at the unit circle and I get the answer. However, I was just curious whether there's an alternative to this, any idea? Because when I tried using cos(-$\theta$) = cos$\theta$, I get the wrong value of $\theta$ as we've been provided with the value of sin $\theta$ as well...
Comment: Why duplicating your question of yesterday:  http://math.stackexchange.com/questions/929151/find-out-theta-when-sin-thetas-and-cos-thetas-value-are-given  ?
Comment: @ChristianBlatter Sorry, no idea why I did that!
Comment: any help here, if you can, will be really appreciated: http://chemistry.stackexchange.com/questions/16259/how-does-k2cr2o7-become-cr2o7-2
Answer: $$\sin\theta=\frac{\sqrt3}2=\sin\frac\pi3\implies\theta=n\pi+(-1)^n\frac\pi3$$
where $n$ is any integer
Set $n=2s+1,$(odd) $=2s$(even) one by one
Again,
$$\cos\theta=-\frac12=-\cos\frac\pi3=\cos\left(\pi-\frac\pi3\right)$$
$$\implies\theta=2m\pi\pm\left(\pi-\frac\pi3\right)$$
where $m$ is any integer
Check for '+','-' one by one
Observe that the intersection of the above two solutions is $$\theta=2r\pi+\frac{2\pi}3$$
where $r$ is any integer
Answer: The given data determine $\theta$ up to an additive multiple of $2\pi$. When $\cos\theta\ne-1$ the principal value $\theta\in\ ]{-\pi},\pi[\ $  can be found using the formula
$$\tan{\theta\over2}={\sin\theta\over 1+\cos\theta}\ ,$$
which leads to
$$\theta=2\arctan{\sin\theta\over 1+\cos\theta}\ .$$
In your example we get
$$\theta=2\arctan{{\sqrt{3}\over2}\over 1-{1\over2}}=2\arctan\sqrt{3}={2\pi\over3}\ .$$


derivation of oblique asymptote for irrational functions

Question: I understand that we can use limits to get the OA for irrational functions, but I would like to know how we were able to reach the following:
$y=ax+b$---> equation of OA
$a=\lim f(x)/x$ as $x$ tends to infinity
and $b=\lim f(x)-ax$ as $x$ tends to infinity
How did they get to those two formulas?
Comment: What is an irrational function?
Comment: @AlexM., one that's not rational (a ratio of two polynomials).
Answer: Hint: an oblique asymptote is a line $y=ax+b$ to which $f(x)$ gets arbitrarily close as $x \to \infty$: $$\lim_{x \to \infty} \,f(x) - (ax + b) \, = 0$$
Dividing by $x$ gives $a = \lim_{x \to \infty} \frac{f(x)}{x}$ then replacing in the above $b = \lim_{x \to \infty} \,f(x) - ax$.
Answer: These are usually taken as the definition of an oblique asymptote, not something that you can derive.
The motivation is that, to say that the graph of $y = f(x)$ has an oblique asymptote, you want to say that the graph of $y = f(x)$ "looks like" a line for $x$ large.  Hopefully it makes sense to require that the slope $f(x)/x$ of the line connecting the origin to a point $(x, y) = (x, f(x))$ on the graph of $y = f(x)$ should tend to the slope of its oblique asymptote.  However, this by itself isn't enough to pin down the exact asymptote, only its slope.  We need an additional piece of information, such as its $y$-intercept.  If you know any point $(x, y)$ on a line of slope $a$, then you can recover the $y$-intercept of the line as $b = y - a x$.  If you only know that your graph is close to a line, then you don't expect $y - a x = f(x) - a x$ to give you the exact answer, only to tend to it as $x$ becomes large; and that is why we put $b = \lim_{x \to \infty} f(x) - a x$.


Using now or block.timestamp

Question: If using 'now' or 'block.timestamp' is considering security risks (miner manipulation) how should I go about current timestamp in my code? Isn't it safe to use either of the two as long as it is not used for randomness?
Comment: What is the use case for the timestamp? It's guaranteed to be roughly accurate, on the order of hours, but certainly don't use it for precise timings
Comment: For example in an ICO, where you would want to check and adjust bonuses based on specifc timestamps.
Answer: As long as you are not basing some critical/time-sensitive logic on block.timestamp you should be ok.
For an ICO that adjusts the bonuses on different timestamps, it shouldn't be a problem. The worst case scenario would be someone investing a few hours after some deadline getting the bonus of the previous tier.
Using now / block.timestamp is a concern when the logic is based on perfectly timing an action.
Comment: One could manipulate the `block.timestamp` to get all bonuses earlier than at a right time. Why do you think this is not a concern? Like in the tip model when user is allowed to withdraw money only in tranches.

Using now or block.timestamp


Does this question belong in stack exchange physics or philosophy?

Question: I recently had a question which I wasn't sure if this would be the correct site for as it seemed too speculative. But by the time I completed it, it seemed, more concrete than I'd imagined. I would like a second opinion of which site it belongs to before I post it (and delete the other as cross posting is not allowed)?
https://philosophy.stackexchange.com/q/47140/
Answer: Your question probably would belong on physics.SE, if it wasn't ill-posed and unclear:

The "state reduction" or collapse of the wavefunction is a feature of certain interpretations of quantum mechanics, and there exist interpretations that explain the results of measurements other than with collapse. Failure to mention this when talking about modifications of quantum mechanics indicates prior research is lacking here, and makes it unclear what you mean by "modifying R" when R is not even present in all interpretations.
It is unclear what you mean by "It seems to me everyone in the physics community has been working on modifying U". The large majority of the physics community accepts conventional quantum mechanics as correct and does not work to change it at all.

For these reasons, I would close your question as unclear what you're asking regardless of its on-topicness otherwise.
Comment: To address you points perhaps if I wrote:
1."The jumping of the quantum state to one of the eigenstates of Q is the process referred to as state-vector reduction or collapse of the wavefunction" where Q is a observable
2.What I mean't by modifying U is one seems to only be concerned about the evolution of the wave function rather than the state reduction .
Would have been better?
Comment: The question [has been posted](https://physics.stackexchange.com/q/368515/124). I agree with ACM's position and accordingly I've put it on hold until it's clarified.


Cox Regression - IVs have different hazard ratios when modelled alone than all together

Question: I'm currently running a Cox proportional hazards analysis on my data to look at outcomes for cancer survival. I'm looking at variables such as cancer type, martial status, gender etc. For some reason when I put in all of these variables together in the SPSS model, I get different hazard ratios than when I put them in separately. Does anyone who know is the reason for this? Am I missing something basic?
Comment: Do you mean that in models with each variable by itself, their coefficients are different than when all of them are used together?
Comment: Yes! For example, if I put in stuff like gender and martial status and different treatment together in the model, I'll get difference Exp(B)s and CIs as opposed to when I do them all separately in SPSS. Is there a reason for that/am I missing something basic?
Answer: As with any type of regression, using multiple explanatory variables has several advantages over simple (single-var) models, besides being able to see them all together. Chief among these is the concept of control. When a single variable ($x$) is used, the coefficient is the effect (relationship, hazard ratio etc..) on the dependent variable ($y$). But relationships between two variables can be more complex than they appear. The relationship can be augmented by the existence of other variables ($x_i$), and this can be modeled and discovered using multiple covariates in the same model.
An a known, if silly example, a relationship between ice-cream sale and murder-rate is high (i.e. the coefficient is highly significant). This, however, is obviously bogus. There is a secondary variable that is in play here - weather. Hot weather increases both murders and ice-cream sales. In this case, weather is a confounder to the relationship between ice-cream sales and murder rates. For an overview of different types of such external influences (confounders, mediators, moderators).
So, using extra variables in the model can often reveal the true relationships between a certain $x$ and a $y$. If, in a simple model, the coefficient of $x_1$ was $\beta_1$ and adding a second variable $x_2$ caused $\beta_1$ to increase in size (in absolute value), than the newly added $x_2$ is the reason for that change, and is likely moderating the relationship. If $\beta_1$ decreased (in absolute value), than $x_2$ is likely a confounder or a mediator.
As a more visual example of this, I'll use a part of an answer I gave to a different question:
Following are two linear regression models (same idea applies to Cox PH) - the first with one explanatory variable (number of friends) used to predict happiness:
<code>             Estimate Std. Error t value Pr(>|t|)
(Intercept)   15.105     14.697   1.028   0.3341
friends        4.580      2.236   2.048   0.0747 .
</code>
The second is the same model, with an added country (japan or china):
<code>            Estimate Std. Error t value Pr(>|t|)
(Intercept)   -9.079     13.541  -0.670  0.52406
friends       11.382      2.861   3.978  0.00534 **
country      -35.974     12.484  -2.881  0.02360 *
</code>
Note the change in $\beta_{friends}$ from 4.5 to 11.38. The addition of $x_{country}$ caused this. Why? Lets look at the graphs of the first and second models (first on the left):

When controlling for country, the effect ($\beta_{friends}$) grew.
At any rate, it is very common for coefficients to change when adding related variables to the model. Do not worry, your model is likely better off.


Create Unresolved Tasks/Contacts/etc through the REST API?

Question: Is this possible? I have found a few results googling this, but only of people asking the question, never answering it.
Comment: Something that shows up in the My Unresolved Items section.
Comment: what defines an 'unresolved'record?
Answer: Interesting question, I cannot find any reference to unresolved in the apex language reference guide, there is nothing useful online that I can find either apart from a way to query unresolved tasks (subject name LIKE '%Unresolved'). People have stated that even cloning those records doesn't work in terms as marking unresolved. My best guess is that a hidden field manages it and salesforce restrict access for whatever reason. Maybe raise a case to support / start an idea to open up access to that functionality.
// Link to unresolved items for those that have not seen it.
https://help.salesforce.com/apex/HTViewHelpDoc?id=outlookcrm_unresolved_items.htm&language=en
Comment: Damn. This is the conclusion I had reached as well. Was hoping someone had access to some arcane lore that I wasn't privy to.


substituting combo amp for speaker

Question: I am thinking of buying a Fender Super Champ amp, but it's only 15 watts. This is fine when I am micing the amp but may not be enough power for a larger venue unmiced. I figure I could always plug into a speaker cabinet for a little extra volume but couldn't I just plug into a 2nd backup guitar amp? The Fender Champ is 8 ohms and has an output jack. I've been told I could plug into an 8 ohm or 4 ohm speaker, but why not just use either an 8 ohm or 4 ohm combo amp that I already have instead of buying a speaker?
Comment: I've read this 3 times, and still can't work out what the question is!
Answer: Here is what I have found through trial and error:
The Super Champ, while an amazing amp, is under-powered for live performance. The easy solution is to mic the amp,but that is not always an option.
My Super Champ is the XD Model.
There are two outputs on the back
(1) speaker out. Should be currently connected to the internal speaker. You can use this to substitute the internal speaker for a different speaker cabinet(like a 2x10 or 1x15 or whatever cab does it for you). In most cases you will not get more volume, just a change to your sound. Keep in mind plugging in the new speaker turns off the old one. You want to make sure your new speaker cab is the same impedance as well.
(2) The other output, the line-out is going to be the better solution for you.  This is NOT a speaker out, this is line-level out. You can send this to a direct box and into the PA, you can send this to a powered speaker (like a powered PA speaker) or to a 2nd amp. If you plug a non powered speaker into this you will get....nothing.
In this scenario, Super Champ internal speaker DOES stay on and produces full sound. You are running the Super Champ plus whatever secondary device as well. You will get much more volume from this, depending on how powerful the secondary source is.
If you send line-level to  a 2nd amp, be VERY careful about the levels out and levels in. If you crank the Super Champ the 2nd amp is getting too much signal. You should be able to balance the two in a way that makes sense.
The line out was built for recording and for running sound to the PA without needed to mic the amp, but keep in mind that the line out sound does not utilize the tube in the amp, so it can be less warm and tube sounding.
Personally, I've found this amp, with the line out going to a powered speaker, PA or second amp all work well and make this amp sound fuller (more hifi). I have used all three options in a live band setting with good results.
Answer: One trick I have seen used to get louder when you have two amps available and one of the amps has two input jacks on one channel as many Fender models do, is to plug your instrument into one of the input jacks and plug a patch cable into the other input jack, and then plug the other end of the patch cable into the input on the second amp. This allows adjustable volume and tone on each amp and increases power output level at the same time. Hendrix, Clapton, Leslie West and others took this technique to an extreme with their Marshall stacks in the late 60's and early 70's.
Answer: Connecting another speaker won't necessarily make your amp sound louder. It's possible  that the placement of an extension speaker closer to the audience will make it sound louder (because of its proximity to their ears) but you don't get something for nothing.
What you need is a 'line out' socket on your amp so you can run it to the input of your second amp. Running from a speaker output to the input of a second amp is asking for distortion, and I suspect that electronically-literate contributors are queuing up to explain why.
Comment: running from the speaker out of one amp into the instrument input of another amp will damage the second amp.

substituting combo amp for speaker