When is a localization of a commutative ring finitely generated as an algebra?

Question: Prove or counterexample: If A is a commutative ring and $A_p$ is a finitely generated algebra over A for all prime ideal p of A, then A is a product of local rings.
Answer: Here is a counterexample. Let p and q be distinct prime numbers, let S denote the complement of {p,q} in the set of all primes, and let A denote Z[1/S]. Then the prime ideals of A are pA, qA, and {0}, the first two of which are maximal. Also, since A is domain (being a subring of Q) with two maximal ideals, it's not a product of local rings. On the other hand, the local rings at the various prime ideals are A[1/q], A[1/p], and A[1/p,1/q], which are clearly finitely generated as A-algebras.
Comment: Cool - I figured something had to go wrong without stronger finiteness conditions.
Answer: In the case that $A$ is noetherian and we replace finitely generated as an algebra with finitely generated as a module we can argue as follows. We have for any choice of minimal prime ideal $P$ of $\mathrm{Spec} A$ that $A_P$ is flat and finitely presented hence projective. It is also an artinian local ring. As it is projective the corresponding sheaf is locally free on $\mathrm{Spec} A$. But
$$\mathrm{Supp} A_P = \mathrm{Spec} A_P$$
so that if $\mathrm{Spec} A$ were connected it would have to agree with the spectrum of $A_P$ since a locally free sheaf has constant rank on connected components. Thus $A$ is in fact artinian and local.
$$ $$
If $A$ does not have connected spectrum then we can rewrite $A$ as $A_P \times A_1$. Where $A_P$ doesn't split up at all. We then just keep playing the same game (next with $A_1$) which terminates since $A$ is noetherian so has finitely many connected components and we in fact see that $A$ is a product of artinian local rings.
The stronger hypotheses I have are probably only somewhat necessary. I don't see a problem (except one needs to remove the word artinian) if one just assumes that the localizations are finitely presented as modules - there is the issue of whether or not this terminates but if you have an infinite product you also pick up extra prime ideals via choice and I have no idea what localizing at one of those would look like so I am not quite sure if this causes problems.
Comment: cool for the argument in the case of f.g. as modules
Answer: I think it's correct. Since the localization  A_p  is finitely generated over A for any prime ideal p, A has only finite maximal ideals. Now A is a semi-local ring, which is also a a product of local rings.
The following link maybe helpful
http://www.mathreference.com/ring-jr,sloc.html


Clone a working Linux server

Question: I need to clone a working linux server. We cannot shut down the working server. Is there any way I can get a clone and deploy it on another server?
Answer: There are many ways to copy disks, file systems or files.  Generally, copying the file system gives you a good clone with the flexibility that it can be a slightly different size on the target system.  With the target system running some sort of live Linux (knoppix, ubuntu live, etc.), booted from a cdrom, you can create the partitions on the disk using fdisk or your favorite partition application. Assuming you have an SSH server running on the source system, take an approach similar to this:
http://www.linuxfocus.org/English/March2005/article370.shtml
The magic is happening in this command:
ssh sourcePC 'dump -0 -f - /' | restore -r -f -

When using any particular method to clone disks on a live Linux environment, your only concern would likely be with the databases.  The best way to backup and restore a database is to use their dump tool to make an ascii file snapshot of the database just prior to the file system dump.  For mysql there is :
mysqldump --all-databases > mysql_databases.sql

For postgresql, there is:
pg_dumpall > pg_databases.sql

If you encounter any sort of consistancy error on the new system, restore the database.  Alternately, once you have shut off services on the source system, do the DB dump again, and restore on the target, and you will not miss any recently modified data.
Comment: +1 for the linuxfocus reference
Answer: Construct a disk layout on the new machine as you want it.
Use rsync to transfer the contents of the disk over.  Repeat a few times to catch up completely.
On the new machine experiment with what you will need to do additionally to boot properly.  Grub for instance, and get it to be in a consistent state.
Until you can shut the old machine down, rsync on regular intervals to keep the new disk close to the old one.
Then bring the old one to maintainance mode, rsync once more, and boot the new one which should come up behaving like the old one.
Comment: This could cause data corruption.  To guarantee a proper copy, of files (including live databases), you would need to be able to run the entire rsync command in one atomic operation, while the system was paused.  An LVM snapshot would be atomic, or building a RAID mirror and then disconnecting one of the drives and putting it in the new machine.  Even then though, you'd really need to go to runlevel 1 ( http://en.wikipedia.org/wiki/Runlevel#Typical_Linux_runlevels ), do the snapshot, and restart in a higher runlevel.
Answer: My coworker swears by System Imager:
http://wiki.systemimager.org/index.php/Main_Page
I don't know how well it would work for "live" systems.
Otherwise I think you are stuck doing things manually:

Verify there isn't any install applications outside of the repositories
Dump the list of installed packages and install them on the new server
Copy over config files
Restore databases
Comment: systemimager rocks. It does work on a live system, with the same provisos for running rsync to copy a live system's state. Some apps will need to be shutdown or dumped to disk (eg mysql DBs) before copying and will need to be restored on the new system.
Answer: Provided you can get your databases into a consistent state on disk, you could simply use DAR to make a copy of everything, then write it back out to your new server.
Syncing your databases to a consistent state on disk may be tricky, but just taking a snapshot and then restoring from that after you restore the DAR image may work. DAR will impact server performance while it's running.
Once you've got your image though, you can tweak the network settings and should be able to bring it back up no problem.
http://dar.linux.free.fr/

Clone a working Linux server


Redmine does not return the web page

Question: I migrated a Redmine installation from an Ubuntu machine to a Debian one (both 32-bits), and now for some reason, for some users it doesn't return the page but only a 200 OK message. Here is the flow (from Wireshark):
GET /issues/142 HTTP/1.1
Host: debian:3000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:17.0) Gecko/20100101 Firefox/17.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: _redmine_session=BAh7DCIQX2NzcmZfdG9rZW4iMStIM1RBNTlNelZVUXlUazgrR1pUNGUvNGdEbytUZzRyMVFSUnBvNGhlSDg9Ihd0aW1lbG9nX2luZGV4X3NvcnQiEnNwZW50X29uOmRlc2MiD3Nlc3Npb25faWQiJThiMDk0MzVhOTEzYTI0MzVjOGEzYTRmNDU0NzcwMTAwIgx1c2VyX2lkaQoiFmlzc3Vlc19pbmRleF9zb3J0IgxpZDpkZXNjIg1wZXJfcGFnZWlpIgpxdWVyeXsHOg9wcm9qZWN0X2lkaQc6B2lkaQo%3D--8588c221c0642a12f396239455fb702aec14c9c9; my_wiki_session=f70ae11e1c533c86f0e039d63cf3f69c; my_wikiUserID=1; my_wikiUserName=Yasin
Cache-Control: max-age=0

HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Wed, 12 Dec 2012 16:30:16 GMT
Server: WEBrick/1.3.1 (Ruby/1.8.7/2010-08-16)
Content-Length: 0

As you can see, I get nothing from the server. This is mostly random because this blank page happens sometimes for some users, and for other users it almost never returns the page...
This only happens for issues, any other page I've tested works fine (like listing the issues, creating a new one, etc...).

RedMine version 2.0.3 with WEBrick

EDIT: Looks like when people use the IP of the RedMine server (192.168.1.5) it works fine. But when using the host name, it doesn't show the issues (only the issues).
EDIT2: Now it shows all pages in blank...
This looks like random... I'm really lost here. Any idea about what can be the cause? Thanks in advance!
Comment: What Redmine version? What web server (passenger)? Installed all dependencies (gems)? File system permissions checked? What does it say when running in the built-in webrick?
Comment: Yes, sorry, edited the question.
Answer: I finally installed latest RedMine version (2.1.4) and followed all steps in the installation process (except initializing data to not overwrite my existing DB) and now it works fine.
I probably only forgot to run
rake db:migrate RAILS_ENV="production"

Redmine does not return the web page


Backtesting Period

Question: Views on timeframes for backtesting vary considerably.  Curious on what timeframe/trade size leads to a statistically significant result.  For example, what backtest period is reasonable for a system that trades roundtrip once per day and results in ~250 trades per year?  Two years, five years, ten years?  Intuitively I struggle with problem because market character/direction also impacts a strategies performance which can span multiple years and so that would suggest the test should span multiple bull and bear markets among other things.  So trying to find a reasonable balance that is practical but also statistically significant.
Comment: I'm not entirely sure how your backtest procedure will look like, but I think this article may be of interest for you: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2308659
They talk about minimal backtest length in a sense to avoid overfitting, which is not entirely what you're asking for. It still might give you some ideas on what period to choose from that point of view.
Answer: What you are asking is more of an opinion. In fact there is no right or wrong answer perhaps.

The caution with using statistics with real world backtests is that if anything looks good on one parameter, e.g. Sharpe ratio, it will look good on t-stat, p-value and pretty much everything else. The primary reason for backtest is to check if there are periods in the history when the backtests showed poor results in spite of an overall good performance.
The answer perhaps depends on the average holding period of your positions. If your trading strategy's average holding period is 2 months to say 6 months, even if the strategy re-balances (or trades) daily or weekly, it is better to use a long time, preferably 15 years. Definitely include two bear and two bull markets. A long term frame will highlight weaknesses in your models. If you are trading short term strategies that turnover within a 1 week or less, around 7-8 years may suffice. For intra-day or other high frequency strategies, which is probably your case, 3-5 years will do. More than 5 years may actually be incorrect for high frequency strategies as the market microstructure might have changed.
To distinguish backtested strategies that work out of sample versus those that won't, a better thing could be to concentrate on segments of your universe, i.e. will the same strategy work well (albeit with weaker attractiveness) if you take out parts of your universe (e.g. does it work well on large cap stocks OR does it only work well on small cap stocks, etc.).
Lastly, it's very easy to find strategies that worked well for 20 years and just when you start to trade it, it no longer works (in-sample bias). Backtested strategies that tend to work out of sample, in practice, also have an clear edge that you can define. Ask yourself what is the asymmetry in your strategy. Does your strategy makes sense! Example, take a hypothetical rule like "multiply price by 2.3, add 5 and subtract sqrt of volume" - even if this backtested well, there is no reason for it to work.
Answer: I don't think there's a robust statistical approach, without making some arrogant assumptions.

