Inhibit screensaver with Python

Question: What's the better cross-DE way to disable the screensaver in Linux? I found something here but it's only for gnome-screensaver. I'm wondering if there's any way to simulate a keystroke or some X.Org API to disable screensaver activation.
Comment: I wouldn't simulate keystrokes. There are only about three or four screensaver packages to begin with, so just find their DBus interfaces (if they exist) and tell them to turn off.
Comment: possibly http://stackoverflow.com/questions/2575528/simulating-key-press-event-using-python-for-linux
Comment: @Blender But his software will break as soon as someone writes a new screensaver. You're also forgetting about stuff like xfce4-power-manager, which dims the screen (it's not a screensaver itself, but I'm pretty sure that his intetiont is to inhibit that as well).
Answer: I have been looking into this a while ago and finally ended up using xdg-screensaver which I call via subprocess.
import subprocess

def suspend_screensaver():
    window_id = subprocess.Popen('xwininfo -root | grep xwininfo | cut -d" " -f4', stdout=subprocess.PIPE, shell=True).stdout.read().strip()

    #run xdg-screensaver on root window
    subprocess.call(['xdg-screensaver', 'suspend', window_id])

def resume_screensaver(window_id):
    subprocess.Popen('xdg-screensaver resume ' + window_id, shell=True)

This is not ideal but apparently there is no other solution that would not involve messing around with DE-specific stuff like dbus or gnome-screensaver-command.
I don't really like the call to xwininfo and wish there was a cleaner way but so far could not find anything better. Another issue with the xwininfo approach is that it uses the id of the root window instead of the app window. Using the app window id instead of the root window would remove the need for the resume_screensaver method since it would then resume as soon as the window is destroyed.
And if you want to simulate keystrokes here is a naive bash script I have been using for some time. It does require xdotool which has to be installed separately.
#!/bin/bash
while :
do
   sleep 200
   nice -n 1 xdotool key shift
   echo .
done

UPDATE
After having used the python solution above for over a year, it was found to occasionally create zombie processes and/or too many instances of xdg-screensaver, so after digging around, I found a simpler alternative which is Gnome-specific, but works for me even in a non-Gnome DE (XFCE) since the core Gnome libraries are required by many GTK-based apps even if you don't have a Gnome desktop.
import subprocess

def suspend_screensaver():
    'suspend linux screensaver'
    proc = subprocess.Popen('gsettings set org.gnome.desktop.screensaver idle-activation-enabled false', shell=True)
    proc.wait()

def resume_screensaver():
    'resume linux screensaver'
    proc = subprocess.Popen('gsettings set org.gnome.desktop.screensaver idle-activation-enabled true', shell=True)
    proc.wait()

