To change replication factor of a directory in hadoop

Question: Is there any way to change the replication factor of a directory in Hadoop when I expect the change to be applicable on the files which will be written to that directory in the future?
Answer: You can change the replication factor of a file using command:
hdfs dfs –setrep –w 3 /user/hdfs/file.txt

You can also change the replication factor of  a directory using command:
hdfs dfs -setrep -R 2 /user/hdfs/test

But changing the replication factor for a directory will only affect the existing files and the new files under the directory will get created with the default replication factor (dfs.replication from hdfs-site.xml) of the cluster.
Please see the link to understand more on it.
Please see link to configure replication factor for HDFS.
But you can temporarily override and turn off the HDFS default replication factor by passing:
-D dfs.replication=1

This should work well when you pass it with a Map/Reduce job. This will be your job specific only.
Comment: I have updated my answer with one possible solution, pass this configuration when you invoke your job. It should turn off replication for your hadoop job output. you can also do some performance tuning of your job by increasing and decreasing Mapper and Reducer.
Comment: Actually replication should not take much time because client write the data into only one datanode and then primary datanode replicates the data into other datanode.
Comment: Means as of now there is no way to set the replication factor for the upcoming files to be written in a directory. Actually I am using MultipleOutputs to write some data out from Mapper while transmitting the other data to reducer. But the mapper runs awfully slow because it replicates the data which it is writing to HDFS. Since the data written from HDFS is only needed for a while I want to make the replication factor for that data as 1. Can you suggest a better approach?
Comment: Do you want to write Mapper output to HDFS before transmitting it to reducer ? Can you explain bit more ?
Comment: I am doing a bit of processing in Mapper. I have overriden the context.write method. Whenever context.write is called I make it do its usual stuff as well as write some additional output to MapReduce based on the key value pair passed to this write method. In order to write that data to HDFS I'm using MultipleOutputFormat. MultipleOutputFormat writes my data to HDFS at a pre designated location. Code works fine but is quite slow. The writes from the Mapper are about 400 MB so the replication makes it take more time.
Answer: I think what you're asking is also asked in this HDFS Jira:
https://issues.apache.org/jira/browse/HDFS-199
and unfortunately it looks like no, the feature is not available and apparently not coming anytime soon. The workarounds from others look like your (and my!) best bet.


How to get a wand with at least 150 vis in Thaumcraft Minecraft

Question: I'm playing the Thaumcraft 4 mod in ftb. I'm trying to make a silverwood staff with thaumium caps and it says that I need 144 of each vis to craft. I thought, ok I'll just make a quarts staff with gold caps and I can make it. Well I did but then I realized that you can't place staff's in the arcane workbench. So now I'm stuck because my strongest wand (Silverwood w/ thaumium caps) only has 100 vis capacity. Is there a way to decrease the vis required or a wand with at least 150 vis?
Answer: The answer for base Thaumcraft is to use a scepter.  The easy route is iron-capped wood wand -> gold capped greatwood wand -> gold capped silverwood wand -> thaum capped silverwood scepter.
Note that thaumaturge's robe, legging, boots plus the googles of revealing all provide additional discounts.
Answer: You need gear that gives you vis discounts. Sanguine helmet, full robes, and a fuelled harness should be enough. If you got Forbidden Magic installed, you could also use a Thaumium Bossed Infernal Wand, and you'd have over 200 vis. With Advanced Thaumaturgy (another mod, hasn't been updated to 1.7 yet, I think) you could craft a Mercurial Wand. It's not easy to make, but it can hold 1000 vis. Ichor wand is another option...
Also note that frugal foci are bugged in versions older than 1.7, so that could be an issue.


Export Tracking Data from Marketing

Question: I need to export tracking data (sent, opens, bounces, etc.)  in  CSV file from Marketing Cloud to a Data warehouse through sFTP folder.
I would use the system data extension as explained here and retrieve email's names and Job's names.
Do you have any suggestions how can i do this?
Comment: Please go through your questions, and mark answers as accepted - I see you have so far only done this on few of your questions, and mostly where the answer was provided by yourself. As a community, everyone here appreciates to know if they have been helpful to you or not.
Answer: You'll probably find the Tracking Extract more useful for your purposes, than Data Views, if what you'd like to do is push this data to SFTP for your DWH. These are somewhat more comprehensive than Data Views and would give you the name of the email from the Job extract.
See Tracking Extract Output for details of what's available. If you do not have Tracking Extracts available as an Extract Type in Email -> Interactions -> Data Extracts or in Automation Studio Activities when you're defining a Data Extract, create a case with Support to have them provisioned to your account.
Answer: If tracking data of the last 30 days is sufficient for your needs, you could just use an automation with a data extract activity.
Further information:

Data Extract Activity
Extract Types Reference

Export Tracking Data from Marketing


Can I put Snackbar above Bottom Navigation?

Question: My scenario is that I have a created a single class Snackbar Display which displays a particular snackbar. So I am calling this Snackbar class from various Activities and Fragments and all of them have a bottom navigation in them. Is there a way to display the Snackbar above the bottom navigation? I can't use any navigation id as it will keep changing from Activity to activity which is calling it.
Answer:
Snackbars appear above all other elements on screen and only one can
  be displayed at a time (javadoc)

You can try displaying this snackbar layout as any other view inside a framelayout to display above bottom navigation. And if your bottom navigation is a common fragment, you can add snackbar view in that layout only aligning it above your navigation bar.
Add enter exit animations to this snackbar layout and it will look as if it is snackbar.
Comment: By doing this then I will have to add snack bar in all layout files. Can't this be done by some other way? And by above I meant that navigation bar and snackbar shouldn't overlap.
Comment: You won't be able to use android Snackbar widget to achieve non-overlapping views as intended as it appears above everything on screen. You have to create your own view/fragment which looks like a snackbar.


Why doesn't using quantum error-correction increase the production of entropy and decohrence?

Question: Error-correction in quantum computing is designed to get around the decoherence "washing out" the answer to a computation.  But wouldn't the introduction of error-correction procedures or apparatus merely increase the production of entropy and produce more decohrence?
Comment: The full answer can be long but I think the point is that you have/need ancillas in error correction
Comment: would this question be more appropriate for quantum computing SE?
Comment: Wouldn't this question equally apply to classical error correction?
Answer: Of course this is true, the point of a useful error correcting scheme is that the errors introduced with the additional complexity needed to implement the scheme are either themselves corrected or less likely than the one it's supposed to correct.
Let's take the example of a simple classical repetition code: say you want to encode a single classical bit, which can be either $0$ or $1$, to protect it from a binary symmetric noise, i.e. an error that simply flips the bit with probability $p$ (from $0$ it goes to $1$ with probability $p$ and vice versa). A possible strategy is to use two additional bits the following encoding:
$$0\rightarrow 000 \\1\rightarrow111$$
now if one of the bits flip, we can just take the majority vote to figure out what was the original bit value. For instance we interpret $010$ as $000$, with an error on the middle bit.
But as you point out, adding two bits adds complexity, and multiple bits can now be flipped: before the encoding, just one bit flip was possible, now there are three bits that could flip, effectively "triplicating" the possible errors that can occur! Haven't we just made things worse? Well no, because even if $010$ could have been produced by $111$ with an error on the first and last bit, the flipping of two bits happens with probability $p^2$, so it's much less probable than the flipping of a single bit, which happens with probability $p$. So, despite apparently making things worse, the repetition code actually decreases the error rate.
The repetition code is not practical in many ways, but for any (quantum) error-correcting code the point is that it must correct errors faster than it creates them. The quantum threshold theorem roughly states that if the error rate of a quantum computer is small enough, then errors can be effectively corrected by an error-correcting scheme.
Answer: You are absolutely right that by adding extra qubits, and extra error correction operations, you also produce extra entropy.
However, with more qubits it is also possible to move all the entropy onto a subset of the qubits, making some those qubits more noisy, while the remaining -- those which become error corrected -- become less noisy! By discarding the qubits on which the entropy has been bundled and replacing them by fresh ones (or measuring + re-initalizing), entropy is removed from the system. This way, one effective reduces the entropy production on the error corrected qubits.


Are metal anchors or buried posts better for 6 x 6 posts for a pavilion?

Question: I'm trying to figure out the best way to set 6 x 6 posts for a pavilion.  I'm considering the two methods below.  I know they both have their good and bad points.  I believe the first will extend the life of the posts but will require extra bracing for lateral movement.  The second will resist lateral movement but it will reduce the life of the posts.
Comment: Correct on all counts. "Best" is up to you now. What's the question?
Comment: I'm leaning (bad choice of words) towards a buried post in concrete for the stability.  I just don't want it to rot out in a few years.
Comment: I prefer the pier and footing solution for ease of repair down the road.
Answer: The pier and footing is the best approach.
A structure, even a deck or pavilion should not have to rely upon the posts being anchored in concrete for structural support. The pavilion itself should be planned and supported to be structurally sound in itself regardless of the type of footing used. If properly installed with an anchored metal post base the posts will be stable and serviceable for many years. Otherwise,with a buried post when the posts rot, which they will, and if the structure isn't sound the only way you will know is if the structure starts to lean - which is not a good plan.
Comment: There are sturdier and less sturdy Simpson brackets. Take a look at the ones that embed in the concrete, rather than the ones that just mechanically attach. (One I use regularly is the PBS ZMAX.)


How do I format tables in Google Documents?

Question: I have uploaded a Word document to Google Drive that contains a table.
I am trying to format the margins and table etc. Tried everything.
How can I do that?
Answer: Select the desired rows to get rid of padding, go to "Format" then "Line Spacing" then "Custom Spacing". The preset "After" is "16"; decrease that to the desired amount.
Answer: I can think of several approaches.

Format everything the way you want it in Word before you put it in Drive.  An easy way to do this is to install Drive on your computer, and have Drive running all the time, so that synchronizing happens automatically.
Make sure you upload the file as a Word document (without converting to gdoc); if you need to tweak something, use a Chrome extension called Office Editing for Docs, Sheets & Slides.
Re-learn all the formatting techniques you already know how to do in Word, but now with the gdocs software.  I have wrestled with this, and I do not recommend this approach personally.  However, apparently there are many people in the world who are happy with this approach.  For example, highlight some or all cells in a table, right-click and choose Table Properties.  Now you can edit "Cell padding."