Because your statistical test window is also the window over which you have done your research, your test size is biased in ways you can not predict. For a statistical test to reliably reflect the chosen $\alpha$, your data not only needs to meet the estimator's assumptions, but you need to have pre-specificed your null and alternative hypotheses ahead of time. This is not the case in trading research: You try $N$ hypotheses, then run your statistical test on the most successful hypothesis. If $N>1$, you suddenly have a test that's heavily biased towards showing statistical significance of your system. I also don't think it's possible to know the extent of this bias of the test statistic since it's not something that increases linearly with $N$ (and there cannot be a concrete definition of $N$).
You could address this to some small extent by, for example, assuming $\alpha = 0.05$ and do some Monte Carlo with GBMs (correlations within the underlying Wiener processes) or with cointelated processes plugged into your system (note that you will have to plug these GBMs into every system you have ever tried, which means great source code management! I hope you have SVN or Github!).
There is also the trade off between statistical power and overfitting as you extend your test horizon, the former is calculable under distributional assumptions and the latter is not calculable. That is, your power is weaker over shorter horizons, encouraging conservative inference, but overfitting to temporary opportunities (or more likely noise) is more of a problem which encourages a type 1 error.
Of course you need to assume statistical stationarity, and the inefficiency that you have supposedly captured is going to last. Note that this implies that your null and alternative hypotheses that you will be testing are not the hypotheses that you wish to test.

If you don't care about the above, you can use:
How much data is needed to validate a short-horizon trading strategy?

Backtesting Period


Minecraft Backwards Compatibility

Question: I was playing Minecraft and got thinking. If I were to update my Minecraft from 1.2.5 to one of the snapshots would I be limited to servers of the same version or would I be backwards compatible with the older servers?
Answer: The server version and client version must match exactly or you won't be able to connect.
Comment: There are very, very specific exceptions (1.2.4 and 1.2.5, for example), but otherwise this answer is correct.
Answer: No, There is only a few exceptions (for example 1.2.4 & 1.2.5) but It has to match exactly, for example, I was trying to play 11.CBGA.ME (Super Craft Brothers) with a client version  1.4.7, but the server needs client version 1.5.

Minecraft Backwards Compatibility


Are there any Torah sections dealing with frustration and anger management?

Question: I'm often frustrated throughout the day by people who either have no regard for anybody except for themself or who are simply too negligent or incompetent to act in a reasonable fashion. I'm in a management position and this is not just me. Every manager I work with comments they thought there was an enlightened way of managing, but once they actually had to supervise a bunch of people they become very frustrated and snappy. I feel like there is infinite, perfect wisdom in the Torah to deal with every issue, but I'm not so much of a Torah scholar. Per chance does anybody have advice from Torah or Talmud-based sources?
Comment: Related: http://judaism.stackexchange.com/q/37531. Also somewhat related: http://judaism.stackexchange.com/q/40851 http://judaism.stackexchange.com/q/3796, and to a lesser degree http://judaism.stackexchange.com/q/51091.
Comment: With all due respect to Moshe Rabbeinu, but he was also frustrated and got angry numerous times. One of the times that he got angry, it cost him his opportunity to lead the people into Israel. That's not just a personal consequence, but a "managerial" consequence, as well. He was supposed to LEAD them (manager) into Israel. Anger cost him that opportunity. I think that this serves as a good example of what anger can do to anyone, esp. a manager. BTW - Ramba"m Sefer Ahava has a major section about anger. Would that serve your purpose?
Answer: The topic of anger is mentioned in Torah and Tanakh, discussed in the Gemara, by Rishonim such as Rambam, and by many later rabbis as well.
See here for a discussion of Rambam's view of anger.
See here for a chapter about anger in The Ways of the Tzaddikim, an anonymously-authored work that first appeared in the 15th century in Germany.
See here for a chapter on anger from Likutei Eitzot, a selection of practical advice from the teachings of Rebbe Nachman of Breslov, compiled by his closest follower, Reb Noson.
For a more Litvish contemporary perspective, see Rabbi Zelig Pliskin's book on the subject of anger.
Comment: @Baruch If he answered your question 100%, consider clicking on that little checkmark to accept his answer.
Comment: Thank you. You're really impressively knowledgable. This, plus clarification through prayer, answered my question 100%.
Answer: Regarding the Rambam's view on anger, it should be noted that in Laws of Tshuva (7:3) he writes that one must repent for becoming angry!

אַל תֹּאמַר שֶׁאֵין תְּשׁוּבָה אֶלָּא מַעֲבִירוֹת שֶׁיֵּשׁ בָּהֶן מַעֲשֶׂה כְּגוֹן זְנוּת וְגֵזֶל וּגְנֵבָה. אֶלָּא כְּשֵׁם שֶׁצָּרִיךְ אָדָם לָשׁוּב מֵאֵלּוּ כָּךְ הוּא צָרִיךְ לְחַפֵּשׂ בְּדֵעוֹת רָעוֹת שֶׁיֵּשׁ לוֹ וְלָשׁוּב מִן הַכַּעַס
Don't say that repentance only applies to sins which involve physical acts such as licentiousness, or forms of theft, rather, just as one must repent from these, so must he examine his improper character traits which he possesses, and repent from anger, etc. (Trans. my own).


What are some useful excercise which I can do to prevent back pain?

Question: I work on desktop everyday in my office and due to this I am suffering from lower back pain. I want to know if I can really get relief from back pain by doing some form of exercise. And which physical exercises might be helpful.
Comment: Which readily available advice about back pain exercises is not working for you? I would say that the single most likely thing to help would be to **change the chair** you sit at, and also get your posture, the position of the screen, mouse and keyboard right. Also get up from your workplace and move around at least once every hour.
Comment: Hi Janny, Welcome to Lifehacks. Have a look at Ergonomics as a subject devoted to the efficiency of the human body in a work (or productive) environment. It deals with the position and distribution of your body to environmental (gravitational) influence. Proper ergonomical position diminishes physical and physiological stress.
Comment: Questions about health issues should be directed to a suitably qualified healthcare professional, not random unqualified individuals on the internet who cannot examine you or know anything about your personal situation
Comment: Some people develop back pain simple because they are sitting on their wallet that is rather thick. Doctors, in this case recommend either alternating rear pockets or put your wallet in your front pocket. Sounds simple, but it does work, if this would in fact be the cause. In my case, it work marvellously.
Answer: Core body strength will help keep you spine stable an "in place".
There are different kinds of exercises to strengthen your core- from traditional gym work on the right machines (consult an instructor first) through Pilates or Yoga (involving a bit of the spiritual side) or specialized core sessions down to Alexander Technique (somewhat controversial afaik)
Answer: I can't say that my back pain was the same as yours, but when I need a new chair I bought a typist's chair to work at my desktop PC because I don't like those "manager style" office chairs which are only comfortable if you are leaning back and directing others.
The chair I bought felt very comfortable. The seat was slightly dished and supported me nicely. Yet I started to get back pain and I didn't know why. Then when I thought about my posture carefully, I realised that my pelvis was tipped back very slightly because of the dished seat.
So I tried another chair with a seat that tipped my pelvis very slightly forward, and the trouble went away very quickly. I was amazed that such a small difference in posture could be significant.

The height of the screen must be right, and your forearms relative to the desk. You should be sitting upright with your body straight towards the keyboard and screen, not twisted.
You also need the right glasses (if worn). I have been to opticians who don't ask what my reading glasses are for, and I found I need different a prescription for reading a book, and when using a computer screen. The 'book' reading glasses were making me hunch forward towards the screen, causing a bad posture.
Answer: Some people develop back pain simple because they are sitting on their wallet that is rather thick. Doctors, in this case recommend either alternating rear pockets or put your wallet in your front pocket. Sounds simple, but it does work, if this would in fact be the cause.
In my case, it worked marvellously.
As for exercises, I would recommend seeing a doctor or health care professional as you do not want to do more damage if this is the case. Make sure you do not have an underlining condition first.
Answer: You can have the most expensive and mechanically advanced equipment which will cause all manner of damage and loss of productivity if used incorrectly and the simplest of setups for years without complications. The key to success is HOW you use your assets.
Ergonomics concerns the study of our efficiency in a working environment.
Volumes have been written and illustrated concerning the optimal work station position, standing, kneeling, and sitting. Perform a Web search for Office Ergonomics for more detailed discussion of the best practices to employ for you specifically.
When your workstation is set up correctly according to ergonomic guidelines, you will

Be less likely to have problems such as headaches or eye strain.
Reduce neck and back pain.
Prevent bursitis or tendon problems that are linked to doing the same task over and over (repetitive tasks).

The only tool you'll need for a lifetime of relief is a tape measure.
A good place to begin is with this How To guide from the MAYO clinic.
Answer: Using a ball chair can help strengthen your core.  I recommend the ones with the locking wheel base and the ball should be the right height so your elbows are at a 90 degree when typing.
Intermittent breaks from long periods of sitting helps more than exercise.


Definition of a model in machine learning