Comment: I really like the `xdotool`-based solution. I find that xdg-screensaver is a bunch of hacks dumped into a single poorly-designed script, while sending fake keypresses actually makes way more sense (since there's no standard way to do it).
Comment: @Hugo: I have indeed found some issues with `xdg-screensaver` and have replaced a while ago the code in my app with another solution which I have added to the original answer.
Comment: That doesn't disable screen blanking, either by dpms, or xfce4-power-manager, regrettably.
Comment: @Hugo: most likely, you are using `xscreensaver` which is the default in xfce. I removed it, and replaced with `gnome-screensaver` and that's why it works for me. It has a much cleaner and aesthetically pleasing look but may also pull extra dependencies.
Comment: No, I'm quite cleary **not** using xscreensaver, since I very cleary stated I'm using `xfce4-power-manager` for screen blanking (dimming, then blanking, actually). `xscreensaver` is way too much bloat in comparison, and `gnome-screensaver` is even worse.
Comment: Then you might have luck with something along the lines of `xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/inactivity-on-ac -n -t uint -s 0`,  `xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/inactivity-on-battery -n -t uint -s 0` *or* `xset -dpms && xset s noblank && xset s off`. Have not tried either.
Comment: @Hugo As ccpizza mentioned, if you are using XFCE then you can use `xset -dpms; xset s off` to disable the screensaver then `xset +dpms; xset s default` to enable it. That is exactly what xdg-screensaver would be doing (without all the crud).
Answer: I know this question is old, but there is a more modern answer to it: now most DE on linux use dbus to communicate, and you can use this:
in shell, using kde tools:
qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.Inhibit "myapps" "because I want it"

this dbus call will return a cookie (a number) that will be needed to uninhibit the screesaver:
qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.UnInhibit $COOKIE

In python, it will be something like
import dbus

bus = dbus.SessionBus()
saver = bus.get_object('org.freedesktop.ScreenSaver', '/ScreenSaver')
saver_interface = dbus.Interface(saver, dbus_interface='org.freedesktop.ScreenSaver')

# now we can inhibit the screensaver
cookie=saver_interface.Inhibit("myapps", "because I want it")

# we can also restore it
saver_interface.UnInhibit(cookie)

Comment: Yeah, now you can even inhibit power management with dbus. Things have changed since I asked this question.
Answer: Discussion
TLDR; there aren't any cross-DE ways to inhibit the screensaver with pure Python. However the question also asked about doing so with Linux (presumably from the shell). To be clear, there aren't any particularly good cross-DE ways to do so in Linux, but at least there is potential. You probably want to use the hackish xdg-screensaver shell script.
This is a topic I've spent some time on. I wasn't happy with any of the solutions out there, so after playing around with some homebrew tools, I ended up modifying the caffeine project to suit my needs and have been using it happily ever since. I'll summarize some of what I've learned in the process.
In case you aren't familiar with it, I'd recommend checking out caffeine (Launchpad PPA @ https://launchpad.net/~caffeine-developers/+archive/ubuntu/ppa).
The caffeine project mostly consists of the following scripts: caffeine-screensaver caffeine caffeine-indicator caffeinate
caffeine and caffeine-indicator are written in Python 3 whereas caffeine-screensaver is a rebranded xdg-screensaver written in shell script.
The first half of ccpizza's answer is great as it is cross-DE and very similar to caffeine's implementation. I haven't had any issues with xdg-screensaver zombie processes but I'm sure it could be remedied if I better knew the use-case or the conditions under which it was occurring. Just a FYI that running xdg-screensaver suspend ROOT_WINDOW_ID will background a tracking process and leave it running indefinitely (until it is resumed).
If you're interested in implementing a truly cross-DE solution then I would strongly recommend examining the aforementioned xdg-screensaver/caffeine-screensaver. The many forks of lightsOn are ripe as well.
xdg-screensaver detects the desktop environment (KDE, Gnome, XFCE, LXDE, xscreensaver, or gnome-screensaver) and acts accordingly. For the xdg-screensaver suspend command, it runs xset -dpms to disable DPMS, DE-specific commands, then watches the supplied window ID for it's duration. If the window disappears, the resume command is run and xdg-screensaver exits. The xdg-screensaver resume command consists of xset +dpms (only if DPMS was originally enabled) then the DE-specific commands.
Note that xdg-screensaver will only track the supplied window ID if xprop is available (it's part of x11-utils, so it should be). To track the window, it backgrounds xprop -id WINDOW_ID -spy to monitor the window for changes. It stores the PID of the aforemention process along with window ID in a lockfile to reference upon suspend and resume. The original state of DPMS is referenced in a separate lockfile. The lockfiles should ensure there are no duplicate processes.
The script is a complete mess, so I empathize with anyone unfortunate enough to use it, but I haven't encountered any issues. You probably don't want to reinvent the wheel so if you are creating something for public consumption then I'd recommend you just co-opt it. If you're creating something for personal use, then just dig through it and use the commands specific to your DE.
ccpizza suggesting using subprocess.Popen('xwininfo -root | grep xwininfo | cut -d" " -f4', stdout=subprocess.PIPE, shell=True).stdout.read().strip() to get the desktop's root window ID. Using the desktop's root window ID with xdg-screensaver suspend will disable the desktop's screensaver indefinitely. Using a specific window's ID will disable the desktop's screensaver for the duration of the window.

Shell Script
To determine the active window ID, you can run the following:
xprop -root _NET_ACTIVE_WINDOW | awk -F '[ ,]' '{print $5}'

To determine the root window ID, you can run the following:
xwininfo -root | awk '/^xwininfo: Window id: / {print $4}'

To determine the screensaver timeout, you can run the following:
xset q | awk '/^  timeout: / {print $2}'

NOTE: the result will be 0 if the screensaver is disabled
To determine whether DPMS is enabled or disabled, you can run the following:
xset q | awk '/^  DPMS is / {print tolower($3)}'

Python Script
There are pure Python options as well. The Xlib module is great for this, as is ewmh (which is a wrapper around Xlib).
To determine the active window ID with ewmh:
active_id = hex(ewmh.EWMH().getActiveWindow().id)

To determine the root window ID with ewmh:
root_id = hex(ewmh.EWMH().root.id)

To determine the active window ID with Xlib:
from Xlib.display import Display
from Xlib.X import AnyPropertyType

active_id = hex(Display().screen().root.get_full_property(Display().get_atom('_NET_ACTIVE_WINDOW'), AnyPropertyType).value[0])

To determine the root window ID with Xlib:
from Xlib.display import Display
root_id = hex(Display().screen().root.id)

To determine the screensaver timeout with Xlib:
from Xlib.display import Display
timeout = Display().get_screen_saver().timeout

Inhibit screensaver with Python


Baby intermitant squint - Can an orthoptic assessment be done for a baby aged 1 year 3 months

Question: Baby aged 1 year 3 months seems to have an intermittent squint, especially when he looks far away up. Can an orthoptic assessment be done for a baby aged 1 year 3 months who has intermittent squint? Or should the parent wait until the child is at least four years old?
Answer: As soon as someone (often a preschool teacher or parent) notices what may be a vision problem, a screening exam should be scheduled. Interestingly, a child need not be verbal yet to be assessed; at your child's age, computerized photoscreeners and autorefractors can use light and cameras to gauge how well your child can see.
While certain eye problems (or neurological problems affecting the eyes) can be assessed from birth on (your child's health care provider does this at each visit whether they explain what they're doing or not), visual acuity itself can't be assessed accurately by your HCP before the child is fairly verbal. A referral to an optometrist or opthalmologist should be provided on request. If a visual acuity problem is detected, the proper corrective lenses will be prescribed.
Vision Screenings for Babies & Children
Comment: if you add that some issues can be corrected if detected early enough so an examination does make sense, I would delete my answer as yours is more on point
Comment: @Lehue - I think your answer is as valuable as mine, and you've stated the benefits well.
Answer: There is a comparably new testing device for infant's eyes that just needs to be pointed to the eyes and creates a complete analysis of the eyes in seconds. The one my paediatrician used is called plusoptix, I don't know if there are other devices like that available. Try asking your paediatrician about this test.
If the test shows abnormal results, it may be possible to treat the visual defect with glasses, which may reduce it over time if administered early enough.
In Germany, you need to pay for this test yourself, about 20€.


Can bytes32 be changed to a string in solidity?

Question: I was wondering if it is possible to convert a bytes32 to a string in solidity like this,
I want an input bytes32 input = 0x74657374
and an output of string output = "0x74657374"
Answer: Yes, but you wouldn't want to do that normally.
Generally, don't burden a contract with a client's job. It isn't especially easy to do because bytes and string are variable length and therefore require setting aside a word for length. The length of bytes32 requires no such extra internal organization.
Have a look over here: How to convert bytes32 to string?
Hope it helps.


How to unmount and then safely remove USB in windows?

Question: I have three WD external drives and I use WD Quick View to detach HDDs when I need to. What it does is, it finishes operations/flushes the drive, powers down the disk (stops the rotations), the LED goes off, and Windows chimes the drive removal sound. Essentially, the WD QV, stops power to the USB port. Is there any way one can do this to all the USB ports for flash/HD Drives?
Answer: You want to find the "Safely Remove Hardware" icon in the system tray, and when clicked it will provide a menu allowing you to eject individual devices:

(Source)
In versions prior to Windows 10, the icon appeared as a USB plug with a green checkmark.
You can also right-click on a removable drive in Windows Explorer and select "Eject" from the menu:
Comment: It's up to the drive to decide what to do when ejected. Windows has no business with that. Most USB hard drives would indeed power down when ejected. A USB port *cannot* be switched off.
Comment: @Dr.UrvishMistry I'm confused; Your question asks how to safely unmount and remove any USB mass storage device, to which I believe I have provided the answer. If you feel a specific detail was not addressed, please specify which detail as I read the question thoroughly the first time, and re-reading it has turned up no new information.
Comment: I request you to read the details of the question. I know what you have illustrated and that is NOT what I am asking for,
Comment: As I have mentioned in the Question Details, I want the drive to power down before ejection, like it does with WD Quick View. The default Windows ejection system does not power down the drive. It just simply unmount it. The drive still spins and LED remain on when ejected with Windows. While WD QV, it stops the power to USB port, the drive stops spinning. LED goes off. So, is there ANY way I can achieve this with thumb drive or other HDDs?
Comment: No. Maybe if you wrote a custom program, but other than that, not really, no. I'm not sure why you would want to actually power-down a thumb drive before removal, and while it's not the same as a full power-down, Windows will retract the heads and spin down the platters on a conventional HDD when it's ejected and there's nothing reading from it (even if it's still plugged into the USB port).
Comment: Okay. Windows MAY be retracting heads, but does not spin down the platter. Why I need this? Because I have an old WD Elements, which is not supported by WD Quick View.
Answer: I don't have enough reputation to comment, so I am just going to make an answer.
You can use USB Safely Remove, as it seems to have the functionality you are requesting like powering off USB flash drives and HDDs. Why you would need this for flash drives is beyond me, maybe you can enlighten me.


daemonize rtorrent

Question: Just read the man page, but found no option for this. Maybe I missed it, maybe it doesn't exist.
I have a server at home I'm SSHing to for rtorrent, but the torrent stops downloading and won't restart on rtorrent restart, so is there a way I can daemonize so I don't have to sit there and watch it?
(if this is relevant, rtorrent is running on a fresh FreeBSD 9.1 install)
Answer: You can run rtorrent in a screen or tmux session so that it will continue running even after you've disconnected.
The apps screen and tmux are terminal multiplexers which allow you to leave long running terminal tasks alone so that they can run uninterrupted.
Example
You can use screen for example, like so:
$ screen -S rtor_sess

This will give you a screen session named rtor_sess. From within it you can now run your rtorrent tasks, when you're done starting them up or checking in on them you can disconnect from the screen session with the key combination Control+A+D. Remember: (Attention + Disconnect).
After some time has passed and you want to peek in on your rtorrent task, you can SSH back into the system where you're screen session was started and do the following commands to see your sessions:
$ screen -ls
There are screens on:
    1506.bp (Detached)
    2335.rtorr_sess (Detached)
    32090.dl    (Detached)
3 Sockets in /var/run/screen/S-root.

Here you can see that I have 3 sessions. So let's reconnect to our rtorr_sess session:
$ screen -r rtorr_sess

Again to disconnect use the same key combination we used before to disconnect. When you're done you simply exit out of the session to destroy it.
Answer: rtorrent does not have the ability to daemonise itself. But you can use an
additional tool for that. For example dtach, screen or tmux. Here is an
example of how to create an rtorrent session in tmux.
tmux new-session -s rtorrent -d rtorrent

This creates a session named "rtorrent", starts the torrent client and
detaches. You can now log out and rtorrent keeps running. Next time you log in,
you can reattach to the session and bring rtorrent to the foreground using
tmux attach-session -t rtorrent

Comment: ok, it takes the command, but doesn't let me see any trace of the rtorrent menu, which I need to start anything. How do I fix this?
Comment: oh sorry nevermind

daemonize rtorrent


Energy, time and force

Question: Consider force $F$ acting on a body of mass 1000kg and the displacement  be $s$. So energy required to do so is $F$x $s$. Now consider the same force causing same displacement on body of mass 1kg. Here to energy required(according to equation) is same. But certainly more energy is required in the first case. How is this possible? Does it mean that no more energy is needed for prolonged application of force? This is the main reason I don't understand why work/energy is force times displacement .Instead force times time makes more sense to me.
Answer: The force is only applied for that distance, the fact that it is the same implies that the smaller object will have lower speed. Note that the relation does not imply the distance the object will move; instead, the displacement is the distance over which the force is applied.
$$Fs=\frac{1}{2}mv^2$$
Hence, because the objects have the same energy but the mass of one is greater, they will have different velocities. This is where your energy "gap" comes in. But no more energy is required for the first compared to the second.
Your understanding of the fact that the first case needs more energy is flawed: they both need the same. In fact, the second case would need more power, because the time it takes is less. Keep in mind that work is the useful work done, and thus inefficiency is not accounted for.
Answer: When I was in high school, my teacher would use a mouse and an elephant for this kind of problem. Let us put a mouse and an elephant on ice skates.
You push the elephant, whose mass is $m_e$, with force $f$. The elephant slowly accelerates. You keep pushing until it eventually moves a distance $s$. By this time, the elephant is slowly moving at velocity $v_e$.
You push mouse, mass $m_m$, with the same force. The mouse quickly accelerates, and quickly reaches a distance $s$. The mouse is moving quickly with velocity $v_m$.
You did the same work on both, so both have the same kinetic energy.
$fs = \frac{1}2 m_e v_e^2 = \frac{1}2 m_m v_m^2$
Answer: You have to realize that the two bodies will reach a different final speed. Both will have the same kinetic energy (equal to the work of the force), but the larger one will have a considerably smaller speed.

Energy, time and force


Antonym of "a picture is worth a thousand words"

Question: I need a title for my essay that is saying that works of words are better than pictures. I was thinking of "a picture is worth a thousand words", but that advocates pictures, not words.
Comment: "You can't draw a picture of courage"
Comment: [Always label your axes](http://xkcd.com/833/).
Comment: Well, I have seen expressions along the lines of "A word that's worth a thousand pictures", but it would only work in very limited contexts.
Comment: @Lawrence's is
Comment: *A word is worth a thousand pictures.*
Comment: the pen is mightier than the brush
Comment: or just simply 'pictures suck'
Comment: or go for the irony of it all : https://wordart.com/
Comment: what did you come up with eventually as a title, pray tell?
Answer: I'm not sure whether it fully fits your essay, but the phrase

The book is always better (than the movie)1

referring to film adaptations versus the books they're based on, gets a fair amount of usage. There are t-shirts, memes, many blog posts, etc. To some extent, the first half has also become a stand-alone phrase, as in the article "10 reasons why books are always better than boys".
Of course this phrase contrasts books with the films that are based on those books. Since books are made up of many words in a particular sequence and films consist largely of many pictures in a particular sequence (and are even sometimes called moving pictures), I think the analogy is fairly clear and the phrase could work for you.
There is even some use of these two phrases in contrast with one another, in the form of the question "If a picture is worth a thousand words, why is the book always better than the movie?" It's been asked on Yahoo Answers, there is at least one meme out there, and it's apparently the slogan of a copywriting company, to link to a few examples.

1 The phrase the book was better is probably more common, but the more extreme version seems to suit your purposes better. However, if you wanted to hedge your bets, you could use The book is (almost) always better or you could use The book was better: with an appropriate sub-title.
Answer: As Ben Franklin said,

A word to the wise is sufficient.

This doesn't reverse the word/picture mechanism of the OP's idiom, but nothing really does. What it does is express the value of a terse, cogent expression in bringing about enlightenment.
Interesting discussion of the origins of the phrase, as well as some parallels, found in blog entry Benjamin Franklin: Talmudist.
By the way, the full rendering of Franklin's phrase is:

A word to the wise is enough, and many words won't fill a bushel.
Answer: It would be nice to know more about the essay but 'It is better to tell than to show' comes to mind off the top of my head.
Comment: The idiom goes the other way.
Answer: 1001 words is worth more than a picture.
Comment: This phrase isn't idiomatic.


How to obtain the standard gene name

Question: I have a list of genes and proteins extracted from literature. How can I convert them into standard gene names.
Comment: It would be helpful to have some example of the gene/protein names that you extracted so solutions can more easily be checked for validity.
Comment: Please define "standard gene names", do you mean gene symbols?
Comment: Please [edit] your question and: i) give us a few examples of the various name formats you have, ii) show us the output you would want from those names (do you want gene name? Gene symbol? From what database? GI accession? RefSeq? Ensembl? The human name from HUGO?). What do you consider a "standard" gene name? And in what species?
Answer: Gene name
Using an Ensembl ID, Uniprot ID or NCBI ID it is much easier to look up your gene. So I would strongly reccomend using one of those as a key. Personally, I'd use Uniprot, but Ensembl is probably better if your genes are human.
One reason for this is also that different resources will use different names, especially for humans.
There are a few considerations, so I will first say how this could be done properly...
Custom Uniprot matcher with weights
Some names are used by different protein, so which one is which would depend on context, co-occurrence with another gene.
Your dataset might be extremely noisy. Therefore, you likely have assigned a confidence score to your matches, yes? It would be nice to give a score to the name based on whether it is the first name of the protein or the fourth synonym in the list.
Therefore to do a conversion properly you really ought to make your own conversion system based upon context and Uniprot data. Uniprot contains the most data on synonyms and notes and binding partners etc. The dataset/API is in XML and Biopython does not have a parser, but I have some notes on the matter and can share some code if needed as I have done something similar (e.g. JSON for human gene/protein names to Uniprot IDs).
Lazy match
The NCBI entrez API is rather flexible and good at presenting to you matches for a strange names. So I would suggest using that.
Answer: If you have a list of human gene names from various sources that may include old or alternative names, then I'd suggest using the HUGO database (www.genenames.org). From there you can get a table of approved names and symbols as well as alternative symbols* . With this you can search for your gene names in the table and assign the approved name.
I wouldn't use  Ensembl ID as some genes have multiple IDs that indicate the haplotype of the source genome, which is probably not useful for most purposes.
*Names are the full description of the protein, e.g. "B-Raf proto-oncogene, serine/threonine kinase" whereas the symbol is the short version you usually see, e.g "BRAF"
Answer: bioDBnet might have what you're looking for if the gene name is in standard format
https://biodbnet-abcc.ncifcrf.gov/db/db2db.php
For proteins Uniprot can be used to look up a protein and find it's information
https://www.uniprot.org/

How to obtain the standard gene name


Connected socket information

Question: Hallo, how it is possible to get information form connected socket. I need to get address of server, the socket is connected to and port. Is this possible to get?
I need to figure it out in WSPSend, to block it or not. So i cant remember it form previous actions(like socket(),connect() etc..)
thx.
Answer: getpeername

Connected socket information


Pre-existing shared memory block (key 5432001, ID 32768) is still in use

Question: I have been seeing this error lately that is causing the server to crash all of a sudden. I have seen elsewhere that the solution is to delete the postmaster.pid and postmaster.opts files and restart the server, but no one has explained why this event happens, and how to stop it from happening again.
Comment: What operating system and version are you on? Do you ever manually kill postgres processes or have a cron job that does it? **Never** delete `postmaster.pid`, you risk severe database corruption.
Comment: It's a Docker container running on Ubuntu Trusty. The database shares a volume with the host to store its data. What you said about killing postgres processes reminded me that I have killed the container a couple of times. What would be the right thing to do?
Answer: It's vital that if you forcibly terminate PostgreSQL then all postgres processes must be killed. If you don't terminate them all then the shared memory block may still be held and the database files may still be open and being written to. In this case starting PostgreSQL again may cause massive database corruption, which is why PostgreSQL tries to stop you doing this. Overriding those safety measures may cause data loss.
You should preferably cleanly stop PostgreSQL with pg_ctl as part of the container shutdown process.
In any case, it's very important that stopping the container terminates all postgres processes.
You should not delete postmaster.pid, it's protecting you from data corruption by allowing PostgreSQL to notice that the shared memory segment is still in use. Unless Docker somehow gets in the way of this process.
Comment: Thank you! I think restarting the container after killing it was not bringing up the server, which is why I removed the pid file. But from now on I will always shutdown the containers gracefully.


Can someone with the Holy Magic Ability and Virtue learn Miraculous effects (Methods and Powers)?

Question: Page 67 and 69 of Ars Magica Realms of Power: The Divine describe that one of the benefits of using Holy Magic is the use of the Holy Power guidelines. Does this mean they can gain the Miraculous effect abilities from pages 45 to 56?
Answer: According to Realms of Power: The Divine page 47, True Faith functions like the gift in that you can learn divine supernatural abilities with it, but says nothing about the Gift being able to do so. Because of this, you would need True Faith to learn Methods and Powers. The same page also says that Holy Traditions can initiate it's members into the Method and Power virtues with rules described in pages 13-16 of The Mysteries.


3D print toolbox is missing from Add Ons

Question: I'm new to 3D printing and I would like to use blender to generate some simple models. I've used it before, but I am still a novice. The first thing every instruction set mentions when trying to make 3D printable models is to make sure that the 3D Print Toolbox is installed. I've gone to Edit->Preferences->Add Ons and searched for this, but nothing with that name appears. I have heard that it is supposed to be included with Blender 3+ and I'm running version 3.4.1 on Ubuntu Mate 22.04.
Comment: I saw already asked this question by Ubuntu user ... I can't find it to mark as duplicate ... same as @GordonBrinkmann on Windows ... my Mac version includes the addon.
Answer: I don't know about Ubuntu, but in Windows it is there. How exactly are you searching for it? It is found under Mesh: 3D-Print Toolbox. If you are entering "3d" in the search field for example it should appear. Also with "3d-print", but if you search for "3d print" without hyphen as you wrote it in your question, it will not show up.


Is there any way to set environment variables in Visual Studio Code?

Question: How can I set up environment variables in Visual Studio Code?
Comment: I used this command  in VS terminal(project roort folder) for Node.js app: ```$env:NODE_ENV='development'``` or ```$env:NODE_ENV='test'```
Comment: Take a look here https://stackoverflow.com/a/70748562/3223785 .
Answer: Assuming you mean for a debugging session(?) then you can include a env property in your launch configuration.
If you open the .vscode/launch.json file in your workspace or select Debug > Open Configurations then you should see a set of launch configurations for debugging your code. You can then add to it an env property with a dictionary of string:string.
Here is an example for an ASP.NET Core app from their standard web template setting the ASPNETCORE_ENVIRONMENT to Development :
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": ".NET Core Launch (web)",
      "type": "coreclr",
      "request": "launch",
      "preLaunchTask": "build",
      // If you have changed target frameworks, make sure to update the program path.
      "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/vscode-env.dll",
      "args": [],
      "cwd": "${workspaceFolder}",
      "stopAtEntry": false,
      "internalConsoleOptions": "openOnSessionStart",
      "launchBrowser": {
        "enabled": true,
        "args": "${auto-detect-url}",
        "windows": {
          "command": "cmd.exe",
          "args": "/C start ${auto-detect-url}"
        },
        "osx": {
          "command": "open"
        },
        "linux": {
          "command": "xdg-open"
        }
      },
      "env": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "sourceFileMap": {
        "/Views": "${workspaceFolder}/Views"
      }
    },
    {
      "name": ".NET Core Attach",
      "type": "coreclr",
      "request": "attach",
      "processId": "${command:pickProcess}"
    }
  ]
}

