Add notification to mpv through notify.send?

Question: Is it possible to generate a brief notification every time mpv starts a playback? Maybe through notify-send?
Answer: mpv can run lua user scripts, some of which are listed here. One of these, notify will generate a sophisticated notify-send. It has a few dependencies, and I wasn't able to get it to work in my setup, but the followed greatly simplified code worked for me. Place this file in
~/.config/mpv/scripts/mynotify.lua (create the directory if needed), and run mpv as usual. You should see a notification when the artist or title changes.
-- based on https://github.com/rohieb/mpv-notify
-- https://unix.stackexchange.com/a/455198/119298
lastcommand = nil
function string.shellescape(str)
   return "'"..string.gsub(str, "'", "'\"'\"'").."'"
end
function do_notify(a,b)
   local command = ("notify-send -a mpv -- %s %s"):format(a:shellescape(),
                                                          b:shellescape())
   if command ~= lastcommand then
      os.execute(command)
      lastcommand = command
   end
end
function notify_current_track()
   data = mp.get_property_native("metadata")
   if data then
      local artist = (data["ARTIST"] or data["artist"] or " ")
      local title = (data["TITLE"] or data["title"] or " ")
      if artist..title~="  " then
         do_notify(artist, title)
         return
      end
   end
   local data = mp.get_property("path")
   if data then
      local file = data:gsub("^.-([^/]+)$","%1")
      file = file:gsub("%....$","") -- delete 3 char suffix
      local dir = data:gsub("^.-([^/]+)/[^/]*$","%1")
      do_notify(dir, file)
   end
end

mp.register_event("file-loaded", notify_current_track)

This updated version waits for events that are sent when a new file is ready to be played. It tries to find the metadata and extract the artist and title from it. If this is empty, it then gets the current filename ("path") and splits out the last part after / to get a filename, from which it removes any trailing 3 character suffix. It tries to find the last directory part of the filename, and uses these 2 items in the notification. If your directories are structured with say, artist/albumname/tracktitle.aac, you might like to change this with a more appropriate pattern match and extraction.  See the lua section on patterns.
Comment: I've updated the answer to cope with no metadata and some simple filename parsing. You should probably accept this answer and move on to a new question for help on lua.
Comment: yeah, i could't make `notify` to work either, that's why i'm asking. I tried your script but i got this error: `[mynotify] Lua error: /home/user/.config/mpv/scripts/mynotify.lua:5: bad argument #1 to 'gsub' (string expected, got nil)`
Comment: As I said, it is greatly simplified. For example, your metadata may not have an artist or title, so you will get an error. I've changed the answer to not crash in this case, or if the keyword is in uppercase, but you may then get notifications with no text. You need to add whatever metadata keys are of interest to you, and exist in your files. I just had some simple id3 tags for mp3 audio files.
Comment: thanks!, I don't think my files have metadata, because they are all aac files. is it possible to modify your script to show only the filenames?
Answer: mpv has an event hook library, libmpv. There's a issue asking for essentially the same thing here titled: libmpv event hooking in C# #3810.
There's a comment on that issue with a screenshot:

From looking this thread it looks like mpv is at least somewhat capable of doing what you want. I believe you'll have to write some code though to implement what you want.
Exploring D-Bus
The other way to approach this on the off chance that mpv is already sending message via D-Bus is to use the cli tool dbus-monitor. With this tool you'll be able to catch all the events being logged, and perhaps you'll be able to catch ones coming from mpv.
$ sudo dbus-monitor --system

NOTE: mpv is a fork of mplayer2 and I know mplayer2 does utilize D-Bus so I would expect mpv to do the same.
References

https://github.com/mpv-player/mpv/tree/master/libmpv
https://github.com/mpv-player/mpv
Exploring D-Bus


Skip one onblur function

Question: I have problem with skipping one of two onblur functions. I have control with two onblur functions and in some conditions I have to skip first onblur function. The second function was added with jquery. I can not change the first onblur function, only skip. Is there some way to do this?
Sorry my english.
Answer: If the jquery event is added after the initial onblur event, you could call event.stopPropagation or event.stopImmediatePropagation to cancel event propagation depending on the structure when skip conditions are met.

Skip one onblur function


Pathfinder Hero Point combined with Ki Pool and Two Weapon Fighting feat

Question: Our DM is using the Hero Points optional rule where I can spend one point to make an additional attack.
My Ninja can spend one from his Ki Pool to make an additional attack.
At level one I took the Two Weapon Fighting feat.
Can I combine all three sources to make four attacks at level one? How many would be at -2 given that both weapons are Wakisashi?
Comment: @V2Blast This isn't really about the Two-Weapon Fighting feat—note you can use the two-weapon fighting combat option without the feat, and it has the same effects and the penalties apply in the same places, they're just bigger. Personally I don't really think [[tag:feats]] fits.
Comment: @KRyan: Fair enough! Feel free to revert my edit if you feel the tag is inappropriate.
Answer: The official hero points optional rule does not actually have an option for an extra attack—instead, a hero point may be expended for an entire extra standard action, which is quite a lot better. You can use that standard action for an attack, but you could also use it for other things.
The ki pool feature allows a ninja to expend a ki point for 1 extra attack at their highest BAB during a full-attack. There is no penalty associated with this.
The two-weapon fighting combat option allows you to make one extra attack with an "offhand" weapon, in exchange for a penalty on all attack rolls during that full-attack. The size of the penalty depends on whether or not the offhand weapon is light (the wakizashi is) and whether or not you have the Two-Weapon Fighting feat (you do). In this case, the penalty is −2.
And, of course, you start with a single attack by default.
That means you can make a full-attack, expending a ki point and using two-weapon fighting, to attack three times, all at −2. Two of those attacks must be with separate weapons; the third can be a second attack with either of them (or an attack with a third weapon if you really wanted to like kick or use armor spikes or something like that). After those attacks are finished, you can spend a hero point to get another standard action: you can use that to attack. Since it's not part of the full-attack where you used two-weapon fighting, it does not take the −2 penalty, and is just made at your ordinary attack bonus.
Comment: I would bold **extra standard action** and **a lot better**. Great answer.


Where can I find the warp whistle in Mario 3?

Question: I have spent a lot of time looking for the warp whistle but I'm starting to think that my game is broken. I used to know how to get it but now Mario doesn't fall through this white block thing anymore which is the only thing I still remember.
Answer: There are 3 Warp Whistles in Super Mario Bros. 3.
The first warp whistle is gotten in stage 1-3 by hopping on the white block, then pressing down for several seconds to drop into the background, then running all the way to the end of the stage.  Be aware that you need to hurry as this effect does wear off.
The second warp whistle is in World 1 Fortress.  You need the Raccoon Leaf to get this one... At the end of the first area, instead of going through the door, stomp the dry bones then run from the far right side to the edge to build up speed so you can fly.  Fly up and to the right.  You'll land on a hidden ledge above the wall.  Run to the right and then press up to enter a hidden door with a chest with the warp whistle in it.  Note: This completes the fortress, but doesn't remove its door on the map.
The third warp whistle is on the World 2 overworld.  You need to get a Hammer by defeating one of the Hammer Bros. sets wandering around the map.  Once you have it, go near the rock in the upper-right corner of the map and use the Hammer.  It will break the block.  Behind the block is a wandering Hammer Bros (Fire Bros. specifically).  Beat them to get the third whistle.
However, you only need two whistles to get to World 8...
Comment: And by door, I mean the one south of stage 1-1.  These doors are used to continue more quickly if you lose all your lives as all the levels you completed are reset on death.
Answer: You're talking about Stage 3 in World 1.  Close to the end of that stage, you'll see a white block, like this one:

Holding down on it for 5 seconds will drop you through it, and you'll be in the "background".  You can still get hit, though, so be careful!
Once you're in the background, run to the end of the level, and "behind" the black border.  It will teleport you into a secret room with a chest that has the Warp Whistle.
Comment: Was there some kind of in-game hint or clue that would make it possible for a player to know that this is possible?
Comment: @christopherdrum no.
Answer: Original: Also according to the letter in W6 it says that there is a whistle in W3 (that is the water world).I didn't take time to find it because I am too lazy but I guess it has something to do with the boat...
Also I think I remember watching a video with a warp whistle and it was different from the well known ones.
This adds up to five warp whistles if the two I was talking about were unique
Edit: So in the NES version it says W3 but actually it meant level 3 in world 1 (I played Super Mario Advance 4 to find that out) which was already covered and the video I was talking about was the secret box glitch which only works in the Japanese version. Here is the video

 So really including glitches you can get 4 warp whistles.
Comment: Please provide evidence for the existing warp whistles, like a link to the video. In it's current form the answer is just speculation and not helpful.
Comment: Ok I found the video and edited it a bit.


Can I drink beer on the paleo diet?

Question: I'm pretty sure it's all in the question. Let's assume I'm talking about the standard kind of beer, you know, the kind I can buy in a pub (as you can tell, I don't know much about beer).
Comment: From the FAQ: on-topic includes "nutrition as it relates to exercise" and off-topic includes "nutrition unrelated to exercise, such as food safety, nutritional needs for children". To that list I would add, "what foods are Paleo".
Comment: @DaveLiepmann I think I joined the wrong SE then, and I apologize. Unfortunately, this SE seems to be the only that even remotely matches the concept of a place where I can ask questions on diets.. I guess I'm off to the meta again, huh..
Comment: Have you tried http://paleohacks.com/ ?
Answer: The Paleo framework starts from the perspective that most people will find that grains, legumes, dairy, being anti-social, getting no sunlight or exercise, and eating too many carbs for their exercise level will be problematic, for genetic and epigenetic reasons.
That being said, here's the Paleo test at its most bare:
<code> Does it cause you gastrointestinal distress? Are you sure?
</code>
That's really it.
Try abstaining from grains (like beer), legumes and dairy for thirty days. Then re-introduce these items one by one, and gauge your response. People are different. Some people can handle these items better than others.

Can I drink beer on the paleo diet?


Norm of a function, Smoothness Penalization

Question: I am seeking for some intuition why norm (for any reasonable norm on functions) of a function is smaller if the function is smoother.
Answer: Norms may not necessarily be related smoothness in any way.
The uniform norm $\|f\|_u=\sup_{x \in [0,1]} |f(x)|$ on the space of continuous functions $C[0,1]$ is unrelated to smoothness. There are nowhere differential functions of arbitrarily small uniform norm.
But on the space of $L_2[0,1]$ absolutely continuous functions the norm $\|f\|=\int_0^1|f(t)| \ dt+\int_0^1 |f'(t)| \ dt$ does measure smoothness in some sense.
Answer: spitespike gave a good explanation already, but here is a another point of view.
Suppose $\|\cdot\|$ is a translation-invariant norm on some space of functions on $\mathbb R$. Translation-invariant means $\|f\|=\|f(\cdot-h)\|$ for all $h\in\mathbb R$. Consider the convolution $f*\varphi$ with some mollifier $\varphi$. In functional terms, this is a weighted average of translates of $f$. By assumption, all of these translates belong to the closed ball of radius $\|f\|$. Therefore, the average is in this ball as well:
$$\|f*\varphi\| \le \|f\|  \tag1$$
We see that making $f$ smoother does not increase its norm. If the norm is strictly convex, then strict inequality holds in (1).


how to set the cell background color baced on the cell value in jqgrid?

Question: I'm using jqgrid. I need to set background color of the cell based on the values.
I have tried  using the following code after reload the table the color is disabled.

jQuery("#list").setCell
  ('5','5','t',{background:'#ff0000'});

I want to set the cell background color on table loading, based on the cell values.
how to do this?
Thanks in advance.
Answer: You can do this in many ways: see this, this or this. Important is not only how you do this, but where. The loadComplete event handle is the good place for that.
UPDATED: In the next version of jqGrid you will able to use new cellattr option as function in the colModel. See this demo and my original suggestion.
Answer: To use the cellattr functionality with the asp.net library of jqGrid, add this to your column.  I can't find this documented well anywhere else online...
<Formatter>
    <trirand:CustomFormatter SetAttributesFunction="clientSideFunctionName" />
</Formatter>

And Thank Oleg for the awesome addition to jqGrid :)


