No notifications on iPhone 4 running jailbroken iOS 6.1.2

Question: I have recently been given an unlocked iPhone 4 GSM, upon which I have installed a jailbroken (but not hacktivated) iOS 6.1.2 using snowbreeze. Calling seems to work fine, as does everything except notifications. They appear to be turned on in the notification centre settings, but I never get any.  I am not using the Apple Mail app, but I have Gmail, Facebook, Twitter installed and connected.  Can anyone suggest how I might fix this?
Answer: It appears that this was caused by restoring an iCloud backup from a previous install which had been hacktivated. Notifications will not work with a hacktivated iPhone, and it seems as though they won't work with a restored iCloud backup of a hacktivated iPhone either.
The solution is therefore to restore the jailbroken image and set it up as a new phone. This will then activate with Apple's servers and notifications will work.


Inkscape - Merging Overlapping Nodes

Question: I would really appreciate some help with this little problem I have, it may only be a click away somewhere in a menu - perhaps someone can help.  The application I'm using is Inkscape and I'm trying to find a way to quickly merge the overlapping nodes of a single object.  Because the shape's nodes have been randomly jittered they are now overlapping each other - which is exactly what I want but not the white 'negative' spaces.  I would like to achieve the result shown on the right of the picture (this was done outside Inkscape using Photoshop) perhaps you can help?
Comment: Have you tried the fill-rule nonzero (see also [here](http://graphicdesign.stackexchange.com/questions/24705/how-to-avoid-white-spaces-when-crossing-pen-tool-lines-in-inkscape/24713#24713))?
Answer: Here is a simplified example of what we're trying to do:

Note that changing the fill rule will not give the desired results.

How to do it:

Make sure all objects in your design are paths.
If you have multiple objects in your design, choose "Path" > "Union" to merge them into one object.
Draw a filled rectangle entirely around your entire design path and choose "Object" > "Lower to bottom" to put the rectangle below your design path.

Select both the rectangle and your design path and choose "Path" > "Difference".

Select the resulting path object and choose "Path" > "Break Apart" to produce multiple path objects for each region of the design.

Using the select tool, click near the corner of the whole rectangle to select the rectangle object.
Delete the outer rectangle you just selected.

Select all the objects that are left over and choose "Path" > "Union".

Tested using Inkscape 0.48.4
Very cool question, by the way!
Comment: It seems so complicate: why not just apply the *non zero* [fill-rule](http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Attributes-Fill-Stroke.html) using the proper button?
Comment: @PaoloGibellini I added some screenshots to explain why changing the fill-rule is not a viable solution in this case.
Comment: Your solution allows to have a border of a different color.
Comment: @PaoloGibellini I added the border only to better illustrate the solution process. If you are implying that (besides the border issue) you still think a non-zero fill rule would be able to accomplish this task, I'd love to see you demonstrate it by adding an alternate answer to this question. I'm genuinely curious. Fill rule was my first thought too, but I couldn't get it to work for a case like this.
Comment: I have interpreted the question as the wish to have the object uniformly filled, and a fast way to achieve this result is changing the fill rule. Your solution is more complicate but also more comprehensive, because it leads to a new and more flexible object (and probably with less nodes). Which version of Inkscape have you used?
Comment: The problem is not related to Inkscape version. My first example (not posted here) was complex but the intersections between the lines didn't create the conditions (number of overlaps and kind of bending) for a "hole" (a negative space). Your solution seems to be the more general.
Answer:    0.  Initial path

Fill-rule: nonzero

Path union (Ctrl +, it works for one path as well)

Break apart (Ctrl Shift K)

Path union one more time (Ctrl +)
Comment: I like this approach, and I am able to replicate this solution process by drawing a path like yours. BUT this solution only removed 1 of the 3 holes in the path from my example solution. Your solution seems better for your example case because it is fewer steps. But it does not appear to remove all holes in all cases.
Comment: @SeanMadsen Indeed, my random path is not so random. In general case your surrounding rectangle helps a lot.
Comment: This solution seems faster, but doesn't work in some conditions, e.g. when the "hole" has at least two nodes in the external path. In this case after breaking apart you have "filled" paths connected by vertex, and no "not filled" path to merge using the union. For this case you can use @SeanMadsen method, with a few variants.

Inkscape - Merging Overlapping Nodes


Word for getting something or getting praised for something you don't think you deserve

Question: I've been struggling to find the word for this. Irrespective of whether the person actually deserves it or not, important factor being he thinks he doesn't deserve something he got or got praised for.
Comment: Please try to use it in a sentence. Here are some guesses, but I am not sure if any are really capturing what you are getting at: Unworthy?
Unearned?
Unmerited?
Ignoble?
Comment: Or it could be *modest, humble, self-effacing*...
Answer: That the speaker doesn't believe it can make them excessively humble or overly modest.
It's difficult to capture the emphasis on the speaker's belief in a word or two, but it should be obvious from the context.
It could simply be undeserved praise (Google 21,600 results). First hit:

I accepted the praise even though I knew I didn't deserve it. [...] am I guilty of accepting undeserved admiration.

Or unwarranted, unjustified, unmerited, unworthy (credit @InterstellarProbe).
Or inappropriate, disproportionate, excessive.
But this says nothing about whose perspective this opinion comes from (or whether it is accurate).
Answer: It could be,
unanticipated, unforeseen, unlooked-for
to express that the one recieving has not expected it. but that misses the point of him not thinking himself worthy.
Maybe in the verb you could do like:
"He was shocked by the unforeseen praise!"


How to update JTree elements

Question: I use JTree with TreeNode which extending DefaultMutableTreeNode.when I add new node,i cant update JTree.Any help will be appreciated
Answer: if you use DefaultTreeModel try to call its reload() method.
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
model.reload();

//or... model.reload(nodeUpdatedByYou);

Never use tree.updateUI() as this is a look and feel operation (although it works).
Answer: Actually, it is enough to reload the parent node. Internally,
public void reload()

is using
public void reload(TreeNode node)

but with root as its parameter, so, unless you are updating the direct root's leaf, you are better of using a more fine-grained version.
Answer: Adding to the node only is not enough, the Tree needs to be notified. The correct way to do this is to let the model take care of adding/removing nodes, as it will notify correctly the Tree on the way.
In case of a DefaultTreeModel (which should be the one used in the JTree if you haven't made your own TreeModel), you have the method insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index), which you can use.
Answer: Since Java use MVC to implement JTree component, your operation that add a node just change the model. Besides, you should notify representation of the tree some modifications have taken place. Try use fireTreeNodes*** methods of your tree model to notify the JTree object this kind of modification. Refer Java API for details. Good luck.
Answer: Are you using DefaultTreeModel?
If so, when adding use insertNodeInto API so that appropriate events are generated.
Comment: Buddy @Gnoupi - the down vote was uncalled for. We concurrently answered the question. I have seen in a few occasions that by the time I finish type my answer and post, a few new answers refresh.
Suit yourself.
Comment: you answered it half an hour later, with saying basically the same thing, that's not what I would call "concurrently". Like I said already, avoid duplicating, as it ultimately brings clutter. If an answer is already stating what you have to say, you can simply not post yours, or delete if if already posted.
Comment: Avoid duplicating answers, though, if you don't bring anything new.

How to update JTree elements


python : Conflicts leads Unable to correct problems, you have held broken packages error in 16.04

Question: I know python is already there when the Ubuntu is installed.
While, some other user used my machine has tried to install some other third party tools (eg : mockSSH etc) another version of the Python has been installed. And now some important softwares like meld is not there.
When I try to install them, it yells me Unable to correct problems, you have held broken packages..
Error :
me@my-pc:~$ sudo apt-get install meld
[sudo] password for me:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 meld : Depends: python:any (< 2.8)
        Depends: python:any (>= 2.7.5-5~)
        Depends: python-gi (>= 3.8) but it is not going to be installed
        Depends: python-gi-cairo but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I tried various ways (eg : fix broken, installing with aptitude, install custom packages etc) but nothing worked.
Eg :
1. Force Installing
me@my-pc:~$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic linux-headers-4.4.0-96 linux-headers-4.4.0-96-generic linux-headers-4.4.0-97 linux-headers-4.4.0-97-generic linux-image-4.4.0-31-generic
  linux-image-4.4.0-96-generic linux-image-4.4.0-97-generic linux-image-extra-4.4.0-31-generic linux-image-extra-4.4.0-96-generic linux-image-extra-4.4.0-97-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Installing with aptitude

me@my-pc:~$ sudo aptitude -f install meld
The following NEW packages will be installed:
  meld python:i386{ab} python-cairo{a} python-gi{a} python-gi-cairo{a} python-minimal:i386{a} python2.7:i386{a}

python2.7-minimal:i386{a}
      0 packages upgraded, 8 newly installed, 0 to remove and 1 not upgraded.
      Need to get 2,447 kB of archives. After unpacking 8,988 kB will be used.
      The following packages have unmet dependencies:
       python : Conflicts: python:i386 but 2.7.11-1 is to be installed.
       python:i386 : Conflicts: python but 2.7.13-1 is installed.
      The following actions will resolve these dependencies:
     Keep the following packages at their current version:
1)     meld [Not Installed]
2)     python:i386 [Not Installed]
3)     python-cairo [Not Installed]
4)     python-gi [Not Installed]
5)     python-gi-cairo [Not Installed]

     Leave the following dependencies unresolved:
6)     python-minimal:i386 recommends python:i386

Accept this solution? [Y/n/q/?]
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

When I check for python it lists these.
me@my-pc:~$ python
python             python2.7          python2-config     python3.5          python3.5m         python3-config     python3m-config
python2            python2.7-config   python3            python3.5-config   python3.5m-config  python3m           python-config

My problem is, how to fix these broken packages and install the python as it should be?
Comment: It would be better if you known which software was installed before package breakage (see `/var/log/dpkg.log` for packages). Also you can try graphical `aptitude` mode (`sudo aptitude`). Select *Actions | Cancel pending actions* and then *Search | Find broken* (or ) then carefully follow aptitude's recommendations.
Comment: Thanx Nornert. I got the answer. This was also helpful.
Answer: I got the solution
Since it says there's a conflict I tried to install the python_2.7.11-1 via deb.
sudo dpkg -i python_2.7.11-1_amd64.deb

