Proving an intuitive fact rigorously

Question:
We place a wooden stack upon two supports and place a weight of mass $m$ at one of its ends. Now it is almost obvious intuitively that just at the verge of the mass $m$ falling down, the normal force $P_2$ exerted by the right-most support will be $0$. But is there any way we can prove it mathematically or rigorously? It seems so obvious that I can't think of a rigorous way to prove this fact.
Comment: Hint: don't forget to take into account the plank weight. It's not drawn in your example, but it should be from the plank center of mass downwards.
Answer: Indeed, this can be shown using the laws of conservation of momentum and conservation of angular momentum.
Assume we have a two-dimensional body held over two support points. Let's call the normal forces by the two supports $\vec P_1$ and $\vec P_2$ and let's denote the horizontal distance from each of the points to the center of mass of the body by $x_1$ and $x_2$ respectively.
If the body is in equilibrium, then the sum of forces on it is zero. Also, the sum of angular moments around the center of mass is zero. Thus we can write:
$$P_1 + P_2 = mg$$
$$P_1x_1 + P_2x_2 = 0$$
On the verge of tipping, the center of mass of the body is right below support 1, so that $x_1 = 0$. This means from the second equation above that $P_2 = 0$, and then from the first equation $P_1 = mg$.
Answer: So if the beam has mass M, the distance from the end to the supports $P_i$ are $L_i$, and they apply forces $F_i$ then:
$$ (m+M)g  = F_1 + F_2 $$
keeps the beam from falling, while to keep it from pivoting around
$P_1$, you have to balance the torques:
$$ mgL_1 = F_1(L_1-L_1) + F_2(L_2-L_1) $$
Solved those and show that as $m\rightarrow m_{max}$, $F_2\rightarrow 0$.
Comment: Pardon please but could you please tell me what we mean by as $m$ approaches $m_\mathrm{max}$? What do we mean by maximum mass in this case? Isn't the mass $m$ fixed?
Comment: $m$ is from your drawing. If the beam is massless ($M=0$), it's flipping over. Since you said if $m$ is on the verge of $F_2=0$, then I would think the equations have a solution for $m \in [0, m_{max}]$, I just don't have time to solve them.
Comment: @JEB, why will $m$ flip over if beam is massless?
Comment: @a_i_r Energy wise, it cost no energy to pivot about $P_1$, so $m$ is going to seek lower $mgh$. In fact, it may be better to solve the problem by computing the energy as a function of flip angle...probably a lot easier. If the center of mass gets lower when the beam goes rip: flip.. Ofc: OP asked about $F_2=0$, so that's how I tackled it.
Answer: The typical way to do something like this is to assume the system is at equilibrium (so that the net force and torque on the plank vanish) and then solve for $P_2$.  The result will be a function of $m$ which is positive for small $m$, zero for some $m=m_0$, and negative for $m>m_0$
The interpretation of this is that for $m>m_0$, $P_2$ would have to be negative (i.e. the plank would have to adhere to the right-most support) in order for the system to be in equilibrium. Assuming that no such adhesive forces are present equates to the mathematical constraint that $P_2\geq 0$. Assuming that $P_2\geq 0$ and $m>m_0$ results in a contradiction, which means that it is not possible for the system to be in equilibrium and that it will begin to rotate.
The threshold point - the last point at which equilibrium is possible - corresponds to $m=m_0$ and $P_2 =0$.
Comment: Pardon please but i am finding it hard to understand where mass $m_0$ comes from? We place only an object of mass $m$ at the end. Isn't this mass $m$ fixed? Sorry if i am being too dumb.
Comment: @madness The quantity $m_0$ will be proportional to the mass of the plank itself and depends on the location of the supports with respect to its center of mass. I'm not saying that $m$ changes dynamically, I'm saying that if you solve for $P_2$ under the assumption that the system is in equilibrium, you will end up with an expression of the form $P_2 = (\text{something...})(m_0- m)$. If $mm_0$ then it will start to rotate since $P_2$ cannot be negative. If $m=m_0$ then $P_2=0$ and any increase in $m$ will cause the system to rotate.
Answer: When the stick is on the verge of tipping over, it is perfectly balanced on a single fulcrum point. Add more mass to the end of the stick, it will tip one way, remove mass, and it will tip the other way. Only when the stick is on "the verge of tipping" does it not tip either way. Since the balanced stick has no tendency to move one way or another, we can remove any supports at one end of the stick or the other without changing anything. When the stick is balanced, removing the P2 support has no effect whatsoever, therefore it can't be imparting any force to the stick.
Indeed, this is the entire concept of balance, that the torque induced by gravity on one side of the fulcrum exactly balances the torque induced by gravity on the other side of the fulcrum. If you need any other forces besides gravity and the fulcrum normal force, you do not have balance. We can't have the stick naturally balanced on the leftmost support while feeling support from the rightmost support, as a balanced lever only gets support from the fulcrum. It would be like using a balance scale while propping up one side with your hand and claiming the scale was balanced.
You can also look at this from a Newtons third law perspective. The only way the rightmost support can be pushing up on the stick is if the stick is pushing down on it. But that implies that if you were to remove the support, the stick would fall over to the right, contradicting the premise that the stick was on the verge of falling over to the left.

Proving an intuitive fact rigorously


How hierarchical are Delphi 2009 project configuration option sets?

Question: Delphi 2009 introduced a hierarchical system for project options configuration, where you set "base" options and then have different build styles with their own option sets. But can you extend the hierarchy even further? I do most of my coding with debug options on, of course, but sometimes there are special cases where I want a slightly different set of debug options. I'd really like to be able to set up a basic debug configuration and then three more specific configurations underneath it, but I can't find any option to do this.  Is it not possible in D2009, or am I just missing something?
Answer: Yes, it's straightforward.
In the project manager, just right-click on the "Debug" configuration, and select "New Configuration". Your new configuration will appear as descended from "Debug" in the way that you expect.
Answer: Build Configurations are completely hierarchical.  You can create any depth of hierarchies that you want in your configurations.  Any build configuration can be descended from, and the hierarchies can be as deep as you like.
In addition, you can use Option Sets to alter any given configuration.  Save an Option Set in a file and apply it to any configuration that you like at any time.
I think it is safe to say that the Build Configuration System in Delphi 2009 is about as flexible and powerful as you'd want it to be.


How does appengine's data store query and index multi-value properties?

Question: Lets say I have a Photo class containing a multi-valued property for tags and a date field.
I would like to allow the user to perform a query based on tags (using only a AND operator for more then 1 tag).
For example lets say a user searches for a rainy day.
Select * from Photo where tag='clouds' AND tag='rainy'
How does the zig-zag merge work? I know that two scans are performed, and based on if the keys from both searches point to the same Photo then it's returned. Does this happen in parallel however? Ex: While Search 1 finds a photo that contains tag 'clouds' , Search 2 is finding the first photo that contains tag "rainy". When both searches are done, it becomes synchronous. Search 1 then continues it's scan until it hits the same key as S2. Then while the keys for each search are the same, the photo is returned, and the "cursor" is moved along 1 step for each search?
Secondly, does defining multiple indexes speed up these sort of queries? Ex, if I wanted to allow up to 4 tags then I would need to define the indexes such as:
Index(Photo)
Index(Photo, tag)
Index(Photo, tag,tag)
Index(Photo, tag,tag,tag)
Index(Photo, tag,tag,tag,tag)
Then, performing the same query above will be quicker?
Also, using our original query, lets say we have Millions of photos tagged as cloudy, but only two are tagged as rainy. Does this mean zig-zag will perform relatively slow? Since one of the searches will try to find a matching exist? Even worse, if we have one million photos tagged "rainy" and one million are tagged "cloudly" yet no single photo have both tags in them. Will defining the above index's fix this issue?
Lastly, lets say a photo has 100 tags. Does that mean all the index's above have to include EVERY combination of the 100 tags?
I know there are got-yas (such as a entity can only be indexed 5000 times, and a single multi-valued property can only be indexed a 1000 times).
Answer:
How does the zig-zag merge work?

You can check out the Google I/O video from 2009 on Building Scalable, Complex Apps on App Engine. Brett Slatkin explains how zig-zag merge works starting at 27 minutes. As he says, "I can't really explain it without showing how it works."


QGIS: Rendering WMS/WMTS raster at proper resolution?

Question: QGIS 2.18.24 – which I use for work and cannot update – seems to struggle with some WMS and WMTS layers. They seem to render at an incorrect resolution, although they appear aligned properly.
This is Mapbox (WMS):

And this is esri World Topo (WMTS):