httpd24 by scl doesn't render php

Question: I have installed httpd24 with php72 by scl in a CentOS 6.10 x86-64 environment. But Apache doesn't render php files and display them as text.
Installed php using,
yum install php72-php php72-php-iconv php72-php-mbstring php72-php-curl php72-php-openssl php72-php-tokenizer php72-php-xmlrpc php72-php-soap php72-php-ctype php72-php-zip php72-php-gd php72-php-simplexml php72-php-spl php72-php-pcre php72-php-dom php72-php-xml php72-php-xml php72-php-intl php72-php-json php72-php-mysqlnd php72-php-ldap

When I run,
apachectl -M | grep php

Output:

php7_module (shared)

When I run,
php -v

Output:

PHP 7.2.14 (cli) (built: Jan 8 2019 11:55:37) ( NTS )
  Copyright (c) 1997-2018 The PHP Group
  Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

There was no php72-php.conf file created in /opt/rh/httpd24/root/etc/httpd/conf.d/ at the time of php72 installation. The php72-php.conf file was created in /etc/httpd/conf.d/ instead.
When I try to manually copy the php72-php.conf file to /opt/rh/httpd24/root/etc/httpd/conf.d/, it won't allow me to restart httpd24-httpd service and gives the below error;

Stopping httpd:    [  OK  ]
  Starting httpd: httpd: Syntax error on line 353 of /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf : Syntax error on line 9 of /opt/rh/httpd24/root/etc/httpd/conf.d/php72-php.conf : Cannot load modules/libphp72.so into server: /opt/rh/httpd24/root/etc/httpd/modules/libphp72.so: undefined symbol: unixd_config    [FAILED]
Answer: I was having the same issue, and this was the solution:
yum install php-fpm

httpd24 by scl doesn't render php


Word for a group of similar photos?

Question: Is there a single word or phrase that means a group of very similar photos, such as when a photographer takes a burst of 7-8 shots with the hope of catching the right instant, or to get the best focus?
Answer: I think you are referring to a sequence of photos:

Sequence photography is the technique of combining different shots of the same subject to present its course of action in a final single image. Capturing a subject in motion will provide you with images which, basically, have the subject at different moments of its movement throughout the frame, usually with the same background (in the case of the most popular type, where the camera is fixed but the subject moves).

