What exactly is a foreign key?

Question: Ok. So I know what a primary key in  DB is. If you have a table in a database, a primary key is a single value that is unique to each row in your table. For example:
id   | name    | whatever
-------------------------
1      Alice     ....
2      Bob       ....
45     Eve       ....
988    ....      ....

So I need a good, simple example to explain what exactly a foreign key is. Because I just don't get it :)

Edit: OK it's pretty easy, I guess I was over-complicating the problem.
So one final question, the only restriction on foreign keys is that it they are a valid primary key value in the table I am referring to?
Comment: "...a primary key is a single value..." yes, so long as you recognize that "value" is _not_ synonymous with "column." It's perfectly valid for the primary key to be multiple values.
Comment: Grrr. Can't edit comments. Last sentence should read: "It's perfectly valid for the primary key to be multiple COLUMNS".
Comment: "the only restriction on foreign keys is..." That's not a "restriction", that's the definition: an FK IS a valid primary key on another table.
Comment: It is the only restriction of being aforeign key, you can still put other restrictions onthe column if you like.
Answer: A foreign key is a field that points to a primary key of another table.
Example:
Table Name - Users

UserID    UserName    UserRoleID
1         JohnD       1
2         CourtneyC   1
3         Benjamin    2

Table Name - UserRoles

UserRoleID    Desc
1             Admin
2             Moderator

You can see that Users.UserRoleID is a foreign key which points to the primary key UserRoles.UserRoleID
The use of foreign keys makes setting up relationships on other tables simple, allowing you to link together the data of multiple tables in a nice way:
Example:
SELECT
    a.UserID,
    a.UserName,
    b.Desc as [UserRole]
FROM
    Users a INNER JOIN
        UserRoles b ON a.UserRoleID = b.UserRoleID

Output would then be:
UserID    UserName    User Role
1         JohnD       Admin
2         CourneyC    Admin
3         Benjamin    Moderator

Comment: No, not (only) a PK. In the relational model, a FK references a CK. (One of which might be called the PK.) (PKs don't matter to relational theory.) In SQL, a FK references a UNIQUE. (Which might be a PK). A CK is a superkey containing no smaller superkey. Some relational presentations might define a FK to reference a superkey. An SQL PK is just a UNIQUE NOT NULL & like any SQL UNIQUE might contain a smaller one.
Answer: Let's say you have another field, which is the home city:
id   | name    | city
-------------------------
1      Alice     San Francisco
2      Bob       New York
45     Eve       New York
988    Bill      San Francisco

Now, it does not make sense to repeat the same cities in many rows. This could lead you to typos, excessive space usage, difficulties to bring up results among other problems. So you use a foreign key:
id   | name    | fk_city
-------------------------
1      Alice     1
2      Bob       2
45     Eve       2
988    Bill      1

home city table:
id   | name
-------------------------
1    | San Francisco
2    | New York

Hope it makes things clearer for you. :-)
Update: about your final question: Yes. :-)
Answer: A foreign key is a column in one table that should uniquely identify something in another table. Thus, the values should correspond to primary keys in that other table.
For example, if you have a table of students taking courses, every record would include a student id and a course id. These are foreign keys into a student table (where there is one record for each student id), and a courses table (where there is one record for each course id).
Referential integrity means that all your foreign keys actually correspond to primary keys in these target tables. For example, all the student ids and course ids in your registration table correspond to real student ids and course ids.
Answer: id   | name    | whatever | countryid
-------------------------------------
1      Alice     ....       13
2      Bob       ....       42
45     Eve       ....       1
988    ....      ....       2

id   | countryid
----------------
1      Japan
2      Spain
13     Norway
42     Italy

The foreign key points from the person table (first) to a row in the country table (second)
Answer: A foreign key is the primary key from another table stored on your table. Say you have a table of customers and a table of orders. The CustomerId is likely the primary key on the customer table, and the OrderId is likely the primary key on the order table. But on the order table you need to know the customer for this order, no? Therefore you need to store the CustomerId on the order table. In this case the CustomerId on the order table is a foreign key.
I would point out that there is no requirement that a primary key (and therefore a foreign key) be a single column. It's simpler, sure. But I've worked on enterprise systems where the primary key was 11 columns long, and I'm sure there are examples longer than that. That is, you needed to know the value for 11 different columns before you can uniquely identify the row.
Comment: Best definition that I have come across.
Answer: In a relational database a one-to-many relationship is implemented by having the child table reference the ID of the parent table. The parent ID in the Child table is called a Foreign Key as it references a primary key of another table.
Answer: A foreign key is a field that references another table in the database. For example, suppose you had 2 tables, PERSON and ADDRESS. There is a field in PERSON called ID and a field in ADDRESS called PERSON_ID. You would make PERSON_ID refer to PERSON.ID as a foreign key. What this means is that you can't have an address that is not connected to a person, since the value in the ADDRESS.PERSON_ID field must exist in the table PERSON.
Answer: using your table example, assume you have another table:
cartid  |  id  | itemid
-----------------------
100        1       abc
101        1       cde

in this table, the primary key is the cartid, the foreign key is the id, which would be linked to your first table. user 1 has two carts, each cart having one item each.
a foreign key is the what you use to link two or more tables that have related information to each other.

What exactly is a foreign key?


Palette 2 with an Ender 3 Printer

Question: Has anyone had any luck with printing multi-colored prints with the Palette 2 on an Ender 3? If so, what is your steps/mm for the Ender 3 and your flow rate in whatever slicer you are using? I currently have my flow rate at 100 % and my steps/mm at 104.4, and I believe this is what is causing my Palette 2 to not produce accurate results.

About the Palette 2
Palette 2 is a separate device providing one multi color filament out of multiple single color filaments.
As the Ender 3 does not support multi-colour printing, that's why I'm using the Palette 2. It allows any printer to print in multi color as it adds multi color printing to single extruder printers.
Comment: What they do need to expand on is what "not produce accurate results" means.
Comment: Hi Trey and welcome to SE.3DP! Please update your question w.r.t. what exactly is the problem and what isn't happening as you expect it to. If you update your question to clarify what is wrong, then the question will be (most likely) reopened. Thanks in advance :-)
Comment: @TreyHope - You need to add more information like what is wrong. Are the colors not changing where you expect them to?
Comment: The OP clearly requires the help from somebody owning both the Ender 3 and the Palette 2, but probably it will be easier for him to contact the Palette customer support...
Comment: @Greenonline from what I could gather, it seems that you just need to fire up both machines, run the code for the pallete to calibrate the length of the connector tube+bowden tube, then run both machines with the code provided by the slicer - which should run them both to extrude at roughly the same speed forewards  and backwards. though I honestly have no idea how to sync the two as they don't appear to be connected...
Answer: On this thread, Does anyone tried Palette 2.0 on Creality Ender 3 or Ender 3 Pro?, there are a couple of useful links:

There is a video, albeit for the CR-101, but that should be of help: YouTube - Setup Guide: Creality CR-10 with Palette 2;
In addition, this Facebook group, Mosaic Palette, Palette+, Palette 2 (Pro) Users, apparently has some users who have paired their Ender 3 with the Palette 2.

However, with respect to your question about the flow rate and steps/mm, there isn't much info out there about that, and no one seems to have experienced similar issues, but your issue might have something to do with profiles - which, as you haven't mentioned them in your question, it is hard to know if that might be the issue or not.
In the same thread, this post, states:

I use it with the Ender 3.  There is a profile in Canvas and Chroma for it also.

This link here, Chroma for Palette 2, states that after using Cura, you then need to load the G-code file into Chroma v3.1, after having selected the appropriate profile. However, if you use Canvas, then there is no need for Cura nor Chroma, as Canvas can slice. This link goes through the whole process for Benchy.

At the risk of repetition, the process for preparing the print, post-slicing, is also given here, from Multicolor 3D Printing How To: Using the Mosaic Palette+ with the Creality Ender 3, albeit slightly different from the link above:

Setting Up Chroma:
When you load up Chroma, you'll be presented with a blank canvas ready
  to be filled with your 3D creations.  In the top left corner, make
  sure that you have the Ender 3 selected from the drop down menu.
  After this you can click Load Print.  From there you'll be presented
  with your gcode files that you have on your computer.
In this example we will be selecting the butterfly-1.gcode file, and
  clicking Open.  From here Chroma will be compiling and arranging the
  settings for the gcode file to be displayed.  This might take a minute
  or more.
Selecting Your Colors:
Once the loading is completed, you will be presented with the 3D
  rendering of our butterfly!  This butterfly will be in 4 randomly
  selected colors by default, but we will be changing this next!  To
  change the colors, navigate to the top of the screen where you will
  see 4 colored circles, and drop down arrows along with each circle.
  These circles represent the colors of each tool head.
To change the color, click on the Tool Head Colored Circle, and your
  options for color will appear, we're going to select Black for our
  first color.  After this, you will want to select the Default PLA
  Settings by clicking the Drop Down Arrow to the right of the first
  Tool Head Colored Circle.
As we make these changes you will notice that the 3D rendering of our
  butterfly will change to our corresponding colors.  Repeat this
  process for the remaining 3 Tool Heads, remember to use the Default
  PLA Settings for each Tool Head.
Saving Your Project:
After you have selected all your colors, you will click Save for
  Printer in the top right corner of Chroma.  From there, name your
  file, and click Save.  You will be then presented with a loading bar
  as Chroma prepares our 2 output files.  One of the files will be an
  adjusted gcode file that has added the purge tower we just modified,
  and the other file will be a file that goes straight to the Mosaic
  Palette+.
Printing Your Project:
Once the files are ready, you will be presented with a screen that
  says "Ready to Print!".  On this screen you will be presented with the
  files you have created for your project, which for us are the
  butterfly-1.msf which goes to the Mosaic Palette+ and the
  butterfly-1.msf.gcode file which is your newly created gcode file.
  You will also be presented with "Materials Used" for the project,
  "Number of Splices" for the project, and "Number of Pings" for the
  project.
After this, you will need to turn your Creality Ender 3 on if it isn't
  already.  After making sure that you have all your components set up
  and assembled correctly, then it is safe to begin the printing
  process.
