Procedure to delete non existing rows oracle

Question: I wrote a procedure in PL/SQL to delete rows from a table,However,if that record does not exist,then throws some error like this: DBMS_OUTPUT.PUT_LINE('No such record'); My procedure is:
CREATE OR REPLACE PROCEDURE del_cn2
                   (c_cntry_id IN COUNTRIES.COUNTRY_ID%TYPE
                   )
    IS
      v_error_code NUMBER;
BEGIN
        DELETE from countries
        WHERE country_id =c_cntry_id;

        IF SQL%NOTFOUND THEN
          DBMS_OUTPUT.PUT_LINE('No such record');
        END IF;
      EXCEPTION WHEN OTHERS THEN
        v_error_code :=SQLCODE;
        IF v_error_code =-2292 THEN
          RAISE_APPLICATION_ERROR(-20004,'Organization '||TO_CHAR(c_cntry_id)||' site

details defined for it.');
        END IF;
      END;

  /

However,when I execute this procedure and provide a record that does not exist in my table,it gives message "Procedure completed successfully" I am using this to execute:
Execute procedure del_cn2('JJ');

Can someone please suggest?
Answer: If you want an exception to be thrown when a value that does not exist in the table is passed in, you would need to actually throw an exception.  You shouldn't use dbms_output for any sort of error output.  That is a very simplistic debugging tool-- you shouldn't assume that the caller will ever be able to see that output.
My guess is that you want something like
CREATE OR REPLACE PROCEDURE del_cn2
               (c_cntry_id IN COUNTRIES.COUNTRY_ID%TYPE
               )
IS
BEGIN
    DELETE from countries
    WHERE country_id =c_cntry_id;

    IF SQL%ROWCOUNT = 0
    THEN
      raise_application_error( -20001, c_cntry_id || ' no such value.' );
    END IF;
END;

Answer: try to set serverout to ON
example:
create table tst_delete (col1 int);

create procedure p_test_delete  as
BEGIN
    DELETE FROM tst_delete
    WHERE       col1 = 1;
    IF (SQL%NOTFOUND)
    THEN
        dbms_output.put_line('No records found');
    END IF;
  END;

then call the procedure in SqlPlus
SQL> exec p_test_delete;

PL/SQL procedure successfully completed

same issue that you described - no insformation...
next try with output activated
SQL> set serverout on
SQL> exec p_test_delete;

No records found

PL/SQL procedure successfully completed

SQL>


meaning of: "Might be dated though!"

Question: Actually, I got a reply from the author of a blog. It is the following

I am glad it's of help to someone! Might be dated though!

However, I understand the meaning of the first part, that the post is able to help someone. But it is the next sentence, as per my raw guess, that the author is trying to say-

"however it is old enough.."

I am uncertain whether the author wants to express the same or something else. Is my interpretation of the second sentence correct?
Answer: The meaning of

might be dated

Is that it might be old and no longer correct.  He is warning you that it may no longer be true because it is old. Dated meaning old.

meaning of: "Might be dated though!"


Siding Installation - Rain Expected

Question: I am having my entire house re-sided. We are having vinyl clapboard installed over the existing asbestos shingles. Some of the house is completed but an entire side is currently covered in Polar Wrap insulation (Tyvek below). Tomorrow there is 100% chance of rain. What happens when the Polar Wrap gets soaked? Does it need to be removed and re-installed? Or do we have to wait until it dries to finish applying vinyl? Thank you.
Answer: The surface of Polar Wrap, according the the manufacturer, is impervious to weather, it will not be an issue for your vinyl siding. If there are any voids, nail holes present, a small bit of water will pass through penetrations and can get trapped, taking a while to evaporate. This may not be an issue either, but if you choose, you can temporarily block the entry of rain by running a line of duct tape or other wide tape to divert the rain over the siding rather than letting it run behind the siding.
I do believe the existing siding will still protect the structure from what little water may get through still.

Siding Installation - Rain Expected


Will Enceladus run out of water due to it being lost to space?

Question: The global liquid water subsurface ocean within Enceladus has been identified as being the primary source of material for Saturn's E-ring. Given that the moon is permanently ejecting large quantities of water to space through the south poles how long will this ocean continue to survive?
Comment: And also it would collect it's own ejected water, to some degree
Comment: This question is probably more suited to Astronomy.SE. According to https://en.wikipedia.org/wiki/Enceladus it has a *lot* of water. Earth will probably lose its oceans long before Enceladus does.
Comment: @AntiElonGuy indeed, in [Enceladus; why use the words "geysers", "jets", and "plumes" interchangeably?](https://astronomy.stackexchange.com/q/19939/7982) I mention an escape velocity of only 240 m/s. That means that a lot of the ejecta droplets and ice particles will rise high but fall back down again in an hour or so (if they don't evaporate/sublimate). However, that's the same order as thermal velocity of water vapor at the surface, so some vapor molecules could leave forever ballistically.
Comment: different but slightly related: [How can "Geysers" on Europa reach heights of 100km?](https://astronomy.stackexchange.com/q/18496/7982) and also [Is there an established distinction between a geyser and a cryovolcano in solar system bodies?](https://astronomy.stackexchange.com/q/19943/7982)
Answer: No.
The approximate escape rate of water on Enceladus to space is $\rm \dot{m}_{\rm H2O}\approx 5000\; g\;s^{-1}$ (ref, with a factor 10 uncertainty in that number). Ganymedes icy mass $\rm m_{H2O}$, which I simply estimate at about 50% of its total mass would then need about $\rm m_{H2O}/\dot{m}_{H2O} \approx$ 400.000 billion years to escape, or about 30.000 times the age of the universe. In other words, Ganymedes water content at the current escape rates is stable.
Comment: The question asks about Enceladus. You first mention Enceladus & then discuss Ganymedes. Is there an error?
Comment: Is that a decimal point, or a thousands separator? According to Wikipedia, Enceladus is losing water at a much higher rate than what you gave for Ganymede:~200 kg/s (it ejects ~250 kg/s of salty water, but much of the salt content falls back).
Comment: @Fred Woops, it seems so.. when researching the material my thoughts must have jumped from one icy moon to another..
Comment: @PM2Ring A thousands separator. The same calculation with Enceladus' mass and your quoted escape rate gives a total lifetime of 0.6 ages of the universe. So then the answer would be "Yes, but it's gonna take a while".


Restoring deleted users OneDrive file

Question: Situation is like, user deleted from the system and his shared OneDrive file also deleted. How can I get back deleted file?
Answer: user needs to go to the website version:
https://onedrive.live.com/
once loaded on the left hand side menu at the bottom click on "Recycle Bin" -> select item and restore:

EDIT
4 months ago is pushing it. Depends on when the user was deleted? by the sounds of it it was provisioned a month ago which goes inline with the files missing as it takes 30 day to provision. Files might still exist.
to restore the user. Go to central admin -> under users on the left hand side select "deleted users" -> select the given user and hit restore:
go to https://portal.office.com/adminportal/home?rc=1
then

then

finally assign password to user.
now login to one drive:
https://onedrive.live.com/
find the file and restore -> save file in SharePoint or 365 group.
Comment: User left  4 month before and shared file was in another user's OneDrive seen last time one month before. Now user suddenly saw that file disappeared. I tried above mentioned things, there no Files on the Recycle Bin. I tried to get deleted user by the PowerShell but no chances. I think 90 days left, but I can see still deleted user name on the system by the PowerShell. But I can't access his OneDrive. Do you know how can I access to deleted user ONeDrive?
Comment: ahh might be a little late though but you could try. Do you have central admin access on 365?
Comment: Yes I have. How can I try?I tried with PowerShell nothing changed.I can access to another user OneDrive from PowerShell but only not for that deleted user
Comment: Dear Ali, I checked it already. User not existing on deleted users list.What else I can do?
Answer: You can recover/restore files from user's OneDrive recycle bin.  Deleted files are stored in the bin for 93 days.
More information is available here

Restoring deleted users OneDrive file


Measure on $\omega_1$

Question: Let $\mathcal{O}$ be the $\sigma$-algebra on $\omega_1$ generated by its countable subsets. Is there a ($\sigma$-additive) probability measure on $\mathcal{O}$ that is not concentrated on a countable set? (I am trying to construct a real random variable whose support has size $\aleph_1$.)
Comment: A set is in the sigma-algebra if it is countable or has a countable complement. Put measure 0 on the countable sets and measure 1 on the sets with countable complement.
Comment: Thanks for your comment -- I realize that I need to refine my question substantially. (I also see that there need be no probability measure on $\mathbb{R}$ whose support has size $\aleph_1$, because any closed set of reals satisfies the continuum hypothesis.)
Comment: Every uncountable Borel set has the size of the contiuum. If you just want such a measure for some $\sigma$a-gebra on $\mathbb{R}$, you can do the following: If the continuum hypothesis holds, you do what I described above. If not, you can do the same with the $\sigma$-algebra of those subsets whose size is at most $\aleph_1$ or whose complement has at most size $\aleph_1$.
Comment: Nate, I think the $\sigma$-algebra you're thinking of is substantially larger than the one you describe. Do you mean to restrict the Borel algebra to a set of reals with size $\aleph_1$?
Answer: Another nice example is related to this.  Let $\Omega$ be the set of all countable ordinals, with its order topology.  I may write $\Omega = [0,\omega_1)$.  Note that the last point is missing, but any countable subset has a supremum in $\Omega$.  Topologically, $\Omega$ is not compact, but is locally compact and pseudo-compact: Indeed, even stronger, any continuous function $f : \Omega \to \mathbb R$ is eventually constant.  The linear functional $\Lambda$ that assigns to each continuous function $f$ this eventual value, is what we want.  As usual, there is a measure $\mu$ so that $\Lambda(f) = \int_\Omega f\,d\mu$ for all $f$.  This is a good example of a measure with "empty support".  For every point $t \in \Omega$, there is a neighborhood $A$ with $\mu(A) = 0$.
Answer: The $\sigma$-algebra you describe includes all the sets of one element. Due to the countable additivity of measure, we conclude that the measure of any countable set is determined by the sum of the measure of its elements.
Suppose the set of positive-measure elements is uncountable. Then some countable set must have infinite measure. Proof: Consider the sets $\{x|\mu(x)\}>\epsilon$. For some $\epsilon$, this must be infinite. Choose a countable subset. (Clever ZF-without-choice mojo may enable you to construct a counterexample here).
If you're okay with that behavior, then the counting measure is an example.
If you're not okay with that behavior, then all measures will look like the sum of Michael Greinecker's measure and a measure of countable support. (Let $S$ be the set of positive-measure elements and $T$ another set, then $\mu(T)=\mu(S\cap T)+\mu(T-S)$, the first being the sum of its elements and the second $0$ on all countable sets, and therefore equal on all co-countable sets.)
Note: I think Gerald Edgar's measure is the restriction of Michael's measure to the Borel measure space.

Measure on $\omega_1$


Exchange Migration Contacts Issue

Question: We are migrating from a hosted Exchange 2007 environment to an internally hosted Exchange 2010 server. One problem that we've encountered during the migration is that users complain that when they reply to emails that were imported from before their migration, it bounces because there is organization info attached to the Reply-To address. I can't think of a way to alleviate this issue from the server side of things, but is there some sort of tool out there that can scrub PST files for Exchange organization info and replace those reply-to addresses with just the email address? Surely someone has had this issue before?
Answer: What you're getting into is x400/x500 code issues.  Exchange routes mail internally based on those codes, not based on SMTP address.  So there isn't a way to do a PST scrub.
What you can (and should) do is contact your old Exchange host and get a copy of the x500 codes, then import them into your Exchange 2010 environment.  Your bounce messages will stop instantly.
Comment: @Justin: What you're looking to get from the previous provider is the LegacyExchangeDN attribute value for each user from the old Exchange server (it's actually an AD attribute of the user object). You'll then use this attribute value to create an x500 address for each user.

Exchange Migration Contacts Issue


Sonar -LOC & Cyclomatic complexity

Question: How does Sonar calculates software metrics particularly LOC and cyclomatic complexity? Does it uses any particular tools? IF yes, please also give the names.
Answer: For each supported language, a "squid" plugin is used to parse the source code and determine some base metrics such as LOC and complexity. How the complexity is calculated varies based on the plugin.
For example, here's the source code files for the JavaScript plugin: https://github.com/SonarCommunity/sonar-javascript/tree/master/javascript-squid/src/main/java/org/sonar/javascript/metrics
In this case, the complexity is calculated in the plugin itself using a very simple formula.
And here is the same set of classes for the C# support: https://github.com/SonarCommunity/sonar-dotnet/tree/master/sonar/csharp/sonar-csharp-squid/csharp-squid/src/main/java/com/sonar/csharp/squid/metric
The creation of metrics, though, can be done by any plugin, so you could write your own plugin if you wanted to supplement the data, or display the data in a different way.
Also take a look at the answer to this question (about creating a new plugin) by Fabrice, one of the .Net plugin maintainers: SonarQube - help in creating a new language plugin
Comment: Is it the same for Java also? I would appreciate if you can provide the link for java plugin as I am analyzing Java projects. Thanks!
Comment: The code for the Java plugin's complexity calculations can be found here: https://github.com/SonarSource/sonar-java/blob/master/java-squid/src/main/java/org/sonar/java/ast/visitors/ComplexityVisitor.java
Answer: You can browse http://docs.codehaus.org/display/SONAR/Metric+definitions for more details.

Sonar -LOC & Cyclomatic complexity


Is it possible to upload my own PDF to kindle app for windows 8?

Question: Unlike "kindle for windows", for Windows 8 metro version of kindle app where is no "My Kindle Content" folder where i can place my own PDF files. Is it any way i can upload my own PDF file to it? I'm using Windows 8 Pro, not an RT.
Comment: Since you haven't received any reply on this question, have you tried asking Amazon support, or posting on their forums? It's possible that no one here knows, or maybe no one has used the Kindle MUI app. My advice in the mean time would be to just use the desktop version of Kindle.
Comment: @allquixotic Sure thing, if no one answers question after reward is set i will ask amazon. But amazon is a big company that has thousands of questions each day, so it will be very hard to evade they level-1 "sorry for inconvenience" support and receive real answer :).
Answer: According to Amazon, no. Look at http://www.amazon.com/gp/help/customer/display.html?nodeId=200939480. The last entry is:

Are Personal Documents supported?
Sending Personal Documents to Kindle for Windows 8 is not currently supported.

So no, sorry to have to tell you that, however the phrasing suggests that eventually, maybe.


git reset commit and push issue

Question: Recently it happened in my team that a fresher tried to do a git pull. Some conflicts appeared on the system after which the developer simply did a git reset (bringing the index to last HEAD). Then the developer "committed" one file change and pushed it to remote. Naturally quite a lot of changes were lost.
However it took us quite some time to figure out who did the bad change (and which commit was bad commit) and recovering it was a whole lot of different effort. Now in the git history (using gitk or git log) git only shows what files have been committed but this is case of overwriting previous files (I know this concept is more of CVS not git in which case files have been moved to a previous commit). What is the best strategy to debug in this case?
Once we know which branch is offending one, once I do a git diff between good and bad commit I can see list of files but looking at the particular commit only, can we find out what files have been moved to a previous commit.
Apologies if the problem is not entirely clarified.
Answer: Take a look at the output of git log -p branch-in-question and you will see changes made, file by file. You can now act accordingly by doing git checkout <some commit> -- some files to get the branch straight again. Add all the changes and commit and push. You should be good from here on.

git reset commit and push issue


Delete open book

Question: I want to create a new work book add a list into it and then save this book. If it is exist I need to delete previous variant and then save current. Here is my code:
Private Sub GenerateReport_Click()

    Dim wb As Workbook
    Dim FilePath As String

    FilePath = ThisWorkbook.Path + "\CommonReport.xls"
    Set wb = Workbooks.Add
    ActiveCell.FormulaR1C1 = "a1"
    wb.ActiveSheet.Range("B1").Select
    ActiveCell.FormulaR1C1 = "b1b"
    wb.ActiveSheet.Range("C1").Select
    ActiveCell.FormulaR1C1 = "3"
    wb.ActiveSheet.Range("D1").Select
    ActiveCell.FormulaR1C1 = "4"
    wb.ActiveSheet.Range("E1").Select
    ActiveCell.FormulaR1C1 = "5"
    wb.ActiveSheet.Range("F1").Select
    ActiveCell.FormulaR1C1 = "6"
    wb.ActiveSheet.Range("G1").Select
    ActiveCell.FormulaR1C1 = "7"
    wb.ActiveSheet.Range("A1:G1").Select
    wb.ActiveSheet.ListObjects.Add(xlSrcRange, wb.ActiveSheet.Range("$A$1:$G$1"), , xlYes).Name = "Ñïèñîê1"
    wb.ActiveSheet.Range("A1:G2").Select

    Application.DisplayAlerts = False

        If Dir(FilePath) = vbNullString Then
           wb.SaveAs Filename:=FilePath
        Else
        SetAttr FilePath, vbNormal
           Kill FilePath
        End If

End Sub

Is it possible to delete book when it is open. How can I handle an error when I want to delete opened book?
Comment: as a side note. It's probably better to do string concatenation with the ampersand. `ThisWorkbook.Path + "\CommonReport.xls"` --> `ThisWorkbook.Path & "\CommonReport.xls"` See: http://stackoverflow.com/a/7750689/726127
Answer: I think it is not necessary to delete the workbook, just overwrite it. If it is opened, close it first. Example:
Option Explicit

Private Const NEW_BOOK_NAME As String = "CommonReport"

Public Sub Test()
    Dim newWorkbook As Workbook

    Set newWorkbook = Workbooks.Add
    With newWorkbook.ActiveSheet
        [a1] = "a1"
        [b1] = "b1"
        [c1] = "c1"
    End With

    Dim filePath As String
    filePath = ThisWorkbook.Path & "\" & NEW_BOOK_NAME

    On Error Resume Next
    Workbooks(NEW_BOOK_NAME).Close

    On Error GoTo 0
    Application.DisplayAlerts = False
    newWorkbook.SaveAs filePath
End Sub

Answer: Olle Sjögren Idea sohould work.
But it could be easier to simply use the worksheet.usedrange.clear method to empty the existing worksheet. Then you could insert your new Data.
This should be a lot faster than the delete-approach.
Answer: You cannot delete an open workbook.
Check to see if a file with the same name is open using something like this: http://www.exceltip.com/st/Determine_if_a_workbook_is_already_open_using_VBA_in_Microsoft_Excel/472.html
If such a file is open, check to see if it has the same path as the file you want to delete by comparing FilePath with the open workbook (eg Workbooks("CommonReport.xls").FullName) and if so, close it by using the close command:
Workbooks("CommonReport.xls").Close SaveChanges:=False

Delete open book


What is the difference between BRAM and distributed RAM

Question: I am doing a project on BRAM implementation. What is the difference between Block RAM and Distributed RAM on FPGA in terms of implementation, area, speed etc? Which is better?
Comment: This is really covered extensively in a lot of random places on the internet (and FPGA datasheets). Did you have a look prior to posting?
Comment: Welcome to the site. Please realise this is not a free design house, homework-answering service or an on-line technical encyclopedia, copied out to you on demand. People will help you take the next step if your question shows you've done as much as you possibly could on your own - which yours doesn't, I'm afraid. Please edit your question and greatly improve it, showing your work and findings so far in considerable detail. The better the quality of question, the better the quality of the answers you will attract. Again, a warm welcome to the site.
Comment: I read much online finding the differencees. But I am unable to understand better, especially which one is better in area and speed. Also when some one says RAM is implemented in FPGA, is it done with BRAMs or anything else?
Comment: "DRAM" canonically stands for "dynamic RAM", and that's an unrelated thing, so to avoid confusion I expanded that abbreviation in your title.
Answer: Block Ram is a dedicated Ram that does not consume any additional LUT in your design whereas distributed Ram is built up with LUT.
In terms of speed the distributed RAM is faster than Block Rams.
Generally speaking, if not much Ram is needed you can consider to implement it as a distributed Ram. Some synthesizers may even use distributed Ram if you specifically chose Block Ram but just use a very small amount of a single block.
As soon as you have large Ram blocks it doesn't make much sense to use distributed Ram.


Why do custom engines typically specify a type like "Ford" or "Chevy"?

Question: I notice that when custom car engines are sold they nearly always have a big name type name like "Ford" or "Chevy". Is this because the block and crankshaft comes from those companies and the custom engine company makes everything else, or for some other reason? Why can't custom engine companies make the whole engine?
Answer: There is no reason in principle why a custom engine builder couldn't cast a block themselves. Everything done by the level of automation in this process could by done by hand, given enough highly skilled craftsmen.
https://www.youtube.com/watch?v=5oUDzkkdkpQ
Whether there are customers who would want to pay for a hand-made block which costs as much as the rest of the car is another question.
The other issue is that if you want to replace the engine in a production car, rather obviously you want something which has the same mechanical interfaces to everything else in the car. So unless you want to cast it from a different material for some reason, you might as well start from a standard block that already fits.
Comment: If it's a hand-made block for an entirely unique engine design that actually works better and as reliably as a stock engine, then it'll cost *more* than the car.
Answer: First, because designing a car engine takes an incredible amount of engineering.  It's not something that someone just sits down and does in an afternoon.
Second, because a "custom built" XYZ engine (302 Ford, 427 Chevy, whatever) is going to be much closer to a bolt-in replacement to a same-type engine.  A typical 65-75 small block Chevy engine won't even physically fit into the engine compartment of a typical 65-75 Ford, and visa-versa -- the companies arranged their cars differently, and the oil sumps are at opposite ends of the engines.  So even if you didn't get murdered by Ford fans for doing it, it would be a job and a half to put a small-block Chevy into a Boss 302 Mustang -- and ditto for a 302 Ford into a Camaro.
Third, there's this thing called "brand loyalty".  Even though I'm not possessed of much of it, if I have some nice Chevy, I'm probably going to want to put a Chevy engine in it.  Ditto Ford with Ford or Dodge with Dodge.  You might find me putting a small-block Chevy into a Henry J, though.
Comment: I put a Nissan TD23 into a Volvo 240 estate...
Comment: And I bet that if you could have bought a thoroughly hot-rodded Volvo engine it would have been a much easier engine swap!
Comment: Ahh, but not the fuel consumption... and we learnt a lot about the precision especially for the clutch release bearing...
Answer:
Is this because the block and crankshaft comes from those companies and the custom engine company makes everything else, or for some other reason?

Usually, yes. Custom engines come in various stages of tuning. Stage 1 is pretty close to a stock engine, with just a few components replaced. Those replaced components have to fit the original engine.
The more power you want to generate, the more components you need to replace. They still all need to fit the original engine.
For extreme applications (top-fuel drag racing), you can get engines where every component including the block has been custom-made and all that's left of the original engine is the main dimensions (distance between piston centerlines, distance between crankshaft main journals etc). These main dimensions remain because that means many of the parts are compatible across their entire catalog: a billet crankshaft that fits stage 3-7 is cheaper to make than a crankshaft that's unique to your 'everything is custom' stage 7 offering.

Why can't custom engine companies make the whole engine?

They can, it's just very expensive, and usually not necessary.
Big car companies produce engines by the thousand, and they have an assembly line set up to do this quickly and efficiently. Custom engine companies don't have the production volume to be able to afford this, so they have to spend more manual labor and machine time to build an engine. Things like the engine block are complicated to manufacture (requires big infrastructure for iron/aluminium casting, or a very expensive 5-axis CNC machine to mill the whole block).
So they only build the parts they really need to. A stage 1 tuning package doesn't require a new block, because the standard block has enough margin built in to handle the extra power.


Arduino Disconnects after router password changes

Question: I am working with arduino Uno R3 connected with EPS8266(http://www.amazon.in/ESP8266-Serial-Wireless-Transceiver-Module/dp/B00O34AGSU?tag=googinhydr18418-21&tag=googinkenshoo-21&ascsubtag=858e5035-7713-403a-942e-487a0fe24800). After router password is changed, it should be re programmed with new password. Is there any another way not to do so repeatedly. I managed 2 SSID for router which one have always unique password. But I think this is not a solution. Is there any technique or idea that says only for particular mac address, the SSID will be opened.
Answer: Routers have multiple "passwords".  I assume you are talking about your wireless encryption key (i.e. WPA/WPA2 key).  When the encryption key is changed, you are correct: you have to re-program the ESP8266 with the new key, because it can't learn this information on its own.  If this key were broadcast, then your network would not be secure as everyone would be informed of the encryption key.
Why is the key changing?  Is there really a need to change the encryption key often?
MAC addresses can be spoofed, so permitting a specific MAC address to "always connect" is not secure.
Comment: Thanks for ur valuable reply.. I am making a very secure wifi protocol that has a function to allow network for particular mac address. Because the device in which it is gonna be loaded will not be touch for next 5 years. In between if router changes may occur than this problem may arise.


Log network traffic with process ID on Mac OS X?

Question: I want to log all network traffic on a Mac OS X server (like tcpdump does), but including the ID of the process that is responsible. Using lsof only gives me the current connections, not the past ones.
Is there a way to do this?
Regards,
Jochen
Answer: While the nettop is nice for viewing the snapshot of current connections, you can use the tcpdump to collect the data and process information as well. With tcpdump use the option -k to display metadata for the captured traffic.
   -k     Control the display of packet metadata via an optional metadata_arg argument. This is useful when displaying packet saved
          in the pcap-ng file format or with interfaces that support the PKTAP data link type.

          By default, when the metadata_arg optional argument is not  specified,  any  available  packet  metadata  information  is
          printed out.

          The  metadata_arg  argument  controls  the  display of specific packet metadata information using a flag word, where each
          character corresponds to a type of packet metadata as follows:

                 I     interface name (or interface ID)
                 N     process name
                 P     process ID
                 S     service class
                 D     direction
                 C     comment

          This is an Apple modification.

So for example displaying the process id and process name, you can do this:
tcpdump -k NP

Answer: I recently had this problem too. One approach you can potentially take is to use both tcpdump and nettop in parallel (each, side by side, in their own terminal shells), and visually observe as the network traffic manifests.
For example, my firewall recently caught suspicious looking network traffic coming out of my Mac's Ethernet, on a private subnet which I did not recognize and on a port (TCP 7000) which looked unusual. In one terminal shell I ran:
$ sudo tcpdump port 7000

and in the other terminal shell I ran:
$ sudo nettop -m tcp

When the network traffic showed up via tcpdump, it nearly instantly was also was added to the nettop output, which indicated it was Apple's AirPlay helper daemon running with process ID (PID) 87 in this example:
AirPlayXPCHelpe.87

This may not necessarily be practical for observing all situations where you're trying to catch something on your network which looks anomalous but as a starting point may be worth trying vs writing a probably more complex DTrace script.
Answer: Sadly, the best way to do this (tcpsnoop, which uses DTrace to do exactly what you describe) does not work on the Mac OS X implementation of dtrace. You'd need some kind of application firewall (Little Snitch for example) but that's more of a desktop / single user thing than something you want running on your server.
This seems like an odd requirement actually, are you trying to make an intrusion detection system, or just figure out what is causing network access?
Comment: Just trying to see what's causing weird network traffic on my box. Regards, Jochen
Answer: I was going down this path for the first time just now. I found DTrace, while powerful, is now difficult to do due to the SIP system. I have Little Snitch installed for regular firewall purposes, but I wanted to start logging data as well.
Nobody here has mentioned that nettop has a logging mode which will output to CSV, and ultimately that's what I would like to get to. This seems to be fairly equivalent to the tcpdump -k NP approach. However, it didn't require me to 'sudo' the command.
I thought I'd just leave that extra note in case it's ever useful to anyone.


Appium :Click on capture image button of inbuilt camera in mobile app. is it possible?

Question: Appium(Android) :Click on capture image button of inbuilt camera in mobile app. is it possible?
Answer: I can't say for sure yes but I do have a trick I have used in the past. So, you'll want to open the Appium Inspector session. If you can find the selector then you're off to a good start. If the element is "not intractable" you can use the selector to get the size and location. From that you can derive where to Tap(x,y).


Story from the 1950s/60s/70s featuring a dangerous water creature like a yellow hammerhead

Question: Can anyone ID a short story (I think) from the 1950s/60s/70s about an expedition to a planet which is mainly water on the surface.  One of the human visitors sees, below him in the water, something threatening like a yellow hammerhead shark.  Possibly by Ray Bradbury, possibly published in the Gollancz hardback science fiction series?
Comment: This is a brief but detailed description of the story. Can you remember anything else that happens in the story you could [edit] in? Every little detail you add can help others identify this for yourself.
Comment: Sadly I probably read this fifty (fifty! argh!) years ago, and I can't dredge up anything else.  If anything else surfaces I'll certainly add it - thanks for asking though.
Comment: There's a Jack Vance novel that partially matches this, but it isn't about an expedition to an ocean planet, but rather people who live in floating settlements on it.
Comment: Thank you Spencer.  I wouldn't rule it out ... I suppose if you remembered what it was called, you would have named it ... ?
Comment: Maybe "Grandpa" by James H. Schmitz, online at https://web.archive.org/web/20150826151128/http://www.baenebooks.com:80/10.1125/Baen/0671319841/0671319841___2.htm ? The protagonist is on a "raft": a lily-pad-like life-form. At one point, he sees a white shark-like predator; his raft is also hijacked by a "Yellowhead". Maybe those together make you remember a yellow (hammer)head shark? But the planet is not all water, although the sea is where the action is. And not Bradbury's style. In Spectrum V, which did come in Gollancz hardback. Are there enough matches for me to put this as an answer?
Comment: How on Earth did you find this, Phil?  It must be the one.  I read it last night and see what you mean about it not being Ray Bradbury's style.  All those exclamation marks!  Thank you for answering something that I've been wondering about for years.
Answer: "Grandpa", by James H. Schmitz. Originally published in Astounding Science Fiction, February 1955. As mentioned in my comment above, an online copy is available at https://web.archive.org/web/20150826151128/http://www.baenebooks.com:80/10.1125/Baen/0671319841/0671319841___2.htm .
It's been anthologised in numerous places, and I've seen it so many times, which is how I found it. I have in front of me a copy of Spectrum V with it in. But equally well-known, in the UK anyway, would have been Penguin Science Fiction, which also republished it.
As you've confirmed that this is the story, I'm answering just for the record. After some delay, because of problems with my Internet connection.
A short story (I think) from the 1950s/60s/70s:
Original publication year 1955, but the impressive list of republications shows a new appearance almost every year up to 1990, and a few after 2000 as well. Some of these are merely new editions, but even so, it keeps on and on coming back.
An expedition to a planet which is mainly water on the surface:
"Expedition" is perhaps an understatement: "The Colonial Team was a practical, hard-working outfit—two thousand people who'd been given twenty years to size up and tame down the brand-new world of Sutang to the point where a huundred thousand colonists could be settled on it, in reasonable safety and comfort."
The planet isn't just water. For example, the station manager Nirmond complains about the protagonist Cord keeping "unidentified and possibly deadly vermin in the woods back of the station". But most of the action does take place on water. On page 3, Nirmond drives Cord and others down to the edge of the bay in a treadcar, and they stop at the edge of a marshy cove, from which they transfer to a "raft". These are organisms that look like "lily pads twenty-five feet across". The raft they take is called Grandpa, a "regular monster" at fifty feet across.
One of the human visitors sees, below him in the water, something threatening like a yellow hammerhead shark:
"The reed bed to their right was thick with Yellowheads, a colony of them. Vaguely froggy things, man-sized and better. Of all the creatures he'd discovered in the bay, Cord liked them least. The flabby, sacklike bodies clung with four thin limbs to the upper sections of the twenty-foot reeds that lined the channel. They hardly ever moved, but their huge bulging eyes seemed to take in everything that went on about them. Every so often, a downy swamp bug came close enough; and a Yellowhead would open its vertical, enormous, tooth-lined slash of a mouth, extend the whole front of its face like a bellows in a flashing strike; and the bug would be gone. They might be useful, but Cord hated them."
Or, later on and with a different predator: "It was the shattering of his [Cord's] hopes to swim to shore from here. Fifty yards away, the creature from which the rubbery thing had been fleeing showed briefly on the surface, as it turned away from the raft; and that glance was all he needed. The ivory-white body and gaping jaws were similar enough to those of the sharks of Earth to indicate the pursuer's nature. The important difference was that wherever the White Hunters of the Zlanti Deep went, they went by the thousands."
Comment: Thank you, Phil.  Interesting to know the story was such a popular anthology choice.  Very inventive, and some highly memorable images.


Is there heteroskedasticity in binomial GLMs?

Question: We know a linear probability model (LPM) will produce heteroskedastic errors by definition because of how the variance of a bernoulli r.v. is defined. My question is whether the same is true for logit/probit. I know that logit/probit can theoretically be amended so that marginal effects are not biased by heteroskedasticity, but does the argument for why heteroskedasticity is certain in an LPM carry through to the nonlinear logit/probit world?
Comment: It's still Bernoulli/binomial. The model for the parameter doesn't change that basic fact about the distribution
Answer: Logit and probit are special cases of the generalized linear model.  (For that matter, so is linear or 'OLS' regression, and thus so is the linear probability model.)  The generalized linear model was developed to, um, generalize standard regression methods.  The problem with OLS regression, when used for a binary dependent variable, is that it assumes the response is conditionally normal.  With a GLM, you can specify the response distribution as binomial.  From there, you can specify a link function, even using the identity function if you really want.  Logit and probit are simply different link functions (it may help you to read my answer here: Difference between logit and probit models).  A GLM with a binomial response, and either of those two link functions will properly account for the fact that the conditional variance changes as a function of the conditional mean.  So heteroscedasticity, in that sense, is not necessarily a problem.  (Whether you want to call the differing conditional variance 'heteroscedasticity' or not is somewhat a semantic issue.)
That does not necessarily mean that the model is modeling the conditional variance correctly, though.  One issue could be that the functional form is wrong, or that you should have used the other link function, etc.  Those imply that the conditional mean is incorrect as well.  But even beyond that, you can have data that vary too much.  If you only have one observation at each value in X, you wouldn't be able to see this, but if you have multiple data, you can sometimes see that the means are bouncing around the predicted means more than they should.  This can happen because there are other relevant variables that you haven't included (you may not even know what they are).  You could call this 'heteroscedasticity' as well (i.e., the term is somewhat ambiguous in this context), but it would be more common to call it overdispersion.


Intuition on Kronecker Product of a Transition Matrix

Question: Let $T$ be a $N\times N$ transition matrix for a markov chain with $N$ states. Thus $T_{ij}$ is the probability of transition from state $i$ to state $j$ (and thus rows summing to one). Now consider the matrix $$T_k=T\otimes T$$. Its easy to see that rows of $T_k$ sum to one and each entry is non-negative. Thus, $T_k$ is a transition matrix for some markov chain which has $N^2$ states. What is the relation between markov chains corresponding to $T$ and $T_k$. I am not able to visualize this.
Answer: I think you  just have a pair of independent chains.  The probability of making a transition from (i,j) to (k,l) is $p_{ik}p_{jl}$, where the first component is the state of the first chain and the second of the second.  The transitions out of the (i,j) state are found in the N(i-1) + j th row.
Comment: can you make any comment on the relation between the steady state probability vectors of both the chains?
Comment: Regarding the comment above, if $\pi$ is the stationary/invariant distribution, then $\pi \otimes \pi$ is the stationary distribution for the product chain. This is because
$$
(\pi \otimes \pi)(T \otimes T) = (\pi T) \otimes (\pi T) = \pi \otimes \pi.
$$
The first equality is just the "mixed-product" property of Kronecker products.


How can I show whether the following function is Increasing, Decreasing, or Constant returns to scale?

Question: I need to show whether or not the following function is increasing, decreasing, or constant returns to scale, but I can't figure out how to extract the t from it when it is put in the form $y(tX_1, tX_2)$.
$$
y = X_2\sin{\left(\frac{X_1}{X_2}-\pi \right)}
$$
Is there any other way of showing IRS, DRS, and CRS? Any help would be appreciated!
Answer: You have $$F(x_1,x_2)=x_2\sin\bigg(\frac{x_1}{x_2}-\pi\bigg).$$
If you multiply all factors by $t$ you get
$$F(tx_1,tx_2)=t x_2\sin\bigg(\frac{tx_1}{tx_2}-\pi\bigg).$$
Simplify the fraction and you are almost done.
Answer: in the case of for example a production function, returns to scale mean the effect when all factors of production are multiplied by a certain constant, with what constant is the production level multiplied?
i) the same constant as the factors of production (constant returns to scale)
ii) a larger constant (increasing returns to scale)
iii) a smaller constant (decreasing returns to scale)
So the right approach is to simply fill in a constant (let's call it c) in your function.
cX2(sin((cX1/cX2)-pi)
and try to rewrite it to
d(X2(sin((X1/X2)-pi))
where d is the constant with which y is multiplied as a consequence of multiplying X1 and X2 with c


where to buy a SIM card in Podgorica, Montenegro?

Question: Will I be able to buy a SIM card in Podgorica, Montenegro so I can use it when I'll be traveling there? Where to buy it and how much will it cost?
Answer: There are many places where you can buy it. One of them is a Telenor shop at Moskovska 20, in the center of Podgorica. A data service for 10 days costs 5 euro. If you want to make calls and send SMS, you have to top up your account with at least additional 2 euro. You must show your passport when you buy a SIM card.
Answer: I bought myself a tourist sim card for only 15 euros for a month. Almost unlimited internet for travel and work.
Specialized stores are easy to find on a Google map. Time for registration - 5-8 minutes. Need your passport. They don't work in Sunday.
Search:

mtel
tmobile
telenor

There is almost no difference. But in Mtel, I liked the mobile application more. With Tmobile had two cases that the Internet did not work (only social networks).


How to trigger protocol function in a view controller?

Question: DeviceTableViewCell
I create a protocol on my custom DeviceTableViewCell
protocol DeviceTableViewCellDelegate : NSObjectProtocol {
    func printMe(_ text : String)
}

I also declared my delegate in
weak var delegate: DeviceTableViewCellDelegate?

DevicesViewController
I had this
extension DevicesViewController: DeviceTableViewCellDelegate {

    func printMe(_ text : String) {
        let text = "Protocol & Delegate"

        print("........")
        print(text)
        print("........")
    }
}

I don't know how to trigger my print() statement.
How would one trigger it ?
Do I need to call my printMe() somewhere ?
Did I missing something here ?
Comment: Which ever class has the `delegate` property (presumable your cell class) must call the `printMe` method at some appropriate time. Only you know how it is to be used and when it should be called.
Comment: You treat a delegate as a placeholder. In future, you can assign any role to this delegate.
Answer: First, do this:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "YourCellIdentifier", for: indexPath) as! DeviceTableViewCell
cell.delegate = self
}

Then, you must call printMe from your cell to handle your action
Answer: Let's take example to understand the concept. So as you already create delegate variable for your protocol.
weak var delegate: DeviceTableViewCellDelegate?

Now to call protocol method you need to assign your delegate to some viewController or class. Let's assign in same view controller in viewDidLoad method.
override func viewDidLoad(){
   delegate = self
}

Now let's say need to call protocol method when some button pressed. So what you need to do is call this method like this in button press method.
delegate?.printMe("Button Pressed")

Answer: You just declare how the delegate function working, you haven't called it yet.
Based on the context, you can decide when to call delegate.printMe(_ text : "Foo").
I suggest a simple example you could refer: passing data back to previous view controller from current view controller using delegate.


Trying to repair avon roadster 2000 circa

Question: Looking for a Manual or pictures to help put back together an Avon roadster circa 2000.
Comment: @Criggie they still make them like this for the retro enthusiast.
Comment: You might need to ask specific questions about a part that is not working as-expected.  For a start, that's unlikely to be a 2000's replica.  The cottered pedal cranks suggest 1970s at the newest, and possibly older.   The rear brake under the chainstay looks too shiny, as do the rims.   What is wrong with it ?
Comment: @JoeK true, but generally not with cottered cranks.  I have seen a modern reproduction with rod brakes.
Comment: @Criggie have a look at what the Indian bike polo team ride. The cotter pin is only dead in the west.
Comment: It's a generic bike, built in 1970s style with cottered cranks, etc.  The brakes are the only "odd" thing, to a US observer.  If it is really ca 2000, though, it's hard to predict whether there might be cartridge bearings, etc.  But if you really need to "put it back together" you can start with any 1970s assembly manual for a regular "city" bike (vs racing or touring).
Answer: You do not need a special manual and there probably isn't any. You have to identify the kind of parts that are used on the bike. Like: quill stem, coaster brake rear hub, the type of bottom bracket (square taper) and so on.
Most skills you need for this bike are the same as on any other similar bike from older times so you need to get generc knowledge about bike maintenance - directed to older bikes specfically.
There are many resources you can use, books, vdeo tutorials, the Sheldon Brown's website. There are specific questions and answers here that list such resources.
Answer: As Vladimir says specific questions for issues will generate more detailed information. The problem is if you don't know what to ask for it's hard to know what to look for. Here is some information to get you started.
Here is a diagram of a bike like - but not exactly the same as - your bike.

Parts List

Sheldon Brown
Here is the link to the manufacturer's page for speedsters where you can still buy a brand new bike similar to this one. Contacting them might produce information on repair documents or parts availability.
search web or YouTube for

"rod brakes" for brake adjustment.
"cottered cranks"


How to fit ARMA+GARCH Model In R?

Question: I am currently working on ARMA+GARCH model using R. I am looking out for example which explain step by step explanation for fitting this model in R. I have time series which is stationary and I am trying to predict n period ahead value.
I have worked on this model but I am looking out for example where auto.arima() function is used for selecting best ARMA(p,q) based on AIC value.
Comment: I am not sure you will find a detailed example. Do you know the R package fgarch ? The garchFit() function might be useful  for your task at hand http://cran.r-project.org/web/packages/fGarch/fGarch.pdf
Comment: the link here has auto.arima() doumentation http://cran.r-project.org/web/packages/forecast/forecast.pdf
Comment: In practice, it is often easier to just make the AR part of the ARMA long enough so that it encapsulates however much MA the series is. This way you can just use normal regression methods instead of relying on numerical methods for ARMA.
Answer: I don't know how to select ARMA lag length when doing ARMA-GARCH. Perhaps someone can edit it into this answer.

For the univariate case you want rugarch package. If you're doing multivariate stuff you want rmgarch. The reason these are better than other packages is threefold; (i) Support for exogenous variables which I haven't seen in any other package, (ii) support for dynamic conditional correlations, (iii) support for a huge multitude of fGARCH variants.
install.packages("rugarch")
require(rugarch)

Let's construct the data to be used as an example. Using $N(0,1)$ will give strange results when you try to use GARCH over it but it's just an example.
data <- rnorm(1000)

We can then compute the ARMA(1,1)-GARCH(1,1) model as an example:
spec <- ugarchspec(variance.model = list(model = "sGARCH",
                                         garchOrder = c(1, 1),
                                         submodel = NULL,
                                         external.regressors = NULL,
                                         variance.targeting = FALSE),

                   mean.model     = list(armaOrder = c(1, 1),
                                         external.regressors = NULL,
                                         distribution.model = "norm",
                                         start.pars = list(),
                                         fixed.pars = list()))

garch <- ugarchfit(spec = spec, data = data, solver.control = list(trace=0))

Retrieve ARMA(1,1) and GARCH(1,1) coefficients:
garch@fit$coef

Retrieve time-varying standard deviation:
garch@fit$sigma

Retrieve standardized $N(0,1)$ ARMA(1,1) disturbances:
garch@fit$z

See what else you can pull out of the fit:
str(garch)

Answer: If you wander about the theoretical result of fitting parameters, the book GARCH Models, Structure, Statistical Inference and Financial Applications of FRANCQ and ZAKOIAN provides a step-by-step explanation. I think that it is not a big problem to implement these steps to R.
Answer: This should walk you through what you are looking for:
https://www.quantstart.com/articles/Generalised-Autoregressive-Conditional-Heteroskedasticity-GARCH-p-q-Models-for-Time-Series-Analysis
https://www.quantstart.com/articles/ARIMA-GARCH-Trading-Strategy-on-the-SP500-Stock-Market-Index-Using-R
Comment: Hi Chris J, welcome to Quant.SE! Could you please edit your answer so it stands on its own? These links on their own, while useful, do not make a good answer.
Comment: Sorry for trying to help, will never happen again.
Comment: I do appreciate that and I believe we need to think about the future. What if these pages go away?
Comment: I saw the question in your weekly newsletter and I instantly knew the links could help solve the problem. I can't leave a comment caus I don't have enough points or whatever. I'm sure the links will be very helpful for whoever looks this up in the future. I'm more focused on the end result than the nomenclature. I'm a trader that can code, not the other way around.
Answer: Here is a example of fitting Garch on financial time series. Application for regime switching in trading.
http://systematicinvestor.wordpress.com/2012/01/06/trading-using-garch-volatility-forecast/
Answer: I know this is an old question but I came across it when I was looking for answers for the same problem.
This article was very helpful to me:
http://www.rpubs.com/ddbs/gldforecasting
Answer: GARCH模型中的ARIMA(p,d,q)参数最优化 might helps. Although it is using Chinese language, but the coding is understanable to programmers.
Comment: Upvoted because of sheer guts

How to fit ARMA+GARCH Model In R?


Autocomplete while compiling a file with c++ is gone

Question: I am using Ubuntu 13.04 and have been programming mostly in C++. I use vim editor and c++ command to compile my .cpp file. What I have noticed is after typing c++ and pressing the Tab key, an autocomplete was expected for the files present in the current directory, but it gives no result. It was fine before, and I have become used to the c++ command for compiling my files.
Please help.
Answer: Try adding this to your .bashrc:
complete -f c++


Would Umbridge kill Harry if she got the chance?

Question: We all know Umbridge loathes Harry, but is there any indication whether she would have killed him (or had him killed) if the opportunity had presented itself?
Comment: VTC: This is question seeks opinion-based answers.
Comment: @Lexible - I disagree. There's ample textual evidence that she's not likely to commit murder, even when it would have benefited her
Comment: I can't imagine what Voldemort would do if she had killed Harry instead of him. I do not think Umbridge would be too keen on finding out that one either.
Answer: Nope. There's no point at which she would outright kill him, even if the opportunity arose (which it did on many, many occasions).
That being said, she's perfectly happy to put him into dangerous situations where death might occur.

The Ministry Years (1993 - 1995)
The first time she encounters him (as a threat to her position at the Ministry) she tries to dispose of him non-lethally, by sending Dementors after him. She's equally happy to discredit him as to cause him to lose his marbles as long as he's out of the picture. There's no good indication that she wants to kill him, although I think it's fair to say that if he'd somehow died in the encounter, she wouldn't have shed a tear.

'Somebody had to act,' breathed Umbridge, as her wand came to rest
pointing directly at Harry's forehead. 'They were all bleating about
silencing you somehow – discrediting you – but I was the one who
actually did something about it … only you wriggled out of that one,
didn't you, Potter? Not today though, not now –' And taking a deep
breath, she cried, 'Cruc—'

As Professor and Headteacher at Hogwarts (1995 - 1997)
When she's teaching him (and latterly as headmaster of Hogwarts), she has nearly endless opportunities to 'accidentally' kill him, blame it on a student, blame it on one of the castle's various hazards, dispose of the body and claim that it's all a big mystery, claim that he attacked her and that she was forced to defend herself, etc etc. She doesn't, though. She just tries to make him compliant.

'Evening, Professor Umbridge,' Harry said stiffly.
'Well, sit down,' she said, pointing towards a small table draped in
lace beside which she had drawn up a straight-backed chair. A piece of
blank parchment lay on the table, apparently waiting for him.
["Avada Kedavra!" she cried, killing Harry instantly with the wand she'd confiscated from Hargrid's umbrella.]٭

Back to the Ministry (1997+)
After returning to the Ministry, she heads up the Muggle-Born Registration Commission. She doesn't appear to have any special desire to kill anyone, including Harry, although if the opportunity presented itself to send him to Azkaban, she would presumably have no compunction about doing so. Again, if he died resisting arrest I dare say she'd smirk a little, but she's not sending death squads out to kill him.
Even in the films, the posters she's seen mailing out don't call for his death, only information about his whereabouts, so that he can be arrested and tried.

٭ Note that this doesn't actually happen.
Comment: @FreeMan - I was highlighting that there's umpteen times when she has him completely at her mercy and could have killed him. But yes, I invented that bit.
Comment: I'd argue that sending Dementors to Kiss Harry is way way worse than killing him.
Comment: It's been a very long time since I read the books. Where does the "["Avada Kedavra!" she cried, killing him with the wand she'd confiscated from Hargrid's umbrella.]" portion of the 2nd quote come from? I'd have thought that might stick out in my mind, but it doesn't.
Comment: @Roberto - It's not clear what her intentions were. She's evidently pretty happy whether he gets caught and kissed, defends himself (futilely) or defends himself (successfully)
Comment: @FreeMan I never read that part of the book, but seeing that it was written in [square brackets], I started wondering if that was part of the story or if Valorum invented a situation in which she could have done it if she truly wanted to kill him. Either way, I found it both confusing and amusing.
Answer: Umbridge tried to Soul-Assassinate Harry with Dementors,

She tortured him with a Blood Quill,

She threatened to use the Cruciatis Curse on him,

Then she was the highest ranking non-imperiused official at the Ministry under Voldemort's reign when it issued a "Wanted, Dead or Alive" style reward for Harry.

So yep!
Comment: None of these things indicate a desire to kill him. And the poster doesn't say "dead or alive", it says that they want info about his whereabouts.
Comment: Umbridge is probably not so much feeling murderous as she is feeling of pique or resentment at some often fancied slight or insult.
Comment: @FreeMan - Well, the other came after and is basically a duplicate, which would explain the downvotes. Note that this one isn't doing too well either, largely because it doesn't actually answer the question asked. The other one also has that problem.
Comment: Interesting that this (currently) has 2 up votes, while [this nearly identical answer](https://scifi.stackexchange.com/a/254913/53088) is at -4. They've got the same examples, this one just includes pictures.
Comment: @FreeMan One might question whether or not the pictures (albeit coming from the movies) can serve as a way to prove that it truly happened, rather than just random speculations. But yeah, I see what you mean.
Comment: Oh, forgot to check the time stamps. My bad.


Does "to hound someone" sound rude?

Question: How rude on the scale from 1 to 10 does it sound to say "You hound me when I'm at work and on my way back" to a close friend if I want to let them know I'm busy to reply to them right now? Is "to hound" in general a neutral slang term or is it more positive/negative one and what are its additional subtle meanings?
Comment: It sounds angry rather than rude, as though you are accusing them of annoying you on purpose.
Answer: To hound someone is not slang. It's a figurative expression.  It means to pursue or harass someone, like how a hound (a hunting dog) pursues its prey during a hunt.
It's not rude as such, not like a swear word, but it doesn't have a positive meaning. Hounding someone is generally a bad thing to do. It's probably not something you should accuse a friend of doing, especially if you want to remain friends with them.
Answer: It depends on who the person is, and what you say they are doing. To be hounded is a bad thing, ranging from a slight nuisance to serious persistent harassment or even stalking. A friend might forgive you for accusing them of slightly bothering you, others might not. A 'number from 1 to 10' cannot be provided.
Another persistent animal which has become a verb is the badger. If you badger someone you continually pester them in some way.

Does "to hound someone" sound rude?


SQL Server 2005- Investigate what caused tempdb to grow huge

Question: The tempdb of my instance grew huge eating up all the available disk space and causing applications to go down. Had to restart the instance in emergency. However, I want to investigate and dig deep as to what caused the temp db to grow huge all of sudden. What were the queries, processes that casued this? Can someone help me to pull the required info. I know I wont get much of historical Data from the SQL serevr. I do have the Idera SQL Diagnostic Manager(third party tool) deployed. Any help to use the tool would be really appreciated.
Comment: I don't think you can do a postmortem analysis. However, you can read plenty of interesting information about how to track your tempdb usage here: http://technet.microsoft.com/library/Cc966545
Answer: As for postmortem analysis, you can use the tools already installed on your server. For future  proactive analysis, you can use SQL traces directly in SQL Profiler, or query the traces using SQL statements.
sys.fn_trace_gettable
sys.trace_events
You can also use an auditing tool that tracks every event that happened on a SQL Server instance and databases, such as ApexSQL Comply. It also uses SQL traces, configures them automatically,and processes captured information. It tracks object and data access and changes, failed and successful logins, security changes, etc. ApexSQL Comply loads all captured information into a centralized repository.
Answer: There are several reasons that might cause your tempdb to get very big.
A lot of sorting – if this requires more memory than your sql server has then it will store all temp results in tempdb
DBCC commands – if you're frequently running commands such as DBCC CheckDB this might be the cause. These functions store its results in temp db
Very large resultsets – these are also using temp db to run properly
A lot of heavy transactions such as bulk inserts
Check out this article for more details http://msdn.microsoft.com/en-us/library/ms176029.aspx on how to troubleshoot this.
Answer: AK2,
We have Idera DM tool as well. If you know the time frame around what time your tempdb was used heavily you can go to History on the Idera tool to see what query was running at that time and what lead to the server to hose... On the "Tempdb Space used OverTime" you would usually see a straight line or a graph but at the time of heavy use of tempdb there's a pike and a straight drop. Referring to this time-frame you can check into Sessions>Details too see the exact query and who was running the query.
In our server this happens usually when there is a long query doing lots of join. or when there is an expensive query involving in dumping into temp table / table variable.
Hope this will help.
Answer: You can use SQL Profiler. Please try the link below
Sql Profiler


Inkscape> Isolate seamless repeat from cloned tiles

Question: I recently found out about the tiled clones tool in Inskcape, so I've been tinkering with it a bit. Is there any way to isolate the seamless repeat out of a pattern? I attached an example below. I created this pattern with the PGG simmetry and would like to isolate a (vector) seamless repeat. What I've been doing up to now is eyeballing the repeat and using guides to help me create a suitable clipping mask, then testing the repeat by creating a pattern fill out of it. However, while this process was fairly easy with this example, it's not always immediate with more complex patterns, which makes the process tedious and prone to mistakes. Is there any way to automate this process e.g. with a script or something like that?
Answer: There's nothing I know of that will do that automatically. Although user287001's answer is probably the closest you will get.
Anyway, if it was me, I'd construct such patterns differently. I'd create a seamless tile manually, then clone the whole tile. You can use the grid and snap to grid to help get the positioning of  repeating pieces that overlap the edges, left, right, top and bottom of the tile to make it seamless.
Here's an example. I've colour coded the triangles so you can see those that repeat. The final design uses the grey box as a clip, then I converted it into a clone. I then placed the first clone on the page, then duplicated and placed the others using snap to grid.

One benefit of using a clone here is you can edit the source and add more complexity and the other clones will update automatically.
Example
Comment: Thank you for your reply. I usually make more complex patterns manually (and mostly not in Inkscape as I struggle a bit with its layer management), but in this case I was looking for some easy and quick workflow to make simpler coordinates, so making these manually would defeat the purpose.
Comment: @Danyan You only have to create one seamless tile manually using this method.  It doesn't involve any layers or layer management. The pattern is made of clones.
Comment: I prefer to have elements organized in groups and layers, especially when more complex motifs are involved. By the way, I am not saying that it isn't doable in Inkscape, but I find it more cumbersome overall.
Answer: There's no need to "eyeball" horizontal nor vertical repeat intervals. There's surely some nodes if you have vector paths (=no raster images, effect results nor non-path presets such as rectangle or ellipse). You should be able to find corresponding nodes at horizontal and vertical repeat intervals.
Unlink and ungroup all shapes of your tiled pattern. If there's non-paths, convert those objects to paths. Nothing else is allowed. See the Objects panel to be sure all groups are ungrouped.
Draw a rectangle which covers one horizontal and one vertical interval of your pattern. If you have point snaps ON you can drag the rectangle diagonally between corresponding nodes.
Select the new rectangle and all shapes below it. Apply Extension > Boolean > Intersection. It clips the shapes without combining them. They stay independent and keep their colors.
There's one hitch: If there's open paths they get closed which will spoil the appearance. To keep it visually right have all filled shapes as closed paths and convert open stroke-only paths to filled areas with Path > Stroke to path.
BTW. Some extensions were lost when Inkscape v1 appeared. I do not know if you have working Boolean ops extension in your Inkscape build. This https://inkscape.org/~Moini/★multiple-boolean-operations-with-inx-pathops is a working fixed version with many enhancements. You should read the Inkscape documentation to learn how to install new extensions.
Comment: yes after thinking about it for a while I arrived to a similar conclusion using the coordinates of the bounding boxes of repeating elements. "If you have point snaps ON you can drag the rectangle diagonally between corresponding nodes." not sure I understood how to do this but I'll make some tests. Thanks for the extension link, I will look into it!
Comment: One thing isn't clear: Why to use pattern fill. You could simply set clip if you already have tiled clones. In addition you would avoid visible gaps at the seams. Inkscape renders 1px wide transparent zone to a perfectly fitting seam. That's anti-aliasing.
Comment: I use the pattern fill at the end, after setting the seamless clip in the tiled clones. I basically fill a rectangle so I can easily see how the pattern looks at different scales, sometimes try to rotate it etc. (I could do this by manipulating the tiled clones, but I find it easier to compare different versions by putting several rectangles in a row and filling them with the pattern)


Boss says that I'm pretty a good worker but not as good as XXX

Question: I had a casual conversation with my boss while running errand with him today.  When the discussion came to my work he said that I'm pretty good but not as good of a worker as ___ who was a previous employee that left.  Should I be worried and is he insinuating that I need to step it up?
Comment: You should have told him "Oh really? Well you're not as good as my old boss too!" just to make him feel what you felt like.
Comment: Are you relatively new?  And is this a very small company?  If so, it would be natural to refer to ____ that way if ____ had been an employee for a while (compared to you), or perhaps one of the early/original employees.  Your value will go up with time, especially given that your boss already has a favorable impression of you.
Comment: Did he told you what to make better ? as it can be a bad way to talk to you about what to ameliorate.
Comment: Well obviously you just need to be more hard core.
Comment: Very few workplace-related things are as good as XXX.
Answer: You should be worried, but not for the reason you think.
Describing your performance in comparison to another individual is an incredibly unprofessional thing for your boss to do.  Either he is very naive as a manager, or he is being a jerk on purpose.  Either way, working for him is likely going to be rather unpleasant.
Answer: No need to worry. "Pretty good worker" is the most important thing. And if you are the second best of ten workers, but not as good as the best, your job is safe. Especially if the best worker doesn't work there anymore :-)
Comment: well the thing is he only had like 3-4 employee not 10 if I was 9 out of 10 then yes I would agree


How to make a voltage controlled adjustable resistor?

Question: I need it for simulating PT100, PT500, PT1000 RTDs, and thermistors in a temperature range of 0-200 °C.
What I want to do is for example: enter 50 °C using a microcontroller, and through the DAC output, it generates me a specific voltage, which I can use to adjust a resistor.
I have to connect it as a two-terminal to devices, and it has to behave like the temperature is 50 °C.
Comment: I think this is not the right way to go for thermistor calibration. You can get close to the correct operation by calculations, the rest should be done using reference temperatures (standards).
Answer: A "digital potentiometer" may help you. Its input is digital, generally I2C, so you can drive it directly with the microprocessor. You can find them in stores like Digikey, Mouser and so on...
If you are looking for an analog solution, then you could use use a MOSFET in triode operating region, or a voltage controlled current source. But this solutions may take more design time, specially if you want to connect them as a two-terminal device, which I interpret from your question .
Answer: I presume you will want some level of accuracy.
For the PT100 simulator, I suggest a high quality low tempco 110 ohm resistor. Now put a digital pot, or a voltage controlled FET, in series with a padding resistor, across the resistor to bring its value down to the 100 ohm region.
By suitable choice of padding resistor and digipot/FET resistances, this allows you to use effective resolutions for the pot that you wouldn't otherwise be able to use. It also means that the drift in the adjustable element is 'diluted' by the good quality fixed resistor.
Answer: In addition to the other fine ideas, you could use a voltage controlled oscillator to produce a clock of variable frequency, and then use switched capacitor techniques to produce an effective resistor that varies with clock frequency.
Answer: This is presented as an incomplete answer.
Most Pt100 circuits work by feeding a constant, known, current in the order of 1 mA through the sensor and by measuring the voltage developed across its terminals to either calculate or look up the temperature. By replacing the Pt sensor with a calibrated resistor we can easily simulate the 0°C condition. Any temperatures higher than zero can be simulated by pushing additional current from an external source through the resistor.

simulate this circuit – Schematic created using CircuitLab
Figure 1. Pt100 / 500 / 1000 simulator.
If the sensor current is known and is exactly the same on every device to be tested the circuit of Figure 1 might go some way to providing a solution. For example, assuming 1 mA from the Pt100 source and SW1 closed and "resistances" of 100 Ω at 0°C and 119.25 Ω at 40°C (based on 0.385 Ω/K, which I have not checked):

Voltages required across R1 will be 100 mV and 119.25 mV respectively.
Setting DAC voltage to 100 mV should result in the op-amp contributing nothing as the voltage drop from the Pt100 current source will provide the required voltage drop and the op-amp input terminals will have equal voltage and will be "happy".
Setting the DAC voltage to 119.25 mV will cause the op-amp output voltage to increase, driving additional current through R1 and causing its voltage to rise unitl then non-inverting input is also at 119.25 mV. This should result in a 50°C reading on the instrument under test.

"Ah," I hear you cry, "but we don't know the source current!"
Well then we'll have to measure it.

simulate this circuit
Figure 2. Pt100 / 500 / 1000 simulator with sensor current measurement.
By reducing the DAC output to zero the op-amp output will go to zero. D1 prevents the op-amp from loading R1. By reading the resultant voltage across R1 we can calculate the current and scale the DAC output to suit. D1 should be low reverse leakage type.
Note that the circuit must be floating and not have any other connections to the device under test. Reverse connection protection is advised: a diode from op-amp output to V+ and another from GND should do the trick.

Several design challenges remain:

Adequate resolution on the DAC output. This may be possible by using the full DAC output range and using a further op-amp circuit to amplify (gain < 1) and offset the control signal.
Adequate resolution on the ADC input. As above but remove offset and scale up.
Comment: Thanks! This solution is working with thermistors as well, if the device uses the same technique for measurement, right?
Comment: It should do. One thing I forgot to mention is that if you want to go to negative temperatures you need to choose lower value resistors than the standard 100, 500 and 1000 Ω values. Let me know if this works for you.
Answer: Voltage controllerd resistor is called transistor. But why voltage controlled? There are SPI controlled resistors, more accurate and nice.
Comment: I don`t think that a bipolar transistor can be used as a voltage controlled resistor - hower, a FET can! But note that the voltage across this resistor (must be grounded!) must not exceed some hundreds of millivolts (due to a certain degree of non-linearity).
Comment: Bipolar may either, depending on circuit. He probably has pull up, so current will be directly translated to voltage, same as resistance
Comment: Oh, and linearity is not an issue- just have to use lookup table for voltage vs temperature
Comment: I thought about that, but my biggest issue is that: for PT100, 1°C means 0.385 ohm, and i couldn't find a digital potentiometer with that kind of resolution.
Comment: Gregory K. - Definitely. a bipolar transistor cannot be used as a "linear" resistor. Did you ever see such an application?
Comment: Again, in the MCU he has to make a table of voltage vs resistance. The problem with bjt is that minimum Vce is higher than he wants.
Comment: Gregory - which path within the transistor has a quasi-linear voltage-current relationship?
Comment: The one that starts from a resistor on the base.
Comment: Sorry, I do not understand. As an example: The drain-source path of a FET can be used as a resistor controlled by VGS (for small voltages). Do you think that something similar does apply to the BJT?
Comment: As i said, depends on the other circuit. If he uses pull up resistor, definitely yes. In other cases maybe. If he uses DMM- definitely no.
Comment: The properties of a BJT do not depend "on the other circuit". The BJT is a part with a strong non-linear voltage-to-current characteristic. More than that, the Ic=f(Vce) curves do not cross the origin.
Comment: Man, have you ever used it? Come on, simplest circuit, 10kOhm on base, emitter connected to GND, 1000R pull up on collector. That's it, there is a simple and cleat dependence of Vce on Vin (applied to the othet side of base resistor).
Answer: The practical way to make a high accuracy simulated resistor (other than a few dozen switched resistors) is to assume that there will be a current through the resistor (usually something like 100uA to 1mA for RTDs, but it could be lower or higher), and to assume it's DC (though sometimes it isn't).
Measure the current at a terminal (say into a virtual ground transimpedance amplifier configuration capable of sinking or sourcing the maximum anticipated current), and force the other terminal to a voltage Vout = Imeasured * Rsim. The DAC output has to handle the maximum voltage anticipated across the sensor and the maximum current anticipated.
The calculation could be done digitally- measured with a bipolar ADC and the output delivered via a bipolar DAC, but it's often better to just use a 4-quadrant (2 used) multiplying DAC for faster response and simplicity. You feed the (bipolar) current measurement into the DAC, along with the digital data for the simulated resistance.
Of course all that is easier said than done, but it's not too difficult for anyone who designs precision instrumentation (unless you want to consider pathological cases where current is very low or very high, or where the energization is AC or switched DC). In the latter case you have to start worrying about the frequency response.
Answer: I see several suggestions for digipots and FET's in varying configurations, but no one has mentioned light-dependent-resistors yet.  Like the name suggests, LDR's have usably-varying resistance depending on the amount of light that hits them.
I don't have any personal experience with them, except to read well-described schematics - mostly audio gear like compressors and crossfaders - but they might be worth looking into.  Potential issues are:

Uncalibrated accuracy: likely to have a wide tolerance from the manufacturer but consistent behavior of each unit.
Light leakage if you make your own LED+LDR unit.  (They can also be bought.)

Neither problem should be a deal-breaker; like all approaches to all projects, you just have to be aware of the potential issues and account for them.
Answer: I'd use a dual ganged motor potentiometer, so I can read back the current position using an ADC and make adjustments by controlling the motor.
Pro:

easy to build
easy to calibrate
fully isolated

Con:

moving mechanical parts


ETH adress creation time?

Question: Is it possible to find out ETH adress generation time (I have adress and want to find out time of it's creation and if possible also is it was created by exchange)?
Answer: All possible ethereum addresses are actually already created. It's kind of like if all the atoms in the universe were a private key, and all you're doing is selecting a random atom in the universe and making it yours. Although it's possible for someone else to select that random atom in the universe, the chances of that actually happening is close to 0% because the number of possibilities is 2^256.

You can however know when the first transaction occurred via a particular public address.
Answer: This isn't possible.
An address is derived from the public part of a public/private key pair. The public key is derived from the associated private key, which is generated first.
The private key is 256 random bits. You can, if you're so inclined, generate it by flipping a coin 256 times. None of those bits convey any information about when the random number was generated, or who it was generated by. That would be a security hole.
Also note, I can do all this offline, without anyone ever knowing I've done it. My address/key-pair can sit there for years, unused, until I decide to use it. Finding out the first time I use my address to send or receive a transaction is a different matter, and can be done, in its simplest form, by looking on a bog-standard block explorer.
Comment: thnx :( and also I can found out that this adres did not exist one year ago for example?
Comment: There's no way of knowing if someone has generated a key-pair that corresponds to an address, no. (Again, because they can do all this offline and not use the address.) You can check whether someone _used_ the address before a year ago by using etherscan.io, but that's the best you can do. Until the address is used, no one can know if it exists.

ETH adress creation time?


Trading crypto currencies with dollars

Question: After I have bought a crypto currency at an exchange like Binance can I sell for dollars if it is going down. Basically if I have a profit from a currency what can I do with it to protect it?
Answer: Yes, cashing out is profit protection but, it is also a stop gain. Follow the exchange user guide for instructions on how to sell or contact their support team, the details of how you do this are exchange specific.
Answer: If you don't have your private key, and the custodial wallet that does have your private key is no longer accessible, then you cannot move your coins or "cash out".
Invest in a hardware wallet, and transfer your coins out of any custodial wallet if you plan on hodling the coins.  That way, if you ever need to cash out, you can.
Answer: Yeah, Willtech is right. You can withdraw your assets if exchange you're using allows doing that. By the way, not only Binance offer such an option. It's also possible to cash out with Cex. Just take a look.

Trading crypto currencies with dollars


grey cast iron from freezing point to room temperature (cooling process)

Question: Do grey cast iron expand from freezing point to room temperature (cooling process)?
Answer: The thermal expansion coefficient for grey cast iron is ~ 10.8 in/(in*degR) see: list of expansion coefficients.
This would indicate that expansion is expected from ambient temperature to melting temperature so the reverse would be to expect shrinkage while cooling to ambient temperature.
Slightly related note, I was taught that gray cast iron is more ductile than regular cast iron so it is less susceptible to shrinkage cracking while it is cooling, for whatever that may be worth.
Answer: No and yes; and no. Pearlitic grey freezes as austenite plus graphite. It shrinks as it cools until the austenite transforms to pearlite , this causes expansion over a very short temperature range . Then the pearlite and graphite continue to shrink. This is a higher strength grey iron. The other grey iron ( most common): Ferritic iron probably freezes as ferrite and graphite and shrinks all the way to room temperature ( no phase transformation).( There is a chance there is some austenite to ferrite transformation at high temperature like 1600 F if small amounts of austenite are formed during freezing). Nodular (ductile) iron is about the same . Malleable iron is a different story.White cast iron is very hard and brittle ,has few uses , mostly it is made into malleable iron by heat-treatment


Is There a Better Strategy for this Combination Scenario?

Question: An elevator containing five people can stop at any of seven floors.
What's the probability that no two people get off at the same floor?
Assume that the occupants act independently
that all floors are equally likely for each occupant.

For the denominator, since each person has seven choices,
there are $7^5$ way that the passengers can occupy the 7 floors.
Then, for the numerator, let the 5 passengers form one group,
and 2 imaginary passengers forming a second group.
So there are 7! permutations, but since the order among the 5 passengers and the order among the 2 imaginary passengers do not matter, you have $ 7!\over 5!2!$ ways that the 5 passengers can occupy the floors such that each floor has only one or zero passenger.
Altogether, you have $7 \choose 5$ / $7^5$.

I am pretty sure that I got the numerator correct.
It took me a long time to figure out the appropriate analogy;
is there a more direct method to this question?
Furthermore, why is the denominator $7^5$ and not $6^7$?
In the context of this question, $6^7$ means that each floor can take 0, 1, ... 5 passengers.

Thanks!
Answer: You are correct that each floor can have $0$ to $5$ occupants, but they are not independent.  If one floor has $5$ all the others must have $0$.  $7^5$ is correct for the denominator.
Answer: Note that in your denominator, you've allowed different arrangements of people on the same floors to count multiples times i.e. Person A on Floor 1 and Person B on Floor 2 is counted differently to Person A on Floor 2 and Person B on Floor 1 hence your numerator should also allow different arrangements to be counted. So the numerator should be $^7P_2=\frac{7!}{2!}$ not $^7C_2$.
The denominator wouldn't be $6^7$ as you claim because you've removed all dependency on the number of people. This method of counting would allow for anywhere between 0 and 35 people.
Comment: You raised a good question about the numerator.  I have a think about this one.


Get rid of raster grid cells that are less than 1

Question: I'm using QGIS to work with raster data. I have a raster dataset of a country where each grid cell is assigned a number 1-100. However, the raster is in the format of a rectangle based on the extent of the file, so all of the cells outside of the borders of the country are assigned a 0. I cannot figure out how to create a GeoTIFF that excludes these cells that have a value less than 1. Any ideas? Thanks!
Answer: The usual approach is to set cells with value 0 transparent. Check layer properties "Transparency" tab and add an entry for the value 0.


What is the cardinal of all discrete probability distributions (discrete and continous)

Question: So I should build a map between something countable, I suppose, and all discrete probability distributions. The same for continous. My attempt:
As for every discrete probability distribution there is a table of probabilities $p_i$ for some $x_i$ we can list all these tables. Set of pairs $<x_i,p_i>,\; i=1,2,\ldots$ is obvioulsy countable and as uniou of countable sets is sountable we conclude that set of all discrete probability distributions is countable.
But I don't have any clue about continous distributions. What can I map them with? Hints?
Comment: What is the real problem here?  Your stated problem, starting with "So", reads  like a step in a larger program of yours.  What is it?  By the way, the set of discrete measures on the reals is not countable.  The collection of all point masses at singletons, $\{\delta_x: x\in\mathbb R\}$, where $\delta_x(A)=1$ if $x\in A$ and $0$ otherwise, has the cardinality of $\mathbb R$.
Comment: "So" reffers to the header. I don't understand your example. Could you explaint it in more detail?
Answer: The answer to the question apparently being asked  is No: the cardinality of the set of discrete distributions is uncountable.
Let $P_a$ denote the Bernoulli distribution with expectation $a$, that is, $P_a$ is the probability law for which $P_a(X=1)=a$ and $P_a(X=0)=1-a.$  The set of all Bernoulli distributions is $\mathcal B = \{P_a: a\in[0,1]\}$.  All members of $\mathcal B$ are discrete distributions.  Note that $P_a\ne P_b$ if $a\ne b$, that is, the distributions in $\mathcal B$ are all unequal to each other. But the cardinality of $\mathcal B$ is equal to that of the set $[0,1]$. Since $\mathcal B$ is a subset of the set of all discrete distributions, this letter set is  not countable, either.
One might ask, whether there exist only countably many triangles in the plane, because a triangle is uniquely specified by its vertices, and each triangle has only 3 vertices.  Or if there are only countably many line segments in the line, because each segment has only two endpoints. Or only countably many points in the Cartesian plane, because each point is a singleton set $\{(x,y)\}$ of only two coordinates, and hence countable.
I hope I have misunderstood this question.


diffusion coefficient derived from simple random walk in a 1D semi-infinite domain

Question: Suppose we have a 1D domain $x\in[0,\infty)$ and particles released at $x=0$ are doing simple random walks along the domain with reflecting boundary conditions at x=0. Then we can write down the evolution equation of particle position.
If we derive the mean and variance of the particle distribution as functions of time, would the the instantaneous diffusion rate be
$D=\frac{1}{2}\frac{d\sigma^2(t)}{dt},$
where $\sigma^2(t)$ is the variance if the mean $E(x(t))^2$ is nonzero? If so, why it is not $D=\frac{1}{2}\frac{d\sigma^2(t)+E(x(t))^2}{dt}$, half of the derivative of the second moment, which represents the mean square displacement. Thanks in advance.
Answer: Without the reflecting boundary condition, the diffusion coefficient follows from the mean square displacement,
$$E[x(t)^2]=2Dt.$$
Reflections at the origin have no effect on this expectation value, so the equation still holds.


Capacitor safety

Question: After looking at some posts,I started wondering if using capacitors,especially electrolytic ones is as safe as I thought.After making sure that the you don't supply a bigger voltage than the rated one and checking,if you have the corresponding type,that it's polarized correctly,what else should you do to make sure it works correctly(doesn't explode or fail)?Does ripple current matter if it's not connected to AC current coming from an outlet,but there is still AC current flowing through the capacitor from a battery(low voltage and current DC transformed in low voltage and current AC)?Or is there something else I should pay attention to?
Comment: The datasheets SOA statements
Answer: Ripple current matters- it causes heating which will reduce the life of the capacitor. Operating temperature is the main factor in determining the life of electrolytic capacitors. A capacitor rated at 85°C may only have a life of 2000 hours at that temperature. Rule of thumb is that the life doubles for every 10°C reduction in temperature, so if you wanted a 64,000 hour life (7 years operating 24/7) then you'd need to keep the capacitor cooler than 35°C. The capacitor does not care where the ripple current comes from, only the RMS current (and to a lesser extent the frequency).
Most larger capacitors are designed to vent with relatively little drama under 'normal' failure conditions. The most typical failure mode is that they dry up and the ESR increases (and internal heating usually increases as a result) until the circuit no longer functions. Under some conditions (very high fault current for the size of the capacitor) you can get it to explode but it's unusual unless deliberate.
CDE says this (generally they have larger capacitors):

United Chemicon supplies this  application information entitled Capacitor Venting
Operating Non-Solid Aluminum Electrolytic Capacitors.
Solid Tantalum electrolytic capacitors are safest when left in the parts drawer, or used only with a relatively large series resistor. Their failure modes include flames, burning and smouldering. Follow the application information directly from the manufacturer to the letter (and even then, problems are not unknown). The most important thing is to limit the current and overrate the voltage by perhaps 3:1.
Edit: To find ripple current, look in the datasheet. For example, suppose we want to use a Kemet ESK108M025AH4AA 1000uF/25V capacitor. The ripple current for this part is specified as 760mA (at 120Hz 85°C). Note that there is another part number in that series (in a larger case 13mm dia x 20 h rather than 10x20 with more surface area for cooling) that has the same voltage rating, same temperature rating and same capacitance but has a higher ripple current rating (950mA).

If your temperature is lower the permissible ripple current is higher (at a cost in life, see above), and if the frequency is higher or lower than 120Hz then the permissible ripple current is higher or lower.

For example, if you are using a half-wave rectifier at 50Hz mains, then you have to derate the 760mA to 570mA.
You can estimate the expected RMS ripple current by simulation but it's best to verify with measurement. Generally in a mains transformer filtering situation the RMS capacitor current may be 2-3x the DC load current, so in our 50Hz half-wave situation we might be able to get 190mA DC current. There's a moderate 3.8V of ripple (+/-1.9V) in that case, so the limitation might be ripple current or voltage. Stepping up to the larger capacitor or a 13 x 25 2200uF part might be called for- or add some diodes for full wave. Engineering trade-offs.
Comment: How do I find out what would be the maximum ripple current of a capacitor and its max RMS then?
Comment: Short answer- read the datasheet or application manual. See edit above for details. Any reputable manufacturer will supply this data (not always in English).
Comment: I never knew capacitors had need of datasheets too,I will take a look.
Comment: Not only datasheets but often application manuals. Well worth a look as some interesting and useful stuff is hidden there.
Answer: I once exploded a couple of beer can sized electrolytic capacitors and  destroyed a 3-phase, 15 amp Variac by turning up the Variac too fast to raise the voltage of a DC supply that didn't have a sufficient limitation on the charging current.
Edit. The capacitors in a DC supply that is feeding an inverter will need to be sized to carry significant ripple current due to the reactive current in an inductive load supplied by the inverter.
Comment: Wiper wasn't fused on the Variac? Ouch.

Capacitor safety


MySQL Join clause vs WHERE clause

Question: What's the difference in a clause done the two following ways?
SELECT * FROM table1 INNER JOIN table2 ON (
    table2.col1 = table1.col2 AND
    table2.member_id = 4
)

I've compared them both with basic queries and EXPLAIN EXTENDED and don't see a difference.  I'm wondering if someone here has discovered a difference in a more complex/processing intensive envornment.
SELECT * FROM table1 INNER JOIN table2 ON (
    table2.col1 = table1.col2
)
WHERE table2.member_id = 4

Answer: With an INNER join the two approaches give identical results and should produce the same query plan.
However there is a semantic difference between a JOIN (which describes a relationship between two tables) and a WHERE clause (which removes rows from the result set). This semantic difference should tell you which one to use. While it makes no difference to the result or to the performance, choosing the right syntax will help other readers of your code understand it more quickly.
Note that there can be a difference if you use an outer join instead of an inner join. For example, if you change INNER to LEFT and the join condition fails you would still get a row if you used the first method but it would be filtered away if you used the second method (because NULL is not equal to 4).
Comment: It seems to me like it makes more sense to include the WHERE criteria pertaining to the joined table within the ON() clause.
Comment: -1: It's not a semantic difference if using ANSI-89 syntax.  Also, in ANSI-92 it makes a big difference if the criteria is in the WHERE vs the ON clause for OUTER joins -- not just LEFT.
Answer: If you are trying to optimize and know your data, by adding the clause "STRAIGHT_JOIN" can tremendously improve performance.  You have an inner join ON... So, just to confirm, you want only records where table1 and table2 are joined, but only for table 2 member ID = some value.. in this case 4.
I would change the query to have table 2 as the primary table of the select as it has an explicit "member_id" that could be optimized by an index to limit rows, then joining to table 1 like
select STRAIGHT_JOIN
      t1.*
   from
      table2 t2,
      table1 t1
   where
         t2.member_id = 4
      and t2.col1 = t1.col2

So the query would pre-qualify only the member_id = 4 records, then match between table 1 and 2.  So if table 2 had 50,000 records and table 1 had 400,000 records, having table2 listed first will be processed first.  Limiting the ID = 4 even less, and even less when joined to table1.
I know for a fact the straight_join works as I've implemented it many times dealing with gov't data of 14+ million records linking to over 15 lookup tables where the engine got confused trying to think for me on the critical table.  One such query was taking 24+ hours before hanging... Adding the "STRAIGHT_JOIN" and prioritizing what the "primary" table was in the query dropped it to a final correct result set in under 2 hours.
Answer: There's not really much of a difference in the situation you describe; in a situation with multiple complex joins, my understanding is that the first is somewhat preferential, as it will reduce the complexity somewhat; that said, it's going to be a small difference.  Overall, you shouldn't notice much of a difference in most if not all situations.
Answer: With an inner join, it makes almost* no difference; if you switch to outer join, all the difference in the world.
*I say "almost" because optimizers are quirky beasts and it isn't impossible that under some circumstances, it might do a better job optimizing the former or the latter.  Do not attempt to take advantage of this behavior.

MySQL Join clause vs WHERE clause


How to change default rule of Google Translate when to translate 'you' to '你' instead of '您''?

Question: '您' is honorifics description of 'you', But ususally we may just want to use '你'. I find google always translates 'you' to '您', How to change the default translate rule?
Comment: Google always translates 'you' as '你' for me. Even if you get '您' for 'you' in the main field, there is a list of other choices that include 你, 儂, 爾, 你們 below it
Comment: Google translate is not based on a very large set of rules, that's simply not how machine translation works (or at least not this type of machine translation).
Answer: I don't have the same issue as you described.
Did you try to translate it into Chinese (Simplified)?