I'm not sure what you mean by the margin.  If it's the margins on the page, go into File -> Page setup.
Make sure you are able to edit by looking at View -> Mode and making sure you are in "Editing" or "Suggesting" not "Viewing".
You might find the Paragraph Styles add-on helpful.


What is the use of pharyngeal resonator or pharyngeal resonance in achieving mix voice?

Question: Mix voice is blend of chest voice and head voice. That means it is blend of mouth cavity and nasal cavity resonance. So what's the use of pharyngeal resonator or pharyngeal resonance?
Answer: I have to correct your obvious assumption that chest voice is associated with mouth cavity resonance, while head voice is associated with nasal cavity resonance. You always have a combination of all types of resonance, except for nasal resonance (including the nasal pharynx), which depends on the position of your soft palate. Without mouth resonance, you would not be able to produce most vowel and consonant sounds. Without pharyngial resonance, your voice would sound totally muffled. Different resonators cannot strictly be considered separate, but essentially, mouth resonance forms the lower part of the frequency spectrum, while pharyngial resonance affects much higher frequencies and is important for the characteristic timbre of each singer, for ring, clarity and air in the sound.


Preventing mug from breaking when making mug cake

Question: I am making mug cake in a pot using steaming method and I will use normal tea cup.
I want to know what precautions I must take so that the cup doesn't break after baking
Answer: The only precaution you can take is to have the temperature change happen as slow as possible. This includes:

don't use cold mugs, start them from room temperature
put the mugs in the steamer before you have turned it on
let the mugs cool down slowly

This doesn't mean that you will never have mugs break on you. It can still happen, but it will be a rare occurrence. Just make sure you are only using cups which you can afford to lose, not the most expensive china.
Also: Mugs and cups have handles, which get shaped separately and attached during the production process. The attachment point is then a place with high risk for breaking. So ideally, you would use something without a handle, if you have it. Good choices would be ramekins, or maybe Japanese tea cups, if you find ones that are large enough.
Answer: Thermal stress is fairly unlikely to break porcelain you've used to bake something.
Porcelain doesn't automatically break at high temperature (remember, it was "baked" at much higher temperatures than your oven can reach), but may break if part of it is heated to a high temperature while a different part is kept at a lower temperature. Normally you'd need direct, high-flux heat (such as over a burner, or immediately under a broiler element) to cause that.
And if you are steaming the mug, it is absolutely impossible to build up the requisite temperature differential. The stress here is much less than the stress caused by adding boiling water to a room-temperature mug. You'll be fine. Unless you drop the mug.
Comment: Yes, don't forget that steaming heats the whole thing quite evenly to a maximum of 100°C (barring pressure cookers of course).  Making a hot drink by pouring in boiling water heats it to nearly 100°C , much less evenly, with far more thermal stress on the handle joint; boiling water in a mug in the microwave can get the main bit right to 100°C with the handle cold.  No one worries about that


A question about continuing education in an Engineering major or Sciences

Question: I am MSc student of civil engineering and I am so much interested in sciences, mostly applied mathematics. My MSc thesis research is also focused on some analytical and numerical solutions to governing equations in field of the civil engineering. It is too difficult to start a BA in Mathematics, because I have to whether continue my education in civil engineering and apply for a PHD or seek for a job. I am so much interested in analytical solutions which exist in mathematics and applied mathematics; differential equations and PDEs. How should I satisfy my interest in mathematics, besides my future job or in my future academic life?
Answer: It is very possible to go to a PhD program in applied math with a masters or even bachelors degree in engineering. I am in an applied math PhD program and many of my colleagues only took a couple of upper level math classes in college. Applied math is very broad and people with all sorts of backgrounds can get into these sorts of programs. But the question is what can you do now to explore your mathematical interests (an perhaps get into an applied math PhD program too)? The key is to do a few of the following

take a few junior/senior level undergraduate math classes (or if you can handle it, graduate level math courses). You likely have the requisite background to take a class in undergraduate Real Analysis or differential equations. Basically you need to convince an admissions committee that you are capable of writing proofs. You don't need a math degree to do this; you don't even need a math minor to do this. If you do well in a single semester of real analysis some great applied math programs are more than willing to take a gamble on you if you have interesting engineering research and a good personal statement that really explains how you got a passion for math while working in engineering.
incorporate math into your research. You say you do numerics, so prove your method converges, develop analytical error bounds, prove the existence or uniqueness of a solution. If your method is too complex to do the above, or you lack the knowledge to make progress in such an endeavor, create a "toy" problem which is similar but vastly simplified and prove something related to it. Toy problems often lead to stand alone publications, they are interesting to us applied mathematicians in and of themselves, and they have the added benefit of giving insight into your engineering research.
Read math. Get yourself a book and work your way through it in your spare time. Just 1-2 hrs a day, of intense mathematical focus will surprisingly allow you to learn a lot more math than you would think. Start at the right level, for some this will be advanced and for others this will be not so advanced.
think about math a lot. Just ask yourself questions a lot. Math is a mindset. Get away from the computer and coding and work with pen and paper (or a whiteboard) for a couple hours each day. Do problems -- putnum exams, course websites, math.stackexchange. They are all great resources.
Comment: Can you sit in on a class, do the hw, go to office hours and talk to the prof without officially taking the class? You might ask a prof if you can do this.
Comment: The problem is that, it is so hard to enter a program or even to choose some course of our my desire. I mean, if somebody wants to study maths in the university, here; he has to sit entrance exam and then apply for the course. There is no way to apply without those qualifications. Furthermore, it is so hard to prepare for the entrance exam, it needs longterm studying which is not possible for me as a graduate of engineering. By the way, the other three comments of you are useful, as far as I can self-study maths or incorporate math into my research.
Comment: Of course this is possible. Good advice... But first I have to be sure about the prerequisite courses and choose the right course to attend.


How do I remove this PCB from another PCB?

Question: I'm trying to replace a transistor on this amplifier. I cannot remove this PCB for the life of me. Is there a secret here? It has these black connectors going into the bottom PCB. I've put a lot of force trying to lift it and anymore I feel like I will break it.
Comment: Even if it can just pull out, and I'm not saying you can, something that long with connectors all along its length will jam if on one side if you pull it at any angle other than perfectly straight. You might need to build something to lever it out evenly. Not to mention that a single connector can be quite tight to begin with and when you have a lot of them that force can add up very quickly.
Comment: Think about it; how would a trained technician at the parent company get it out? The squarish latch you see on the connector holds the answer. Without breaking any, I think these can be pushed or manipulated somehow to get this board out. Use a small flat screwdriver and be gentle. Pull it apart as vertically as you can.
Answer: I would work back and forth along the length of the PCB using a piece of bent steel like this blanking plate.  Slide the short end under the PCB then rock the tool sideways to lift the PCB a bit at a time.  Hopefully there is enough of a gap to fit it in, but it is hard to tell from the photos.


Inequalities for upper semi-continuous affine functions on compact sets by using extreme points

Question: Suppose $f_1\colon K\to [0,\infty)$ and $f_2\colon K\to[0,\infty)$ are two upper semi-continuous affine functions,
$$
f_i(\lambda x+(1-\lambda)y)=\lambda f_i(x)+(1-\lambda)f_i(y)\ \mbox{ for all }\ x,y\in K\ \mbox{and}\ 0<\lambda<1,
$$
on a compact convex set $K$ in a locally convex Hausdorff space $E$. If $f_1(x)\le f_2(x)$ for all extreme points $x\in K$, is it then true that $f_1(x)\le f_2(x)$ for all $x\in K$?
Comment: In a Tychonoff space an upper semi-continuous function is a pointwise infinum of a collection of continuous functions. Perhaps an upper semi-continuous **affine** function is a pointwise infinum of a collection of continuous **affine** functions?
Comment: @erz Yes, such an upper semi-continuous affine function on a convex compact Hausdorff space $K$ is the pointwise limit of a decreasing net of continuous affine functions on $K$.
Comment: could you please provide a reference? I've made an answer based on this fact.
Comment: @erz Yes, of course. This is Corollary I.1.4 in "Compact convex sets and boundary integrals" by E. M. Alfsen.
Answer: First, let us assume that $f_2$ is continuous, and let $h=f_1-f_2$, which is an upper semi-continuous affine function, negative on the extreme points of $K$.
Let $c=\sup_K h$. Since an upper semi-continuous function attains its maximal value on the compact set, $L=h^{-1}(c)$ is non-empty and convex. Since $c$ is the maximum, $L=h^{-1}[c,+\infty)$ is closed, and therefore compact.
Let $x$ be an extreme point of $L$. Assume that there are $y,z\in K$ such that $x=\frac{1}{2}(y+z)$. Then, $h(x)\ge h(y), h(z)$ and $h(x)=\frac{1}{2}(h(y)+ h(z))$ lead to $h(x)=h(y)=h(z)$ which contradicts the fact that $x$ is extreme in $L$. Hence, $x$ is also extreme in $K$, and so $c=h(x)\le 0$. Thus, $h\le c\le 0$ on $K$.
Now, to pass to the general case, use the fact that $f_2$ is an infinum of a set of continuous affine functions $\{g_i\}$. For each of these $g_i$ we have $f_1\le g_i$ on the extreme points of $K$, and so from the previous part, on the whole $K$. But then $f_1\le\inf_i g_i=f_2$ on $K$.


Sharepoint Online Modern = Right formula crashes