Source:http://www.photopoly.net/how-to-create-sequence-photos/
Comment: Works for me Josh! +1
Comment: good one .. that's what you'd say on a shoot, etc. (Indeed you'd just say "this burst ..." if you were referring to them while editing or whatever. but I suppose that's a sequence, if for some reason you don't want to say burst.) Here's the original burst photographer! http://en.wikipedia.org/wiki/Étienne-Jules_Marey
Comment: My first thought was **set**, which is along these lines.
Comment: Your answer sounds right but your link describes and depicts something quite different than what the OP asked for.  The picture in your link shows a single background and multiple images of a skier (or snowboarder) splayed across that single background.  The OP's question is asking for the technique where multiple pictures are taken *"with the hope of catching the right instant, or to get the best focus"*
Comment: @KristinaLopez - The picture with the single background and multiple images is actually a representation of a sequence of photos  as described in the text. The sequence is in just one picture to obtain a stronger effect. But it is just the photo technique OP is referring to.
Answer: Burst or Continuous Shooting
From Digital Photography Review:

Burst or Continuous Shooting mode is the digital camera's ability to take several shots immediately one after another, similar to a film SLR camera with a motorwind.
Answer:
a burst of 7-8 shots

"Burst" is the correct term of art. You'll see some cameras have a feature called "burst mode." Instead of shooting just one shot of one setup, you shoot a burst of shots of one setup, and then later pick the best out of the burst. A burst of 7–8 shots might be taken in only 1–2 seconds. Instead of tapping the shutter just once for a single photograph, the photographer holds it down just once and shoots a burst.
A "sequence" is bigger than a burst. A sequence implies each photo had some thought behind it. A sequence of 7–8 shots might be taken over 15–30 seconds.
Larger than that would be a "gallery" — a gallery of 7–8 shots might be taken over the course of an hour or a day.
Comment: right - if he literally means a sequence which is a burst, then it's a burst.  (I guess a bracketed burst, as Erik mentions, is also a burst.)  i feel FWIW you wouldn't use "gallery", you'd indeed just refer to the "shoot" for the overall, well, shoot: everything taken on one day.
Answer: Photographers often bracket their shots to maximize their likelihood of obtaining the optimal exposure:

transitive verb
4 c :  to take photographs of at more than one exposure in order to ensure that the desired exposure is obtained

The related noun is also bracket:

4 :  a section of a continuously numbered or graded series (as age ranges or income levels)

(Definitions from Merriam-Webster.com)
Answer: Compendium might be what you're looking for:

a collection of things, esp. one systematically gathered

Word for a group of similar photos?


Security consequences of disabling CURLOPT_SSL_VERIFYHOST (libcurl/openssl)

Question: What are the security consequences of Enabling CURLOPT_SSL_VERIFYPEER and Disabling CURLOPT_SSL_VERIFYHOST?
Answer:
CURLOPT_SSL_VERIFYPEER checks that the remote certificate is valid, i.e. that you trust that it was issued by a CA you trust and that it's genuine.
CURLOPT_SSL_VERIFYHOST checks that the cert was issued to the entity you wanted to talk to.

To compare it to a real-life scenario, VERIFYPEER is like checking that the form of ID is one that you recognise (i.e. passport from a country you trust, staff card from a company you know, ...). VERIFYHOST is like checking the actual name on the card matches who you wanted to talk to.
If you don't use VERIFYHOST (the correct value is 2, not 1, btw), you disable host name verification and open the door to MITM attacks: anyone with a form of ID you trust can impersonate anyone within the set of IDs you trust, e.g. anyone with a valid passport could pretend they're anyone else with a valid passport.
Comment: Thank you for elaborated answer. This lead me to another quick questions: I got a website with a valid SSL certificate
https ://www.example.com (cn=www.example.com as it should). When I visit the website via it's IP address, it will show me cert errors (because the cn don't match), removing the SSL_VERIFYHOST will solve it, but will open it up to MiTM attacks.
 What is the correct solution to handle this? (allow connecting via IP address WITHOUT showing errors). Replacing the entire validation method using CURLOPT_SSL_CTX_FUNCTION only to verify that a specific IP address matches a CN?
Comment: Why would you want to connect with the IP address? It it a certificate from your own CA (or self-signed)?
Comment: I have 2 servers (22.214.171.124 and 184.108.40.206), the DNS for example.com contains 2 A records (of those ip addresses). The client randomly choose one of them and connect to the IP address and not the hostname. I would like openSSL to call me when it checks the common name field so i can compare the certificate common name with example.com, if it's okay, i will accept the certificate. I haven't seen that libcurl supports that so i assume i have to write my own implementation. The certificate for example.com is a trusted Verisign cert.


Loose spokes after truing a wheel

Question: I badly bent my rim going down a huge hill and bouncing all over the trail. I've managed to get the wheel much more true to the point where the wheel is ridable. However, due to the extent of the bend, the spokes on one side are really right and some on the other side really loose. There's still some buckle so I'd need to tighten up the tight spokes more to remove the buckle fully. Does the wheel need a few casual rides to allow the rim to move?
Comment: Is the rim stil centred? Does it need to be? (with disk brakes you can probably move it a mm away from the tight side) How are you measuring spoke tension?
Answer: Jobst Brandt's The Bicycle Wheel tells about repairing this failure mode in the following way:

In a soft failure the rim has a smooth and continuous bend, and some of the
spokes have become loose. If the wheel is deformed laterally more than ten
millimeters, all nipples, even on spokes that have no tension, should be
unscrewed two turns before attempting to straighten the wheel. Straightening
the rim by bending it without first unscrewing the nipples would, in effect,
straighten and tension the wheel at the same time. Straightening makes the rim
yield and take a new shape. When yielding, it will deform not only in response
to the straightening forces, but also to the spoke tensioning forces. If the nipples
are not unscrewed, the combined forces would cause kinks in the rim at each
spoke.
To repair such a bent or collapsed wheel, first loosen all nipples about two turns
(one turn if the wheel was loosely spoked). Lay the wheel on its side with the
largest wave toward the floor and press down on the rim on either side of the
bend. If necessary, repeat this process turning the wheel over until the rim is
reasonably straight. Now place the wheel in the truing stand for tensioning and
truing. If the misalignment is still more than ten millimeters, repeat the
procedure on the floor while gradually tensioning the spokes. Now the wheel
can be trued as previously described. Because straightened rims usually have
nonuniform spoke tension, the wheel may not stay true.

I suppose you didn't follow that procedure but rather trued the wheel in a truing stand only? Loosen the nipples as directed, straighten the rim and retension and re-true.
Answer: A rim which is not straight when at rest, will result in uneven spoke tension after it's trued. This is always the case, because no rim is perfectly straight.
If the rim is only slightly bent (the 10mm figure sounds reasonable), then the resulting un-evenness in the spoke tension will be moderate and tolerable. But if the rim is excessively bent, or if it's very stout (such as some BMX rims), then it will not be possible to true it without excessively uneven spoke tension. The rim should be straightened or discarded.

Loose spokes after truing a wheel


Why nephrotic syndrome does not present with haematuria?

Question: As we know that nephrotic syndrome is characteristically present with proteinuria and on the other hand haematuria is seen in nephritic syndrome. Defect/loss of podocytes in nephrotic syndrome leads to escape of proteins , so why don't RBC's escape with the proteins?
Answer: If you remember the structure of the glomerulus there are three barriers that regulate the filtration process: the first barrier is endothelial cells which has spaces between them that allow the passage of molecules of certain size, and among the molecules these spaces allow to pass are proteins (Ig, albumin,different transportation proteins, etc...) but such spaces are so small (70-80 nm at maximum) and do not allow red cells to pass (diameter between 6-8 micrometeres which is much bigger than 80 nanometers).
(https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2681366/)
The second barrier is the basement membrane which also do not allow large structures like different cells in the blood to pass but allow small molecules to pass.
Remember that glomerular filtration is not governed only by size of molecules, but the charge of the molecules play a role, for example the basement membrane is negatively charged which leads to repulsion of molecules with negative charges like albumin and do not allow them to pass. If i am not mistaken the podocytes also contribute to the regulation of charge in basement membrane and problems in podocytes could lead to alteration in charge in basement membrane which could contribute to albumin passage into tubules. (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2895306/)
And the third barrier is the podocytes which produce the basement membrane among the other functions that they have. The podocytes also regulate filtration by contracting and restricting spaces between their foot processes which leads to decrease in filtration.
(https://academic.oup.com/jes/article/4/4/bvaa029/5781251)
Podocytes allow micromolecules to pass like electrolytes and glucose, drugs, etc... through the spaces between their foot process (called slit pore) but do not allow macromolecules to pass like albumin (although a very small quantity can pass but majority do not).
(https://www.hindawi.com/journals/ijn/2012/481520/)
As you can see even if there is an abnormality in podocytes at maximum it will allow macromolecules to pass like albumin, because larger structures like red cells will be blocked by endothelial cells and basement membrane before they even reach the podocytes level.
Comment: Thanks a lot


Error while setting up windows in my late 2014 iMac

Question: Boot Camp Assistance is stuck on create a partition? So I used the procedures in this link to try and set up windows in my iMac , but when it reached the part where they asked where do you want install Windows and after I select BOOT CAMP, I got an error - " We couldn't create a new partition or locate an existing one."
Comment: I don't have a way out of the pickle you find yourself in but you have two system & EFI partitions on your Mac, where you should have one each. You also have three primary partitions (where macOS and Windows would go) And you may be over the number of partitions possible for a working BootCamp installation, which would be the reason for the error. Other than deleting all of those partitions and starting over from scratch (assuming you have a backup of what is already there) I am unsure how to help you get out of this pickle.
Comment: @SteveChambers: There are two drives in the image. Each has a single System (EFI) partition. This is not unusual. There is a primary partition on each drive for possibly a macOS fusion arrangement. The primary partition labeled `BOOTCAMP` and recovery partition labeled `Recovery` are for Windows. I never understood why users post that they do not know the answer, but the solution should be to start over.
Answer: The difference is you are trying to install to the second HDD or SSD. The link you gave is for installing to a Mac with a single internal HDD or SSD. The Windows installer GUI is not equipped to handle your situation. One possible alternative would be to use the CLI to install Windows.

Note: I am using the Windows 10 20H2 English 64 bit version. In other words. the Windows 10 October 2020 update.

Starting from the window posted as an image in your question, proceed as follows.

Click on the red X to close the window. In the popup window, click on the Yes button.

Enter the following commands to start diskpart and get a list of volumes.
diskpart
list volume

Assign a drive letter P to the flash drive. In the first command given below, replace the # symbol with the volume number for the flash drive given in the previous step.
select volume #
assign letter=p

Assign drive letters to the EFI and Windows partitions.
select disk 1
setect partition 1
assign letter=s
select partition 3
assign letter=w

Enter the following command to quit diskpart.
exit

This command applies the Windows image to the desired partition.
dism /apply-image /imagefile:p:\sources\install.wim /name:"Windows 10 Pro" /applydir:w:\ /checkintegrity

Note: If you do not what Windows 10 Pro and do not know the desired name, then you can get a list of available names by entering the following command.
dism /get-imageinfo /imagefile:p:\sources\install.wim

This command copies the drivers provided by Apple to the drivers store.
dism /image:w:\ /add-driver /driver:p:\$WinPEDriver$ /recurse /forceunsigned

Note: This step searches for .inf files. If a found .inf file does not result in a driver being properly copied to the driver store, then an error message may be generated. You can ignore such messages. For example, some drivers can only be installed after Windows has finished installing.

Create the boot files. The command below installs for US English.
bcdboot w:\windows /l en-us /s s: /f uefi

Close the command prompt window and select to Turn off your PC. In other words, shutdown the Mac.
exit

Start the Mac and continue with the installation of Windows. If you boot to macOS, then select Windows from the Startup Disk pane of the System Preferences application.

When finished installing Windows, install the Windows Support Software provided by Apple. Look for the Setup application in the BootCamp folder on the flash drive.

From Windows, run the Apple Software Update application to get any Boot Camp and other software updates from Apple.

Updating AMD graphics drivers for Windows in Boot Camp
Apple has a website Update AMD graphics drivers for Windows in Boot Camp which provides a link to the AMD website homepage. Clicking on Drivers and Support takes you to a webpage where there is a Download Now button which will download software to "Auto-Detect and Install Radeon™ Graphics Drivers for Windows®". You can also select your product from the list. According to everymac your late 2014 iMac has a Radeon R9 M290X dedicated video processor. Going though the list took me to the AMD Radeon™ R9 M290X Drivers & Support webpage. For the "Windows 10 - 64-Bit Edition", there is a download under the title "Auto-Detect and Install". This download is the same as the one found on the Drivers and Support webpage. There are also various versions of the drivers you could download and try.
Comment: I successfully installed windows 10 using those steps, but it terribly slow, don't judge me but, I tried running Rocket League on it and it seemed like it was running at 1 Hz refresh rate..
Comment: I updated my answer to include how to update the graphics driver. Let me know if this helps.
Comment: so I downloaded the driver and installed it but I got an error from that software "Error 173- Radeon Software install cannot proceed as no AMD graphics hardware has been detected in your system configuration". Is there a fix for this?


Do EEPROMs lose their data over time?

Question: For example 8x8 small image stored on eeprom will get corrupt over time?
I've seen somewhere eeproms losing their data over time like vhs tapes.
Comment: All data storage systems degrade with time. This is part of thermodynamics (entropy is always increased). Eventually, in billions of years when the universe experiences thermodynamic heat death, there will be no data storage of any kind left intact. But EEPROM is not bad for small amounts of data that must be stored for decades. I think it would be my first choice for high reliability on-board non-volatile memory (in a consumer device).
Comment: Look up their "data retention time." The answer is yes, they lose their data. But for different reasons than VHS tapes.
Comment: They don't change randomly, the bits eventually all become 1s or 0s depending on the technology.
Comment: Here is another way to say it. EEPROM will most likely not corrupt data until after you are dead and don't care anymore. But if you are going to expose it to very extreme conditions such as very high temperatures, corrosive atmosphere, etc, then it may fail prematurely.
Comment: even eeprom not used it is going to forget or slowly data inside get garbled like if i write text like test after a time test text will be t4jt?
Comment: but if system used frequently which had eeprom inside and system heats to up 100 Celcius will it damage in near time
Comment: @TRGamerTR based on Spehro's answer I would say yes, at 100C memory loss may be very premature.
Answer: Yes, they are based on a stupidly tiny charge on a floating gate, so eventually they will lose their memory.
The time is generally pretty long under benign conditions (seldom, if ever, re-written, cool temperatures, no significant ionizing radiation).

If any of those things are not true, the life can be significantly foreshortened. For example, at high temperatures rule of thumb is half for every 10°C (not sure this is 100% valid for EEPROM cells, but let's use it here).. so that 100  years becomes 50  years at 35°C, 25 years at 45°C, 12.5 years at 55°C and so on.. so at the maximum storage temperature of 150°C the retention might be less than a week.
Similarly, a badly written or errant program can quickly exceed the lifetime 10^6 erase/write cycles in a matter of hours.
I believe there is some interaction between the two- many write cycles negatively impact the retention time.
Comment: @quetzalcoatl  It's a figure of speech. The capacitance (fF) number of coulombs (or even electrons) is so small to be far outside of normal experience for non-IC designers.
Comment: It is good to remember that these 100's of years are an estimate. The technology simply didn't exist for that long yet.
Comment: Why 'stupidly'?
Comment: @fraxinus Certainly, they were introduced around 1980, not in some dark pre-historic time. Although barely 40  years has passed, I've personally seen a number of EEPROM failures, most of which "bricked" the  product.
Comment: Personally, I believe this is a significant threat to digital preservation. EEPROM is a time bomb of the digital (dark) age, the number is only a projected lifetime. How long will today's technology last in the wild is still largely untested. Imagine when a future archeologist wants to download data from a HDD made in 2010, only to find that its firmware and parameters in a EEPROM are gone, permanently bricking the electronics, even when the platters, motors and the head are good. The transition to NAND flash only made the problem worse.
Comment: Does the lifetime get "refreshed" if the EEPROM is powered up?
Answer: You can find a datasheet for the EEPROM you want to use.  I looked at one for a 24LC64 (from Microchip) and it said data retention was greater than 200 years.  So, yes, they don't hold data forever, but may be good enough for your use.
Answer: There are several methods to manufacture an EEPROM, and I mention this only because most of the time when people see "EEPROM", it can be just about anything.  Generally speaking, the architecture depends greatly on what they will be used for. For all cases, it's a variation on the floating-gate MOSFET You have a very little amount of charge on NOR and NAND-based storage for SSDs, but you will have larger capacitors for industrial applications where you care about data integrity.  Fundamentally, this is a function of the sense amplifier structure and how much charge it takes to flip the bits.  I would put my ICs in an oven at 200C to simulate aging and look at charge loss.  Generally, we saw no charge loss due to the gates, but possible offsets due to shallow charge trapped in the oxides.
Here's a summary of how you make floating gates:

Analog-based that are programmed with injection and tunneling
Differential.  This uses two different floating gates to store a value, so one is high and one is low.  TI uses this to store information on non-FLASH processes.
SONOS The charge is trapped in the oxide.  This works well for space.
NOR/NAND.  This has excellent charge density, but is a special manufacturing process.

For all of these, you test them by putting them in an oven and watching the drift over time.  The NOR/NAND is the worst because it's driven by density so that there is very little charge.  Everything else pretty much will hold charge effectively forever.  One needs to also keep in mind that changing the state can be destructive, depending on how you do it.
physics warning: If you are "tunneling", this is a quantum process and this is effectively safe for infinite cycles as you do not have enough energy to move a hole.  If you are using hot electron injection, there's a probability that you will eventually have an energy state that high enough to move a hole, and you'll throw an atom into oxide.  If you are careful, ie: not in a hurry, you can effectively have infinite programming cycles.  The oxides will fill with shallow traps of charge to make a bias, but if you have a large enough capacitor, you'll not have any issues with offsets.
Answer: Other answer have covered the basic risk of corruption on EEPROMs, but this only relates to the hardware.  EEPROMs have to be read by software though, and software often has recovery strategies to detect errors in EEPROM data.
If the software provides error recovery, the user may not ever see corruption.  If the error is recoverable (and by design this will be the case for most errors), the software will detect the corruption, recover from it, and report the corrected data to the user.  The software will typically also rewrite the data on the EEPROM to ensure it remains correct going forwards.  The result is that even though corruption is very likely occur sometime over the EEPROM's lifespan, the chances of corruption occurring over the EEPROM's lifespan which cannot be corrected are very, very low.
If the software provides error detection (e.g. a checksum) but not error recovery though, the result may be all or nothing.  Corrupted files may be discarded entirely, instead of being made available and showing your "VHS tape" type of errors.  In this case, a change to just one bit in the image might result in the entire image being reported as unreadable.
Or of course the software may simply report the data as-is, in which case as previous answers say you may get some small amounts of corruption over time.

Do EEPROMs lose their data over time?


Embedding Office files into SharePoint pages

Question: Is it possible to embed Office documents into SharePoint publishing pages? This way the user doesn't have to open the file; its contents display inline on the page or in an iframe. The files will be stored in a local SharePoint 2010 library (not on the Internet). Thanks.
Answer: Use an iframe with the URL to the Office Web Apps page. For instance use the Page Viewer Web Part.
Comment: Thanks, Wictor. We can't publish the documents outside of the organization; they must remain on the intranet (even though they'd be in a private cloud with Office Web Apps). Any solution in this scenario?
Comment: Added another answer with a different approach.
Answer: Another option is to use Word Automation services and create an HTML version of each document. These HTML files could then be deployed to your appropriate environment.


disable tab-scrolling in Chrome/Chromium

Question: Is there a chrome/chromium build that addresses the anti-feature discussed here, where making the mistake of scrolling while the cursor is over the tab bar has the effect of scrolling to random tabs? Specifically I'm interested in a build that reverts this behavior.
Answer: Works on ubuntu 20, chromium 93:

go to chrome://flags/#scrollable
to enable scrolling, set to defaults: "Tab Scrolling" and "Tab Scrolling Buttons"
to disable scrolling, enable: "Tab Scrolling" and "Tab Scrolling Buttons"
Restart chrome/chromium

Update 2022.02.25
It seems like they've renamed things (in chromium at least). Here are the new steps:

Navigate to chrome://flags/
In the search bar, search for "Scroll switches tab"
In the dropdown select, "Never"
Restart chromium
Comment: It feels like an eternity since I posted this question. Thank you so much!
Comment: As a bonus, since I've since switched to firefox. Here's the relevant setting in about:config for firefox: "toolkit.tabbox.switchByScrolling". Setting this to "false" will disable the same annoying behavior in firefox :)
Comment: I just used that in my firefox, thanks! Nice trade :)
Answer: You'll need to place your vote by starring an issue to fix this bug at https://bugs.chromium.org/p/chromium/issues/detail?id=680499. It wouldn't hurt if you found several more (or several hundred more) people to do the same. Once enough people star the issue, developers will get to work and get the option added so you can easily disable (or enable if you like) this functionality.


what is zen's attitude / teaching on keeping a journal?

Question: Not much more to elaborate than just the question. But the website is making me type more stuff. So here it is.
Comment: Keeping a journal to what purpose?
Comment: just to write down thoughts and explore them... no purpose really
Answer: There is no "Zen" attitude about anything. That in itself is not Zen. If someone keeps a journal, then someone keeps a journal. That's all it means, and it is neither good nor bad. It is just keeping a journal.
Answer: Zen is indescribable. Where do you get these thoughts like zen has some rules or attitudes towards anything you do apart from maybe sitting meditation?
Look most of the things we do in this world has not much point apart from the ideas and concepts we are creating in our minds. I don't see why journal keeping is any different unless you unsuccessfully try to write Zen everyday in your journal.
Let's take for example tea-making. It is done with great attention and care and sipped with great attention and care. Such a simple thing is a ceremony. So, you could also sit there and write a journal with focus and attention if you would like to. Why are you bothered about Zen? Throw it and write your journal.
Comment: wow. that really rings true.
Answer: It's not necessary.  In fact, it might even be an impediment.  Thoughts about your experience/practice have a pesky way of being wildly wrong.  Any idea or theorizing generally just gets in the way.  I remember working with one koan in particular that I was damn sure I had nailed down.  I began ruminating over it and extrapolated that experience into all sorts of crazy theories.  Sure enough, in the dokusan room my teacher told me that I was barking up the wrong tree.  With that, my entire theory crumbled into dust.
So no, a journal isn't necessary.  Not unless you want to laugh at yourself and your overwhelming stupidity somewhere down the road!  :)
Answer: When I was a novice monk in a monastic retreat at my temple in Taiwan, which lineage wise is Linji Chan although they embrace all forms of Buddhist practice, as well as modern methods and technology to propagate the Dharma, one of the activity was to keep a daily diary of our experiences. And generally I tend to have a lot to say just about everything that occurred as well as my personal thoughts, this was handed over to our teachers for feedback. My teacher thought it was good that I have a lot to say, maybe even a bit too much to say that it has become a stream of consciousness. I distinctly recall an acquaintance new to the Dharma that struggled badly to write anything down and end up doodling on the page. It was through this comparison that I realized I really did mature as a person through my practice. Good diaries were further shared on the notice board to benefit other participants.
Generally it can be wonderful to reflect on and share important special moments. It can cultivate a mind of gratitude, appreciation, good will and resolve. When you begin to cultivate yourself, your writing likewise show your personal refinement.
You can even find inspiration from seeing enlightened thoughts within your peers, their resolution to become better people and so forth. Our temple even publish diaries of young novice monks which are just wonderfully heart warming.
Answer: I think writing a journal is okay. I'm not so keen on the idea of comparing one's own writings to someone else's 'doodles' to bolster ideas of one's own maturity. Some people might be more confident in expressing themselves in other ways. The idea of using it to become a better person seems contrary to the spirit of Zen.


Will updating the kernel reset the phone memory?

Question: I updated my OnePlus One phone to the company-owned system, Oxygen OS. The battery now is miserable - it depletes within 5 hours. I am looking for a solution to fix that without wiping and reinstalling another OS. I read that installing a different kernel can solve such an issue. I flashed many ROMs on many devices previously, but never updated a kernel. What I will lose if I did it?  What is the best way to update the kernel?
Answer: If you're directly writing the kernel with fastboot then it shouldn't touch the user data.  If you're flashing it through recovery it should also be OK, but it's possible for the update.zip file to perform other actions that could wipe data.


How can I create a new site collection in another SharePoint farm

Question: I need to be able to create a new site collection from one SharePoint 2010 farm to another. I.e. the user fills out the forms associated in SharePoint Farm 1 and creates a site collection with the specified info in SharePoint Farm 2.
I have considered the following alternatives:

Using the Client Object Model (COM), but the highest available object is SPSite, and I need a SPWebApplication object to create a new site collection.
Using a built in SharePoint 2010 Web Service, but which one? Neither WebSvcAdmin, WebSvcSiteData, or WebSvcsites seems to be able to do this.
Implement a custom web service, but what about authentication?
Answer: You need to use SPWebApplicationBuilder class.
But instead of SPFarm.Local use SPFarm.Open(SqlConnectionStringBuilder connectionString, string user, string password)


If a Jew got testicular biopsy, can Jews marry him

Question: Testicular biopsy is when men get a portion of their testes removed to be scientifically tested, often for reproductive reasons. The Torah prohibits Jews having marriage with eunuchs, men with injured  genitals. So would a Jewish man who got testicular biopsy be fine to marry?
Comment: A biopsy removes a very small amount of tissue whereas a eunuch is castrated. Very different
Answer: The restriction is specific to males who have suffered an actual loss of reproductive organs. Even then, the restriction is not considered universally binding in all scenarios as such a Jew can marry others outside of the main marriage pool.

They may marry converts
They may marry women unable to have children themselves

If a man loses only a part or one of his testicles, he isn't restricted from marriage as long as he still has his reproductive capacity intact.
The fact is though this person would need to make the issue fully disclosed as part of the shidduch process so the woman is aware he may have reproductive issues. Losing a testicle may not make someone sterile but knowing that there was an issue may present more information to the woman deciding on a husband.
It would benefit a male in such a situation to seek out a reproductive screening to verify with medical records that he is still fit to produce children. That would go a long way in easing concerns regarding his injury.

דין פצוע דכא וכרות שפכה ובו יד סעיפים: פצוע דכא וכרות שפכה אסורים לישא
ישראלית ומותרים בגיורת ומשוחררת ואפילו כהן שהוא פצוע דכא מותר לישא
גיורת ומשוחררת לפי שאינו בקדושתו ואפילו נתינה או אחד מהספקות מותרת לו
הואיל ופצוע דכא אסור לבא בקהל לא גזרו על הנתינים ולא על הספיקות אבל
אסור בממזרת ודאית שהרי אסורה מן התורה ויש מתירים אפי' בממזרת (טור
והראב"ד והרשב"א):
A petzua daka and a krus shafcha [each of these are categories of males with reproductive losses/problems] are prohibited to marry a jewess, and
permitted with a convertess and a freedwoman. And even a priest who is
a petzua daka is permitted to marry a convertess and a freedwoman,
since he is not in his sanctity. And even a nesina or one of the
questionables are permitted to him; since a petzua daka is forbidden
to enter the congregation, they did not decree on him regarding
nesin's nor regarding questionables. However, he is forbidden in an
unquestionable bastardess, for behold she is forbidden from the Torah.
And some permit even a bastardess. (Tur, and Raavad, and Rashba)