Comment: Thanks for your answer. I'm working on a node application and there using some environment variable like as process.env.VAR_NAME, I want the variables when running the project. Is the configuration env variables will be available in this case? It's not working.
Comment: the above example sets an env variable when using a debugger from vscode (it works for the node debugger when launched from vscode too). Perhaps you could ask another question with some more details as to what exactly is not working? Are you running from vscode? Perhaps share the launch.json you are using? Does it run but just not have the env variable set or does it not run at all? If you want to tag me in a comment (just use @stewart_r in the comment) I'd be happy to try to help but I'm sure if you give a detailed enough question there will be lots of help available from others too.
Comment: I feel I have answered the question as it was asked. If you are still struggling perhaps ask a new question trying, as far as possible, to follow this guide: https://stackoverflow.com/help/how-to-ask to give the community the best possible chance of being able to help
Comment: Thank you for posting your answer, @Stewart_R.  I feel it should be the accepted answer, and feature right at the top.
Answer: In the VSCode launch.json you can use "env" and configure all your environment variables there:
{
    "version": "0.2.0",
    "configurations": [
        {
            "env": {
                "NODE_ENV": "development",
                "port":"1337"
            },
            ...
        }
    ]
}

Comment: What if I have two configurations? How do I switch between them? For example, the second one's name is "Launch Program 2". My code just imports an environment variable, but I want it to import different values depending on the current configuration. I mean just for a simple launch, I am NOT in a debugging session.
Comment: @SergeyZakharov within the "configurations" you can add a new one (just change the "name") and then select in debug tab which config you would like to use.
Answer: You can load an environment file by setting the envFile property like this:
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch",
      "type": "go",
      "request": "launch",
      "mode": "debug",
      "remotePath": "",
      "port": 2345,
      "host": "127.0.0.1",
      "program": "${workspaceFolder}",
      "envFile": "${workspaceFolder}/.env",
      "args": [],
      "showLog": true
    }
  ]
}

Place the .env file in your folder and add vars like this:
KEY1="TEXT_VAL1"
KEY2='{"key1":val1","key2":"val2"}'

Further Reading: Debugging go in vscode with environment variables
Comment: `envFIle` isn't supported anymore, unfortunately. I am not sure there's an alternative
Comment: this is just for Python or debug-config-contributing extensions that decide to support such a feature.
Answer: I run vscode from my command line by navigating to the folder with the code and running
code .

If you do that all your bash/zsh variables are passed into vs code. You can update your .bashrc/.zshrc file or just do
export KEY=value