There I got below problem.
dpkg: regarding python_2.7.11-1_amd64.deb containing python, pre-dependency problem:
 python pre-depends on python-minimal (= 2.7.11-1)
  python-minimal is not installed.

So, I tried to install python-minimal.
sudo apt-get install python-minimal

WIth that it set up all the related things.
And I tried sudo aptitude install meld and it worked!
Thanks all for the support!


word 2016 omml to mml equations

Question: I have several documents in word 2016 with a few hundred equations written in the native word equation format (i think it is omml). I want to convert every equation to mathml. what is the quickest way?
I have already installed mathtype but it says omml2mml.xsl missing. Even after locating the file and putting it where the mathtype website said, it is showing same error. How to fix it?
Answer: There exists an open source framework called transpect.
It's purpose is conversion of complete documents from and to individual formats. (docx, TeX, html...)
Among others, docx files are supported as input:
https://github.com/transpect/
If you have git or svn installed, you can simply follow this guide for a basic setup:
http://transpect.github.io/getting-started.html
The guide describes converting the whole docx document into hub.xml (basically docbook+css).
Both, MathType and OMML equations are translated to MathML during conversion.
You can simply extract the mml:math elements from the hub.xml, using any tool you like.
There exist more transpect modules, to convert the hub.xml to your desired format completely.
That requires more time for setup, so it depends on what you intend to do with the results.
Background
The old Word Equation Editor was built upon MathType.
The new Word Equation Editor is based on OMML.
A MathType-Equation is displayed as an image in Word.
If you have MathType installed, a separate window opens if you click to edit the equation.
Else, you cannot edit it.
New equations (OMML) can be edited directly inside the Word software.
OMML and MathML are both XML-formats.
omml2mml.xsl is a file provided by Microsoft to go from OMML to MathML.
transpect uses a modified variant of it, because the original file has several flaws.
(There also exists mml2omml.xsl, to go from MathML to OMML)
MathType uses a non-XML-structure for its equations.
MathType can import MathML equations, but not OMML.
MathType therefore requires the omml2mml.xsl file to generate MathML first.
On a side note, MathType does not always preserve character styles (bold/italic) when exporting to MathML/TeX.
To support all equation-types in Word, and to improve the performance of conversion, transpect is able to translate MathType to MathML.
For your info: I am a contributor to the transpect project.

word 2016 omml to mml equations


Token-based authentication - Securing the token