As you can see (click to enlarge), both look really crappy. Seems like the resolution is way off. Other layers do not have such issues. Am I missing something obvious here?
Comment: Is your QGIS project using some other CRS than the native one for the WMTS Service?
Comment: The texts like "Berlin" in the screenshots are slightly rotated and I suppose that in some part of the chain the tiles are re-projected. Check again from QGIS if the services really support tilesets in EPSG:3059. And have a try by changing the CRS of QGIS into EPSG:3857 and see if it makes difference. Naturally you must then select a tileset that is in EPSG:3857 as well.
Comment: What is wrong with using the official DTK by the LGB (https://www.geobasis-bb.de/geodaten/geo_wms_uebersicht.htm)?
Comment: @user30184, yes, I use EPSG:3059.
Answer: I'd strongly suggest that you ask your IT team to consider allowing you to have at the least a parallel install of QGIS 3.4LTR or QGIS 3.10, as they've made inumerable significant improvements in every area since 2.x, not least of which was a change to the raster rendering pipeline that allows for pixel-perfect rendering at native resolution, which did not occur in prior releases, as the raster data were still being scaled (resulting in the distortions you see in your imagery).
For your specific case, you might be best off to convince your IT team to wait for QGIS 3.10LTR, which should be out soon (2020-02-21), as this change has been committed to QGIS Master, 3.8, 3.10, and 3.10LTR, with no evidence of being backported to any other release.
Changelog for QGIS 3.8:
Feature: Improved "Zoom to Native Resolution" behavior
We've improved the "Zoom to Native" action, so it now works correctly with tiled (e.g. WMTS/XYZ/ArcGIS MapServer) layers, by zooming to the closest native tile resolution. Additionally, we tweaked tile rendering so that pixel-perfect rendering occurs when the map is viewed at a native tile resolution. The result: super-crisp map renders when using tiled layer sources!

Summary
QGIS 3.8 and newer have the improved raster rendering logic which will allow for pixel-perfect rendering, even of webmap layers.
Comment: Thank you for the response. I do have QGIS 3.10 installed on my own computer, and I experience the same issue there as well. Let's hope the changes in upcoming releases fix that.
Comment: I see that in a comment above you mention you use a CRS that isn't EPSG 3857/4326. QGIS is going to have to reproject (distort) the tilesets because they're not in their native/served CRS, which is going to introduce some artifacting. As suggested by user30184, you should re-load the tilesets in a native EPSG:3857 project and see if they behave better (they should). If not, time to file a bug at the QGIS GitHub!


Netbook Touchpad

Question: I just installed Xubuntu on my Acer Aspire netbook but can not get the pointing device at all.  I am unable to access anything as a result.  Can someone please help.  Thanks.
Comment: If you have a synaptics touchpad, try installing `xf86-input-libinput`
Comment: Please all more details to the question.
Answer: First off if your laptop has a toggle touchpad button, hit it to see if it changes things.
You may have drivers installed, but the mouse isn't activated or recognized.
Login using your keyboard/tab/ and or arrows keys.
Open a terminal using a keyboard shortcut
default is:
ctrl + alt + T
You can check this with the following commands
xinput

Find your touchpad id, it should be a 1 or 2 digit number(like 14).
Then once you have your ID, run:
xinput --list-props <ID>

This should spit out all the properties that deal with your touchpad driver.
The key thing we are looking for is something along the lines of:
Device Enabled (SOME_NUMBER): 0

Obviously 0 is off, so we want to change it with this command:
xinput --set-prop <ID> <THAT_NUMBER> 1

This should "activate" your touchpad. If this problem persists(!) you may need to change your driver (libinput is the one I use as some features were not working with stock synaptics.)
Along with this you can create a script to fix this at startup (I personally add the commands to the end of my ~/.profile file)
The order of input devices MAY change after you logout. Because of this you can always replace the numbers in your long term solution with the String names:
IE:
xinput --set-prop 14 138 1
To
xinput set-prop 'SynPS/2 Synaptics TouchPad' 'Device Enabled' 1
Goodluck!

Netbook Touchpad


Get file unit by name and vice versa in Fortran

Question: Is there a way in Fortran 90 to get a file unit by name and file name by unit number? I know it will be expensive, but I have a lot of file names that I want to be able to re-access in a subroutine after they've been created..
Comment: Because the answer says both, I believe it is useful to have also both in the question. If you disagree, you can roll-back the edit.
Comment: Looks good to me, thanks!
Answer: A command like
inquire(unit=12, opened=openedq, file=name_of_file)

will return the name of the file connected to unit 12 to the character variable name_of_file. If there is no file connected to the unit opened will return false, otherwise true.  The command takes a variety of other optional arguments too.
To get the unit number of a file which is already attached use a variation on the preceding, like this
inquire(file='my_favourite_file.nuts', number=unknown_unit_number, opened=openedq)

Reference to your compiler documentation should explain all the variations that inquire supports.
Comment: I don't know what the unit number is (in your case 12), but I do know the name of the file that I want to open and write to (in your case name_of_file)... I created a temporary integer to open the unit, but lost it when leaving a subroutine. Is there any way that I can still access the file without the original unit number and just with the file name? Or do I have to save the unit number?...
Comment: You have to save the unit number, or use INQUIRE to get it again as Mark suggested.
Comment: Looks like outdated answer.  See the answer by Federico Perini below
Answer: In order to get file information, you have to use the INQUIRE statement.
UNIT and FILE are both valid input options to the INQUIRE statement, but I am not sure if they can used for output (For example, gfortran 7.4.0 will complain that INQUIRE statement at (1) cannot contain both FILE and UNIT specifiers).
So, to get file name information from a unit number, use NAME, e.g.:
inquire(unit=12, opened=openedq, NAME=name_of_file)
To get unit number information, the previous example is valid:
inquire(file='my_file', opened=openedq, NUMBER=file_unit)


Need to customize newdocset.aspx of document set in Sharepoint 2010

Question: We need to customize newdocset.aspx of document set in SharePoint 2010. Currently reference is given to newdocset.aspx of _layouts folders application pages. Did lot of research, but I got no where.
Answer: Microsoft has a sample of how to do this on MSDN.  You would basically create an Application Page that serves the same function and then set the "new" url of the document set content type (or your custom one build on it) to that new page:
http://msdn.microsoft.com/en-us/library/ff512780.aspx
Answer: My team and I have found a custom solution that does not require a new feature or application page.
Using SharePoint Designer, create a new Edit form at the target Library. For this example, we'll call this form CustomNewDocSet.aspx
In SharePoint Designer, navigate to a List and create a New Form of type New item form. Then, take that markup and place it into "CustomDocSet.aspx". This will update the 'Type' of this form from Edit to New. At this point, you associate this form with the target Library's Document Set content type as the "New Form". Upon creating a New Doc set, you should be routed to CustomDocSet.aspx and realized there were no Save or Cancel buttons!
You can add these buttons adding the following snippet between the  &    tags:

Afterwards, navigate to the CustomDocSet.aspx page and Edit the page to add a Script Editor webpart for any custom .css and .js
So far so good, as I have not encountered any nuances or issues with this implementation.
Comment: Hi Clinton, Do you have any working snippets on how to do so, because i tried with your method but i dont find how to associate with newform of the document set content type as there is only edit and display form association.


what are some good practices for sight reading sheet music?

Question: I'm teaching my self to learn the piano, currently I've started learning sheet music. I feel as if I'm not progressing as fast as I'd want and I'm hoping to find some practices to make my sheet music reading more natural. any tips?
Answer: After learning the note names in the staffs, lines and spaces - writing down the  note names right in the system, use large lines with large spaces! -  you need to learn the chords and triads, seventh chords, scales and chords in each key, write down the melodies you have in your mind and your memory. By writing the music you have in your mind and playing what you have written, also chords and their inversions  you learn to play what you already know and you will be able to use these chords and motifs  like elements to decipher at first sight new music you haven't read before. So this is a sight reading and learning to read by writing.
Answer: I don't think there's any useful 'box-ticking' approach to this.  Just read lots of music.  Preferably get into a situation where you HAVE to read lots of music.  Work with a singer who has charts.  Accompany student instrumentalists in their exam pieces.  If you can stomach religion, play piano for the hymns.  Anything that requires the skill.


Hash rate of CPU is the same as that of GPU

Question: My GPU:gtx1050ti
My cpu: ryzen 5 1500x
Both of them have a same H/s of 320.
I'm using xmr-stack for both. Nvidia version for GPU and CPU for CPU.
Why is it so?
Comment: Probably just a coincidence. Can you comment or edit your post to state if you get an increased hashrate on one or both of you run them independently rather than simultaneously?
Comment: @jwinterm it's the same independently or individuallly for both.
Answer: If you expect the GPU to be much faster, your question may be answered here: Is it better to mine with a CPU or GPU
Your numbers sound reasonable for the CPU, and mostly consistent with reported numbers for the GPU. That said, I've got a bit better performance out of XMR-Stak than ccminer on my GTX 950 card. I also made a test of numerous configurations for blocks and threads for my card, and there are certainly numerous settings that will cause it to underperform.
I am running XMR-Stak-CPU and XMR-Stak-NVIDIA, and can share my rates for some of the workers for comparison if that's any help.
<code>AMD FX-6300 Six-Core Processor   : 274 H/s
  > low_power_mode on 1/6 cores

NVIDIA GeForce GTX 950           : 251 H/s
  > 32 threads x 18 blocks

Intel i7-7700K @ 4.20GHz         : 340 H/s
  > low_power_mode on 0/4 cores

2 x Intel Xeon E5-2620 @ 2.00GHz : 288 H/s
  > low_power_mode on 2/12 cores
</code>
I run all of these on headless Linux, mostly Ubuntu 16.04, and with the latest CUDA.


Why are my beignets hollow?

Question: Can anyone explain what's going wrong with my beignets? The first time I made them they were perfect. Since then they've come out completely hollow. Like just a shell with nothing at all inside. As far as I know I'm doing everything the same, and I'm using the same recipe as it's written. I switched brands of yeast after the first hollow batch happened, then the next two batches did the same. What causes this? This is the recipe I'm using(which worked great the first time) https://addapinch.com/beignets-recipe/
Comment: Hmmm.  Maybe try rolling it out a bit thicker?  1/4 inch seems pretty thin for beignets; try making it about twice as thick?
Comment: Rising at 90F?  Seems like Megha may be on to something ...
Comment: It's a yeast dough, right?  could there have been a difference in temperature, which would affect the dough's proofing?  I mean, I've seen something similar in bread, when it's more holes than loaf...  Or even a temperature difference in the frying oil, might make a difference in the, um, equivalent of oven-spring aka how much it puffs up when exposed to the heat... more puff mean more air, less beignet inside.
Comment: @FuzzyChef  Yes, I've tried thicker. Same thing happened. Thing is, they came out perfect the first time and I've followed the recipe the same every time(well, obviously I haven't)
Comment: @Megha There does seem to be an awful lot of air. It rises quite large and when I pull a piece of dough off , the rest collapses. I don't think it did that the first time I made them. I've been putting the covered dough outside on a dark part of my porch to rise. It's been about 90 degrees. Maybe I should keep it inside. But it just worked so well the first time. They were some of the best beignets I've ever had, and I live in New Orleans.
Answer: I had the same problem too, and thought that I was going crazy because I've tried so many different recipes and always end up with hollow beignets!
What I eventually found out was that when I fried my dough in lower heat, the longer time allowed the dough to expand more, which resulted in bigger, puffy, hollow beignets.
When you cook them in medium heat, the quicker frying time allows the heat to expand just the outside and a little bit in the center- this is what makes it less hollow and more pillowy.

Why are my beignets hollow?


How do I protect this function from SQL injection?

Question: public static bool TruncateTable(string dbAlias, string tableName)
{
    string sqlStatement = string.Format("TRUNCATE TABLE {0}", tableName);
    return ExecuteNonQuery(dbAlias, sqlStatement) > 0;
}
Comment: Who is allowed to call TruncateTable?
Comment: Not at all.  You need to use parameterized queries to be sure.  http://www.c-sharpcorner.com/UploadFile/puranindia/ParameterizedQuerySQLInjectionAttacks08102009011903AM/ParameterizedQuerySQLInjectionAttacks.aspx
Comment: I would not in general allow a user interface to call truncate table! If you need to do this, you most likely have a serious design flaw.
Answer: The most common recommendation to fight SQL injection is to use an SQL query parameter (several people on this thread have suggested it).
This is the wrong answer in this case. You can't use an SQL query parameter for a table name in a DDL statement.
SQL query parameters can be used only in place of a literal value in an SQL expression.  This is standard in every implementation of SQL.
My recommendation for protecting against SQL injection when you have a table name is to validate the input string against a list of known table names.
You can get a list of valid table names from the INFORMATION_SCHEMA:
SELECT table_name
FROM INFORMATION_SCHEMA.Tables
WHERE table_type = 'BASE TABLE'
  AND table_name = @tableName

Now you can pass your input variable to this query as an SQL parameter.  If the query returns no rows, you know that the input is not valid to use as a table.  If the query returns a row, it matched, so you have more assurance you can use it safely.
You could also validate the table name against a list of specific tables you define as okay for your app to truncate, as @John Buchanan suggests.
Even after validating that tableName exists as a table name in your RDBMS, I would also suggest delimiting the table name, just in case you use table names with spaces or special characters.  In Microsoft SQL Server, the default identifier delimiters are square brackets:
string sqlStatement = string.Format("TRUNCATE TABLE [{0}]", tableName);

Now you're only at risk for SQL injection if tableName matches a real table, and you actually use square brackets in the names of your tables!
Comment: Validate against know possible inputs. +1
Comment: The OP should also consider the possibility of two or more tables  having the same name but belonging to different owners/schemas.
Comment: I think a lot of people forgot that you can't use parameterized queries with this type of query. Good observation.
Answer: As far as I know, you can't use parameterized queries to perform DDL statements/ specify table names, at least not in Oracle or Sql Server. What I would do, if I had to have a crazy TruncateTable function, that had to be safe from sql injection would be to make a stored procedure that checks that the input is a table that is safe to truncate.

-- Sql Server specific!
CREATE TABLE TruncableTables (TableName varchar(50))
Insert into TruncableTables values ('MyTable')

go

CREATE PROCEDURE MyTrunc @tableName varchar(50)
AS
BEGIN

declare @IsValidTable int
declare @SqlString nvarchar(50)
select @IsValidTable = Count(*) from TruncableTables where TableName = @tableName

if @IsValidTable > 0
begin
 select @SqlString = 'truncate table ' + @tableName
 EXECUTE sp_executesql @SqlString
end
END

Answer: If you're allowing user-defined input to creep into this function via the tablename variable, I don't think SQL Injection is your only problem.
A better option would be to run this command via its own secure connection and give it no SELECT rights at all. All TRUNCATE needs to run is the ALTER TABLE permission. If you're on SQL 2005 upwards, you could also try using a stored procedure with EXECUTE AS inside.
Answer: CREATE OR REPLACE PROCEDURE truncate(ptbl_name IN VARCHAR2) IS
  stmt VARCHAR2(100);
BEGIN
  stmt := 'TRUNCATE TABLE '||DBMS_ASSERT.SIMPLE_SQL_NAME(ptbl_name);
  dbms_output.put_line('<'||stmt||'>');
  EXECUTE IMMEDIATE stmt;
END;

Answer: Use a stored procedure. Any decent db library (MS Enterprise Library is what I use) will handle escaping string parameters correctly.
Also, re:parameterized queries: I prefer to NOT have to redeploy my app to fix a db issue. Storing queries as literal strings in your source increases maintenance complexity.
Comment: Why didn't I think of that. While I'm at it, I'll just stop putting in all of those stupid bugs that I've been coding all these years. Also, genius, *deploy* can mean a lot of things - like going from local box to dev server. Interrupting other developers by rebuild/redploy to dev can be a pretty big disruption.
Comment: "Use a stored procedure" does not address the SQL injection risk.  It's just as easy to execute an unsafe dynamic SQL query in a stored procedure as it is in application code.
Comment: It can also be disruptive to deploy a new revision of a stored procedure.
Comment: If you don't want to redeploy, then do it correctly in the first place and test it.
Comment: Whatever. It addresses it as much as using parameterized queries does.
Answer: Have a look at this link
Does this code prevent SQL injection?
Remove the unwanted from the tableName string.
I do not think you can use param query for a table name.
Answer: There are some other posts which will help with the SQL injection, so I'll upvote those, but another thing to consider is how you will be handling permissions for this. If you're granting users db+owner or db_ddladmin roles so that they can truncate tables then simply avoiding standard SQL injection attacks isn't sufficient. A hacker can send in other table names which might be valid, but which you wouldn't want truncated.
If you're giving ALTER TABLE permissions to the users on the specific tables that you will allow to be truncated then you're in a bit better shape, but it's still more than I like to allow in a normal environment.
Usually TRUNCATE TABLE isn't used in normal day-to-day application use. It's used for ETL scenarios or during database maintenance. The only situation where I might imagine it would be used in a front-facing application would be if you allowed users to load a table which is specific for that user for loading purposes, but even then I would probably use a different solution.
Of course, without knowing the specifics around why you're using it, I can't categorically say that you should redesign, but if I got a request for this as a DBA I'd be asking the developer a lot of questions.
Answer: Use parameterized queries.
Comment: From a table name? Do you have some links to support this?
Comment: A strangely correct but poor answer.  A small example based on the OP code would be way better.
Comment: True, but people really should understand the dangers of letting ANY string be passed into a query without using parameterized queries.

I didn't have the time to write up a code example, but he should know about them.
Answer: In this concrete example you need protection from SQL injection only if table name comes from external source.
Why would you ever allow this to happen?
If you are allowing some external entity (end user, other system, what?)
to name a table to be dropped, why won't you just give them admin rights.
If you are creating and removing tables to provide some functionality for end user,
don't let them provide names for database objects directly.
Apart from SQL injection, you'll have problems with name clashes etc.
Instead generate real table names yourself (e.g DYNTABLE_00001, DYNTABLE_00002, ...) and keep a table that connects them to the names provided by user.

Some notes on generating dynamic SQL for DDL operations:

In most RDBMS-s you'll have to use dynamic SQL and insert table names as text.
Be extra careful.
Use quoted identifiers ([] in MS SQL Server, "" in all ANSI compliant RDBMS).
This will make avoiding errors caused by invalid names easier.
Do it in stored procedures and check if all referenced objects are valid.
Do not do anything irreversible. E.g. don't drop tables automatically.
You can flag them to be dropped and e-mail your DBA.
She'll drop them after the backup.
Avoid it if you can. If you can't, do what you can to minimize rights to other
(non-dynamic) tables that normal users will have.
Answer: You could use SQLParameter to pass in tableName value. As far as I know and tested, SQLParameter takes care of all parameter checking and thus disables possibility of injection.
Answer: If you can't use parameterized queries (and you should) ... a simple replace of all instances of ' with '' should work.
string sqlStatement = string.Format("TRUNCATE TABLE {0}", tableName.Replace("'", "''"));

Comment: you're right.  there are actually a number of things that need to be replaced (e.g. ' ; --, /* */ xp_, etc...) and thus my recommendation to use a parameterized query (or any other valid option, e.g. stored proc, ORM, etc...).  still, along with constraining the length of the string "tableName" ... this solution would probably work 100% of the time.


Built-in mic does not work in Ubuntu Mate 16.04

Question: Problem:
The built-in microphone does not work (sound recording, Skype, Video conferencing apps, etc.).
Although all the apps recognize the built-in microphone as "Built-in analog stereo", none of them can actually get any sound from it.
The microphone worked before on Kubuntu 15.04 and under Windows 7.
The interesting thing is that when I open the Sound settings and go to the 'Input' tab, I can see that the "Internal microphone" does not hear my voice, but it does hear a loud hand clap.
What I have tried:

Checked that the mic is not muted in sound settings.
Changed the "Input volume" to over 100% in "Sound settings > Input".
Changed the "Input volume" to over 100% in PulseAudio volume control (Input Devices).
Unlocked and muted one channel with pavucontrol.

Hardware/software:

Lenovo Thinkpad Edge E330 Ubuntu 16.04.2 LTS
uname -r 4.10.0-27-generic
MATE Desktop Environment 1.12.1
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VC Analog [ALC269VC Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
dmesg | egrep -i "sound|audio|snd"

9.393579] thinkpad_acpi: Console audio control enabled, mode: monitor (read only)
[    9.408050] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC269VC: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[    9.408053] snd_hda_codec_realtek hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    9.408054] snd_hda_codec_realtek hdaudioC0D0:    hp_outs=1 (0x15/0x0/0x0/0x0/0x0)
[    9.408055] snd_hda_codec_realtek hdaudioC0D0:    mono: mono_out=0x0
[    9.408056] snd_hda_codec_realtek hdaudioC0D0:    inputs:
[    9.408058] snd_hda_codec_realtek hdaudioC0D0:      Mic=0x18
[    9.408059] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x12
[    9.428090] snd_hda_intel 0000:00:1b.0: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
[    9.434521] input: HDA Intel PCH Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input8
[    9.434570] input: HDA Intel PCH Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input9
[    9.434614] input: HDA Intel PCH HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10