Shulchan Aruch in Ever Ha'Ezer 5
Comment: +1 Worth noting that if the person who became a saris did so because of illness, then this is not considered "human action" according to Rambam and most Rishonim, and this is the halacha (Yam Shel Shlomo; Mishkenot Yaakov; Birkei Yosef; Pitchei Teshuva 5:7; Maharsham; AHS 5:18), in which case this might not apply. CYLOR.


SOM automated/objective clustering

Question: So as I understand it SOM is primarily a visualization tool and clustering is a logical next step after you construct a SOM from data. Typically, the clustering is subjective in that after looking at your SOM you can 'see' N clusters and then from there you would go on to cluster (k means, hierarchical etc.) the SOM nodes with this N as your parameter. Is there a nonsubjective (maybe nonparametric?) way to cluster the SOM nodes (i.e. without first looking at the SOM to determine the number of distinct clusters)? Thanks
Answer: To answer your question, yes there are. There are numerical ways to determine the best cluster form. However, it is subjective which one you use.
I do not think you are still looking for this 5 years after date but this can hopefully help people in the future.
If you have any question on clustering, see @Ben 's elaborate answer in how to determine optimal cluster
Here he discusses 8 ways to determine the number of clusters:

look for a bend in the WSS elbow plot (I am currently using this, because it's easy, however, difficult to automate)
Partitioning around mediods with the pamk function of fmc in R
Calinsky criterion (I am not a fan, don't understand the background that well)
Determine the optimal model and number of clusters according to the Bayesian Information Criterion for expectation-maximization. This is nice, maybe the closest you will get to feeling it is not subjective, because it gives an 'optimum'.
Affinity propagation (AP) clustering
Gap Statistic for Estimating the Number of Clusters
clustergrams to visualize cluster assignment, see http://www.r-statistics.com/2010/06/clustergram-visualization-and-diagnostics-for-cluster-analysis-r-code/
The NbClust package

Ben explains each one with examples with nice plots.
Comment: Welcome to the site, @Piet93. Can you provide a synopsis of the information at the link so future readers can determine if it's something they want to pursue & in case it goes dead?
Comment: I'll give it a try!
Answer: If you don't know a priori the number of clusters, I don't think SOM will be of much help. However, you can take a look at some SOM variants, like  LARFSOM, which is a SOM that inserts/removes nodes on the fly - and it was conceived by my graduate advisor :) The number of nodes in the end is expected to be the correct number of clusters in the dataset.

SOM automated/objective clustering


what's the difference between dumb and stupid?

Question: Could somebody explain to me the difference between "dumb" and "stupid" ? As French person, there isn't many differences !
Comment: *isn't* **much** *difference* or **aren't** *many differences* !
Answer: There isn't much difference between dumb and stupid when referring to intelligence. Dumb is probably more of an insult, while stupid can refer to a temporary state such as drunken insensibility, but English has a very large number of terms for a lack of intelligence, which typically differ less in meaning than offensiveness and appropriateness. Of these, stupid is one of the most common in many contexts, and less likely to be offensive than alternatives. If you must say that someone lacks intelligence, stupid is probably the most suitable word.
Merriam-Webster offers a usage note which says these words mean "mean lacking in power to absorb ideas or impressions." It suggests dumb refers to "an exasperating obtuseness or lack of comprehension" while stupid refers to "a slow-witted or dazed state of mind that may be either congenital or temporary". So if it is a temporary state, then stupid is more appropriate, but both words are typically used to imply a permanent state of lack of intellectual ability.
Dumb is problematic because historically it also meant mute, i.e. incapable of speech, and this usage is now considered offensive (Merriam-Webster). Because being unable to speak is not correlated with being stupid. While I would hope nobody uses dumb to mean mute, this has tainted the use of dumb in other contexts, such that people may find it offensive. (Similarly, other terms for lack of intelligence like moron can be problematic because of their historical use in psychology or medicine: moron formerly referred to milder forms of intellectual disability.)
Stupid has largely escaped these taints, and can be used in formal contexts (insofar as calling someone stupid is ever polite). In contrast, Merriam-Webster points to the "exasperating" quality of being dumb, hence its use as an insult.
One of the main uses in which dumb is still used these days is in the expression dumbing down, meaning to lower the difficulty, intellectual content, or educational level of something - often used to criticize mass media and popular culture for encouraging a low level of discourse.
Comment: While it is no longer considered appropriate for deaf-mute people, in British English the primary meaning of _dumb_ is still 'temporarily unable or unwilling to speak' - see [Cambridge Dictionary](https://dictionary.cambridge.org/dictionary/english/dumb).
Comment: I would add that for a considerable part of my lifetime (born 1952) _dumb_ for stupid was a mainly American English term, and in British English it meant 'mute', that is, either temporarily or permanently unable to speak.
Answer: The term dumb would insinuate ignorance. Someone who doesnt have knowledge of, or is unfamiliar with a consequence or action result. Basically its a explicit derogatory of the term ignorant. Being called ignorant isnt pleasant either but the term is often used more as an insult than an insinuation for lack of intellect in a given circumstance.
Stupid-ity is more of an action based word. In other words you cant really be referred to as stupid unless to perform and action or circumstance where one knew the risks and the potential of consequence and performed the action or circumstance anyway.
One can break the law by performing a knowingly illegal act and disregarded the consequences thus they were stupid. A perfect example of this would be from the movie Forrest Gump. He wasnt stupid, he was just literally dumb.
When people asked if he was stupid (because of something he did or said) he said "stupid is as stupid does", thus points out that stupidity is derived from an action of disregarded consequence or otherwise
Answer: Dumb:
The term "dumb" typically refers to a temporary or situational lack of intelligence or the ability to speak. It is often used to describe someone who is temporarily unable to find the right words or express themselves verbally. Being dumb does not necessarily indicate a lack of overall intelligence or cognitive abilities. Instead, it implies a momentary difficulty in communicating effectively.
Stupid:
On the other hand, "stupid" generally implies a more permanent or inherent lack of intelligence. It refers to a person's overall intellectual capacity or their consistent inability to grasp concepts, understand information, or make sound judgments. Unlike being dumb, being stupid suggests a more lasting condition rather than a momentary lapse in cognitive abilities. check out the detail guide to know more about Dumb vs Stupid.
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: I disagree with this answer; I think these two words can be used more interchangeably than is implied here. Even if my friend is very intelligent, there is nothing wrong with me saying, "That was a stupid thing to say," or, "That was a stupid thing to do," or, "You sure acted stupidly when you were drunk last night." I can also say, "He's as dumb as a box of rocks," if I'm describing someone who is not very bright or intelligent.

what’s the difference between dumb and stupid?


Is shell script a programming language?

Question: This is my first question in UNIX:
I started with shell scripts 2 days ago.
But I have a question: is a shell script a special programming language for a specific shell?
Comment: Do you mean you wrote a shell script and it executed with no errors, then you tried to execute it in another environment and got an error? If so what was the error message?
Answer: Bash is a scripting language:
From wikipedia:

A scripting language or script language is a programming language that
supports        the writing of scripts, programs written for a
software environment that automate the execution of tasks which could
alternatively be executed one-by-one by a human operator. [...]
The term script is typically reserved for small programs (up to a few thousand lines of code).

Scripts are typically quick and dirty. Say, a bash script to make your life easier. Whereas a 'programming' language is meant to be much more thought out and deliberate.The thing with 'programming' languages is that they are usually faster, and offer more control over low-level things if you want.
'programming' languages are typically used in scenarios where the code will be around for a long time. If you want to write something quickly and then never use it again, 'scripting' languages are what you want.
You can find an interesting article here.
Comment: ... I think I misread you. That is more or less what you say.
Comment: Well, scripts are not only things you (= the user) write to automatize things (that's the "tool" side to scripts). Examine your system, there are scripts everywhere: that's the "glue" side to it. Also, while it is true that the expert C/assembler programmer has total control, in most normal settings, it is much better to invoke a standard application that's been around and tested for decades. Point is, C is great, scripts are great, the challenge is when to use what.
Answer: If you know of any command, say, ls, you type it, and then hit return, the shell will know where that program (ls) is, invoke it, and show you the result. This is the "non-script" shell usage.
But, if you order a couple of such commands in a sequence, say A, B, C, D, and then put it (the sequence) in an executable file, you've got a program. The program has a name and location, so it can be referenced, and invoked; it has code, so it can be executed, one command at a time, by the CPU.
(The program is not compiled - like, for example, C source would have been - and this makes it a script. But it is a program nonetheless.)
That is, in some aspect, already at this point you are programming, because you are instructing the computer what to do.
Furthermore, you are, again at a very basic level, also using a programming language, because you can't just type anything (and expect it to work); at the same time, whatever you type you'll get activity from the computer that corresponds exactly to what you wrote.
There are rules how you should say things, and there are rules how the computer will react to those things.
That said, with "programming", you typically associate somewhat more expressive power than just piling commands on top of each other. At the very least, you'd like branching (if ... then ... else), iteration (loops: while, for, etc.), and probably some other things as well. But that's OK as the scripting languages have those things and more.
The shells have different languages, yes, but some may overlap to a great extent because of convention (why change a good way to say something?), or to be compatible with earlier versions (or some standard).

Is shell script a programming language?


Expected number of m-cliques in a random graph

Question: Let $Z_m$ be a random variable that corresponds to the number of $m$-cliques in a random graph with n vertices and the probability of any edge happening is 1/2. Prove that $$ \mbox{E}[Z_m] = {n \choose m} 2^{-{m \choose 2}}.$$
Comment: How many possible m-cliques are there?  What is the probability of a given m-clique being in a random graph?
Comment: Also, expectation is linear.
Comment: The number of m-cliques is infinite since there are n vertices in this  random graph.  The probability of a given m-clique being in a random graph change from one m to another since different numbers of m requires different numbers of edges.@deinst
Answer: What is an $m-$clique?

 An $m$-clique is a set of $m$ vertices such that every two distinct vertices are adjacent.   IE: There is an edge connecting ever pair of vertices in the set.

How many $m$-cliques could there be?

 The number of plausible $m$-cliques in a random graph of $n$ vertices, is the count of selections for $m$ from $n$ vertices.

What is the probability that a particular $m$-clique happens.

 The probability that a particular set of $m$ vertices actually form an $m$-clique is the probability that every edge joining any two of those points are connected.  How many such edges are there ? What is the probability that all these connections happen?

Put it together using the Linearity of Expectation.

 You can do it, if you try.
Comment: @dataKnight To form an $m$ clicue, how many edges need there be?  What is the probability that all of them happen?
Comment: Can you explain why is the probability part 2^{-(m choose 2)}
Answer: I know this is an old problem, but I also faced the same doubt. Luckily, I was able to solve this doubt by myself. Hence, I provide how I solved it, so in case that anyone else is having the same doubt will find an easy to follow step-by-step proof of this result.
First of all, we need to understand that a clique of size $m$ is a set of m nodes, in which every node is connected to every other node (in a social network it would mean that everyone knows everyone else).
Hence in a network with $n$ nodes we choose all the subsets of size $m$. The total number of possible combinations (subsets) will be $\binom{n}{m}$.
Now we can define $\binom{n}{m}$ $X_j$ indicator r.v.s, i.e. $(X_1, X_2,...,X_\binom{n}{m}$), which indicate wheter the j subset is a clique or not.
Hence the Expected Number of cliques of size m will be the sum of those indicator r.v.s:
$E(X_1 + X_2 + ... + X_\binom{n}{m}) = E\left (\sum_{1}^{\binom{n}{m}} X_j \right )$
By symmetry of expectations we know that all those expectations are exactly the same. Hence, for example, we can multiply the Expectation of $X_1$ by $\binom{n}{m}$.
$E(X_1 + X_2 + ... + X_\binom{n}{m}) = E\left (\sum_{1}^{\binom{n}{m}} X_j \right ) = \binom{n}{m}E(X_1)$
Now by the fundamental bridge, we know that the expectation of an indicator r.v. is the same as its probability, i.e. $E(X_1) = P(X_1 = 1)$. In other words, we want to calculate the probability that the first subset of size m is a clique of size m.
To calculate this probability we only need to know the probability  of any edge happening, which we will call $p$ (in this case it is $1/2$). Furthermore, we know that in order to form a clique all the nodes in this subset must be connected, that means that all possible combinations of 2 nodes from the $m$ subset, that is $\binom{m}{2}$. Hence:
$P(X_1 = 1) =  (p)^\binom{m}{2}  = (\frac{1}{2})^\binom{m}{2} = \frac{1}{2^\binom{m}{2}} = E(X_1)$
Putting all of this together, we obtain that:
$E(X_1 + X_2 + ... + X_\binom{n}{m}) = E\left (\sum_{1}^{\binom{n}{m}} X_j \right ) = \binom{n}{m}E(X_1) = \binom{n}{m}P(X_1 = 1) = \binom{n}{m} \frac{1}{2^\binom{m}{2}}$
So:
$E[Z_m]=\binom{n}{m} 2^{-\binom{m}{2}}$
where $Z_m = X_1 + X_2 + ... + X_\binom{n}{m}$
Hope this helps.


How can eclipsing binaries be used to gauge distances?

Question: I understand that we can infer much about the parameters, such as the radius and mass, of stars in eclipsing binary systems. But how can eclipsing binaries be used to gauge distances? The current Wikipedia entry, for example, for binary star mentions that eclipsing binaries can be used to gauge distances, even to nearby galaxies, but I don't understand exactly how.
Answer: Most distance methods are luminosity-based: you measure an object's flux, assume it has a particular luminosity, and then determine the distance from that using the inverse-square law. So the question becomes: how do you determine the luminosity?
The eclipsing-binary method uses the idea that a star's luminosity can be defined as $L = 4 \pi f_{s} R^{2}$, where $f_{s}$ is the flux per unit area from the star's surface and $R$ is the radius of the star. So how do we determine those?
The surface flux of the star can be estimated from stellar-atmosphere models combined with detailed spectroscopy of the star; alternately, there are tight empirical relations between the surface flux and the color for late-type stars (known as the surface-brightness--color relationship [SBCR]). The latter seem to be preferred for recent eclipsing-binary work (where the binary consists of red giant stars).
The radius of the star is where the eclipsing-binary method comes in. By detailed photometric monitoring, you can determine the period of the orbit, the timing and duration of the eclipses, and the duration of the eclipse onsets and exits (i.e., the partial eclipse phases before and after the full eclipse). And with detailed spectroscopic monitoring, you can determine the radial velocities of the stars, which lets you determine the orbital velocities (from the observed radial velocities of the stars, via the Doppler shifts of their spectra). From the period of the orbit and the orbital velocities, you can determine the size of the orbits. Given the size of the system and the velocities of the stars, you can work out the radii of the stars (e.g., for the same velocity and orbit size, a star with a small radius will go into full eclipse later, but more rapidly, than a large star will).
Note that knowing the geometry and timing of the orbit also allows you to better determine the colors or spectroscopy of the individual stars, and thus their individual surface fluxes. (E.g., when the system is not in eclipse, you know you are seeing light from both stars at once, while if one star completely eclipses the other, you know you are only seeing light from it, and can then work out how much of the combined light is due to the other star.)
Things are simplest if the orbit is circular and the inclination to our line of sight is $90^{\circ}$ (i.e., the binary is edge-on); but as long as there are at least partial eclipses and monitoring of the radial velocity, you can still work out the geometry of the system and use the method.
So the key advantage of the eclipsing-binary method is that you can work out the geometry and timing of the system, so that you can determine the radii of the two stars, and then combine that with their surface fluxes to get their luminosities -- and then their distance.
Answer: The key here is mass.
In nonbinary systems (or other external factors) it can be a bit tough to determine mass of a star. You just see a point source of light; we can get spectral features which can in some instances be used to give us some idea, but it's rather tough to otherwise get mass.
If you do have mass (which you can get because binary stars are moving and move according to their masses) then you can use the mass-luminosity relationship or other theories of special objects in combination with the color to determine the luminosity and thus the distance, since knowing the output of flux on the surface and the flux you're measuring in your telescope can then easily be turned into a distance (Flux by definition is luminosity per a spherical square surface, the radius of the sphere being your distance from the object. With flux and luminosity, you just solve for the distance.)
For eclipsing binaries, you can determine the mass one of two ways. If you take the spectra of the stars while the two stars are not eclipsing, you can determine their speeds through the redshirting of one object's lines and the blue shifting of the others; you can then determine the period of the orbit by the light curve, and using both, be able to find the size of the orbit. With this information, you can find the collective mass of the two stars.
Alternatively, you can carefully look at the light curves of the stars, and determine the size based off of how long ingress (the star to go from partially eclipsing to totally eclipsing) takes in conjunction with the speed of the orbit. With size and color, you can then determine luminosity and mass, although mass in this case is less important, as luminosity is the end goal here.
The former method fails with two objects of significantly different brightnesses, such that the spectral lines of one are washed out by the other.
Comment: This is incomplete, because you aren't considering the *eclipsing* nature of the binary and how that is used to determine the *sizes* of both stars, in addition to their masses.
Comment: You're right, I failed to mention the way mass was determined in the system, so I made an edit for that. However I'm not sure I understand the need for size; while it's good to know, don't you need to know the speed of the object to find the size, and if you know the speed of the object from spectra and it's period from the light curve, could you not then determine the semi major axis and use Newton's version of Kepler law to figure out the masses without the sizes?
Comment: After doing bit more reading: the eclipsing binary method does not rely on determine the masses of the stars at all. I'll see if I can write a short answer summarizing it.
Comment: Note that the "mass-luminosity" relation is only valid for *main sequence* stars, so you have to verify a star is main sequence in order to use it.


How to access recovery console without using grub?

Question: So I just got a computer from work for free but it's a rather old iMac, probably from 2006, and it has Ubuntu on it. I have no clue how to use this software and the previous owner is unknown so I can't get his password for it. I have been trying to reset the password for the admin so I can uninstall the software but I can't reach the grub menu. When I went to check the settings for the grub menu on the guest user profile, there was no file for it under etc/default/grub and I cat find any file about it anywhere. It is currently running 12.04 and I can't figure out how to reset anything. Please help, all I want is to know how to enter the recovery console without the grub menu or any other faster way to uninstall the software. Thanks.
Comment: Just do a new installation using live usb or cd of the operating system you want to use. You don't need to log in; you'll be able to erase the disk during the process of installation.
Answer: Depending on the configuration, you may be able to force the GRUB menu to show up by holding Shift when it is running. (To be safe, hold shift before you start the computer until the menu shows up or Ubuntu boots.)
If Ubuntu boots without showing the GRUB menu then this didn't work.

If that doesn't work, pressing Esc may work.
Comment: It's usually the right shift key and some people have to tap repeatedly, not hold it


How to install default/stock Terminal app?

Question: I uninstalled the default/stock Terminal app via AppCleaner. How to get the default/stock Terminal back without reinstalling Mojave?
Comment: Default apps are protected by SIP so you shouldn't have been able to delete it without some complex steps prior.  How exactly did you do this?
Answer: You can restore it from your backup. Because you wouldn't start deleting bits of the system with a third-party app without making sure you had a backup.
Failing that, you can reinstall the OS over the top of your existing installation, and all your files, apps and settings will still be in place. This will make sure that anything else important that ApplCleaner has deleted will be restored.
Some people do this from time to time, just to make sure nothing's got corrupted or missing.
Answer: I don't think there is a way to access the terminal app without reloading the operating system. If you have terminal on another machine you may be able to copy the app to your computer.
An easier solution would be to use iTerm2. Its a terminal emulator like terminal but with more features. Its considered by many as a better emulator than Terminal. I use it myself in place of the Terminal app.
Comment: I do have another Mac machine, will copying the Terminal app via AirDrop work?

I'm using iTerm2 that's why I uninstalled the default/stock Terminal app. But I'm using Visual Studio for Mac & is looking for the default/stock Terminal app which I  uninstalled...
Comment: If you can air drop the Terminal app I would try that and see if it works.
Comment: You said, "I don't think there is a way to access the terminal app without reloading the operating system." and that is not at all true! It can be copied from another system running the same version of the OS it was delete from, (zip up a copy and move the zipped copy) or extracted out of a macOS Installer of the same version without reinstalling the whole OS. I use [Pacifist](https://www.charlessoft.com) for extraction operations such as that. Note that I am not affiliated with the developer of Pacifist, just a satisfied paid customer.
Comment: I also said if you have it on another machine you may try copying it.


How can I get a breakdown of s3 cost at per bucket level in Cost Explorer?

Question: It seems like I can get total cost of S3 using the service level in the filter.
However I want to get cost per bucket level.
Can it be done in Cost Explorer?
If not, can I get the breakdown with aws cli?
Answer: I'd look into using cost allocation tags:
https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html
https://docs.aws.amazon.com/AmazonS3/latest/dev/CostAllocTagging.html
You'll need to Activate cost allocation tags under your billing dashboard, then add the tags you wish to track (ie billinggroup).
Then Under each bucket -> properties -> Advanced Setting -> Tags set a tag like billinggroup: bucketname
You could also do something like this with aws cli, but I don't think it will be as accurate, since it wont calculate the size of all object versions and replicas, but it might work for a ball park figure:
bucketlist="mybucket1 mybucket2"
echo -e "Bucket\tObjectCount\tTotalSize\n"
for x in ${bucketlist}; do
    echo -en "$x\t"; aws s3 ls s3://$x --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {count=0; total=0}{count++; total+=$3}END{print count"\t"total" ("total/2^30"GB)\t$"(total/2^30)*0.023}'
done

Comment: I've always wanted to name a variable `bucketlist`.
Answer: AWS cover this in their knowledge base:
https://aws.amazon.com/premiumsupport/knowledge-center/s3-find-bucket-cost/
Basically, you need to add a tag to every bucket and set the value to be the bucket name. Then you can use the cost explorer to find that total cost per bucket:

If you have lots of buckets, this is very tedious and error-prone so I wrote a Python script to automate the task:
import boto3
from botocore.exceptions import ClientError

s3_client = boto3.client('s3')
s3_resource = boto3.resource('s3')

def add_bucket_name_tag_to_all_buckets():
    TAG_NAME = 's3-bucket-name'

    for s3_bucket in s3_resource.buckets.all():
        s3_bucket_name = s3_bucket.name
        print(f'Setting tag "{TAG_NAME}" in "{s3_bucket_name}" to "{s3_bucket_name}"...')

        # Create tag iff there are no tags at all
        bucket_tagging = s3_resource.BucketTagging(s3_bucket_name)
        try:
            tags = bucket_tagging.tag_set # This throws if there are no tags
        except ClientError:
            tags = [{'Key':TAG_NAME, 'Value': s3_bucket_name}]
            bucket_tagging.put(Tagging={'TagSet':tags}) # Use carefully, this overwrites all tags

        # Now append tag if not present
        tags = bucket_tagging.tag_set
        if len([x for x in tags if x['Key'] == TAG_NAME]) == 0: # If tag not found, append it
            tags.append({'Key':TAG_NAME, 'Value': s3_bucket_name})
            bucket_tagging.put(Tagging={'TagSet':tags}) # Use carefully, this overwrites all tags

if __name__ == '__main__':
  add_bucket_name_tag_to_all_buckets()

This will recurse through your buckets and append a new tag called s3-bucket-name and set the value to be that name of that bucket.

If you don't understand Python, or trust running scripts from the internet(!), you can just do it manually as per the Amazon instructions, pasting contents below:

To check which Amazon S3 bucket is increasing your storage cost, perform the following steps:

Add a common tag to each bucket.

Activate the tag as a cost allocation tag.

Important: All tags can take up to 24 hours to appear in the Billing and Cost Management console.

Use the AWS Cost Explorer to create an AWS Cost and Usage Report for your tag.

Note: Cost allocation tags don't show you costs that you incurred before you set up the tags.
Resolution
Before you begin, your AWS Identity and Access Management (IAM) policy must have permissions to do the following:
Access the Billing and Cost Management console
Perform the actions s3:GetBucketTagging and s3:PutBucketTagging
Tip: Avoid using your AWS account root user for this solution. Instead, use an IAM user or role with the permissions that you need.
Adding a common tag to each bucket

Open the Amazon S3 console.

From the list of buckets, choose the bucket that you want to track costs for.

Choose the Properties view.

Scroll down and choose Tags.

Choose Edit.

Choose Add Tag.

For Key, enter a name for the tag that you'll add to all the buckets that you want to track costs for. For example, enter "S3-Bucket-Name".

For Value, enter the name of the bucket.

Repeat Steps 1 through 7 for all the buckets that you want to track costs.

Activating the tag as a cost allocation tag

Open the Billing and Cost Management console.

From the navigation pane, choose Cost allocation tags.

In the search bar, enter the name of the tag that you created for your buckets. For example, type "S3-Bucket-Name".

Select the tag.

Choose Activate.

Use the AWS Cost Explorer to create a cost report for the tag

Open the Billing and Cost Management console.

From the navigation pane, choose Cost Explorer.

Choose Launch Cost Explorer.

From the navigation pane, choose Reports.

Choose New report.

For Report Templates, select Cost & Usage report, and then choose Create Report.

Under Filters, for Service, select S3 (Simple Storage Service). Then, choose Apply filters.

For Tag, select the tag that you created. For example, select S3-Bucket-Name. Then, check each bucket that you want to track costs on, and choose Apply filters.

Note: If you don't see your tag in the filter list, it's likely that the tag was recently created and applied to a bucket. Wait 24 hours, and then try creating the report again.

Under Advanced options, confirm that Show only untagged resources is unchecked.

From the top of the graph, choose Group by, and then select the tag that you created.

Choose Save as.

Enter a title for your cost report.

Choose Save Report.

After you create the cost report, use the report to review the cost of each bucket marked with the cost allocation tag that you created.
Note: You can set up a daily or hourly AWS Cost and Usage Report report to get more Amazon S3 billing details. However, these reports don't show you who made requests to your buckets. To see where requests to your bucket are coming from, enable either object-level logging or server access logging. To get more information on certain Amazon S3 billing items, you must enable logging ahead of time. Then, you'll have logs that contain Amazon S3 request details.
Comment: This doesn't handle S3 buckets in different locations.
Answer: Python script I used to loop through each of the buckets with the tag name s3-bucket-name and then save the results to a csv file.
import boto3
import csv
from datetime import datetime, timedelta

# Set up AWS credentials and region
session = boto3.Session(
    aws_access_key_id='YOUR_ACCESS_KEY_ID',
    aws_secret_access_key='YOUR_SECRET_ACCESS_KEY',
    region_name='YOUR_REGION'
)

# Set up S3 client and CloudWatch client
s3 = session.client('s3')
cloudwatch = session.client('cloudwatch')

# Set the date range for the cost report
start_time = datetime.utcnow() - timedelta(days=30)
end_time = datetime.utcnow()

# Set the tag key to filter by
tag_key = 's3_bucket_name'

# Get the S3 bucket names that have the specified tag
bucket_names = []
response = s3.list_buckets()
for bucket in response['Buckets']:
    response = s3.get_bucket_tagging(Bucket=bucket['Name'])
    for tag in response['TagSet']:
        if tag['Key'] == tag_key:
            bucket_names.append(bucket['Name'])

# Get the S3 bucket usage metrics for the specified date range and tag
costs_and_sizes_per_bucket = {}
for bucket_name in bucket_names:
    response = cloudwatch.get_metric_statistics(
        Namespace='AWS/S3',
        MetricName='BucketSizeBytes',
        Dimensions=[{'Name': 'BucketName', 'Value': bucket_name}],
        StartTime=start_time,
        EndTime=end_time,
        Period=86400,
        Statistics=['Average']
    )
    if 'Datapoints' in response:
        for datapoint in response['Datapoints']:
            bucket_size = datapoint['Average'] / 1024 / 1024 / 1024
            cost = datapoint['Average'] * 0.000000001 * 0.023
            costs_and_sizes_per_bucket[bucket_name] = {
                'size': bucket_size,
                'cost': costs_and_sizes_per_bucket.get(bucket_name, {}).get('cost', 0) + cost
            }

# Save the bucket name, size, and cost in a CSV file
with open('s3_costs.csv', mode='w', newline='') as file:
    writer = csv.writer(file)
    writer.writerow(['Bucket Name', 'Size (GB)', 'Cost'])
    for bucket_name, data in costs_and_sizes_per_bucket.items():
        size = data['size']
        cost = data['cost']
        writer.writerow([bucket_name, size, cost])

print('CSV file saved successfully!')

Comment: For Daniel's answer above, I had to add { 'Name': 'StorageType', 'Value': 'StandardStorage' }
as a dimension for this to pull data back from cloudwatch.


C++ in ubuntu(linux platforms)

Question: I want to start developing c++ programs in the linux platforms. So can anyone tell me where to start learning c++ for linux, the compiler, etc.
Thanks in advance :)
Answer: Do a quick
sudo apt-get install build-essential

and you will have a C++ compiler which you invoke with g++.
As for learning resources, there are vast amounts of information for C++ programming. Your best bet is to google for phrases like "linux c++ programming".
Don't forget to check this SO post, which is the definitive C++ book guide.
Answer: I use Ubuntu. I currently use Code:Blocks for my IDE (in the Universe repository) and Visual Paradigm Home Edition for my design/development software (it's not in the repository but is free). You will need build-essential to use Code:Blocks, as the other poster suggested. I also like gdb for the purpose of figuring out where a segfault happens and the like.

C++ in ubuntu(linux platforms)


Should I wrap Azure AD B2C for authentication?

Question: I want to implement an authentication system. The purpose of the system is to centralize account management and handle the complexity of account security. Internally, I don't want to implement the actual login by myself. Instead, I want to use Azure AD B2C for user login, forgetting passwords, etc.
Our team has other web services. All other services will rely on this system for authentication.
Currently, I wrap Azure AD B2C so that other services won't directly depend on Azure AD B2C. When a user goes to a service, and he is not logged in, the service will redirect the user to the authentication system, and the authentication system will redirect the user to Azure AD B2C again while handling the logic of appending client ID, generating nonce, etc.
After the user finishes the login, he is redirected to the authentication system. The authentication checks the ID token and issues another access token (JWT) using a private key it maintains, sets the access token in Set-Cookie header, and redirects the user back to the initial service.
I found it good that other services don't directly rely on Azure. It's completely abstracted by the authentication system. But it also adds a lot of complexity to the implementation.
When using an authentication-as-a-service like Azure AD B2C or Auth0, is it suggested to issue our own access token after the user is authenticated? Or is it suggested to directly use the access token issued by Azure AD B2C and pass it around all other services?
Answer: I don't see why you would.  The point of standards is that you don't care what provider is issuing your tokens/claims. If you want to change authentication provider then you just migrate any accounts.  Your interfaces or claims need not change.  Wrapping just means extra work as far as you describe it.
Comment: If the provider is changed, all the other services need to change the settings for validating access token(e.g. issuer, jwks URL). The account ID may also change. Do you think that could be a problem?
Comment: Maybe I misunderstand but you're talking about a reconfiguration to a new service provider?  Well, yes, I guess but that's just config.  Account ID I expect you could migrate the existing ones to your new provider.


Public site error "API_CURRENTLY_DISABLED"

Question: I'm getting a API_CURRENTLY_DISABLED error when I'm trying to call the ajax api (sforce.connection.create) from my public page.
In my site's public access settings I see the the 'API Enabled' option is checked.
Any ideas why I cannot call the ajax api?
Comment: Are you using a `Developer Edition` account or a trail `Professional/Enterprise/Ultimate Edition`?
Comment: I'm using an EE production/sandbox orgs
Comment: were you able to solve this ?
Comment: Does the account/profile your testing with have the API enabled?
Answer: The public API isn't available for the guest user. It's explicitly blocked.
Comment: So what is the point of having the 'API Enabled' checkbox in the Public Access settings?
Comment: You're right, it doesn't do anything.
Answer: Neither do Trial Enterprise and Ultimate Editions have API support, nor does Salesforce activate it on request.
Getting to a work-around, if you want to test the API, go for a Developer Edition account. Therein you can create multiple CRM users, manage Accounts and Contacts etc. But do note that the DE comes with certain restrictions that can be easily bypassed. This will guide you into it.


How to open an image with ImageJ in java

Question: I want to analyse images using the ImageJ framework in java. How can I open an image? I need to have an ImageProcessor object to be able to generate a histogram. Here is the code I have so far:
public void run(ImageProcessor ip) {
        int[] H = new int[256]; // histogram array
        int w = ip.getWidth();
        int h = ip.getHeight();

        for (int v = 0; v < h; v++) {
            for (int u = 0; u < w; u++) {
                int i = ip.getPixel(u, v);
                H[i] = H[i] + 1;
            }
        }

        // ... histogram H[] can now be used
    }

Answer: I work with medical grayscale images where a ColorProcesser is not appropriate. In that case I use
Opener opener = new Opener();
String imageFilePath = "somePath";
ImagePlus imp = opener.openImage(imageFilePath);
ImageProcesser ip = imp.getProcessor(); // ImageProcessor from ImagePlus

Answer: I didn't see anything specifying how you wanted to open the image but Iv'e added some code below that will open the folder opener window and you can navigate to a folder of images (I think its mainly used for image stacks but you could just make the stack size 1 and it should work to open a single image).
import ij.plugin.FolderOpener;

// Do this stuff in your run method
FolderOpener fo = new FolderOpener(); // create FolderOpener object
ImagePlus your_imgPlus; // create ImagePlus object
your_imgPlus = fo.open(null); // call FolderOpener.open()

The null argument in open() allows the folder selection window to open, you can also use a file path as an argument.
Answer: Create a java.awt.Image first and then use it to construct a ColorProcessor (subclass of ImageProcessor) object.
Image myImage;
// instantiate myImage
ImageProcessor processor = new ColorProcessor(myImage);

Answer:  File inputFile = new File("someImage.png");
    Image someImage = null;
    try {
        someImage = ImageIO.read(inputFile);
    } catch (IOException e) {
        e.printStackTrace();
    }
    ImagePlus imagePlus = new ImagePlus();
    imagePlus.setImage(someImage);
    ColorProcessor processor = (ColorProcessor) imagePlus.getProcessor();

Comment: While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value.
Comment: Edited, one more line was added
Answer: The answers are old so maybe there has been some changes, but I prefer using the static method IJ.openImage(java.lang.String path_to_file) http://rsb.info.nih.gov/ij/developer/api/ij/IJ.html. This method returns an ImagePlus object.
I use absolute file paths myself but I suspect relative ones should work fine too. If you want the ImageProcessor associated with the ImagePlus you call getProcessor().


Do you need to be a customer of the bank to use their safety deposit box services?

Question: The bank I want to use in the future doesn't have physical bank office locations so I'm looking into being able to use a safety deposit box service or something similar to store some documents.
Comment: If you use a bank's safety deposit box, doesn't that make you a customer?
Comment: I don't understand --  If they don't have physical bank office locations, where would these safety deposit boxes would be located?
Answer: Forgive me Miles, I see you are new here. In general, we need a standard answer "ask the business." This question falls into that category. Why? Because even if ten of us agree on the answer, but some bank takes the opposite position, that doesn't help you. You need to go to the convenient brick and mortar bank near you and ask.
Comment: Some may require you to open a small savings account for $5. Now you are a customer. Add $1 every year to make sure the account isn't considered abandoned.
Comment: Thanks for your answer. I know every bank is different, but I'm looking to hear a general experience from the community. I'd at least like to know that it's not something that is unheard of.
Comment: Have you called/visited your local B&M bank?
Comment: Thanks mhoran. Could you make that an answer so you get answer points please?


How to Clip The Negative Portion of a Signal?

Question: What is an easy way to remove the negative portion of a signal without distorting the positive side of it?
Comment: Fast signal diode, with a low forward voltage.
Comment: Have you access to a copy of 'The Art of Electronics'? It gives a nice explanation of an "Active Rectifier"; chapter 4, section 4.3.2 D in Ed 3. The circuit behaves like a diode without suffering from the forward voltage drop of a diode. It's pretty much an op-amp, diode and resistor. A quick search will probably find a good description. Oh, and what is the bandwidth and amplitude of the signal, and acceptable levels of distortion?
Comment: Maybe have a look at this lab worksheet for an explanation of an "Active Rectifier",  http://www.niu.edu/~mfortner/labelec/lect/p575_01b.pdf. Please come back and ask for help if you need it.
Answer: I would recommend a precision rectifier.
Answer: The most basic op-amp circuit (it has to be the right op-amp of course) is this: -

It relies on a few special features of the LT1078 but is a pretty good half wave rectifier.
You can use most op-amps in this configuration: -

The cool thing about this circuit is that one op-amp can produce two outputs.
Note that both the op-amp circuits shown above are inverting configurations but that doesn't matter if you are dealing with waveforms that are amplitude symmetrical.
You can also make full wave rectifiers using two op-amps: -


evidence silokas: transmigration even among animals and plants and insects or devatas

Question: I need the evidence shlokas that explain that soul's transmigration even among animals and plants and insects or devatas for convincing those who do not believe soul's transmigration among them.
Comment: Bhagavad Gita 16.20. Also Chandogya Upanishad 5.10.7-8.
Answer: Hare Krishna
Mahabharata, Shanti Parva, Moksha Dharma parva, chapter 302
तम:सत्वरजोयुक्तस्तासु तास्विह योनिषु | नियते प्रतिबुद्धित्वातबुद्धजनसेवनात|| 43
Due to the association with material nature the Jiva gets endowed with the qualities of goodness, passion and ignorance.Due to the association with those persons who identify with bodily concept of life, the Jiva further takes birth in the species which are in modes of goodness,  passion and ignorance.
सहवासविनाशित्वान्नान्यो अहमिति मन्यते| यो अहम् सो अहम् इति हि युक्तत्वा गुणानेवानुवर्तते ||44
Due to the constant association with material nature, the rememberance of one's constitutional position is forgotten, thus the purusha thinks that he is not different from the body. " I am that", "I am this", "I am the son of such and such person" , "I am of such and such caste", thinking so, the Jiva follows the traits of Sattva, rajas and tamo gunas.
तामसा निरयम यान्ति राजसा मनुशानथ | सात्विका देवलोकाय गच्छन्ति सुखभागिनी ||47
By the mode of ignorance, the soul endowed with that particular body falls into the depths of hell, the soul endowed with the mode of passion goes to the world of humans, and those souls who are participants in the mode of goodness reaches the planets of the demigods.
निष्कैवल्येन पापेन तिर्यग्योनिमवाप्नुयात | पुण्यपापेन मानुष्यम पुन्येनैकेन देवता : ||48
Due to excessive sinful activities, the soul takes birth in animal, bird, beast species. By the resultant action of mixture of sinful and pious activities the soul takes birth among human species.Therefore by solely being pious does the jiva takes birth in Demigod species.
एवं अव्यक्तविषयम क्षरमाहुर्मनीषिण: | पंचविंशतिमो yo अयं ज्ञानदेव प्रवर्तते || 49
That which is a product of the association of prakrti and purusha is called as the fallible -kshara by learnt sages and the Parama Purusha is the akshara the infallible.
Chapter 303
एवंप्रतिबुद्धत्वातबुद्धमनुवर्तते | देहाद देहसहस्त्राणि तथा समभिपद्यते || 1
O King this way the Jiva being ignorant of his constitutional position, follows the path of ignorance, that is why the spirit soul keeps on transmigrating from one species to thousands of other species
तिर्यग्योनिसहस्त्रेषु कदाचिद देवतास्वपि | उपपद्यति संयोगात गुनै: सह गुणक्षयात || 2
Due to association with the modes of material nature, the Jiva by being endowed with its quality sometimes takes birth in animal species, and sometimes in Demigod species.
मानुषत्वाद दिवं याति दिवो मानुष्यमेव च | मानुष्यान्निरयस्थानमानन्तयम प्रतिपद्यते || 3
Sometimes in human form he attains the merit to go to the heavenly planets, sometimes he returns back to the earthly planet and sometimes from earthly planet he goes to hellish planets.
कोशकारो यथा आत्मानम् कीट: समवारुन्धति | सूत्रतन्तुगुणैर्नित्यं तथायमगुणो गुणै: || 4
Just as the silk worm binds itself as a cocoon in all direction due to its own web, in the same way the Jiva atma who is not a product of material quality binds himself due to the result of his material deeds.
तिर्यग्योनिसहत्रेषु कदाचिद देवतास्वपि | अभिमन्यत्यभीमानात तथैव सुकृतान्यपि || 8
Sometimes he identifies himself as an animal in the animal species, sometimes he assumes the identity of a Demigod, thus due to the result of identification with particular species the jiva experiences the result of his particular actions performed in those particular bodies.
I hope this helps.
Comment: Dear Severus Snape, this is what I really want to get. These evidence silokas will help people to understand truth. I really appreciate. Thank you so much (^o^)