Question: I have developed a backend REST API for a mobile app and I am now looking to implement token-based authentication for it to avoid having to prompt the user to login on every run of the app.
What I had in mind was on the initial request the user sends their credentials using Basic authentication over SSL. Once the server authenticates the credentials it creates a secure token and sends it back to the user so they can use it in subsequent requests until the token either expires or is revoked.
I am looking for some advice as to how I can generate a token which won't be susceptible to things like MoM/Replay attacks as well as ensuring the data stored within the token cannot be extracted out.
I am going to use the following approach to generate the token which I think would prevent any data from being extracted from it. However, I still need to make sure it's not vurnerable from other attacks.
The API will only be accessible over SSL but I am not sure if I can rely solely on this from a security perspective.
Comment: Be very careful with writing your own session management mechanism (which is essentially what you are proposing). There are dozens of common errors that inevitably occur in every new session management mechanism, which will affect yours, too. You should seriously consider how you can use an existing mechanism instead of rolling your own
Comment: @MikeWeller OAuth is probably the universal solution to this problem, however, time constraints & complexity of development is where it falls down. Also, OAuth is probably a little bit overkill as there are no plans to open the API up to 3rd parties at the moment. The sort of token-based system I want to implement isn't far off what OAuth does, it's more like Twitters version of [XAuth](https://dev.twitter.com/docs/oauth/xauth) whereby you skip the whole login request part.
Comment: What about OAuth?
Answer: The "authentication token" works by how the server remembers it.
A generic token is a random string; the server keeps in its database a mapping from emitted tokens to authenticated user names. Old tokens can be removed automatically in order to prevent the server's database from growing indefinitely. Such a token is good enough for security as long as an attacker cannot create a valid token with non-negligible probability, a "valid token" being "a token which is in the database of emitted tokens". It is sufficient that token values have length at least 16 bytes and are produced with a cryptographically strong PRNG (e.g. /dev/urandom, CryptGenRandom(), java.security.SecureRandom... depending on your platform).
It is possible to offload the storage requirement on the clients themselves. In the paragraph above, what "memory" should the server have of a token ? Namely the user name, and the date of production of the token. So, create your tokens like this:

Server has a secret key K (a sequence of, say, 128 bits, produced by a cryptographically secure PRNG).
A token contains the user name (U), the time of issuance (T), and a keyed integrity check computed over U and T (together), keyed with K (by default, use HMAC with SHA-256 or SHA-1).

Thanks to his knowledge of K, the server can verify that a given token, sent back by the user, is one of its owns or not; but the attacker cannot forge such tokens.
The answer you link to looks somewhat like that, except that it talks about encryption instead of MAC, and that's:

confused;
confusing;
potentially insecure;

because encryption is not MAC.
Comment: +1 This is more along the lines of the type of answer I am looking for, thanks. You mention that the proposed solution for generating tokens is potentially insecure and I understand why (if it's encrypted there is the possibility for it to be decrypted). However, it's encrypted using the machine key of the server ([see here](http://support.microsoft.com/kb/910443)) so am I right in saying it's secure as long as my server is physically secure and no-one get's a hold of the decryption key?
Comment: For the record, the standard ASP.NET functionality linked in the original question does involve a MAC. The method name, Encrypt(), is misleading.  What it actually does includes both an an HMAC (with SHA256) and encryption (with AES).
Comment: @James: what I mean is that the authentication token is secure as long as the attacker cannot build a fake one. Encryption does not protect against that. For instance, if using a stream cipher like RC4 (data is encryted by XORing with a key-generated pseudorandom stream), it would be trivial for a user to authenticate under his name, then fiddle with the bits to make a new valid token with another name of his choosing (as long as it has the same size as his name) (and I have seen that in a deployed banking system !). Really, if you need integrity, use a MAC.
Comment: Based on your comments here is what I am doing (server-side). Generating a secret key of 256 bits using a [.NET RNG](http://msdn.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx). Then generating a HMAC using [SHA12](http://msdn.microsoft.com/en-us/library/system.security.cryptography.hmacsha512.aspx) of the username + creation date of token (using the secret key). Then finally, generating a final HMAC of username + creation date + HMAC(username + creation date) again using secret key. Does that sound about right? I can post code if need be.
Comment: @ThomasPornin Thank you for a very good answer. When you say that "It is possible to offload the storage requirement on the clients themselves", does it mean that the server does not need to store any information whatsoever of issued tokens? As a token is signed by the server itself and carries all relevant information (username and expiration), the server does not need to query its database to tie the token to a user and check for expiration - all data is available in the token and cannot have been altered if its signature is checked. Correct?
Comment: @JanusVarmarken: yes, that's the point. The token contents are all that the server needs to "remember", and since there is a MAC, the server can be content with not storing any per-token data, just the unique MAC verification key. Hence, no database at all! Note that such a setup implies a few restrictions: the client can omit to send back the token and thus claim to be new; similarly, the server cannot forcefully invalidate a token, since the server has no stored notion of what tokens have been issued. Usually, such client-side tokens are managed with a timeout policy.
Comment: Ah ok I see what you mean. So in terms of storage would you say it would be safe to store the token as it is generated or should that also be salted using a MAC?
Comment: "*salted using a MAC*" - think that should say *keyed* not salted. Also, is it reasonable to to store the secret in the database along with the token? Similar to how you would store a salt?
Comment: @James: the MAC is there for storage on the client (as a cookie), to prevent forgeries without having to remember client-specific state on the server. As long as you store on the server, there is no need for a MAC.
Comment: The tokens will be stored both client + server side. From the client-side point of view this will probably be in a file stored in the app settings to allow the users to be automatically logged in without having to re-authenticate. For the server side, the tokens will be stored in the database.
Comment: @ThomasPornin You said the token should be stored in the database. Would it not be better just to store the MAC of the token in the user sql table?
Comment: May the secret key K be a private RSA key? Or it really should be a PRNG? This key K must be unique for each token or it can be the same for all tokens generated by the server?
Comment: @Elisa the token is already a HMAC and that's what you would store.
Comment: @Plinio.Santos I think an RSA key would be fine, I imagine it's just as secure as a PRNG key, the important points of the key is A. it can't be replicated easily & B. it's kept secret. The secret key has to be distinct per user otherwise all users would also have the same public key and there would be no distinction between user tokens.
Answer: In short, you should use a cryptographic strength one-time random token, and hash it in the database.
The token

must be allowed to be used only once,
must only be usable for the user it was created for,
must only be sent via HTTPS,
should have an expiry date (e.g. 7 days).

Once the user logs in with the token, it is invalid and a new token should be created and given to the user. In the case of an expired token, the user must be made to log in again, using their real credentials.
A more definitive and lengthy description of these rules can be found in part 2 of The Definitive Guide To Forms based Website Authentication:

Persistent Login Cookies ("remember me" functionality) are a danger zone; on the one hand, they are entirely as safe as conventional logins when users understand how to handle them; and on the other hand, they are an enormous security risk in the hands of most users, who use them on public computers, forget to log out, don't know what cookies are or how to delete them, etc.
[...]
Follow Charles Miller's 'Best Practices' article. Do not get tempted to follow the 'Improved' Best Practices linked at the end of his article. Sadly, the 'improvements' to the scheme are easily thwarted (all an attacker has to do when stealing the 'improved' cookie is remember to delete the old one. This will require the legitimate user to re-login, creating a new series identifier and leaving the stolen one valid).
And DO NOT STORE THE PERSISTENT LOGIN COOKIE (TOKEN) IN YOUR DATABASE, ONLY A HASH OF IT! The login token is Password Equivalent, so if an attacker got his hands on your database, he could use the tokens to log in to any account, just as if they were cleartext login-password combinations. Therefore, use strong salted hashing (bcrypt / phpass) when storing persistent login tokens.

Update: Sorry, I misunderstood the question. The method you linked looks reasonable, but it won't protect you from replay attacks or man-in-the-middle. You should use SSL alongside it.
Comment: "*cryptographic strength one-time random token*" would you say the approach I linked to is secure enough for this? "*Once the user logs in with the token, it is invalid and a new token should be created*" Not quite sure if I understand how that would work. Are you saying tokens should be invalidated/re-issued on a per request basis?
Comment: @James When the user comes to the site and does not have a session, the cookie token is sent to the server. The server validates it, creates a new session as the logged in user, and invalidates the token. It then gives the user a new token. The session identifies them whilst they're using the site, but when they close their browser (or the session expires) the user is no longer logged in. When they come back, they have no session, and the new token you gave them allows you to create a new session (go back to step 1)
Comment: @Polynomail There is no notion of a cookie, session or browser in my case. This is a REST API which is accessed via a mobile app.
Comment: @James Sorry, misunderstood the question. The mechanism you linked is fine for this kind of situation, but it will not protect you against replay attacks. You need to use something like SSL to prevent MitM / replay.
Comment: The API is running over HTTPS so is it safe to assume I wouldn't be vurnerable to those sort of attacks? I guess I am probably being overly paranoid, however, when it comes to security on the web I think it's a good thing to be like that!
Comment: Yup, you should be fine if it's over HTTPS and your client refuses invalid certificates / weak ciphers.
Comment: I have it validating the server certificate, however, I don't think I am doing anything with regards to the weak ciphers. Any advice on that?
Comment: Configure the client and server HTTPS implementations to reject weak ciphers and TLS downgrades. It's platform dependant, so you'll need to do some googling.
Answer: A pure RESTful API web service should use the underlying protocol standard features:

For HTTP, the RESTful API should embrace and comply with existing HTTP standard headers, status codes and methods. Adding a new HTTP header violates the REST principles.
RESTful services MUST be STATELESS. Any tricks, such as token based authentication that attempts to remember the state of previous REST requests on the server violates the REST principles.

Bottom-line: For authentication / authorization purposes, you should use HTTP authorization header. And you should add the specific HTTP authorization scheme header in each subsequent request that needs to be authenticated.
I have developed a RESTful web service for the Cisco Prime Performance Manager application. Search Google for the Cisco Prime Performance Manager REST API document that I wrote for that application for more details about RESTFul API compliance - see below.  For this application, we have chosen to use the HTTP "Basic" Authorization scheme to authenticate and authorize requests.  And obviously, we are using HTTPs to encrypt all the data in transit from the client to the server when using HTTP Authorization.
http://www.cisco.com/c/en/us/support/cloud-systems-management/prime-performance-manager/products-programming-reference-guides-list.html
Comment: If token based approaches are not allowed, doesn't that mean the client must store and resend the user's name and password on every request and determine when to invalidate them?
Comment: Couple of things - who said I wasn't utilising the authorization header? Token authentication is still stateless, the server remembers nothing beyond the current request - the token is simply used as a ticket to say "*hey, I've been before, he's the proof, so you can skip the authentication step*".


Arithmetic Sequence Word Problem

Question: . Lucy Ango'yuaq, from Baker Lake,
Nunavut, is a prominent wall hanging
artist. This wall hanging is called Geese
and Ulus. It is 22 inches wide and
27 inches long and was completed in
27 days. Suppose on the first day she
completed 48 square inches of the wall
hanging, and in the subsequent days the
sequence of cumulative areas completed by
the end of each day produces an arithmetic
sequence. How much of the wall hanging
did Lucy complete on each subsequent
day? Express your answer in square inches.
Answer: length of painting =27 inches
breath of painting = 22 inches
This shows that wall hanging is in a rectangular shape which is apparent from the diagram as well.
Therefore area of hanging = length * breath = 27*22=594 sq inches.
Hanging completed on first day = 48 inches,
since after first day she completed the Hanging in an arithmetic sequence on subsequent days.
Therefore area of painting left to complete after first day =594-48=546 sq inches,
Than also, days left= total days-first day = 27-1 =26 days.
So hanging completed by Lucy each day = total area of hanging reaming to complete÷days left
<code>                                 = 546 ÷ 26 = 21 sq inches a day
</code>

Arithmetic Sequence Word Problem


How can I add a fee programmatically?

Question: I know how to add a line item programmatically, but I can't seem to find a way to specifically add a custom commerce fee in PHP. Commerce fees seem to register in two locations in the order array: Once under commerce_line_items, and once under commerce_order_total (See attached image). They are different than a regular line item in that they don't show up as products, but rather in the order totals box at the end of the order.  The fee shown in the attachment is one that has been entered using the Edit form in the admin section. I need to add one in code. Any ideas?
Answer: What you're seeing is the commerce price component and the relevant line item that were added to the order. It gets added by the commerce_fees_apply() function from commerce_feeds.rules.inc.
So, if you're wanting to programmatically add a $5 fee to an order, then you can do so like this:
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$fee = commerce_fees_load('machine_name_of_fee');
commerce_fees_apply($order_wrapper, $fee, 500, 'USD');

Where 'machine_name_of_fee' would be the machine name of the fee that was created using the UI. Remember that the 3rd argument will be an amount and not a decimal. You'll also need to pass in the currency code. If you're wanting it to take the value of the currency code of the order, you could replace 'USD' with something like.
$currency_code = $order->commerce_order_total[LANGUAGE_NONE][0]['currency_code'];
commerce_fees_apply($order_wrapper, $fee, 500, $currency_code);

Comment: thank you so much! that makes sense. Although I get this error when called from my custom module:

`Fatal error: Call to undefined function commerce_fees_apply() in /Users/.../my_module.module on line 588`

How do I get my module to see that function?
Comment: You'll need to call `module_load_include('inc', 'commerce_feeds', 'commerce_fees.rules');`.
Comment: Thanks. Was missing the 'inc' part. It's loading now, but now I'm getting this error:
`Warning: Illegal offset type in isset or empty in commerce_fees_load() (line 168 of /Users/.../sites/all/modules/commerce_fees/commerce_fees.module).` That's the line for `commerce_fees_load` which appears to only require a string... which is what I'm giving it. I've also double checked that the machine name is correct. At any rate, thanks for the direction, I'll keep tooling away at why it isn't registering. (Also, you typed in "feeds" a couple of times... I assume you meant "fees".) Thanks!
Comment: OK for the life of me I can't figure out why `commerce_fees_load()` is returning an "empty" error. I've even called `$feeTypes = commerce_fees_get_types(); dsm($feeTypes);` to make sure that all my custom fee types are available, and sure enough they all appear with the correct machine names. If you have any other ideas, i'd appreciate it!
Comment: Does anyone know at what point fees get applied? When I apply them before sending the order through the checkout process, they don't seem to register.
Answer: If you stucked in why #1 doesn't work, you should try something like this:
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$fee = 'FEE_MACHINE_NAME';
commerce_fees_apply($order_wrapper, $fee, 500, 'USD');
$order_wrapper->save();

Good luck!

How can I add a fee programmatically?


New email envelop does not appear in notification area in Outlook 2010

Question: When an email is received, Outlook 2010 creates an envelop in notification area. But when my emails are moved by a rule to some folder other than standard inbox, I dont get a notification in system tray. Is there any way to fix this?
Answer: I have not been able to find a way to get the mail icon to work with sub-folders. So I have posted this work around in order to get a notification for those rules you have. Hope it helps for now.

In order to display desktop notification for rules which move incoming emails to specific folders, edit the rule which you are referring to. In the "actions" step where you select which fold it is moved to, scroll to the bottom. There you will find additional options for notifications. The last one is Display A Desktop Alert. Also, if you prefer, you can use the one above it to create a custom message.
Comment: That Desktop Alert is actually something different to the `notification area` (`system tray`) icon or the 'toast' popups.
Comment: @paradroid You are correct. I didn't clearify I was offering a work around. From what I found, the envelope icon only works with unread items in the Inbox, not in subfolders.
Comment: Yes.  See my answer for a fix for that.
Answer: It has been a long time since I encountered this problem, so I may be slightly wrong about the details but, if I remember correctly, that notification icon only works with emails arriving in the main inbox folder for the primary email address.  I did not get them for emails that were moved into other folders using rules, or for other address inboxes.
The solution I found to these Outlook deficiencies is Bettasoft Mail Alert, which provides a number of flexible options.  It costs $6.95, but there is a free trial.
Answer: Are you using large or small icons on your taskbar?  If you are using small icons, the notification does not work.


WorldWind wms services show reversed coordinate in ArcGIS Desktop

Question: I'm adding WorldWind wms services (http://data.worldwind.arc.nasa.gov/wms?) to ArcMap (ArcGIS 10.2.2) but maps are misplaced, looks like they have reversed coordinates (as explained here: http://viswaug.wordpress.com/2009/03/15/reversed-co-ordinate-axis-order-for-epsg4326-vs-crs84-when-requesting-wms-130-images/). Is there any workaround to get maps properly placed?
Answer: You seem to be right and server wants BBOX coordinates in lon-lat order even it claims that it is a WMS 1.3.0 server.
This brings the whole world from east to west
http://data.worldwind.arc.nasa.gov/wms?service=WMS&version=1.3.0&request=GetMap&layers=esat&CRS=EPSG:4326&BBOX=-180,-90,180,90&format=image/png&styles=&width=300&height=200
This request with standard compliant axis order does not http://data.worldwind.arc.nasa.gov/wms?service=WMS&version=1.3.0&request=GetMap&layers=esat&CRS=EPSG:4326&BBOX=-90,-180,90,180&format=image/png&styles=&width=300&height=200
However, the GetCapabilities document from the service is not valid. Server seems to support only WMS 1.3.0 but GetCapabilities has a root element which is used in WMS 1.1.1 WMT_MS_Capabilities version="1.3.0" Schema-aware clients cannot contact the service at all. Root element should be WMS_Capabilities version="1.3.0"
I don't know about ArcGIS, but with QGIS you can use the service by selecting "Ignore axis orientation" from server settings.


android webview or browser not deleting session cookies on device reboot

Question: When I am rebooting my android device (kindle fire) or kill an application, it seems like the browser or WebView 'session' cookies are not deleted. This seems to be quite different from the behavior of browsers on Windows or MacOS where 'session' cookies are gone if you kill the browser application. Only 'persistent' cookies should be persisted after browser process restart.
To clarify, the meaning of 'session cookies' here is a cookie set by the server with no expiration date, using http header in the response, such as:
Set-Cookie: mycookie=ifmr0846qcsdpeqqkgvuqmc5u7; path=/
Since no expiration date is specified, browsers typically don't persist those, keep them alive until the process is killed, based on my understanding. Typically session ids are set using this type of cookie.
I am convinced that those are not deleted on device reboot, or app restart because if I log in to my website, establishing a session (using non persistent/'session' cookie for the session id, named PHPSESSID in that case), then reboot the device and open the browser or WebView to the same url, I am still logged in, which means to me that the browser still sent the same PHPSESSID cookie that was set by the server before device reboot.
Could anyone explain/confirm this behavior for android WebViews or browser? How do they manage session and persistent cookies exactly?
thanks.
Answer:
You are correct, session cookies do not expire automatically in the
  lifecycle of a WebView. If you are seeing issues with this, you can
  always clear all of your cookies or overwrite your session cookies
  explicitly with an empty value.

reference : Lifecycle of a session cookie in an Android WebView / CookieSyncManager
to clear session use
<code>CookieManager.getInstance().removeSessionCookie();
CookieManager.getInstance().removeAllCookie();
</code>


to download samples the user should login or create an account first

Question:
i want to restrict the user so that if he wants to download the sample data he would have to login or create an account first otherwise he would be not be able to download the sample data.
Comment: How are you adding the link to the samples download?
Comment: just by creating downloadable product in magento create product option and adding the file there
Comment: you would need to override the template that loads the downloadable product link and then use the logic in my answer to display or hide the downloadable product.
Comment: can i prompt the user to login or create account first when the downloadable product is shown
Answer: To perform logic on the login status of a customer in a template use a helper class to detect if the customer is logged in
private $httpContext;

public function __construct(
    \Magento\Framework\App\Http\Context $httpContext
) {
    $this->httpContext = $httpContext;
}

/**
 * is logged in using CONTEXT_AUTH
 * @return boolean
 */
public function isLoggedIn()
{
    return $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);;
}

Depending on how you make your helper available to your template you can call the isLoggedIn() method and use it to display or hide content. Here I am using a ViewModel helper injected into the default Template block class.
$viewModel = $block->getViewModel();
?>

<?php echo ($viewModel->isLoggedIn() ? 'LOGGED IN':'NOT LOGGED IN')?>


Fast OS/filesystems/utilities to work with very large numbers of files

Question: I work (create, read, copy, delete, count the number of) with millions of files under Windows XP (and NTFS). Are there any other filesystems or OS better optimized for dealing with millions of files? Can you provide any suggestions on how I can significantly speed up things (say, copy/delete/count)? Any useful utilities?
Comment: Millions of files in a directory will kill pretty much *any* OS and/or filesystem.
Comment: So maybe the approach should be to store data in fewer files?
Comment: Or to use a hierarchy of folders to partition the files.
Answer: I use FAR Manager when dealing with large numbers of files.  It's ideally suited for this sort of task because you can set up filters to limit the number of files you see at one time:
  FAR Manager (free and open source)
  http://www.farmanager.com/
Both 32-bit and 64-bit editions are available, which is particularly important when dealing with really large numbers of files since 64-bit processing will yield a definite advantage for you.
Answer: Check DiskBoss.

DiskBoss is an automated, rule-based
  file and disk management solution
  allowing one to perform disk space
  utilization analysis, file
  classification and categorization,
  duplicate files detection and removal,
  high-speed file synchronization and
  data migration, disk change
  monitoring, rule-based file
  organizing, data wiping and much more.
Answer:
It sounds a design issue. You should
revise your solution.
Format your drive(s) with a lower
cluster size to save some space.
Total commander is a good
utility for this purpose. Maybe you
need to develop your own
business-oriented solution.
Comment: Regarding 1: I work with raw files produced in hundreds of thousands by mass spectrometers analyzing protein samples and with results of protein identification in these files. Maybe I should write to the major producers of mass spectrometers and to the developers of protein identification software that they should revise their solutions.
Comment: Odds are good that these software developers are interested in their customers feedback, and if you are paying for support, then this type of request should absolutely be submitted to them.
Comment: @Leo: So small data is not suitable to be written on file system. A database is more suitable here.


What is the correct word to the song that kept telling me its okay or that keep telling is correct

Question: Like something I've been listening for a year and want to express that the song was the one that keep me going and what should be the correct word for me to post with kept telling or keep telling what should i use?
Comment: "The song **has kept** me going all year.  It **keeps telling me** (or **has kept telling me**) that everything is OK."
Answer: You can say it kept telling me or it keeps telling me. (Not it keep telling me - that would not be grammatical).
If you say it keeps telling me, that says that you are still listening and receiving the message.
If you say it kept telling me, you are choosing to focus on your experience in the past. That suggests that you are no longer listening (or no longer getting that message), but it not necessarily saying so: you may still be listening, but you are choosing to talk about the past rather than the present.


Should I worry about cross-contact or cross-contamination inside food production factories?

Question: I live in Portugal. Here are some supermarket chains such as "Continente", "Pingo Doce" etc. They sell their own brand foods and also other brands' foods. For instance: Continente sells vegetable salads, vegetable sandwich, vegetable soups etc. They do NOT have "suitable for vegetarians" label. Their ingredient lists don't seem to have any animal-derived or Haram ingredients. But I have a concern. Do I need to know, whether there is any cross-contact (or cross-contamination) between vegetarian and non-vegetarian foods in the Continente food factories? What usually happens in these kind of factories?
Please help....
Comment: Why would you need to know? I don't see anything haram here except the meat if it's halal or not (slaughtered or not).
Answer: Bismillah Hir Rahmaan Nir Raheem
As Salaamu 3laykum,
I hope you are doing well. Its very important to make sure your food is not contaminated. I would ask the company itself as to how they package their foods. But in my opinion if they are packaging vegetable foods or using a conveyor belt then they would not have meats mixed with that. But you can always call them to find out.
Have a nice day!
Comment: Hi ... Thanks for your reply. May I know where do you live? What about Walmart in USA? Do you think contamination happens there? And, if the ingredients' list doesn't contain any animal derived or haram thing, does it mean that there is no cross contamination in the production line?
Comment: As Salaamu 3laykum, i hope you are doing fine. Yes, i live in the United States. I like Walmart lol. So I believe that many products will state that this product is used with other things like nuts, milk or something like that. I think you might have seen that on the back label of some products. I would call the company if you are in doubt.


arbitrage between currencies

Question: looking at the current prices of bitcoins in different currencies it seems as one could buy some in GBP and convert sell them to get USD, than convert those USD back into GBP and make some money. is it that easy? what am i missing? thanks!
Comment: Bank transfers are harder then you might imagine. Often your bank account will get shut down if you make too much money this way. Also fees and taxes and stuff. Other then that, nothing its like free money.
Answer: Make sure you are factoring in taxes and fees charges by the exchanges. Although, if you were to sell on localcoins it would be less expensive to transact in multiple currencies and you save on exchange/broker fees.
But it is basically that easy afaik. Just like any other currency trading (including forex) some currencies are worth more than others at a particular point in time.
You should also ask yourself if your method of transaction is fast enough to do this kind of trade and make the profit you expected
That being said, in the last few weeks people Have been buying XBT with USD and selling XBT for CNY at a premium and then converting that CNY to USD and making a nice chunk of change.
The reason for this is that Chinese citizens have limited access to USD and because most XBT exchanges transact in USD the Chinese can not buy XBT easily. Therefor the chinese pay a premium for their XBT.
What about trying your hand at alt-coin trading on a minimal investment... Say $10 USD. You can learn a lot about these systems of exchange, including where to get XBT cheaper.
XBT = BitCoin
Answer: What you are suggesting is called Triangular Arbitrage.
Some info are on the wiki page: https://en.wikipedia.org/wiki/Triangular_arbitrage
The idea is interesting and if the processus is faster enough it should be without any (or just few) risk.
It would be quite simple to automatize the processus of searching for necessary conditions and suggest to the user how to trade.
In the past I had the same idea and I found some interesting videos about this kind of trade on youtube, but I did not bookmarked them so I cannot link them now. I'll try to find them later.
Comment: Bitdango does exactly that (monitors all markets for triangular arbitrage). https://bitdango.com/marketpairs

arbitrage between currencies


Seeing a mirage through mirror?

Question: Okay, I am not really good in physics (rather terrible), but nonetheless.
So, I was just wondering if you can see a mirage, is there something special in our eyes that we can see it or what? I mean, if I am looking a mirage (or into a mirage or at a mirage, whichever is correct) and then instead of directly looking at it, I take a plane mirror and turn my around and look into mirror would I still see the mirage? How would the situation differ if I had a concave/convex mirror?
Comment: Mirage is an optical phenomenon. That doesn't imply something's fishy with ur eyes. If you see a mirage, you'd see whatever you do.

Whatever mirror you use, the situation would be just as you are seeing a real object.

Why do you think a mirage should behave differently?
Comment: @Cheeku:
I don't know man. I am terrible at physics. I was watching some sci-fi and it was about illusion and universe and what not, and they were like you `and it (the universe) looked at itself through mirror and found that the reality is just illusion, just like a mirage.`
Comment: Well, that was pure sci-fi then.
Comment: Vampires don't have a reflection in mirrors, right?
Comment: @b_jonas:
yeah, I've heard that, but is this really true? I mean if they were for real, (not the people who pretend to be Gothic and sh**) so will they not see themselves in mirror?
Comment: @Razort4x I'll let you know when I'm done counting the angels dancing on the head of my pin.
Answer: Since the mirage is an optical illusion, the mirror will not change thas effect. You are still using your optics while looking through a mirror. A mirror is simply reflecting your eyes back towards the mirage. A mirror will not change this effect. If you were to use say a camera or video-camera, then the results would be very similar. Overall the mirror will not change the outcome of the mirage.
Comment: So, how would the result differ if I was using a camera?
Comment: You see the mirage with your eyes, and the camera records it. In most cases the camera is just a tool to help you see and will not change the illusion of the mirage.
Comment: @JackMoody Didn't you mean to say instead : "If you were to use say a camera or video-camera, then the results would NOT be dramatically different"
Comment: a camera is inspired from our eye. a camera works just like our eye. so if you can see a mirage you can click a picture of it. search for some images and you will see.

Seeing a mirage through mirror?


Extending Object

Question: New to blender. Working on 3D printed prosthetic. One hand design we have has been scaled for a client. There is a certain part that falls about 1.5 inches to short. The diameter and circumference of the object need remain the same as other parts attach at both ends, but the object is 1.5 inches too short. I need to pull from one face out to elongate it. I do not want to scale it in the Y axis as it distorts the circumference and width. Is there a way to split the object up into cross sections and just extend further down one end? Any help would be appreciated as soon as possible. Thanks!
Comment: Edge loops? try a few of those then extrude
Comment: Select the faces on the end and hit [E].
Answer: This would seem pretty trivial to do. Start by going into the properties window (on the left) and into Scene (third icon in the ribbon) > Units. Select imperial. This will allow you to more accurately move things in inches (the exactly 1.5 inches you mentioned). In Edit Mode (hit tab to go to edit mode) select (By right clicking on the surrounding vertexes. Hold shift to select many) the face(s) you want to pull (from what I gather, correct me if wrong, this is the end of something cylindrical).  Next set your coordinates to local (Dropdown right below the 3D  View. By default it says "Global") . This will let you drag facess accurately and elongate the object without skewing it. Now there are two possibilities:

You are working on a simple cylinder that you don't want to scale along an axis, because it is rotated. Go to an orthographic view from top (numpad 7 followed by numpad 5, if you don't have a numpad, go to View > Top and View > View / Persp / Ortho). Next, grab the axis of the 3D manipulator that is in the direction you want to move the faces (most probably the blue Z axis) and after you have started dragging, press and hold shift and control. You can look below the 3D view to see how much the faces move.
You are working with a more complex shape and simply dragging faces would distort it. In this case you must add geometry to the object. With the faces selected, hit E to extrude and type ".15" (without the quotes) or "-.15" (without the quotes. This will create an extrusion from the faces you wanted with exactly a legth of 1.5 inches.

I hope this helps.

Extending Object


US patent appl. # us20140027014 is in violation of Laminar Technologies patent # 5842617

Question: An ex-employee has taken confidential drawings and designs and applied for a patent that infringes on our companies prior patents. What do I do to stop this?
Comment: I have no idea, but patents do not infringe other patents. Making, selling, importing and using a product are things that can infringe.
Answer: In google patents US5842617 for it says
<code>Date    Code    Event   Description
Jan 18, 2011    FP  Expired due to failure to pay maintenance fee
</code>
So the patent expired three years ago. They appear to be trying to solve related problems.


Hidden files on memory card

Question: I recently checked one of my memory card for space to add some video footage. The card had 11+GB of space, and is using 4.6 GB, but the video footage was 13GB. I was disappointed, as I was running low on available cards. I opened the card to see if I could move some of what was there to make space. There was one folder with, surprise, four documents. So, I was perplexed as to why four documents was using 4.6GB of space. I checked further and the folder (Files) was in fact using only 13.6 MB of space. So there was something else on the card that was hidden. I "unhide", and there were three more files: .fseventsd, .Spotlight-v100 and .Trashes. The .Trashes had 4.6GB of stuff (trash).
My questions: Why are these files hidden, and why is there a file with Trashes still on my card taking up all that space? Should I delete it? can it even be deleted?
Any help with this issue is appreciated.
Thanks...
Answer: When you send something to the Trash in the Finder, it gets moved to the <code>.Trash</code> folder on the disk. If you want to delete it, you have to empty the Trash.
If you want to delete the files inside the Trash folder, then you can delete them. Don't delete the .Trash folder itself.
The Spotlight file is, as you can guess, a file relating to the Spotlight index. The .fseventsd folder is also part of the file system, relating to file changes on the disk.
You should not delete the Spotlight folder, nor the fseventsd folder.
Comment: Thanks for your prompt and clear response. I'm saying though, that the trash is on the memory card (hidden). And the Trash (in the Dock) is empty...at least now. I take it then, that the fix is to delete the files in the .Trash folder (files only),
Comment: @Radam13 Usually, the GUI Trash folder should include the .Trash folder from any mounted drive. So something may have gone screwy.

Hidden files on memory card


Writing a good/readable constructor that needs a lot of calculation to fill its fields

Question: I have a class that has several fields which can only be filled consecutively by a lot of calculation. The 1st field can be set very easily. To fill the 2nd field, we take the 1st field's content and calcuate a lot. The 3rd, 4th and 5th field must be calculated together from field1 and field2 (it is not possible to calculate 3, 4 and 5 isolated from each other without severe performace loss). And the 6th field is calculated from field 1, 3 and 4.
I will use C# syntax for every code example.
class Foo
{
    private Type1 f1; // obtained directly from input parameter of constructor
    private Type2 f2; // from f1 we can calculate f2
    private Type3 f3; // from f1 and f2 we can calculate the triple (f3,f4,f5)
    private Type4 f4; // from f1 and f2 we can calculate the triple (f3,f4,f5)
    private Type5 f5; // from f1 and f2 we can calculate the triple (f3,f4,f5)
    private Type6 f6; // from f1, f3 and f4 we can calculate f6

    public Foo(Type1 input)
    {
        ... // What is a good way to write it?
    }
}

I would like to get some input regarding a good way to implement such a constructor. I am quite new to real-life software engineering (I just made some sandbox projects in university earlier) and don't know yet what the most important aspects are.
Here are the two ways I have in mind. Please comment on them, tell me about pros and cons I have not thought of, or give examples of how you would write such a constructor!
First version: static side-effect-free methods
public Foo(Type1 input)
{
    f1 = input;
    f2 = GetF2(f1);
    Tuple<Type3, Type4, Type5> bar = GetF3F4F5(f1, f2);
    f3 = bar.Item1;
    f4 = bar.Item2;
    f5 = bar.Item3;
    f6 = GetF6(f1, f3, f4);
}

private static Type2 GetF2(Type1 field1)
{
    Type2 field2 = new Type2();

    ... // calculating a lot, setting the correct value for field2

    return field2;
}

private static Tuple<Type3, Type4, Type5> GetF3F4F5(Type1 field1, Type2 field2)
{
    Type3 field3 = new Type3();
    Type4 field4 = new Type4();
    Type5 field5 = new Type5();

    ... // calculating a lot, setting the correct values for field3, 4 and 5

    return new Tuple<Type3, Type4, Type5>(field3, field4, field5);
}

private static Type6(Type1 field1, Type3 field3, Type4 field4)
{
    Type6 field6 = new Type6();

    ... // calculating a lot, setting the correct value for field6

    return field6;
}

pro:

At every line in the constructor, one knows exactly which fields are already set and which are not, making it clearly readable.
The calculations are encapsuled in side effect free methods, making them easily changeable.
Every method clearly shows what fields are needed for the calculation.

con:

Creating tuples has some overhead.
It might seem useless for the reader that a variable is defined, initialized and returned just to set a field to this value - instead of setting the field directly.

Second version: non-static methods manipulating the fields directly
public Foo(Type1 input)
{
    f1 = input;
    GetF2();
    GetF3F4F5();
    GetF6();
}

private void GetF2()
{
    f2 = new Type2();

    ... // calculating a lot with f1, setting the correct value for f2
}

private void GetF3F4F5()
{
    f3 = new Type3();
    f4 = new Type4();
    f5 = new Type5();

    ... // calculating a lot with f1 and f2, setting the correct values for f3, f4 and f5
}

private void Type6()
{
    f6 = new Type6();

    ... // calculating a lot with f1, f3, f4, setting the correct value for f6
}

pro:

Slightly shorter.
No Tuple overhead.
Probably a bit faster because the detour "initialize->return->set" is missing . (just a guess)

con:

If you take some line in the constructor, you cannot say which fields are already initialized and which aren't. (Or maybe you can because of the method names, but for my eyes it is not as clear as in the first version.)
The methods do not tell which fields they use for calculation.
Comment: First option. Always. IMO.
Comment: related (possibly a duplicate): [How can you decompose a constructor?](http://programmers.stackexchange.com/questions/231915/how-can-you-decompose-a-constructor)
Comment: Have you considered a third approach? [Not doing unnecessary work in the constructor](http://misko.hevery.com/code-reviewers-guide/flaw-constructor-does-real-work/) at all?
Comment: @DavidPacker you'll find that in my linked answer.
Answer: The first approach is much, much better than the second approach.
The most important quality of software is readability, since the number of times we may write and re-write a line of code is much smaller than the number of times we may read a line of code.  (Do you ever write code and then never read it again? I hope not.  And before you re-write a line of code, you will certainly read it at least once, right?)
The performance penalty associated with returning multiple values from a method call is completely immaterial, especially since by your own admission, the calculations involved are extensive.  So, returning the results is not only very cheap, but also, much cheaper than other operations that you already know that you have to do.
Also, since the calculation methods are going to be private, the compiler may even optimize them away, so there may even be no performance penalty whatsoever.
(In any case, if you really want to avoid the creation of the tuple, and since you are using C# syntax, you might as well use out parameters.)
(Also, keep in mind that the second approach would not even be an option if you were hoping to make your object immutable.)
There are two kinds of performance concerns: algorithmic concerns, and "save the clock cycles" type of concerns.
Algorithmic performance concerns have to do with using quicksort instead of bubble sort, using binary search instead of linear search, desynchronizing operations so that they can be performed in parallel instead of sequentially, improving protocols of communication so as to not require round-trips, etc.
"Save the clock cycles" type of performance concerns are about hacking, tweaking, and twisting stuff in order to save clock cycles here and there.
My advice to you would be to never consider a "save the clock cycles" type of performance concern as a "pro" or a "con" when deciding how to structure software.  This type of concern will never make a difference, and in the extremely unlikely event that it may one day be found to make a difference, there will always be a very easy way to fix it.
If you really really want a suggestion for an alternative approach, consider the factory method pattern:

Make your constructor private, and have it accept exactly one parameter for each member variable to be initialized. (f1, f2, f3, f4, f5, and f6.)
Write a public static function which accepts the Type1 input parameter, performs all the calculations necessary storing the results in local variables named f1, f2, f3, f4, f5, and f6, and ends with return new Foo( f1, f2, f3, f4, f5, f6);.
Answer: Consider separating use from construction.
Foo foo = new FooInjector(f1).build();

Now making Foo immutable is trivial. Now I can look at Foo's behavior without being distracted by f# construction.  Sure Foo has a long constructor to handle but that's hidden in FooInjector, not spread throughout the code base.
If you find many classes (besides just Foo) need to do this to access the f# family you might want to look into the introduce parameter object refactoring.
I'd also go into why a constructor shouldn't be doing real work but that already has an answer here.
Comment: If by "real work" you mean "anything not required to fully construct the object," then sure.
Comment: @CandiedOrange `Foo` is the only class that needs the f# family. Can you explain the benefit of creating a `FooInjector`? The calculations have to be done to get `Foo` into a valid state, so they are required. They are not "real work". And they have to be done SOMEWHERE. What is the purpose of creating an extra class that encapsules all my methods from above, instead of keeping them in `Foo` itself?
Answer: I don't see that it matters. All the processing is internal / private to the foo class. It's one massive side-effect anyway; the constructor is setting Foo object state. If Foo cannot trust itself then what's to do? Don't hold state and re-calculate all the fx objects every time?
Nonetheless I like the 1st option not because of side-effect management but because explicitly passing parameters expresses the dependencies for constructing an object. It makes the required construction order and participating objects unambiguous. And it does not make me have to read lots of code, as the 2nd example does, to figure out what's going on.


Relationship field for navigation menu

Question: I need to create a 'megamenu' with a page title and a summary for each menu item. The only way I can think of doing this is to create a channel entry for the menu and use a relationship field for each item. Is this a good/bad idea? Or is there a better way of doing it?
Comment: Yes, I would probably use both Grid and Relationship
Comment: Why not to use GRID?
Answer: Many URLs with summaries in

 structure, No doubt channel entry is needed. You can use both Relationships and GRID to accomplish the megamenu needs.
(As there are several plugins available in devote ee But I don't think they will match megamenu criteria so no other options except channel with GRID and Relationships)

Relationship field for navigation menu


What to do with Pickled Figs

Question: I have a jar of pickled figs bought for me as a present, and would like to make good use of them. Any ideas??
Comment: I love figs and pickled things, but I can't quite place this.
Answer: I think the two most likely things to do with this are to serve it as an accompaniment to a cheese plate (preferably with a triple cream / brie type cheese or an intense blue cheese), or in a dish with a gamey meat.
Comment: yes, this sounds like it is the best use - now to find a good brie. I might melt try melting it a little on toast.
Answer: I would stuff one inside a quail before cooking.  You should get a really nice gamey-figgy gravy out of it.
Answer: I would just eat them as a side with dinner. YUM!  Our family can't have Thanksgiving dinner without pickled figs on the table.
Answer: Iread that they can be used in a casserole. I have some Spanish ones preserved in vinegar.They did not go down well as an apero / cheese accompaniment so I'm stuck with them. Would like some ideas.

What to do with Pickled Figs


Can I use a different version of gcc inside Xcode?

Question: I installed gcc4.7 from MacPorts and I would like to use it inside Xcode (4.5). Is there a way to achieve this setup?
Thanks
Answer: The closet thing i found to using GCC4.7 installed by Macports on XCode is from by using the method used in this link.
http://www.implbits.com/About/Blog/tabid/78/post/building-with-gcc-4-6-on-osx/Default.aspx
Hope it helps. I installed GCC4.7.2 manually i am still trying to figure how to use it with XCode without installing Macports. I have Homebrew installed, i recently removed Macports for Homebrew since you cannot have both Macports or Homebrew installed on the same machine might remove Homebrew and return back to Macports.


About career break in CV

Question: I am going to apply for a postdoc position and there is an item about career break.
Having finished my Master degree, I got a position titles Director of Research in a College for about 6 years. In the meanwhile, I was visiting lecturer for some courses for different academic levels such as sub-bachelor, Bachelor students. After that experience I was involved in a research project as an assistant professor, then after 6 months  I commenced my Ph.D studies. I do not know whether the years before stating Ph.D ( 6 years as lecturer and director of research) is career break or not?
Comment: Do you mind rephrasing the question, it's a bit unclear at the moment (at least to me). Also what is a sub-bachelor student?
Comment: Subbachelor is an associative degree awarded to students who intend to find a job as technisian after completing their studies. I edited the question
Answer: I suspect that the intent of the question is to have you explain things that you did completely unrelated to your career and to your field. As such, the things you describe don't seem to qualify. I don't think they are necessarily asking about breaks in your academic progress (time between degrees), but they might be interested in that.
But the sorts of things you did prior to the doctorate would seem, to me, to be supportive of your case for the position and so should be mentioned somehow in your CV whether in this "section" or just in a narrative.
Some people need to take a career break to care for an ailing parent or child, for example, or because they are in jail (oops). In such breaks it may be impossible to do much professionally. Those need to be explained if they last more than a few months.
Comment: Totally. I'm on a "career break" because I am on parental leave right now. Nothing you describe is a career break. Indeed, time between master's and PhD is unlikely to be considered a "career break" no matter what happened in that time. In a way, your academic career starts post-PhD. However as @Buffy says, certainly mention those things on your CV, they sound very positive.

About career break in CV


How do you set the number of measures per line or page in LilyPond / Frescobaldi when you have a score with multiple instruments?

Question: As I am doing an arranging project, I was wondering how to set the number of measures per line and therefore page as it is a score with a rhythm section and five horns. I have seen these pages (line breaking and using an extra voice for breaks), but I am confused on how to make the techniques work for multiple instruments in a score, each defined as their own variable. I currently am using a tune with a 31 bar form (7 measures, 8 measures, 8 measures, &, 8 measures) and would like to have a separate page or line for each section, if I could.
Comment: The example in Section 4.3.8 can be extended to multiple voices (instruments) just by adding more `\staff`s. What did you do and how does it fail? Can you post a sample that demonstrates the problem?
Comment: What do you want to achieve by doing this? Musicians are used to line-breaks happening at any bar-line, not necessarily those at ends of phrases. Let Lilypond put breaks where it wants. Forced breaks every 7 or 8 bars are too frequent. If you want to refer to a point in the middle of the piece, use its bar number. Or insert rehearsal `\mark`s.
Comment: It seems to me, that you are considering a task, which lilypond performs on its own: you provide to notes in `\staff` granularity, lilypond does the layout. This is unrelated to any line break functionality.
Answer: A \break or \noBreak in any voice affects the whole system. I just have a special variable in all of my Lilypond files that contains only spacer rests with those breaks set up, and I put it as a voice into one of my staves (it doesn't matter which one it is). Here's a lilybin example: http://lilybin.com/walvlh/1 .
By the way, I'd say it's a good idea to first write down the whole score and only then work on the linebreaking (as well as on any other tweaks that would make the score nicer).
If you want to take complete control over the line breaks, just put a \noBreak after every bar in the line-breaking voice. So instead of s1*4 | \break, you would write \repeat unfold 3 { s1 | \noBreak } s | \break.
If you want to take it to the extreme, then you can put this into your \layout block:
\context
{
    \Score
    \override NonMusicalPaperColumn.line-break-permission = ##f
    \override NonMusicalPaperColumn.page-break-permission = ##f
}

This will disable line breaking (the first override) and page breaking (the second override) completely (in the sense that Lilypond will never insert a break, except when you specifically tell it to do so by using \break or \pageBreak).
Answer: In addition to Ramillies's great answer, a similar tool that may be helpful is specifying how many systems you want on your page. In your paper block, include systems-per-page = #4, for example, to have exactly four systems on each page. But this can be problematic depending on the nature of your score: if the instrumentation changes often from dense to sparse, having the same number of systems on each page may not make much typographical sense.
And if you want to keep this line in your score while you test it, you can turn it off by either commenting it out or setting the value to ##f.
Comment: The systems-per-page is extremely handy, and I'd go as far as to say a necessity when dealing with page layout, even if you take it out later.
Answer: I want to thank everyone for their answers and help and I am sorry about being late with getting back with you. What I actually ending up doing was adding a variable above all of the rest that had the "silent voice" with all of the break information in it, like this:

systeminfo = { \new Voice {

      s1*8 \break

      s1*7 \break
      s1*8 \break
      s1*8 \break
      s1*8 \break

       s1*7 \break
      s1*8 \break
      s1*8 \break
      s1*8 \break

       s1*7 \break
      s1*8 \break
      s1*8 \break
      s1*8 \break

      s1*7 \break
      s1*8 \break
      s1*8 \break
      s1*8 \break } }

I then added the variable to all of my instruments in the score block like on this one:

<< \new ChordNames = "chords" \gtrHarmony
\new Staff \with { instrumentName = "Trumpet" shortInstrumentName = #"Trp. " midiInstrument = "trumpet" } { << \Trumpet \systeminfo >> } >>

Next time I will have to use the "systems-per-page" and see how well that works.


How do I estimate puzzle durations?

Question: I'm looking to run an immersive/ARG style LARP and I'm trying to block out the time that I'm estimating players will spend on different tasks.  One part of this is going to involve puzzle solving, and there is a puzzle which can be solved, but isn't central to the main plot (so the players don't HAVE to solve it).  I'd like to know if you guys have any good way of guesstimating the difficulty of a puzzle/mystery or how you plan this thing since I have a finite amount of time to work with and don't want to generate too much content.
Answer: The best way is to beta test it.  If you have a favorite RPG forum (which is NOT the same as an RPG Q&A site), post it there.  Gamers like puzzles and many of them will be happy to try out your puzzle, even if they're not playing in your game.
Comment: we'll take it in chat too :)
Comment: In fact there is https://puzzling.stackexchange.com/ for this
Answer: As previous posters have said, you'll get a huge variation in the time taken to solve the puzzle.
If your puzzle is basically a maths problem, or can be brute forced in some way, you can make a ballpark estimate. Figure out how long it would take you and assume a spread of about 50% - 200% of your time. The more players you have, the more likely the time is to be towards the lower end of the range.
For anything which involves some intuition, you really can't make a reliable estimate. It all depends on whether any of your players think in the same way you do. At a weekend long LARP for 100 players, I've seen puzzles of this type we estimated at 2-3 hours be solved in under a minute and other puzzles we estimated at 10 minutes not be solved at all.
Looking at the second part of your question - "how do you plan this thing" :
1) Since this puzzle isn't central to the main plot, make sure it can be worked on in parallel with the main plot without tying up a significant proportion of the player base.
2) If you would like to see it solved anyway, have one or more clues available for the players to find as they progress down the main plot line.
3) If it is obvious that this isn't part of the main plot, be prepared for the players to totally ignore it.
Answer: There are two basic ways.

The hard way: playtest your puzzles. It takes time, it is rather inaccurate, but if you invent your own one, you need to do it at least a couple of times.
The easy way: take ready puzzles and adapt them to your needs. Gotcha! All the work already done for you by someone else! I love this way.

As others have noted, be prepared that some players will take considerably more time to solve the puzzles, and some will take considerably less.
It should be noted that even if your puzzle is open-ended, you still need expectations. For example, let's say that you make a list of 50 questions and give 20 minutes to solve them. If they are too easy, you may find out that all of your players chew through them a lot faster than expected, e.g. in 10 minutes or quicker, or, if the questions are too hard, you might see that the amount of solved questions is generally too low to determine winners.
So, always have an estimation of the time needed to solve the puzzle!
Answer: If you set a specific amount of time instead of leaving the time open ended, you have just effectively sealed off how much time it will take to accomplish a task.  This means, however, that you will have to measure success or failure in a different manner, such as with quantity or quality of work.  Puzzles involving different configurations, searching for words/images/differences, or alternate solutions to problems would seem to be appropriate for this sort of timed puzzle venture.
If you want to go outside of the box, you can have players do an action that is similar in hand or body movement accomplish another task. ( "Pick this lock? Tie knots in this string.  You have 45 seconds.")
If you REALLY want to go outside of the box, you can have the players perform a symbolic action or set of actions to accomplish the task.  The action could/should allow for others to assist in the action, and I highly reccommend that the addition of assistants make the action performed exponentially more hillarious.  (I,e. Lockpick plays GM in a game of Connect Four. Assistants have to try to tickle the GM with feathers to assist the Lockpicker. Gun-slinger is taking aim at an opponent in game, but out of game he has to hit a target with a pool noodle.  Anyone assisting has to hold a pie for the gunman to hit with said pool noodle.) This increases fun for the entire room, especially if the participants don't mind hamming it up. The game within a game also keeps things fresh.
Mr Puzzle gives this explanation for physical puzzles.

Difficulty rating 1 are the easier puzzles to do and memorise. Difficulty rating 10 is the most difficult to do and memorise.
  Puzzles rated 1, 2 or 3 may not take hours to do but there will always be some challenge involved. Don't write off these puzzles as too easy for adults.
  For a puzzle to be rated a 9 or 10 it must be VERY difficult to complete the puzzle, and VERY difficult to memorise the puzzle's solution.
  For example, a puzzle rated 7 could take an average person a couple of hours to do and then memorise.
  A puzzle rated a 9 we expect that most people - say 80 % or so - will NEVER be able to master the puzzle without assistance from the solution.
  How we present some of our puzzles will also have a bearing on the rating we give them. Some of our Interlocking puzzles are sold apart which adds the challenge of having to put the puzzle together without having first taken it apart.

The youtuber, Chris Ramsay solved a level 10 Lotus flower puzzle in around 41 minutes.  He does those puzzles professionally and has a lot of experience.
If all of your puzzles are Level 10, as above, you can expect the average person to take longer than 41 minutes, up to more than a few hours.
Comment: Thinking about open-ended puzzles looks like a good alternative other puzzles, but overall, this answer does not explain how to estimate time needed to solve a given puzzle. (Even for an open-ended puzzle, how would one get a good estimate of how much solution to expect in a given time?)

How do I estimate puzzle durations?


When should one not use Normalization Techniques in a deep learning models?

Question: When should one not use normalization between layers like Batch Norm, Layer Norm, Instance Norm, and Group Norm in deep learning while training a DL model?
Answer: In transfer learning cases when fine-tuning a pre-trained model on a new dataset, your mentioned various types of normalization layers might be frozen or omitted to avoid disrupting their already learned statistics (mean and standard deviation) that are well-suited for the original dataset. When fine-tuning a pre-trained model, there is a risk of "catastrophic forgetting" where the model forgets what it learned during the original training. If normalization layers are allowed to update their statistics during fine-tuning, it might disrupt the knowledge catastrophically captured by the pre-trained model.
Furthermore, if your fine-tuning target dataset is relatively small, freezing or omitting normalization layers can help prevent overfitting since they effectively introduce potentially many additional parameters particularly such as batch normalization's scale and shift of each unit that could contribute to overfitting.
In some generative models like GANs, normalization layers may interfere with the learning process. The generator in a GAN is trained through an adversarial process where it constantly adjusts its parameters based on the evolving dynamics of the discriminator. Various normalization meta-algorithms assume that the distribution of inputs remains constant within a batch which may not hold during GAN training, causing internal covariate shift ironically. GAN training is already known for its inherent instability challenges and the introduction of normalization layers can sometimes lead to further instability, making it harder for the model to converge.


What does the writing on Poe's helmet say?

Question: What does this writing on Poe Dameron's helmet say?
Answer: It spells "Roæhal" which may be a signature of Senior Prop Modeller Roy Halfpenny.  Thanks to Valorum for pointing this out.
I haven't been able to find any clean images of the actual prop from the movies that show the lettering in full, but the official Disney/Hasbro replica shows this:

I found an unboxing video that has a better view of the text:

According to the Aurebesh alphabet:

It spells "Roæhal."
Comment: **Roy Hal**fpenny- senior prop modeller; https://www.imdb.com/title/tt2488496/fullcredits/?ref_=tt_ov_st_sm
Comment: One Reddit user (probably misguidedly) hypothesized that the text is meant to be "RO & HAL," which would presumably be the initials of a concept artist and a significant other. A quick search of TFA's cast didn't turn up anyone who fit that bill.
Comment: @Valorum Not that I'm saying you're wrong, but why use Enth instead of Yirt?
Comment: @DavidW - To make it look more "space-y", probably. I'm planning to make this into a separate answer, but I'd honestly prefer if you added this info into your own.
Comment: @Valorum Thanks for finding this; I've updated the answer.


Fastest SD card for Pentax K-01?

Question: What SD card type and brand would be the fastest and most reliable for a Pentax K-01 DSLR camera?
Comment: We can't possibly have a question like this for every camera model in existence, _particularly_ when the answers end up being general anyway.
Comment: According to this PentaxForums page, the max write speed of the K-01 is 25 MB/s.  This question shouldn't be marked as duplicate IMHO.  There are answers to these questions, it's just a matter of digging up the information.

https://www.pentaxforums.com/articles/photo-articles/comprehensive-sd-card-guide.html
Answer: For speed, you can check out this website that details what the different symbols and ratings mean. As far as reliability, that comes down to brand reputation with some of the most popular being Lexar and SanDisk. Reading the reviews and knowing that the cheapest option (barring some kind of one-day sale) is probably not the best quality.
These qualities will be independent of the type of equipment you are using/nobody does testing to determine if what's fastest on this device is also what's fastest on that device. To my knowledge it's not possible to test the speed on the device itself and what most people do is test it using software on their computer and assume those results will correlate with what they get on their camera.
The only remotely relevant exception I can think of is that with the Canon 5DIII, using an SD card limits the CF card to SD speeds.
Comment: The other Canon models with dual slots (1 CF and 1 SD) do the same thing because the SD slot on those cameras is not UHS-1 compliant. The Canon models with only an SD slot are UHS-1 compliant, though.

Fastest SD card for Pentax K-01?


How to crop all the pages of a PDF

Question: I saw this Command line tool to crop PDF files. Being ignorant couldn't understand it.
How can I crop all the pages with same dimension(except last and front)? This is precisely the book. Also how to select the dimensions properly? That will be helpful.
Comment: @Stormvirux I saw that, and mentioned in the link in my question. Couldn't seem to grasp it completely
Comment: I've used PDFScissors, which (once you get it running) is easy to use and works well. It requires Java. https://sites.google.com/site/pdfscissors/
Comment: @NickWeinberg Is it for Ubuntu 16.04? Can you so some example of it?
Comment: Yes, it works on Ubuntu 16.04. I don't understand your second question (please be sure to read the webpage and watch the video about it to see if it answers your questions)
Answer: This may help you.
This is in accordance with the newer version of Ubuntu and life.
This is Master PDF Editor. You can use it crop, add some stuff, etc.
Example:
This is before

This is after ctrl + k
Answer: I personly love the tool Briss:
http://briss.sourceforge.net/
I used it to Crop pdfs to read on a Kindle.
See a screenshot here
The Programm groups together pages with the same layout and superimposes them.
You are then able to select the part of all these pages you want in your pdf.
The programm also handle the order of the pages.
If needed you can crop one page in multiple pages.
If you want to exclude pages from the cropping process you can manually enter pages that souldn't be loaded when opening a new file.
hope I could help
gz

How to crop all the pages of a PDF


Redmine-PlugIn development: helper method not found in view

Question: I'm writing a plugin for redmine and there is one thing i just don't get:
I have a helpermodule called approvals_helper.rb which contains a method 'rev_approved?'
module ApprovalsHelper
  def rev_approved?(repository, revision)
    # return some boolean value
  end
end

Now i want to use this method in my view which is a partial and is called _approved.html.erb
<% if rev_approved?(@repository, @revision) %>

show something

<% end %>

This partial is rendered in the revision.html.erb (from redmine view/repositories)
But when i do i get this error message:
ActionView::Template::Error (undefined method `rev_approved?' for #<#<Class:0x7f801e6bf030>:0x7f801e669ae0>)

When i add "include ApprovalsHelper" directly to the ApplicationHelper it all works fine, but i don't want to change the code directly. Is there a way to do this in a my plugin?
Is this because i actually render my partial in the revision view? How can I get this to work?
I'm using redmine 2.3.1 , ruby 1.8.7 and rails 3.2.13
Many thanks!
Answer: in your init.rb add
require_dependency 'name_of_helper'


Need a porcelaine socket for a recessed light fixture

Question: I just looked at the picture of the recessed light and read all the comments. Well, I need to replace the socket but I do not know what the name is and where to find this porcelain socket...Help please
Comment: Can you link to *which* post you were looking at? This makes very little sense without context.
Comment: Yes, it appears you asked a question, then created a new, second account in order to ask this question.   FYI accounts can be merged.
Comment: Take a photo of the fixture then take that to a hardware or big box store. With "off the wall" or different repairs I have had good luck finding unusual parts at a plumbing & electric specialty store in my town.
Answer: Lamp components are fairly standardized.  You should be able to go into a quality hardware store and get any common part.   If the parts are not common, it may be possible to rearrange it with common parts.
One common problem is people overlamping fixtures; that is, putting too-high-wattage bulbs in fixtures that can't take the heat.  This is a great time to alter the fixture to make that impossible, by changing to a socket type for which high-wattage incandescents are not made.  A good choice for this is a candelabra base, as LED screw-in "bulbs" are widely available at sane price, including some quite high-brightness ones.


What is the difference between securing a linux box using hosts.[allow|deny] vs iptables?

Question: As the title states, I have a linux box. As far as I can tell I can use hosts.allow / hosts.deny or iptables to secure. What's the difference? Is there another mechanism that can be used?
Answer: IPTables works at the Kernel level.  In general this means it has no knowledge of applications or processes.  It can only filter based on what it gets from the various packet headers for the most part.
The host.allow/deny however operates on the application/process level. You can create rules for various processes or daemons running on the system.
So for example IPTables can filter on port 22.  SSH can be configured to use this port and generally is, but it can also be configured to be on a different port.  IPTables does not know which port it is on, it only knows about the port in the TCP header.  The hosts.allow files however can be configured for certain daemons such as the openssh daemon.
If you have to chose I would generally opt for at a minimum IPTables. I view the hosts.allow as a nice bonus.  Even thought it seems like the daemon levels seems easier IPTables will block the packet before it really even gets very far.  With security the sooner you can block something the better. However, I am sure there are situations however that change this choice.
Answer: iptables blocks the access before it reaches the application, whereas hosts.allow/hosts.deny is part of PAM and requires the application to implement PAM checking and correctly handle the file. Both are useful, and having both in place is even better.
Comment: I don't believe the hosts.[allow|deny] files have anything to do with PAM. Were you thinking about tcpwrappers?
Comment: Sorry, I was getting it confused with the allow_hosts impementations inside PAM for vsftpd etc.
Answer: TCP Wrappers only restricts access to 'wrapped' services, processes that have been explicitly compiled against the libwrap.a library.
Access to other processes is not impacted.
For example, if you set ALL:ALL in hosts.deny, then you won't be able to create a new incoming connection to sshd, but connections to netcat will work just fine.
Under some circumstances, wrapping can depend on hostnames, rather than IP addresses, but this protection is a bit limited and not as hard to bypass as it should be.
There's no reason I can think of not to use TCP Wrappers, but I don't think it reliably does anything that can't be done better and cleaner with IPTables.


Server with Froxlor UI; Permission error with PHP FPM and nginx

Question: I'm running a vhost that provides a Froxlor web UI for configuration. Froxlor generates the config files for everything in its scope automatically.
The problem I'm currently facing is that Froxlor creates a config file for PHP FPM that generates the socket for the corresponding domain user, lets call him dom-user:dom-user while the nginx server is configured to be run as user www-data:www-data which is correct.
That however unfortunately seems to lead to the problem that I get permission denied errors when PHP tries to access the socket because it's not owned by www-data:www-data.
I can of course change the user for the socket manually in the config files, but I would have to do that every time after Froxlor regenerated the config files. There must be a configuration flaw somewhere in Froxlor that I haven't been able to find.
Maybe that's something someone around here has already encountered too and knows how to solve it.
Answer: Solved by adding dom-user and www-data to each other's groups.


Where can I see the source code of the Sun JDK?

Question: I want to have a look at how Java implements LinkedList. Where should I go to look at the source code?
Comment: It is the source code of the jdk, not the jvm.
Answer: Install the Java SE Development Kit from http://java.sun.com/javase/downloads/index.jsp.
Once installed, you should find an archive called src.zip in the top of the JDK installation directory.  The Java source code is in there.
The file is java/util/LinkedList.java.
update: You may also like to visit the online OpenJDK Source repository. See this answer below.
Comment: They seem to have moved the JDK source to http://hg.openjdk.java.net/jdk7/jdk7/jdk/
Comment: Bill, this doesn't appear to be the case with the latest Java update (7u51). I wonder what the deal is...
Comment: Actually, I figured it out. I downloaded the wrong JDK package. =/
Answer: You have the source in the docjar:
LinkedList.java (from the openjdk-7)
Comment: +1, First link that is still working and can be viewed online
Comment: Seems outdated to me. Last update was 2010, so no Java 8 :(
Comment: @Qw3ry That is possible indeed. This was one of my first answers on this site eleven years ago.
Answer: The sources are hosted at hg.openjdk.java.net. You can find the library sources for a specific JDK version under src/share/classes. For example, the JDK 8 source for java.util.LinkedList is located at:
hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/tip/src/share/classes/java/util/LinkedList.java
You can follow the instructions here to explore the source.
Answer: grepcode.com has source code of almost all opensource projects.
It also provides common IDE features like find usages, derived types, etc.
Here  you can find LinkedList source:
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/util/LinkedList.java/
Answer: As previously said, you have a src.zip file installed with Sun JDK if you have selected it during installation.
Moreover, if you use eclipse and add a JDK to your JRE list, it will attach automatically the sources to the jar and if you try to open a class with Ctrl+Shift+T (Open Type), you type LinkedList, and it will show you the code of the class.
Answer: If you have a JDK, you can find the source in the src.zip file.
If you have an IDE, you can just ctrl+click or similar on the class/method you want to see the definition of.
Comment: Intellij Idea has not found the src file automatically. Thanks for file reference.
Answer: Here:
http://hg.openjdk.java.net/
Answer: zGrepCode has an online directory of Java open source code. Here is the Sun Java classes available: https://zgrepcode.com/java/openjdk/10.0.2/java.base/sun/
And here is the LinkedList implementation code. Hope it helps.
Answer: I would say start at the OpenJDK repository, but I don't see anything there for the LinkedList objects.
Answer: The best way to view java source code is to install Intelli-J community edition. Create a new Java project and inside your project create a new class.
Inside class if you want to see the source code of LinkedList, create a new LinkedList object as follows:
public class LinkedListWatch{
   public static void main(String[] args){
    LinkedList linkedList = new LinkedList();

  }
}

Now ctrl + mouse left click on LinkedList class, will take you to LinkedList source code.
You can explore many things and it could be very useful.

You can look at the implementation of Stack class also; very helpful.
Enjoy searching java open source code.
Comment: This isn't useful if there is no attached source documents. Why would you even post this after reading the other answers that explain where to get the source documents?
Comment: I am sure you missed something, I found it very convenient to look for Java source code inside Intellij, check my updated post for screenshots
Comment: This is fine for IntelliJ, but what about when you're using an IBM implementation of Java and they didn't include the Java source documents? Someone should download IntelliJ to view them? I disagree, they should do as Bill answered in '08; navigate to the src.zip to view / attach the source code.
Comment: @superPhreshHackerKid You can do this in Eclipse and pretty much any IDE. Plus, you get to browse through the source code as you would with your project. That's far better than dealing with the src.zip yourself.


Does MLB rules prevent blocking home plate on infield hits

Question: Are catchers allowed to block the plate before they receive the ball if the ball is fielded in the infield ?
Comment: Out of curiosity, why do you think they would be?
Answer: No, the catcher is not allowed to block home plate without possession of the ball. For this, it doesn't matter whether the ball is coming from the infield or somewhere else.
This can be found in MLB's Official Baseball Rules (OBR) 2015 edition Rule 6.01(i)(2):

Unless the catcher is in possession of the ball, the catcher cannot block the pathway of the runner as he is attempting to score. If, in the judgement of the umpire, the catcher without possession of the ball blocks the pathway of the runner, the umpire shall call or signal the runner safe. [...]
Comment: It goes on to give an exception: that the catcher can block the plate while attempting to field a throw.  Interestingly, a case not addressed: the catcher might block the plate while attempting to field a *batted ball* (imagine a squeeze play where the bunt goes up the third base line).  It's not clear whether that's allowed, but if it is, that would be an infield play for which the catcher could block the plate before having the ball.
Comment: The case of a fielder (including the catcher) attempting to field a batted ball is addressed in 6.01(a)(10). The same rule also makes a very important distinction between batted balls and thrown balls. Whereas the fielder has priority on batted balls, it will only be interference by a runner on a thrown ball if intentionally done so! The same principle applies to plays for the catcher as well. In general if the catcher is attempting to field a batted ball he is not considered to be blocking the plate at all, so 6.01(i) does not apply.