lspci | grep -i audio

00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
Answer: Not good having Pulseaudio levels above 100%, likely to cause audio distortion
Try checking ALSA level settings
alsamixer -c 0 --view capture
use spacebar to set capture for recording device
mic boost and capture level settings can be adjusted with arrow keys
Or use command:
amixer -c 0
for text output if you need more help finding settings


Single Page Website .htaccess

Question: Let's see if I can explain well the situation. I have a single page website with all the content in screen, but hidden. If, peg, you go to domain.com/product/about I'd take the first part to go to div-column "product" and div-row "about", with some Javascript and CSS positioning.
The problem: I need my .htaccess to rewrite all URLs (except index.html ofc) to index.html (or whatever URL we set).
The problem inside the problem: this webpage is in a subdirectory, and it could -probably- be in a second level subdirectory (that is, (root)/folder/subfolder/thisweb). Let's see with this last case, so it'll be easier to go up than down.
What I have:
RewriteEngine on
Options +FollowSymLinks
RewriteBase /folder/subfolder/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !^index.html
RewriteRule .* /index.html [L]

What happens:

domain.com/subfolder/foo: Redirects to domain.com/folder/subfolder/
domain.com/subfolder/foo/: The requested URL /er1csports/test/foo/ was not found on this server.

Playing around with other rules, sometimes I was redirected to parent's folder index.html. Just like if the RewriteRule didn't worked at all - JFYI.
What I need:

Rewrite, as I said, everything to index.html, without changing the URL in address bar - it shouldn't matter the sublevels of the URL (foo/foo2/foo3 should also rewrite to index.html).
Images, CSS, Javascript, resources in general, if they could be not affected with their URL and references it would be great.
Whatever the URL is, "folder" should never appear in the URL address bar. If I could be told how to hide too the "subfolder", if the rules applied were different in both cases, would be also great.

I know, a lot of things. But I hate .htaccess and I've been searching and messing around for hours and I've been not able to find it.
I'll keep on searching and trying, but what I don't want is to write 100 lines when there's a way to write only 10 and keep it clean.
Thanks a lot for your help and time!
Answer: Try using this code in .htaccess:
Options +FollowSymLinks -MultiViews

RewriteEngine on
RewriteBase /folder/subfolder/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule . index.html [L]

Comment: Above .htaccess will apply for URLs such as: `domain.com/folder/subfolder/foo` (your URL doesn't have `folder/` before `subfolder` However yes .htaccess present in parent folders will indeed change its behavior.
Comment: Hello! Thanks for your answer! Unfortunately, domain.com/subfolder/foo is not found, and redirects to domain.com/folder/subfolder/foo/. Maybe a .htaccess from pattern folders could be messing out things?

Single Page Website .htaccess


Render looks different to screen view

Question: Any quick thoughts why the render through camera viewport (right) looks completely different to the on-screen render (left)?
Comment: Brecht (original creator of Cycles) lists a couple of reasons here: http://blender.stackexchange.com/a/1189/47
Answer: Could be:

you have changed the "exposure" in the "Film" panel the Render Tab
and you have not re-rendered yet (i don't think is the case anyway)
there is a lamp, or a plane, or something that is hidden in the viewport but is still marked as
"rendered" as seen in the screenshot below:
Comment: Hmm I've worked out that it's something to do with a series of lights that I imported from a x3d file. When I turn them off both scenes go dark. But why the camera is affected more must be to do with its settings... Eg. exposure or focal length? Are there any other camera settings that might affect it?
Comment: I don't think that camera settings are involved, none of them can led to this overexposure, unless thera are someme "Custom Proprety" (that my be enherited from the x3d file...but I don't think so...more probable something to do with lighting..or the compositor). If you could upload your .blend filem, or a part of it, I'm quite sure we'll be able to give you a proper answer. Could you?

Render looks different to screen view


What size, spacing and baseline shift for tm and numerals in superscript?

Question: Is there a set formula / ratio for creating a trademark symbol (TM) or adjusting numerals such as 2nd or 3rd to create the proper visual effect on the superscript? Currently I always just eyeball it to make it look right. Is there a set standard for this though?
Answer: No.
It depends entirely on the font. Some fonts have the superscripting built in, others provide you with relatively full height glyphs. Among those that are predesigned, there are varying levels of optimization for varying point sizes. That last point is critical.
The principal considerations are:

Make sure the glyphs are legible (some go with the minimum here in all cases)
Align their optical top edge with the cap height or, with extreme cap to ascender differential, between the cap and ascender height.
Comment: Figured I would've known this 'golden ratio' by now if one existed... also figured it would make a nice question for this little Q&A we've got.
Comment: I wish there was a formula! You just have to find the right ratios for your most oft used typefaces and set up styles in your favorite app that can be imported.


How do I take this ratio of two means, then normalize according to another mean while maintaining a correct measure of spread?

Question: I have been trying to figure out how to correctly calculate the standard deviation for the ratio of two protein expressions as measured by ELISA, so that I may then run a hypothesis test, similar to this figure in this paper with the IL-1ra/TNF-alpha ratio. https://pubmed.ncbi.nlm.nih.gov/24013843/#&gid=article-figures&pid=figure-1-uid-0
I am seeing how expression of TNF-alpha and IL-1ra change according to two factors: the type of particle used, and the concentration of each particle. I have 2 particles, 3 concentrations each, therefore 6 treatment groups plus one contrl group.
I have 7 data sets of n=6 technical replicates each for the IL-1ra, 7 data sets of n=4 technical replicates each for the TNF-alpha. I am worried that it is incorrect just to divide the respective average concentrations and propagate their standard deviations. I additionally want to normalize these ratios according to percentage cell viability data that I obtained at each concentration.
Please let me know if this is the appropriate place to ask this question, or where else I could ask.
Comment: Welcome to Cross Validated! This is a good place to ask, but please provide a few more details. I understand your 7 groups (control and 6 particle-type/concentration combinations), but it's not exactly clear to me what the `n` represents. Does `n=4` for TNF-alpha and `n=6` for IL1-ra mean that completely separate experimental runs were done for analyzing each of TNF-alpha (4 runs) and IL1-ra (6 runs), or do those represent the number of technical replicates in a single experimental run? Please edit the question to provide that information; comments are easy to overlook and can be deleted.
Comment: Hi EdM, apologies for the confusion. I have edited the question to provide that information.  n represents the number of technical replicates in a single experimental run. Please let me know what other information would help. Thank you!
Answer: As best as I can tell, the paper you cite seems to report only errors arising from technical replicates based on a single batch of macrophages. Inference should be based on biological replicates. See the Technical Perspective on "Empowering statistical methods for cellular and molecular biologists" in Molecular Biology of the Cell 30: 1359-1368 (2019) for how to distinguish technical from biological replicates (depending on experimental context) and the danger of pseudoreplication when you rely solely on technical replicates. I trust that you will perform this experiment more than once.
That said, sometimes the results of biological replicates are illustrated with one example as in the figure you link, with a statement that the example is representative of a larger number of biological replicates. As it's (perhaps unfortunately) customary for reviewers to insist on (potentially misleading) p-values based on technical replicates in such a display, I'll provide some suggestions.
Your primary measurements of IL-1a and TNF-alpha can (in principle) be handled by analysis of variance with appropriate post-modeling comparisons among the treatments and control. The assumptions might not hold well if your data are similar to those in your linked plot, with errors evidently increasing with the values of the analytes.
Sometimes working in a log scale instead improves the situation, although then you would be modeling the means of the logs of the values (generally different from the logs of the means). That's similar, however, to reporting qPCR cDNA values in Cq or delta-Cq scales, logarithmically related to the actual amount of target cDNA in the sample.*
Think carefully about the specific comparisons you will perform after the modeling. There are 21 two-way comparisons possible among 7 experimental conditions, so if you do them all you need to make a large correction for multiple comparisons. The Technical Perspective noted above discusses that issue briefly.
For ratios/normalizations, be warned that the formulas for propagation of uncertainty are approximations that can be highly misleading, depending on the nature of the data. In your situation the technical replicates of IL-1a and TNF-alpha are presumably uncorrelated, which simplifies the formula for the IL-1a/TNF-alpha ratio.
I suspect that you will be better off working in a log scale for the ratios, as:
$$\log \frac{\text{IL-1a}}{\text{TNF-alpha}} = \log \text{IL-1a} - \log \text{TNF-alpha},$$
and (with no correlation) the variance of the ratio in the log scale is just the sum of the variances of the two analytes in their log scales.
The above doesn't address the problem of the statistical tests to use once you have variance estimates for the ratios. The best would be to use the variance estimates along with the corresponding Welch-Satterthwaite degrees of freedom, which are based on the numbers of replicates of each type and the standard deviations.
There is probably no need to adjust the IL-1a/TNF-alpha ratio for cell viability. There is no reason to expect that wells sampled for IL-1a differ in viability from those sampled for TNF-alpha, so a pooled viability estimate for each particle-type/concentration combination makes the most sense. If you correct each of IL-1a and TNF-alpha for viability, that viability factor cancels out in the ratio. If you think that you need to correct the IL-1a and TNF-alpha values individually for viability, then apply the principles outlined above for ratios.

*An alternative is ordinal regression, which only uses the rank-ordering of outcome values and can be considered a generalization of non-parametric tests like the Kruskal-Wallis test.
Comment: Thank you for the comprehensive answer! I wanted just some clarification on your last sentence. When correcting the IL-1ra and TNF-alpha values individually for viability using the principles outlined above for ratios, would this for example be correct? $\log \frac{\text{IL-1ra}}{\text{MTT Absorbance}} = \log \text{IL-1a} - \log \text{MTT Absorbance},$ Additionally, if I did do this, would there be an error associated with each individual data point of IL-1ra as I would be dividing by the average MTT absorbance over n=6 biological replicates of the respective concentration it is in.
Comment: @slatt the formula is certainly correct (although I worry about MTT as a "viability"measure ; see https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8657538/). Do incorporate the variance in MTT into the calculations. The formula for the variance of the ratio depends on whether the IL1a and MTT were done on the same wells or on different wells. If they were from the same wells, then use the formula for a [weighted sum of  correlated variables](https://en.wikipedia.org/wiki/Variance#Weighted_sum_of_variables). If not, the covariance is 0 and it's just the sum of the variances.


Accidentally deleted everything in home directory along with other important files

Question: Might be the worst mistake I've made in Ubuntu. To give some context: I created a directory named "~" by accident in the home directory. Didn't want it so I recursively deleted the directory. Next thing I know is that all my files in the home directory are gone, and I can't used commands such as gcc and apt. Is there a way I can recover from this, or should I just take the L and move on? Also might be good to note that I don't have sudo permissions.
Comment: No backups, I assume?
Comment: Or a recent install with Ubuntu on ZFS?
Comment: I'm in the 'take the L and move on' camp. If there's any data you can back up, go for it. If not, this is a very important lesson you learned, and you didn't even have to pay for a tutor! (The lesson being twofold - be careful when deleting stuff and have *working* backups.)
Answer: You did not state, but it looks like you recursively deleted ~ using a terminal command (e.g. rm -r ~). ~ expands to the absolute path of your home directory. What should have done what you wanted is:
rm -r '~'

Note the single quotes '. These tell the command interpreter, bash, not to try expanding the enclosed characters, so this would have removed a dile or directory named ~ in the current directory. Using an absolute path, the command would have been
rm -r ~/'~'

This explicitly refers to ~ in the home directory.
Directories and files are, indeed, effectively deleted. Recovering is not at all trivial where possible. So unfortunately, yes, these data are essentially lost, so it is hoped you have a good backup.


Why a circular camera lens captures rectangular pictures?

Question: I want to know how a circular camera lens captures a rectangular picture.
Moreover what will happen if the lens was rectangular.
I have tried a lot to think about it but i could not figure out anything.
Comment: It doesn't: as any large-format photographer will tell you lenses make circular images, called the 'image circle' of the lens.  Out of this image you take a rectangular chunk with your sensor.  If you have a large enough sensor or a small enough image circle you see a circular image.  If the sensor is far enough away from the centre of the image circle (this is a common problem for LF cameras with movements) you can see part if the edge of the circle.
Answer: In short, cameras produce rectangular pictures because the sensor is rectangular; the illuminated area is circular and some light is wasted off the edges of the sensor. In film cameras the sensor is the film, which is stored in a roll as tape, and making the frames bigger so they catch all the light would waste film. In digital cameras you could make a round sensor if you so desired, but the language of rectangular images is so deeply entrenched that no one does this.

Image source
Answer: Quite an interesting question... The important thing to understand is that the lens doesn't actually determine the shape of the picture that is produced. With any camera the lens only bends and focuses light onto a screen, which for olden day cameras are objects like films. The shape of the film actually determines the shape of the picture.
The lens in a camera is very similar to the human eye. The eye is circular and yet you don't see everything in a circular picture. Lenses can be different shapes like rectangles (as you mentioned) but these shapes are not as good at focusing light. This is why the eye, magnifying glasses and various other objects are round rather than square or rectangular
Answer: Per an earlier answer, a lens creates an image circle which is typically cropped by a smaller image sensor. The geometry of the image is then equivalent to the image circle.
If you use an image sensor that is larger than the image circle, the image will show up as a circle encompassed by a black image. This is common for 360 degree surveillance camera miniature m12 fisheye lenses.
The geometry of an image circle is based on the aperture and lens. Some lenses, like an 'anamorphic' lens, have an elliptical shaped image 'circle' which is created by cylindrically-shaped lens elements.
Comment: The link to your site doesn't seem to help answer the question, so I've removed it. Please read our policy on [self-promotion](https://physics.stackexchange.com/help/behavior).


"Imperial Japanese Navy" or "Japanese Imperial Navy"?

Question: Is it "Imperial Japanese Navy" or "Japanese Imperial Navy", and why?
Comment: As many questions do, this made me think of beer... and so out of curiosity I did some Googling.  Interestingly, "[Russian Imperial Stout](http://rogue.com/beers/imperial-stout.php)" and "[Imperial Russian Stout](http://www.stonebrew.com/irs/)" seem to be interchangeable.  Equally delicious either way.
Answer: Although @tchrist has given an excellent explanation for why it ought to be "Japanese Imperial Navy", searching for "Japanese Imperial Navy" auto-corrects to "Imperial Japanese Navy"... and even if you override that and re-correct to "Japanese Imperial Navy", the first hit is http://en.wikipedia.org/wiki/Imperial_Japanese_Navy.  Even the pages further down in the results, whose titles include "Japanese Imperial Navy", revert to "Imperial Japanese Navy" in their actual body text.  Further, the official (English) abbreviation is "IJN", not "JIN".
As for why, I suspect that the answer is twofold:
-  originally, an arbitrary choice on the part of some translator or other - perhaps employed by the Imperial court - that "stuck" and became official usage
-  in modern usage, to distinguish between the Japanese Navy of Imperial days and the modern navy, known as the Japan Maritime Self-Defense Force.
Comment: Perhaps the "Imperial" is qualifying "Japan" first, and then the resultant phrase "Imperial Japan" is qualifying "Navy".  That's why it ought to be "Imperial Japanese Navy".
Comment: @user6076 - Sounds reasonable to me; I can see an argument for it either way (although in fact it sounds more logical to me with "Japanese" in front.)  But yes: from everything I've read about Japan and Japanese society during those years, "Imperial" seems to have been foremost on everybody's mind.  I imagine it was much the same in Napoleon's France.
Answer: It's "Japanese Imperial Navy", not the other way around. This is due to adjective ordering restrictions.
See this paper by Alexandra Teodorescu for details various and sundry.
Comment: Adjective ordering doesn't apply to proper names.
Comment: @DavidSchwartz I didn't realize it was a pre-defined term.  If it is a pre-defined term, then why the question?
Comment: Is it obvious that the said term is pre-defined?


CI: Hudson with .Net vs CruiseControl.Net

Question: I work for a .net shop looking to integrate a CI server.  From what I've seen, Hudson seems to be the most popular choice.  Considering we are a .net only shop, will Hudson present any hurdles that CC.NET will not?
Comment: See also this CC vs Hudson question: http://stackoverflow.com/questions/604385; despite the "for Java projects" in the title, none of it is Java specific really. About Hudson & .NET, see this answer: http://stackoverflow.com/questions/616149/how-and-why-do-i-set-up-a-c-build-machine/616230#616230 To summarise: go with Hudson. :)
Comment: Consider adding .net as tag to your post
Answer: I cant think of a single thing that Hudson hasnt been able to do for our C# development, even with MSTest based tests, you can now run and trendgraph on them with the new plugin (only works if you are testing ONE assembly) or my method which works on multiple assemblies.
I suppose the only thing that would be nice, would be to generate code coverage data and report on that, not sure if CC.net does that.
Also, Hudson seems to have much stronger community support.  I've never heard of someone picking CC.net over Hudson if they had the choice.
We use it to

Deploy windows services
Deploy web services
Run MSTests & display as much information as any junit tests
Keep track of low,med,high tasks
trendgraph warnings and errors

These things may not be anything new to Hudson, but I felt the need to re emphasize that Hudson can handle this with a .net project, no problem.
Here are some of the built in .net stuff that Hudson supports

MSBuild
NAnt
MSTest (two methods, linked above)
Nunit
Team Foundation Server
fxcop
stylecop
compiler warnings
code tasks

Also, god forbid you are using visual source safe, it supports that as well. I'd recommend you take a look at Redsolo's article on building .net projects using Hudson
Comment: Well now you have met someone who prefers and chose CC.NET. I am one. CC.NET's community is great, I don't know Hudson's community but if it is that much better, then Great for you. I found the need to learn Java for my customizations my major impediment
Comment: You don't need to learn java to add build steps, I've written batch files as shown in my link above.  you can add executables as well.

How does the built in plugin support compare to this?
http://wiki.hudson-ci.org/display/HUDSON/Plugins
Comment: It compares favorably, most of that functionality is just in CC.NET, no need to do extra work. And what isn't I have no need for. I am not bashing on Hudson, it seems pretty good. I'd say they compare vary favorably. I can change the fundamentals though, not just add a plugin
Comment: In CC.NET you also have a client app (CC.NET Tray) which comes very useful to see what is the status of the project. On top of that you can also control the CC.NET server (like force build and stuff).
Comment: Cool, I'm pretty sure there are numerous ones in Hudson / Jenkins
Answer: Hudson is much easier for beginners. We use it to auto-build and pack C++ Builder dlls and exes. Think about that! It's not Java nor C#.
Comment: nice, yeah you could even setup hudson to build using jslint, heh
Answer: I know almost nothing about Hudson.  I will say that since CC.NET is based on .NET, it tends to have lots of built-in and community-contributed tasks and reports relating to the .NET ecosystem:
MSBuild
Visual Studio
NCover
NUnit
FxCop
etc. etc. etc.
So, if you use these tools, you should carefully check how well they are supported "out-of-the-box" by Hudson.   Also, if you end up having to write custom plugins (I have done a few for CCNET), it is usually advantageous to be able to use the development language and IDE that you use for "normal" development.
Comment: Why "Are you Serious?" Jeremy says he doesn't know Hudson, he is not saying that stuff isn't in Hudson. What are you questioning?
Comment: misread the message, cant edit the comment
Comment: Wow are you serious?  Hudson supports all of that out of the box via plugins except NCover and I think one is in the works. Anyway you can develop custom build steps as executables or just run dos commands, there is no need to know java whatsoever.
Answer: I've checked the hudson support for xunit testing frameworks a short summary is included below:

MBUnit/Gallio: There is a plugin but the development doesn't seems to be too active nor the community that use it. For example there is only one issue added. It was reported in reported in April and isn't touched yet (August). (Gallio team supports the plugin for CC.Net, their response time looks much better)
MSTest: Has the same problem. Has only two issues in the issue tracking system and an average response delay is 6 months. (It looks like CC.Net has native support for mstest but requires some configuration)
nUnit: The support for nunit in hudson seems to be quite good. The dev team is much more responsive and it also has more bugs reported (8 currently).

So I think I'm going to give the CC.Net a try.
Answer: I cannot fathom why a .Net developer would use a Java CI tool.
CruiseControl is a Java-centric tool a well.
This is why CruiseControl.NET was created.
.NET centric continuous-integration.
If you want to setup a tightly integrated system you will be writing your own plug-ins for the system to make it do exactly what you want.
e.g. Pull together all the version information you care about and then write out AssemblyInfo.cs files with the versions in them.


Can We Charge Maintenance Free Battery?

Question: My Honda Activa has an Exide maintenance-free battery, but the electrical starter is not working well. The battery is not getting a response, so can we charge a sealed battery?
Answer: Yes, all car batteries (secondary cells) are designed for charging. Only primary cells are those that cannot be charged, and such cells are not used in automotive applications. Consider this: the car alternator is continuously charging the battery, so what damage could you do by charging it with an external charger?
However, that said, if the battery is not just lacking charge but is dead, you may need to change the entire battery. Lead-acid batteries do not in general like to spend lots of time in a state where they lack charge. So, if the problem is not a recent problem but has been there for a long amount of time, the battery charging may not necessarily fix your problems.
Overall, it is much cheaper to recharge a battery than to replace it. So, I would give charging a try! If the charging fails to solve the problem, you may need to replace the battery.
Answer: "Maintenance Free" just means that you don't have to top it up with distilled water regularly. It's fine to charge it up - but I recommend you take it to a car spares store - they can test whether it's worth charging, or if the battery has just reached the end of it's life. If you can get the car there, they can also check if the alternator is OK - the two are connected, and if one fails, it often takes the other out.

Can We Charge Maintenance Free Battery?


How do I disable iCloud without losing all my photos?

Question: I foolishly enabled iCloud hoping that I could sync photos between my apple devices. However, I do not want the same photos on all my devices and I do not want ANY at all stored long term in my cloud. I had hoped I could delete the ones that were not wanted from individual devices. Can I do this, and if so, how? I can't find any way of manually deleting them from the cloud without them disappearing from my phone, or from my phone without them disappearing from the cloud.
If this isn't possible, is there any way to delete my iCloud without deleting all my photos?
Answer: In short, disabling iCloud should keep your photos on your device. To turn it off, navigate to "System Preferences" > "iCloud" and click the "options" button next to "Photos". Deselect "iCloud Photo Library" and "My Photo Stream" (as below).

Note: On iOS turn this off under the iCloud setting, not the Photos & Camera settings.

To answer the question

...is there any way to delete my iCloud without deleting all my photos?

Turn iCloud Photo Library off. I have tested this on my Mac and all my photos are still there. You can not delete iCloud because it is a service, not a place or thing. Hence you just stop using it.
If the Mail Man stopped delivering letters, you still get to keep the ones you already have.

Can I do this, and if so, how?

By definition synchronisation (sync) means to make the same. So iCloud will do whatever it can to make sure all your devices have the same content for everything. This is obviously not what you want.
However, there are three main parts to iCloud photos, not just the syncing bit.

iCloud Photo Library (the syncing one I assume you have enabled – a.k.a sync everything)
My Photo Stream (upload only new photos you have taken to all devices)
iCloud Photo Sharing (upload selected albums).

Think of these as three different services. You want to enable iCloud Photo Sharing so that you may select only the albums you want to keep in sync. As far as I'm aware, iCloud Photo Sharing does not store pictures in iCloud like the photo library does. It says below, this is for sharing with other people, but you can just add yourself when sharing the album.

To share albums
On Mac, select an Album you which to share, then click the share button. Click "iCloud Photo Sharing", then the big plus to add the album. Now just add yourself as a contact in the "invite people" section.
On iOS, there is a little cloud symbol at the bottom of the screen in the "Photos" app labeled "Shared". If it is empty, it will guide you though it.
Comment: Fair point @DAVincent. Thanks for the comment. Hope the changes above are helpful. You are welcome to edit.
Comment: Could we modify this by saying in place of "Turn iCloud Photo Library off. I just did it on my Mac", something that explicitly mentions the steps, similar to (I haven't checked this)  "go to System Preferences > iCloud > Photos > Options, and uncheck".  Maybe put the picture closer to that?


Finding the derivative of an integral using the Fundamental Theorem of Calculus

Question: How can I find the derivative of $$\int_1^x \sin (x+t) \,dt$$ using the Fundamental Theorem of Calculus? Thanks in advance!
Answer: If $T(x,y)=\int_1^x \ \sin\ (y+t)\ dt$, then $$ T_x=\sin\ (y+x),\
T_y=\int_1^x\ \cos\ (y+t)\ dt$$
Hence $$\frac{d}{dx}\ T(x,x) = T_x+T_y =\sin\ (2x) +\int_1^x \ \cos\
(x+t)\ dt$$
Answer: Let f(x) be a continous function. Let F(x) be the antiderivative of that function. The fundamental theorem of calculus tells you that $\frac{d}{dx}\int_a^b f(x) dx = F'(a) - F'(b) = f(a) - f(b)$. You have the case however where a or b are functions of x. In that case note that $\frac{d}{dx}F(g(x)) = g'(x)F'(g(x))$ by the chain rule.
Hence if $f(x) = sin(x+t)$, and $a,b = 1,x$ then your integral is $\frac{d}{dx}x * f(x) - f(1) = 1 * F'(g(x)) - sin(x+1) = 2sin(2x) - sin(x-1)$
Answer: Another approach is to use
$$\sin(x+t)=\sin x\cos t+\sin t\cos x$$
so your function is
$$\sin x\int_1^x\cos t\,dt+\cos x\int_1^x\sin t\,dt$$
Now differentiate each term using the product rule and the fundamental theorem.


php file child theme directory not overriding parent theme php file

Question: I am trying to customize the html in theme/woocommerce/layout-products/grid.php,
I have copied the file from parent theme to theme-child/woocommerce/layout-products/grid.php but without any effects.
From the answers I found here I understand that sometimes copying the php file works, sometimes not?
I also tried the require_once for this file but this breaks the whole WordPress.
How can I customize the product grid html?
Answer: That layout-products folder is not a folder from Woocommerce templates. This folder is a custom folder created by the theme you are using.
Try checking out how that template is loaded and see if it can be overriden.


Recommendation letters post master's

Question: I'm presently in a master's program. The program is much more relevant to the area I wish to do a PhD in (I switched majors from Bachelor's->Master's). I took two recommendation letters from my undergraduate institution to apply for master's, but the strong one was about a relatively unrelated subfield and I have not kept touch with the professor in question due to the switch. I'll be applying 3 years post undergrad. In this situation, can I forego the folklore rule of 1 letter of recommendation from an undergrad university ?
Comment: Hmmm. Never heard that folk tale.
Answer: I don't see much value in a letter from an old relationship that is no longer relevant. Your recent work will almost certainly be considered more heavily than anything you did as an undergraduate. (Extraordinary cases aside.)
Get letters from those who know your work and can make a (positive) prediction about your likelihood of success in the new program. That probably means professors and/or advisors from your MS program.
Comment: @FareedAbiFarraj You should probably include your degrees. Name followed by MA or MS (or whatever) is enough. You can include the field in parentheses in the signature area.

Recommendation letters post master's


Types of options trading and which is more popular

Question: For the average retail options trader do most buy options in the hopes of exercising it or do most buy options , resell and profit of the net of the premiums by doing so, much like buying and reselling stocks ?
Comment: You can look at [this answer](https://money.stackexchange.com/a/154462/109107) for a numerical example discussing early exercise and why it's mostly inefficient to do so.
Answer: Most of the time, it makes more sense to sell to close an option rather than exercise it because exercising early throws away the time premium. That's dumb money. If no time premium remains, it still makes more sense to STC the option rather than exercise because there is less slippage and fees.
If the option is in-the-money and the bid is trading below intrinsic value, it makes sense to exercise and close in order to avoid the haircut (assuming that you have sufficient margin as well as the appropriate trading privileges). If there is a pending dividend, this gets a bit more complicated and I'll leave it to you to research that.
When exercising to close a position, manage the risk with the correct order sequence (close the underlying first).
Answer: Exercising an option is almost always suboptimal. It may happen that inexperienced retail investors exercise options that they shouldn't but overall, you should at least understand the very basics of options before trying to buy options.
Ultimately, that's part of the reason why most retail option traders lose money. Options are complicated securities and not knowing what you buy / sell is usually a bad thing.
Answer: When purchasing options with the intention of exercising them, you must either have a substantial amount of cash readily available (for executing a call) or possess a significant quantity of unwanted stocks (for executing a put).
This situation typically arises when the market moves against an investor, catching them off guard. Thus, they buy options as a form of insurance, commonly referred to as hedging.
The majority of retail traders acquire options not primarily for hedging purposes, but rather as a form of extreme leverage due to the large price swings. Therefore, they typically refrain from exercising the options and instead focus on reselling them.


Possible?: Centronics to USB adapter to wireless router w/print server

Question: Is it possible to connect an old printer to a wireless router with a USB print server via a Centronics to USB adapter? Will this work?
Answer: My customers have had good luck with the "Cables To Go 6-Foot USB to Parallel Printer Adapter Cable".  It runs about $15 at major online retailer such as Tiger Direct, Provantage amd PC Connection.
Comment: So they have been able to connect their parallel printers to a USB router successfully? Any additional configuration problems?
Answer: What printer, what OS, what type of cable (a number would help)?
My first guess: no, because either the printer won't be able to receive whatever you send to it or the router won't recognize your printer being there.
Comment: Why not order a used Jetdirect card off eBay?  I see 3 for under **USD 15**.  No adapter cables, no driver issues (Jetdirect is mature), and you get to save your USB print server.
Comment: If you get the right drivers it MIGHT work
Comment: It is an HP Laserjet 5, my laptop has Vista Home Premium 64 bit and the desktop has WinXP SP2.
Answer: The USB Print server probably won't be able to handle the centronics->USB adapter. If it does...well you're in luck.
Answer: it could work. but there are some things making it more unlikely.
the print server may not be able to properly translate the request into the format the printer needs in order to understand how the document is supposed to look, and even if it did the centronics adapter may not relay the request in properly, as it may be using a propriety protocol between itself and it's device driver. the computer can get it, (possibly automatically as windows searches online for the driver as it always does when you plug in a usb device it doesn't have the driver for)
but the print server can't use a windows driver so it doesn't get clued in on the special way to talk to the printer and thus can't.
Answer: Despite the negative comments I see here, you can be confident about the converter and the printer working together. I use some without any problem. This is cheap equipment, but works well.
Note this is a USB to parallel, not parallel to USB.


Mac not updating from 10.8 to 10.10

Question: So I have a macbook air and it is stuck on the version 10.8 and I have checked app store for updates and I clicked on the apple logo and clicked software updates. It says I have none available when clearly there are newer versions out there. This prevents me from downloading some things because they require my version to be 10.10 or higher. Please help.
Comment: El Capitan should be the first banner item in the App Store. Unless you have previously purchased Yosemite, it is no longer available
Answer: You need to check inside the featured section of the Mac App Store because new versions of OS X do not always show up in the updates and you have to purchase it (the last three versions have been free) from the Mac App Store and install it. If 10.11 is okay, than that is still available in the App Store. It should be in the featured section or if you search, you will have no trouble finding it. It is only possible to get 10.10 if you purchased it while it is still available, in which case it would be in your purchased tab.

Mac not updating from 10.8 to 10.10


The case of the vanishing ™

Question: I moved from the United States a few years back. Recently, someone visited the U.S. and brought back some "junk food" that my family missed, including Milk Duds and Oreos. I was shocked to see that the stylized words "Milk Duds", "Oreo", and "Nabisco", forming logos, did not have trademark symbols next to them, nor was there any notice on the packaging that those things were trademarks. I'm pretty sure that, just a few years ago when I lived there, all such packaging had indication of trademark status. Did the law change since then? Can someone provide details, please? (Or maybe those three marks happened to lose their trademark status and are up for grabs?)
Answer: Trademark symbols
Such symbols and notices were never required. Many company lawyers thought that they helped make a stronger case for infringement actions if someone did infringe. And perhaps also that they would deter people from using the trademarks without approval, perhaps even in ways that were legal but that the company did not like. (Companies routinely claim more trademark protection than the law allows.)
Added, legal and source citations
[15 U.S. Code § 1111] provides](https://www.law.cornell.edu/uscode/text/15/1111):

Notwithstanding the provisions of section 1072 of this title, a registrant of a mark registered in the Patent and Trademark Office, may give notice that his mark is registered by displaying with the mark the words "Registered in U.S. Patent and Trademark Office" or "Reg. U.S. Pat. & Tm. Off." or the letter R enclosed within a circle, thus ®; and in any suit for infringement under this chapter by such a registrant failing to give such notice of registration, no profits and no damages shall be recovered under the provisions of this chapter unless the defendant had actual notice of the registration. emphasis added

This section was last revised in 1988, and dates originally from 1946
The US patent and Trademark Office (USPTO) publication Basic Facts About Trademarks (PDF) says (on page 9):

Each time you use your mark, it is best to use a designation with it. If registered, use an ® after
the mark. If not yet registered, use TM for goods or SM for services, to indicate that you have
adopted this as a trademark or service mark, respectively, regardless of whether you have filed
an application with the USPTO. You may only use the registration symbol with the mark on or
in connection with the goods/services listed in the federal trademark registration. However, no
specific requirements exist as to the precise use of the "®" symbol as to placement, e.g., whether
used in a subscript or superscript manner.  emphasis added

Added Analysis
I cannot find any provision of US law requiring use of the ® symbol or any of its equivalents. However failure to use it may reduce the damages available in the case of infringement.
I cannot find any provision of US law authorizing or requiring the use of the tm symbol. It appears to be a matter of common law, that is judge-made law, and a reference to court cases would be needed.
There have been significant developments in US trademark law in recent years, but mostly in the degree to which First Amendment concerns are being held to limit tr4ademark protections. I found no change in regard to the symbols, their use, meaning or effect.
Many countries, unlike the US, do not grant protection to trademarks unless they are registered, so the tm symbol is largely a US usage.
What Changed?
To the best of my knowledge, there has been no change in US law on this issue in recent years. I see lots of tm and ® symbols on everyday products. I just looked at the power supply for my laptop and it has a tm after the maker's name. I just looked at a candy bar wrapper and it carries an ®.  If there WAS a recent court case that changed the practice or influenced a change I haven't heard of it, and I've done some reading in recent major trademark cases. But I am not a lawyer, much less an IP lawyer, so I can't be sure.
Another possibility is that the comparatively large symbol adjacent to the large logo on the front of the package was removed, and a smaller logo, with symbol, was placed on the back of the package. That would probably give legal notice to any would-be infringer.
Comment: Thanks for the info! But this doesn't say what changed in the past few years.
Comment: @msh210 To the best of my knowledge, there has been no change in US law on this issue in recent years. If some companies have changed their practice, it is not  because of a change in the law. And many products continue to use the tm symbol on their packaging.
Comment: @msh210 sources citeed and quoted
Comment: Thank you. While you seem 100% correct that the ®'s not required, "in any suit for infringement... by such a registrant failing to give such notice... no damages shall be recovered... unless the defendant had actual notice of the registration" is doubtless why the ®'s always there. Or was. While you're answering the letter of my question, "did the law change", and I thank you, and +1, you're not getting at the heart of it. What _did_ change? (A local guest of mine who sees my Oreos & has never been in the States can now start an Oreo cookie company there, lacking "actual notice"?!) [continued]
Comment: [continued] Maybe there was a recent court case that interpreted that clause so as to put less of a proof burden on the registrant (so "actual notice" can be proven more easily)? _Something_ must've changed in the past few years.
Comment: @msh210 My guess is that the **only** thing that changed was the individual company policy of Nabisco. (but I have no source form that). I see lots of tm and ®  symbold on everyday products. I just looked at teh power supply for my laptop and it has a tm after the maker's name. I just looked at a candy bar wrapper and it carries an ®. By the way as for your friend, trademark protection is country-specific, so what is done outside the US is not affected by US law; also US law gives extra protection to "famous" marks, which OREO probably is.
Comment: @@msh210 If there WAS a recent court case that changed the practice or influenced a change I haven't heard of it, and I've done some reading in recent major trademark cases. But I am not a lawyer, much less an IP lawyer, so I can't be sure. You can look at my other answers on this site under the trademark tag.
Comment: (Milk Duds are not Nabisco's. They're Hershey's's. If it were one company that lacked the trademark symbol, I'd not have wondered so much, But it's two companies, both of which doubtless have good IP lawyers on staff (or retainer).)
Comment: @msh210 some internet searching for images of Oreo packages suggests that it's not consistent.  Some contemporary packages have the symbol and some don't.  Those that do don't use it for every instance of the trademark.  Older packages seem to show a similar inconsistency.

The case of the vanishing ™


What is Pointer Jumping ?

Question: Studying parallel algorithms for CLRS, old edition Chapter 30.  Can some one explain with a simple example what is pointer jumping and how exactly it works ?
Comment: [have you tried looking it up?](http://xlinux.nist.gov/dads/HTML/pointerJumping.html) If yes, what exactly is unclear?
Comment: I studied how it is used on a PRAM for List ranking problem. I could not undersstand 'why' it works? and also how it can be used to solve same problem of list ranking on a Interconnection network.
Answer: I really can't explain it better than Wikipedia does:
Suppose you want to traverse a tree. You can traverse it in a serial manner by walking the tree (either recursively or otherwise), or you can traverse it parallel by starting at $N$ leaf nodes and following the shortest path to the root.
In the serial case your running time will be $O(n\log(n))$.
$n$ is because you need to visit all $n$ nodes and $\log(n)$ because of extra time spend going up and down the tree because you can only reach sibling nodes via their parent.
In the parallel case your best running time will be $O(\log(n))$ or more accurate $O(\frac{n}{m}\log(n))$ where $m$ is the number of threads used.
You do this by assigning a leaf node to a thread and finding the shortest path to the root.
If you have more leaf nodes than threads you'll assign more than one leaf node to a thread.
Because the height of a tree is $\log(n)$ the running time per thread is obviously $O(\log(n))$.
This is not as efficient as can be, because the closer you get to the root the more nodes will get visited more than once.
You can solve this issue by having the first thread to arrive at a parent to leave a breadcrumb after which subsequent threads drop out.
If you elect to let duplicate threads drop out of the traverse, you also solve the problem of thread synchronization issues when altering data in the tree.

What is Pointer Jumping ?


Which is correct "The most tragic" or "the tragicest"?

Question: How should I say, "The most tragic" or "the tragicest"?
According to the rule, the second one is more preferable, but I have seen the first one as well as the second. So, is there any difference?
Comment: 'Tragicest' isn't a word? Making the first one correct.
Comment: Which rule are you referring to? Where did you come across "the tragicest" and why do you believe that is an English word even though it can't be found in a dictionary? [Wiktionary](https://en.wiktionary.org/wiki/tragic) is a good place to look because it shows you the comparative and superlative forms of a word.
Comment: What @Andy said. Offhand, I doubt there are *any* English adjectives ending in ***-ic*** that can be used with the comparative suffixes ***-er, -est***. On the phonological front, I guess I could just about tolerate ***homesickest***, but I'd much prefer ***most homesick*** anyway (and ***homesicker*** just sounds totally weird).
Comment: @FumbleFingers Take off the "home" and "sicker/sickest" sounds perfectly natural.
Comment: @Adam When this type of construction is used (e.g. intentionally making up a word or using a nonstandard form) there would usually be a *k* added, as in "tragickest", to fix the pronunciation. It's not exactly what I'd call a grammatical rule, since it's not really grammatical in the first place.
Comment: For what it's worth, if I saw "tragicest" without the word "tragic" nearby, I would assumes that it had a soft c sound - pronounced like the _-cest_ in _incest._
Comment: @Adam I'd go one further and assume it was a misspelling of "tragicist," even though that isn't a word, either--but at least it has a clearly inferable meaning of "one who writes tragedies."
Comment: Sure. Like _picnicking._  I am just saying that _tragicest_ is so wrong, it isn't even pronounced like _tragic._
Comment: @Adam Linguists call this a [*phonotactic*](http://phonotactics.anu.edu.au/intro.php) rule.
Comment: 1) I don't know where you heard this "rule" from, but throw out that source. That is very, very wrong. Whoever or whatever said something that wrong cannot be trusted for anything. 2) "Met" is the past tense of "meet". Meet: come into the presence or company of (someone) by chance or arrangement. You haven't *met* either of the two phrases. You've *seen* them. Perhaps you've *encountered* them. But you haven't *met* them. You meet people, not things.
Comment: The most Tragic....as such tragicest is not any word.
Comment: I'm not sure why this kind of question is so popular. Tragecist? So hard to proununce. And to me this is the first time I have ever heard of. I am sorry I had to downvote.
Answer: Most monosyllabic (1-syllable) adjectives seem to use -er/-est to form superlatives.
Most trisyllabic (3 syllables) or longer adjectives seem to use the "more/most" construction.
According to various grammar sites, there's no clear rule for bisyllabic adjectives, with some suggesting checking the dictionary to see if -er and -est forms are listed immediately after the root word (but I don't think that's great advice because one can publish a more consolidated dictionary by just leaving those forms out).
In this specific case, "most tragic" is clearly correct and "tragicest" isn't, but I have a hard time explaining any rule why, beyond deference to a dictionary.  The best I can offer by way of a generalizable test is this Ngram which shows "most tragic" in reasonably common use and "tragicest" not found in the millions of books Google indexed.  That strategy can be used to figure out which superlative form other adjectives typically take.
Comment: @C.M.Weimer: the historical reasons behind which words work which way are complicated; both word length and origins are certainly involved, but neither works as a definitive criterion.  The Cambridge Grammar of the English Language has (as usual) a very good detailed discussion of this.  But as a quick rule of thumb, number of syllables is pretty much as good as word origins, and is much easier to use in practice; it's recommended by for instance the [Oxford Dictionaries](http://www.oxforddictionaries.com/words/forming-comparative-and-superlative-adjectives) writers. [cont'd]
Comment: Just to give examples of some words with Latin origins (either via Norman French, or as later formations) that can take the *-er*, *-est* forms: *fine*, *sane*, *common*, *petty*, …
Comment: If this rule is correct it seems to illustrate the general principle that "languages are not logical", since Latin itself uses comparative and superlative endings (-ior/-ius and -imus/-ima/-imum), even for adjectives with irregular comparatives like bonus-melior-optimus.
Comment: @alephzero Languages are not logical indeed.  Here's a relevant question on that point I posted to EL&U just earlier today: [Phrasal verbs with synonymous opposites](http://english.stackexchange.com/questions/318871/phrasal-verbs-with-synonymous-opposites)
Answer: As others pointed out already, most tragic is the correct form.
One-syllable adjectives use the -er and -est endings, and three-or-more-syllable adjectives do not, but there is no good rule that describes two-syllable adjectives. Some two-syllable adjectives use the -er and -est endings, such as happy/happier/happiest and feeble/feebler/feeblest, but others do not, for example famous and boring.
Note that for many adjectives, it is not really well-defined whether or not the -er/-est forms are acceptable. Sometimes native speakers will disagree. For example, once I translated a story into English and used the word tenderer. Tenderer is in many dictionaries and is attested in literature, and some of my editors accepted it without hesitation, but others said that it sounded awkward and insisted that I revise it to more tender.
When in doubt, you can always use the more and most forms. People will definitely notice if you say boringer or famousest, and they might even think tenderer sounds out of place, but I doubt anybody will react if you say more happy, even though happier is more common.

I also wanted to point out that if tragic had an -est superlative form, it would be spelled tragickest, not tragicest. The c in tragicest would sound like an s, and to my ear it sounds like a portmanteau of tragic and incest, or perhaps the superlative form of tragice (which is not a word).
Consonants are often doubled when a suffix is added (e.g. big/bigger, bat/batting, pad/padded). Whether or not a consonant is doubled will often change the pronunciation and meaning (e.g. hater/hatter, riper/ripper).
The doubled form of c is ck. This can be seen in the difference between slicing and slicking, and in words like magic/magicked/magicking.


Recognize Morse-like code words

Question: In a line there're voltage levels representing words of dots and dashes. In particular, the device is intended to raise an output each time a given pattern of five short/long signals (say 1s and 2s durations, respectively) is recognized (and restart if nothing comes in for a given time). A sort of Morse code recognizer (Arduino Uno preferred, but others are also OK) would be a good starting point. Any hint is welcome, I'm new in this community.
Answer: Use a GPIO of an Arduino and check (at the speed you need) the HIGH/LOW state.
Depending on the speed at which is sent, you can check the dots and dashes being sent, e.g. by keeping a timer since the last change checking if it is a short or long 'HIGH'.
You have to sample often enough to check if there is a drop (between dots/dashes).
Comment: Is Arduino Uno the best selection to implement this device? Since it's going to be embedded (the smallest, the better), I would like to know the best fitting option.
Comment: There are many microcontrollers. Arduino is not the smallest or cheapest, but probably the easiest to program, especially if you are new to microcontrollers). There are smaller, like Arduino micro/nano etc, which also are not difficult to program.

There are also other (small) microcontrollers, even cheaper, but mostly those have a more steep learning curve, like PIC, STM8/32.

Recognize Morse-like code words


Should I switch to ART?

Question: ART has better performance and better battery life on paper at least.  Should I consider switching to it on my moto g? What are the results I can expect? What precautions should I take? Is it easy to turn back to dalvik?
Comment: It's about the same. Optimised Dalvik and ART are pretty much identical except some apps don't have ART support yet. Any differences I saw were completely placebo. Why not just try it sure and see... This is probably off topic as being opinion based.
Comment: @RossC What device you have?
Comment: S4 Google Edition, Nexus 4, 5 and 7 (2012 one) in terms of ART compatible devices. And a GTi9505 Galaxy S4 I sometimes run AOSP ROMs on.
Answer: Just try it by yourself. I've felt no real difference. Maybe it is something that is device specific or there is just a very small difference.
But it can change with Android 5.0 'L' because ART on Android 4.4 is some sort of beta version.
Switching to ART is as easy as switching back to Dalvik.
Settings > Developer Options > Select Runtime.

There you can choose ART.
You have to reboot your phone to apply the changes.
If you want to go back to Dalvik, redo the steps and select Dalvik.
Comment: @Chahk As it's ART that's still in beta, it would be fairer to say that it doesn't support all apps.
Comment: BTW how many apps we're talking about here? 1%?
Comment: It's worth noting that currently not all apps support ART, seeing how it's still in beta.
Answer: It's worth noting that rebooting after switching runtimes may take several hours - at least this has been my experience. This is because the ART recompiles all your applications.  It may even do it more than once if the process is interupted (e.g. due to battery drain)  - i.e it start over again at the top.
I'm hoping that switching back will be quicker since hopefully the compile step (unecessary for the Dalvik JIT) is what has slowed it down. I have not yet switched a device back to Dalvik so I'm not sure if this is correct or not.
Comment: Thanks for the heads up! Did you notice by how much your apps expanded in size after switching? Also, what about performance and battery life?
Comment: I did not see a noticeable size difference - mind you for the most part I am using things like Gmail, Youtube, and Chrome so they may be better suited for ART.

Should I switch to ART?


How to use 以 ... 為主grammar?

Question: I am a little bit confused about how to use  以 ... 為主 correctly in a sentence. Originally, I thought that it means "to put the main importance on ... ", but some people said that it has more tendency to mean "mostly". Can someone give an explanation about how this grammar is often used, or perhaps, the correct way to use this grammar? Thanks!
Answer: Both are correct, as they are essentially equal
Your thinking "...the main importance on..." implies there is more than one important thing but this one carries the most weight or mostly carried by it.
Comment: Ah, I see. But for example, if I want to say "Right now I am prioritizing the development of this field", I can say "我目前以此領域的發展為主", right? Because for some people , it's more towards "我目前比較看重此領域的發展". What do you think about this? Do you think that these two are essentially the same?
Comment: They are somewhat different. Your sentence sounds more definite and determined on the subject - the development of this region has the highest priority. The other sentence indicates the importance of the subject is only slightly above others - among things to do, I am focusing more on the development of this region.
Answer: You may translate it by "as ... being the most important", or "taking ... as the most important"

How to use 以 ... 為主grammar?