before opening it.
Comment: Why does it only pick up the env variables if started via the command line? I always want it to use my env variables in `.zshrc`.
Answer: For the VS Code process
VS Code's environment (the environment variables it has) will be its environment as it was given when it was created (see also Changing environment variable of a running process. TL;DR you generally can't change a process' environment variables after it has been created).

You can start VS Code with custom environment variables (Ex. by using the env UNIX command)

You can run VS Code from an environment that already contains the environment variable as you want it, since most Operating Systems will make child processes inherit the environment of their parent processes by default.

You can modify your system's environment variables (which all processes in the user space inherit by default (if I understand correctly)). Ex.

For Windows: What are PATH and other environment variables, and how can I set or use them?)
For macOS: How do I set environment variables on OS X? / Setting environment variables on OS X
For Ubuntu: How do I set environment variables?
or some other configuration point that gets sourced for user processes, such as ~/.profile (related: What is the difference between .profile and .bash_profile and why don't I have a .profile file on my system?).

Note that with macOS and Linux installations, VS Code will try to source an environment from shell-specific user-level configuration files (Ex. ~/.bashrc and ~/.zshrc) even when not manually launched from such shells by creating such a shell and starting itself from that shell. For relevant documentaiton, see here.
See also How can I specify environment variables for the VS Code process in my VS Code settings?
For shell processes in the integrated terminal
See the terminal.integrated.env.<platform> settings, where <platform> is one of "windows", "osx", or "linux". The setting's description reads:

Object with environment variables that will be added to the VS Code process to be used by the terminal on <platform>. Set to null to delete the environment variable.

See also the related terminal.integrated.inheritEnv setting. Its description reads:

Whether new shells should inherit their environment from VS Code, which may source a login shell to ensure $PATH and other development variables are initialized. This has no effect on Windows.

For task processes
Use the task's options property's env property. Similar to the terminal.integrated.env.<platform> setting, this setting's value is a JSON object mapping environment variable names to values. The setting's description reads:

The environment of the executed program or shell. If omitted the parent process' environment is used.

For run / debug processes (launch.json)
Each launch configuration can decide how it wants to allow you to configure this. According to VS Code's documentation, "Many debuggers support some of the following attributes: [...] env - environment variables (the value null can be used to "undefine" a variable)". Other extensions that contribute launch configuration types may use a different schema, such as the cppdbg from the cpptools extension, which uses a format like [ { "name": "config", "value": "Debug" } ].
For processes related to specific extensions
This is only if those extensions contribute settings to do such configuration.
For example,

The CMake Tools extension contributes various settings, which are documented here, including cmake.environment, cmake.configureEnvironment, cmake.buildEnvironment, and cmake.testEnvironment.
The Python extension has the python.envFile setting, and launch configurations of the python type can also have a envFile property. You can find related docs here.

There's a slightly related feature-request about this here for the extension host process: API: allow an extension to change the environment variables #152806. See also this comment there about more broadly applying it to the "root" VS Code process, this update/summary, and this note about using process.env for the extension host.
Answer: For C/C++ debugging this works for me (docs):
// Defined per configuration in launch.json
"environment": [
    {
        "name": "<env_name>",
        "value": "<env_value>"
    }
]

Answer: Could they make it any harder?  Here's what I did:  open system properties,  click on advanced, add the environment variable, shut down visual studio and start it up again.
Comment: I believe the original post request to ask to set environment variables in the IDE is because he did not want to do that in the system. One possible reason could be that he did not have administrator right to change the system's environment variable
Comment: The dialog that you use to set system environment variables also will let you set user environment variables (no elevation needed) that will be available for any new processes in the user's session. It works, but this is not an ideal way to set environment variables for VSCode for more than the debugger/launch.json uses. I prefer the approach recommended by @mvndaai: https://stackoverflow.com/a/60403290/100596
Answer: My response is fairly late. I faced the same problem. I am on Windows 10. This is what I did:

Open a new Command prompt (CMD.EXE)
Set the environment variables . set myvar1=myvalue1
Launch VS Code from that Command prompt by typing code and then press ENTER
VS code was launched and it inherited all the custom variables that I had set in the parent CMD window

Optionally, you can also use the Control Panel -> System properties window to set the variables on a more permanent basis
Hope this helps.
Comment: I like your answer. But is it also possible to define environment variables in vscode. I know it is possible to do that for the terminals in the vscode, but I want it to be recognized by any vscode extensions as well. I believe your method did achieve what I want, but wonder if vscode has any setting that can do the same things.
Comment: Close all instances of VS Code when attempting this. A running instance will merely spawn a new window and close the process you spawned.
Comment: @Bruce You're right, but I have not found defining those debug configs and environment files easy nor have I even got them to work reliably (nor do I have the time or desire to figure out yet another config format), while this way (and the equivalent in Mac/Linux) just works.
Answer: Since VS Code uses powershell in the terminal.
The powershell command is
$env:NAME='VALUE'

To learn more:
https://www.tutorialspoint.com/how-to-set-environment-variables-using-powershell
Comment: 1 VS code uses whatever terminal you set it up to use, though powershell is the default (mine is on bash), 2 environment variables created directly in VS code's terminal window may not persist between sessions.
Answer: If you've already assigned the variables using the npm module dotenv, then they should show up in your global variables. That module is here.
While running the debugger, go to your variables tab (right click to reopen if not visible) and then open "global" and then "process." There should then be an env section...
Answer: You can try the env:variable_name syntax. For example you write export DATASET_PATH=my_path in your shell (or .bashrc) to set the variable locally, then edit your launch.json
        {
            "name": "ExampleTask",
            "type": "python",
            "request": "launch",
            "program": "/home/${env:USER}/git/runfile.py",
            "console": "integratedTerminal",
            "args": [
                "--dataset-path", "${env:DATASET_PATH}",

            ],
            "justMyCode": true
        },

Though, for some reason it stopped working for me recently (The variables I set already still work, I just can't add new ones, it's very mysterious). So don't get your hopes up too high
Answer: As it does not answer your question but searching vm arguments I stumbled on this page and there seem to be no other. So if you want to pass vm arguments its like so
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "java",
      "name": "ddtBatch",
      "request": "launch",
      "mainClass": "com.something.MyApplication",
      "projectName": "MyProject",
      "args": "Hello",
      "vmArgs": "-Dspring.config.location=./application.properties"
    }
  ]
}


New washer hookup is overflowing

Question: We just had a new washer dryer hook up put on the first floor of our house. But immediately when the washer drains water, floods, the floor coming out of the drain. The plumber claims that it could be a bed vent but since the wall is now sealed up with sheet rock and spackle and painted. We really do not want to destroy the world. Is there something else we can do?
Comment: I do not know those vents except from what I read on here, but having it inside of the wall, when they need replacing every so often, does not sound like the best of ideas.  A new vent should not have problems already, so maybe a clog in the drain your plumber did not know of, or they made a mistake.
Comment: To be clear water comes out where the washer hose goes into this pipe ?  I am not sure what the normal way to do it is.  Ours does not have a trap and air gap.  Maybe it just can't cope with the volume and pressure of water.
Answer: There absolutely must be an access panel over the vent location large enough to replace it, so buy one, reference the picture, and cut a hole to put it in.
Not impressed with your plumber (this should have been tested before the wall was closed up, and the access should have already been there if using a mechanical vent. Also, the mechanical vent should have been higher than that.)

New washer hookup is overflowing


Hadoop cannot start NodeManager

Question: I have installed the Hadoop Cluster which is the hadoop 0.23.9 version. I install the HDFS-1943.patch and now I can start all the namenode and datanode. (start-dfs.sh is working for me)
However, when I want to start the yarn daemons (running start-yarn.sh) , it shows the following error as the same as the previous happening:
<code>[root@dbnode1 sbin]# ./start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /home/hchen/hadoop-0.23.9/logs/yarn-root-        resourcemanager-dbnode1.out

datanode: starting nodemanager, logging to /home/hchen/hadoop-0.23.9/logs/yarn-root-nodemanager-dbnode2.out

datanode: Unrecognized option: -jvm
datanode: Error: Could not create the Java Virtual Machine.
datanode: Error: A fatal exception has occurred. Program will exit.
</code>
I have installed the patch already and start-dfs.sh is working for me. Why start-yarn.sh does not work??
Answer: Run HDFS as a non-root user with the appropriate permissions. Here is a JIRA with more details.

Hadoop cannot start NodeManager


Reasoning for comparing variance between and within for Anova?

Question: I looking for some logic reasoning why ANOVA test uses $σ^2$ given by these to variables. a logical reasoning why the ratio of variance between these two would say that the each population has the same µ, and the groups which it has been tested on comes from the same overall distribution Why??
Answer: The actual logic behind it is much simpler:
There are two ways to estimate the variance in the population when you have several groups but you assume the values all come from the same distribution.

look at the variance in each group

Each group can be considered a random sample from the population and each one provides an estimate for the population variance. We need a single estimate, so we take the average. This is the within-variance $\hat{\sigma}_\mathrm{within}^2$

look at the variation of the means