Question: Using Sharepoint Online Modern experience.
I am trying to use the right formula in a column with a calculated value and get an Sharepoint error.
I have a column named LOCATION and has a string value of "ST-BERNARD @ 140".
I create another calculated column with function =right(LOCATION,4) to extract the "140" but get sharepoint error.
But when I enter =right(LOCATION) I get a value of "0".
The column does accept the lenght of the extraction.
Answer: Finally found the answer but I don't know why Sharepoint modern only accept ; and not ,
Example intead of using RIGHT(COLUMN,4) I had to use RIGHT(COLUMN;4)
All the documentation was always specifiying a comma not a semi-colunm
Answer: The RIGHT function extracts a given number of characters from the right side of a supplied text string. For example, RIGHT("apple",3) returns "ple".
Right(LOCATION,4) should return "@ 140", but an error occurs because it contains the special character @.
Right (LOCATION) will not return any value, so it is displayed as "0".


Can the Validator ensure a certain Datum is sent by the Redeemer?

Question: is it possible for a Validator to ensure that the redeemer pays some Value along with a certain Datum attached to it? Looking at the possible transaction methods on the ScriptContext, checks are only done on the Value and not the Datum. I see the DatumHash types but am not sure what it is used for.
Comment: Hope my answer was helpful. I'm not sure if you're overloading the term "Redeemer" (the redeemer data type vs the sender of that tx). I think I got what you were going for though. LMK if I can clarify.
Answer: The validator can ensure that a datum or multiple datums are included in the output.
Take the Uniswap clone in the plutus-use-cases for example:
The validateCreate method ensures that an updated Factory datum
Constraints.checkOwnOutputConstraint ctx (OutputConstraint (Factory $ lp : lps) $ unitValue usCoin)

and a new Pool datum
Constraints.checkOwnOutputConstraint ctx (OutputConstraint (Pool lp liquidity) $ valueOf lpCoinA outA <> valueOf lpCoinB outB <> unitValue c)

are included in the outputs.
Both of these are attached to some Value.
Comment: Oh gosh I didn't know there was a whole library on On-Chain Constraints. Thank you!

As for the term Redeemer, I believe the language used has been not-strict enough. So to my understanding, the person initiating the transaction is called the Redeemer, and he/she will supply a RedeemerType to the Validator to spend the underlying eUTXO.

Link to the On-Chain constraints library: [https://github.com/input-output-hk/plutus/blob/160d158c2679a72adfc8edf7a1c43a4b59189d99/plutus-ledger/src/Ledger/Constraints/OnChain.hs]
Comment: Yeah. The on-chain constraints are great and they compliment the off-chain constraints well. The more declarative the better :)


How to change all the blue colors of RWD theme to another color?

Question: How to change all the blue color of RWD theme to another color?Actually this question may be duplicate but please help me none of the methods worked for me in Google or in MSE.
Answer: To do it properly, you should have compass & sass installed, navigate to the sass folder with your terminal (skin/frontend/rwd/default/scss), run
compass watch .