Question: This definition does not quite apply since we are not always assuming an underlying distribution. So what is a model really? Can a Gradient Boosted Model (GBM) with specified hyperparameters be considered a model? Is a model a collection of rules?
Comment: You could just take one step further generic-ness and look at https://en.wikipedia.org/wiki/Mathematical_model - most ML models will match that definition, even if they do not match "statistical model" (although I think almost all trained unsupervised or supervised ML models would be considered statistical models).
Answer: I was interested in the same question recently and came to the realization that there is no single definition of a "model" in machine learning. It's highly dependent on the sources you're consulting, which may be the documentation for a particular software program, the slang adopted by its user community, or the definitions used in published academic papers, which can vary widely from journal to journal. Moreover, I had to learn to keep in mind that such papers are written not just by specialists in machine learning, but by experts in other disciplines who have a need for applying machine learning techniques (such as imaging, various medical fields, etc.). Many of them do not explicitly define the term "model," which is often used loosely. Here are just a couple of different definition of "model" I've seen in all this widely scattered literature:
• Statistical models, particularly the stats related to probability distributions.
• Regression data and related statistics.
• Mathematical models as mentioned by Neil Slater above.
• The data models used in machine learning, such as the columns involved, their data types, the data sources and other metadata. This is particularly tricky because there's nothing mathematical about this definition at all, unlike the first three I listed. For an example, see all the documentation for SQL Server "mining models," which serve double-duty for machine learning purposes.
• Sometimes all of the definitions above are expanded to include machine learning structures built on top of the equations and the metadata, such as the specifications of neural nets. In other cases, these are considered separate entities.
All of the above are sometimes mixed and matched together, depending on the source. I'm sure there are other definitions of "model" I've left off this list, which will complicate the matter even further. To deal with this ambiguity, I'm trying to train myself to divine the intentions of the author whenever they use the term "model." Sometimes it's easy to determine based on the context or the field the author works in, but other times I have to read deeply into an article or documentation before figuring it out. I wish I could be more definitive about it, but it's really a naturally fuzzy term; there's never going to be a simple one-size-fits-all answer to this. I hope that helps.
Comment: While the term "model" might indeed apply to plenty of things, in the context of Machine Learning, the model is the artifact created through learning/training - e.g. in the case of neural networks the weights and biases of that network.
Comment: I think you are missing the link between model, hypothesis and hypothesis space. In some way the ML algorithm searches through the hypothesis space to come up with the best fitting to make predictions on the data also check [this](https://stats.stackexchange.com/a/236669/340682) for rererence
Comment: Even though the ML model is often a quite theoretically approach the result of learning the model could definitely be applied to a concrete hypothesis so it relates back to the normal meaning of a model in general language (simplification for understanding). This thougt makes since at least when I think of a couple of different ML approaches.
Answer: From article on Amazon Machine Learning
The process of training an ML model involves providing an ML algorithm (that is, the learning algorithm) with training data to learn from. The term ML model refers to the model artifact that is created by the training process.
Answer: I like the Machine Learning definition given by Tom Mitchell.

A computer program is said to learn from experience E with
respect to some class of tasks T and performance measure P
if its performance at tasks in T, as measured by P, improves with
experience E.

So, given this definition, I should say that a model is the acquired experience after doing some task T.
Comment: Isn't the experience E the training set?
Comment: Tom has also a great definition on hypothesis and hypothesis space, I should say that a model is the acquired experience after doing some task T learnt through falsifying hypothesis from a given hypothesis space. There even might be different hypothesis spaces relevant for a problem. For reference check both answers So S and Lerner Zhangs answere [here](https://stats.stackexchange.com/questions/183989/what-exactly-is-a-hypothesis-space-in-machine-learning)
Comment: Experience would be a linking word, you need something that experiences - the ML algorithm, and something to experience - the training data. So the ML alg. "experiences" the data, and the result of that "experience" is some parameters which would substitute the variables of a formula/equation. That "explicited" / concretized equation is what is most generally used as "model". Mitchell doesn't use the word model in that definition, so nothing can be inferred about 'model' from that. The word is also used for other things than experience. For me it is the result of that experience: equat +values
Answer: A model, loosely speaking, is a simplification of some thing or process. For example, the shape of the Earth not actually a sphere, but we might treat it as one if we are designing a globe. Similarly, assuming the universe is deterministic, there is some natural process which determines if a customer will buy a product on a website. We might construct a something that approximates that process, which we could give some information about a customer and which tells us if it thinks that customer will buy a product.
A "machine learning model", then, is a model constructed by a machine learning system.
(Apologies for this not being a rigorous answer, but I hope this is still useful.)
Comment: I would love to see a connection to the hypothesis and hypothesis space in your answer
Answer: In machine learning paradigm, model refers to a mathematical expression of model parameters along with input place holders for each prediction, class and action for regression, classification and reinforcement categories respectively.
This expression is embedded in the single neuron as a model.
For single layer perceptron and deep learning model, one needs to extract this model by carefully walking the neurons and layers to collect and stitch activation function in an ordered fashion.
Answer: In machine learning, a model is an abstraction that can perform a prediction, (re-)action or transformation to or in respect of an instance of input values. A model could be a single number such as the mean value of a set of observations which is often used as a baseline model, a polynomial expression or a set of rules (e.g. decision tree) that define how to get to generate the output.
In general, a model is defined by a set of rules and hyper-parameters that define the model's structure and capacity to be optimized to perform the task at hand. A hyper-parameter could be the degree of the polynomial or the depth of the decision tree. A model can be subjected to an optimization process where parameters are optimized against a certain objective.
The optimization process is often referred to as training for fitting and results in a fitted model, which also can be simply referred to as model. If a model was trained or not often needs to be deduced from the context.
Answer: In machine learning, the model is the center of gravity,  everything revolves around it. Yet, people have different definitions of 'model'; but in my opinion, the best definition of model in ML is "the hypothesis that has learnt to predict, i.e. to fit, unseen data".
Answer: This is a fun discussion! My two cents are that a model is stored information that a computer can interpret to estimate mappings from some set of possible inputs to a set of appropriate outputs. A model is nothing more or less than the definition of a simple function that approximates a more complex function. It's not necessary for the complex function to be a real-world phenomenon, only for the model to approximate the complex function without storing sufficient information to reproduce it perfectly.


Where can I find a map or list of places that have Northern & Southern Lights?

Question: I'm a huge fan of Aurora Borealis (Northen Lights) & Aurora Australis (Southern Lights) and I was planning my next vacation to one of the areas where I might get a chance to view them in person. However, besides the typical answer of Norway or Sweden, I want to know where else can one see such sights. Can someone please help by providing me with a link or reference to such a resource?
Comment: Welcome to TSE.  As asked this question is too broad. You can either ask for online resources to find the locations or narrow the question down to just one or at most two countries, (which changes your question a lot.)
Comment: Everything north of, say 65°N or south of 65°S.
Comment: @Jan Actually, I think it's more like a ring, there is such as being too far north or south.
Comment: For viewing, it is not just where the lights happen. You also need a clear sky. low light pollution, and a view of the appropriate horizon. I think Norway and Sweden get recommended because they have a lot of locations that meet all the requirements, not just being far enough north.
Comment: Hi, welcome to TSE. I edited your question to prevent it from being broad, hope you don't mind. You can roll it back if you want, but that might cause it to be closed.
Comment: Here .. http://www.aurorawatch.ca
Answer: The Aurora Forecast is one of the best resources I have found online for locating Aurora Borealis. It's a correlation between solar wind data from NASA and magnetic data from around the world.
But that requires you to already be in the Northern Hemisphere, as the long term predictions are not that accurate. But, if you read through the whole resource, you will better understand how far south you can see the Northern Lights and under what conditions.
I feel like it is quite rare to see lights going further south than Kp4 or Kp5, but it does happen once in a while.
There is also the same website but for Aurora Australis. And as you can tell, they are harder to see from common tourist destinations, as it has to up to Kp7 for them to even reach Tasmania.
Comment: Also, be aware of THIS:  http://www.aurorawatch.ca and similar sites/services


What design reasons have been given for the fact that armor doesn't break?

Question: In D&D objects have hitpoints values, but when I equip a suit of full platemail it doesn't grant me protection in the form of its own hitpoints before any actual damage is applied to me. Have any D&D designers said why armor is designed this way?
Comment: To the people voting to close: This question is a lot like [this one](http://rpg.stackexchange.com/questions/41089/what-explanation-do-the-dd-devs-have-for-designing-spontaneous-casters-to-lose).  While the question as asked will almost certainly never have a real answer, since the querent is specifically asking for developer commentary, the question is answerable without getting into opinion.  "Why is it like this" is opinion-based, "What have the developers said about their design" is not.
Comment: Welcome to RPG.se! Take a look at the [tour]; it's a useful introduction to the site. Questions of the form "why does the game work the way it does" tend to not work here—they collect a bunch of opinions instead of answers supported by research—so they're generally closed. I've changed this to ask if there is any designer statement about it, and if so, what they've said. *Alternatively*, if what you really want is people to discuss and speculate on this topic, you may just want a [discussion forum instead](http://meta.rpg.stackexchange.com/q/5449).
Comment: While I doubt the designers of *D&D 3.X* weighed in on this specifically, it's possible designers of *other* editions have, as the Armor Class *concept* has remained largely unchanged since the mid-70s. This might make a better gaming lore question so as to cover all *D&D* editions. (One of the few questions I've seen that might benefit from an *expanded* mandate.)
Comment: Would it bother you if there isn't a design reason?
Comment: Also, is there a comparison you can draw between the way that *D&D 3.X* handles armor and the way another game handles armor in the way the question describes? (That is, the Palladium Books house system tracks armor damage, as do some RPG-war game hybrids (I'm thinking classic *Car Wars* here), but offhand I don't know of any modern RPG systems that do.)
Answer: I'm not sure this answer is exactly what you were expecting, but the question has got none yet. So I'll take a risk to make use of your exact wording "any D&D" (though you may have meant "any designers").
From AD&D 2E DMG:

Damaging Equipment
For the most part, specific damage isn't applied to equipment under the AD&D rules. This doesn't mean that equipment is never damaged or broken. Instead, it is assumed that whatever normal wear and tear an item may suffer (such as dents in a suit of plate mail) are repaired during moments (or days, or months) of inactivity.
The fighter spends time in camp sharpening his weapons, patching the rips in his chain mail, and hammering out the dents in his breastplate. The thief repairs the padding that muffles the clinks of his metal buckles. The mage sews patches onto his clothes. All characters have ample time to make repairs. It's not very interesting to role-play, so it is assumed all characters maintain their equipment.

Thus at least designers of the previous edition explained it explicitly. They didn't think it was interesting. The concept of damaging objects has been taken to the 3e with only few changes (it was expanded with sunder combat action and object hardnes but the core concept remained the same). So we can assume that designers of D&D 3e either shared this view or just have taken the concept as is.
Comment: @KRyan I've reviewed relevant sections of PHB 3.5 (armor, sunder, smashing an object) and DMG 3.5 (damage) and found nothing. Though it can be somewhere else.
Comment: I've recognize those paragraphs, and I never played 2e. They may very well also appear in the 3e and/or 3.5e DMGs. Though someone could have just quoted in a discussion about 3.x, perhaps. So +1 either way, but if you have some time to look through the 3e or 3.5e DMGs the answer would be even better.


Mouse not recognized in USB port, but it does work through a hub in the same port

Question: (ubuntu 13.04)
If I connect my mouse in one USBv2 port on my laptop, it does not work. This is the output I get from dmesg:
usb 1-1.2: new full-speed USB device number 21 using ehci-pci
usb 1-1.2: device not accepting address 21, error -32
usb 1-1.2: new full-speed USB device number 22 using ehci-pci
usb 1-1.2: device not accepting address 22, error -32
hub 1-1:1.0: unable to enumerate USB device on port 2

Now, if I plug in a USB hub in that same port, I get:
usb 1-1.2: new high-speed USB device number 23 using ehci-pci
usb 1-1.2: New USB device found, idVendor=1a40, idProduct=0101
usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
usb 1-1.2: Product: USB 2.0 Hub
hub 1-1.2:1.0: USB hub found
hub 1-1.2:1.0: 4 ports detected

and, if I now plug the mouse in one of the ports of the hub I get:
usb 1-1.2.1: new full-speed USB device number 24 using ehci-pci
usb 1-1.2.1: New USB device found, idVendor=4168, idProduct=1011
usb 1-1.2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.2.1: Product: Targus Wireless Optical Mouse
usb 1-1.2.1: Manufacturer: reserved
input: reserved Targus Wireless Optical Mouse as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.1/1-1.2.1:1.0/input/input15
hid-generic 0003:4168:1011.0005: input,hiddev0,hidraw0: USB HID v1.11 Mouse [reserved    Targus Wireless Optical Mouse] on usb-0000:00:1a.0-1.2.1/input0

and the mouse works perfectly.
Well, I hope I can make the mouse work directly in the port without the hub.
Thanks in advance for any help!
Answer: Well, a transitive kind of relationship.
A (your OS)does not recognise B(mouse), so A does not connect to B.
C (your hub) knows both both A as well as B, so connects.
Funny thing, but what else to say here.


Bathroom exhaust fan/light combo only fan works

Question: I bought a new bathroom exhaust fan and light combo. It came with two sets of wires, one for the fan and one for the light. It also came with an extra ground for the motor (where should I put that)? So I wired the two hot black wires (one for the fan and one for the light) onto the one red wire for the switch. I then wired all the neutral wires together and all the grounds together, even the one for the motor. This was all done in a junction box with three sets of wires coming in, plus the wires from the fan/light combo. When I turned the breaker back on and flipped the bathroom switch, just the fan came on with no light. All other connections seem secure. Does a fixture like this have to be wired onto two separate switches? I figured just the one would be enough. I am also using LEDS for the lights. The instructions don't even have a number for the company... Any help would be greatly appreciated!
Comment: According to your description, the lamp and the fan should be getting the same voltage  If the light is not on, first try an incandescent bulb and if that works try a different LED.  Also check the LED bulb in a different fixture.
Comment: One is enough, but a photo might reveal the problem. Your description doesn't. The "extra ground for the motor" doesn't make much sense to me. You might edit to also list the fan model.
Comment: What make and model is this exhaust fan?
Comment: You just have a faulty product like mine. Everything is wired correct. And now I don't have either fan or light.
Answer: You will have a light ground and a fan ground...so read the directions that came with the purchase as it will tell you where to attach the additional ground.  In many cases its a metal strip that the other ground also is attached to... otherwise try contacting the company that manufactured the unit and they have help desks.  But you also may want to hire a qualified person to install that for you...
Comment: Check to make sure the bulb is working.  Then double check your wire nut connections.
Answer: Based on your description of how you wired the circuit both your light and fan should run.  Easiest thing to check is if the bulb was good in another lamp.  The unit you bought could be operated with two independent switches or with one.


How to delete my favorites?

Question: I specify lots of question as my favorites without attention. Now my favorites become useless and unmanageable. I wish to find any way to delete them all and start to make as favorites with more attention for the next time in order to do a better search between them. So is there any way to undo favorites?
Comment: Are you just asking how to remove one question from your favourites or all at once? For one, it's simple, just click the star to undo.
Comment: @LiveWireBT I want to remove all of them
Answer: There is no "bulk" way of removing favorites, but there is a way which is somewhat easy.
Go to your favorites page, and click on the favorite icon of each question one by one. At least you won't have to go into the question's page each time.
Comment: I was kind of sure that the api provides a way to do this.

How to delete my favorites?


Should a Jewish cashier scan treif items?

Question: On the basis of Vayikra 11:8, is it permitted to work as an employee at a grocery store as a cashier (not the owner of the business), which would entail touching packaged yet non-kosher food items when you need to scan them? I am asking solely from an employee vantage point, not an owner – the employee making no direct benefit from the transaction other than an hourly wage to scan items and work the till.
Comment: It seems that the focus of your question is can a Jew touch a packaged non-kosher item, correct? We do this often, in the super market, already! Unless you purchase it, why should there be a problem? You gain no benefit from it.
Comment: @DanF, note the first six words of the question.
Answer: Since the question is asked based solely on Vayikra 11:8, the answer is (as quoted by Rashi there, but this is the generally accepted view) that there is no issue with touching them, except in connection with the Temple at the time of the holidays of Pesach, Sukkos and Shavuos (or any other time a Jew wanted to be there).

and you shall not touch their carcasses: One might think that Israelites are prohibited to touch a carcass. Scripture, however, says, "Say to the kohanim …[(a kohen) shall not defile himself for a (dead) person among his people]" (Lev. 21:1); thus, kohanim are prohibited [from defiling themselves by human corpses], but ordinary Israelites are not prohibited. Now a kal vachomer can be made: Since in the more stringent case of defilement by a human corpse, only kohanim are prohibited, then in the more lenient case of defilement by animal carcasses, how much more so [should only kohanim be prohibited! If so,] what does Scripture mean by, "you shall not touch their carcasses"? [It means that Israelites may not touch animal carcasses] on the Festivals [since at those times they deal with holy sacrifices and enter the Temple]. This is what [the Sages] said: A person is obligated to cleanse himself on Festivals. - [R.H. 16b, Torath Kohanim 11:74]

This means that even for a Kohen, the only prohibition of becoming impure is for a dead person. Animal meat is not an issue for anyone, absent some other requirement to be pure for a Temple service purpose.
That being said, there are other potential issues with doing business with non-Kosher food. See for example here. However that has to do with a different, Rabbinic prohibition where someone may come to eat from the food. Vis-a-vis this verse, there is no prohibition to handle the non-Kosher per se, rather it is prohibited to handle it when it would take away from the holiday obligations in the times of the Temple.
Comment: @BruceJames, I clarified in my post - in the end a Kohen is only prohibited with regards to a dead (human) body.
Comment: would the plastic wrapping around the carcass salso make a difference for a kohen since he would not be touching the carcass directly?
Comment: So from the last part of your answer, would you say that someone working as a cashier is "deriving benefit" from the food or the sale of it, if they are not the owner of the corporation? Regarding selling to a Jew accidentally, at what point does their power of choice kick in? For example, the other day I saw a man wearing a printed Hebrew t-shirt buying bacon. Other than the Hebrew shirt, there were no signs of Jewishness. Should the Jewish cashier refuse to sell the bacon to such a customer on grounds he may be Jewish?
Comment: @BruceJames Neveilah and Meit are Metammei through movement even without touching ("beMassa"). (see Keilim 1 and Zavim 5)


Tempering chocolate without a thermometer

Question: Is it possible to successfully temper the chocolate without a thermometer? I'm sure it's quite important but since it's so difficult to find one in my country and since I don't make chocolate so often I would know if there's a way to temper without it.
Answer: Your best bet is to start with a good quality tempered chocolate and melt it just to the point of melting, which is to say keep it 88° - 91°F (if you ever do end up getting a thermometer). Most suggest using a microwave for this in short bursts to keep the chocolate from getting too hot.  If you use a double boiler, use a low heat and go slow.  Pull the bowl off the heat often and stir.  It may not seem like all the chocolate is going to melt, but keep stirring and add small amounts of heat.  Or you can follow Alton Brown and sandwich a heating pad between two bowls and adjust the heat.
The theory behind this is there are 4 different types of crystals in chocolate.  The good ones we want are Beta crystals, which do not melt until 91° - 94°F.  As long as you don't  melt the beta crystals, the chocolate should set back up to a proper temper.
Use a grater to make nice even bits, melt the chocolate 2/3 of the way and then remove from the heat.  Stir off the heat until the rest melts, or add heat in very short bits, 5-10 seconds at a time.  Don't let it harden either, it's harder to remelt if it's hardens up slighty as it then becomes one big solid mass to melt.
Once you break the temper, there is no going back, you have to start over and there is no real easy way to do that without years of experience as bobobobo said, or a thermometer.  You can find inexpensive thermometers online, just have to make sure to get one that handles the lower range of temperatures.  I use my chocolate thermometer to also measure the temperature of water when making bread.  It seems more accurate at the lower temeratures.
Answer: After watching Jacques Torres explain it (check out the cool thermometer he uses!), I really don't think so!  Can you tell 88 degrees with your eyes / hands?
From here:
If the chocolate is allowed to cool on its own, the fats inside it will have a "loose crystal structure."  [As a result the chocolate will be] "dull in appearance, soft & malleable, and greasy to the touch."
If you keep the chocolate at 88°F (31°C) for a while as you cool it, you're apparently going to get a rigid, dense crystal structure, which gives you chocolate that "snaps".
So I think if you did it a million times you'd develop a "feel" for it, but other than that it seems the pros use a thermometer.
Answer: Yes. The way I was taught to temper chocolate was in a microwave, with no thermometer:
Heat on high for 20 seconds. Stir for 20 seconds. Repeat until the chocolate is smooth. If it's almost smooth after a twenty-second stirring session, keep stirring until it's actually smooth rather than putting it back in the microwave. Always end with stirring.
The stirring is VERY important, it's how you keep it from overheating or heating too unevenly.
I've used this technique to make chocolate bars, and it's quite effective.
Answer: Use you're lower lip as thermometer, little sting 115- 120 f. little cool on the crest of lower lip about 90 f. Darker chocolate requires higher heat index than semi or milk chocolate to temper.
120 for Dark chocolate 115 for semisweet
 or milk chocolate.
Just call me Coco B-)    You're welcome...
Comment: This will not work at all. Those temperatures will completely melt chocolate. (No need for a thermometer to do that!) To temper it you need to hold it at a much lower temperature, 88-90F for dark chocolate and 86-88F for milk chocolate.


How to deposit US social security in Japanese bank

Question: How do I deposit US social security and pension directly to Japanese bank without an American bank?
Comment: You don't need a US bank: Japan has an international direct deposit agreement with the United States (and there are other options such as a Direct
Express® debit card, for which you don't need any bank account). See whether [this SSA brochure](https://www.ssa.gov/pubs/EN-05-10137.pdf) has the info you need (and then some).
Answer: This webpage, not published by Social Security, contains the following q-and-a:
Q: I have looked at the Social Security website and could not find if there is a way to receive one's Social Security pension benefits for an American citizen living abroad without a bank account anywhere in the world.
A: The Social Security Administration can send checks; however, there are some country exceptions. For the most current information about receiving Social Security payments outside the United States You can also get a copy of Social Security Administration Publication No. 05-10137, ICN 480085, online, by postal mail from the Social Security Administration, or from the Federal Benefits Unit serving your area (check the AmericanCitizens Services section of the American embassy In your country of residence.
Thus, if Japan is not a "country exception," and if your Japanese bank will accept a US direct deposit or a US check for deposit or collection, you should be OK.
Comment: Cashing for person US checks in Japan is impossible. For some corporate clients some banks may provide such service for additional fee and it may take several months.
Answer: It doesn't look like any Japanese domestic bank participates in the American banking system's electronic draft system that would give them the ABA bank code number you need for a direct deposit from with the USA. Instead, Japanese banks all use the international SWIFT codes which are not the same system with ABA.
(I once had the opposite problem of trying to get funds from japan and they needed a bank with international swift and many banks in the USA only have ABA)
At best you could set up a MUFG Union Bank NA account in the USA and withdraw in Japan, but that's an American bank and you don't want to do that. Same goes for CitiBank.
I'm not sure why you're trying to avoid setting up an American bank account. You have an American social security number  so it should be easy to set up an account with an online bank that'll issue you an international debit card you can use to withdraw the funds in Japanese yen in Japan at any 7-11 or post office.
Update: from the link @Giorgio provided, the social security office can also provide you with a debit card you can use to either cash out or charge purchases to:

Another option to receive your benefits electronically is to use the Direct Express® debit card. You do not need a bank account. With the Direct Express® card program, we deposit your federal benefit payment directly onto your card account. Your monthly benefits are available on your payment day — on time, every time. You can use the card to make purchases, pay bills, or get cash at thousands of locations.


Active Directory and SSO in Sitecore 8.1

Question: We are trying to implement AD and SSO in Sitecore 8.1.
There is this specific requirement to not move all the AD users to Sitecore Profiles/DB as the list of AD users are huge.
Rather we are planning to save & validate the users at the time of authentication and then use it for SSO.
Please suggest any suitable approach to achieve this.
Comment: Are you able to use an AD query to limit the users/roles from AD to import into Sitecore?
Comment: Not sure how to use it.Can you explain?
Comment: Your connection string should point to the parent node of the logical group, then on the "system.web/memebership/providers" node you can add a "customFilter" attribute that can further limit the users/roles that will show up. The filter will be specific to how your AD groups are setup, but an example query would be something like "(memberOf=CN=Managers,DC=testdomain,DC=sitecore,DC=net)"
Answer: You have couple choices here:
1) You can use the SSO mechanism and then override the sitecore login pipeline to let the users login from your custom login screen. This will ensure only users who are validated via your sitecore login or custom sitecore login screen due to override in pipeline.
2) Sitecore AD connector does allow you to have multiple domains. So all you can do is create a domain with specific users whom you want to grant access and let them login to the sitecore. I have written this blogs https://mrunaldaftari.wordpress.com/2017/02/17/sc-and-active-directory-connecting-to-multiple-domains/ which may help you understand how exactly you can achieve this but for summary here are the steps you should take:

Work with the infrastructure team to get below things in place for each domains you want users to be allowed to login
Infrastructure team needs to create Organizational Unit
A domain controller using which you can connect to the the LDAP so can be any
server.
For example This is the distinguished name of the OU that all
of your stuff is in: OU=public LDAP Test,OU=User
Accounts,DC=hq,DC=usernet,DC=com
User account and server to connect
to the above settings.
Once you have all of the above your connection
string may look like below:
LDAP:/domaincontrollermachinname/OU=Public LDAP Test,OU=User
Accounts,DC=domainname,DC=usernet,DC=com
User account and server to connect to the above settings
Once you have all of the above your connection string may look like below:
LDAP:/domaincontrollermachinname/OU=Public LDAP Test,OU=User Accounts,DC=domainname,DC=usernet,DC=com

And you can keep repeating this steps for each domain and add them to the connection string to let them login.
Let me know if you need more details. This https://mrunaldaftari.wordpress.com/category/active-directory/ blog link have 5 related blogs which will help you get achieve what you need using AD module.
Update this is another step which you can look into for SSO
https://mrunaldaftari.wordpress.com/2017/02/16/active-directory-and-sso-to-let-ad-users-login-to-the-sitecore/
Comment: I do not want to have AD roles or users to be added into Sitecore DB. I need to validate the AD users not in Sitecore before going for SSO. So that only validated users that are present in AD but not in Sitecore are allowed for SSO. Can we achieve this anyway?
Answer: I had the same challenge back in Sitecore 6.6, we used cookies in order to implement SSO, however you can use Virtual User in Sitecore context, if you need to use Sitecore Roles for its context. I had to write custom ldap queries in order to search for users and its groups in AD, we only imported AD Groups into Sitecore Roles, and used VirtualUser, then generated secretToken and stored in cookies, which then been read by a different system in order to perform SSO.
Comment: Thanks Sergejs Kravcenko. It would be really helpful if you can describe how you achieved this.
Comment: That was about 10 years ago, I don't remember its implementation but it should be straight forward if you follow the sitecore documentation around Virtual User usage.


Storing bechamel sauce

Question: Is storing a Bechamel Sauce in the fridge for up to week ok? Will it curdle or otherwise go bad? I love eating Croque Monsieurs for dinner and adding a bit of Bechamel is awesome but I would rather make a batch once and then use it later.
Answer: You can store béchamel for 4-5 days safely in the refrigerator.  Cool the unused portion as quickly as possible after the sauce is finished and make sure to place a piece of cling film directly in contact with the surface of the sauce prior to refrigerating it so that it doesn't form a skin and slows down oxidation.  Do not freeze the sauce as it will likely break the emulsion.
Another way to make it easier to make your nightly béchamel would be to pre-make a larger batch of roux and freeze it in portions for later use in sauce.
Comment: Don't use plastic directly -- although formulas have been changed  in response to health concerns, certain plasticizers which are not good for you (and which tend to be fat-soluble) can leach into the sauce. Use wax or parchment paper.
Comment: In the Bouchon cookbook, Keller reports that you can refrigerate sauce mornay (béchamel with cheese added) for "a week" (which I would assume to be 7 days, but could be 5).  He also recommends the cling wrap and suggests thinning it out with cream if necessary.
Comment: I don't know if it's necessary to freeze the roux. It'll keep for a couple of weeks, [I think](http://cooking.stackexchange.com/questions/21146/how-long-will-roux-keep).
Comment: This is an old post, but I make this sauce for Mac and Cheese, and it's been in the fridge for a week or so before.  What exactly happens to the sauce?  Are you saying it's bad to store after a week?  Does it go bad/harmful for consumption, or it just starts breaking down and the sauce isn't the same:?  I haven't really a issue.

@JoshCaswell Any sources for this claim?  I heard plasticizers only leech when dealing with heat, i.e., microwave or oven.

Are you saying this isn't true and that any fatty foods should not be used with plastic wrap?  I also heard the stretchy plastics are the issue.
Comment: @XaolingBao Both claims are speculation. I doubt they analysed several bechamel samples under a microscope samples after different days or something like that.

Storing bechamel sauce


How do I display a user specific content?

Question: I have a site that displays the content only to registered users.
Most of the content is available to all the users, but some of it is user specific (i.e. all users have that page, but each sees a it's own content which no one else can see).
Any idea as to how I can restrict(and display) specific content per specific user ?
Comment: what was your solution? i am looking For something similar. In my case behind a restricted website a verified user has to use a multipage form which collects all the necessary info and after all the data has been collected the data info is sent to the admin
Answer: I had coded something like this a while back and i remember wanting to upload it to the plugin repository but never had the time, Basically it adds a meta box to the post or page edit screen and lets the user select specific users by name or roles and then it check using the_content filter, so here you go:
Update:
It just got approved in to WordPress plugin repository so you can download it User specific content form there or from your dashboard and i wrote a little about it here.

<?php
/*
Plugin Name: User Specific Content
Plugin URI: http://en.bainternet.info
Description: This Plugin allows you to select specific users by user name, or by role name who can view a  specific post content or page content.
Version: 0.1
Author: Bainternet
Author URI: http://en.bainternet.info
*/

/* Define the custom box */
add_action('add_meta_boxes', 'User_specific_content_box');

/* Adds a box to the main column on the custom post type edit screens */
function User_specific_content_box() {
    add_meta_box('User_specific_content', __( 'User specific content box'),'User_specific_content_box_inner','post');
    add_meta_box('User_specific_content', __( 'User specific content box'),'User_specific_content_box_inner','post');
}

/* Prints the box content */
function User_specific_content_box_inner() {
    global $post,$wp_roles;
    $savedroles = get_post_meta($post->ID, 'U_S_C_roles',true);
    //var_dump($savedroles);
    $savedusers = get_post_meta($post->ID, 'U_S_C_users',true);
    //var_dump($savedusers);
    // Use nonce for verification
    wp_nonce_field( plugin_basename(__FILE__), 'User_specific_content_box_inner' );
    echo __('Select users to show this content to');
    echo '
'.__('By User Role:').'
';
    if ( !isset( $wp_roles ) )
        $wp_roles = new WP_Roles();
    foreach ( $wp_roles->role_names as $role => $name ) {
        echo '<input type="checkbox" name="U_S_C_roles[]" value="'.$name.'"';
        if (in_array($name,$savedroles)){
            echo ' checked';
        }
        echo '>'.$name.'    ';
    }
    echo '
'.__('By User Name:').'
';
    $blogusers = get_users('blog_id=1&orderby=nicename');
    $usercount = 0;
    foreach ($blogusers as $user) {
        echo '<input type="checkbox" name="U_S_C_users[]" value="'.$user->ID.'"';
        if (in_array($user->ID,$savedusers)){
            echo ' checked';
        }
        echo '>'.$user->display_name.'    ';
        $usercount = $usercount + 1;
        if ($usercount > 5){
            echo '
';
            $usercount = 0;
        }
    }
    echo '
'.__('Content Blocked message:').'
';
    echo '<textarea rows="3" cols="70" name="U_S_C_message" id="U_S_C_message">'.get_post_meta($post->ID, 'U_S_C_message',true).'</textarea>
'.__('This message will be shown to anyone who is not on the list above.');
}

/* Save Meta Box */
add_action('save_post', 'User_specific_content_box_inner_save');

/* When the post is saved, saves our custom data */
function User_specific_content_box_inner_save( $post_id ) {
    global $post;
      // verify this came from the our screen and with proper authorization,
      // because save_post can be triggered at other times

      if ( !wp_verify_nonce( $_POST['User_specific_content_box_inner'], plugin_basename(__FILE__) ) )
          return $post_id;

      // verify if this is an auto save routine.
      // If it is our form has not been submitted, so we dont want to do anything
      if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
          return $post_id;
      // OK, we're authenticated: we need to find and save the data
    $savedroles = get_post_meta($post_id, 'U_S_C_roles',true);
    $savedusers = get_post_meta($post_id, 'U_S_C_users',true);
    if (isset($_POST['U_S_C_roles']) && !empty($_POST['U_S_C_roles'] )){
        foreach ($_POST['U_S_C_roles'] as $role){
            $new_roles[] = $role;
        }
        update_post_meta($post_id, 'U_S_C_roles', $new_roles);
    }else{
        if (count($savedroles) > 0){
             delete_post_meta($post_id, 'U_S_C_roles');
        }
    }
    if (isset($_POST['U_S_C_users']) && !empty($_POST['U_S_C_users'])){
        foreach ($_POST['U_S_C_users'] as $u){
            $new_users[] = $u;
        }
        update_post_meta($post_id, 'U_S_C_users', $new_users);
    }else{
        if (count($savedusers) > 0){
             delete_post_meta($post_id, 'U_S_C_users');
        }
    }
    if (isset($_POST['U_S_C_message'])){
        update_post_meta($post_id,'U_S_C_message', $_POST['U_S_C_message']);
    }
}

add_filter('the_content','User_specific_content_filter');
function User_specific_content_filter($content){
    global $post,$current_user;

    $savedroles = get_post_meta($post->ID, 'U_S_C_roles',true);
    $run_check = 0;
    $savedusers = get_post_meta($post->ID, 'U_S_C_users',true);
    if (!count($savedusers) > 0 && !count($savedroles) > 0 )
        return $content;

    if (isset($savedroles) && !empty($savedroles)){
        foreach ($savedroles as $role){
            if (current_user_can($role)) {
                return $content;
                exit;
            }
        }
        //failed role check
        $run_check = 1;
    }
    if (isset($savedusers) && !empty($savedusers)){
        get_currentuserinfo();
        if (in_array($current_user->ID,$savedusers)){
            return $content;
        }
            //failed both checks
        return get_post_meta($post->ID, 'U_S_C_message',true);
    }
    return $content;
}
?>

Comment: This is just what I was looking for! Just wanted so give some big thanks man!
Comment: @Bainternet A user just claimed that your plugin isn't working anymore :)
Comment: @kaiser what can I say??
Answer: Assuming this content is the usual post loop:
$current_user = wp_get_current_user();
if(get_the_author_meta('ID') === $current_user->ID):

  // show the content

endif;

I think this only works inside the loop.
If you need it outside the loop then just query posts from $current_user->ID:
$query = new WP_Query('author' => $current_user->ID);

Comment: only problem here is that it it's not really intuitive for the site owner to set 'permissions' per post
Comment: then checkout the "Members" plugin: http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin it's much more user-friendly...
Comment: was thinking about this one, only I saw it wasn't updated in a while now. any idea if it still works ?
Comment: it throws up a few notices with wp_debug, but it works. I'm using it to control roles and caps
Answer: In addidtion to what One Trick Pony wrote, if the site owner needs the ability to restrict the content to each user, you can develop a small custom meta box that will appear inside each post and will display checkboxes with the site's users and then you will have in your dayabse the needed post_meta of the users that have permission to the content and you could make the condition.
If you need another way of controlling the content, it's  better you provide some more specific details on how this should and needed to be handled, so it will be easier to think for appropriate solutions...
Good luck :)
Answer: 1st approach:

One method of doing this to create individual page for each student and make this page as password protected. That password can be given to student.
You can allow comment for that Page/Post so that student can add there queries and responses.

2nd approach:

You can use WP Private Content Plus (https://wordpress.org/plugins/wp-private-content-plus/) and make each page/post visible to specif users only.
You can create any types of user menu of admin.

You can also use 2nd approach with 1st for additional security though its optional.


Question about phrasal verbs

Question: My student yesterday said "I asked around the people for directions." but I corrected it to "I asked THE PEOPLE around me for directions."(I changed the order). I couldn't provide a good explanation for why I did that. Can someone please help me do that? Thank you.
Answer: The term ask around is a phrasal verb that functions intransitively:

I asked around for directions. Finally, I found someone who could assist me.

The verb ask by itself can act transitively, where you specify who you are asking:

I asked three strangers for directions. Finally, I found someone who could assist me.

Interestingly enough, the dictionary on my Mac says:

• [ no obj. ] (ask around) talk to various people in order to find something out: there are fine meals to be had if you ask around.

The way your version reads could be parsed like this:

"I asked [the people around me] [for directions]."
Answer: To me, it should be corrected as :  I asked the people around for directions since the verb ask is transitive, and  by putting around before the people, the object will be missed because around in the first is a preposition not adverb.
Comment: You do offer a grammatical sentence using transitive **ask**, but the verb "ask around" means "to inquire", and is intransitive.

Question about phrasal verbs


2001 Jeep Grand Cherokee Laredo Value

Question: I think this is a useful enough question, so I'm posing it. Some kid rear ended me, and it's going to cost more to repair the bumper and two package than my WJ is worth. Can I expect his insurance company to just cut me a check, or do I have to buy my own car back from them? It's perfectly drivable, should I have to go through all of this trouble?
Answer: A lot depends on the insurance company and where you live. I have had it go both ways. In one case they offered a check, but wanted the vehicle. In another case they paid me and were happy I didn't make them tow it away.
Be aware that laws vary from state to state and it may be a hassle to reregister the vehicle as it will have a salvage title. This may require reinspection by a DMV officer. It may not pass without the repairs. You may get them to issue you a check without totaling the Jeep by making the payment a little less than the value. That way you have a clean title.
Answer: Take the oportunity to put an aftermarket bumper on it at the insurance companies expense.
Somthing like http://www.kevinsoffroad.com/cart/wj-grand-cherokee-rear-bumper-wo-tire-carrier-p-827/
It's cheaper, looks good, and is much stronger.
Insurance claims completly paid of my Dodge Ram for me, and I just fixed everything with aftermarket parts. (My truck has been hit 2 times now, while parked, while I wasnt in it, and someone broke into it and stole my radio). Tubing bumpers, stero system, dash, etc...
I have an 01 WJ also, and I love it.
Comment: I can't charge them for repairs if it's totaled.
Comment: true, but just like mikes said, but they will pay it out and will be willing to work with you. You know you can put a pretty trick bumper and tow package on for less then $1000, so you got the estimate, tell the insurance company you will settle for less in order to avoid the salvage title. And tell them you will fix it yourself so they just cut you a check. They will do anything to pay you less, so if you give them the option they will take it.

2001 Jeep Grand Cherokee Laredo Value


How can I clean calcium deposits off my mirror?

Question: I live in Denmark and water is containing high amounts of calcium so my bathroom mirror has all these white spots which are so hard to remove, any ideas for a dissolver or something?
Answer: Here is a little known secret, don't tell anyone!!!!  "Bar Keepers Friend"  powered cleaner works miracles with fogged, rain stained and calcium covered glass.  It contains acyclic acid and a mirco fine abrasive. It cleans glass, head light lenses  and fiberglass like crazy and give you a very smooth polished finish. you can also use it with a buffing wheel or by hand. You can find this product at most any grocery store.
Answer: In Central Texas, we have very hard water (high calcium levels). I cope with this by using white vinegar. The 5-7% acid level will react with the calcium to make water-soluable salt which is easily removed.
Apply vinegar to a damp, clean cloth, or use a spray bottle to apply vinegar to the affected areas. Let soak for 30-45 seconds, then wipe away with a clean dry cloth.
Answer: Put full strength vinegar in a spray bottle. If you can lay the mirror flat, this will work the best, otherwise make sure you keep the mirror wet. Never do this with a dry mirror.
Take a BRAND NEW single edge razor blade and angle it downward 50-80 degrees or so. Never try a used blade as any imperfections on the blade could/will scratch the mirror. Using a small amount of downward pressure, start sliding the blade back and forth across the glass. You'll feel or hear it cutting off the buildup. When the blades feels smooth on the glass then move along to the next spot. KEEP the mirror WET!
If you don't trust yourself holding the bare blade in your hand, just get a slide-in type blade holder.
This worked far better for me than any of the commercial sprays I tried. This also works fantastic on ranges with glass tops. In fact, Samsung recommends this method over any & all abrasives.


Linux SUSE - How to clean up PATH?

Question: By doing an echo when I am logged in as root I can see I have a lot of junk in my PATH (probably from running tests and then forgetting all about it).
What's the best way to clean it up? I am not looking for anything fancy -- is there a .profile file I can edit? If so, which one (there's too many and I am a newbie!).
Any help appreciated!
Answer: Ok deleting the lines from bash_profile did the trick!

Linux SUSE - How to clean up PATH?


display image as cursor

Question: i am developing a portal, where client require animated cursor on page
I have done something but it is not working. steps which i have taken to make this is following:

in photoshop develop a image and save as cursor.ani
2  pest this image in images folder.
pest the following code in html page  before body tag in head tag.
<code>       <style type="text/css">
      <!--
          body {cursor:url("images/red_rose_turn_heart_shape_ty_clr.ani");
      }
        -->
       <style>
</code>

I am running this on following browser
1. FF
2 IE6
3 netscape
Answer: Try single quotes instead of double quotes.

display image as cursor


Webform Civi Payment fields not showing up

Question: I just created a webform with a Civi contribution page enabled. When I save the form to test, the payment options are not showing as part of the form. Do I need to do something other then enabling the contribution section and assigning it a contribution page to get the credit card and billing address fields to show?
Comment: If you enter a number into the amount field, does anything happen?
Comment: On the Civi form if I add a number then the billing/payment info pop up at the bottom. But if I do it on the webform I still do not get the payment fields. I just upgraded my Drupal and webform on Friday to the lastest versions.
Comment: Hmmm, could permissions be affecting it? Are you attempting it from an account (or anonymous) that don't have permissions? Just trying to rule out the easy to fix issues first. :)
Comment: I am logged in and have admin rights, so I don't think it is a permissions issue. Do I need to have a separate paypal module in Drupal or as long as it is set up and works in Civi I should be ok?
Comment: Correct, if your payment processor works correctly in Civi, it *should* work on the Drupal. However, certain processors may not. Do you have PayPal Pro or PayPal Standard? And are you able to complete a transaction in a Civi only contribution page?
Answer: Presumably you are on 7.x-4.15 of webform_civicrm since you say you just upgraded.  If you switch back to 7.x-4.14, does it work?   If so, it looks like the same issue I logged here: https://www.drupal.org/node/2676752
Comment: @Rachel - please mark this answer as "Accepted" by clicking the check mark to the left of this answer, it helps other people with the same problem.
Comment: Yes we are on version 7.x-4.15. I did an upgrade from 7.x-3 so how do I go about reverting back to .14? Or do they usually fix the bugs in a timely manner? I need to get this form done in the next couple of days, so I am trying to figure out what is the fastest way to fix this.
Comment: Just to chime in, I rolled back to webform_civicrm-7.x-4.14 on my site (Civi 4.6.13), and the payment fields work again.
Comment: @Rachel - it's a manual process: download 7.x-4.14 from here: drupal.org/node/2603480 Find your existing webform_civicrm directory (probably under sites/all/modules), remove it and replace it with the files from the download.
Comment: @Aidan - This answer just solved my issue, thank you!
Answer: With the fixes outlined here: https://civicrm.stackexchange.com/a/18449/930
The payment fields should work in webform version 7.x-4.18 with CiviCRM 4.7.18.


How did the British Navy pass orders to its fleet before radio?

Question: During the 18th and 19th century, the British Navy had ships all over the world, and communicating with them had to be difficult.  After all, the Battle of New Orleans happened after the British had signed the Treaty of Ghent ending the War of 1812.  Although many ship captains or fleet commodores had great freedom to operate tactically within their sphere of influence, what system of communication did the Royal Navy use to pass orders and receive reports from its ships far away?  Assuming that orders had to travel by courier on fast sailing ships, did the Navy rely only upon its own ships to pass messages, or did it use fast commercial vessels?  Was their a back-up system in case the courier was interecepted?  Typically, how long did the process take?
Comment: [Pigeons](http://en.wikipedia.org/wiki/Pigeon_post). For some reason, the answer needed to be long! Ignore this sentence. Answer is Pigeons. Really. Click the [link](http://en.wikipedia.org/wiki/Pigeon_post) please.
Comment: You have undoubtedly hear of *snail mail* and *sneaker net*; the British Admiralty used *sail mail*. before radio.
Comment: @user6326: the reliable range of a pigeon is a few hundred miles, and the failure/mortality rate increases with distance. You wouldn't rely on a single pigeon to travel 500+ miles. So that's not the full answer. You'd still need ships too.
Answer: According to Brian Lavery's "Nelson's Navy"[1], communication between the Admiralty and the fleets (at least during the French Revolutionary/Napoleonic Wars) was performed by the navy's own vessels. As noted in a previous answer, these were refered to as despatch vessels or despatch boats[2], and the role was usually filled by a variety of schooners and cutters attached to the fleets for this purpose. However, as Lavery also notes, any warship that was heading in the right direction might be used. The term "despatch vessel" seems to have referred to a role rather than a type of ship in the same way that, at the time, a "cruiser" was any type of warship sailing on detached operations.
The Admiralty Regulations[3] required that all communication from the commander-in-chief of a fleet or squadron on a foreign station (i.e. outside of home waters) to the Admiralty, was to be sent in duplicate and triplicate "by different conveyances". The aim of which, presumably, was to increase the chances of the communication reaching the intended destination.
The most famous examples of these despatch vessels would be the schooner Pickle and the cutter Entreprenante, which were with the British fleet at Trafalgar. These vessels were both sent home carrying duplicates of Collingwood's despatches following the battle, with the Entreprenante following the Pickle a couple of days later.
In contrast, Nelson sent the first copy of his despatches following the battle of the Nile on board HMS Leander (a 50-gun, forth-rate), as his fleet had lost most of its smaller vessels earlier in the campaign. Another copy was sent on the brig Mutine to Naples[4]. The Leander was captured by a French 74-gun ship and her copy of the despatches was dropped overboard, which illustrates why there was the requirement for multiple copies.
The prior to 1823, packet boats were operated by the post office to move mail, goods and passengers. These operated on a regular schedule from a number of ports around the British coast to locations in Europe, the Americas (including the West Indies) and Africa. Mail to the East Indies would have been carried on HEIC ships. The cross-channel services worked on the most frequent schedule with 2-3 sailings a week, while sailings to more distant locations were once a week or greater[5]. While that sort of frequency would have been acceptable for delivery of personal mail, it would have been unsuitable for the timely delivery of wartime orders and despatches.
After 1823, much of the work of the packet boats was taken over by the Royal Navy (who were trying to find a use for many of the small ships remaining from the Napoleonic period). So the distinction between despatch vessel and packet boat becomes less well defined. Although it's noted that the Navy's existing ships were ill-suited to the essentially civilian role and new ships were built to fit the purpose.
[1] "Nelson's Navy, The Ships, Men and Organisation, 1793-1815", B. Lavery (Conway, 1989) Pg 263
[2] "British Warships in the age of sail, 1793-1817", R.Winfield (Seaforth, 2005) Pg 359
[3] "Regulations and Instructions relating to HM's Service at Sea" (1808) Ch.2, Article XI
[4] "Nelson's Battles, the Triumph of British Seapower" N.Tracy (Seaforth, 2008) Pg 142
[5] "History of the Post-Office Packet Service between the years 1793-1815" A.H.Norway (Macmillan, 1895) Pg 8
Answer: They sent ships to the various headquarters with messages.  Ships would return to their local headquarters to receive orders periodically.  Failing that, the HQ would send another ship to the place where a particular ship was operating.
I suppose the navy might have used commercial ships if convenient, but in most cases had to use their own sloops and frigates for the purpose.  Commercial ships usually lacked the crews for operating efficiently at high speeds and in foul weather.
As transoceanic trips could take weeks to months, this method took that kind of time.
Comment: I think your answer is probably correct, but Tyler gives more information, and neither of you cite any references.  So I'm still not ready to accept an answer.  Do you believe that Tyler's description of the mechanism is correct?
Comment: The use of overland post was more or less irrelevant for the Navy, outside of England.  There you might send orders to Portsmouth from the Admiralty in London.  Outside England, Naval HQs were at a port, as were the ships.  Fleets on a station in war, such as blockaders, also had a known location that could be found by ship, and the Admiral was there.
Comment: I was referring to the second paragraph of Tyler's answer, which distinguishes the naval version of the packet system.
Comment: He only adds a name: packet ships. This is accurate, although they were also called dispatch vessels or not given a name at all if sent for an exceptional case like announcing a victory to the country.  Then a promising officer was sent on the courier and often given a promotion because of it.
Answer: Before the telegraph, communication was normally by post, which was an office or shack for handling the mail. Military communications were handled right alongside civilian messages and for this reason the post was almost always operated by the government. Each route went over land or by sea as was most convenient and sometimes both. In many cases private contractors would be employed to carry the mail between posts, in which case the packages of mail, called "packets" were sealed in some way to prevent the contractor from reading them. The business of carrying packets was called in England the "packet trade" and was a large business. Special, fast boats called "packet ships" were used to carry the packets and conduct other time-sensitive business.
Naval ships operated according to written orders and would periodically put in to a port to report and collect orders which would be found waiting for them. Military ships used the regular (Royal) post, except in very exceptional circumstances.
In places where maintaining a post was impossible due to cost or political considerations, then the Navy would try to use an embassy as the post. In very remote or dangerous places a standing ship would be used as the post.
Any British ship carrying official mail usually had a special pennant indicating that it was a mail ship.
Comment: @TylerDurden As I told Oldcat, I'm looking for a complete answer, practiaclly like yours, that has some references in it.  Can you provide any?  If so, edit your message accordingly.  Thanks.
Comment: I think that this answer describes the situation from circa 1800 onward, but not the 1700's. For example this [Royal Mail Pennant](http://www.crwflags.com/fotw/flags/gb-rmail.html) is from 1884, and the [RMS - Royal Mail Ship](http://en.wikipedia.org/wiki/Royal_Mail_Ship) designation dates from 1840. Could you clarify?
Comment: Can you provide a reference for linking packet ships to the time of William the Conqueror? My thinking is that packet ships were steamers, and they and English language broadsheets occur in the 19th century. To come to town for the mail on a given *day* implies reliable arrival times, something steam provided but sail didn't. Hence hence my earlier request for clarification.
Comment: No, I was suggesting you improve your answer with a reference. But I'll take a reference made in comments :-)
Comment: @andy256 The use of packet ships goes back centuries and certainly to the time of William the Conqueror. The term "RMS" is an 18th century term, but as a general rule any packet ship carrying official mail would bear the flag of the king or some similar authority. If you are interested in researching it, look up the term the "king's messenger" which can apply equally to a ship or post runner.
Comment: @andy256 Also, if you have access to any old broadsheets, such as colonial broadsheets you can find the notices of the mail packets. Since people had to know which day to come to town for the mail. So you would see notices like, "The Boston packet will arrive on such a such date, etc". All such ships would have a special flag.
Comment: @andy256 You want me to start footnoting my comments? If you are so interested in this topic, try reading "Old post bags: The story of the sending of a letter in ancient and modern times" (1928) by Alvin Harlow.
Comment: Interesting, that it was called "packets", which is how data is transmitted on the internet too "packets"


Fun way to teach algorithms

Question: I will teach algorithms for 4 days for some students. It will be their first course in computer science before learning coding with Java.
My fear is to bore them as I was bored at the university :(
Is there a fun way to teach algorithms ?
Comment: Start here for Hungarian Folk dancing: https://flowingdata.com/2011/04/14/sorting-algorithms-demonstrated-with-hungarian-folk-dance/
Comment: Why were you bored? Four days seems not much for a deep topic. Say something about the students and what they know. How much of algorithms? Examples only? Analysis? Taxonomy? Fun for whom?
Comment: I was bored because it seemed far for real world applications.
My students are 18 and are about to start learning computer science. They have never learned algorithms. So I'm trying to find a fun way to teach them that topic.
Comment: A perfect funny approach to algorithms would be the famous Hungarian dances for sorting algorithms, which you can find on YouTube!
Comment: I do sorting and searching using cards.You need to ensure that you have enough, and that you don't have a simple sequence (or the students will choose other algorithms, that don't otherwise make sense).
Answer: I think this is hard to do in four days. You can barely touch the surface. I think that the most you can likely do is give them an appreciation for why the study of algorithms is useful and important.
There is one general sort of algorithm that is "easy" to carry out before students learn to program: Linear Recursion. There are many such problems. The basic idea is that one student "plays" the base case in the recursion and others "play" the recursive case. A simple example is counting the length of a list. The base case, when asked "how many" replies "one". The others, when asked "how many" pass the same message to the student in line to their left and if told, say, five, by that student, replies six. The professor lines up the student and asks the first student "how many". If it happens to go to the base case, the prof gets "one", but otherwise the message gets passed down and reflected by the "base case" and (after a lot of noise" gets back the length of the list.
A similar thing can be done. I've held "choir practice" with a bunch of students where each student has a script. The overall script is to recite "There was an old lady who swallowed a fly", which you can find on the net.
I've also had success with Matryoshka. How do you "paint" a Matryoshka? You can "apply color" to a given figure before the recursion or after. You can even "apply" color to the bottom on the winding phase and to the top on the unwind. The recursion is either (winding phase) "apply color, pass paint" or (unwinding phase) "pass paint, apply color". The base case just applies color and returns. This is an important lesson for students, that you can "do work" in a recursion on both the winding and unwinding phase. Some students miss this essential idea.

Another general area that can be explored prior to learning programming is the idea of sorting and what is required to do it. There are a lot of subtleties that are usually glossed over but that can be explored before you even start to program. For example "How do you sort the numbers 1 through 10 numerically". Answer, you don't. They are  already sorted.
You can ask "Why do we want to sort?". Connecting it to the search problem and a real-world scenario and maybe even binary search.
Another subtle issue is the distinction between the size of the multiset (bag) that you are sorted and the size of the set of values from which they are drawn. For example, sorting a list of int or long values can always be done in linear time (linear in the size of the bag, length of the list). This is because the collection of expressible long values is finite. See Radix Sort for example. In general, sorting (mathematical) integer values is harder, since the set of integers is infinite even when the bag to be sorted is finite. Radix sort can be carried out by a group of student "actors", if you either discuss binary representations, OR, adapt the algorithm of a mechanical sorting machine to use human actors.
Another fun thing to do with sorting is to try to have a competition for the least efficient sorting algorithm anyone can come up with. I can think of some doozies that are either extremely inefficient in space or in time. I have a completely infeasible sorting algorithm that is linear in time but requires too much space. Other inefficient (in time) algorithms are possible. For example, randomize the list and then check. Repeat until sorted. If you have a truly random number generator this is guaranteed to halt (law of large numbers in probability). There are a lot of possibilities.

In my first reading of the question here, I somehow completely missed the fact that the students didn't know anything about programming (oh my). If they do, then the following might be appropriate, but they would be hard to do otherwise.
One "interesting" algorithm is just Huffman Encoding. How do you minimize the number of bits sent to encode a message using an alphabet with a given frequency of use. There are several things that need to be discussed here, including the economics of data transmission. "Less is More". Then there is the question of the alphabet and its characteristics in use. See Poe's The Gold Bug for a discussion that is actually incorrect, but interesting and has the right idea if the wrong numbers. Don't be naive and try to use the distribution of the message itself as the source of statistics on the alphabet. It can't work.
Next you need to discuss tree structures, etc, and the bit encoding of the message, including the need to be able to separate the message into discrete characters, since the encoding doesn't use the same number of bits for each character (the essence of the problem, actually).
Note also that even a naive but accurate distribution provides some improvement. Huffman is optimal for a given distribution. So, discuss optimization, as opposed to satisfaction.
Now you need to discuss and maybe implement both the encoding and the decoding algorithms.
Then you can discuss space time tradeoffs. We trade time (for encoding/decoding) for space (bits sent).
An "overnight" thought experiment for the students: Why can't you use the message itself to determine the distribution? It takes a bit of thought and may be obvious or not. But a long discussion here previously showed why it can't work.
You could even spend a bit of time on the difference between linear scanning of a set of data and searching through a tree that has been previously constructed.  This could get you close to something like binary search to put a "future work" idea in their minds.
There are other similar examples. The key is a problem in which the naive solution (same number of bits per character) can be improved (fewer bits for common characters), then showing how to develop the algorithm to do the improvement.
One problem I find magical is the Dutch National Flag as discussed at the link and the book by Gries. A linear time sorting algorithm for a restricted kind of data. Since DNF only involves an array and a few index variables, it can be done with students as "actors" representing the Red, White, and Blue values. A few other actors (index values) point at the corresponding "slot" in the array to keep track of the algorithm as it progresses.
I think other algorithms that use an array or list can be handled similarly, but it is probably necessary to stick to linear running time algorithms. That is just because time is limiting and little insight can be gained if the thing is too complex or takes so much time that the details obscure the main points.
Comment: Thank you. I'm a little bit surprised and skeptical about teaching the Huffman coding before data structures. Do you have a more complete blueprint ?
Comment: I'm surprised you are teaching algorithms before data structures, actually. Huffman is pretty standard. There is a lot of information you can find, I think.
Answer: A loaf of bread, a knife, a jar of peanut butter and a jar of jelly.  Write an algorithm to build a PB&J.  Have one of the kids follow the literal direction written by a different kid.  This project have been a favorite starter for algorithms for 30 years.
Comment: A classic, of course. But mostly for the fact that such descriptions of process are too often lacking. What "isn't" an algorithm is a valuable lesson. Tie your shoelaces is even worse. I think.
Answer: A crowd favorite of the Beauty and Joy of Computing (BJC) course from Dan Garcia and many other creative leaders:
Each group of 4 students gets a deck of shuffled playing cards. Groups race the clock to deliver the deck in sorted order, ace to king within suits, suits alphabetically. BJC uses that activity first.
I had interesting results one year using that activity later in the semster, and modifying it: each group gets two distinguishable decks shuffled together, one of them missing a card. Race the clock to identify the card I retained from your group.
Either way, athe key is the post-race discussion. What algorithm did your group follow? What is the best algorithm? Does the answer to the previous question depend on how well the deck is shuffled? Does it depend on which card is missing? Nice tie ins available to complexity and worst case time efficiency.
Answer: Do I understand correctly that you're teaching kids already that have not yet learned any programming? And that you are trying to teach them algorithms?
I would not focus on a programming language at all; they are not ready to implement algorithms yet in actual code.  Instead, I would focus on Computational Thinking.  Let them act out various approaches to solving a problem and turn them into recipes.
I would look at ice-breaker games and at resources for Computational thinking for nice, active learning ideas to get at algorithms without all of the cumbersome programming at the start.
Comment: @alk01771 That age group still loves to move around. I teach them just 2 months before you get them :)
Comment: Well the course is not intended for kids : it's for high school graduates who will start learning computing ;)
Comment: Oh dear. I completely missed the "don't know programming" part in my first version of the answer. I've tried to recover.

Fun way to teach algorithms