The means of the different groups can be seen as a sampling distribution of means from the population. The variance of this distribution is: $\hat{\sigma}^2_{\bar{x}} = \frac{\hat{\sigma}^2}{n}$
Crucially, we are interested in the population variance $\hat{\sigma}^2$ so we have to multiply the variance of the means with the sample size: $\hat{\sigma}^2 = \hat{\sigma}^2_\bar{x} n = \hat\sigma^2_\mathrm{between}$
If all values really come from a single distribution, the two ways to estimate the variance should give the same result. But obviously drawing samples is a random process, so we calculate a $p$-value, which tells us the probability of deviations from equal variances (even though all values come from a single population). If the probability is very low, we might argue that the values do not come from a single population. Then the means will variate much more than we expected and the ratio increases.
To me its astounding that ANOVA is not taught in this way. Most instructors just start with sum of squares and degrees of freedom and the formulas do not make any sense. When seeing that both variances are actually estimates of the population variance, the formulas start to make sense.
Note that I assumed a balanced design where the sample size for each group is the same ($n$). If this is not the case one has to take weighted averages.
Answer: If I understand correctly, I can begin my answer by saying that we assume that the sample means differ; if their observed differences were 0, there would be nothing to "test," so to speak. Now what we are actually interested in is if these observed mean differences are merely due to chance (i.e., sampling error) or represent a real effect of the independent variable (i.e., factor) on the dependent variable in the real world. That is, we want to ensure that these observed differences are reliable so that we can be comfortable making an inference to the population (as is the case in inferential statistics in general).
To do so, we partition the variation seen across the observed scores into two sources: between-group variance, that is attributable to the factor (i.e., the independent variable), and within-group variance, whatever is left over and considered random error. The logic is that the latter (i.e., the denominator) is a representation of the variation we would expect simply by chance. The value of this ratio is distributed as F when the null hypothesis of no difference between population means is true.
However, when the numerator is large enough to yield an F-value that is also sufficiently large (typically reaching the criterion of p < .05), then it is often concluded that the observed difference between means is not merely due to chance (sampling error). This simply rests on the meaning of the derived p-value. Of course, remember that the ANOVA significance test only tests if one mean is different from any other; to get at which means differ in particular, one needs to run post-hoc tests. However, to my understanding (and anyone feel free to correct me if I'm wrong), but partitioning the observed variance in this way is all about getting obtaining an F-statistic and its associated p-value. In other words, it is all about hypothesis testing, not estimation (which is done by calculating the raw difference between means and possibly a confidence interval around it--at least in the frequentist approach).
Answer: I'll start by discussing what happens under the null hypothesis of no difference between groups. Suppose we run an ANOVA on junk data. Let's say the groups are the ethnic/racial divisions as devised by the US Census and the variable is a random number generated by a computer.  In our sample, each group will have a different mean value of RN (at least, if we use enough decimal places) so there will, even under the null, be some variation between groups. There will also be variation within groups since, e.g. not all White people have the same RN (indeed, no two people do). In this case, we expect the variation within and between to be equal - it's all noise - so we expect an F = 1.
Now, what happens when the null is false? Suppose we no longer use random numbers but family income. There will still be variation within and between, but we now expect that the variation between groups will be larger than the variation within, because the incomes are not distributed randomly, but with some order.


When do you submit a preprint?

Question: I'm working on a number of projects right now, some are near "completion" (as much as that is ever possible!). I've been thinking a lot about preprints lately. When would the appropriate time to upload one? At the same time as you submit a manuscript to a journal? My fear is that all my previous work has changed quite a bit in the review process (which seems normal enough), so if this is normal for my work should I avoid preprints at this stage? What if the results are modified by incorporating suggestions of reviewers?
Comment: @RamPadmanabhan, a caution. Some of the "general" advice you give to questions here isn't universally valid. You have a specific outlook that needs to be qualified. Not every field is like math. Not every country is like India. (Technical advice such as you give here is fine, but preprints may not be open to the OP here.
Comment: This depends on the field and also on the journal(s) you intend to submit to. What field?
Comment: For me, ecology. Interesting that you suggest its field-specific - why's that?
Comment: When you make updates to your article after the review process, you can simply update your submission on the preprint server. arXiv has formalized this (using v1, v2 notation), and it's easy to download previous versions of articles, even if they have changed significantly after review. However, the most recent version is the one that's directly visible.
Comment: In pure mathematics, preprints posted by authors are pretty ubiquitous. But some journals in some fields won't consider a paper that has appeared anywhere, even in preprint. That may be starting to disappear, though, and some journals, themselves, post preprints after acceptance but before formal publication. Sorry, though, I can't give advice for your field. But you can explore policies of journals you'd like to submit to.
Answer: I don't know about ecology specifically, but in biology in genearl (my experienece is molecular and computational biology and genomics), I always submit a preprint when I first submit the article to a journal for review. Yes, the paper sometimes changes between submission and final publication, but that just gives you something new to talk about in your tweet-torial about the final publication that was different to when you tweeted about the preprint!
Almost all preprint servers will allow you to upload new versions of papers after initial submisison, but be aware that some journals allow you to submit articles that have been preprinted, but then do not allow the upload of updated versions after that point.
Answer:
As was said in a comment, some journals don't accept papers that are published as preprints (although it seems to become unusual these days). So if you have one or a few journals in mind, check their policy before putting out your preprint!

You don't want to have a preprint out there that is embarrassing, so wait with publishing a preprint until you're really convinced of it (and maybe have the material discussed with a few people).

If these issues are out of the way, I'd say publishing a preprint is fine and sometimes you want to do it early in case others work on the same thing and a time stamp can tell that you were there first. Also, if your preprint is out some time before submission, you may discuss it with some more people and improve your journal submission. (I do realise that one may sense a slight contradiction to the first issue, but everything can be improved, even if you are at some point convinced that it's good enough!) People also may cite your preprint in case the publication process takes so long that the journal version doesn't exist at the point where others want to cite you.
Comment: Yes, and it may also help if you need to cite yourself. E.g. if you need to publish two articles, one about the method and another one applying that method.

When do you submit a preprint?


upgrade sql server to 2008 R2