and then edit _var.scss and change the value for the $c-blue variable.
Upon save, compass will regenerate the complete css files.
Answer: For that go to style.css.
Find all '#3399cc' color code and replace it with your color code.
First take backup for further usage.
(#3399cc color is default background color for RWD theme.)
Comment: @dhoni7 Of course you cleared your browser cache? Did you modify the correct styles.css? Did you try using inspect element in your browser to see what styles are set on the element and what file sets them?
Comment: @dhoni7 I don't think you did: http://magemana.nl/Color-rwd.png - Jack's answer is spot on. Investigate further, for example, are you even on the right server? Is the skin URL pointing somewhere else?
Comment: thankx for your answer but that didn't bite the dust
Comment: @Melvyn yeah done all thos but still not getting
Comment: This approach assumes that styles.css is being edited directly, rather than the source Sass files. I would strongly recommend NOT editing the .css files, but instead setup Sass/Compass compilation, as covered here: http://www.magentocommerce.com/knowledge-base/entry/ee114-ce19-rwd-dev-guide#compass-install
Answer: I don't care if this is the worst answer ever written here. It is beyond preposterous that to edit something as simple as a background color, not only do you have to install ruby, and install compass, just to edit one line of a SASS file? I guess editing the precious little .scss file in Textwrangler and replacing it in the proper folder just can't work can it? We have to RECOMPILE?!? Thanks EBAY also, for bringing this on board.
Answer: If you don't want to recompile or compromise the css files, you can go to :
System > Configuration > General(on the left)> Design, and add your style override in the "Miscellaneous Scripts" textarea :


What are most fundamental things you must check before theoretical prediction of novel 2d materials?

Question: For prediction of novel two dimensional materials using Density Functional Theory, what are the most important concepts one should check out before formulating new structures.
Comment: Besides ensuring that the structure's forces and stresses are zero (within some tolerance), this paper (https://pubs.acs.org/doi/10.1021/acsami.9b01261) provides a good summary for various stability criteria. Though, I think it may have left out elastic stability (covered in https://iopscience.iop.org/article/10.1088/2053-1583/ab2ef3)
Comment: Thank you CW Tan, other than these can someone please add things too look before choosing elements to form a compound materials like electronic configuration compatibility etc. I have seen 2d materials following different valency rules than bulk counterpart of it.
Answer:
You must make sure that the structure that you predict 'makes sense.' This means that it must follow some logical reasoning in construction of the unit cell and the material. Fo example, consider that you are trying to predict $\textit{h}$-BN from graphene, the line of thought that you would ideally follow is a B-N segment is isoelectronic amd isolobal with a C-C segment, and can be replaced.
Making sure that proper reasoning is followed in generating the structure would ensure that you would have a better chance synthesizing the material, provided it has the properties that are of interest to you.


Django foreign key display values in detail view

Question: I have a main DB table Radni_nalozi (Work Orders) to which I am attaching Stavke (items) by a foreign key.
When I go to see details about a specific Work Order I also want to display all the items that are connected to that Work Order by a foreign key.
I tried many different approaches and it seems that I just can't figure it out on my own.
I am attaching the code below. In an HTML template, I can only fetch details about specific work orders but not the items.
Answer:
If you are using ForeignKey in django, you can access all rows that are in relationship with one row using "related_name" parameter.To get all the items that are connected to that Work Order(id=1) by a foreign key.
radni_nalozi_obj = Radni_nalozi.objects.get(id=1)
radni_nalozi_obj.stavka       //we are using related_name that is mentioned in "Stavke" model for "Artikl" foreignkkey.

In your detail view, you may have to modify the context object before returning.
Answer: Add get_context_data to your detail view in order to get the object and fetch all items related to that obj. Basically, this method replaces the default context provided by the DetailView, so you have to also include the object itself.
class RadniDetailView(DetailView):

    # ..... remain code ......

    def get_context_data(self):
        context = super(RadniDetailView, self).get_context_data()
        radni_obj = self.object # this contain the object that the view is operating upon
        context['object'] = radni_obj # don't forget this also

        # Get all items/Stavke related to the work order/Radni_nalozi
        context['items'] = Stavke.objects.filter(Rn=radni_obj)
        return context

inside HTML you can display all items like so
{% for item in items %}
   {{ item }}
{% endfor %}


How to determine which processes are using how much entropy from /dev/urandom

Question: Doing fuser -v /dev/urandom tells me which processes currently have /dev/urandom open, but only that.  Is there any was to determine anything about how much entropy each one is using up over time?  For instance, it might be that one process is using up about 1 bit of entropy every minute, while a different one is using up about 8 bits per second; I'd like some way of determining that.
Comment: `/dev/urandom` is not really an entropy source, it is a [PRNG](http://en.wikipedia.org/wiki/Pseudorandom_number_generator) reusing what is fed into `/dev/random` - estimating its entropy is questionable at best.
Answer: The short answer is 0, because entropy is not consumed.
There is a common misconception that entropy is consumed — that each time you read a random bit, this removes some entropy from the random source. This is wrong. You do not "consume" entropy. Yes, the Linux documentation gets it wrong.
During the life cycle of a Linux system, there are two stages:

Initially, there is not enough entropy. /dev/random will block until it thinks it has amassed enough entropy; /dev/urandom happily provides low-entropy data.
After a while, enough entropy is present in the random generator pool. /dev/random assigns a bogus rate of "entropy leek" and blocks now and then; /dev/urandom happily provides crypto-quality random data.

FreeBSD gets it right: on FreeBSD, /dev/random (or /dev/urandom, which is the same thing) blocks if it doesn't have enough entropy, and once it does, it keeps spewing out random data. On Linux, neither /dev/random nor /dev/urandom is the useful thing.
In practice, use /dev/urandom, and make sure when you provision your system that the entropy pool is fed (from disk, network and mouse activity, from a hardware source, from an external machine, …).
While you could try to read how many bytes get read from /dev/urandom, this is completely pointless. Reading from /dev/urandom does not deplete the entropy pool. Each consumer uses up 0 bits of entropy per any unit of time you care to name.
Comment: Although the answer is correct, it sort of misses the point I believe. The kernel does have an estimate on the amount of entropy available (readable from /proc/sys/kernel/random/entropy_avail) - and although it is not a reasonable practice, reading from /dev/urandom consumes it and makes processes reading from /dev/random block. So it is a perfectly reasonable thing to attempt to account which processes read /dev/urandom and how much, even if it does not make cryptographic sense.
Comment: See http://www.2uo.de/myths-about-urandom/ for details on why this answer is correct and which entropy is not quite the problem people think it is.
Comment: @CameronKerr From a cryptographic perspective, `entropy_avail` is not useful for the same reason `/dev/random` is not useful. From a practical perspective, `entropy_avail` is useful only to investigate why a program may be blocked reading `/dev/random`.
Comment: @Gilles'SO-stopbeingevil': exactly right; entropy_avail is highly useful from an operational concern (why are some workloads freezing occassionally?), which is presumably the OPs motivation behind trying to determine where the demand is coming from.
Comment: From a practical Linux perspective, I've found it very useful to look at /proc/sys/kernel/random/entropy_avail over time, particularly for Java workloads. (some versions of Java, before 8u??? read from /dev/random as well as / in stead of /dev/urandom by default, and this makes things like J2EE workloads start up very slowly and stall). Particularly on a VM where there is no keyboard-mouse activity. Note also that dd if=/dev/urandom of=/tmp/bigfile will also deplete entropy_avail and cause reads form /dev/urandom to block.
Answer: While not automated, you could use a tool like strace to watch for reads from the file descriptor(s) related to urandom.  Then see how much data is read over a specific time period to get the read rate.
Answer: There are a few ways you could approach the problem if you don't know (or don't suspect) which process may be depleting entropy_available on Linux.
As mentioned, you could use strace, which is great for getting useful insight into which processes you might want to look at.
You could use auditd to audit which processes open /dev/random or /dev/urandom, but that won't tell you how much data is read (to prevent logging issues). Here are some commands do list the rules and then add two watches
auditctl -l
auditctl -w /dev/random
auditctl -w /dev/urandom
auditctl -l

Now SSH into the box (or do something else you know should resulting in opening /dev/urandom or similar, such as dd).
ausearch -ts recent | aureport -f
In my case, I see something like the following:
[root@metrics-d02 vagrant]# ausearch -ts recent | aureport -f

File Report
===============================================
# date time file syscall success exe auid event
===============================================
1. 07/01/20 01:13:36 /dev/urandom 2 yes /usr/bin/dd 1000 6383
2. 07/01/20 01:16:43 /dev/urandom 2 yes /usr/sbin/sshd -1 6389
3. 07/01/20 01:16:43 /dev/urandom 2 yes /usr/sbin/sshd -1 6388
4. 07/01/20 01:16:43 /dev/urandom 2 yes /usr/sbin/sshd -1 6390
5. 07/01/20 01:16:44 /dev/urandom 2 yes /usr/sbin/sshd 1000 6408

Do disable those watches
auditctl -W /dev/random
auditctl -W /dev/urandom

Remember though that this only will capture data for system calls that aren't read/write etc. so if there is anything that already has it open, you won't see it being read.
However, I noticed (using Prometheus and node_exporter) that I was still seeing a sawtooth pattern whereby the VM (CentOS 7 with nothing to collect entropy) was reporting entropy_available raising up to nearly 200 and upon doing so would plummet back down to 0.
Does lsof (of fuser if you prefer) offer anything?
[root@metrics-d02 vagrant]# lsof /dev/random /dev/urandom
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
chronyd 2184 chrony    3r   CHR    1,9      0t0 5339 /dev/urandom
tuned   2525   root    5r   CHR    1,9      0t0 5339 /dev/urandom

Note though the character device major and minor numbers; testing another way... (I'm not sure if this would be useful, just thinking in terms of things like Docker, which is not running on this VM)
[root@metrics-d02 vagrant]# ls -l /dev/*random
crw-rw-rw-. 1 root root 1, 8 Dec 19 01:24 /dev/random
crw-rw-rw-. 1 root root 1, 9 Dec 19 01:24 /dev/urandom

[root@metrics-d02 vagrant]# lsof | grep '1,[89]'
chronyd    2184           chrony    3r      CHR                1,9      0t0       5339 /dev/urandom
tuned      2525             root    5r      CHR                1,9      0t0       5339 /dev/urandom
gmain      2525  2714       root    5r      CHR                1,9      0t0       5339 /dev/urandom
tuned      2525  2715       root    5r      CHR                1,9      0t0       5339 /dev/urandom
tuned      2525  2717       root    5r      CHR                1,9      0t0       5339 /dev/urandom
tuned      2525  2754       root    5r      CHR                1,9      0t0       5339 /dev/urandom

Okay, so we have two processes, chronyd and tuned. Let's use strace. lsof told us chrony had /dev/urandom open for reading using file-discriptor 3
[root@metrics-d02 vagrant]# strace -p 2184 -f
strace: Process 2184 attached
select(6, [1 2 5], NULL, NULL, {98, 516224}
.... (I'm waiting)

So chronyd is waiting for some activity, with a timeout of 98 seconds from when it started this system call.
While I wait, I should highlight that my activity on the system is likely to create increase the kernels estimation of available random bits. (entropy_available)... so sit back and just watch the Prometheus graph...

We can repeat with tuned too... (this time adding some timestamps and a grep filter just for file-descriptor 5 (the read etc. calls would have this as the first argument)
[root@metrics-d02 vagrant]# strace -p 2525 -f -tt -T 2>&1 | grep '(5,'

Red Hat have a blog that further discusses CSPRNG (Cryptographically Secure Psuedo Random Number Generator). It discusses some other ways that processes can get access to random numbers:

getrandom() system call  <-- recommended for RHEL7.4+, high quality without blocking after entropy pool has been initialised
/dev/random <-- will easily block
/dev/urandom <-- problem when used before pool has been initiased. Will 'never block'; should be what most applications should use.
AT_RANDOM  <-- sets 16 random bytes once at execve-time

While AT_RANDOM is not useful, it is present for every process, so just the act of starting a process should drain at least a little bit.
You'll realise now that what I've shown above using lsof is not enough, it doesn't reveal use of getrandom(). But since getrandom() is a system-call, we should be able to reveal use of it using auditctl
[root@metrics-d02 vagrant]# auditctl -a exit,always -F arch=b64 -S getrandom
[root@metrics-d02 vagrant]# auditctl -l
-a always,exit -F arch=b64 -S getrandom
[root@metrics-d02 vagrant]# tail -F -n0 /var/log/audit/audit.log
... (now we wait)

I got bored and ssh'd into the box, and I saw a lot of interesting cool stuff, but no getrandom(), which shouldn't come as a surprise as we saw it using the /dev/urandom API earlier.
So, trying to account for the depressions in the graph, nothing is opening /dev/*random, and nothing that has it open is currently using it, and nothing seems to be calling getrandom()... Is there anything else that would consume data from the [pool behind /dev/random]? What about the kernel? Consider functionality such as Address Space Layout Randomisation (ASLR):
https://access.redhat.com/solutions/44460   [requires subscription]
[root@metrics-d02 vagrant]# cat /proc/sys/kernel/randomize_va_space
2

'2' here means that in addition to randomizing where things like mmap and stack (etc.) get loaded it will also enable heap randomization. What happens if we turn that off
[root@metrics-d02 vagrant]# echo 0 > /proc/sys/kernel/randomize_va_space
[root@metrics-d02 vagrant]# cat /proc/sys/kernel/randomize_va_space
0

(Answer: same thing... perhaps someone else can illustrate this further)
The kernel will also be where AT_RANDOM is set. Here's a simple example which you can use strace to observe that it doesn't call /dev/*random or getrandom()
[vagrant@metrics-d02 ~]$ cat at_random.c
#include <stdio.h>
#include <stdint.h>
#include <sys/auxv.h>

#define AT_RANDOM_LEN 16

int main(int argc, char *argv[])
{
    uintptr_t at_random;
    int i;

    at_random = getauxval(AT_RANDOM);

    for (i=0; i<AT_RANDOM_LEN; i++) {
        printf("%02x", ((uint8_t *)at_random)[i]);
    }
    printf("\n");

    /* show that it's a one-time thing */

    for (i=0; i<AT_RANDOM_LEN; i++) {
        printf("%02x", ((uint8_t *)at_random)[i]);
    }
    printf("\n");
}
[vagrant@metrics-d02 ~]$ make at_random
cc     at_random.c   -o at_random
[vagrant@metrics-d02 ~]$ ./at_random
255f8d5711b9aecf9b5724aa53bc968b
255f8d5711b9aecf9b5724aa53bc968b
[vagrant@metrics-d02 ~]$ ./at_random
ef4b25faf9f435b3a879a17d0f5c1a62
ef4b25faf9f435b3a879a17d0f5c1a62

Hope that's useful.
Practically, I would first look to Java workloads first as that's where I've typically been bitten by this the most.  See https://blogs.oracle.com/luzmestre/why-does-my-weblogic-server-takes-a-long-time-to-start for an example.
Comment: None of which actually answers the question, which is how much entropy is being depleted **by `/dev/urandom`**.  It's in the title and body of the question.


Detect a person's motion and identify his body parts moving forward towards camera on Android

Question: I have this requirement where I need to detect body parts or objects moving towards camera. What are some of the sample projects or library that I can look for as a starting point.
I can take the first frame of the video as reference point and then any object that is moving forwards towards camera has to be perfectly detected.
The camera would be managed by a person so there would be some slight shaking so the background won't be exactly same through all frames.
Answer: There is a guy that uses opencv and python with a raspberry Pi. You have access to his source code Basic motion detection and tracking with Python and OpenCV but this is only a first part without limb detection. You could try to decipher the code and port to your needs. As for the limb detection that is a big project my friend.
Have a look at this hand / arm / head / legs tracking and this presentation Human body skeleton & tracking and also this function from openCV calcOpticalFlowPyrLK which could help you get started.
Answer: Augmented Reality is the KEY
"Augmented reality (AR) is a term for a live direct or indirect view of a physical, real-world environment whose elements are augmented by virtual computer-generated sensory input, such as sound or graphics. It is related to a more general concept called mediated reality, in which a view of reality is modified (possibly even diminished rather than augmented) by a computer. As a result, the technology functions by enhancing one's current perception of reality."
we can detect a person's motion and identify and body parts moving with Augmented Reality.
we did not have the sample code but there are some sample code for the Augmented Reality tutorials.
Please look into these links : http://www.instructables.com/id/Augmented-Reality-Tutorial-No-1-Marker-Based-Primi/
https://github.com/phishman3579/android-motion-detection
Answer: I think you should give this a try:
Why doný you use the Camera.AutoFocusCallback?

Callback interface used to notify on completion of camera auto focus.

I have no idea if it works but I think this is definitely the easiest option.


How to restore backups manually from Time Machine?

Question: I bought a new Mac a few days ago. I did a clean install, so I can start blank. Now I want to restore some files back from Time Machine to the new Mac. Is there a way to get the Time Machine interface so I can travel through my old backups using TM on my new Mac?
Answer: To restore the latest backup, connect the drive used for Time Machine to the new Mac and run <code>/Applications/Utilities/Migration Assistant.app</code>. There is also a support document from Apple covering this (but it reads some reading between the lines because it covers several use cases as once).
To access the backup as a whole, see this answer.
Comment: I just got the method to get access to my previous backups. My Mac User name is different from my last one, so he can't find older backups from my new mac name, that's right. So I retrieve the level inside finder so I see the user and from there I can access my older backups. Thanks for the time and answers!
Comment: Thank you for the answer. I tried the last option to get access to the whole backup. I access the TM interface after holding alt + click. I will see all dates at the right side, but there is now way to click on a date or travel back in time. What does I do wrong?
Comment: I can't verify this here. @grgarside, any idea?
Comment: I can only travel through "Programs", the tab "Documents" etc I can't access..


My image is not visible in render

Question: I'm just doing a simple 2D animation with a PNG file I made in GIMP. I have used this file before with no issue, so it is not a GIMP problem.
I can see my image perfectly until I get to render, than its all transparent. I have no idea why. One of the things I saw while googling this problem brought up checking my filters in the view layers properties and there is no filter option in my blender. I have uninstalled and installed again but no luck. I am very much a beginner so any help would be appreciated.
Answer: Let me guess: you have imported your image as a "background image" or "reference image" objects? They are not renderable.
You need to create a mesh the same dimension of your image and assign the image as a texture in its material.
An easier way to do it is to use the addon Import images as planes
Search it in the Preferences' addon category, enable it. Then you will be able to go to File → Import → Image as plane → browse to your picture. That will create the mesh with material for you.

My image is not visible in render


Dying Light Multiplayer Broke

Question: My friend and I got Dying Light on release day and have been playing multiplayer everyday since then. There were no problems. Then one day when we logged on we could no longer do multiplayer. When we go into our games, they say our game visibility is "Single Player", even though under options we have Friends Only for online. Changing the online setting to public does nothing. Restarting the PS4 does nothing. Does anyone know what to do?
Comment: I always had some probs in multiplayer, but i'll give it a New try now, just got the update now
Comment: well i just tested it and for me nothing changed, it's still unstable
Comment: So it looks like it had nothing to do with the update. We just had bad timing. The night before the update, we stopped playing right before the last main quest which you apparently must do by yourself. The game must have logic to block your mulltiplayer in this scenario.
Comment: Good to know however they should fix that and just stop the connection if you Start last Main quest
Answer: So apparently in addition to the prologue, the ending must be played by yourself. My friend and I just happened to quit right before starting the last mission. I guess the game has logic to block your multiplayer if you're on the last main mission, even if you have side quests. Once we finished the main quest we were able to do multiplayer again.
Answer: The main problem with the crashing until they fix it is that: the games restrictions on how "your" game and your partners games need to match the server is to tight. When you play note that the game will almost always crash during a change in the environment. An air drop, an event, and when the weather changes from sunny to rainy. Me and my friend tested this for a few hours last night and it seems to be pretty consistent. If one or both of you are lagging and the server does a check to see if you are both in the same game state and your not, it will always crash. They will fix it.

Dying Light Multiplayer Broke


What is the easiest way to add noise to a circuit?

Question: I'd like to have a sinousid wave with some noise. Then use that signal as input for an arduino, visualize that signal in Matlab and use a simple filter (moving average, for example) to remove the noise. To create the sinusoid I'm using a little DSO Nano v3 but I don't know a simple way to add noise (real noise, I don't want to add noise through Matlab).
Comment: Real noise can be created with a reverse biased transistor, then use HPF and amplify noise 1,000 times or more to be useful. Digitally, a true random number generator can emulate noise, though it is more of a 'pop-corn' noise than white or pink noise like a transistor would get you.
Comment: audio signal from an off-station AM radio
Answer: This circuit will get you noise; the output noise of Q1 is large enough (5 milliVolts RMS or about 30 mV Peak Peak for 6 sigma or about 1 part per million) to cause serious distortion across the base-emitter junction of Q2, unless Q2 has a large Remitter.
[ in the first version of this post, I made a GAIN error; the math shows Q1 gain is 200X, but I erred by
simply scaling the total integrated noise in the full bandwidth, or 28 microVolts, by 1,000X. Again correct scale factor is 200X]

simulate this circuit – Schematic created using CircuitLab
Notice the self-biasing of each stage: scaling the total base resistors to be BETA * Rcollector will cause Vcollector_DC to be nearly VDD/2 under all conditions.
This self-biasing, useful as DC as a operating-point servo-loop (regulator) also NULLS out the very low frequency SIGNAL, because low frequency simply looks like a variation in operating-point. Thus low frequency NOISE will be nulled out.
The bandwidth of the noise is probably set by Rc of stage1 and the Cmiller (input capacitance) of Q2. Wit 40X gain of Q2, and assumed Cob (C_collector_base) of 10pF, thus Cmiller is (1 + Av) * 10pF = 410 pF.
With Rc = 1Kohm, and Cload = 10pF (Cob Q1) + 410pF from Q2, the time constant Tau is 1K * 420pF = 0.42 microseconds, radian frequency of 1/0.42uS, Hertz frequency of 1/(2 * pi * 0.42uS) ~~ 400,000Hz. This is not the assumed 1MHz bandwidth. Your noise will be
about 3dB (0.707) lower than predicted.
Answer: Additional to what @Sparky256 said, you can simply generate true random noise with a reverse biased diode, followed by a high gain OPAMP. The output of the OPAMP can then be coupled onto the sine wave with a capacitor.


Why is it so difficult to stop Ad Blockers?

Question: My understanding of how ad blockers work is essentially that they just look at the domains sending the information. Why has no one been able defeat ad blocking software in a general sense?
Comment: As this is asked at the level of a practical security rather than the underlying science, I am migrating this question to [security.se].
Comment: I imagine that ad blockers regularly have their domain lists updated.
Answer: Adblocking works by either modifying the existing page so that it does not even attempt to load ads or by blocking the domains associated with ad-networks. From inside the current page there is nothing you can do against some extension or proxy denying access to a host, because this is simply outside of what you can do with HTML and Javascript. You could also not simply serve your ads from different hosts because this would need fundamental changes on the way ads are delivered, i.e. the model of few large ad-agencies which dynamically sell ad-space to affiliates etc.
The usual way adblock-blockers work is by including the ad-content from the same domain as the original page and avoiding URL's and HTML tags/attributes which might be typical for ads. This works mostly, but this way the ad-networks loose a large part of the flexibility (i.e. real time ad bidding). Also users can be tracked less (better for privacgy, worse for ad-networks) and the risk for the user to get infected by malvertisment is much lower.
The other way is to detect ad-blocking (i.e. detect if ads are loaded or not) and simply deny users access to the page if they have ad-blocking enabled. And to make sure that users don't work around outlaw bypassing the ad-block detection by using DMCA or similar laws. See Axel Springer bans adblock users from Bild online for a recent case.
Answer: That seems like a fairly outdated take on ad-blockers. There are a lot of different methods that they could use: prevent domain access, restrict known tracking scripts, restrict images of known advert sizes, restrict HTML elements with specific IDs or class names, disable types of active content (e.g. Flash) until the user chooses to load it...
Also, the authors of ad-blocking software tend to be very quick to react to changes made by advert publishers - they can push out updates on the same day if desired. On the other hand, advert publishers are usually running on much longer lead times - weeks or months, depending on the sites they affect.
Finally, ad-blocking has a lot more public support than advertising, at the moment, probably down to concerns with privacy issues and tracking. People don't like adverts "following" them around - Google even warns about this, whilst providing the tools to do it - and are realising that large numbers of adverts slow pages down. Therefore, they will report any adverts that do get through to the ad-block providers, whereas they are unlikely to tell an advertiser "well done, you got through my ad block".
Answer: Ignoring all theoretical and practical considerations, consider the psychology: Adblockers are used by people who don't want to see ads. What do you achieve if you get your ads seen on a computer despite the adblocker? Your ad will be seen by a person who most definitely doesn't want to see it. That person will not start buying the advertised product, instead they will be mightily pissed off and do everything in their power to keep all their friends and family from buying your product.
And then there is the small question of legality. By circumventing measures that I have taken to not display ads, you are hacking into my computer. Some people will take that seriously, will complain at the right place, and get you a substantial fine.


Do baking soda or vinegar reduce toxicity?

Question: Both baking soda and vinegar can be used to remove cigarette odor from cloth and surfaces, at least temporarily. Do they reduce toxicity of the third hand cigarette smoke too or just 'hide' the smell?
Answer: The toxicity of cigarette is due to nicotine. Nicotine is not deeply modified by adding vinegar or baking soda. Such an addition changes nicotine into an ammonium derivate that suppresses its odor and smell, but it does not modify its toxicity. Nicotine and its ammonium derivate have the same toxicity.


How do the GPIO Pins actually work?

Question: I recently started learning how to use the raspberry pi for robotics but ran into some problems early on as people, everywhere I checked,  were using the gpio pins with no explanation as to why they were putting them into each pin. Some would start by putting the female end into the physical pin 7 and then not explain why not into the first or second. Please help!!
Comment: Try some of the raspberry pi tutorials https://projects.raspberrypi.org/en/projects/physical-computing
Comment: why should there be a reason for picking pin 7 other than liking the number 7?
Comment: The best tutorials I found explaining ***how the GPIO pins actually work*** are the following:
(1) Digital Buffer Tutorial - Electronics Tutorials
https://www.electronics-tutorials.ws/logic/logic_9.html

(2) Pull-up Resistors - Electronics Tutorials
https://www.electronics-tutorials.ws/logic/pull-up-resistor.html. Happy reading. Cheers.
Comment: Of course you can dig deeper to say, logic gates, to know what the hell are are those weirdly looking "electronics symbols" etc mean. Oh, yes, there is also the "analog" stuff (Operational Amplifier etc) you don't know about.  But then life is too short to learn everything, In This Wonderful World: https://www.youtube.com/watch?v=R4GLAKEjU4w . Happy  living. Cheers.
Answer: Study the Raspberry Pi pin-out.  There are power pins, ground pins, and pins connected to General Purpose Input Output (GPIO).
All the GPIO may be used to read and write digital values.  Some of the GPIO can also implement specialist features such as serial links, SPI buses, I2C buses etc.
I suggest you study https://pinout.xyz/
Comment: Are there any videos you suggest?

How do the GPIO Pins actually work?


Are truth values of all mathematical statements immutable?

Question: Are there some mathematical statements whose truth values are not fixed, but can change? Probably something like 1+2=3 will always be true, but are there at least some mathematical statements whose truth values can change over time?
Comment: According to the mainstream view about mathematical theories, NO. A true statement about e.g. numbers has a definite truth value (either true or false) that does bot change over time and irrespective of the fact that we know it (i.e. that we have discovered a mathematical proof of it).
Comment: Note that for example in the intuitionist philosophy of Mathematics mathematical statements need not have a defined truth value. One there is a way to construct a proof for them, then they are true; prior to that, they are assumed without truth value. In this sense, the truth values are not fixed but change over time.
Comment: @Conifold You should probably post your comment as an answer. It answers my question well.
Answer: What counts as a "mathematical statement" is somewhat ambiguous. Do we count any statements that mention mathematical objects or concepts, or those that mention only mathematical objects and concepts, no concrete/real ones. On the broad reading (that people often take in everyday discourse, as in "I hate math"), mathematical statements can easily change their truth values, "the number of planets in the Solar system is a power of 2" changed several times throughout its history.
But this is not the typical approach in philosophy. In the closely related analytic/synthetic distinction what counts as analytic is that which depends only on conventions ("meanings"), anything that involves factual information is synthetic, even if it also depends on conventions. Although treating mathematics as purely conventional is controversial and, strictly speaking, inaccurate, it is still about abstractions, like sets and numbers, whether we think of them as conventional or not. Abstract entities are understood by most as causally inert and timeless in some sense, and that means that truth values of statements about them can not change, see Truth-value realism.
Of course, our conventions, i.e. definitions and/or axioms, can change. The concepts of "function" or "continuous function" do not mean today what they meant in the 18th century, see Function Concept on MacTutor. Given that, the truth value of the sentence "continuous function is differentiable at most points" did change from true to false. But most people would interpret that as equivocation, the same words simply refer to different things, so we are dealing with different statements. Even if statements stay roughly the same our beliefs about their truth value can change as well. Until the 19th century almost everybody believed that "the parallel postulate is derivable from the rest in Euclidean geometry" is true. But, on the majority view, its truth value was always false, we simply found that out only after hyperbolic geometry was discovered.
However, there are schools of thought, especially associated with confirmation holism and cultural relativism (Feyerabend, Kuhn, Bloor, French feminists), that see things differently, see e.g Bloor's Knowledge and Social Imagery. They see mathematical "truths", like all other "truths", as subsisting on transient paradigms or cultural conventions, and "timeless truths" generally as an exercise in mythical platonism or worse, the "tyranny of truth" with ulterior motives. On their view, abstractions come into existence with cultures that practice their use, and wink out of it with their passing. When conventions governing the use of abstractions change there is no platonic realm to pin their old "meanings" to, and so we would have to say that statements about them change their truth values as well, if they even still make sense.
Comment: *Of course, our conventions, i.e. definitions and/or axioms, can change. The concepts of "function" or "continuous function" do not mean today what they meant in the 18th century* -- I beg to differ. At least if you mean what I think you mean, because describing it it terms of "meanings" and "conventions" muddles the point. It much more useful to think about concepts and words, which denote them. Then it's it easy to see that while it may take time to refine our description of concepts and agree on the what concept is denoted by a particular word (e.g. continuous vs differentiable)....
Comment: ... *the concept themselves are timeless* -- they do not change. And they didn't -- for example, Euler's *understanding* of continuous function was no different from ours, according to the MacTutor page that you've linked. What might have been wrong is his *theorem* claiming that if a function is defined in a certain way, it must be continuous. Same as with Euclidean geometry. It is true now as it always has been -- as a special case of hyperbolic geometry.
Comment: @YuriAlexandrovich Euler's concept of function was "*an analytic expression composed in any way whatsoever of the variable quantity and numbers or constant quantities*". Modern conception, traceable to Fourier and Dirichlet, is quite distinct:"*a succession of values or ordinates each of which is arbitrary*". Given the 18th century idea of "analytic expressions" much followed from the first that does not from the second. And neither Euler nor even Cauchy had modern "understanding" of continuity, it is due to Weierstrass, hence the controversy over nowhere differentiable continuous functions.
Comment: OK, imagine an alternative history. Instead of stretching the meaning of "function" to every godawful edge case (so sought strictly for their horrendous depravity, caring little for being useless otherwise... and caring even less so for Poincaré's feelings... sending an occasional frog for Christmas hardly counts).... so imagine, instead, they would leave "function" to denote the same concept, and come up with new names for the above population? Like "map" for non-analyticals, etc?
Comment: To sum it up: the "abstract" objects being timeless means they *always* existed, and always will. Euler's "function" existed before he described it. And it always coexists (-ed) with its modern equivalent... The way we *reference* them is a different story.
Comment: @YuriAlexandrovich Ok, but how is this different from "same words simply refer to different things" in the post?
Answer: Propositions must not change within a set of rules, as per Aristotle's first law [1], which implies that a proposition must remain constant and identical on the set.
Elements that change along time (or another referential) are called variables, and its analysis of truthfulness implies including the referential. By doing that, the variable is not anymore the value of truth, but a function relating the variable and the referential.
Let me explain that a bit. Imagine that you have a variable position (x) that changes along time (t): 2 the first minute, 4 the second minute, etc. Then, x=f(t) (position is a function of time).
So, the proposition x=2 is true just for an instant, just like t=3. So, that's not the Aristotelian truth. The proposition which value of truth remains constant along all the analysis is x=2t. If you think it a bit, that a quite clever way to keep Aristotelian rules accepting variables that change along time.
[1] https://oregonstate.edu/instruct/phl201/modules/Philosophers/Aristotle/aristotle_laws_of_thought.html
Answer:
are there at least some mathematical statements whose truth values can
change over time?

No. Something can change over time ONLY if it is affected by time. And mathematical statements aren't, because they live in the abstract timeless universe that is Math. In it,  there's neither time nor change; no movement, no life. Perfect ice crystals arranged into ever more complex concepts -- endless φ-dimensional labyrinth frozen in time.
Now, as far as Math concerned, for all its intents and purposes, it is better to assume that the crystal-palace above is real, making mathematical truth objective and, thus,  universal (true for all, or for no one) -- just the way the real truth is objective and universal.
Back in the real world, we too better be real about having a telepathic link to cloud9... But, just as true, we are not doing Math, so HA! <== a perfectly valid answer for everyone, BTW.
And if only everyone could take a hint! We would live in a different, a better, world, where I wouldn't have to keep typing, and... you are still reading! why you are still reading?...
No, never mind. It's all in your head. All of it, as everyone else has a copy of everything. You have 9 and I have mine... Welcome to intersubjectivity.
Answer: Arriving at Truth by systematic preconditioning
The evaluation of any Mathematical object to be True, can only be by preconditioning a number of other equations to be True as well. Thus in this layer of abstractions, the lowest level should be the hardest to objectively prove (i.e. f(x) = 2*x = x+1 only if x=1; thus f(x=1) = 1+1=2; that is real number twice outputs the composition of these two numbers that is 2).
Hypothesis
The values (Truths) of hypothesis can change over time with respect to testing with different Premises. One of them is the Riemann hypothesis
.


How to check if PDF was successfully opened in the browser using WatiN?

Question: I am using WatiN library to do a quick smoke test on a web site after deployment. Among other things, I want to make sure that when I click on a specific link on my page, a PDF is opened in the browser. Clicking the link is easy, but how can I detect if Acrobat Reader was successfully opened in the browser window? I would like to catch situations like 404, server errors, or time-outs...
Answer: Rub,
I found one bug report and one feature request on this issue. Both the bug and feature request are closed but I am still not able to attach to a IE window that is hosting a PDF document.
In fact the window that is hosting the PDF file is not even an item in the IE.InternetExplorers() or the InternetExplorersNoWait() collections.
I'm using WatiN 188.8.131.528 and IE7 on Windows XP.
My solution was to use add a COM reference to Interop.ShDocVw.dll and check for the window myself since IE windows that host PDF viewers are not items in the WatiN.IE.InternetExplorers() collection for some reason.
Do NOT add a reference to Interop.ShDocVw.dll by using Add Reference -> COM -> Microsoft Internet Controls v1.1. If you do theres a good chance you'll recieve this exception:

System.IO.FileLoadException: Could not load file or assembly 'Interop.SHDocVw, Version=22.214.171.124, Culture=neutral ... or one of its dependencies. The located assembly's manifest definition does not match the assembly reference (Exception from HRESULT: 0x80131040)

Instead you need to reference the ShDocVw.dll thats distributed with WatiN. Check out the 'WatiN Error Could not Load Assembly' StackOverflow question for more info:
WatiN Error Could not Load Assembly
using System.IO;
using SHDocVw;

namespace PDF_SPIKE
{
    class Program
    [STAThread]
    static void Main(string[] args)
    {
        SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();

        string pdfViewerURL = "http://YourURL/document.pdf";
        bool pdfOpened = false;
        string filename;

        foreach ( SHDocVw.InternetExplorer ie in shellWindows )
        {
            filename = Path.GetFileNameWithoutExtension( ie.FullName ).ToLower();

            if ( filename.Equals("iexplore") && ie.LocationURL.Equals(pdfViewerURL))
               pdfOpened = true;
        }

        if ( pdfOpened )
           Console.WriteLine( "Your PDF file is OPENED" );
        else
           Console.WriteLine( "Your PDF file was NOT found." );
}

Answer: Thanks, MoMo, for this answer.  It was very helpful to me as well.
I would just like to give an additional solution to this answer just in case anyone else runs into same problem I did.
I initially received an error implementing this line:
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();

"SHDocVw.ShellWindowsClass cannot be embedded, use applicable interface instead"
The solution can be found here:
http://www.debugging.com/bug/24258
You need to right click on the reference Interop.ShDocVW.dll and set the embed interop types to false.


How to get a developer position with self taught skills?

Question: I am an experienced professional developer with two two year technology diploma from back 20 years ago (I also later did a Commerce Degree) and I want to get into a software development position using .NET.
How can I do this when I've not used it professional since 2013 (my last two positions were development a SQL db and a C like proprietary dev language). Plus I have limited web dev professional experience. I've created blogs and a professional site for myself various times over the years who'.
I've updated my knowledge in .NET Core through online classes.
It's fairly competitive out there now and my question is how do I convince an employer to give me a chance (in a .NET role)?
Is volunteering (work for free) on websites, for ex, something people think is worthwhile> Just to get some web development expertise. Thank you.
Comment: This may help you: https://workplace.stackexchange.com/questions/2595/effectively-adding-self-taught-skills-on-your-resume
Comment: Do you have a portfolio of recent .NET projects that you can show to prospective employers?
Comment: When did you last use .NET informally? You stated that professionally it was on 2013, but have you used .NET since then in any other situation?
Comment: Thanks VERY much for answers. I will create a portfolio of sites for potential employers to view. "No" to the the 3rd question. 2013 was the last time professionally I used .NET. I've coded personal projects on the side, though, to get some hands on experience. Thanks for the tips. Really appreciate it.
Answer:
I am an experienced professional developer with two two year
technology diploma from back 20 years ago (I also later did a Commerce
Degree)

I wouldn't include that on your CV anymore, world has moved on in the 20 years and this will bring your currency into question, as people will assume that you've been in the field all this time and that won't go well for you at all. Maybe mention that you have that degree but skip the 20 years part.

I want to get into a software development position using .NET. How can
I do this when I've not used it professional since 2013

The way I see it you have three main options:

Find someone who is willing to overpay you based on your future potential. This almost universally means taking advantage of an existing network of people and using those connections to get yourself a job for which you are not qualified yet, but with the assumption that you will grow into the role. If you do not have those connections then this is unlikely to work as strangers do not hire unqualified people to do a job where qualified applicants are available - and that's how you describe the market around.

Take an entry level job. As straightforward as it sounds, admit that your level of knowledge is around the entry level and seek out those jobs, while betting on yourself to quickly gain the required experience and knowledge to advance and make some proper money. For many people this is a non-starter as they cannot afford to live in on entry-level job wages, but if you can live on that for a year or two then this is very similar to option one, but you are the one taking the financial hit instead of the company.

Gain the experience as a side-hustle while working in your core competency. This means that you will have to keep working the job you are qualified to do now (maybe in reduced hours if you need it) and in the spare time work on some related projects. Delivering meaningful contributions to some established opens source projects is definitely a good way to establish yourself. You could also create your own, but then there is a very real risk that no one will ever know about it besides you, unless you are providing something unique, while improving an existing project guarantees recognition if you are willing to tackle the hard issues. This is a slow route to your goal but it's also relatively safe, you continue contributing, updating your cv that highlights your involvement with projects X, Y and Z and eventually you may just score a job.

I wouldn't even suggest trying to go freelance, unskilled part of that market is very much oversaturated, so you will be cutting price dramatically while delivering something that is unlikely to ever see light of day anyway.
Comment: Your first suggestion (get overpaid) sounds way less likely than him making even $1/hour freelancing which you tell him not to even try.  And how is it different from your second suggestion which you admit won't pay him enough to live on. I suppose you're really not saying that money matters in any of these cases but?
Comment: @HenryM I don't think that I follow what you are saying. Getting overpaid requires a network, it's as simple as that, otherwise it's a nonstarter. As freelancer with no skills on the market you will spend more time begging for a job than you will actually spend doing the jobs, unless something has changed in that area recently (but OP clearly says that it's highly competitive in employment, so freelance usually follows suit). But yes, short of option one, wanting to follow OPs desire is going to be expensive.
Comment: Presumably he doesn't have a network so as you say, option 1 is "unlikely to work".  The other options won't pay much, as you say. So none of these options are about making money. They're about gaining experience. In which case I don't understand why you tell him not to try freelancing.
Answer:
It's fairly competitive out there now - how do I convince an employer
to give me a chance?

You explain to them why you believe you can do the job they are trying to fill, and why you would be the best candidate for the role.
Comment: Fifty-something and as busy as I care to be.
Comment: Don't understand the downvote. All you need to do is demonstrate you can do the job. If you can, you might get it. If you can't, you won't, and that's only right and proper. The OP has experience, even if it's not the most recent thing they've been doing. They just need to apply for jobs. There's no secret handshake.
Comment: @Chewbacca you've provided an answer and multiple comments claiming that it's next-to impossible to get a coding job over 30 (or even 25!) and yet not a single shred of evidence that it's the case. Conversely, in my programming team there's two in their 20s, three in their 30s, one in their 40s, two in their 50s and one in their 60s. If you're struggling to find a programming job, you might want to stop and think whether it's really because of your age. It probably isn't.
Comment: Not the downvoter, but without a protfolio/experience you are unlikely to be given a chance to sell yourself with almost all companies, it will instantly go to the trash can.
Answer: If the OP is currently employed, in some sort of development or related roll, there is another path that wasn't mentioned by the other answers.
You can try to gain experience in your target technology, by doing side tasks, for your current employer.  At first, you can start very small, and be "under the radar".  For example, you could start using C# as a scripting language for all the small peripheral scripts/tools that developers write just to make their job easier, but that no one else knows about - collecting data, generating reports, configuring test runs, etc.
Once you get some experience, you can try to expand that to some scripts/tool that are used by others and are part of the "official" source code / tool chain.  Here you will likely need approval from a manager (as this is code that the company will use and maintain), but if you start small, you can present a solved solution for approval.
Finally, once you gain some buy in, you can try and convince your manager to undertake some tasks of considerably more size and scope in this new technology.  This might be especially powerful if you propose the project, and it's a project which can some useful impact to the firm, but still far away from the main-line product(s)/code-base.  A small web based tool for managing configurations, or collecting log output, whatever.
This allows you to learn the new technology, while remaining employed.   It will, after a year or so, allow you honestly describe yourself as a developer versed in this technology, and give you a portfolio of work to discuss.
Comment: I've done this for years and in several places. It works, mostly. The drawback is that you end up as a "lone-wolf" developer in a workgroup that isn't set-up as a development shop and with a manager that knows zero about development. When you try to reach out laterally to actual developers in the org, you're not seen as "one of them" and collaboration is an uphill challenge. However, it can be a good springboard into a development job in another organization-- people get started in all kinds of ways (not always smoothly) and this is one of them.
Answer: Given the context, I believe the best way to prove your skills in a given language is creating and maintaining open-source projects on websites like GitHub. Specially something that is user-facing rather than a complicated niche tool for programmers. Think of it like a portfolio or a model book. It shows that you can deliver stuff based on this technology by yourself at first. If people collaborate it even shows some people skills and business mind.
Note that is not that simple to get a recruiter to check your code, so maybe leave unclear in your CV where exactly each programming language was applied in your career. You'll handle this at the interview, and then you can explain about your open source projects. Don't expect a head hunter or HR person to check your code, but maybe your future manager might want to take a look at it, to check if it's well written, organized and if it has tests.
Answer:
A. Open Source.

B. Closed hobby project.

C. Self-employed work. See Freelancing Stack
Exchange

C. is more valuable to some employers. Others prefer A. B. can really help with first time jobs, I thnk.
Answer: Apply for management roles
You've got 20 years of experience and a Bachelor of Business? I'd say you're probably overqualified for a programming job - instead, you should be applying for jobs involving the management of programmers. Maybe a Team Lead role if you want to get your hands dirty with actual code, but most likely something like a Project Manager role.
Comment: What sort of ageist nonsense is that @Chewbacca? Besides that management can be as stressful as programming, but the idea that someone is "too old" for one but not another is just pure nonsense.
Comment: I'm 63.  I've been coding with some of the 'cool' new stuff.  @Chewbacca your comment is nonsense.


Is Darth Vader's suit waterproof?

Question: Yeah I know that Vaders suit could help him survive in the vacuum for a short amount of time, but would it work submerged under water?
Comment: As far as I know such suits are usually designed to withstand a certain amount of both extra negative and positive pressure. So if it could hold the air inside while in space, it could probably hold water from getting in for about the same time, but not necessarily.
Answer: After 15 minutes of assorted Googling, I was not able to find a single piece of canon  evidence pointing either way to the suit being waterpoof or not.

However, we know that the suit IS hermetically sealable and able to with stand vacuum.
As Wookieepedia says (sourced from Empire of Dreams: The Story of the Star Wars Trilogy):

McQuarrie added a distinctive skull-like helmet for the character when he read the script of Star Wars Episode IV: A New Hope and he became aware of the fact that Vader would have to cross through the cold vacuum of space in order to board the captured Tantive IV at the start of the film [EpIV: ANH - DVK]

It is fairly likely that a suit that is hermetically sealable against vacuum would also be sealed against water; and at the very least proof against some water pressure.

Having said that, we don't know if the suit's externals have any electrical systems that are NOT waterproof and can short out.
More likely than not that shouldn't be the case as we know TGFFA robotics technology is easily able to build waterproof mechanical and electrical systems, for example R2-D2 was none the worse for wear when he went swimming on Dagobah.
But there's no unambiguous canon proof.
Comment: I don't think I completely agree with this, if you think about it to survive in a vacuum any device would have to be designed to withstand pressure forcing it outwards. It is the exact opposite with water pressure, the device would have to be designed to withstand pressure from the outside coming in. You're probably right that it is "water resistant", but under higher pressures in deeper waters I doubt it would suffice.
Comment: @NominSim - which is **precisely** why I said "**some** water pressure" :) I am in no way sure that it is pressure-proof at depths.
Comment: To [quote professor farnsworth](http://www.imdb.com/title/tt0584455/quotes?qt=qt0432752) if his ship can survive 1000 atmospheres of pressure under water "Well, it was built for space travel, so anywhere between zero and one."

Is Darth Vader's suit waterproof?


Is there a way to apply the "Select features by rectangle\polygon...." function on multiple layers simultaneously?

Question: I have put a map together using openstreemap data that is intended to be used as a base for different projects. However due to the amount of information (number of layers) the loading time is rather slow. I was wondering if there is a way to select items in all layers within an area by using the selected features only once (well can be a few more times, but not once for each layer) and save them separately, so that I can load only the information within a specified suburb in a project, rather than the entire city?
Comment: [@Jason Tam](https://gis.stackexchange.com/users/59981/jason-tam), since you are working with shapefiles directly, then you can easily create a new layer, which will define the target area for your project. In the next stage, you just need to perform a clip action (Vector > Geoprocessing Tools > Clip) between your target area layer and all others. Could be much efficient to use PyQGIS or a Model. Alternative you may try the selection by location (Vector > Research Tools > Select by Location)
Answer: You could use the plugin "Clip Multiple Layers" (https://plugins.qgis.org/plugins/ClipMultipleLayers/) to do this. This will clip all of the layers within the extent of a selected polygon and save them to a location of your choice. You could do this for each district or area, then create a layer file for each group to allow you to easily drag in each batch of layers.
Note that for very large/complex shapefiles the process can be very time consuming and does crash occasionally. So limiting the inputs by getting rid of unused data is a useful first step.
Answer: It's difficult to use one unique tool to get this result.
You could merge layers and realize just one geographic request and later, split your result....but it's not the beter way and it's time consuming.
It's possible to get a result from many layers through many solutions :

SQL : Use postgis + Qgis to request layers (= table) and save results to different table (= import table to qgis as layer). You can connect postgis Databases to Qgis with database manager extension.
SQL : Use QSpatiaLite extension to directly create SQL request on Qgis and create dynamically your result without postgis or others outside tools
Use Qgis graphical modeler to automatically realize vector calculs and delete manual operations (http://docs.qgis.org/2.0/ca/docs/user_manual/processing/modeler.html)


Eclipse not showing Pydev in Preferences

Question: After installing Eclipse and python I am not able to see Pydev on eclipse. When I try to install eclipse again it is showing as duplicate location.
Comment: How did you installed Eclipse, via repositories or download from eclipse.org? Which version? How did you installed Pydev?
Comment: Installed both from Ubuntu software center, Eclipse Indigo, Python 2.7.
Answer: it seems that you installed pydev with wrong version. remember check your java version(by typing java -version in console). if it says 1.6.X, then you should NOT check "Show only the latest versions of available softerware" option in the first popup window after "Help->Install New Software" clicked. by uncheck that option, you will see a long list versions of pydev, pick 2.8.2. it will work well with your current java version. btw, if your java version is above 1.7, pydev's version should be above 3.0.
good luck!
Answer:
Dowload Newest Eclipse
Follow this guide to install pydev plugin:
http://pydev.org/manual_101_install.html
open"preference" and search "pydev"

Or
You can use "Aptana Studio"
Comment: I followed as it was mentioned in the link above. but again Python is not showing in preferences.
Comment: I tried everything I know but it is still no use. How can i remove eclipse from my computer completely so as to start fresh installation again.
Answer: Eclipse on Ubuntu (correct for 13.10) can not properly use plugins installed in the user's home directory. If you need PyDev or any other plugins not provided by Ubuntu, your only choice is to install it manually:

Uninstall Eclipse from Ubuntu.
Go to Home Folder, then press Ctrl+H.
Delete the .eclipse folder.
Reinstall Eclipse with this link.
Answer: Try "Help/Install New Software..." and instead of putting pydev link put this one http://download.aptana.com/studio3/plugin/install which is Aptana Studio that has pydev.
I've tried "Help/Install New Software..." quite a few times with http://pydev.org/updates but it haven't brought pydev into life. Eclipse would complain that pydev has been installed, but still would call gedit for .py files and there's no pydev in Window/Prefferences. I was already going to switch to something else, like PyCharm, but then gave it a try with Aptana Studio and i got my PyDev installed.
Answer: If you installed Pydev correctly, you should see an entry in Eclipse under Window -> Preferences:

Once there, go to Interpreter - Python, it should see all you python 2.7 libs automatically. If not click on the Auto Config button.
EDIT: ok i understand now. How did you installed Pydev? I simply went to Help ->Eclipse MarketPlace, then typed pydev on the search. In my case it's showing update because i already have it installed. It should be Install for you. Also i'm using Eclipse Java EE Juno 4.2 which i downloaded the binary from eclipse.org
Comment: I agree with you but in the preferences option I am not getting the option of Pydev. I installed Python 2.7 first using the Ububtu software Centre, then I went for Eclipse. I can run IDLE with no problems but still eclipse is not showing Python. I am using the same mechanism on Windows & it is working fine. I am not getting the Pydev option so that I could select the interpreter at all.
Comment: I edited my answer, please take a look.
Answer: Upgrade your version of Java. That will allow python to run.
Java 7 (or 1.7) is required to run the latest pyDev plugin updates.
Answer: Manualy download zip file from here and extract it, like suggested on PyDev install web site. Then go to directory where you installed Eclipse (default is /home/username/eclipse) and copy exctracted content into eclipse/dropins folder and restart Eclipse. Worked for me on Kubuntu 18.04 and Eclipse 4.7


What was Michael Emerson actually eating with the Lost Boys?

Question: There is a scene in the Lost Boys cave where David (Keifer Sutherland) and/or the Lost Boys play a prank on Michael (Jason Patric) while they were eating out of Chinese take out boxes. The contents of Michael's box toggled between being rice/maggots and noodles/worms. What was the actual food in the boxes? Were they eating Chinese take out, or were the vampires all eating maggots and making Michael think it was Chinese food?
Comment: I don't have a source to cite, but it was actually supposed to be noodles. The scene was a nod to the trope about vampires having the power of illusion.
Comment: @Omegacron: It's impossible to find a source for this. Evey description of the scene I can find literally skips the food and goes straight to the wine. Which the average teenage boy would probably do, granted, but it's not how the scene plays out.
Answer: James already has an accurate answer for you, but here's a transcript of the scene from the film's screenplay:

Marko suddenly arrives bearing cartons of take-out food.
MARKO: Chow time!
David takes the cartons from his hand.
DAVID: Chinese! Good choice.
  He pops the lid on one of the cartons and approaches Michael with it.
DAVID: Guests first.
Michael hesitates.
DAVID: It's only rice. Don't you like rice? 300 million Chinese people can't be wrong.
Michael takes the carton warily and David immediately turns his back on him, passing out food to the others. Michael takes a mouthful of
  rice using the plastic spoon provided.  The others begin to eat as
  well.
DAVID: So how do you like those maggots, Michael?
MICHAEL: What?...
DAVID: You're eating maggots. How do they taste?
Michael looks at his food.
CLOSE ON THE CARTON - A thousand wiggling maggots, squirming and sliding over each other. MICHAEL spits out his mouthful in horror and
  revulsion and throws the carton to the ground. But as the carton
  spills out, we see that it is just rice after all.
The boys LAUGH UPROARIOUSLY.  Michael looks mortified. Star gets to her feet.
STAR: Leave him alone.
DAVID: Sorry, Michael.  No hard feelings, huh? (offers a new carton of food) Here. Try these noodles.
Michael looks at the noodles and his expression turns to one of disgust.
MICHAEL: Ugh!
CLOSE ON THE CARTON - A hundred squirming earthworms fill the container.
David tilts back his head and pours the contents of the carton into his mouth. The slimy bundle of worms slides slowly across his lips.
Michael looks on with a sick expression. He grabs David's arm.
MICHAEL: Don't!  Stop!
DAVID: Why? (beat) They're only noodles.
David shows Michael the carton again.  And sure enough, they are only noodles. Michael is baffled. The boys have a good, long laugh at his expense.

Oddly enough, this ability to make others see what they want is never mentioned again, neither in this film nor the two sequels. And that's despite several situations where it would have proved quite useful. It's most likely just a nod to the trope that vampires have the generic "power of illusion".
Comment: Michael's first clue that something is not right: David's estimate of China's population is way off - it was more like 1 billion in 1987, not 300 million. :) http://en.wikipedia.org/wiki/China_population
Comment: @RobertF - true. He may have actually said "a billion" in the movie. Screenplays are rarely 100% accurate compared to the final result. I have it at home, guess I'll to watch it tonight :P
Comment: @RobertF He does say 'a billion' in the movie: https://www.youtube.com/watch?v=0A80j2BuMaU
Answer: They were eating Chinese take-out and making him think it was maggots. This was to set up the subsequent scene, where he won't believe the female vampire's claim that the 'wine' is actually David's blood. You can tell because the female vampire is honest with Michael about the wine, so she wouldn't have lied to him about the Chinese food (which I thought was rice, not noodles, but it's been a while since I watched it).
Comment: They had both rice and chow mein noodles, but I think the one Michael had was rice.
Comment: @Omegacron Ty. I edited the question.
Comment: I believe your assertion about the sequence leading to the "blood wine" is spot on. As stated in the @Omegacron answer, there was rice (maggots) and noodles (worms) both. +1 for a good answer.
Answer: The illusions were maggots & worms. Vampires CAN eat human food but it's tasteless to them. David played the mind tricks on Michael in case Star tried to warn him of the real contents of what was in the bottle.
Answer: I have always wondered if it was really maggots and worms as a snack since they are vampires and need blood to survive and the illusion was made to make it appear as actual rice and noodles so Michael wouldn't see what they are actually eating and then they stopped the illusion long enough for him to see that it was actually maggots and worms to mess with his mind and to add to the story of vamps being able to get inside someone's thoughts,but after all if Michael knew they were really eating maggots and worms,he would never drink the bloodwine and it would give them away perhaps before he was befriended, but also it could work the other way to cover incase the female was to tell him the wine was blood he would not believe her and drink it anyway as he did. But after all,they are vampires and can not eat regular food and the worms were the type of worms called blood worms so it really could have been maggots and worms and the illusion of real food but could Ben actually food and made to look like maggots/worms. Guess for the watcher to interpret his own way