One-to-"Zero or One" Relation

Question: I have the following requirements:

Every transaction has one of the following types; debit, credit, deposit, or withdraw.
Debit or credit transactions must have a linked invoice record and no bank account record.
Deposit or withdraw transactions must have a linked bank account record and no invoice record.

Currently my basic design is like this:

My current solutions are:

Have atwo nullable foreign keys to the invoice and bank account tables in the transaction table. However, I believe a nullable foreign key column isn't a good design.
Have a foreign key in the invoice and bank account tables that link to the transaction table. However it's seems harder to query and it models a one-to-many relation (not one-to-optional-one relation I want).

Which approach that I outlined is a better solution? Or is there another way to meet my constraints that is even better?
Comment: See ["How to model an entity type that can have different sets of attributes"](http://dba.stackexchange.com/q/149904/63644) and the questions encompassed within the [`subtypes`](http://dba.stackexchange.com/questions/tagged/subtypes?sort=newest&pageSize=50) tag.
Answer: Although very many NULLable columns are normally a sign of bad design, in some instances, it's perfectly legit to have them, and use the database CONSTRAINTS to make sure that the 0-1 relations and your business rules are kept. This would be your solution #1. Your solution #2 isn't easily helped by the database, you could eventually have one transaction without the corresponding rows in both invoices and bank_accounts tables.
Let's assume, for a moment, that you're not using MySQL1 (at least, as of version 5.7).
Let's assume you are using another database that actually performs the checks2, it would make sense to use a schema like the following one, with one invoice_id and one bank_account_id columns, and the necessary constraints that guarantee that they're REFERENCEing the proper rows in the proper tables (what you call links), and the CHECKS make sure that the proper ones appear, and the ones that do not correspond are not there:
CREATE TYPE transaction_type AS ENUM
    ('debit', 'credit', 'deposit', 'withdraw') ;
-- Note: this could be a table with four values (and probably four ids)

CREATE TABLE invoices
(
    invoice_id integer /* serial */ PRIMARY KEY,
    other_data text
) ;

CREATE TABLE bank_accounts
(
    bank_account_id integer /* serial */ PRIMARY KEY,
    name text,
    other_data text
) ;

CREATE TABLE transactions
(
    transaction_id integer /* serial */ PRIMARY KEY,
    type transaction_type,
    nominal decimal(10, 2),
    invoice_id integer REFERENCES invoices(invoice_id) ON UPDATE CASCADE ON DELETE RESTRICT,
    bank_account_id integer REFERENCES bank_accounts(bank_account_id) ON UPDATE CASCADE ON DELETE RESTRICT,

    -- Constraints for your business rules
    CONSTRAINT chk_debit_and_credit_must_have_bank_account
         CHECK (case when type in ('debit','credit') then
                    bank_account_id IS NOT NULL
                else true end),
    CONSTRAINT chk_debit_and_credit_must_not_have_invoice
         CHECK(case when type in ('debit','credit') then
                   invoice_id IS  NULL
                else true end),
    CONSTRAINT chk_deposit_and_withdraw_must_have_invoice
        CHECK(case when type in ('deposit','withdraw') then
                  invoice_id IS NOT NULL
              else true end),
    CONSTRAINT chk_deposit_and_withdraw_must_not_have_bank_account
        CHECK(case when type in ('deposit','withdraw') then
                  bank_account_id IS NULL
              else true end)
) ;

With this in mind, and the following data...
-- Adding two invoices
INSERT INTO invoices
   (invoice_id, other_data)
VALUES
   (1, 'data for invoice 1'),
   (2, 'data for invoice 2')
;

-- Adding two bank accounts
INSERT INTO bank_accounts
   (bank_account_id, other_data)
VALUES
   (1000, 'Bank account 1000'),
   (1001, 'Bank account 1001')
;

... you can have one legit INSERT
-- Good credit and debit
INSERT INTO transactions
    (transaction_id, type, nominal, invoice_id, bank_account_id)
VALUES
    (2000, 'credit', 1000.00, NULL, 1000),
    (2001, 'debit',   900.00, NULL, 1000) ;

... and some illegal ones (being rejected by the database)
-- Bad credit, it's got invoice
INSERT INTO transactions
    (transaction_id, type, nominal, invoice_id, bank_account_id)
VALUES
    (2002, 'credit', 1000.00, 1, 1000) ;

ERROR:  new row for relation "transactions" violates check constraint "chk_debit_and_credit_must_not_have_invoice"
DETAIL:  Failing row contains (2002, credit, 1000.00, 1, 1000).

-- Bad credit, it's got not bank_account_id
INSERT INTO transactions
    (transaction_id, type, nominal, invoice_id, bank_account_id)
VALUES
    (2003, 'credit', 1000.00, NULL, NULL) ;

ERROR:  new row for relation "transactions" violates check constraint "chk_debit_and_credit_must_have_bank_account"
DETAIL:  Failing row contains (2003, credit, 1000.00, null, null).

(and all other combinations)
A careful choice of names for the constraints can help a lot on debugging erroneous inserts or updates. If you need maximum speed, all the constraints can be reduced to just one single check expression. I normally would try to have the database help me, and keep it simple (4 easy names and 4 easy-to-read expressions, instead of a single one).
You can find all the setup at dbfiddle here

1This is the reason why:
Unfortunately, MySQL doesn't help much, because from MySQL's 5.7 manual on CREATE TABLE

CHECK
The CHECK clause is parsed but ignored by all storage engines. See Section 22.214.171.124, "Foreign Key Differences".

2I've used PostgreSQL. With some syntax variations, this would also work with SQL Server or Oracle
Answer: Let me suggest a third alternative: You can use triggers to check your business rules and fail the insert/update in a similar fashion a foreign key constraint would.
For your scenario I setup something like this:
CREATE TRIGGER Transaction_BEFORE_INSERT BEFORE INSERT ON Transaction_Table FOR EACH ROW
BEGIN

-- deposit, withdraw must have a bank account and no invoice
if NEW.`Type` in ('deposit','withdraw') then

   if not(select count(*) from Account_Table where id = NEW.id)
      or (select count(*) from Invoice_Table where id = NEW.id)
   then
      SIGNAL SQLSTATE '45000'
      SET MESSAGE_TEXT = 'Error message';
   end if;
-- credit, debit must have an invoice and no bank account
elseif NEW.`Type` in ('credit','debit') then
   if not(select count(*) from Invoice_Table where id = NEW.id)
      or (select count(*) from Account_Table where id = NEW.id)
   then
      SIGNAL SQLSTATE '45000'
      SET MESSAGE_TEXT = 'Another error message';
   end if;
end if;
END

I've used SQLSTATE 45000 which is a generic state for user-defined exceptions. You may customize that and also set an appropiate error message.
You would also need to create a BEFORE UPDATE trigger that does a similar check.
There will be a performance penalty for abusing triggers this way. Each insert/update will run 2 selects on the other table. You should optimize the selects to be as fast as possible. On high transaction databases it could be a bad solution. So if you choose taking this route please test the impact before running it on production.
Answer: You don't have a transaction table, you have a [BankAccountTransaction] and a [CreditTransaction] table.
Yes, split you transaction in two tables, one has a FK to [BankAccount] and the another got a FK to [Invoice].
If the need arises you can create a "parent" [Transaction] table and use it to intermediate the relation between the above two tables to a table don't see the difference between them.
Or if that important only to report like queries you can create a view where you easily use a UNION.
                        +---------------------+                +---------------+
                        |                     |                |               |
        +---------------+  CreditTransaction  +---------------->    Invoice    |
+-------v------+        |                     |                |               |
|              |        +---------------------+                +---------------+
|              |
| Transaction  |
|              |
|              |          +------------------------+       +----------------+
+-------^------+          |                        |       |                |
        |                 | BankAccountTransaction |       | BankAccount    |
        +-----------------+                        +------->                |
                          |                        |       |                |
                          +------------------------+       +----------------+

One-to-"Zero or One" Relation


1998 Dodge Ram AC clutch won't engage

Question: When I call for AC on the dash the clutch on the compressor doesn't engage. I disconnected the clip that connects the wire to the clutch and checked for voltage and there was none. People say that means I "need a new computer". But that seems drastic. And expensive. Is there some fuse that can be blown? Some broken relay?
Comment: Engine Size? Ram 1500?
Comment: Yeah, it's a Ram 1500. No idea what the engine size is or what the correct measurement for that is. I assume it's in what I remember as "combined cylinder volume" and I don't know what that is but I do know it has a V8. Or is it a straight 8? It's probably a V. What car has a straight 8?
Comment: i have the same issue with mine if you wiggle the relay the clutch will kick on and off i think theres looses wires in the fuse box
Answer: There are several things that can keep the compressor from engaging

the heater-A/C mode control switch
the low pressure cycling clutch switch
high pressure cut-off switch
compressor clutch relay
Powertrain Control Module (PCM).

One of the most common problems is a low refrigerant charge, the low pressure switch prevents the AC clutch from engaging when the system is low on refrigerant.
Comment: Nice! Thanks. I'm digging into each of those now. I got a new compressor clutch relay (which I had to order and just showed up) and checked fuses and so far it's none of those easy things. Someone else mentioned it could be a stuck "high RPM shutoff switch" or something like that. The "low pressure cycling clutch switch" sounds like a good contender because the previous owner mentioned it would come on for a bit but then turn off (which is why he thought the compressor was fine since it would blow cold for a bit). I haven't experience it ever come on. And now I need to find that switch!
Answer: Definitely check the fuses before replacing anything else.  Your interior fuses should be on the drivers side as pictured below in a video from carcarekiosk.com.

The video shows a page in the owner's manual that indicates that a fuse connects to the "A/C Controller" titled "MIRR HTD".  It is a 10 Amp fuse.  Here is an image from the same video.  (The panel is being held sideways).

Another fuse is under the hood on the drivers side titled "A/C Clutch".  The picture below is from justanswer.com.  Look at the lower left corner of the image.  It's labeled "J".

Those are the only two fuses that I could find.  You should check them both and any others that might be related, such as the blower fuse, just in case before you move on to more expensive repairs.
Comment: Why 2 fuses to the same thing? I checked the one under the hood and it was fine and still need to find the one in the cab. I ordered a new relay and I'm trying that too. And that schematic for under the hood box is RIGHT ON! Too bad there is no central repo for that information on every car.
Answer: I had the same issue. Clutch suddenly quit engaging. Checked relays, high and low pressure switches. Everything checked OK. Then I noticed that my horn wasn't working either. Turns out that the 20 amp Horn Relay fuse, in the relay box under the hood, also feeds the AC Compressor clutch relay. New fuse, and I'm chilling again.

1998 Dodge Ram AC clutch won't engage


If I never battle in Clash of Clans and I have zero trophies will I get atacked at a higher townhall?

Question: My question is will I get attacked after a while playing Clash of Clans from 0 trophies going to a higher town hall, because I have started a new game just need to learn some tricks and tips.
Comment: Your question is a bit unclear. Could you give an example scenario?
Answer: You will get attacked only by players with similar trophy count.
This means, theoretically you can get attacked by a higher level town hall than level 1 even if you have 0 trophies, but only if the attacking player also has a very low trophy count.
This can be useful even at higher trophy counts - if you start losing trophies on purpose, you will meet bases that are easier to beat.


Worst alien invader ever

Question: I'm looking for a short story I think I've read all of once, it involves a fortune cookie with a day of the week and nothing else and an alien sent to disrupt the defenders of Earth who feels that the best approach is a demoralisation campaign involving such cookies and prematurely wilting heads of lettuce. The human protagonist takes pains to find out where the fortune cookie came from and after a James Bond style villain monologue goes to the psych ward secure in the knowledge that while no-one believes him the alien in question is never going to get anywhere and mankind is safe.
Comment: This must be the alien counterpart of "Russia disrupts our democracy via tweets and memes" meme so prevalent nowadays.
Answer: Harlan Ellison's "Never Send to Know for Whom the Lettuce Wilts" (ISFDB) (Internet Archive) found by searching for short story alien wilts lettuce.

... But he follows them with Never Send To Know For Whom The Lettuce Wilts, which is the most Ellison-y tale of the lot — goofy, but prescient, cruel and smart, having to do with a curious man, a fortune cookie, and an alien trying to conquer the world through small, demoralizing acts (like wilting lettuce, making nails bend, and inventing the English language). The funniest bit? The alien (small, gnomish and furious) wears a huge yellow button pinned to its breast that reads CONQUEROR. An award it gave to itself.
Comment: You never know what keywords are going to do the trick. :-D
Comment: Ah so that's why I couldn't find it, I was looking for it in anthologies I have not _The Magazine of Fantasy & Science Fiction_ which I read only very sporadically for a couple of weeks one year. Also I was looking for the cookie not the lettuce.

Worst alien invader ever


Checking Transmission Fluid Condition

Question: I have read a lot about transmission fluids, what good ATF looks like, and when to change it. But, I still have trouble defining the deterioration level of transmission fluid I extracted from my 2008 Camry (See attached image). It looks quite muddy but it has no burnt smell. What you think, how deteriorated is this ATF? Should I have changed it before it started to look like this?
Comment: The color is dark, but it's not black or close to it. There don't seem to be any particulates in it so it doesn't look terrible. How many miles on this car? In your post, what does PFA stand for? What trim level is your Camry btw? CE, LE, or XLE? Is it the 4 cylinder or the V6?
Comment: PFA for please find attachment. :)
My Camry is XLE L4 2.4 and made 150000km. I bought it used, previous owner said he changed the fluid at 110000km.
Comment: Thing is, "change the fluid" can be through any one of a couple of methods. 1: Spill and fill. Just let the fluid drain from the drain plug and replace it once it stops. This only replaces something like 30% of the fluid. What's in your torque converter and other parts of the transmission won't be changed this way. 2: Forced fluid change. Best done by the dealer, this forces the fluids in the transmission out as the new fluid goes in. This changes nearly 100% of the fluid. If the previous owner did a spill and fill, then what you see makes perfect sense. Not so much for method #2.
Comment: I am going drain all fluid, replace the filter and gasket and refill with original ATF WS. But I have read somewhere that, if it's too late (fluid and some parts are burned in AT) it's better not to change anymore. Because new fluid will clean all burned stuff and debris will kill the transmission. In this case it's better first replace all worn-out parts inside the transmission.
Answer: The colour is too dark, this fluid should be changed. As mentioned in the comments, automatic transmission fluid lives in 2 places: in the drain pan and in the torque converter.
Some cars have a drain plug for the fluid in the pan (that's as simple as a motor oil change), others don't and you need to remove the pan and change the gasket (that's a messy job).
To get to the fluid in the torque converter is more involved and usually can't be done at home. You don't need to go to the dealership, any mechanic shop can do this. Find one that you trust.
If the automatic transmission fluid was "dirty red," you could have just drained the fluid from the pan and replaced it. But this fluid is too dark, I would have the entire system drained (torque converter and pan) (it's simpler), or drain the pan and refill multiple times.
For this last option, you'll need lots of fluid and you'll need to drive the car a little bit between flushes to get the fluid to mix. Basically, this will dilute out the old fluid, you'll probably need 10 to 12 flushes to get the  ATF to "look like new." The amount of ATF needed for this will cost the same if not more than getting a shop to flush the entire system (1st option).
Comment: You should have changed it sooner than this, yes, but if the transmission still shifts smoothly, you probably didn't hurt it. If you don't have a drain plug and need to remove the entire pan, make sure you clean the magnets good.
Comment: Should I have changed the fluid before it become that much dark? I mean,  am I late? I just want to note for the next time.

Checking Transmission Fluid Condition


Find latest entry of a duplicate row in Google Sheets

Question: I have a spreadsheet that tracks the status of documents. Every time a document is worked on, a new row is added with that day's date and the new document status. This way I can track the progress/life-cycle of each document.
I want to filter this sheet (or show the relevant data in another sheet) to show the latest version of every document, based on the latest date.
For example, Document X might appear three times (because it was worked on three times), but I only want to show it once in the spreadsheet - the entry with the latest date.
Do you guys have any idea how I would do that?
Answer: Assuming dates in Column A and document names in Column B:
<code>=query(A:B,"select B, max(A) group by B")
</code>
Reference

QUERY function


How to unmount USB mac disk with MacDrive

Question: If you have a USB external drive in Windows, you can right-click it and unmount it before unplugging. But if this USB drive is Mac formatted and mounted with the helper app MacDrive, the "Unmount" option is gone from the contextual menu. How can I safely remove a Mac formatted volume under Windows?
Answer: This is according to Mediafour (makers of MacDrive): How To...Safely remove drives from the computer

Even though FireWire and USB devices
  are Plug & Play (i.e. they are ready
  to use upon being plugged-in), you
  should not just unplug them. By
  unplugging a drive with a "hot"
  connection, you can corrupt data on
  your hard disk or other storage
  device. It is important to note that
  even disconnecting a device improperly
  one time can cause file system
  corruption.
You can prevent such problems by
  clicking the "Unplug/Eject" or "Safely
  Remove Hardware" icon in the system
  tray (down by the clock). The icon
  looks like a gray box with with a
  green arrow on top.
You'll then be given a list of
  removable devices that are currently
  connected to your computer. Highlight
  the device you would like to remove
  and click "Stop".
Windows should then prompt you that it
  is safe to disconnect the device. If
  not, this is an indication that some
  part of Windows is using resources on
  the disk. To clear this, reboot your
  computer and before doing anything
  else, try the above instructions
  again.
Comment: The problem is, this icon is not visible for MacDrive volumes. Only for FAT/NTFS disks.
Comment: Maybe the MacDrive driver installed incorrectly. I doubt they would say to use the Safely Remove Hardware feature if MacDrive didn't support it. Try reinstalling it.


Lesson of Eicha

Question: Of course it is a poignant account of the destruction of the Temple and Jerusalem, but what deeper message(s) does Eichah teach us?  Other than the testimony it provides, why was it chosen to be read on the night of Tish'ah BeAv?
Answer: The Jewish approach to mourning and what to mourn about "Al Eilah Ani Bocheah"
Answer: Reading it helps to make the destruction of the Beis Hamikdash more real to us. That, in turn, fuels a stronger desire to do whatever we can to increase our Jewish knowledge and observance, in order to bring it back.

Lesson of Eicha


Nature of Chirality: Additive or multiplicative?

Question: What kind of quantum number is Chirality? Helicity, being the projection of spin in the direction of the momentum, is like a component of spin, and therefore, additive in nature. For a process, $A\to B+C$, the helicity of the LHS should match with sum of the helicities of B and C on the RHS. Is it the same about the chirality?
Comment: Is it a qn? I'd say it was rep. of Lorentz group, that coincides with helicity in massless limit
Comment: @innisfree I'm not sure. $\gamma_5$ is the chirality operator. Isn't it? When acting on chiral projections of fermionic field, it gives a number times the field.
Answer: Chirality is not a quantum number. In representations of the Lorentz group where it makes sense to talk about it, it is the eigenvalue of the $\gamma^5$ (as one would denote it i four dimensions) that lives in the top degree of the Clifford algebra, but not every representation of the Lorentz algebra is one of the Clifford algebra, so speaking of chirality does not make sense for arbitrary objects.
In particular, $\gamma^5$ is not an observable - not even a quantum operator at all - and cannot act on states - it only exists in the finite-dimensional representation a Weyl/Dirac spinor transforms in, but not in the infinite-dimensional unitary representations where the states of your quantum theory live. The unitary representations are labeled by the mass and spin (for massive states) and helicity (for massless states), but not by anything that would lend itself to be interpreted as chirality that would be distinct from there. The available operator is helicity (and other spin components, of course), not chirality. Note that for massless fermions, the notions of chirality and helicity coincide, and that for massive Dirac fermions, the two chiral parts do not decouple, making the notion not particularly useful in the first place.


combating mission which approaches innocent Jews

Question: I see recently a great number of posts about Christianity: pseudo-innocent questions that seem to ask about the legitimacy of some missionary religious sect or of יש"ו. I feel that Mi Yodeya is too friendly and we are duty-bound to protect people who are frail. Why moderators do not clean up a little more?
See here, here, here for examples.
and here
Comment: @msh210 You make Mitsva מכשפה לא תחיה!
Comment: @SAH I agree that my examples are not wholly adequate, I agree too with the Kidush Hashem.  But the example of the Jeru C. makes my blood boil, because in Israel it is the classical baiting for frail people. They make great damages.
Comment: This question would be stronger and more answerable if you'd [edit] in some specific examples of posts that fit this category along with details of what actions you think need to be taken toward them and why.
Comment: @IsaacMoses I tried to remember and linked few examples
Comment: thanks. Like I said, details about what you think mods ought to do in these cases would be valuable.
Comment: I'm trying to rewrite this in better English and am stuck on "Why moderators do not clean up a little more". Do you mean "Why don't moderators clean up a little more?!" as a proposal (they should!) or "Why do moderators not clean up a little more?" as a question (please explain why)?
Comment: @msh210 Yes I think that the moderators have a great responosability and duty to protect Jewish people
Comment: @msh210 "which", "witch one": I am confused have you a link to explain
Comment: http://grammarist.com/homophones/which-vs-witch/
Comment: @Kouty I strongly believe that none of the questions you linked involves proselytizing or is otherwise objectionable. I'm not sure what our obligation is to keep proselyters off the site but we indeed have an obligation to make darchei shalom and kiddush Hashem in the view of the nations--and to act as fair, reasonable, non-parochial human beings. In light of the last point especially, I think the numerous downvotes on these (generally good) questions are not merited
Answer: Posts (questions or answers) that exist only to proselytize other religions are not welcome here, and when the moderators become aware of them we delete them.  The community can help with flags.  If a post is offensive or spam be sure to use the correct flag; doing so can expedite removal.
The problem comes in posts that aren't that blatant, ones that might be asked with ulterior motives or might be asked out of ignorance.  The last of your three examples, for example, is asked respectfully and from an admitted lack of knowledge by someone who declares his religious perspective up front; that seems wholly unobjectionable to me.  Your other examples are less clear in this regard but do not, in my opinion, cross this line.  Dan l'chaf zichut means we should give the benefit of the doubt, so we don't remove borderline posts unilaterally.  The site is open to everybody, including non-Jews who sometimes lack basic knowledge.  We should distinguish between the one who does not know how to ask and the one who posts with bad intent.
This doesn't mean we can't respond to poor posts in other ways, though.  If a post is unclear or shows no research, you might want to downvote it.  If a question is unclear or off-topic or opinion-based or too broad, you can vote (or flag) to close it.  You can leave comments requesting clarification or suggesting improvements, and if a poster seems to be sincere but misguided I encourage you to give him a hand.
Please help us to be as open as possible while shutting down the trolls and missionaries.  There are a lot of people out there, gentiles and Jews, who have some basic misunderstandings and could benefit from coming here for answers.  Let's try not to shut them out.
Comment: I never said to shut out anybody. It's clear! +1 for the chaf zchout. I greatly appreciate your prose.
Comment: @kouty it was not my intent to put words in your mouth.  I'm sorry if you thought I was.
Comment: All is good I was not cynic. I really said that it is beautiful to be able to kep these posts lechaf zechut. I appreciate it really. I am sure.
Answer: I think that posting sources from other religions shouldn't be accepted, as this is a site about Judaism and this should be about Judaism only. If they want to ask if we believe in oisoi ho'ish, that's fine because it's asking about Judaism, but to bring a Christian translation of the Torah and based on that ask why we don't hold of him would be inter-religious discussion which I don't think should be on this site.
It would seem more appropriate to be in the Christian site as they hold that Judaism was an authentic religion and a precursor to their religion.
Answer: When it comes to questions like these, it is important to remember that Mi Yodeya is not a Jewish site. Yes, we are a site that is about Judaism. Yes, most of our users are Jewish. But censoring opinions that is not in accordance with Judaism (as long as they are not provably wrong and as long as they are not offensive and as long as they are not off topic), is not the moderators' responsibility, nor should anybody do that.
Comment: This would make more sense about answers I think than questions.
Comment: not a Jewish site --> OK, all is open. 100% right.
But a question witch concern not Judaism even if it is a Jewish question is not on topic
An other point is to detect spam. Missionary is spam, nothing else.
Comment: @Daniel I think a second time. you say right and beautyful things, are "censoring" the point of my question, and  you falsely attribute to me some opinion and answer to this. Nothing in my post says that m.y. is a Jewish royalty. My topic is the awareness about propaganda and disguised missionarism. I you think that it is prohibited in a non-Jewish site to spoke on illegal and threatening advertising.
Comment: @kouty agreed. Posts that are clearly arguments against Judaism don't have any place here. But the questions that you linked are not that. They show poor research effort, but they are legitimately questions about Judaism
Comment: @DoubleAA my answer has the caveat that it only applies to questions that aren't off-topic. I think the only difference between questions and answers is that questions are more likely to be off-topic.
Comment: @Daniel I agree that the posts  are not the best examples of propaganda. But a least, in  the post of Jer. Con. it is impossible to leave this withoutd caution against an this missionary organization. י"ש
Comment: @kouty my use of the term "censorship" should not be taken to have an automatically negative connotation. Removal of spam is also censorship, though an important aspect of site maintenance.


RLC voltage at resonance

Question: I did a small simulation for a RLC circuit as here :

How does one compute the maximal voltage attained for this resonance?
Answer: At resonance, the final voltage on the resistor is precisely what the input sinewave amplitude is. This is because inductive and capacitive reactances totally cancel to zero in an AC analysis.
This then tells you the current flowing through all series components so, use ohms law (for impedances) to calculate the voltage on L and C individually. At resonance they will be the same amplitude and, if their individual reactances are greater than the resistor, you will see that the voltages are larger than the incoming sinewave.
In an off-resonance scenario you calculate the net impedance of the capacitor and inductor (zero at resonance as previously mentioned) and use Pythagoras to determine the voltage across the resistor then proceed as above.
Answer: I leave the complete answer for you to solve.
use the impedance ratio of the voltage divider to determine the Transfer function (f).  Then multiply this by your input signal.
edit
I must assume now( since you are young and assume too much and forgot to include specs) that you are modulating an ideal voltage source 0 ohms at the theoretical resonant frequency with an AM signal from 0 to 100% and you ask how to determine the output amplitude when then input is unknown. SO we can look at ratios.
We know that X(fo) impedance for a series LC resonant frequency = 0 Ohms
We see your ideal LC circuit ( no DCR in L or ESR in C and no significant (yet real) parasitic capacitance Cp in the inductor,L) with a 1 Ohm load.  Yet inspite of this 1 Ohm load with an 0 ohm source and 0 ohm resonant frequency and assuming the generator is exactly at this amplitude. We should expect the transfer function to be unity.  Any error in the above assumptions leads to less than unity gain or "attenuation"
Without know your assumptions and errors, one can only guess.
The relevant factors are the Q of the series filter which determines envelope rise time. You ought to know how to calculate resonant frequency from  ωo=1/√(LC) and impedance ratio Q at ωo.
From the signal we see a modulation effect of the envelope which declines at te end of the trace.  This carrier modulation for a high Q circuit may be the beat frequency of the error of your input signal frequency and your actual resonant frequency.
( from mental calculations)
 I previously estimate the Q @ 125 which means your signal generator error must be << 1/125 . Q is defined as the resonant f/-3dB BW so if Q is 125 or so ( U do the math) then your sig. gen must be < 0.1% error to reach >90% of the input.
Since it is now obvious to me that your signal generator has more than 0.1% error from envelope wavelength relative to the signal frequency ~125kHz , by number of cycles to ramp up and then ramp down from error f I could calculate your attenuation and estimate your input signal.
But the rigorous method is to perform Calculations with Input signal and transfer function from impedance of each part using the same methods as KVL for divider ratios.  The input signal voltage, frequency and impedance are essential in the Vin(t) or Vin(f).

RLC voltage at resonance


Why cisco switches have many mac-addresses?

Question: im trying to find the reason why cisco switches have a base mac-address and one for each port?? Can anyone help me to understand this..
Comment: Mainly so they can be used as non-switchports. Since a switch is fundamentally a transparent layer-2 bridge, nodes don't speak to a port directly.
Answer: The MAC address is the "hardware address" which uniquely identifies a virtual device (such as an SVI or loopback interface), a host, a port or what-have-you at Layer 2 of your network.
These extra MAC addresses are utilized by managed devices (such as Cisco switches) to provide additional functionality beyond that of a "dumb" switch or hub.
Understanding the 7-Layer OSI Networking Model is critical to your understanding and troubleshooting of networking issues.
http://en.wikipedia.org/wiki/OSI_model
Comment: A switch (or hub or "bridge") doesn't require a MAC to function -- devices aren't "talking to the port". Look at a simple, unmanaged netgear/linksys switch, notice it doesn't have a MAC *at all*.
Comment: I'll reword my statement, but you know precisely what I mean from the utilization and usage of those MACs on *managed devices*.
Comment: at a hardware level i do think switch use mac-addresses to map its own ports.. port numbers are for humans.. and this is why i asked the question to be sure of that...
Comment: learning the osi model as someone refer here does not tell me why switches have a mac-address for each port... yeah, i know how switches identify hosts on a L2 domain..
Answer: As far as I know a switch uses its own MAC address when it needs to send traffic on the control plane. It does not use them when it's performing switching.
Comment: That is correct. Switching doesn't need a mac. Various *services* need a MAC. (spanning-tree, layer-3 (ip) interfaces, etc.)


Which version of Windows introduced the "Span" wallpaper style?

Question: I am refactoring an old program that I wrote which will set the user's wallpaper to NASA's Astronomy Picture of the Day, each day. I'm programming one part that will let the user specify which style of wallpaper they want (Tile, Center, Stretch, etc), depending on whether the image is larger or smaller than their monitor's resolution. I did a bit of research, and found this program, which claims that the "Fill" and "Fit" wallpaper styles were introduced in Windows 7. I've added the appropriate code to make sure they're running Windows 7 or greater if they choose that style. I noticed that my Windows 10 machine has a "Span" style, which isn't listed in the aforementioned program. This makes me think it was introduced after Windows 7, but I'm not sure if it was introduced in 8, 8.1 or 10. I need to know which of these introduced the Span style, so I can make sure the user has the appropriate version of Windows before I change their wallpaper style to Span, should they select that. Which version was it introduced in?
Comment: I can't give you a definitive answer, but I don't recall any differences on the wallpaper configuration between 8, 8.1 and 10
Answer: It was introduced in Windows 8.
However, the option will only appear there if all monitors are the same size or if Let me choose one scaling level for all my displays is checked in the Display screen in the desktop Control Panel. It seems to appear even when there's only one monitor; props to Journeyman Geek for testing.
Answer: You can simulate this effect in Windows 7 and below by creating a single, large bitmap that is the sum of the width of all connected screens and choosing "tile" as the layout style.
The upper-leftmost pixel on display 1 is the origin, and as long as the bitmap is exactly the size of the screens, it will be "tiled" only once, causing a single image to span across all displays.  This trick worked even if the screens were all of different resolutions.
There is a program called UltraMon that automates this, but the software is not free.  It's very useful on Win7 and below, but Microsoft has added features starting w/ Windows 8 that has made many of its features irrelevant.


Can I claim English as my first language?

Question: I consider myself to be fully bilingual. My mother tongue is Afrikaans and I went to Afrikaans schools, but I learned English as a toddler and was a fluent speaker by the time I went to school. I read my first (abridged) Dickens at age 10. My degree was presented only in English. My husband and I speak mostly English to each other, although I speak Afrikaans to my children. When I speak, read or write English I think in English. I more often have to translate words from English to Afrikaans than the other way around. Can I claim English to be my first language?
Comment: By claiming English as your first language, are you also relegating Afrikaans to second-language status?  If you are fully fluent in both, why is important to choose one as "first"?  Is it for filling out some kind of form where they have separate boxes for first language and other languages?
Comment: The answer is yes. Just see *first language* on Wikipedia.
Comment: The reason is for a form, yes. I want to register with a professional council to work in another country. If English is my first language, I do not need to write IELTS.
Answer: Yes, if you want to.

ILR Level 5 – Native or bilingual proficiency
Native or bilingual proficiency is rated 5 on the scale. A person at this level is as fluent as an educated native speaker.

Wikipedia: Interagency Language Roundtable scale

Level C2: Proficient User: Mastery or proficiency

Can understand with ease virtually everything heard or read.
Can summarize information from different spoken and written sources, reconstructing arguments and accounts in a coherent presentation.
Can express him/herself spontaneously, very fluently and precisely, differentiating finer shades of meaning even in the most complex situations.

Wikipedia: Common European Framework of Reference for Languages
Other employers or organisations may apply different criteria, of course. Some of the correspondences between CEFR levels and other English language proficiency scales are listed here. But in general it makes no difference whether you're bilingual, a native speaker, or you're speaking English as your nth language. The point is your level of ability, rather than the circumstances in which you acquired it.
I'd suggest you simply continue to describe yourself as 'bilingual' though, because it sounds as though you're essentially a native speaker of both English and Afrikaans, so that's the most accurate description.
Comment: +++++1 I'd upvote more if I could.
Comment: I am as fluent as any first language speaker. I would claim "bilingual" except that on the relevant form there is no such option.
Answer: Is there a specific reason that you need to declare it as your 'first' language as opposed to simply listing the language as 'native' or 'fluent'? What is the application of this declaration? Are you applying for jobs, or does this come up in conversation? If there is some reason that you need to distinguish one language as your 'first', then by all means, claim it. Otherwise, what's the utility of making such a distinction?
All in all, I suppose your 'first' language is the language to which you arrive initially when prompted. As far as I can tell, this does not need to be your mother tongue; indeed, I know a handful of individuals who speak English more than their mother tongue. I would consider it valid if they claimed English as their 'first' language, even if they speak it with some accent.
Comment: I am applying for professional council registration in another country. Otherwise I would not distinguish either!


Mplayer subtitle change color in config file

Question: How change mplayer subtitle from white to yellow? Also how change subtitle font to Ubuntu-font-family ?
Answer: edit  ~/.mplayer/config
#put the path to the desired font
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf

ffactor="10" #black outline
sub-bg-alpha="0" #background color ala closed captions
sub-bg-color="0" #black to white
subfont-text-scale="3.7"    #truetype font scaling
subfont-blur="1" #Slight blur

not sure about color codes, but you can play 0-255
Comment: not work [shot0001.png](http://dl.dropbox.com/u/3117811/shot0001.png)
Answer: You can try the following:
Edit your mplayer config file (/home/user/.mplayer/config) and add these lines:
font = "Ubuntu"
ass-font-color = "ffff0000"
ass-font-scale = "2"

Let's say you have a video named video.avi and the subtitles in the same folder eg:(home/user/Videos) named subtitle.srt.
Then to open a video with mplayer in full screen from the command line type:
cd /home/user/Videos
mplayer video.avi -sub subtitle.srt -fs -ass

(You can change the value of "ass-font-scale" acoording to your needs.)
If you are using mplayer-gui to open the video, make sure you have SSA/ASS enable,right-click in mplayer-gui and go to Preferences.
In the tab "Subtitles & OSD" click in "SSA/ASS subtitle rendering"

If you want to change another option like font scaling just go to  the "Font" tab.

(Maybe after changing some options you have to restart the mplayer-gui.)
Hope this will be helpful!
Regards.


What are the essentials I need to install if I want to use PostgreSQL DB with zope? for eg: Zope Database Adapter?

Question: I am into a project where zope web server is used. With this PostgreSQL database is used. But I am not able to add a new PostgreSQL connection via zope. Actually, I am not aware of what else I need to install so that I can use PostgreSQL dB with zope. From whatever I have explored about this I have come to know that I will require a Zope Database Adapter so that I can use PostgreSQL dB with Zope. But still I am not confirmed about this. Also I don't know which version of Zope Database Adapter will I require to install? The zope version I am using is 2.6 and PostgreSQL dB version is 7.4.13 and the Python version is 2.1.3 . Also from where should I download that Zope Database Adapter?
Answer: Look at psycopg, it ships with a Zope Database Adapter.
Answer: Psycopg2 is absolutely required but is not sufficient.  Psycopg2 provides the low-level python database interface.
There are quite a few ways to provide database interconnection, and it depends what exactly you want to do.
No matter what solution you choose, you want to get the required eggs from PYPI: http://pypi.python.org/
If you want to be able to have Script methods that will allow your Zope objects to query a database, you can use a Zope Database Adapter, and for that I prefer SQLAlchemyDA: http://pypi.python.org/pypi/Products.SQLAlchemyDA/0.5.1.  SQLAlchemyDA's major advantage over other database adapters is that you can plug in numerous db-api providers (e.g. psycopg2) to get access to PostGreSQL, Oracle, MySQL, and many others.
If you want to use products that rely on a SQL database connection - such as pas.plugins.sqlalchemy and ore.contentmirror for Plone - you will usually need z3c.saconfig: http://pypi.python.org/pypi/z3c.saconfig/0.12
One thing we still need is a way to permit SQLAlchemyDA to be configured from z3c.saconfig.


Is using my phone number as a pin for a phone a security risk?

Question: I just did a factory reset on my smartphone to see if it might fix issues with battery life. I configured a phone number as the lock screen code so I have a code that's both long and easy to remember. Are there security risks that make this a bad idea?
Comment: Well a phone number is no secret, so effectively your passcode is the fact that "your phone number is the passcode". And the real questions is, if that is safe.
Comment: If it's known data about you, it isn't a password or pin. Just that simple. It's why all those secondary security questions are suspect. If it can be found on your facebook page or is known by your friends, business contacts, etc. it isn't secret. These are the first things somebody skilled in "social engineering" will try.
Comment: If it wasn't insecure, it probably is after you posted this question.
Comment: @bayo15 answered it as targeted as possible: **Not secret**!
Comment: @NeilSmithline Yeah, I changed it already to something else.
Answer: Your phone number is documented in a large number of places - your friends, your family, your employer, maybe even your Facebook profile and G+ profiles. Many of these people know your phone number. Some of them may even know it from memory.
The equivalent would be writing your password down in an email and sending it to your contacts list - you're not advertising the fact that it is your password but the information is out there and significantly easier to find than a password or PIN that you have memorized (which would require intimidation or  torture to get it out of you, or brute force/exploiting a vulnerability to bypass).
Answer: Using your phone number as your PIN code exposes you mainly to password (PIN) guessing attack. Your phone number is not a strong knowledge factor. People you know and trust, and thus they know you could be the first ones to guess your password. There are so many users who use their phone number as a password to their social/messaging accounts which thing is a bad practice.
Answer: If an hacker can tell that the passcode is as long as a phone number, he is likely going to try that. This to me is the same as using your pets name, road name etc. This is not secure in my opinion.


Implementing a fixed size virtual UI card

Question: I am trying to implement a virtual UI ID card that would look like a card on all devices. I will need 4 rows total and 3 columns. I also would like to have the width about twice the size of the height (2:1 ratio).

1) I considered the border layout. but it seems like it spans the whole screen size. Quickly the size of my card width was like 5 times the size of the height. So that did not visually work.  I suspect the Gridlayout would suffer from similar issues.
2) I used the table layout (4 X 3). I tried using padding / margin and it seems like the look & feel of the card UI quickly gets out of proportion on tablets while looking decent on phones since phones seem to naturally have a similar width to a card.
3)I tried specifying widthPercentage as a constraint on the table UI. Again this approach sufferred from similar issues. Since on smaller phones I would have to remove add small percentage margins but on big tablets I may need bigger margins. This can get quickly challenging to get right / test.

I am thinking now of attempting to take one of the following approaches:

1) I am not sure if there is a way to specify the TextField width based on the number of characters. For example when the card issue date grows on tablet it can fit 10s of characters where I want it to fit only couple for moht(mm) and 4 chars for year(yyyy). Is there a way to do that?
2) Can I tell the screen width in inches or mm ? I can implement a function to attempt and scale padding / margins on different screen size.