Question: I have installed an instance of SQL Server 2008 Express Edition but when trying to restore a db file - bak, I receive the following error: "The database was backed up on a server running version 10.50.1600. That version is incompatible with this server, which is running version 10.00.1442. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server."
I assume this error is generated because the bak file was backed up on a sql server 2008 R2.
My question is how can I upgrade my database server to 2008 R2 Express Edition so I can restore this file?
Or if there is any other option to import the file using the already installed version..
Comment: This is not a programming question, and is off-topic here. Voting to move to [superuser](http://superuser.com)
Answer: Here is a walkthrough on how to upgrade a SQLExpress 2008 instance to SQLExpress 2008 R2 version
http://www.asql.biz/Articoli/SQLX08/Art5_1.aspx
Answer: 10.50.1600 is SQL Server 2008 R2, and 10.00.1442 - they are separate versions, and 2008R2 is a later version. You can't do a restore down the versions, only to identical or higher versions.

upgrade sql server to 2008 R2


What is the physics behind width of the duty cycle in Arduino?

Question: I was wondering if someone can tell me how Arduino changes the width of the duty cycle? How it produces an on-off pattern? I am looking for an explanation for modulation in this system.
Comment: What do you mean modulation of the system? Timer interrupts switch a totem pole output between high and low. It really is as simple as a MCU keeping track of time to turn switches on and off. The analogWrite(255) refers to 8 bits of resolution on the duty cycle.
Comment: there is no phase and amplitude? unlike the analog one? let's consider that I am controlling the position of dc motor with pwm. what is the input of this system ? am I really controlling the phase and amplitude?
Comment: No, amplitude is always high or low - no in between voltages. You can't control phase either.
Comment: @nikki2 I think you're confusing (analog) modulation schemes used for **data transmission** with PWM. PWM is **not** for data transmission. OK, you could do it but it is not intended for that. PWM is for controlling power to motors and LEDs, lamps etc. It is efficient as it switches on/off very rapidly instead of regulating which is much less power efficient.
Comment: if I  want to drive the transfer function output should be the velocity and input should be pwm? or phase? which one.
Answer: There are several simple ways of making a PWM signal. PWM means Pulse Width Modulation which is a signal of (usually) a constant frequency in which the time that the signal is high is variable.
One way to implement this is
Make a counter which continually counts from 1 to 100 and after 100 resets so the next count is "1": So: 1, 2, 3, ...,99, 100, 1, 2,...
Then use a comparator to compare that number to the Duty Cycle you want. For example, we want a 33% DuCy, then we make the counter output "1" when the counter's value is 33 or lower. The comparator will "flip" at 34 so for 34 to 100 output will be "0".
The Arduino has not 100 DuCy levels but 256 so the counter counts not to 100 but to 256.
The counter will "clock" (count up) on some clock derived from the main clock frequency.
I am not saying that this is THE way that this is implemented in the ATMega chip on the Arduino, it is an example of how it could be implemented.
Comment: Of course I know that (I have designed counters) but I wanted to keep things simple so I lied and started counting from 1 **on purpose**. Sometimes not being technically accurate helps in getting the message across.
Comment: @Bimpelrekkie normally I'd agree with 'lies to children', but in the case of counters, I'd think I'd try to normalise children to count from 0, especially when talking about real hardware. That way, any confusion is informative. If you use Matlab, you'll know the frustration of only having 1-based arrays. Why not zero based? It was written by a chemist!
Comment: Technically it goes from 0 to 255 on 8 bit timer, but it also have 16 bit timer.
Comment: Different Arduino models are built around different microcontrollers.  The overall method of generating PWM in the microcontrollers is usually the same.  The details (such as number of bits in the counter, number of counters, number of PWM channels) may vary from one microcontroller to another.


what is the meaning of this?

Question: It is that when looking for a flight Madrid-Santa Cruz I've found the price and its options, that is correct, but What is the meaning of  SSEEOB, QEEOB, TMEEOB, VEEOB, HEEOB, BEEOB, YOW ? This is always beside the prices
Answer: The codes are the different Fare Basis codes available for the flight. The first character of the code is (usually) the booking class (example for UA). The different types of fare basis indicate flights with differing flexibility and restrictions, such as requiring so many days advance booking, Saturday night stays and cancellation penalties. In your case, SSEEOB will be the cheapest and most restictive, and YOW will be the most expensive and completely flexible and refundable.

what is the meaning of this?


Which country traces its roots back to the oldest civilization?

Question: Which country is recognized or documented as having the first prominent civilization? After reading so many articles, I couldn't determine which country should be acknowledged as having the oldest civilization. According to Puranas of India, it seems to be the oldest country with a prominent civilization. However, while searching Google, I found that Egyptians existed at the same time as the earliest Indian civilization. Can anybody clarify this?
Comment: Define Civilization.
Comment: Very good question!!! ( i would say I couldn't have said it better myself but I really could not
Comment: I really think Lennart's question is essential in this matter. "Civilization" is hardly an academically fixed concept.
Comment: I'd also ask what is meant by prominent, are we talking the first, earliest civilization that can be detected with current methods and tools?
Comment: You also need to clarify whether you mean that there's cultural continuity, or that the ancient civilization just happens to be located in the modern-day country.  Modern Egypt, for instance, has almost nothing in common with ancient Egypt, or even Egypt under the Ptolemies, Romans, or Byzantines.
Comment: Yes, but not in a useful way. If we can restrict ourselves to the original definition, which basically means "having cities" then it can be answered.
Comment: Year-round intensive agriculture based on division of labour is also an oft-cited definition, if a bit arbitrary.
Comment: Wikipedia summarises civilisation, unsurprisingly.
Answer: The Sumerians are widely credited with being the first genuine civilisation on Earth, beginning gradually around the 5th millennium BC and reaching clear 'civilisation' status by the early 4th millennium BC. Towns and large agricultural communities existed before this time, but are generally not considered to have constituted a civilisation. The Sumerians, who were situated in modern-day lower Iraq and Kuwait, are widely believed to have invented the city-state and organised government, law, writing, systematic agriculture, the wheel (probably), and irrigation, among various other early innovations and marks of civilisation.
Although the dates of the beginnings of these civilisations are in general not terribly well-defined, the order of the appearance of "civilisations" is often considered to be the following.

Ancient Sumerian — the very earliest (first city-states in world in 4th millennium BC, cuneiform script, probably first 'proper' writing system, c. 3,000 BC)

Ancient Egyptian — widely considered independent in origin (gradual development of civilisation throughout 4th millennium BC, unification / start of First Dynasty c. 3150 BC, appearance of hieroglyphs c. 3,000 BC)

Ancient Indian (Indus Valley Civilisation) — widely considered independent in origin (c. 3,300 BC, Indus 'Script' from around 3,300 BC but may well have just been pictograms for initial phase, since not yet deciphered, syncretism with Indo-Aryans from early 2nd millennium BC)

Ancient Chinese — widely considered independent in origin (c. 1,900 BC with Ertilou period and development of state, beginning of Bronze Age, Oracle Bone Script recorded from c. 1,250 BC but definitely older, yet still pictographic at this point)

Ancient Greek (Minoan / Mycenaean) — partially inheriting from Mesopotamian and Egyptian developments, older than the above if you count the Minoans of Crete (c. 3,000 or early 3rd millennium BC, undeciphered Linear A script from c. 2,500 BC, Mycenaean Greece and deciphered Linear B script from c. 1,600 BC)

Phoenician / Canaanite (Lebanon area) — partially inheriting from Mesopotamian and Egyptian civilisation (first recorded in 15th C BC by Egyptians, but city-states likely several centuries older)

Ancient Italian (Etruscan / Roman) — partially inheriting from the Greeks (Etruscans and city-states from c. 900 BC, Rome founded in c. 753 BC, Republic in 509 BC, dominant Mediterranean power by late 3rd C BC and defeat of Carthage)

Ancient Iranian (Medean / Persian) — partially inheriting from Elamite and Mesopotamian civilisations (Medean Empire from c. 678 BC but with scarce archaeological remains, extremely influential and historically important Achaemenid Empire from 550 BC)

Sources for these dates can be found here and here. Admittedly, I miss out a few civilisations like the Elamites, Akkadians, Hittites, and other Anatolian and Middle Eastern ones (and thus perhaps I do them injustice) — that said, these would usually be considered to have left behind a far less marked cultural or historical impact on their respective regions, or indeed even a lesser archaeological or documental history in some cases. The Elamites are perhaps most deserving of a place in the above list, and they would date from c. 3,000 BC, putting them in '4th place'. I believe it's debatable how much they were influenced by Sumer.
Note also that I am restricting this answer to Old World civilisations, since although the Norte Chico civilisation of South America can be considered very early, it does not bear some of the hallmarks of what we typically consider — rightly or wrongly — a 'genuine' civilisation (e.g., a mature writing system, the wheel).
Comment: @rougon Yeah, fair point. Of course, dates are very hard to pin down (by their nature only fuzzy) for the earlier civilisations in particular, but it's a good suggestion nonetheless.
Comment: What about the Maikop culture?
Comment: @Anixx: Too little is known about that culture, I believe. It would be too much of a stretch to call it a genuine civilisation, in any cases, at present. Most likely what "civilised" aspects it did pick up were from the contact of Indo-European peoples with the advanced Middle-Eastern cultures at the time.
Comment: The title asks what country traces its roots back to the oldest civilization. You mentioned Sumeria was in the Iraq area, but what about technological, ethnic, linguistic, and cultural heritage? Would you say that going that far back means just about everyone has roots in their civilization? Or is there some country or countries with a unique claim to Sumerian descent?
Comment: @Mr.Bultitude: In brief summary of a very complex issue: technological heritage was immediately the Assyrians (who later conquered the region), the entire Middle East, the Mediterranean and Indian civilisations, then the whole world in time. Ethnic? Very hard to tell, although there's nothing to suggest the Sumerians were wiped out. They lost their identity over time thanks to the Assyrians & Babylonians, but I'm sure many modern Iraqis, Syrians, Jordanians, and people far wider afield have a little Sumerian ancestry if you go back far enough!
Comment: As for linguistic descent, there are no living descendent of Sumerian, although a number of loanwords entered Assyrian and other Semitic languages, and have been passed down into modern languages. See e.g. "cane" in England (http://www.etymonline.com/index.php?search=cane). I'm sure Syriac (which still exists as a liturgical language) has a number of Sumerian loanwords, though I can't list them off the top of my head.
Comment: Cultural heritage? Again, extremely hard to discern, but they certainly left legacies of epic literature, book-keeping & accountancy, and many other things that influenced later civilisations, in particular via the Assyrians again. You'd have to ask an expert on Sumerian culture to get a real answer about this though.
Comment: Where are the Hittites and other Anatolians?
Comment: @Anixx: True, I probably should have included them, although it must be said they didn't leave very much of a written record as far as I know. They can be dated from round about the dawn of the Mycenaean Greek culture (though not as early as the Minoans of course).
Comment: Fwiw, the Persian Empire was around long before The Roman Republic.
Comment: @rougon Long before... no. Only a little before, on a historical scale.
Comment: @Noldorin true, on a scale like that. The answer could be improved by including dates, as you are discussing a sequence.
Comment: Updated answer now.
Answer:
After contenders like Sumerians, Egyptians, there is another forbidden world which was ruined because of earthquake or may be foreign invasion (some estimate this). Here i am talking about Indus Valley Civilisation who trace back its root since 3300 - 1300 B.C and was the most advanced among all the ancient settlements at that time.

 - Handicrafts
 - In Mettalurgy
 - City Planning
 - Great sewage and drainage systems
 - Baked bricked walls
The civilisation was alien to us but came to known after britishers (colonists) discovered the ruins and clusters of city buried under the earth.
The civilisation was based on the land which is modern day punjab of pakistan. The Harrappa and Mohenjadaro were the major cities of those times.

For More information, follow this link : http://en.wikipedia.org/wiki/Indus_Valley_Civilization
Sources:
www.wikipedia.com/ indus valley civilisation
www.google.com / search engine
{Apologizes for bigger than size images}
Answer: If you use the term civilization with the connotations of culture than the first pieces of art were found in South Africa from more than 60,000 years ago. In an even broader sense apes are now known to possess culture, by teaching technological tricks to their siblings and newcomers in their group.
Answer: Ancient Sumerians were the first people to invent an alphabet and they did it long before the Egyptians.  They kicked off the "Agricultural" revolution, which started the "Urban" revolution and the domestication of animals.
They gave the world the first "Religion" that became a template for all civilizations that followed in human history.  Consider the fact that their
"war between the Gods" theme was incorporated by the big three monotheistic monopolies of our planet.  Judaism, Christianity and Islam.  Then consider the fact that a citizen of Mesopotamia, named Abraham, ( and his sons ) started it all.
Comment: @T.E.D.: The first known alphabetic system was Phoenician; the Greek's borrowed it. There are many writing systems, which are summarized here: http://www.omniglot.com/writing/types.htm
Comment: Sure the Tigris and Euphrates are great rivers; so are the Yangtze, the Indus, the Mekong, and others.
Comment: They seem to have been the first with writing of some kind. However, the first known *Alphabet* was the Greek one, and that didn't happen until the Ancient Sumerians were long gone.
Comment: @PeterDiehr - Well...sort of. The Semitic scripts weren't true alphabets because they didn't have proper symbols for vowels. However, that's probably because vowels are regular enough in Semitic languages that symbols for them aren't really necessary. Last I heard, it wasn't 100% conclusive which was borrowed from which.


IFilter dll works on Windows Desktop Search, but not on SharePoint 2007

Question: I have written an IFilter dll that returns text from my application's file format.  I registered it on my local system, and Windows Search correctly returns results with it.  I registered it on my SharePoint 2007 server, rebooted, and it doesn't seem to find anything inside the file.  Documentation says that all I should have to do is to register it in the same way IFilters are registered for other Index Server implementations (such as Windows Desktop Search)... and that SharePoint will pick up on that as a secondary source of search filters.  When that didn't work, I tried setting it up in the first source that SharePoint uses for IFilters (modeled it after the instructions in http://support.microsoft.com/kb/925765).  Rebooted again, and set SharePoint to crawl, and it still didn't produce search results.
I have my file type defined for crawl as is spelled-out in http://technet.microsoft.com/en-us/library/cc261843.aspx.
I've looked through the event logs, and through the detailed logs in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS  (which has sharepoint search messages)...
EDIT:
I have it working.  There are 2 flavors of SharePoint: WSS and MOSS.  I was told that I was working with a MOSS installation, and the registry entries were present for that, so I was modifying there.  I modified the WSS registry area instead, and it worked.
I still need to find out why, contrary to the documentation, just registering the DLL and aiming its HKCR.  to it via its PersistentHandler for IFilter linkages didn't work.
I also need to better understand the relationship between MOSS and WSS with respect to search.  I suppose, when this gets instaled by a SharePoint Admin, I can just install to both registry sections if they're there (search entries for WSS and search entries for WSS).
Comment: Looks like you have answerd this yourself - why not write an answer?
Answer: In the interest of helping other people with this question, here's the answer:
"I modified the WSS registry area instead, and it worked. "
In other words, you have to tweak the registry bits allocated to the WSS version rather than the MOSS version.


What is the first use of the 'tapping' method?

Question: The 'tapping' method is an advanced guitar technique where both hands are placed on the fretboard, typically reserved for solos. Who was the first guitarist to use this method - live or otherwise?
Comment: As this questions does not *require* live music, the [tag:live-music] tag doesn't seem to be appropriate. But which tag instead? An instrument tag, i.e., "guitar"? Or a general "techniques" tag?
Answer: First guitarist was possibly Jimmie Webster, who made recordings in the 1950s using a two-handed tapping method he described in 'Touch Method for Electric and Amplified Spanish Guitar', published in 1952.  George Lynch, from the bands Dokken and Lynch Mob, has claimed that George Van Eps used tapping in the 1950s as well.
As far as Rock goes, the earliest purveyor mentioned is usually Canned Heat guitarist Harvey Mandel, whom none other than Ritchie Blackmore attests to have seen perform this method going back to 1968.  Randy Resnick (who was mentioned in the Eddie Van Halen biography) of the band Pure Food and Drug Act used two-handed tapping techniques extensively in his performances and recordings between 1969 and 1974. Resnick also recorded using the two-handed tapping technique in 1974 on the John Mayall & the Bluesbreakers album "Latest Edition".  You might note that these were all California musicians, and would have been bands Eddie VH was going to check out on weekends.
However, just to prove this phenomenon didn't stay in California, take a listen to Steve Hacket (Genesis)'s work on "Dancing with the Moonlit Knight", from 1973, and "The Return of the Giant Hogweed", from 1971.  So, either the wheel was being invented on 2 continents simultaneously, or somewhere during tours one band heard the other and began employing it as well.
Comment: Wow, Genesis is NOT a band I expected to come up in he answer. Very interesting.
Comment: Here's a video of an Italian guy doing it in 1965 I just came across.  https://www.youtube.com/watch?v=UmTQYquqxSY
Answer: My vote for the 1st use of 1-handed guitar tapping would be Harry DeArmond:
http://en.wikipedia.org/wiki/Harry_DeArmond
My vote for the 1st use of 2-handed guitar tapping would be Stanley Jordan:
http://en.wikipedia.org/wiki/Stanley_Jordan
Comment: While I can't find a good video of the band Genesis performing it, this cover gives a perfect view of the fretboard.  And keep in mind, it was written in 1972.  [Genesis - Return Of The Giant Hogweed cover]  (https://www.youtube.com/watch?v=1QRZyEQ9tXo)
Answer: Tapping was used before any of us. There's a YouTube that focuses on this and includes an old video of an Italian guitarist doing great tapping stuff. Harvey and I played together in the Pure Food & Drug Act where he first saw me  doing it. I use tapping in different ways, to imitate a slide guitar riff, for example, or African bottle music. I have an album of my different tapping recordings, free to stream unlimited on my Bandcamp: https://randulo.com


Dynamic DNS client records not being updated correctly

Question: Our network is running Windows and macOS clients all of which are joined to Active Directory. The Macs are all running Windows via Bootcamp. We were having issues which were being caused by our macOS clients because they were not registering PTR records. We were also having issues with stale records. I spent a lot of time researching DNS and DHCP configuration to try to resolve these problems and ended up thinking I had solved it with the following configuration. But I have now realised that we still have problems which I will explain after the configuration.
Servers

2 x Windows Server 2016 VM's
Both Domain Controlers
Both running DNS
Both running DHCP

DHCP Config

Failover mode: Load balance
Enable DNS dynamic updates: Always dynamically update DNS records
Discard A and PTR records when lease is deleted: Enabled
Dynamically update DNS records for DHCP clients that do not request updates: Enabled
Disable dynamic updates for DNS PTR Records: Disabled
DHCP name protection: Disabled
Lease duration: 2 days
Dynamic DNS credentials are configured. Account is only a Domain User

DNS Config

Active Directory Integrated Zones
Dynamic updates: Secure only
Replication: All domain controllers in this domain
No-refresh interval: 1 days
Refresh interval: 1 days
Scavenging period: 3 days

Group Policy

Computer\Administrative Templates\Network\DNS Client\Dynamic update: Set to Disabled

Current Problems
My aim was to get the DHCP servers to handle all DNS registration to solve the problem of macOS not registering PTR records. The PTR records are now being created but it looks like the macs are still creating their own A records as the permissions list the client instead of the DNS registration user.
The macs obviously use the same ethernet or wireless card in macOS and Windows so the MAC address won't change. I assume when each OS requests an IP it will be given the same IP due to the MAC address and the DHCP server will update the client name. I'm not sure about DNS though; Will the DHCP server create a new A record because the client name is different? resulting in duplicate records for a single IP; OR will the the DHCP server try to change the client name on the A record with the matching IP in which case it will fail if the mac has already registered its own record. I don't know if/how I can tell the mac to let the DHCP server register the records for it (Our mac technician decided to pursue a different career path leaving us Windows tech's scratching our heads :P ).
The second problem I'm having is that for some reason even the Windows clients aren't always registering correctly. I have a Windows only device which has received an IP from DHCP but has no A or PTR records. This device is affected by the Group Policy mentioned above, so it would be relying on the DHCP server to register the records for it. But I can't see anything in the DHCP-Server or DNS-Server logs in Event Viewer on the our servers which relate to this client name.
The third problem, albeit minor is that any clients with statically assigned IP's don't register in DNS due to the setting in Group Policy. There are only a handful of these and we occasionally assign IP's temporarily for various tasks (as DHCP clients require proxy for Internet)
If I have missed any important information please ask. Any help would be greatly appreciated.
Answer: I found post this because we have similar issues. I might have an answer to your "third albeit minor" problem. For static IPs we use reservations on our DHCP, so the DHCP handles DNS records.
Good luck!
Roger


Separating sugar from soda

Question: I want to do a lab with my students in which they will try to prove how much sugar is in a can of coke. I know that distillation is the go-to method for separating out the syrupy sugar mix, but does anyone know of a method that goes further to separate out the pure granulated sugar and not just a syrup?
Answer: The simplest approach would be to degas a sample and measure its specific gravity with a vintner's hydrometer. It will have scales of specific gravity and Brix (sugar content) on it.The Brix (Bx) reading is the percent of sucrose, w/w, in a solution with the same density/specific gravity as the one you are testing. There are, of course, other things in coke besides sucrose (fructose, coca extract, phosphoric acid) but they should be in small enough concentration that the sugars will swamp everything else and all sugars behave amazingly the same with respect to density of their solutions).
Based on the reported sugar content of Coke it contains 108 grams of sugar per liter. Thus its specific gravity should be about 1.041 and the corresponding Bx reading about 10.4. The density of water at 20 °C is 0.998203 so the density corresponding to 1.041 SG is 1.039 and 10.4% of 1039 grams (weight of a liter of 10.4 Bx sucrose solution) is 108 grams.
If you don't have a hydrometer with the Bx (or Plato) scale or if you determine density by weighing a known volume (convert to specific gravity) you will need to be able to determine the sucrose content of a solution of given specific gravity. There is lots of opportunity here to go into the history of wine and beer making, which you male students will love (though I understand that in modern schools discussion of things related to alcohol may not be politically correct) but in any case determining the w/w sucrose content of solutions of given SG is a well studied problem. There are various tables but the easiest way to get w/w sucrose from specific gravity is a polynomial promulgated by the ASBC (American Society of Brewing Chemists). It is
°P = ((135.997*S -630.272)*S + 1111.14)*S -616.868
I believe that separating out the pure sugars at anything close to 100% recovery would be difficult (barring HPLC or something of that sort). Sugars seem to be assayed by indirect methods such as the gravimetric ones I proposed or measurement of refractive index.
Comment: The *Journal of Chemical Education* has a lab experiment that fits here.  The calibration goes uses a linear regression with water, and samples of 5, 10, and 15 weight% of sugar and from this infers 11.9 weight% of sugar in (then available) Minute Maid apple juice.  Henderson, S. K.; Fenn, S. A.; Domijan, D. D. Determination of Sugar Content in Commercial Beverages by Density: A Novel Experiment for General Chemistry Courses. *J. Chem. Educ.* **1998**, *75*, 1122-1123; [doi 10.1021/ed075p1122](https://doi.org/10.1021/ed075p1122).
Comment: I suppose another tractable, if tedious, method would be to (i) assume nearly all of the organic dissolved solids in the Coke is sugar, (ii) to dry the degassed Coke, and (iii) to perform some sort of calorimetry on the combustion of the solid residue.
Comment: Degassing will be fast(er) with an ultrasound bath, or a [foamer](http://sonicfoamer.com/) as «popularized» e.g., by Guinness as *surger* ([video](https://www.youtube.com/watch?v=9Zjx0rTyZys)).
Answer: If the amount of sugar is to be determined precisely in a given solution, the simplest thing is to mix it with a $0.2$ M $\ce{HCl}$ solution, to heat it up to boiling for ten minutes, and cooling it down to room temperature. This will hydrolyze the saccharose to a mixture glucose + fructose. Then, the glucose is determined by Fehling's solution, producing a $\ce{Cu2O}$ precipitate, which can be weighed or titrated. The procedure is described in all books of analytical chemistry.
Comment: In North America at least, most soft drinks are sweetened with high fructose corn syrup (which doesn't suppress hunger and metabolizes into lipids, not glucose: hello obesity), so there might be no sucrose and not much glucose there.  How will that affect this procedure?
Comment: @Ray Butterworth: one of the deceptive names in food is "high fructose corn syrup". Sucrose is 50%/50% fructose/glucose. HFCS is 42% or 55% fructose on a dry basis (https://en.wikipedia.org/wiki/High-fructose_corn_syrup). What makes the fructose high is the low water content, ~24% in the syrup. Of course, that also makes the glucose high. Coke claims to use sucrose in its Coke, but there are varieties of Coke, so maybe some use HFCS.
Answer: How about precipitating the sucrose? Acetone and CaCl2 can precipitate up to 98% of the sucrose. There are other precipitation schemes on the web that use complex organic compounds of transition metals, but they seem more useful for analyses than for actual separation.
I can't do any better than to copy and paste an abstract (the whole article is available at the reference url):
"The use of methanolic CaCl2 for the non-aqueous extraction of sucrose from dried sugar beet (Beta vul garis L.) cossettes was investigated, with emphasis on the effects of CaCl2 concentration, time of extraction, and operating temperature. Solubility of sucrose from dried cossettes was optimal in range of 10-15% CaCl2 in methanol and increased by a factor of four as the temperature was raised from lC to 60C. Nearly complete extraction (98%) was achieved in batch experiments with four successive extractions. The methanolic CaCl2 extract was found to have both higher purity and greater sucrose stability compared with aqueous diffusion juice. The sucrose could be precipitated completely from the solution by the addition of 5 volumes of acetone at 20C, leaving 9~/o of the CaCl2 in solution. Steady state conditions could not be reached in simulated continuous column experiments, probably because of calcium exchange with other cations in the beet pectin. Pure sucrose was precipitated from these effluent solutions on cooling. The amount of sucrose recovered was pro portional to the decrease in calcium content on pas sage through the column. From this, the molar ratio of calcium to sucrose in the methanolic CaCI2 sucrose complex was calculated to be 2:1." Ref 1.
Ref 1. https://bsdf-assbt.org/wp-content/uploads/2017/04/JSBRVol30No1and2P57to69SucroseExtractionFromBeetByMethanolicCalciumChloride.pdf

Separating sugar from soda


Current on both sides of a capacitor

Question: When a capacitor is connected to a DC circuit, what ensures that the current on both sides of the capacitor is the same? When charges arrive at one end of the capacitor they stop moving; presumably they give their kinetic energy to charges on the other side of the capacitor so they can leave. How exactly does this transfer of energy occur?
Comment: A lumped two-pole is the general circuit element with two connections (like resistors, capacitors, inductors, diodes etc.), for which we can neglect the internal structure and the relative geometry of the physical component in relationship to other components, wires, etc.. We can describe them with a  low frequency current/voltage relationship like Ohm's law or the capacitor or inductor formulas. For frequencies with wavelengths of the size of the physical component this is not correct, any longer, and we need refined models that take electromagnetic radiation into account.
Comment: That the current on both leads of a capacitor is the same is an approximation that characterizes lumped two-poles. In general, however, a conductive structure with the typical shape of a capacitor does not conserve current this way if it can radiate electromagnetic waves into free space, but that's very hard to calculate, so for technical applications we assume that the capacitor is a self-contained element, rather than the combination of two antennas. This works because we can often simplify the problem to a pure displacement current between the two plates and neglect the external fields.
Comment: Sorry, what are lumped two-poles?
Answer: You seem to be asking two questions: why is the current on either side the same, and what happens to the energy. To clarify where the energy goes, the kinetic energy is transferred entirely into electrical potential energy of the capacitor. This is the energy stored as a result of all the similar charges being close together on either capacitor plate. There is no actual energy transfer from one plate to the other.
For the currents, let's imagine the current on one plate was larger than the other. The capacitor would end up building a net charge, as a result of the charge on one plate being larger than the charge on the other. By conservation of charge, this extra charge must have come from somewhere else in the circuit, and there must be the opposite charge to cancel out the net charge on the capacitor. This is an energetically unfavourable situation, so doesn't happen without some additional influence. We can thus conclude that the current on either side is identical.
Answer: It is possible for a capacitor to have a net charge. However, most components have a small capacitance with respect to infinity. Unless you're dealing with a huge metal ball, it will take a large voltage in order to get any appreciable charge there.

Current on both sides of a capacitor


MBR and GPT pointing to same OS?

Question: I understand there are a lot of questions regarding this topic of MBR partitions, GPT for UEFI, having dual OS, one with MBR and the other with GPT, but due to my own inexperience I cannot figure this out.
I have an USB drive. It has a full installation of Elementary OS, which is a close distro to Ubuntu, using MBR to boot ONLY from CSM UEFI and actual Legacy BIOS systems. I want to use it across different systems, some of them use UEFI, others UEFI + Legacy, CSM...
Is it possible to have two partition tables, MBR and GPT on the same USB stick which point to the same OS so it can be booted from UEFI and Legacy systems? If it is, How can this be archieved?
Comment: Ubuntu can boot in BIOS or UEFI boot mode from gpt. You need an ESP - efi system partition for UEFI boot and a bios_grub partition for BIOS boot. Some have configured one gpt based flash drive for both, but I prefer just to have two flash drives.  And I normally use gpt for both. https://help.ubuntu.com/community/Installation/UEFI-and-BIOS May not be totally stable as updates in one mode may conflict with the other mode.
Answer: Strictly speaking, a disk can use MBR or GPT, but not both. That said, there's an ugly and dangerous hack, known as a hybrid MBR, which is most often used on Macs, that enables a GPT disk to include MBR pointers to three of its partitions for the benefit of GPT-unaware OSes. There's very little or no reason to use a hybrid MBR except on Macs that are dual-booting with Windows 7 or earlier, or with other non-GPT/non-EFI OSes. A hybrid MBR would provide NO benefit for your specific case.
Be aware that boot mode (EFI/UEFI vs. BIOS/CSM/legacy) and partition table type (GPT vs. MBR) are not necessarily linked. Windows ties the two together, and older OSes understand neither EFI nor GPT, but other than that, you're usually free to mix and match. You can install Ubuntu in BIOS mode to a GPT disk, for instance. That said, using GPT for EFI-mode booting and MBR for BIOS-mode booting will minimize the risk of running into problems, but it's often possible to cross those boundaries if doing so is necessary. Thus, if you want to have a USB drive that's bootable under either BIOS or EFI, you can, in principle, use either MBR or GPT on it. You'll have to be sure to install both BIOS-mode and EFI-mode boot loaders, but the partition table can be either type. This type of configuration can be tricky to set up, though, and offhand, I don't know of any site that provides step-by-step instructions for configuring it. There are about a million special cases that can create problems for specific computers or for computers configured in particular ways (Secure Boot issues, firmware that's finicky about partition tables, 32- vs. 64-bit systems, etc.). Thus, depending on your needs, it might be better to plan on creating two or more bootable USB drives. Yes, that's more hassle to carry around and keep them straight -- but that hassle may be less than the hassle involved in navigating the mine field of quirks involved in creating a truly universal boot medium.
Answer: As far as i know, there is NO possibility of having 2 partitioning schemes on the same data storing device. Either MBR or GPT, BUT NOT BOTH at the same time. GPT is an evolution of MBR, but they enumerate data blocks a bit different which is leading to misunderstanding where the partitions are starting and where are ending on the disk. GPT is better because it automatically creates a backup of the partition table at the end of the disk.
I personally use two USB sticks: one with MBR, the other with GPT. Some people say that a GPT Ubuntu can boot in BIOS mode. That may be truth, but when installing it to internal drive in BIOS/MBR mode, you will be having BIG trouble with the GRUB not installing correctly, and thus not being able to run the Ubuntu from the hard-drive.
So, you can run it any way you want, but you can't install correctly any way you want. Install from GPT medium to another GPT medium, and from BIOS medium to another BIOS medium. Don't mix them up!

MBR and GPT pointing to same OS?


How can I use mean normalization. Should I use it for numerical columns or categorical columns as well?

Question: Should we normalize the categorical columns in our dataset? Or just the numerical columns?
Comment: What exactly do you mean by 'normalize categorical columns'?
Comment: I mean after encoding the categorical variables using Target encoding, can we use mean normalization? And would it be useful?
Answer: Normalization and standardization are transformations that can only be applied on metric variables. You cannot normalize categorical variables.
Either you label-encode your data or you one-hot-encode it, depending on the algorithm you use. That's all you do with it.
Comment: If we one-hot or target encode the categorical variables, will standardization or normalization help the model? Or I can simply not apply any sort of scaling and algorithm works fine anyway?
Comment: Normalization projects your values into the range between 0 and 1. If you one-hot-encode them, they are already either 0 or 1. Also, these transformations do not make any sense at all with categorical variables. For example, to standardize a column, you have to substract the mean from each value and divide it by the standard deviation of the column. Assume, you try to standardize the categorical column "animals" that holds values like "cat", "dog", "horse", etc. I hope it is clear, that such a column cannot have a mean or a standard deviation.
Answer:
I mean after encoding the categorical variables using Target encoding, can we use mean normalization? And would it be useful?

I think it depends. A priori I'm inclined to think this doesn't make any sense, but let's think about it. You are encoding each value with a number which is somewhat related to the target. In what range do these numbers live? Now, I think the main way to answer the question is by inspecting the following question:

What is the purpose of normalization?

There are algorithms which can understand greater values have greater meaning, and by simply having features with different ranges prevents the algorithm to perform well. Here it seems like it would make sense to normalize.
Here, Urvashi Jaitley explains that without normalization,

gradients may end up taking a long time and can oscillate back and forth and take a long time before it can finally find its way to the global/local minimum. To overcome the model learning problem, we normalize the data.

After thinking a bit about this, although it didn't make much sense to me at the beginning, I now think normalization would apply in this case too.
As of the comment on @georg_un's answer:

If we one-hot or target encode the categorical variables, will standardization or normalization help the model? Or I can simply not apply any sort of scaling and algorithm works fine anyway?

If you one hot encode the variables, the values will be either 0 or 1. Here it really doesn't make sense to normalize. What you want is a binary variable to indicate something as either yes or no. You don't want grays there.
Hope this helps!