Depending on your specific project will determine how long the
  printing process takes.  But once your printing process is complete
  you will be presented with your beautiful multicolored 3D butterfly
  (or whatever your project was)!  After printing is finished, you
  should let the project cool before you attempt to remove it from the
  tray. Once it has cooled you can now gently pry the project off of the
  tray.

Footnotes
1 The CR-10 is, on a broader level, an Ender-3 with 2 lead screws and a slightly different board.
Answer: The guide is at Getting Started With Palette 2 (Setup to Printing), which includes guides to use the correct slicer software and swapping the firmware.
The latter part may be a little bit of an ordeal on the Ender3 as there is no bootloader on it - however, it is not apparent from the instruction, whether this would be an issue or not - it seems to be a fairly simple process.

Open your Palette 2 package and remove your Palette 2 unit and USB cable. Connect your Palette 2 to your computer.
To help the updater recognize the port for your Palette, try
  unplugging other USB devices.
Download our Firmware Installer for your operating system.
Latest Palette Firmware V. 4.2.3 (Mar 14, 2019)

Windows (x32 or x64) Download
macOS    Download
Linux (x64, Tested on Ubuntu 16.04)  Download1

Follow the on-screen instructions and click "Install Latest"
Once the firmware is updated, you will receive the Success message, and you can unplug your unit from your computer.

1 For Linux users, please refer to this support article.
Comment: @Trish - Following on from our adventure, when we updated the firmware on an Ender, this process described above seem to be a lot less painful (Plug in USB and run an application). I wonder how that is achieved, with out the ISP programming (see [How to install new ATMEGA firmware via the ISP pins?](https://3dprinting.stackexchange.com/questions/6685/how-to-install-new-atmega-firmware-via-the-isp-pins)). Maybe there is a bootloader, after all?

Palette 2 with an Ender 3 Printer


How can we improve the OpenLayers documentation?

Question: I have difficulty understanding the documentation. Is it just me?  Are there alternative sources of information?
Comment: flagged: rant diguised as question
Comment: edit note: severe editing of a poor question, but the answers thus far are very interesting.
Comment: I'd try: How can we make OpenLayers documentation _even better_?
Comment: **To all**: In light of the preceding comments and the many views and votes the replies have been getting, I have attempted to reformulate the question constructively.  If you agree the question is now tenable (or that the replies deserve to be made visible to all) and have sufficient reputation, you can express your interest with a vote to reopen.  If you don't have the reputation, you can still easily express your view by upvoting the question itself if you like.  (As a mod, I am reluctant to unilaterally reverse a previous action.)
Answer: OpenLayers, as a project, started with a notion of "documentation by example". That is, the primary documentation for many aspects of the code is the almost 200 examples that we make available, with full code to back them. This is typically the first resource to go to for any documentation needs.
After that, we expanded to API documentation. This was an area where we extended later, instead of starting with that as a basis -- this means that it is somewhat less developed, and a bit counter to how most of the OpenLayers developers approach documentation. The API docs are simply less complete because it's not our primary way of communicating about the code.
However, this particular problem is not helped by the fact that JavaScript API documentation for a project like OpenLayers is extremely difficult to make easily available and accessible due to poor tools. The JavaScript language doesn't actually have many of the constructs that OpenLayers uses at its core -- like the class inheritance structure -- as first order objects, which means that they are tacked on, and documentation tools don't have universal support for them. So, the lack of language support or any sane tools to do documentation play a role. (This situation has improved over the years, but it's worth noting that OpenLayers -- and the source of its documentation and tools -- is older than many JavaScript projects that exist today, having started 5.5 years ago.)
In order to cope with poor API documentation tools, and the fact that examples simply don't scale to a project as large as OpenLayers, the prose documentation is intended to fill the gap. For the limited coverage it has, it is generally said that the prose documentation is actually quite good, and I'd be surprised if you're saying that this is what sucks. Instead, the problem is that the coverage is quite low -- and the reason for that is simply that limited time on OpenLayers is invested on new features, not on documentation.
While you can argue the approach that OpenLayers uses -- whether it be documentation-by-example, or documentation taking a back seat to actual development -- both of these tend to be simply differences of opinion on what is more important.
Lastly, there are several significant contributors to the OpenLayers project who work primarily on funded projects from contract development. Both of these teams have made offers to groups to accept funding for development of documentation. Most features in OpenLayers are developed this way, but documentation has not been successfully developed this way, due to lack of appropriate funding. In short, it seems that no matter how much people dislike the documentation, they don't want to pony up the resources to improve it.
Comment: Roughly speaking, how much funding would be required to resolve the documentation issues?
Answer: Well you could argue that its both you and the documentation. Since I only know the documentation, I'll prefer to discuss that :)
In my opinion the documentation doesn't give enough information. Thus I read the documentation and browse through the source code alongside to give me a better picture of how things are working.
Though the documentation could be more thorough, a lot of examples are available and google gives you even more.
And if eventually that is not enough, you can use this forum or even stackoverflow to get answers from some of the most experienced people.
The OpenLayers guys maintain a mailing list, though I think this forum is much more usable than browsing through lots of mails :)
So, if you have any questions, just ask here - but I would suggest that you phrase your questions a bit more positive ;)
Comment: I know, I subscribe :) But I prefer the way SO categorises and visualises questions and answers. The amount of mails indeed supports your statement, but its like a stack of unsorted papers - very difficult to grasp. I think it would be great and much more useful to have the system SO uses instead of the mailing list - but thats my personal opinion.
Comment: Maybe you could persuade some of the those mailing list members to become active here, Chau :-).
Comment: For the record, very few OpenLayers developers use stackoverflow compared to the number of users and developers who are available on the mailing list. In general, I see the same dozen people on Stack overflow -- but the OpenLayers mailing lists have more than 1000 people signed up to them. So, SO isn't always your best option to get correct answers quickly.
Comment: I think that persuasion should come from the knowledged ones answering their mailing list questions. If they don't want to use this forum and thus refer people here, why should the askers go here? Then my personal preference doesn't matter ;)
Answer: I'm not sure where your abilities are, but Packt Publishing has a book.  I've never used it and haven't read reviews on it, but it may be worth purchasing.  The E-Book is the cheaper option.


Difference between least squares and chi-squared