I appreciate any feedback.
Answer: See the Kitchen Sink demo which has the default "cards" mode in the start. It uses grid layout with special cases to fit the columns in a sensible way for Tablets/Desktops.
https://www.codenameone.com/demos-KitchenSink.html


Waterproof lower part of exterior wall

Question: We recently had 30" of water in a 1000 year flood. House is gutted so now's the time to fix a recurring problem I had. The previous owners made an add-on to the house where the concrete is only 2" above grade rather than the 6" for the rest of the house. Regular, heavy rain has slowly been rotting the lowest part of the wall. I can't prevent another 30", but is there something I can do to waterproof against the routine 3"?  It's a straight 23' run with an outside corner and another 12' run.  Both walls tie into the existing house and closed in a corner that was previously patio. I know the best solution would be to bring the slab up to the 6", but that is cost prohibitive at the moment.
Diagram of the slab
Comment: Hello, welcome to Stack Exchange, and our thoughts are with Louisiana. A diagram and/or picture would help us understand your situation better.
Comment: Thank you.  I've added a rough sketchup diagram that I hope adds some insight.
Answer: If you can not work on the inside and raise it then work on the outside. What I would do is use a roll on sealant and add drainage along the exterior walls and draw it away. Consider getting about 10 ft away them use perforated pipes to leech the water lines into the ground and at its ending, possibly look into a 3 ft hole filled with rocks.
Comment: I had a backup plan that is exactly this: French drain along the wall and possibly a dry well. The problem with a dry well is our water table is pretty shallow.
Comment: You know the leech method is exactly why we use it due to the water table being as low as 30ft for wells. I am not sure what yours is at but 30ft for our area is extremely shallow. Its the same method used for septic tanks ( cesspools) We have about 100 ft of piping( 50 ft out then turns 50ft only 18 inches down. But mind you we are on acreage and so I do not know if you have the room to do such.

Waterproof lower part of exterior wall


ASP.NET MVC using as a RESTFUL Service and Consuming it easier way

Question: I wanted to know, if say I had a MVC Application with some functionality and I want to provide this as a service to some of my clients. Do they need to go through coding and querying the XHTML data?(as it is represented in XHTML). I mean how do they generate proxy classes and use my methods? One of the ways is creating URI object but it seems there is still quite a bit of coding to be done in accessing that service(http://msdn.microsoft.com/en-us/magazine/dd943053.aspx).
So , how do i consume the service on Client Side and can I provide a XML?...I have just a simple method that gets user ID and returns details in the controller and respective view. I want to provide this as a service to my client and avoid lot of code.
Comment: Some pretty good information about that here: http://omaralzabir.com/create_rest_api_using_asp_net_mvc_that_speaks_both_json_and_plain_xml/
Answer: If you are just exposing a bunch of XML from your various MVC controllers, then the only information clients have to go on is whatever you're doing to document your XML payload format and the URI scheme of your application.
If you want clients to be able to generate client proxies so that they can automatically consume your services, then they'll need some kind of meta data, in which case you should consider using WCF to create RESTful services which would allow for metadata generation and client proxy generation as well as just being able to do just "POX" access.
As the previous commenter said, if all you want to do is expose XML data from your MVC controller, there are a variety of ways this can be done - the easiest of which is just to have your View template render XML tags instead of HTML based on data stored in the ViewData dictionary. You can also very easily expose the underlying data as Json by returning a JsonResult instance from your controller method instead of View().


Is there a way to validate only ethereum wallet address?

Question: I'm not very familiar with cryptocurrency, but i need somehow validate ethereum wallet address. I've found a way, but it also accept token contract address. So is there a way to differ them, and only allow wallet addresses and not contract address
Answer: If you use web3 you can use this way
web3_instance.eth.getCode(address).then(function (code) {
    if (code === "0x") {
        // this address is account
    }
})

Comment: Unfortunately i can't use web3. What does getCode do? Can i implement it by myself using c++ for exampe?
Comment: This data is only available on network and you must use their library to fetch the data binary of each address if it is a contract then it has data more than 0x if is not it has 0x
Answer: I'm not quite sure if there is web3 library for C++, but another way you can achieve this by using the Etherscan API. You need to register and obtain your api key and then you will be able to use the Etherscan API with certain limits.
This is how you are going to build your GET request:
https://api.etherscan.io/api?module=contract&action=getabi&address=<YOUR_ADDRESS>&apikey=<YOUR_API_KEY>
Where <YOUR_ADDRESS> is the address you are about to validate and <YOUR_API_KEY> value is the key which you are going to receive from the Etherscan API.
The two main responses which you're going to receive back from the request are:
Address which is not a smart contract - {"status":"0","message":"NOTOK","result":"Contract source code not verified"}
And address which is a smart contract - {"status": "1","message": "OK","result": <ABI_DEFENITION_OF_THE_CONTRACT>}


Paradigmatic vs syntagmatic relationship

Question: I was exploring some various aspects of corpus linguistics and studying different approaches to corpus research on the internet when I came across these phinomena of paradigmatic
and syntagmatic relations. Can I get a satisfactory elucidation of both the concepts as well as how do the two technically and practically differ?
Comment: Your very first statement sounds rather fallacious to me, when you say that Paradigmatic relation is the relation simultaneously of the opposition and functional identity  between linguistic elements, the combination of two contrasting attributes isn't getting down my throat. Could you please further illaborate that?
Comment: Your comment should probably be under my answer, not here. Still, I'll answer. There's nothing fallacious there. If we take phonemes, they oppose each other, they form contrasting pairs, but still they function the same way, identically – they all serve as building blocks for morphemes with their opposition needed to differentiate morphemes. There's no contradiction in what I wrote.
Comment: Syntagmas and paradigms are orthogonal to each other. Syntax is time-related -- one item follows another -- whereas paradigms are fixed relationships among the choices available at each stage of a syntagma. Paradigms are the divergence and syntagmas are the curl; they each describe one aspect of many in language.
Answer: Paradigmatics
Paradigmatic relations are relations of opposition and functional identity of linguistic elements ("OR - OR"), i.e. the paradigm combines sets of linguistic units that are similar according to one, and opposed according to some other criterion(s). Paradigmatics determines to which level of grammatical categoric hierarchy this or that language unit belongs, by analogy with units similar to it. For example:

Phonemes b, ɪ, g, s, t are the building blocks of morphemes big and -est.
Morphemes big and -est can combine to form the lexeme biggest.
The lexeme biggest is a part of the sentence That's the biggest fish I've ever seen!

Syntagmatics
Syntagmatic relations can be defined as relations of compatibility of elements of the level in a sequence of speech events, i.e. combination of phonemes with phonemes, morphemes with morphemes, etc. Syntagmatics combines language units by their direct combination.
The logical formula of syntagmatic relations is the formula "AND - AND", i.e. both one element and another element together, side by side, one after another, forming a chain of the same-order elements of a certain length.
Examples of syntagmatic relationships:

b=ɪ=g=ɪ=s=t, bɪg=ɪst (phonetico-phonological level)
big=est, water=s, walk=ing (morphological level)
teach=er, re=name (word-building sub-level)
tall man, tall tree (lexical level)
The tree is tall. (syntactical level)


Cauchy boundary conditions and Greens functions with Fourier transform

Question: Consider the wave equation
\begin{align}
(\partial_t^2-\nabla^2)\phi(t,x)=0,
\end{align}
with Cauchy boundary conditions $\phi(0,x)=f(x)$ and $\dot{\phi}(0,x)=g(x)$. Suppose we perturb the system with an external source $J=J(t,x)$. The solution to this is given by
\begin{align}
\phi(t,x)=\phi_0+\int_{-\infty}^\infty dt'dx'\,G(t,t';x,x')J(t',x'),
\end{align}
where $\phi_0$ is the homogeneous solution without the external source that fulfills the Cauchy boundary conditions, and $G(t,t',x,x')$ is the Greens function, compatible with the differential equation
\begin{align}
(\partial_t^2-\nabla^2)G(t,t';x,x')=\delta(t-t')\delta(x-x').
\end{align}
A common approach to solve this is to Fourier expand the Greens function, i.e., to consider
\begin{align}
G(t,t';x,x')=\int_{-\infty}^\infty \frac{d\omega d^3k}{(2\pi)^4}\tilde{G}(\omega,\vec{k})e^{i\left[\vec{k}\cdot(\vec{x}-\vec{x}\,')-\omega(t-t')\right]},
\end{align}
and replace it in the Greens equation where we can invert the differential operator in momentum and frequency space. Regarding the wave operator, we can find
\begin{align}
\tilde{G}(\omega,\vec{k})=\frac{1}{-\omega^2+k^2},
\end{align}
where $k=\left|\vec{k}\right|$, and then if we are able to solve the integral
\begin{align}
G(t,t';x,x')=\int_{-\infty}^\infty \frac{d\omega d^3k}{(2\pi)^4}\frac{e^{i\left[\vec{k}\cdot(\vec{x}-\vec{x}\,')-\omega(t-t')\right]}}{k^2-\omega^2},
\end{align}
we are "done"—we obtained the Greens function, and then if we integrate it with the external source we can obtain the total solution of the system, in principle. However, regarding this method, how does the Greens function, or the total solution "feel" the Cauchy boundary conditions in this example? Moreover, where can I find literature about this discussion?
Comment: You have the contour integral, but to solve this integral, you will have to specify the contour as well. In what way do you think that the choice of contour will affect your answer?
Comment: With the retarded prescription the result will be proportional to $\Theta(t-t')$, with the advanced to $\Theta(t'-t)$ while the Feynman's one will be ordered in time. I know that, however, I don't see how those quantities are involved in the discussion of my question.
Answer: Your problem is not specific to d'Alembert's PDE, but can be traced back to ODE's, even the simple harmonic oscillator. Say you want to solve:
$$
\frac{d^2G}{dt^2}+G = \delta
$$
Going to Fourier transform:
$$
\tilde G(\omega)=\int\frac{d\omega}{2\pi}e^{i\omega t}G(t) \\
G(t)=\int dte^{-i\omega t}\tilde G(t) \\
(-\omega^2+1)\tilde G = 1
$$
You want to divide by $1-\omega^2$. However, when $\omega=\pm1$ this is zero, so the "value" there is undefined. Using the theory of distributions, you can prove that $\hat G$ is necessarily:
$$
\tilde G = PV\frac{1}{1-\omega^2}+C_+\delta(\omega-1)+C_-\delta(\omega+1)
$$
with $PV$ denoting the Cauchy principal value and $C_\pm$ being constants. The converse is easy to check, using the fact that:
$$
f(t)\delta(t) = f(0)\delta(t)
$$
Going back to time:
$$
G = \frac{\sin |t|}{2} +C_+e^{-it}+C_-e^{it}
$$
with $H$ you see that $C_\pm$ is specified by the initial conditions $G(t_0),\frac{dG}{dt}(t_0)$.
Back to your case, the similar situation happens when you divide by $k^2-\omega^2$. From:
$$
(-\omega^2+k^2)\tilde G = 1
$$
you deduce:
$$
\tilde G = PV\frac{1}{-\omega^2+k^2}+C_+(k)\delta(\omega-|k|)+C_-(k)\delta(\omega+|k|)
$$
with now $C_\pm$ are functions defined on $R^3$. They can be determined by the Fourier transforms of $G,\partial_tG$ at $t_0$ which will give the unique solution to the Cauchy problem.
In classical physics, you are often interested in the causal solutions, i.e. $G$ is supported on positive times (in field theory, you are rather more interested in the Feynman propagator which you obtain by Wick rotation or time ordering). It turns out, using Jordan's lemma and the residue theorem, that it amounts to taking the limit of $\epsilon\to 0^+$ of:
$$
\tilde G = \frac{1}{k^2-(\omega-i\epsilon)^2}
$$
and more generally making the substitution $\omega\to \omega-i\epsilon$.
Hope this helps.
Answer to comment
a) Actually the prescription retarded/advanced/Feynman will determine the $C_\pm$. Once again, there is an ambiguity in defining $\frac{1}{k^2-\omega^2}$ which these prescriptions help resolve. If you want to interpret it as the Cauchy $PV$, then you need to add the appropriate $C_\pm$.
However, in this case, it is easier to think directly in terms of contour integration since you are not interested in solving the Cauchy problem. Indeed, writing explicitly what the prescriptions mean for the $C_\pm$ is needlessly complicated.
b) It depends. The problem arises when you divide by zero, in which case you need additional information to uniquely define your Gren's function (boundary condition, causality ...). However, this is not always necessary. Take for example the operator $-\Delta+m^2$ with $m$ real in arbitrary dimensions. Then its Green's function is (in Fourier):
$$
\tilde G = \frac{1}{k^2+m^2}
$$
which makes sense no matter what since the denominator never vanishes. Adding boundary conditions would overdetermine it.
An important caveat is that when you are taking Fourier transforms, you are restricting your attention to tempered solutions. In general, you could have more solutions thus requiring further restrictions. Take for example a modification of the previous simple case:
$$
-\frac{d^2G}{dt^2}+G = \delta
$$
By Fourier transform, you obtain the unique tempered Green's function
$$
\tilde G = \frac{1}{1+\omega^2} \\
G = \frac{e^{-|t|}}{2}
$$
however, if you are looking for distribution solutions in general, you could get for example:
$$
G = \frac{e^{-|t|}}{2}+C_+e^t+C_-e^{-t}
$$
with $C_\pm$ arbitrary constants and can be resolved by Cauchy boundary conditions. Note that when the coefficients are not zero, $G$ is not tempered, so the usual Fourier transform is ill defined.
In physics, you usually sweep under the rug such technical assumption (temperedness ...). To really guarantee unicity you'll need to do some rigorous math. Check out any course on distributions for more information.
Comment: Thank you for your answer. I know what the retarded, advanced, and Feynman's prescriptions are. However, a) If I compute one of them, these constants $C_\pm$ will not appear? I have computed them, and it seems that they do not. And b) so it seems that when I compute Green's functions by means of Fourier transform, it is necessary to specify boundary conditions for it apart? (I know that they can be read from the boundary conditions for the dynamical function (see https://en.wikipedia.org/wiki/Green's_function#Theorem)). I am confused.


Script to create new files with content recursively

Question: I have a tree of folders where every folder contains between two and three jpg files. As I have plenty folders, I would like to develop a script to create recursively an Inkscape file in every folder containing the jpg files in it, and renaming the svg file with the name of the containing folder. How may I achieve this?
Answer: Find directories with JPG files and run inkscape on them:
find . -type d \
    -exec sh -c 'set -- "$1"/*.jpg; [ -e "$1" ]' sh {} ';' \
    -exec sh -c 'inkscape --export-plain-svg="$1/${1##*/}.svg" "$1"/*.jpg' sh {} ';'

This will look for directories under the current directory. If the directory contains at least one .jpg file, inkscape is invoked on this directory, picking up all .jpg files from within it and exporting an SVG file into it, with the name of the directory as its filename.
The output filename is constructed as $1/${1##*/}.svg where $1 is the first command line argument to the sh -c script (this is the path to the directory with the .jpg files), and where ${1##*/} will strip the path from the directory and leave just the directory name.
This is untested in as far as I don't have inkscape and I'm not familiar with the program (apart from reading its manual).
Given the following directory structure:
$ tree
.
|-- dirA
|   `-- 1
|       |-- file.jpg
|       |-- image.jpg
|       `-- picture.jpg
`-- dirB
    |-- 2
    |   |-- file.jpg
    |   |-- image.jpg
    |   `-- picture.jpg
    |-- 3
    |   |-- file.jpg
    |   `-- image.jpg
    `-- 4
        |-- file.jpg
        `-- image.jpg

6 directories, 10 files

This is what would have been executed:
inkscape --export-plain-svg=./dirA/1/1.svg ./dirA/1/file.jpg ./dirA/1/image.jpg ./dirA/1/picture.jpg
inkscape --export-plain-svg=./dirB/2/2.svg ./dirB/2/file.jpg ./dirB/2/image.jpg ./dirB/2/picture.jpg
inkscape --export-plain-svg=./dirB/3/3.svg ./dirB/3/file.jpg ./dirB/3/image.jpg
inkscape --export-plain-svg=./dirB/4/4.svg ./dirB/4/file.jpg ./dirB/4/image.jpg

Comment: Thanks Kusalananda for your quick answer. At first, it seemed to work. The script created the svg file keeping the name of the containing folder. However, only 1 jpg file was included and not all the files contained in the folder. What might be the problem and how can it be solved?
Comment: @antecessor This may be something to do with how `inkscape` works when you give it multiple input files. I don't use this program. Could you tell me what the command should look like for a single folder?
Comment: I don't really know how the command should look like... I've been checking the manual and I don't really know where to look at... I ran Inkscape from my terminal but nothing appears on it when importing images from the GUI...


Automatically connect bluetooth mouse

Question: I have a bluetooth mouse (Apple Mighty Mouse) which I use with Kubuntu (KDE). I always have to manually connect to the mouse, although it is listed as a trusted device. How can I automatically connect the mouse when I have it turned on? Or at least reconnect after suspend?
Comment: That looks deprecated, I do not have a `/etc/default/bluetooth` config, but a `/etc/bluetooth` folder.
Comment: You might want to try the method mentioned here https://help.ubuntu.com/community/BluetoothSetup
Answer: You can use hciconfig to do that.
First manually connect your mouse as you usually do, then open a terminal and run hciconfig -a to retrieve its name. It should be something like hciX where X is the number of your device. You can either use hcitool scan, it should give the name as well.
Once this is done, you can force the bluetooth device detection by running
sudo hciconfig <name_of_your_mouse> reset

In order to do that automatically at every boot, you want to edit /etc/init.d/bluetooth and append the magic line at the end of the file : hciconfig <name_of_your_mouse> reset. Then save, reboot, and it should work forever.
Also make sure that your mouse is plugged in at boot time. If you plug it in after booting you will have to manually detect the mouse again.
Hope this helps.
Answer: I have a Logitech bluetooth travel mouse. I have Ubuntu 20.04. My laptop is a Lenovo ideapad.
How to fix Bluetooth in Ubuntu
First, if bluez is installed. make sure the mouse is detected and paired. If not remove mouse icon, press the button on the mouse to pair and reconnect the mouse.
next:
open terminal
To turn it on enter:
sudo /etc/init.d/bluetooth start

To make it permanent when booting up the system enter:
sudo systemctl enable bluetooth

Also:
rfkill list # to see if anything is blocked

And to remove and reinstall the bluetooth stack and programs if it is corrupted use:
sudo apt purge python-bluez
sudo apt install python-bluez

Install blueman:
sudo apt install blueman

Edit the main.conf file:
sudo nano /etc/bluetooth/main.conf

uncomment ReconnectAttemps=7 (remove # character) and also uncomment (remove #)
AutoEnable=true

Save, exit nano and reboot.
To remove blueman icon in upper right corner, right-click on blueman icon then uncheck appindicator under plugins.
Make sure to close cover and turn off mouse. Wait for suspend mode to occur (blinking power light), then turn on mouse then open lid on.
The mouse will automatically connect.

Automatically connect bluetooth mouse


PSN Wallet top up card

Question: I'm wanting to buy a PSN Wallet top up card from the UK and send that redeem code over to a guy in California. Would UK money on that card work on his PS4 in California if you know what i mean?
Answer: No.
via the PlayStation Community
User "emerald swords" wrote in 2009:

PSN cards are region locked. You will need to buy a card associated
  with your region.  DLC's are also region locked.   I've used this site
  several times for obtaining codes out of my region, works very well!

This was again verified by a pro level community supporter, "Brit-Ko" in 2010:

No PSN cards from one country will not work in another, for example a
  USA PSN card will not work in the UK & vice versa, having said that if
  the country was an EU country then an EU PSN card would work in a
  number of countries, make sense?

You'll have to purchase a PSN card from the region the recipient will use it.

PSN Wallet top up card


In a restaurants' kitchen in SC, is it DHEC approved to store raw meat next to ready to eat food?

Question: In a cold table, is it dhec approved to hold raw meat up top next to ready to eat food, provided they have lids.  There is a 3-4 inch steel spacer in between each top holding area.  It would not be above the ready to eat food in any way, and the way the table is designed, splashing is not likely. If anyone could refer me to the specific law that would be great as well.  Thanks.
Answer: Here is a link to the South Carolina Retail Food Establishment Regulation page. I'd recommend looking at section 3-302. It says that except as specified, you should separate raw animal foods from ready-to-eat foods during storage, preparation, holding, and display. If you can't find what you're looking for I would call them and ask them what the regulations are because laws can vary from each locality.
Personally, I would never store or work with raw meat anywhere near ready-to-eat (RTE) foods without sanitizing in between. Also, raw meat is a TCS food, is the cold table going to keep it cold enough? I guess it depends how long you're holding it for. If your establishment is constantly handling raw meat throughout the day I'd recommend having separate stations for RTE foods and raw meat (cross-contamination between the two is extremely dangerous to customers and it's better to separate them altogether). Hope that helps.


Latin-1 Supplement Unicode Characters

Question: The unicode characters under the "Basic Latin" unicode block from U+0020 to U+007F are the characters that characters we use in English. However, the "Latin-1 Supplement" block from U+00A0 to U+00FF is an extension of the "Basic Latin" block and includes characters that are used in some languages. For example, the Spanish language use all the characters from U+00A0 to U+00BF as well as the letter "Ñ/ñ" (U+00D1 and U+00F1), which is pronounced like the "ny" in "canyón". So, how did some languages get the characters under the Latin-1 supplement block?
Comment: You don't use most of U-0001 to U-001F in English. And my friend Zoë thinks you are naive to think no other characters are used in English.
Comment: [Politics](https://politics.stackexchange.com/help/on-topic)?!
Answer: The Latin-1 supplement was taken unaltered from the upper half of an existing standard, ISO 8859-1, which in turn was based on a standard published by the European Computer Manufacturers Association (ECMA) in the early 1980s as ECMA-94.
ECMA-94 was based on an actual hardware encoding, developed by Digital Equipment Corporation (DEC) for its popular VT-220 video display terminal, presumably on the basis of what they perceived as customer demand. But the various national standards associations negotiated some adjustments which, as is often the case, were hammered out in interminable meetings attended by well-meaning people with a lot if enthusiasm but without much expertise in designing character sets.
In the end, ISO 8859 was extended to a series of 8-bit encodings, ISO 8859-1 through ISO 8859-15, providing support for national languages which had not been well-served by the original encoding.
By then it was obvious that 256 codes were not enough for all the alphabets in use at the time, but there was still some reluctance to switch to a wider encoding for languages which could be shoe-horned into eight bits. Many manufacturers were quite prepared to sacrifice the possibility of representing multilingual documents (unless, of course, one of the languages was English), and the relatively simple Unicode proposal was countered within the ISO by a byzantine collection of unworkable multibyte shift encodings. Fortunately Unicode did eventually prevail, but the provisions for context-dependent shift encodings continue to complicate multilingual APIs.
For another view of this history and some interesting links, you can check out the Wikipedia entry on ISO 8859-1.

Latin-1 Supplement Unicode Characters


Vector potential in gauge transformation

Question: While applying Gauge transformation, $\psi\prime = U \psi$ , where $ U= e^{i q \lambda(x)}$ , transformation law for "Vector Potential" comes out to be : $$ A_{\mu}\prime= UA_{\mu}U^{-1}-\dfrac{i}{q}(\partial_{\mu}U)^{-1}U.$$ The book I am referring, derives this using the argument that if $ \psi\prime = U\psi$, then this implies $$ D_{\mu}\prime \psi\prime= U(D_{\mu}\psi) .$$ Can anybody explain the origination and meaning of this assumption?
Answer: I would say that $D_\mu '\psi' = U(D_\mu \psi)$ is a requirement, rather than an assumption:
When $U$ is a global transformation (i.e., when $\lambda$ is independent of $x$), we have trivially $\partial_\mu \psi' = U(\partial_\mu \psi)$, and so $(\partial_\mu \psi)^\dagger (\partial_\mu \psi) = (\partial_\mu \psi')^\dagger (\partial_\mu \psi')$.
We define the 'covariant derivative' $D_\mu$ by requiring that $D_\mu \psi$ transforms in the same way under local transformations, $D_\mu' \psi' = U (D_\mu \psi)$, and so the corresponding combination $(D_\mu \psi)^\dagger (D_\mu \psi)$ is invariant under these.
The simplest way to do this is minimal coupling: define $A_\mu$ transforming as you state and set $D_\mu = \partial_\mu - i q A_\mu$.


How to configure eth0 manually?

Question: How to manually configure eth0 in Ubuntu?
I don't have any DHCP server. Do I need IP address when I am just going to capture packets?
Answer: I am not sure what you exactly mean by your question. The real manual method has been described above, but since you write you don't have DHCP, I think you rather would like to know what to do to give your box a static IP address and assign this IP address at boot time automatically. Well, here is how:
There should be a file /etc/network/interfaces. This file is read by the Ubuntu boot scripts which in turn configure the network according to that file. If you would like to know what should / could go into that file, then please type "man interfaces".
For example, my /etc/network/interfaces looks like this (comments are cut out):
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 192.168.20.20
        netmask 255.255.255.0
        network 192.168.20.0
        broadcast 192.168.20.255
        gateway 192.168.20.250

The first two lines are standard and may already look similar on your box. You may be interested especially in the rest of the file: These lines define a static network configuration to eth0 (without DHCP), and this static configuration gets active automatically on every boot.
Answer: You may want to try this as well:

sudo -H gedit /etc/network/interfaces
Edit the eth0
auto eth0
iface eth0 inet dhcp

Save and Exit
Run sudo /etc/init.d/networking restart.
Answer: You don't need IP address for capturing packets in promiscuous mode (when you want to capture all traffic, not just traffic destined to your computer). You can put that interface up using command
ifconfig eth0 up

This do not assign IPv4 address to interface (IPv6 local-link address is automatically assigned, if you have IPv6 enabled).
Comment: with the new `ip` use `ip link set eth0 up` instead
Answer: ifconfig
ifconfig etho
ifconfig ehto 192.168.3.40 netmask 255.255.255.0
route -n

or
ip route show
then
name for DNS
nameserver 127.0.11
nameserver 184.108.40.206

Comment: the abover answer just configuration for ip address

How to configure eth0 manually?


Your employer approaches you with a raise offer. Is it appropriate to negotiate if you aren't satisfied with the offer?

Question: Quick background - I am an accountant for a small labor union.  The lady that runs the pension department is due for retirement and it is openly discussed in the office that I will be filling her role.  I had planned to negotiate a raise when the time came, but my boss approached me the other day and volunteered that he would be giving me a raise when I moved into the new position.  This was music to my ears, as I wasn't sure how well asking for a raise would go over, especially in the middle of a pandemic and after we just lost a major, multi-year pipeline project.  I had a number in mind that I planned to ask for.  If my boss offers me less than what I desire, would it be in bad taste to counter his offer?
Comment: @D Stanley, apologies, stack exchange is a vast network and I wasn't sure where to post.  I only belong to this one and Home Improvement, and this fits a helluva lot better here.  I'll join Workplace.
Comment: Would you be willing to fulfill the new role for no extra money? Do you view this potential new role as a benefit or a burden?
Comment: @spuck No, I wouldn't be willing to fill the new role for the same rate of pay.. But in this case I'm not the one initiating negotiations.  I was (or will be) approached with an offer.  I was just looking for some feedback as to whether or not it would be appropriate to counter an unsolicited raise offer.
Comment: Understood. Just trying to gauge how important the money actually is, which gives some idea of how much you're willing to risk or give up to reach a deal.
Answer: It is absolutely appropriate. As a boss myself, I don't want ANYONE to be afraid to speak their mind and stand up for what they think they are worth.
If you worked for me and did that I would hear you out. If I agreed and had the budget I'd make the raise happen. If not, I'd explain my counter-argument and hope you stayed with the company without the raise. Or I would counter-offer a smaller raise.
In the end you have to be willing to walk if you don't get your number. If you aren't then you really have very little negotiating position and are demonstrating you are willing to work for less.
Good luck!
Answer:
If my boss offers me less than what I desire, would it be in bad taste
to counter his offer?

No. It would not be in bad taste to ask for more.


Can a game have characters named after video game franchises?

Question: The video game Battlerite, a free to play team brawler, includes a hero called "Destiny", essentially named after the Destiny video game franchise. Is this legal, and why it is not a trademark infringement?
Comment: Voting to close as duplicate as it essentially the same as [Is it legal to use car manufacturers' names in a game?](https://gamedev.stackexchange.com/questions/14460/is-it-legal-to-use-car-manufacturers-names-in-a-game)
Comment: What is the difference between this question and [your previous question](https://gamedev.stackexchange.com/questions/201416/it-is-legal-to-create-a-video-game-that-uses-the-name-of-moba-heroes-for-another)?
Comment: In general, does X infringe on Y is determined by context & when needed, the court system. Legal where? Things that may be legal in on place might not hold in another. Do they know? Sometimes it's up to the IP holder must discover violations & enforce their rights. What's the intent? Some applications might be legal (Destiny is a common enough name) & others not (if Battlerite appears to be leveraging the Destiny franchise popularity for its gain). These are just some of the issues potentially at play; complex legal questions are best directed to legal professionals.
Comment: This does not look like a question about how to develop a game, but a question about law you should ask a lawyer. This site draws experts in the making-a-game parts of game development. If you want an expert in trademark law, you're much less likely to find them here than on dedicated legal sites. Trademark law does not take on a separate "game version" that only game developers know about if the supposed violation happens to occur in a game, so I don't see any reason to bring this question to a gamedev site rather than to a trademark lawyer.
Answer: I'll start by saying that I'm by no means a legal expert and that your question will be much better answered in the Law Stack Exchange.
That being said, from my understanding of the U.S. copyright and trademarks laws, it depends on the specifics of the use of the name. As you seem to know, names aren't under copyright, but under trademarks. In order to keep your trademark, you need to defend it, otherwise you'll loose it. This is why the Elder Scrolls sued Mojang for the use of Scrolls in the name of one of their games. They needed to do so to keep their trademark, but they lost because Scrolls is too common of a word to be kept by one person. Also, remember that the trademark law is meant to benefit the consumers, not the companies, to make the products differentiable. So if the two products, or the use of the name in both cases, is easily differentiable, it should not be a trademark infringement. In your case, unless Destiny clearly refers to the game or one of its characters, I don't think it would be a trademark infringement. Imagine if all books using the word destiny could to be sued for that, it wouldn't make any sense.
But remember that I might be completely off, especially if you're not talking about the U.S., in which case I refer you to Law Stack Exchange (linked earlier) or to your relevant jurisdiction's website to read the actual laws, such as:

US Federal Code
Consolidated Laws of New York
Consolidated Acts and Regulations of Canada


What is the biblical basis for denying the Lord's Supper to those in mortal sin?

Question: Recently, Nanci Pelosi was barred from receiving Eucharist by the Catholic Church, due to her public stance on abortion which contradicts the Catholic faith, considered a mortal sin by the Church. What is the biblical basis for denying someone in mortal sin the Eucharist?
Comment: @Jess It literally uses the word Catholic twice in the body and has it in the tags
Comment: It needs to have catholic in the heading!
Comment: Matt 18 lays out instructions for approaching the fellow believer living in sin. After several failed attempts to turn him from sin, including involving the Church itself, the ultimate recourse is to cast him from the Church and no longer associate with him.
Answer: What is the biblical basis for denying the Lord's Supper to those in mortal sin?
St. Paul speaks of this quite clearly!

26 For as often as you shall eat this bread, and drink the chalice, you shall shew the death of the Lord, until he come.
27 Therefore whosoever shall eat this bread, or drink the chalice of the Lord unworthily, shall be guilty of the body and of the blood of the Lord.
28 But let a man prove himself: and so let him eat of that bread, and drink of the chalice. - 1 Corinthians 11:26-28

This has always been the teachings of the Church.

Who Can Receive Holy Communion?
The Catholic Church sets out specific guidelines regarding how we should prepare ourselves to receive the Lord's body and blood in Communion. First, you must be in a state of grace. "Whoever, therefore, eats the bread or drinks the cup of the Lord in an unworthy manner will be guilty of profaning the body and blood of the Lord. Let a man examine himself, and so eat of the bread and drink of the cup" (1 Cor. 11:27–28). This is an absolute requirement that can never be dispensed. To receive the Eucharist without sanctifying grace in your soul profanes the Eucharist in the most grievous manner.
A mortal sin is any sin whose matter is grave and which has been committed willfully and with knowledge of its seriousness. Grave matter includes, but is not limited to, murder, receiving or participating in an abortion, homosexual acts, having sexual intercourse outside of marriage or in an invalid marriage, and deliberately engaging in impure thoughts (Matt. 5:28–29). Scripture contains lists of mortal sins (for example, 1 Cor. 6:9–10 and Gal. 5:19–21). For further information on what constitutes a mortal sin, see the Catechism of the Catholic Church.
The Church's ancient teaching on this particular matter is expressed in the Didache, an early Christian document written around A.D. 70, which states: "Whosoever is holy [i.e., in a state of sanctifying grace], let him approach. Whosoever is not, let him repent" (Didache 10).

Those publicly supporting abortion are guilty of creating a grave scandal in the eyes of many Catholics.
Comment: The problem is that nothing in that Scripture says anything about others being able to prevent you from taking it. And, in the vast majority of cases, bishops don't do this. Plus there's the issue of the fact that saying a grave sin should be legal isn't a grave sin.
Comment: @trlkly Just because the vast majority of bishops do not take this step, makes this a less viable answer. Those other bishops lack courage to take the this step! Politics?
Comment: My wording was bad there. It's not that most bishops don't do this. It's more that no bishop does this for the vast majority of grave sins. And, yes, I do believe the reason this is being done here is for political reasons.


What could cause Visual Studio / C# error MSB3105: Duplicate resources

Question: While working on an existing project I suddenly got the following error when trying to compile the solution:
error MSB3105: The item "[filename]" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
Now, as far as I'm aware, I did not make any change to the project that affects the resources. Also I have checked each and every file within the project, but there is no duplicate reference anywhere to this file.
Now I already found some forum entries regarding this error:
1) Open the .csproj file and remove the duplicate reference. [Tried this, but I cannot find any duplicates in it]
2) In a 'partial class' project, move everything to a single class. [ Could try this, but the project has been split up into partial classes since the start, and I do not want to change this just because of the error ]
So what else could cause this ?
Comment: A more recent variant of the question, with different cases and solutions: http://stackoverflow.com/questions/7810758/how-to-solve-a-duplicate-items-error-in-the-resources-parameter
Answer: Did you try showing all files in the Solution Explorer?  You could have a duplicate .rsx file somewhere in there.
Comment: Thanks for the suggestion. But I did, and I did not find a duplicate. I also tried to find duplicate forms, for someone suggested I might have accidentally copied a form.
Answer: I found the answer in .NET forum posting by Roy Green, and Theresa was right after all, though I did not recognize it.
If you have your main form class split up into partial classes, the partial sections end up in the solution explorer as separate items. And if you double click on them they show up in the designer mode as a normal form. But if you (accidentally) drop a control on these forms, Visual Studio creates a new .resx file and a InitializeComponent routine for it. But since this form is actually just part of the Main Form class it leads to the 'duplicate resources' error. And there is no other solution but to remove the InitializeComponent routine and delete the .resx file by hand.
Answer: Be sure that under yourForm.cs no duplicate resources are defined (.resx). If you renamed your Form, remove the old resource because the new one during compile will be created with the new name.
Answer: I just made the same mistake. Delete the mainform.designer.vb, then I restored it again from the recycle bin, and found this error message when compiling.
I try to search on google and someone suggested to check on .vbproj. Did that and found a duplicate on some line.
Answer: I had this as well, in VB.  There is the "real form" file frmMain, and then I had created new class files and modified them to be Partial Public Class frmMain.  For example, I have an ImportFromExcel.vb Partial Class file (I didn't want to clutter up the frmMain.vb with the rather complicated Excel import code.)
Everything worked fine until I decided I wanted to use an OpenFileDialog in the Sub ImportFromExcel.  I dragged the OFD from the toolbox over to the Designer view of the ImportFromExcel file.  (I have no idea why this view exists, if you can't do anything with it!)  But at any rate... dragging the OFD to the Partial Class Designer created an ImportFromExcel.resx file.  The drag/drop operation also created an InitializeComponent sub in ImportFromExcel, which is redundant and shows an error -- easily corrected with a little editing.
Ultimately, I chose to not use the dragged resource, but localized the code in the ImportFromExcel.vb file.
All you really have to do is right-click the ImportFromExcel.resx file, and choose Delete. Everything else seems to "fix itself", and it builds fine now.
Comment: Nice solution to a similar problem. But maybe you should add it as a new question / answer so it can be found by VB users ?
Answer: In my case, this problem happened because a file had the same name but not the same case in the GIT repository.
For example MyFile.cs and myFile.cs.
If you do a checkout on windows, one of the files is overwritten by the other (no message, no warning). So, it is compiling, and we don't notice anything. But if you try to compile on Linux (with .NET Core) both files are present, and there is this error at compile time.
Comment: Same issue, had to ssh into our build server and `git rm `


Find registry key for windows 8 per-application input method setting

Question: I had some trouble to adapt a windows 7 application for windows 8. The issue was windows 8 having a global input method on windows 8.
I found that the control panel setting "Let me set a different input method for each app Windows" solved my problem (Set Windows 8 to per-application input language mode).
Now my question is : where can I find this setting in the windows 8 registry ?
I would like to retrieve this key in my application..
Answer: This setting is stored in HKEY_CURRENT_USER\Control Panel\Desktop\UserPreferencesMask. The registry value itself is a binary value that represents a bitmask of various settings.
Its format is documented here
Unfortunately this document is a bit oudated and does not contain information about this particular setting. By experimenting with this value I have found that the settins is stored in bit 32. When this bit is on, input switches for each application separately.
<code>Example of HKEY_CURRENT_USER\Control Panel\Desktop\UserPreferencesMask with setting on:
9e 1e 07 80 92 00 00 00
With setting off:
9e 1e 07 80 12 00 00 00
</code>
Here is a Powershell script example to turn it on:
<code>$prefMask = (Get-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'UserPreferencesMask').UserPreferencesMask
if (($prefMask[4] -band 0x80) -eq 0) {
  $prefMask[4] = ($prefMask[4] -bor 0x80)
  New-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'UserPreferencesMask' -Value $prefMask -PropertyType ([Microsoft.Win32.RegistryValueKind]::Binary) -Force | Out-Null
}
</code>
Was tested on quite a bunch of win8.1 machines (both x86 and x64) and appears to work as expected.
Note that the setting takes effect immediately, but displays wrong in language panel settings dialog. So you need to logoff and logon back for panel settings to pick up the change.


Printing custom paper size to an impact printer in WPF

Question: I'm printing to an impact printer, loaded with 8.5 x 8.5 inch paper.  When I print, the printer ejects 11 inches instead of 8.5.
PageMediaSize pageSize = new PageMediaSize(PageMediaSizeName.Unknown, element.Width, element.Height);

PrintDialog dialog = new PrintDialog();
dialog.PrintTicket.PageMediaSize = pageSize;
Console.WriteLine(dialog.PrintableAreaHeight); // 816, good!
dialog.PrintQueue = myQueue;                   // selected from a combobox
Console.WriteLine(dialog.PrintableAreaHeight); // 1056 :(

dialog.PrintVisual(element, description);

Using "How do I convert Twips to Pixels in .NET?" I've determined that 8.5 inches is 816 pixels, which is the size of my element.Width and element.Height.  I'm setting a new PageMediaSize, but this seems to have no effect, dialog.PrintableAreaHeight is still ends up at 1056 when I set the queue on the dialog.
If I do dialog.ShowDialog(), manually pick my printer, and manually find and change Paper Size in my printer's advanced settings, then dialog.PrintableAreaHeight properly reflects the change.
This page http://go4answers.webhost4life.com/Example/set-printdialogs-default-page-size-168976.aspx suggests that I can only set a PageMediaSize supported by my printer. Using the GetPrintCapabilities function on my PrintQueue, I see a list of 10 or so page sizes, none of which are 8.5 x 8.5. This is the same list I see when I go to my printer's advanced settings in windows.
Answer: Please find the code below, it sets paper size as required
        var printerSettings = new PrinterSettings();
        var labelPaperSize = new PaperSize { RawKind = (int)PaperKind.A6, Height = 148, Width = 105 };
        printerSettings.DefaultPageSettings.PaperSize = labelPaperSize;
        var labelPaperSource = new PaperSource { RawKind = (int)PaperSourceKind.Manual };
        printerSettings.DefaultPageSettings.PaperSource = labelPaperSource;
        if (printerSettings.CanDuplex)
        {
            printerSettings.Duplex = Duplex.Default;
        }

Comment: Incomplete solution and explanation


Is there a way to standardize latitude and longitude to be used as predictors in KNN algorithm?

Question: The predictors are latitude and longitude, and target variable is region.
Comment: Take the cosine of the longitude, and take the sine of the latitude. This way, points on either side of the anti-meridian (longitude 180) will be near each other in the transformed space. You may need to convert the longitude/latitude to radians first depending on the implementation of sin and cos that you're using.
Answer: Rather than modifying your data, use great circle distance for those features' conmponent of the cost function.


Shear connections

Question: Question: which of the three shear connections (beam/column) below will require diagonal bracing?
Answer: Usually, there is no need for diagonal bracing. The details A and B are not suited for diagonal bracing.
Detail C for large span beams under heavy loads can have triangular stiffeners welded on the bottom between the two sides, but that kind of connection is not encouraged. If the girder or heavy beam connects to support or column, custom-designed connections are employed because of limitations on the detail C type configuration.
For A and B if the loads warrant they add horizontal web stiffeners as per this.
Comment: The shear plates/tabs in the image you showed above could potentially be braced with addition of the gusset. But which other type of connections are suitable for bracing?
Comment: There are huge amount of literature and research on steel connections. Shear, moment, ductile,  super plastic limit and beyond. Many steel frame buildings are designed for push over plastic joints, highly complex behavior design to withstand very large earthquakes at the expense of energy absorbing joints deforming into prescribed wrinkles.

Shear connections


mktextfm fails when pdflatex is invoked by cgi-bin script under www-data (apache)

Question: I'm starting pdflatex from a shell-script invoked as cgi-bin application on Ubuntu (running under default www-data user) and from time to time I have the following kind of error preventing compiling:
kpathsea: Running mktextfm larm0700
mktextfm: mktexdir ./.texmf-var/fonts/tfm/lh/lh-t2a failed.
kpathsea: Appending font creation commands to missfont.log.

./thebook.tex:330: Font T2A/cmr/m/n/7=larm0700 at 7.0pt not loadable: Metric (T
FM) file not found.
<to be read again>
                   relax
l.330 10 м/с\textsuperscript{2}

./thebook.tex:330:  ==> Fatal error occurred, no output PDF file produced!
Transcript written on thebook.log.

Inspection shows that an empty directory .texmf-var/fonts/tfm/lh/lh-t2a created in a working dir (in contrast with mktexdir message).
Running the same script with sudo -u www-data fixes the problem temporary: fonts are generated and then this particular document can be compiled from the cgi-bin script. But it does not provide stable result: as new fonts are needed, cgi-bin script stops working again.
The similar problems are discussed also here, here, here, here, here (in Russian), here and maybe somewhere else, but no clear solutions provided.
Answer: The problem was solved by adding
export HOME='/var/www'

to the shell-script just before the pdflatex command.