Question: What is the difference between least squares and reduced chi-squared?
For me they look nearly exactly the same, with the difference, that in chi-squared everything is divided by the variance. But despite from that, they are both identical?
Comment: Check out [this lecture](https://www.asc.ohio-state.edu/gan.1/teaching/spring04/Chapter6.pdf); the direct answer to your question is on slide 5. In short: $\chi^2$ if $y$ are from a Gaussian distribution, if not – it's least squares (because then the resulting distribution is not $\chi^2$).
Comment: Why the downvote? Seems a perfectly valid question to me.
Comment: @corey979 Do I understand it right, that they use least squares to minimize chi-squared? I'm now even more confused as they also involve MLE there in the same context..
Answer: $R^2$ is used in order to understand the amount of variability in the data that is explained by your model. A $R^2$ of $90\%$ means that the $90\%$ of the variance of the data is explained by the model, that is a good value. On practice you cannot rely only on the $R^2$, but is a type of measure that you can find.
The Chi-Square goodness of feat instead determines if your data matches a population, is a test in order to understand what kind of distribution follow your data.
Instead, the Chi Square statistic is commonly used for testing relationships between categorical variables.
There are other posts in this forum that explain this difference, and there are many sites that explain these two variable.


How does a transmitter re-modules a wave radio to get more distant devices?

Question: I was told that a WiFi AP re-modulates its radio signal in order to enable it to better go through obstacles and noisy places, reaching more distant client's transceivers this way. Basically, the receiver tells the transmitter to slow down to get the data more clearly. As a result the data rate slows down too. what exactly of a radio wave is re-modulated? Frequency, amplitude, or what? Could anyone also graphically represent a radio wave before it gets remodulated and after, when it carries less data?
Comment: Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer.
Answer: I think you are talking about beamforming - it's not about modulating the signal itself but controlling the phases transmitted by the different parts of the antenna array. Ideally, the different phases add up to a maximum in the exact position of the receiver.
Another method for the radio to achieve a greater effective distance is to lower the transmission rate, so that even a weak signal is still decipherable. The slower rate may also use another modulation method but not necessarily.
Most 802.11 modes use quadrature amplitude modulation (QAM) which can get quite complex when modelled in practice.
Comment: "to achieve a greater effective distance is to lower the transmission rate". But lowering the transmission rate is still transmit data over the same radio wave with the same features? Just less data on the same wave?
Comment: Signal amplitude drops with distance squared plus attenuation by obstacles. Lower amplitude means lower signal-to-noise ratio. Lower SNR means you can only get a lower data rate across.


Running python within flash actionscript (AS2 preferably)

Question: Suppose I have a python script, say my_script.py. Now in flash actionscript(version 2), I want to run this script. For example, when a certain button is clicked, a certain function in my_script.py is executed (i.e the parameters are entered into the function via input text box or some other input method, and the variable returned by the function is stored in some other variable within flash actionscript). For example, say in the python script we have a function add(p, q)

def add(p, q):
<code>   return p+q
</code>

and I want to import this code into action script, and there write a code which enters the parameters p an q to that function, and another variable (say sum) stores the value of add(p, q).

//Code to import the function
//sum= add(a, b)

I know this question is a bit vague, but it is the best way I could put it. I don't know whether it is possible either. I would be gratified if someone helps.
Answer:
You can prefer this web link about how to use python + Actionscript...
[PyAMF - AMF for Python][1]
[1]: http://www.pyamf.org/tutorials/actionscript/simple.html


Skyscraper sheaves cohomology

Question: Let $X$ be a topological space and $G$ an abelian group. Denote by $\mathcal{S}$ the skyscraper sheaf with  group $G$ at the point $x\in X$. How I can prove that $\mathcal{S}$ has not cohomology, i.e $H^i(X,\mathcal{S})=0, \: \forall i>0$ ?
Comment: Do you assume $G$ is an abelian group?
Comment: Yes! -:) ${}{}{}$
Comment: There is also a cheaper way for showing this : you can build a discrete partition of unity adapted to your sheaf. This is done in the book of Miranda, Algebraic curves and Riemann surfaces.
Comment: Yes. Thanks fo the remark :)
Comment: Can I have a moment to understand the answers?
Answer: A skyscraper sheaf is flasque, hence  has no cohomology: Hartshorne Chap. III, Prop.2.5, page 208.
Answer: You can also see this using Čech cohomology:
Consider an open cover $\mathfrak{U}=(U_i)_{i\in I}$ of your space $X$. You can always refine this cover so that only one of the sets $U_i$ contains the point $x$: Pick a set $U_0$ containing $x$ and consider the cover $\mathfrak{U}'$ consisting of $U_0$ and $U_i\setminus\{x\}$ for all $i\in I$. Then $\mathfrak{U}'$ is a refinement of $\mathfrak{U}$ and $x$ is only contained in the set $U_0$.
In particular, $x$ is not contained in any intersection of two or more distinct sets in $\mathfrak{U}'$, so the scyscraper sheaf has no sections over these. Hence all higher Čech-cocylces are $0$ and all higher cohomology groups vanish.
(I believe this approach can also be found in Forster's book on Riemann Surfaces.)
Comment: Dear @IvanSo, the question as asked was in the setting of topological spaces, where there is no notion of affine. If you are in the situation of, say, schemes, then you may mimic this approach by starting with an affine cover (which exists by definition of a scheme) and refine this as described, noting that intersections and open subsets of affines remain affine.
Comment: But I suppose affine intersect affine is affine is only true for X being seperated (hausdorff)?
Comment: I got a regarding the equivalence of Cech cohomology and the normal cohomology group H^i. In Hartshorne III 4.5, it said the two cohomology are equivalent only if we assume the open covering used for the Cech consideration is affine.
How can you guarantee your specially chosen open covering to be affine?
(if I am considering from the algebraic geometry perspective)
Comment: @IvanSo You are right, there are subtleties involved. One should probably require Noetherian schemes, as Hartshorne does (if I am not mistaken). Maybe qcqs is enough, though...
Answer: These notes probably have enough detail to give you what you want. I'll assume you mean $G$ to be an abelian group. Basically the argument goes like this: if $G$ is an abelian group, take an injective resolution $G \to I^\bullet$ of abelian groups. Then $\pi_*G \to \pi_*I^\bullet$ is an injective resolution, where $\pi:{\ast} \to X$ is the inclusion of a point. Note that $\pi_*G$ is your skyscraper sheaf. To compute $H^i(X,G)$ take global sections of $\pi_*G \to \pi_*I^\bullet$, which just gives back the resolution $G\to I^\bullet$, which shows that the higher cohomology of $\pi_*G$ vanishes.
Comment: The link is not working. Do you have a new link for the notes?

Skyscraper sheaves cohomology


Multi-class classification but a single feature sometimes boils it down to a binary-classification

Question: I have a three-class classification problem for a large dataset. Classes are 0, 1, and 2. There's a categorical variable in my feature vectors such that when a sample point has this variable positive, it can only belong to either class 1 or class 2. On the other hand, if that categorical variable is negative for another sample point, then this sample can be from all three classes. I was wondering how I can make a neural network use that information during training? I guess I need a custom loss function however I could not figure out how to exactly create that.
Answer: I think a custom loss function would be an overkill in this situation. A linear pattern like this would be easily learned by any loss desinged for multi class classification.
If I were you I would try 3 roads, in this order:

train a classifier based on decision trees (random forest & xgboost in primis). The rule you described would most likely be learned as first split to perform, if the remaining features are easily separable then such classifier would perform better than a neural network, plus it would be interpretable.
train a neural network without any fancy loss function, again the rule you describe is linear and really simple, no reason to think any loss function would miss it. BUT, if you have specific reasons to think that or if you want to try to get the best of the best out of your data there is still another possibility.
train an ensambled model. More precisely, split the data yourself into 2 subsets, one with positive feature "x" and one with negative feature x, and train 2 separate models on each subset of training data. It is reasonable to think that the model trained on the subset associated with positive feature x would perform better, since the problem will turn from multi class classification to binary classification, but with pros comes cons as well, specifically higher risk of over fitting or class unbalance depending on the stats of your overall dataset.


In Haxe hxml file, how to target main class not in the root package

Question: I'm trying to compile a project where the main entry point isn't in the root package (which virtually all examples use, e.g. -main Main), but I keep getting this error message:
Error: Invalid commandline class : rtp.qt.QTPrinter should be QTPrinter

Here are the various syntaxes that should work:
-cp src
-main rtp.qt.QTPrinter

Or:
-cp src
-main rtp/qt/QTPrinter.hx

Answer: It turns out, those syntaxes are both fine. I had just moved the QTPrinter.hx file from src/ to src/rtp/qt/ directory and I forgot to update the package statement at the top of the file (hence the invalid commandline class error.)
In my src/rtp/qt/QTPrinter.hx file, fix the package statement:
package rtp.qt;

I'm posting this mistake in hopes it helps someone. Cheers!
Comment: I literally made the same mistake (with a different file) just yesterday - happens to the best of us!


I can no longer receive service medals

Question: I had these services medals unlocked: The shirt, the big spender and the recruiting officer. They just disappeared. What happened? How do I get them back?  Also during the last update I lost about 200,000 coins and 60 bux.  Any idea how to get these back?
Answer: The service medals was for a limited time period (10 days) and they are no longer available to collect.
Can't help with the bux/coins problem.
Answer: Nothing you can do about the medals as mhazeltine said, but for the missing coins and bux then email the developer ( email@example.com ) and describe to them the problem and they should be able to help you on it.

I can no longer receive service medals


Prevent usb HDD Sleep mode?

Question: I'm having a problem with my computer running Ubuntu server 12.04, I have an external USB HDD plugged in for samba file sharing but after a few hours not using samba the USB HDD goes to sleep. When I try to use my samba share again I en up with an Input-Output error. How could I prevent the HDD from going into sleep (always spinning)?
PS: I mount my HDD to a folder in /media/ at every boot using fstab
Any help would be appreciated.
Answer: hdparm -B255 /dev/sdX will help as this disables the spindown.

Prevent usb HDD Sleep mode?


Light and the electromagnetic spectrum

Question: We say that light has magnetic and electric fields ossilating perpendicular to each other.What causes the those fields to exist and why does the light as a whole does not get affected in the presence of other charges or magnetic fields.
Comment: If you consider molecular bonds to be EM fields, then light *is* affected.  It can be absorbed, reflected, and/or refracted.  Also, external EM fields can affect molecular bonds.
Answer: The electromagnetic fields are generated by the motion of an oscillating charge (for example, electrons in an antenna for RF - radio frequency - waves; or electrons bound to an atom for light). The relationship between the oscillating charge and the fields are given by Maxwell's equations.
Because these fields are oscillating, there is no net influence on them if you put them in the presence of another (DC) field. In principle it is possible for photons to interact at sufficiently high energies (see two-photon interaction) - this proves that it is just about possible for an electromagnetic wave (photon) to interact with another. But that's well beyond the level of your question.

Light and the electromagnetic spectrum


Disposing of custom Data Access Layer references

Question: Our application uses a custom DataAccessLayer class almost exclusively, and within that we do use Data Access Application Block (currently version 2).  We are getting the infamous "GetOrdinal" error sporadically.  We are not using out-of-method connections.  We are using DAAB version 2.  Below is a typical example of our DAL methods:
Public Function MyDALMethod(ByVal Param1 As Integer, ByVal Param2 As Integer) As System.Data.IDataReader

        Dim db As Database = DatabaseFactory.CreateDatabase()
        Dim sqlCommand As String = "usp_MyProcedure"
        Dim dbCommand As DbCommand = db.GetStoredProcCommand(sqlCommand)
        db.AddInParameter(dbCommand, "Param1", DbType.Int32, MyParam1)
        db.AddInParameter(dbCommand, "Param2", DbType.Int32, MyParam2)

        Return db.ExecuteReader(dbCommand)

End Function

In our code we just instantiate a DAL var and call the desired method.  After using the DataReader, the referencing code will close, dispose, and set the reader to nothing.  However, nothing is done with the reference to the DAL.  I've wondered if this is part of our problem.   A typical method would use our DAL like this:
Dim DAL as New DataAccessLayer
Dim dbReader as system.data.idatareader

dbreader = DAL.MyDALMethod(parm1, parm2)

While dbreader.read
    i = dbreader.items("column1")
    j = dbreader.items("column2")
End While

dbreader.close()
dbreader.dispose()
dbreader = nothing

My main question is should these DAL references be disposed somehow?  It's a custom class written in VB.NET, so it doesn't implement IDisposable so I'm not sure if there's anything to be done or not, but we do have errors and issues (like the GetOrdinal problem) which seem to be load-related, and I'm wondering if this is part of the problem.
Answer: If the DAL holds at least one member variable that is Disposable (implements IDisposable), then it too should implement IDisposable.  This would then indicate to DAL's client that Dispose() should be called.  The DAL's Dispose() would then call the member variable(s) Dispose().
That is the general guidance for implementing IDisposable.
BTW - there is no need to dbreader = nothing - it achieves nothing.  See Eric Lippert's post


If unstated, do literary magazines generally publish work submitted by minors?

Question: Unless a literary magazine/journal is looking for work from a certain age range (ex. the teen experience, 20 to 30-year-olds), I rarely see age restrictions under submission guidelines. If unspecified, is it safe to assume that most literary magazines/journals publish will work submitted by minors? I understand that competition is steeper for young writers, but I am asking this question from a legal/technical standpoint as opposed to a competitive one. Additionally, if unstated, do literary magazines generally accept international submissions, or are submissions often limited to their regional area (ex. only residents of the United States)? As a novice writer, any information on this would be extremely appreciated!
Comment: Welcome to Writing.SE! We have quite a few questions about publishing at a young age - see [this one](https://writing.stackexchange.com/q/18591/23927) and its [many, many duplicates](https://writing.stackexchange.com/questions/linked/18591?lq=1).
Comment: When you write your bio, you can include "studying creative writing at X High School" or whatever is appropriate. Check into any colleges in your area to see if they have a literary magazine. Feel free to expand your "region". Chris has a good point about payment, but most literary magazines, especially small ones, don't pay. Good luck!
Answer: Neither age nor geographic origin are typical considerations when submitting work. Unless you specify them when querying or submitting, they won't even know (unless your email address and/or postal return address give it away), and you usually wouldn't specify unless it makes a difference to your writing, or supports your qualifications to write a specific piece.
When it comes to getting paid, however, it's a different story. I'm no lawyer, but I believe a parent would have to sign the contracts for a minor. And getting paid internationally is always difficult.
It's worth noting that the competition for inclusion in well-known literary magazines is incredibly fierce (even for adult writing professionals in the same corner of the world!). You might have better luck starting out by publishing in a local magazine, and/or one aimed at youth, and then building your way up to larger, more international publications. Better a successful publication in a small local magazine than any number of rejections from Granta.
Comment: Thank you for your answer! My age and geographic location were actually details I'd planned to put in my cover letter since Submittable asks for a 'short bio', but are these details I shouldn't include since they do not support my qualifications? I appreciate your tips, too! Unfortunately, I live in a pretty small peninsula where literary magazines and competitions are next to none. I have been trying to find some magazines aimed at youth, but those are often restricted to geographic origins.  Still searching though!


Reattach Toilet Seat Pin Inside the Hinge

Question: The pin inside the toilet seat hinge came out (this is NOT the bolt that attaches the seat to the toilet). The pin screws into the lid and then I can slide it through the flange (piece that bolts to the toilet) and then through the seat. However, I can only do it on one side because you have to screw it in first on that side and then slide everything on. There is no way to get everything on, on the otherside and still be able to tighten the pin. If I tighten the pin on the otherside first then I can't slide it though the hinge and seat. There is no way to screw the pin in once it's assembled as the end of the pin is just flat. Do I have to just buy a whole new seat?
Comment: Have you tried removing the pin, lining up everything and then installing the pin from the right side and tapping it into place with a hammer?
Comment: The two outer pieces look different to each other, are they?  Does the pin have a slot cut into the smooth end?
Comment: (a) I'm wondering how it was assembled. Do the pins look like they might have been sheared off at the ends? Is there a cap in the part by the base of the thumb in the photo for access that way? (b) If you had a dremel-type tool, you could cut a slot in the plain ends.
Comment: Cut a slot for a small screw driver on the non-threaded end, using hacksaw. Then you can take a small screw driver and screw it in.
Answer: That is not a screw-in pin.

It is just roughened on one end to keep it from sliding out.
Insert from center part, and gently knock it in with hammer.
You can fill the lid hole part with some caulk (before inserting the pin), to prevent it to slide out again.
Answer: Copied from my comment after checking my toilet seat. Try removing the pin, lining up everything and then installing the pin from the right side and tapping it into place with a hammer?
Comment: Great minds think alike


Conversion of VS 2010 project to VS 2008

Question: I downloaded some sample ASP .NET projects from net. But they are in VS2010 format. I use VS 2008. How can I change the format?
Comment: unwise, I would say, at best.
Comment: are the sample projects dotnet 4? if so then they cannot be run outside of vs2010
Comment: Can u tell me a place to find good source codes of VS2008 for beginners?
Answer: If you take a 2008 project and migrate it to 2010, only the .csproj, .vbproj, .sln files etc will actually change. So in theory you could try to edit these back to 2008 values. However, the actual code in the samples may be aimed at a different version of the .NET Framework than you have.
I would recommend creating a new ASP.NET project in VS 2008, then using Add, Add Existing Item to add the pages, config files etc from the samples into your project. Then edit them to fix any issues with using functionaliy you don't have.
Or better still, go find some samples for the version of VS and the version of the .NET Framework that you are actually using.
Answer: You can try to create a brand new solution and create new projects from the existing source (File | New | Project From Existing Code).  However, if they're using any .Net 4.0 features (or certain C# 4.0 features like dynamic) then you'll be out of luck.


What could be the possible reason for Windows removing Password protection for zipped folders?

Question: I remember in Windows XP, you could set a password to a zipped compressed folder. But in newer Windows OS, the option is not available. Is there any reference which tells why would they remove this feature?
Answer: Windows only supports ZipCrypto natively. As ZipCrypto is vulnerable to known-plaintext attacks that could easily be exploited e.g. with bkcrack, it should never be used. I don't think it's clearly told anywhere, but I can guess the feature was silently removed (since Windows Vista), because it gave false sense of security. However, probably because of the strong backwards compatibility, even Windows 10 can still decrypt those ZipCrypto ZIP files.
7-Zip, WinZip, WinRAR etc. support AES-256 encrypted ZIP-files. The encryption is stronger, but...

It only encrypts the file contents, not their names. You can circumvent this by first compressing the files into a ZIP and then putting that ZIP into another, AES-256 encrypted ZIP.
It's not compatible with the native ZIP support in Windows. If you use it, the receiver must have a third party program with the support, too.
Answer: The option to encrypt the zip files is still there, but Microsoft has done changes to the mechanism - how to do it and the way it works. Now, you would have to zip the file and then right click > Properties> Advanced Attributes > Encrypt contents to secure data > Apply to folders and sub-folders. As long as you're logged into your Microsoft account, you will be able to open/extract the contents and other users will not. However, this is not suited for sending as encrypted zip.
I do not know why they'd do something like that, but if I can recommend a great tool for compression/decompression and password protection, I'd like to recommend 7zip: it's a very powerful FOSS tool.
-Cheers
Comment: That is something else entirely: EFS, an NTFS feature to encrypt files.


Number of 4-digit numbers having different digits.

Question: How many four-digit positive integers are there such that all digits are different?
Comment: @Shepard I can tell you're busy playing Mass Effects ... but at least can you show some of your work? or whatever you have attempted? that way people would be more likely, and willing to help you
Comment: We should play and talk about math at the same time!
Answer: For a valid $4$-digit number, the Highest Significant digit will be among $1\cdots9$ so can have $9$ values
From the next onwards, they can assume $0\cdots 9$ excluding the ones already selected
So, the number of combinations will be $$9\cdot9\cdot8\cdot7$$
Answer: Hint:
The first digit can be any number from $1$ to $9$. The next three digits can be any number from $0$ to $9$. If we choose each digit one at a time and stipulate that each digit is different from the previous choices, how many choices do we have for each digit? Multiply these together to get your answer.
Answer: Allowing for a zero first digit
10 * 9 * 8 * 7
10 possible options for the first digit, 9 remaining options for the second digit, 8 remaining options for the third digit ...
Comment: allowing for a zero first digit would make it a **3-digit number**


AMD R9 290 600watt enough?

Question: I have got an AMD R9 290, with a 600 watt power supply(Coolermaster GX 600 watt).
Now, when i am playing a game everything works fine, but when i am trying to mine bitcoins, my system crashes(no signal hdmi, all fans got to 100%).
I have got an I5 3570, and I have nothing overclocked(windows 8.1)
Is it possible that my video cart is asking more power then my power supply can give it?
Comment: I'm not into bitcoin mining but can say, as someone that's built computers for years, 600 watt is fine for a single R9 290 as it only uses 300 watts of power. So your rig should be fine. You'll need someone with bitcoin mining experience to chip in and offer help. Might wanna change title/tags to get one to look.
Answer: Is the power supply the GX-Lite 600W? Unless it's faulty it should be fine, since it should deliver 540W on the 12V rail.
While the R9 290's official TDP is 250W, reviews are placing it unofficially at 300W. Still, the PSU should cover that.
So yes, it could be the power supply, but only if it isn't functioning properly. Likewise, it could be some other part or even a software-related issue. Without some more info (errors logs or something), or testing by trying alternate hardware, it's difficult to say more.
Comment: Beat me to it! Good point about the dodgy software possibility.
Answer: From the system requirements from several different manufacturers, it looks like you could need anywhere from a 600W up to 750W power supply for this card.
The ASUS product page suggests that the card will use 300W of power, which is obviously 50% of your total power available. I would guess that while gaming is fine if it's not completely stressing the card 100% of the time, mining Bitcoins is going to draw too much power and result in crashes like you are experiences.

AMD R9 290 600watt enough?


Interpreting Japanese sentences from right to left or left to right

Question: Are Japanese sentences (horizontal) to be read/interpreted from left to right or right to left?  For e.g: the word "Inshoku" when read from left to right, means Drink and food, but the translation read "Food and Drink".
Comment: You ask about _sentences_ but use a _word_ as an example. Words are tricky because they can use either Chinese order (left to right) or Japanese order (right to left). And your example is special because it has an arbitrary order (just like 'drink and food' and 'food and drink' would have the same meaning, if not the same frequency of use).
Answer:
The translation will not always follow the thought-order of the original word
飲食{いんしょく} is not two words in Japanese, it is one word(熟語{じゅくご})
As a phrase in English, "Food and Drink" is more commonly used than "Drink and Food"
Horizontal Japanese can be read either from left-to-right (as in English) or right-to-left, depending on context
When horizontal Japanese is read right-to-left it is actually being written as top-to-bottom, right-to-left (each top-to-bottom line has just a single character at the top) - This functions like a bold title and is most often seen in scrolls or in temple decorations

You can type 扁額 into Google to see many examples of this type of decoration.


converter software for fortran 77 to fortran 90

Question: i have coding for fortran 77 but i want to converted to fortran 90..where can i donwload the converter software??
Comment: What are you going to do with it once converted?  Code converters typically produce code that works but is hard to work with.
Answer: Here is a python solution that I helped write: https://github.com/arktools/fortran_tools
It successfully converted the entire airforce f77 datcom code to f90, so it is well tested. I will be adding some more features as I have time.
If anyone finds it useful/ and makes modifications, feel free to contribute to the project.
Answer: The first hit on a Google query for "fortran 77 convert 90" returned this page, which has 3 free tools and 2 commercial ones listed (after clicking the link for "Subprograms, Converters, Key Works").  I've not used Fortran in quite a while, and can't vouch for the quality of any of these tools.
Answer: I'd recommend Lemon Lab f2f. I'm a bit biased, since I was the original developer, but my motivation was due to the fact that I didn't think the alternatives worked very well. Give it a try if you like.
Comment: Works well for my simple purposes (which include avoiding using fortran whenever possible).
Comment: Sadly this is a deal link now.
Comment: https://github.com/MRedies/f2f_mirror
Answer: The free program convert (http://www.nag.co.uk/nagware/Examples/convert.f90) will convert from Fortran 77 fixed-source form to Fortran 90/95/2003 free-source form and make some simple transformations, such as declarations.   There are also some commercial products, such as SPAG (http://www.polyhedron.com/spag0html).
Comment: The two links are broken
Comment: Thanks! The first URL seems to go directly to http://www.nag.co.uk/. Do you have an updated URL for the program? Or do you have any recommended program convert from Fortran 90 to Fortran 77?
Answer: I have found and used three programs convert.f90 (Michael Metcalf), preconvert.f90 (Purple Sage Computing Solutions, Inc.) and to_f90.f90 (Alan Miller).
None of them worked 100% like I expected. Results depends on how closely your source matches what the programs expect to see.
For your convenience I have zipped the source files up and hosted them here:
Source Files
I have used Compaq Visual Fortran 6.5 to compile into three separate projects. If you want the projects also use this link
CVF 6.5 Projects
Best of luck.
Comment: I wonder why I got a downvote without a comment?


A vector of complex numbers as a linear combination

Question: Is it possible to state a vector of complex numbers as a linear combination of a real numbers vector (Re(z)) and a another real numbers vector (Im(z)) multiplied by i?
Answer: Yes, for example, $$(83+42i,96-15i)=(83,96)+i(42,-15)$$
Answer: Every element in $\mathbb{R}^n $ can be written as a linear combination of the basis vectors $(e_i)_{i=1}^n$, where $e_i=(0.\ldots,0,1,0,\ldots,0)$ where $1$ is at the $i$th position. Now for any $z\in\mathbb{C}^n$ we have $z=x+iy$ where $x,y\in\mathbb{R}^n$ and each of the $x$ and $y$ can be expressed as a linear combination of $e_i$'s.


Maximum Duration for dual boot (8.1 and 14.04)

Question: I have just bought a Lenovo i7 Laptop with 500 GB hard I have installed Windows 8.1 on Partition#1 of 360 GB and the remaining 95 GB is Empty I want to install Ubuntu 14.04. how long will it operate successfully and is 95 GB good to go (if I install latest java IDE).
And what if I format Partition#1 after installing 14.04 will Ubuntu stay there with out any affect.
Answer:
how long will it operate successfully

Well.. technically Ubuntu 14.04 will be supported until April 2019. So if you do not mess it up yourself you can stick with 14.04 for a few years ;)

and is 95 GB good to go

More than enough. You can run Ubuntu comfortably with 25Gb. The Ubuntu base system itself needs about 10Gb to work without running out of space.

if I install latest java IDE

That is not going to cost you Gb's so you should be fine.

And what if I format Partition#1 after installing 14.04 will Ubuntu stay there with out any affect.

Yes. If Ubuntu is installed elsewhere (ie. not on P#1) it will remain there.  1 thing though: if you delete the bootmanager (grub) you will need to re-install it for it to show all the operating systems again.
Comment: and if I have to format the partition#2 having ubuntu will windows stay there ?
Comment: Yes. Same rules apply: if there is 1 operating system the bootmanager will disappear. So if you need both you also need a bootmanager (Ubuntu will install GRUB for you). 1 possible problem: Ubuntu is not always told during partitioning that there is a W8 partition and sees that partition as "free". So I would install using the "something else" option and by picking the correct disk manually and not use the automatic installation options.


Proper transformation file to go from NAD83 CSRS UTM 17 to NAD83 UTM 17

Question: Looking to determine which transformation file to select when using the Project tool in ArcMap 10.2.2 to go from NAD83 CSRS UTM 17 and NAD 83 UTM 17.  The data I am working with is from Geogratis and will be projected to suit Ontario standards (NAD83 UTM 17).
Answer: Esri software does not have a built-in transformation to convert between NAD 1983 and NAD 1983 CSRS in Ontario.
The Ontario Ministry of Natural Resources and Forestry provides an NTv2 file to convert between NAD 1983 (original) and NAD 1983 CSRS. You can download it from COSINE. You have to apply, but it's not onerous, and the NTv2 files are free to download.
Once you have the .gsb flie, you should place it in your ArcGIS for Desktop install location in the pedata\ntv2\Canada folder. Next, use the Create Custom Geographic Transformation Tool to define a new transformation that uses it. In the tool, select the appropriate source and target geographic CRS, method is NTv2, and use the Canada\filename for the parameter.
Comment: Thanks kindly for posting this, I couldn't understand why there wasn't an Ontario-specific transformation available through ArcGIS.


Taxonomy terms with a scale?

Question: Not quite sure how I should even google this. I've got a Content Type "Trips", the image shows what I want to see in my trips node page. Adventurus, relaxing, educational etc are my taxonomy term categories. It seems to me like each taxonomy term should have a scale of 0-5. Which is the better way to achieve this? Any module around? (using drupal 7)
Comment: Sounds like a combination of taxonomy and the https://drupal.org/project/fivestar module
Comment: Thanks alot, that's a nice solution and as far as I can see it's easy to customize the graphics.
Answer: I used Star Rating module. Exactly what I was looking for. In contrast with Fivestar module, it is intended for rating only by the author of the node. Plus no dependencies.
[Thanks to @jimajamma]
Answer: In drupal 7, you can add fields to taxonomies. Use the following steps:

Install the star rating formatter mentioned by @Nim, then configure
Can two posts have a different # of categories?

If so, I suggest you add such a single star rating formatter field to the desired taxonomy (http://example.com/admin/structure/taxonomy//fields). Make sure the field and the taxonomy are multi-valued.
If not, consider adding three separate taxonomy fields.

Amnon

Taxonomy terms with a scale?


What's the name of this sound/collection of sounds?

Question: What is it called when one expresses "Yes", "No", or "I Don't Know" without using words - just humming their response?  You know, when someone responds with a low note than a high note for Yes or "Ah-huh!"; a low note and a slightly lower note for No or "Nuh-uh"; or a low note, a high note, and a low note for I don't know.
Answer: In a sentence, it's often called a grunt or murmur of assent.
A related question is How to describe making sounds with your throat?
Answer: I believe the word falls into the category of paralanguage.
http://www.dictionary.com/browse/paralanguage
Answer: Wikipedia describes 'Vocables' as "utterances which are not considered words."

vocable n.
A syllable or sound without lexical or referential meaning, vocalized as part of a song or sung melody.
  - OED Definition 2
Comment: This would be an excellent answer - well explained, and links to references - but the only problem is that the OP didn't ask about *all* non-word utterances, they specified "humming", i.e. mm-mmm.
Comment: @Chappo I interpreted the question to include all non-word utterances, as some of the given examples ("Ah-huh," and "Nuh-uh") are not humming.
Comment: interesting vocable-related questions: https://ell.stackexchange.com/q/221341/ https://linguistics.stackexchange.com/q/26175/ https://music.stackexchange.com/q/42995/


Skoda Octavia 5e 2016 184hp losing motor oil

Question: Hello guys I have Skoda Octavia 5e 2016 kombi since 2020 February bought it at 125.000 and at start I didn't lose any oil Every 10.000 I change my oil and in 2021 I had one issue what my mechanic told me at 150.000 the seals of top motor place I don't know what's called but it was worn off and the oil leaked in timing belt and I needed to change that and the seals on top of the motor done it and it seemed ok
then now 1 year later I put on 10.000 km additional 1 liter of 5w30 oil because I lose oil now but I don't think it's normal because on normal drive max speed 100 kmh I don't lose anything still but when I do a kickdown or little bit aggressive drive I get a warn lamp to add more oil often then is something off should I check air intake or ? No leaks on motor or under,spark plugs I changed 1 week ago and there was no oil on them or smth else ...does it has inpact when the oil is hot? I mean I don't know if that's normal but normal drive my motor oil is always between 90/105 Celsius but when I drive 140kmh on autobahn it comes to almost 115celsius..
I didn't had this issue before and I don't know if it's normal because I didn't had this before .. now it has 175.000 km and motor type is CUNA and I am scared if it is pistons or some bigger damage to stop it before it's to late I am sorry for bad English and long text I am thankful for any advice ..
EDIT
I have 2.0 diesel motor I forgot to mention that and I have a different question is it normal that the 2.0 diesel motor never sounds same ?
Or ?
This drives me crazy sometimes it sounds almost like a 2000 tractor and sometimes u can't almost hear nothing besides nice noice but sometimes I hear some clicks but local mechanic told me that's normal for those motors ?
Answer: Please see this link for possible causes.


Convert VB.NET event with multiple event arguments to C#

Question: I'm in the process of transplanting a unit test written in VB.NET to the larger project written in C#. However, this little ditty has me looking for help:
Public Sub object_DataChange(ByVal TransactionID As Integer, _
                             ByVal NumItems As Integer, _
                             ByRef ClientHandles As System.Array, _
                             ByRef ItemValues As System.Array, _
                             ByRef Qualities As System.Array, _
                             ByRef TimeStamps As System.Array) _
                             Handles myObject.DataChange

    '' Does event code here
End Sub

What is the best way to convert this event? Also, is this a good instance to use EventHandler<> to consolidate my arguments into a structure?
Comment: Just a tip. If I'm not mistaken SharpDevelop has a feature to convert VB.net to C# code. So if you have a lot of code to convert, that might be worth checking out.
Answer: In this case, you're actually demonstrating an event handler vs. an event. C# does not have the Handles clause notion that VB.NET has. Instead you must manually assign an event handler to an event like so:
myObject.DataChange += this.object_DataChange;

And correspondingly, when you're done with the event you should remove the handler like so:
myObject.DataChange -= this.object_DataChange;

The actual event handler can be translated as follows.
void object_DataChange(
    int TransactionID,
    int NumItems,
    ref System.Array ClientHandles,
    ref System.Array ItemValues,
    ref System.Array Quantities,
    ref System.Array TimeStamps) {
    ...
}


Is this matrix always orthogonal?

Question: I was reading about orthogonal matricies and noticed that the $2 \times 2$ matrix
$$\begin{pmatrix} \cos(\theta) & \sin(\theta) \\ -\sin(\theta) & \cos(\theta) \end{pmatrix} $$
is orthogonal for every value of $\theta$ and that every $2\times 2$ orthogonal matrix can be expressed in this form. I then wondered if this can be generalized to any smooth paramtrization of the unit circle. More precisely, let $x(t)$ and $y(t)$ be a smooth parametrization of the unit circle for all $t$ in some interval $I \subseteq \Bbb R$ such that $|\langle x(t),y(t) \rangle| = 1$ for all $t \in I$. Is the matrix
$$A= \begin{pmatrix}x(t)&y(t)\\x'(t) & y'(t) \end{pmatrix} $$
necessarily orthogonal?
At first I thought yes, but I'm having trouble proving it. Letting $v = \langle x(t), y(t) \rangle$, it suffices to show three things: 1) $|v| = 1$, 2) $v \cdot v' = 0$, and 3) $|v'| = 1$. (1) follows straight from how $x(t)$ and $y(t)$ were defined. (2) can be obtained by differentiating the equation $x(t)^2 + y(t)^2 = 1$:
\begin{align*}
&\frac{d}{dt} \Big[ x(t)^2 + y(t)^2 \Big]= 0 \\
&\implies 2x(t)x'(t) + 2y(t)y'(t)= 0 \\
&\implies v \cdot v' = 0.
\end{align*}
But I couldn't find a way to prove (3). Now I am unsure whether (3) is true at all. Is $A$ even orthogonal in the first place? Any hints would be much appreciated.
Comment: For the sine/cosine case that matrix is orthogonal since it is the wronskian matrix of the DE $$y''+y=0$$, but in general two functions $x(t),y(t)$ are not two independent solutions of the same differential equation.
Comment: In fact, the matrix defined by $x(t) = 1, y(t) = 0$ is not even nondegenerate.
Answer: First, not every orthogonal matrix is of the stated form, only rotation matrices. There are orthogonal reflection matrices, with determinant $-1$:
$$
\left[
\begin{array}{@{}rr@{}}
\cos\theta &  \sin\theta \\
\sin\theta & -\cos\theta
\end{array}\right].
$$
Second, your conjecture is not true: Only unit speed parametrizations have the stated property, because the rows of an orthogonal matrix form an orthonormal set (in the obvious sense), and particularly must be unit vectors.
Answer: The third point implies that the parametrization goes over the circle at a constant speed $1$, which is, of course, false in general.
Take for example $v(t)=\langle \sin t^2,\cos t^2\rangle $ for $t\in[0,\sqrt{2\pi})$.
Answer: In general, (3) is not true. Since $\left\vert v \right\vert^2 = x(t)^2 + y(t)^2 = 1$ , we can write $$x(t) = \cos \theta(t), \quad y(t) = \sin \theta(t)$$
for some function $\theta(t)$. But computing gives $\left\vert\dot v\right\vert^2 = \dot\theta(t)^2$, so the condition $|\dot v|^2 = 1$ (which just says that $v$ is a unit speed parameterization) forces $\dot\theta(t) = \pm 1$, and this condition yields just the matrices of the given form (the rotations). Note that a composition of any rotation with a reflection is another reflection and hence orthogonal, but these reflections cannot be of the form in the question: Reflections have determinant $-1$ but matrices of the given form have determinant $(\cos \theta)(\cos \theta) - (\sin \theta)(-\sin \theta) = +1$.
Answer: No, that is not the case. Ad you show, the rows in your $A$ will necessarily be orthogonal to each other, and the first row has norm $1$ -- but the norm of the second row is not necessarily $1$.
If you scale each of $x'(t)$ and $y'(t)$ in the second row by $\dfrac{1}{\sqrt{x'(t)^2+y'(t)^2}}$, you do get all of $SO(2)$, assuming that your $x'(t)$ and $y'(t)$ never vanish at the same time.
Answer: (3) is only sometimes true, and it is at only the times that (3) is true that A is orthogonal.
More particularly, the reason A is orthogonal when A is some multiple of the rotation matrix is that (x(t), y(t)) describes a circle, so position is orthogonal to velocity.
For A where position is not orthogonal to velocity, the conjecture is false.

Is this matrix always orthogonal?


Center align floated div inside it's floated container

Question: I have a floated container with multiple child floated divs.
I want to center align (not text-align) all these floated child divs with respect to the floated container.
How do I do that ?
At a time, only 1 of these child div is visible on the browser ..User clicks on Prev/Next to view other child divs (kind of like Carousel)
Apparently I am facing issues center aligning if I use float:left for the child div.
Answer: You cannot align a floated element relative to a parent element.
The float CSS property rips an element from its context in the document (similarly to position:absolute/fixed). As a result of this, the element cannot be positioned "at the center of the parent".
Answer: I was searching for a solution today for my three divs inside a parent container and I came across this old post where a good solution doesn't seem to have been offered.
My situation: I have a parent container with width:100% so that it fits the screen. I also set a max-width so that the parent container doesn't grow too large. At the max-width I want the three child divs to display all in one row.
As the page is reduced and the parent container shrinks in width, I want the three child divs to reflow, each child div being pushed under the previous child div until they are all stacked vertically. As this happens I want the child divs to stay center aligned within the parent container.
The solution is to not use float which "rips an element from its context" as Rob W truly states, but instead use inline-blocks:
.parentContainer{
   margin:0 auto; /*keep centered in page*/
   width:100%; /*stretch to page*/
   max-width:800px; /*expand up to 800px*/
   text-align:center; /*keep my children centered*/
}
.childDiv{
   display:inline-block /*treat me as a block that flows like text*/
   width:230px; /*set my size*/
   vertical-align:top; /*keep me aligned at the top of my parent even if my siblings are taller than me*/
}

Content 1

Content 2

Content 3

You can float the parent container, give it absolute positioning, pretty much whatever, and the child divs will keep their same behavior.
cheers
Answer: If you show only one child div at once, probably they don't need to float. The best way to center a non-floated block inside of another block is to assign the following style:
.child {
    margin: 0 auto;
}

This will center the div.child because both left and right margins will span equally to fit the parent container. Similarly, you can align divs to the left and to the right:
.left {
    margin-right: auto;
}
.right {
    margin-left: auto;
}

Answer: If you have a fixed width for both container and children, then you can use margin-left and margin-right set to (container div width - contained width width)/2. Of course, if you have paddings and borders, you have to account for them in the formula.


ISO 27002 Controls - Which Ones to Implement First

Question: Im struggling to understand in which order I should implement the ISO 27002 controls.  I was thinking about using the CIS Top 20 to help but what is the best route?
Answer: This really doesn't have a straight forward answer, as it depends on your organization. It's important to remember that 27002 is simply a guideline for IS. It does not have a certification, nor do you have to meet each control. It is just a suggestion of things you should consider.
In most cases, you need to implement some sort of security policies so that you can implement everything else. Obviously, those policies can and will change as you implement other controls. For many organizations, the focus is on access control after some sort of baseline policies are in place. This includes all of your password policies and role based access to your network.
Answer: Evaluate your priorities.
Your organization may have company policies in place that can guide you with this task.
For example, you may be keeping customer information and your organization places importance on this. Other places to start are IP or infrastructure.
If you understand what your corporate assets are, this makes the job easier.
Performing a security assessment helps as well. A good assessor will set priorities
for you that will guide you in your implementation.


What does it mean when a professor says that he'll pay me as a 'mission' for an internship?

Question: I applied for and got selected for a summer internship at a renowned research lab in Germany. The professor says they will try to fund all my expenses, but will pay me as a 'mission'. What does this mean? I have never heard of this phrase before.
Comment: Can you paste in the entire sentence containing 'mission,' as written by this professor (be it in English or German)? I suspect (assuming the note is in English) they mis-translated a german idiom. Barring any further info, my best guess is that what's meant is that they are committed to funding you somehow.
Comment: Not so sure but as each sort of work should be paid, they should pay you for what you will do for your internship. Probably, they will not take you as a research assistant, which requires a contract between you and institution. So, I think, in order to be safe jurdically, professor proposes to do your internship as a mission. It is like "outsourcing" .
Answer: In my experience, there are typically three methods for dealing with funding for a short- to medium-term visit:

Directly collect travel and living expense information (e.g., via receipts) and advance/recompense money to those documented expenses.  This can be quite painful to actually implement for anything more than about a week.
Take on the person as a short-term employee, paying them a sufficient wage that it is expected all told to cover their travel and living expenses.  This can often be complicated due to subsidiary problems with HR, hiring policy, etc., and may often be much more expensive for the host depending on how their overheads are calculated.
Give the person a lump sum of money that is expected to be large enough to cover their travel and living expenses.  This is the simplest method, but requires available money that is allowed to be used for this purpose, which is often hard to come by except in specific visiting scholar funds and the like.

My guess is that the statement about "mission" may be an unusual or mistranslated phrasing referring to the third type of funding.  The only way to know for certain, however, is to ask for clarification from the person who used the phrase.


How to predict the products of a organic chemical reaction

Question: Given a set of reactants, what aspects should I consider when predicting possible products?
Answer: You need to build a working knowledge of known reaction mechanisms that include the functional groups of your reactants. Put another way, (1) identify the functional groups present in your reactants and (2) check known reaction mechanisms that proceed by reaction of these functional groups.
Really, the only way to be good at this is to study and memorize organic reactions. There's a number of resources to help with this (e.g. online flashcards, and I really like Chemistry by Design, an app that you can use on a smartphone).
Comment: On the topic of flash cards - I think these are an excellent way to learn the patterns of organic chemistry, and with those patterns ingrained, you're much better equipped to deal with the important, applied aspects of the subject. I wasn't happy with the online flash cards available for organic chemistry, so I've been steadily creating high quality sets for students to use on Quizlet - https://quizlet.com/features/OrganicChemExplained
Answer: Sharpen up your general chem skills.  One skill is recognizing redox reactions.  Many organic reactions are redox.  In problems where you have the reactants and products and are prompted to give the reagents you can recognize reductions and oxidations.  For the problems where you have the reactant and conditions you can more easily recognize oxidizers and reducers.  You can work on relative acidity and identify the most acidic proton in a molecule.  You can recognize the different types of carbon in a molecule and remember which are more reactive to which conditions.
Also, keep a notebook where you put in 5-10 reactions a day and memorize them.  You probably don't want to start today but you wish you started a month ago and a month from now you'll wish you started today.  Just learning name reactions would be a good start.
Answer: Short answer: You can't.
Long answer: for simple substrates and simple reagents there is a big stock of reaction protocols with more-or-less known general mechanisms, that can give a good guess of resulting product. However, in case of complex substrates or tricky reagents (yet unknown) strange transformations may occur. They can get ad-hoc explanations, but.. that's not satisfactory enough. A really good book, considering key intermediates and most important reactions with mechanisms is March's Organic Chemistry (that's probably one of the best books on the subject).
Comment: Are March's organic chemistry and March's advanced organic chemistry the same books ?
Comment: @user70856 Truthfully, I know one book "organic chemistry", originally written by March and survived several reeditions. No idea, how it is called right now and who edits new editions.


How to drive P mosfet gate to ground in half bridge synchronous DC buck/ boost converter

Question: The diagram shows the totem pole driver circuit for the Hi Side P channel Mosfet driven from PIC pin PWM output. This is part of a buck boost circuit running at 250KHz.
The biased totem pole transistors drive the gate of the P channel mosfet approx 6.5 volts below Vin to turn it on. The Mosfet gate threshold is 2-4V.
This works well if Vin is above about 8 volts but when Vin is only 5V then the gate is driven at 3V only 2 V below Vin. Instead of using the level shifter (or as well as) is there a way to drive the P-MOSFET gate to ground that allows the gate to charge up and then discharge quickly when connection to ground is removed.
Thanks
Comment: *is there a way to drive the P-MOSFET gate...* Yes, the easiest and most reliable way is to use a **gate driver IC**.
Comment: Thank you. I was trying to learn about how the discrete components work and construct a P channel drive circuit using transistors, just wanting to learn, I think I know that driver IC is easist.
Comment: OK! So removing the emitter resitor allows it to drive to zero! That's great and also I've replaced the 180Ohm resistor from the PIC pin with 1.8K.
Comment: Will half bridge gate drivers  work with P channel on high side or do they have to be N channel?
Answer: Didn't do the math but I think that your first transistor is not biased correctly to pull the driver pair.
Why did you put the emitter resistor? You need all the strength available and you are in straight switching mode, there is no need to limit the collector current (more than the collector resistor). 180 ohm into base also seem a little low to me. Did you forget a zero?
Anyway. This kind of discrete driver is only used for huge mosfet/igbt modules (when you have maybe DPAK transistors as gate drivers). It's an interesting exercise but the market is full of dedicate gate drivers ICs (with all the nice protections as a bonus).
Also consider using an N-channel mosfet, they are cheaper and more efficient (from the schematic it seems some kind of buck converter or bridge leg). They are difficult to drive because you need to bootstrap the gate but it's done in the driver IC.
Comment: Thanks for your reply, my understanding was that Ie was approx Vb-Vbe/Re, this sets the
Comment: Thanks for your reply, my understanding was that the collector current in active mode was approx to the emitter current so setting the emmitter current with Re=Vb-Vbe/Re=5-0.7/180 gives 0.024A so V across Rc=270X0.024=6.45V. So the DC bias is always 6.45V below Vin. Yes you are right it is a DC DC buck boost converter running at 250KHz. I wanted to make this one using transistors and using P Mosfets on the Hi Side to start with as cutrrent will be upto 5 Amps. N channel hi side Mosfets and boostrapping can come later for higher current circuit. So, how to drive the gate of P Mosfet to ground?


Facebook: how to block friend A from seeing posts from friend B

Question: Friend A was married to Friend B. Now they are divorced and I'm friends with A and B. Can I block friend A from seeing posts friend B tags me in and vice versa?
Answer: Facebook provides the following methods which can be used based on your requirements

Timeline review
Blocking particular friend

Timeline review allows you to review the posts from your friend before they appear on your timeline.
It can be found under Settings > Timeline review
It can be activated if you just need to restrict others from tagging you in their posts.
The next option is blocking the particular friend. This will entirely avoid all the activities from your friend.


How to parry a mono-blade?

Question: The molecular thread used is consist of a single long super dense compound with extremely fast angular momentum (referring to its quantum property) at nearly the speed of light. This filament less than 1 nm thick is shown to sever any molecular bonds upon contact with almost no resistance, how to effectively block against such weapon if possible using modern day innovation?
Comment: By using the same technology that lets you reach those insane specifications?
Comment: @user6760 be careful when trying to sound cool.  It can backfire pretty spectacularly.  In this case, you have a grave dimensionality error, because the units of angular momentum are not the same as the units of the speed of light.  That then draws extra attention to your use of the speed of light, which really doesn't belong anywhere near hand-to-hand-combat.  Momentum is also the one thing you don't want to draw attention to in a monoblade, because you shouldn't have to rely on momentum in any way shape or form for that particular science fiction weapon.
Comment: @user6760  How does it have infinite angular momentum?? Angular momentum is M*V * D  (mass) (angular velocity) (distance from center of rotation)  The mass is very small.  The distance is at most a few dozen meters.  The man waving it around can't move his hand faster then a few dozen meters / second)
Comment: Actually the angular momentum refers to the individual molecule because I want it to sound cool, that's all.
Comment: @Cort Ammon: sorry I forgot to include the tech level just now, and I dislike the idea of self defeating.
Comment: Can you explain the angular momentum part? I don't understand how that has any relevance.
Comment: @Cort Ammon: yeah you're right I learnt my lesson.
Comment: Just limiting the question to "How do you parry a monofilament sword?" would really have been enough, I think.
Comment: In reality monomolecular edge can be destroyed by a cell. Living cell. If yours is somehow practical, it does not use real physics anyway. With unreal physics, you can do whatever you want.
Answer: I would probably punch the guy who is wielding it.
We get a lot of questions on StackExchange in the form of "unstoppable forces" or "immovable objects," and then the request is to brainstorm solutions.  Typically these solutions are given limitations well below the technology or magic used to create the unstoppable force or immovable object.  In this case, no physics is provided for the monoblade, so it's all handwavium.  This means there's no weaknesses in the implementation for us to explore.
A few potential solutions:

Capture the filament with electrostatic forces.
Burn the filament with plasma.
If the filament is conductive, you might be able to use a tesla coil to zap the guy.
Block the blade at the hilt, rather than at the pointy bit.
Be elsewhere (not technically blocking, but not a bad idea any time someone comes at you with technology Clarke would call "magic")
Set off a nuclear device near the monoblade (which has the convenient side effect of also ensuring the wielder stops wielding any blades)
Comment: As always, there's a tangentially related xkcd comic to this: https://xkcd.com/538/
Answer: Shoot him

A sword can only reach so far of course...
Answer: Use your own mono-blade to parry your opponent's mono-blade. Of course you would, if your opponent has a mono-blade, then surely you do too.
The OP didn't specify how super-dense the mono-blade might be, so the chances are your opponent will be struggling to even lift his mono-blade because it is too heavy to lift. In that case, follow Cort Ammon's advice and punch him.
Alternatively, you run him through with a non-super-dense conventional blade or shoot Mr Mono-blade with an ordinary gun. If you're really lucky he will die of a heart attack trying to lift his too heavy, super-dense mono-blade.
Basically remarkably few modern innovations are needed to stop someone armed with a super-dense mono-blade. Conventional weapons are more than adequate at combating persons armed with swords. This is only sword, admittedly it does have the Rule of Cool on its side, but the sad truth is the Rule of Cool never saved anyone's life. A sword by any other name is still a sword.
Comment: As a courtesy could the downvoter give reasons for doing so. If my answer needs improvement, I'd certainly like to know what is the problem. I'm sure you like same courtesy with regards your answers too.
Answer: I will take block to mean "stop him from hitting more people with his fancy sword."
Meaning kill the wielder with basic weapons
Kamikaze
You can't block his sword and he can't block you either.  You swing an axe at him he "blocks" it by cutting through it.  The cut off segment keeps going and hits him.  So he can always hit you and you can always hit him, just rush three guys at him kill him and take the sword.
Shoot him if he "blocks" the bullet / arrow it will hit him.
The monomolecular weapon may not even harm a human.
IF it cuts a very sharp cut with a very thin blade (monomolecual) and moves very fast (the term used was infinite angular momentum which is impossible, but assume fast) the bonds may reseal on the other side with out the loss of blood of damage to the organs.  It may be true he cuts you dozens of times to no effect at all.
Comment: if the blade is blade shaped (not a mono pin) then slight twitches in the angle of the slice could separate the molecules.
Answer: How to counter an unstoppable sword? Why, with an invulnerable shield of course.
Do you have magnetic shields (aka 'force' fields) available? There're some ideas around already: http://www.popularmechanics.com/military/research/a14683/boeing-patent-plasma-shield/
Answer: Have you tried diplomacy? :-)
Just kidding. More seriously: what's the melting point of this monofilament? Perhaps it can be "parried" by a flame thrower or hyper-focused laser. Similarly, maybe extreme cold makes it brittle.
Alternate: What is its sliding friction coefficient? As it slices through objects, it is going to lose energy and slow down. There is some thickness that will stop it unless it is being actively propelled -- that thickness might be a planet or it might be a thick brick of uranium, depending upon the coefficient.

How to parry a mono-blade?


bed entries collapse based on score column

Question: I have a bed file where some entries have the exact same chr:start-end but change in the name and score column. I would like to apply bedtools or a similar tool to obtain a filtered file where for each set of chr:start-end entries, only the one with the highest score (column 5) is used, the others filtered out. I would like to do this with a bed format toolkit (bedtools, etc) rather than scripting it.
Comment: I searched for bedtools merge or bedtools collapse, but couldn't find a way.
Answer: Use BEDOPS bedmap --max-element or bedmap --max-element-rand to grab the maximal-scoring element over mapped intervals, e.g.:
$ sort-bed elements.unsorted.bed5 > elements.bed5
$ bedops --merge elements.bed5 > merged.bed3
$ bedmap --max-element merged.bed3 elements.bed5 > answer.bed

The file answer.bed will contain the maximal-scored element from elements.bed5 that overlaps the merged intervals in merged.bed3.
The --max-element and --max-element-rand options differ on handling ties. The first option grabs the first match from ties by sort-bed (lexiographical) sort order; the second option grabs a random match on ties.
The option you pick would depend on what you're doing with the answer. Picking a random hit might be better if you're doing downstream statistical tests, for instance.
You can add --sci and --prec <int> options to format the score output to your desired level of precision. I think the default assumption is six digits of precision; adjust as needed.
There are also --min-element and --min-element-rand options for, conversely, reporting minimal-scoring elements.
For more information: http://bedops.readthedocs.io/en/latest/content/reference/statistics/bedmap.html#score-operations
Answer: groupby from bedtools might help you:
bedtools groupby -i variantsToRepeats.bed -grp 1-3 -c 5 -o max

-grp to select the columns to group by
-c to select the columns to summarize
-o to select how to summarize the column selected.
Comment: Could you please expand your answer? An explanation might help future readers. Thanks! I edited your question from the help page you linked. I hope it is now better, and I understood it correctly
Comment: How lazy can people be? I even linked the help page and to anybody with an IQ over 80 the options should be immediately obvious.
Comment: Without the explanation your answer becomes pretty unhelpful if the location of the help files changes


Are there any good strategies for the SC2 Mod "Footmen"?

Question: I've been playing the Footmen mod for SC2 a lot lately and i really enjoy it. I was wondering if anyone has some good strategies for this mod? What hero should i choose and what stats should i upgrade first? Is it better to stick with the lower tier units and upgrade armor/weapons or do it the other way (first level up units, then armor/weapons)? Any other suggestions on how to win?
Comment: I haven't seen it yet. Is it anything like the War 3 footment frenzy?
Comment: @Jonn, it is similar
Comment: Dang. I've been looking and it seems we don't have that on the SEA server. I've been waiting for a footies in SC2 for a while now.
Comment: This one surely needs more attention!
Answer: Its only published in Europe
Theres a lot strategies i think. Theres a forum (http://footmen.de.gg/), maybe check this out, strategies and other stuff is discussed there.
From what ive seen, building reapers (terran tier 1) and then doing attack and armor upgrades is a pretty good strategy. Or buying a grenady launcher + armor + other items for your hero is also good.


How can i redirect to a separate page without filling value in the required field?

Question: I have a site in drupal 9. I have one taxonomy with the name and and another field.
I have a Go back button which takes me to a separate destination.
The problem is that I cant click go back without giving some values in the name field as it is by default a required field in drupal.
I want to click go back without giving anything in that name field. How can i achieve this?
Answer: You didn't post any code, but it sounds like your back button is somehow submitting the form (because it is validating the form, and failing required validation).
So the solution is to make sure the back button is not part of the form.
On my own site, to add a back button to some webforms, I add this HTML in a block that is shown on the webform page:
<button onClick="window.history.back()" class="button">Back</button>

You can easily do something similar with standard HTML + JS.
Answer: Another option if you cannot move the back button out of the form (and if it uses the Form API), would be to use the #limit_validation_errors property to avoid any form validation.
The example below can be used if you are building the form by yourself. If using a hook_form_alter(), just add the #limit_validation_errors line.
$form['back'] = [
  '#type' => 'submit',
  '#value' => $this->t('Back'),
  '#submit' => ['::yourSubmitCallback'],
  '#limit_validation_errors' => [], // This will ensure any validation is skipped
];


What's Bitcoin url or where can I find it

Question: What is a Bitcoin transaction url? Is that the wallet or hash or what. I sent btc to address for game n it says confirmed but never came. Now the host is asking for transaction url but ?
Answer: There is no such thing as a Bitcoin transaction URL. Bitcoin transactions are identified by a transaction-ID which looks like 31144ef6faaad902f3ec4e6f6241aa09f9ea08374abb67242039f3285414cd2e
There exist web sites run by various organisations that allow you to search for Bitcoin transaction data by transaction-ID. These websites are examples of blockchain explorers. For example you could find details of the above transaction at a number of websites including

https://blockchair.com/bitcoin/transaction/31144ef6faaad902f3ec4e6f6241aa09f9ea08374abb67242039f3285414cd2e
https://www.blockchain.com/btc/tx/31144ef6faaad902f3ec4e6f6241aa09f9ea08374abb67242039f3285414cd2e
https://blockstream.info/tx/31144ef6faaad902f3ec4e6f6241aa09f9ea08374abb67242039f3285414cd2e

and many others
However, any honest recipient only needs the transaction-ID, they don't need you to tell them which blockchain explorer they should be using.
Dishonest recipients will often mis-use technical terms to try and confuse you into paying them more money.


How to prevent Wordpress to remove my embedded SVG images

Question: I run my own wordpress (not on wordpress.com)
I'm trying to minimize the number of image files and embed some very small images directly into HTML code using the classic editor.
However, when I save the post and load it again - all my embedded SVG images are gone!
How do I prevent Wordpress from removing my SVG images?
Answer: I think you are missing dimension properties (height and width) while adding it in HTML, that's why it is not appearing. For SVG files height and width is compulsory if you align it center or left without giving dimensions property it will break. I faced the same issue when I started my ChartExpo project.


How to rotate trace logs in SQL Server

Question: We are using 4032 & 3605 trace flags in SQL Server 2012 to get the expected log output.
Now, we would like to rotate the log files on daily basis to archive it in Amazon Glacier storage facility.
Any pointers on log rotation would be appreciated,
Answer: To rotate the logs you just need to execute
<code>EXEC master.sys.sp_cycle_errorlog;
</code>
You can schedule the execution daily or as often as it makes sense in your scenario with a SQL Server agent job.
Answer: You never know when another process has run the master.sys.sp_cycle_errorlog, so I think it's prudent to have an archive process that reads through all of the logs and apply the necessary filtering to capture what you want.  The following example DOES use undocumented stored procedures to read the logs.  It's only an example - tweak as needed
<code>--The following code uses 'undocumented' stored procedures - use at your own risk

--Initially create a table to track the last time you ran this archive process
--The following two lines are a one time thing
create table dbo.LastErrorLogArchiveProcessed (LastErrorLogArchiveProcessedDateTime DateTime)
insert into dbo.LastErrorLogArchiveProcessed (LastErrorLogArchiveProcessedDateTime) VALUES('2016-09-04 00:01:00.570')

--The following code could be scheduled in a job that runs daily at midnight
DECLARE @errorlog TABLE (LogDate DATETIME,[source] VARCHAR(max),[message] VARCHAR(max))
DECLARE @BeginDateTime DATETIME = (SELECT LastErrorLogArchiveProcessedDateTime FROM dbo.LastErrorLogArchiveProcessed)
DECLARE @EndDateTime DATETIME
DECLARE @LogArchive INT = 1
DECLARE @NumErrorLogs INT

--Cycle the errorlog
EXEC sp_cycle_errorlog

--Capture the current timestamp
SET @EndDateTime = sysdatetime()

--Get the number of configured ErrorLogs
EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE'
    ,N'Software\Microsoft\MSSQLServer\MSSQLServer'
    ,N'NumErrorLogs'
    ,@NumErrorLogs OUTPUT

--Loop through all ErrorLogs
WHILE @LogArchive <= @NumErrorLogs
BEGIN

    INSERT INTO @errorlog
    EXEC xp_readerrorlog @LogArchive,1,NULL,NULL,@BeginDateTime,@EndDateTime

    SET @LogArchive += 1
END

--Update dbo.LastErrorLogArchiveProcessed
--reflecting the DateTime just processed
UPDATE dbo.LastErrorLogArchiveProcessed SET LastErrorLogArchiveProcessedDateTime = @EndDateTime

--Execute DELETES from @errorlog to apply filtering
--NOTE: The 3rd and 4th parameters of xp_readerrorlog allow some filtering
--It's whatever you want to do
SELECT * FROM @errorlog

--@errorlog now contains the data you want to save and archive

SELECT * FROM dbo.LastErrorLogArchiveProcessed
</code>

How to rotate trace logs in SQL Server


Is it possible to create a ramdisk of more than 4 gb in a 32bit system?

Question: I'm planning on building my desktop computer to have a ramdisk. At the moment my pc has 4 gb ram, and I was thinking if it is possible to go beyond 4 gb and use the extra ram as a ramdisk.
Answer: Yes. It looks like you can: http://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem/  You would have to find the device names of the extra RAM and then follow that tutorial or one that is similar.
Comment: The default ramdisk size is 64M so you would need to use the ramdisk_size= kernel argument to increase it.
Answer: You are better off letting the kernel manage the ram for you.  It will allocate the ram to applications that need it ( up to 3GB per process ), and use any free ram to cache files automatically.


Difference between RequestParameter and QueryParameter

Question: I'm retrieving a URL parameter from a CloudPage. What is the difference between RequestParameter() and QueryParameter()? They appear to do the same thing. Are there scenarios where you would need to use one over the other?
Answer: The "query" of a page's life cycle is the stuff after the "?" character in a URL, while a request parameter is one placed in the body of the request (a "form post"). Let's look at an example of what a browser might send to a server:
<code>POST /path/to/file?The-Query-String=Here&Query-Values=Are-In-The-Url HTTP/1.1
Host: myhost.com
Content-Length: 52
Content-Type: x-www-form-urlencoded

Request-Body=Here&Request-Values=Are-In-The-Form-Post
</code>
However, in the documentation for the RequestParameter, it explicitly states that it can return query parameters (the part in the URL), and values in the form's post.
You can use QueryParameter to ignore form values, while you'd want to use RequestParameter if you need to read the values from a form post. RequestParameter may return more values than QueryParameter, especially if the request is a form post.
Comment: @duyduc27 it depends on how the form submit action is set up. In general, I would suggest using RequestParameter to read form post values.
Comment: I built a simple HTML submit form post, and both functions (QueryParameter and RequestParameter) can capture element id values. Is it another form post you was mentioning?