summary
stringlengths 15
147
| text
stringlengths 1
19.3k
| answer
stringlengths 32
22.6k
| labels
float64 0.33
1
| answer_summary
stringlengths 5
164
|
---|---|---|---|---|
Get current Activity with Android
|
I have a method that scans the position and gets called on every activity I have, everytime an actions trigger I need to show an alertDialog, this is the code:
AlertDialog.Builder builder = new AlertDialog.Builder(mMainActivity.this);
builder.setMessage("test")
.setCancelable(false)
.setPositiveButton("go", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(mMainActivity.this,LocationDetails.class);
intent.putExtra("placeId",1);
startActivity(intent);
}
})
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
But How can I create the alert on the current activity? Because now it only gets created on AlertDialog.Builder(mMainActivity.this);
|
Have this AlertDialog logic in a public class and make call using a method with passing context .
For example:
showAlert(youractivitycontext);
Use the Context as your current activity.
| 1 |
AlertDialog logic in a public class
|
Can summoned creatures take items back with them?
|
If you summon a creature and give it any item then dismiss it, does the item go with it?
|
It would require a DM ruling.
There are no specific mention of rules that specifically address that concern. But one should consider the following:
Paladin's Special Mount
Each time the mount is called, it appears in full health, regardless of any damage it may have taken previously. The mount also appears wearing or carrying any gear it had when it was last dismissed. Calling a mount is a conjuration (calling) effect. Should the paladin’s mount die, it immediately disappears, leaving behind any equipment it was carrying.
The main reason a Paladin's Mount is a conjuration (calling), rather than conjuration (summoning), is due to dispel circumstances. It wouldn't be fun for the paladin if someone simply dispelled his mount from underneath him (although some may find that hilarious).
Also consider the aspect of conjuration (teleportation). For example, the teleportation spell states:
You can bring along objects as long as their weight doesn’t exceed your maximum load.
Since extraplanar travel isn't allowed with teleportation explicitly, lets look at Lesser Planar Ally:
A task taking up to 1 minute per caster level requires a payment of 100 gp per HD of the creature called.
At the end of its task, or when the duration bargained for expires, the creature returns to its home plane (after reporting back to you, if appropriate and possible).
Depending on the amount of hit dice, that could be a considerable amount of gold - and weight.
Opinion
I would say Conjuration (Summoning), No; Conjuration (Calling), Yes. And that would make perfect sense. Your DM would be the final arbiter. But imagine the implications if he allowed someone to be grabbed and sucked into whatever plane the creature was summoned from...
Then again, it could be one heck of an adventure hook:
| 0.777778 |
Calling a Paladin's Special Mount
|
UNIX semaphores
|
I wrote an example program about UNIX semaphores, where a process and its child lock/unlock the same semaphore. I would appreciate your feedback about what I could improve in my C style. Generally I feel that the program flow is hard to read because of all those error checks, but I didn't find a better way to write it. It's also breaking the rule of "one vertical screen maximum per function" but I don't see a logical way to split it into functions.
#include <semaphore.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
int main(void)
{
/* place semaphore in shared memory */
sem_t *sema = mmap(NULL, sizeof(sema),
PROT_READ |PROT_WRITE,MAP_SHARED|MAP_ANONYMOUS, -1, 0);
if (!sema) {
perror("Out of memory");
exit(EXIT_FAILURE);
}
/* create, initialize semaphore */
if (sem_init(sema, 1, 0) < 0) {
perror("semaphore initilization");
exit(EXIT_FAILURE);
}
int i, nloop=10;
int ret = fork();
if (ret < 0) {
perror("fork failed");
exit(EXIT_FAILURE);
}
if (ret == 0) {
/* child process*/
for (i = 0; i < nloop; i++) {
printf("child unlocks semaphore: %d\n", i);
sem_post(sema);
sleep(1);
}
if (munmap(sema, sizeof(sema)) < 0) {
perror("munmap failed");
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
if (ret > 0) {
/* back to parent process */
for (i = 0; i < nloop; i++) {
printf("parent starts waiting: %d\n", i);
sem_wait(sema);
printf("parent finished waiting: %d\n", i);
}
if (sem_destroy(sema) < 0) {
perror("sem_destroy failed");
exit(EXIT_FAILURE);
}
if (munmap(sema, sizeof(sema)) < 0) {
perror("munmap failed");
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
}
|
One thing to note:
sem_t *sema = mmap(NULL, sizeof(sema),
PROT_READ |PROT_WRITE,MAP_SHARED|MAP_ANONYMOUS, -1, 0);
if (!sema) {
Failure in mmap will return MAP_FAILED, not NULL (usually I think MAP_FAILED expands to -1 cast to a pointer, meaning your failure check won't work).
As for style: This is just an opinion, but I think your style could benefit from the concept of a "cleanup block".
For example, instead of this kind of style [paraphrasing your code, not doing literal quotes]:
sema = mmap(/* ... */);
if (sema == MAP_FAILED)
{
exit(EXIT_FAILURE);
}
foo = malloc(sizeof(*foo));
if (!foo)
{
exit(EXIT_FAILURE);
}
You could do something like:
int status = EXIT_FAILURE;
sem_t *sema = NULL;
struct foo *foo = NULL;
sema = mmap(/* ... */);
if (sema == MAP_FAILED)
{
goto cleanup;
}
foo = malloc(sizeof(*foo));
if (!foo)
{
goto cleanup;
}
// TODO: do stuff with sema and foo
// mark success
status = EXIT_SUCCESS;
cleanup:
if (sema && sema != MAP_FAILED)
munmap(sema, /* ... */);
if (foo)
free(foo);
return status;
The benefit to this kind of style is that you can add any type of allocation you want (in between the other stuff, before it, after it, whatever), and you just need to add a quick line or two in the cleanup block, and suddenly, all success and failure paths get the resources freed. If any of the intermediate steps fail and you wind up in the cleanup block, you can be assured that you're not leaking anything, and it won't feel repetitive to make that happen.
There are other variants of this, for example if you or someone you're working with has some religious objection to goto (even though it's the cleanest way to do error handling in plain C), on the slightly more repetitive side you could repeatedly check status to see that you're still succeeding:
int status = EXIT_SUCCESS;
sem_t *sema = NULL;
struct foo *foo = NULL;
if (status == EXIT_SUCCESS)
{
sema = mmap(/* ... */);
if (sema == MAP_FAILED)
{
status = EXIT_FAILURE;
}
}
if (status == EXIT_SUCCESS)
{
foo = malloc(sizeof(*foo));
if (!foo)
{
status = EXIT_FAILURE;
}
}
if (status == EXIT_SUCCESS)
{
// TODO: do stuff with sema and foo
}
if (sema && sema != MAP_FAILED)
munmap(sema, /* ... */);
if (foo)
free(foo);
return status;
| 0.777778 |
a "cleanup block" is a cleanup block .
|
Why Didn't Théoden Let Merry Fight In the Battle At Minas Tirith?
|
In the Peter Jackson version of The Return of the King, Merry offers Théoden his sword and service, which Théoden accepts. Théoden gives Merry the title of "Meriadoc -- Esquire of Rohan."
When the Rohirrim set out to ride to Minas Tirith, Théoden is very firm with Merry, that he is not allowed to ride into battle, and tells Merry that he is a burden that none of the Rohirrim can bear at that time.
Why didn't Théoden let Merry ride to war? And yes, I know that Merry was taken into the Battle of the Pellenor Fields by Éowyn, who herself was going to fight on the sly.
|
Merry wasn’t able to ride a full sized horse by himself, and would have been a burden to both a full grown male warrior and his horse. He would have weighed down the horse, and interferred with the soldier’s ability to fight. Éowyn, being smaller than the average soldier, was able to carry Merry on her horse without slowing it down, as their combined weight was less than that of a fully equipped regular, male warrior.
| 0.888889 |
Eowyn was able to carry Merry on her horse without slowing it down .
|
How could I launch the sequence of git commands from java application?
|
I need to add the file to the repository and then commit it from my java project. I use
Runtime.getRuntime().exec("C:\\Program Files (x86)\\Git\\bin\\sh.exe");
to start git but what should I do next?
|
sh.exe isn't Git, it's the command shell distributed with Git. You'd want to run Git directly, e.g. like this:
String[] command = {"C:\\Program Files (x86)\\Git\\bin\\git.exe",
"add",
"some-file-to-add"};
Runtime.getRuntime().exec(command);
But since you're writing in Java I suggest you have a look at JGit, a native Java Git library.
| 1 |
Git is the command shell distributed with Git
|
What is the difference, if any, between 'art', 'the arts', and 'Art'?
|
In answer to this question, there was some discussion about whether these two sentences are equivalent:
Art nurtures the soul.
The arts nurture the soul.
Are they equivalent?
'The arts' is a common but woolly term and 'art' is notoriously difficult to pin down. Oxforddictionaries.com gives the following definitions:
art [mass noun] the expression or application of human creative skill and imagination, typically in a visual form such as painting or sculpture, producing works to be appreciated primarily for their beauty or emotional power
(the arts) the various branches of creative activity, such as painting, music, literature, and dance
What practical differences in usage are there (if any)?
Also, does Art (capital A) have a special meaning distinct from art (lower case a)?
|
"Art" is an abstract. Its primary use is as an abstract quality. It can also be used as a collective noun for objects (or activities) characterised by art (the quality).
"The arts" is a different kind of abstract: it is not a quality, but an aggregation of activities (not usually objects) that are characterised by art.
So "art nurtures the soul" could mean that the aggregation of works of art (or artistic activities) nurtures the soul, but is far more likely to mean that the abstract quality "art" nurtures the soul.
"The arts nurture the soul" would to me mean the somewhat different idea that the aggregate of artistic pursuits (and perhaps their results) are what nurtures, rather than the abstract quality they share.
| 1 |
"art nurtures the soul"
|
Photoshop/Illustrator: generate vector graphic from bitmap
|
Possible Duplicate:
Vectorization graphics approach
Folks,
Photoshop newbie here with what I think is a simple question, but clearly, I am not searching for the right keywords on Google.
I have a hand-sketched pattern that I have scanned into a (bitmap) image. It is a crisp black and white image. I would like for a way to get Photoshop (or Illustrator) to detect the edges and extract paths from it, thereby converting it into a vector graphic.
Is there a simple way to accomplish this?
Thanks.
-Raj
|
Yes, by using the 'trace' function in Illustrator: there's a tutorial here.
| 1 |
Using the 'trace' function in Illustrator
|
Etiquette for posting civil and informative comments
|
Sometimes I leave a comment like "Stack Overflow is not your personal research assistant," but am accused of being rude. How can I craft a comment that is seen as civil to the community and instructive to the OP?
What tone should I strike in comments?
What are some examples of bad comments and their better replacements?
|
Another way to make a comment more friendly is, when possible, to cast it as a question rather than a statement. Consider the difference between:
(Answer) doesn't work because of X.
and
When you do that, how do you account for the problem of X?
It could well be that X isn't a problem -- your assumption is wrong. If you assert it you look bad; if you raise the question the poster isn't put on the defensive, and if it's a problem he can fix it (and thank you for the help).
I used to leave comments like the following that I thought were friendly and helpful:
This question/answer could be improved by adding (details/a source).
I realized that comments like the following got better results and also that I preferred them when on the receiving end:
Could you add more details about X?
Do you have a source?
This approach doesn't always work (e.g. for site policy). It's also most important for the initial comment, before you and the other person are engaged in a dialogue.
| 1 |
How do you account for the problem of X?
|
Is there a word specifically referring to the stand upon which a large book is displayed, opened to a page?
|
I'm thinking in particular of dictionaries or illuminated bibles being displayed on these stands, which are at least waist-high on a standing person, constructed of wood. Is there a particular word for this, other than "book stand"?
|
"Book stand" is the natural choice.
A tall book stand such as you describe is a "freestanding book stand". Woodform, Inc. uses this term, and they seem to know what they're talking about! They also refer to a "dictionary stand".
Otherwise, a "podium" is
a stand with a slanted surface that holds a book, notes, etc., for
someone who is reading, speaking, or teaching
Or, if you want get poetic, there is "pedestal" or "plinth".
| 1 |
"Book stand" is a "freestanding book stand"
|
How can I stop a running MySQL query?
|
I connect to mysql from my Linux shell. Every now and then I run a SELECT query that is too big. It prints and prints and I already know this is not what I meant. I would like to stop the query.
Hitting Ctrl+C (a couple of times) kills mysql completely and takes me back to shell, so I have to reconnect.
Is it possible to stop a query without killing mysql itself?
|
The author of this question mentions that it’s usually only after
MySQL prints its output that he realises that the the wrong query was executed.
As noted, in this case, Ctrl-C doesn’t help. However, I’ve noticed that it
will abort the current query – if you catch it before any output is
printed. For example:
mysql> select * from jos_users, jos_comprofiler;
MySQL gets busy generating the Cartesian Product of the above two tables and
you soon notice that MySQL hasn't printed any output to screen (the process
state is Sending data) so you type Ctrl-C:
Ctrl-C -- sending "KILL QUERY 113240" to server ...
Ctrl-C -- query aborted.
ERROR 1317 (70100): Query execution was interrupted
Ctrl-C can similarly be used to stop an UPDATE query.
| 1 |
Ctrl-C will abort the current query if you catch the wrong output
|
How do I create a simple yet complex business layer?
|
I'm working with a fairly complex web application. It's split up into the following layers:
Presentation - HTML
Service layer - A REST and SOAP API communicating with the business layer
Business layer - Contains the business logic.
Data access - Provides access to the storage (SQL etc)
The business layers contains classes encapsulating specific areas, such as customer registration, user management and more. The problem we are seeing is that the business layer is starting to get a bit messy. We have a single class handling customer management but as this area of the application grows more and more complex, the class grows and grows and become messy.
For example, we may have the following classes
class CustomerManager
void CreateCustomer(...)
void DeleteCustomer(...)
class UserManager
void CreateUser(..)
void DeleteUser(...)
void ActivateUser(...)
void InactivateUser(...)
void ResetPassword(...)
Creating a customer involves creating users as well. So CustomerManager calls misc methods in the UserManager class. As the application has evolved, creating a new customer means roughly 10 different things needs to be done except for registring the customer in the database, such as informing sales, audit logging, configuring default user accounts, creating a default configuration for the customer, notifying end-users of their auto-generated passwords and more. So CustomerManager.CreateCustomer grows to ~100 lines of fairly hairy code.
I'm trying to think of a good way to handle this but am assuming that there's some common good way to do this which I'm simply not aware of.
I've considered creating "Task"/"Command" classes implementing small sub-processes and then let the CustomerCreation.CreateCustomer simply execute a set of tasks. I would have more classes but they would each do less things.
I've also considering implementing some kind of global application-level event/plug-in systems where CustomerManager.CreateCustomer just creates the customer in the database and then publishes an event that the customer is created. Plug-ins/something can then subscribe to these events and do stuff such as informing sales and logging the fact. Using this method, I wouldn't have to actually update CustomerManager.CreateCustomer when I want to do more stuff which is something which feels attractive to me.
What obvious design pattern am I missing?
|
As @DocBrown said, plugins are mostly useful when you want to allow third parties to be able to extend your application. But that doesn't mean you can't use similar techniques in your design as what gets commonly used when interfacing with plugins.
For example, if a lot of the code you have is along the lines of "after creating the customer in the databse, components X, Y and Z need to be informed so they can take their appropriate actions", then you can use the Observer pattern there to decouple CustomerRegistration from X, Y and Z (and at a later time, A and B could get added to that list as well).
On the other hand, if your logic has a lot of ifs, buts and unless tests in it, then there is no real way to reduce the complexity of the code, because it is inherent in the business rules that the code represents.
| 0.888889 |
plugins can be used when interfacing with plugins
|
Unique Existence and the Axiom of Choice
|
The axiom of choice states that arbitrary products of nonempty sets are nonempty.
Clearly, we only need the axiom of choice to show the non-emptiness of the product if
there are infinitely many choice functions. If we use a choice function to construct a mathematical object, the object will often depend on the specific choice function being used. So constructions that require the axiom of choice often do not provide the existence of a unique object with certain properties. In some cases they do, however. The existence of a cardinal number for every set (ordinal that can be mapped bijectively onto the set) is such an example.
What are natural examples outside of
set theory where the existence of a
unique mathematical object with
certain properties can only be proven
with the axiom of choice and where the
uniqueness itself can be proven in ZFC (I
don't want the uniqueness to depend on
a specific model of ZFC)?
The next question is a bit more vague, but I would be interested in some kind of birds-eye view on the issue.
Are there some general guidelines to understand in which cases the axiom of choice can be used to construct a provably unique object with certain properties?
This question is motivated by a discussion of uniqueness-properties of certain measure theoretic constructions in mathematical economics that make heavy use of non-standard analysis.
Edit: Examples so far can be classified in three categories:
Cardinal Invariants: One uses the axiom of choice to construct a representation by some ordinal. Since ordinals are canonically well ordered, this gives us a unique, definable object with the wanted properties. Example: One takes the dimension (as a cardianl) of a vector space and constructs the vector space as functions on finite subsets of the cardinal (François G. Dorais).
AC Properties: One constructs the object canonically "by hand" and then uses the axiom of choice to show that it has a certain property. Trivial example: $2^\mathbb{R}$ as the family of well-orderable sets of reals.
Employing all choice functions: Here one gets uniqueness by requiring the object to contain in some sense all objects of a certain kind that can be obtained by AC. Examples: The Stone-Čech compactification as the set of all ultrafilters on it (Juris Steprans), or the dual space of a vector space, the space of all linear functionals. (Martin Brandenburg) The AC is used to show that these spaces are rich enough. Formally, these examples might be categorized in the second category, but they seem to have a different flavor.
|
If you are satisified with your example of the cardinals as unique objects defined using choice then there is an easy answer to your question. Note that there is not a unique ordinal which is in bijective correspondence with each set; there are many, but there is always a least one which we call a cardinal. So the uniqueness comes from the well ordering of the ordinals. Given the axiom of choice you can always well order the domain of objects in which you are interested and then choose the least one. This will of course, be unique, but I doubt this is what you had in mind. But I think it does show that a better example than the cardinals is needed for uniqueness.
One can construct saturated models by transfinite induction and then show that, under certain circumstances, these are unique. One also has $\beta \mathbb{N}\setminus \mathbb{N}$ which needs choice to be non-empty, and it is also unique --- but probably also not what you had in mind.
| 0.666667 |
Uniqueness comes from the well ordering of the ordinals
|
Dumping Stack Overflow to a private network
|
Is there any tool to use the Stack Overflow Creative Commons data dumps to serve as the same Stack Overflow format website, but only on a private network (for example, running locally over Apache).
Currently I've downloaded Creative Commons data dumps, but it contains only XML files with no user interface and database engine provided to use these XML files.
Is there any easy way for me do you it, without needing to write the user interface and database queries on my own?
|
The answer is no, because the SE engine is not publicly available.
IIRC the engine was commercially available, but no longer.
These clones may help you, many of them are open-source
But they most probably rely on a different DB model, so you would have to do a major revamp of the dumps and import.
| 0.888889 |
SE engine is not publicly available, but no longer available
|
Is apt-get upgrade a dangerous command?
|
When I use apt-get update and apt-get upgrade,there are some packages should installed in newest version,like below:
The following packages will be upgraded:
accountsservice apparmor apport apt apt-transport-https apt-utils binutils
cloud-init cpp-4.8 dpkg fuse g++-4.8 gcc-4.8 gcc-4.8-base gdisk gnupg gpgv
grub-common grub-legacy-ec2 grub-pc grub-pc-bin grub2-common initscripts
isc-dhcp-client isc-dhcp-common libaccountsservice0 libapparmor-perl
libapparmor1 libapt-inst1.5 libapt-pkg4.12 libasan0 libatomic1 libbsd0
libcurl3-gnutls libdrm2 libedit2 libfuse2 libgcc-4.8-dev libgd3 libgomp1
libitm1 libjson-c2 libjson0 libnuma1 libpam-systemd libpolkit-agent-1-0
libpolkit-backend-1-0 libpolkit-gobject-1-0 libquadmath0 libstdc++-4.8-dev
libstdc++6 libsystemd-daemon0 libsystemd-login0 libtsan0 libudev1 libxext6
linux-libc-dev ntpdate openssl overlayroot patch policykit-1 ppp
python-urllib3 python3-apport python3-problem-report python3-update-manager
rsyslog systemd-services sysv-rc sysvinit-utils tcpdump tzdata udev
update-manager-core
75 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
If I didn't know every one of there packages what will happen if there update in newest version.I shouldn't execute this command(apt-get upgrade).
For example:
This php version is before I upgrade
yzxu@ubuntu:/tmp/git-2.1.2$ php --version
PHP 5.6.6-1+deb.sury.org~precise+1 (cli)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
and after I upgrade:
yzxu@ubuntu:/tmp/git-2.1.2$ php --version
PHP 5.6.10-1+deb.sury.org~precise+1 (cli)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
The php version is changed.And if I didn't what what was change in two version,should I upgrade it?Is it will influence product?
|
apt-get update
Refreshes the repositories and fetches information about packages that are available online.
apt-get upgrade
Downloads and installs updates for all installed packages - as long as it doesn't bother dependencies (install new packages, remove old ones or crosses a repo source (switch a package from one repo to another)).
apt-get dist-upgrade
Does the same as "upgrade" but upgrades a package also when dependencies or sources are changed (something you want to avoid on servers without further testing).
To conclude - an update can break things but it is necessary!
So if you are on a desktop you should normally do a:
sudo apt-get update && sudo apt-get dist-upgrade
Without destroying something.
On a server most of the times a:
sudo apt-get update && sudo apt-get upgrade
should be enough AND security updates should be installed automatically (on servers and desktops)
TL;DR!
Yes you should update php in this example - cause it is a security fix (what can be seen through the numbering scheme of php and else it would not have been pushed into the "upgrade" branch of ubuntu...
| 0.666667 |
apt-get update Refreshes repositories and fetches information about packages that are available online
|
Security of running openpgp.js in a browser with the private key in HTML5 localStorage
|
If I were to write a web application using openpgp.js (http://openpgpjs.org/) for creating PGP encrypted/signed messages and if I stored the user's private key in localStorage, would this be vulnerable to the same complaints about JavaScript cryptography on Matasano's webpage (http://www.matasano.com/articles/javascript-cryptography/)?
As far as I can tell, the main points outline by Matasano are:
"Secure delivery of Javascript to browsers is a chicken-egg problem." (This could be fixed by using HTTPS)
JavaScript isn't well suited to cryptography
Browsers are too complex for cryptography since they have the potential to contain multiple attack vectors.
If localStorage isn't the best place to store something sensitive like a private key, what would be a better place?
|
If you do decide to store the secret in localStorage, you will want to make sure you never store the cleartext session key there. I'm not familiar with openpgpjs, but it probably facilitates secure storage of keys (some form of keyring class I guess).
| 1 |
Openpgpjs in localStorage - a secret session key
|
How much of the universe is observable at visible wavelengths?
|
Knowing that:
The Zone of Avoidance (Looking towards the center of the Milky Way) blocks roughly 20%
Each Milky Way star has an angular size, depending on proximity, that obscures a certain percentage of our optical view.
Each Galaxy has an angular size, depending on proximity, that obscures a certain percentage of our optical view.
And so on through Galaxy Clusters, Superstructures, etc...
What percentage of our universe can we not see at visible wavelengths?
|
Surprisingly, it makes no sense to make calculations with the angle subtended by objects. They don't simply "block out" the light of foreground objects. The Universe is more subtle than that and, when you spot a galaxy, in most cases you can be pretty sure that there isn't anything behind it, at least anything that you would be able to see if the galaxy were removed.
Moreover, the fact that two objects lie along the same line of sight is a happy coincidence, that helps seeing the most distant one, due to gravitational lensing amplification. Usually the background object would be too faint to be detected otherwise. Whole Ph.D. thesis are written every year due to this extraordinary coincidences. See this beautiful image, called the Horseshoe lens, where the image of a distant blue galaxy, that lies far behind a red foreground elliptical, not only is not blocked out, but is even amplified:
(image from Wikipedia Commons http://en.wikipedia.org/wiki/File:A_Horseshoe_Einstein_Ring_from_Hubble.JPG)
This effect happens too with individual stars, and nowadays telescopes are not able yet to resolve the images in that case, but we can still detect an increase in brightness (that is how a lot of extrasolar planents are being detected). See http://en.wikipedia.org/wiki/Microlensing .In addition to that, typical transverse speeds of stars make unrealistic that a star can hide another fainter one for much time...
Another fact is that, for nearly all practical purposes, galaxies are transparent. In the worst scenario you can think of, at least the different redshifts in the lines would allow to distinguish between two overimposed images. A famous example is the galaxy ngc7603. Two foreground objects with redshifts ~0.2 and ~0.4 are seen through the galaxy itself at redshift ~0.03:
(Image from http://quasars.org/ngc7603.htm)
Another famous example is Q2237+030 (known as "Huchra Lens" or "Einstein Cross"), a background quasar that is seen through the very center of a galaxy. As an additional effect, we see four images of the background quasar, thanks to the bulk mass of the foreground galaxy acting as a lens:
(downloaded from http://www.astr.ua.edu/keel/agn/qso2237.html)
And, finally the image of a star is not a tiny circle, but a diffuse spot, in the ideal case with faint rings (the so called Airy diffraction pattern, impossible to avoid even for the HST) but usually blurred by the atmosphere and spatially extended thorough the CCD plane. That is why it is so difficult to spot Pluto's moon. Not because the angle the objects subtend, but rather due to technical optical limitations (and atmospheric blurring). In some cases, sophisticated deconvolution algorithms have allowed to see additional objects that were embedded in the blurry image of the star. That is how three planets could be seen around HR8977, a star 140 light-years away:
(image from http://keckobservatory.org/gallery/detail/milky_way/27)
The zone of avoidance is only an annoyance if you want to have data from a particular object in a particular wavelength interval, but it is not important for our understanding of the Universe, since at large scales the Universe is homogeneous and isotropic. Consider too that, if we don't restrict to the tiny portion of the spectrum called visible light, the zone of avoidance is not as bad as it seems. I am still amazed by this infrared movie of stars orbiting the central black hole in our galaxy, that was made looking directly through the avoidance zone:
http://www.astro.ucla.edu/~ghezgroup/gc/pictures/orbitsMovie.shtml
A big progress is being made too in gamma and x-rays detectors. It is not completely unrealistic to think that, in the future, there might be neutrino telescopes that achieve the same resolution of today optical instruments (radio astronomy with optical resolution was too a fantasy at the beginning). That would unveil new regions, for instance it would allow us to look directly at the center of the Sun...
| 1 |
Infrared movie of stars orbiting the central black hole in our galaxy
|
Can the word "facet" be used in a sentence like this one?
|
Leadership skills are also a valued facet in a friend.
Can facet be used in this way?
|
A facet is usually one aspect or 'face' of something. We usually talk about a facet of something. Probably because a facet of something is literally one 'face' of it, we don't about facets in things - think of a diamond with many facets. The facets are the flat surfaces or faces on the diamond.
We often talk about facets of jobs, problems and even people's characters, but we don't talk about people themselves having facets. Your sentence, nonetheless, sounds strangely correct as well as definitely wrong. I think this is because the word facet rhymes with the word asset, which would be perfect in your sentence:
Leadership skills are also a valued asset in a friend.
Valuable asset is a very common collocation in English. Asset, as I'm sure you know, means a beneficial or useful thing. Here's the definition from Oxford Dictionaries Online:
NOUN 1.
A useful or valuable thing or person:
quick reflexes were his chief assets
the school is an asset to the community
In case you're interested in the etymology of facet, here is the entry from the Online Etymology Dictionary:
facet (n.)
1620s, from French facette (12c., Old French facete), diminutive of face (see face (n.)). The diamond-cutting sense is the original one. Related: Faceted; facets.
| 1 |
a facet of something is literally one 'face' of a diamond .
|
Planet orbits: what's the difference between gravity and centripetal force?
|
My physics teacher says that centripetal force is caused by gravity. I'm not entirely sure how this works? How can force cause another in space (ie where there's nothing).
My astronomy teacher says that gravity is (note: not like) a 3D blanket and when you put mass on it, the mass causes a dip/dent in the blanket and so if you put another object with less mass it will roll down the dip onto the bigger mass. Is this true and is this what causes the centripetal force.
|
cetripital force only exists when you have prescribed motion (due to constraints). Think of a roller coaster car riding on a rail. To keep the car on the rail and tangetial to it's direction a force and moment need to be applied to the car. When the path is circular we call the cetripetal force. In fact, with any path, instanteously it is said to be following a circle and therefore there is always an instanteneous centripetal force (unless in free fall).
Planets and things in orbit do not have a prescribed motion, but are following the free fall path whichever way they need to go. Gauss called this the principle of least action.
I hope this helps.
| 1 |
Cetripital force only exists when you have prescribed motion (due to constraints)
|
Advice on using FORMAT_MODULE_PATH
|
From what I have read FORMAT_MODULE_PATH allows to use custom formats.
How can I access the first value from DATETIME_INPUT_FORMATS in my application?
The DATETIME_INPUT_FORMATS variable for german should be '%d.%m.%Y', whereas for english should be '%Y-%m-%d'. I want to use the values from the formats.py files depending on the language.
I followed the Django documentation for how to use the FORMAT_MODULE_PATH variable, but I don't get the expected results.
settings.py:
USE_L10N = True
USE_I18N = True
FORMAT_MODULE_PATH = 'myproject.formats'
myproject/
formats/
__init__.py
en/
__init__.py
formats.py
de/
__init__.py
formats.py
I change the browser's language from English to German, and back and nothing happens with the date format. It is always '%Y-%m-%d'. The displayed date format is the value of settings.DATE_INPUT_FORMATS[0].
Django version is 1.2.5 and Python version is 2.5.4.
|
I couldn't make it work using the FORMAT_MODULE_PATH setting, but I have managed to this using formats.get_format('DATE_INPUT_FORMATS')[0]. You can find this in my answer.
| 1 |
Format.get_format('DATE_INPUT_FORMATS')
|
What are the rules of thumb for margins in web design?
|
My web designer tells me that in a web page, the empty margins or padding should always be multiples of a standard. For example 6 px, 12px, 18px. This should produce nicely balanced lay-outs. I would like to learn a little bit more about it:
Should one really not violate this at all?
Should the standard be the same horizontally and vertically?
|
You should have consistency yes - but if the page is not user focused what good are multiple standard margins/padding anyways. I try and use multiples of 5 personally as it is faster to equate.
| 0.777778 |
How to equate multiples of 5
|
How can I check USB drive contents safely?
|
I would like to check the contents of a USB stick drive from a not-quite trusted source (my sister): is there a safe way to do this in OSX 10.9.5 or 10.10.1?
|
One option is to reboot your Mac to a Linux installation CD/DVD.
You can unmount your local hard disk once the Linux desktop loads.
You can then plug in the thumb drive and be isolated from your installation of Mac OS X as well as your local hard disk.
| 1 |
Reboot Mac to Linux installation CD/DVD
|
Change face of plain text between double quotation marks in Emacs
|
I am looking for a way to highlight or use different face of quoted text in plain text. It seems that there should be a sophisticated/enhanced text mode but I cannot find it.
If there isn't a easy solution, can you let me know where should I begin to write a function?
Thank you very much!
A noob who has been using Emacs from 19.xx
|
I'm not sure about a major-mode that already does this, but you can make one easily enough using define-derived-mode
(define-derived-mode rich-text-mode text-mode "Rich Text"
"text mode with string highlighting."
;;register keywords
(setq rich-text-font-lock-keywords
'(("\"\\(\\(?:.\\|\n\\)*?[^\\]\\)\"" 0 font-lock-string-face)))
(setq font-lock-defaults rich-text-font-lock-keywords)
(font-lock-mode 1))
Alternatively, you can add a hook to text-mode:
(defun add-quotes-to-font-lock-keywords ()
(font-lock-add-keywords nil '(("\"\\(\\(?:.\\|\n\\)*?[^\\]\\)\"" 0 font-lock-string-face))))
(add-hook 'text-mode-hook 'add-quotes-to-font-lock-keywords)
Generally speaking, a good mode for editing any text is org-mode. It does not font-lock strings by default, though.
| 1 |
define-derived-mode does not font-lock strings by default
|
Should an adverb go before or after a verb?
|
For example:
The word rarely turns up outside of those contexts.
The word turns up rarely outside of those contexts.
Which one is correct and why?
|
Both correct, I don't think it's supposed to be limited here. Maybe the creative usage "turns rarely up" would also be used in some cases.
| 1 |
Creative usage "turns rarely up"
|
How do I set serial special characters?
|
In my ongoing quest to interface with some legacy equipment, I've discovered that the vendor supplied software sets the special characters to:
00 00 00 00 11 13
But the SerialPort class of .NET set them to:
1A 00 00 1A 11 13
I suppose that I have two questions:
What do these bytes mean?
How can I tell SerialPort to use a specific set of special characters?
The latter is all I really care about, but I suspect the former is going to be useful to know.
Update: The following doesn't work:
byte[] specialchars = {
0x00,
0x00,
0x00,
0x00,
0x11,
0x13
};
this.port.NewLine = System.Text.Encoding.ASCII.GetString(specialchars);
Update 2: As requested, here are Portmon logs for the vendor supplied app (filtered to remove the many thousands of IOCTL_SERIAL_GET_COMMSTATUS entries) and for my attempt to match even the first exchange.
|
NewLine is not what you are looking for. It's the plain old 'new line' sequence, e.g. CR LF or LF alone.
The special characters are handled like this:
EOF — set to 0x1a, you cannot change it in .NET
ERR — set by SerialPort.ParityReplace
BRK — don't know
EVT — set to 0x1a, you cannot change it in .NET
XON — set to 0x11, you cannot change it in .NET, and it doesn't even usually make sesn
XOFF — set to 0x13, you cannot change it in .NET, and it doesn't even usually make sesn
It may be helpful for you to study the Win32 DCB structure as well. It's used by .NET internally to set the state of the serial port.
| 1 |
NewLine is the plain old 'new line' sequence
|
Array Binding simple example doesn't work
|
I'm very new to xaml and I'm trying to understand the Binding issue. I have a problem with the Array Binding. I created this very simple example: I have a stack panel with three images. Each image has a RotationTransform. Each Angle is obtained by an array element (the array is a DependencyProperty called Rotations). This is the xaml simple file:
<StackPanel Orientation="Vertical">
<Image Source="/Assets/knife.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding ElementName=pageRoot, Path=Rotations[0], Mode=OneWay}"/>
</Image.RenderTransform>
</Image>
<Image Source="/Assets/fork.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding ElementName=pageRoot, Path=Rotations[1], Mode=OneWay}"/>
</Image.RenderTransform>
</Image>
<Image Source="/Assets/spoon.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding ElementName=pageRoot, Path=Rotations[2], Mode=OneWay}"/>
</Image.RenderTransform>
</Image>
<Button x:Name="actionButton" Content="Try Binding!"
Click="Op_Click"/>
</StackPanel>
And this is my c# class:
public sealed partial class MainPage : Page
{
public static readonly DependencyProperty RotationsProperty = DependencyProperty.Register("Rotations", typeof(double[]), typeof(MainPage),
new PropertyMetadata(new double[3]));
public double[] Rotations
{
get { return (double[])GetValue(RotationsProperty); }
set { SetValue(RotationsProperty, value); }
}
private void Op_Click(object sender, RoutedEventArgs e)
{
Rotations[0] = 180;
Rotations[1] = 130;
Rotations[2] = 350;
}
public MainPage()
{
this.InitializeComponent();
Rotations[0] = 20;
Rotations[1] = 90;
Rotations[2] = 180;
}
}
The binding works only the first time (at startup time). When I click on the button (changing the Rotations array) the binding doesn't work and it is completely ignored from my images.
This is a very simple example, so it's clear that I miss something concerning the Binding issue.
|
Try the below code:
Xaml:
<StackPanel Orientation="Vertical">
<Image Source="/Assets/knife.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding Rotations[0], Mode=OneWay}"/>
</Image.RenderTransform>
</Image>
<Image Source="/Assets/fork.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding Rotations[1], Mode=OneWay}"/>
</Image.RenderTransform>
</Image>
<Image Source="/Assets/spoon.png" Width="50" Height="100" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform Angle="{Binding Rotations[2], Mode=OneWay}"/>
</Image.RenderTransform>
</Image>
<Button x:Name="actionButton" Content="Try Binding!"
Click="Op_Click"/>
</StackPanel>
In the code behind set the DataContext as below :
this.DataContext = this;
| 0.888889 |
Set the DataContext as below.DataContext
|
Convert "Mon Aug 01 09:08:25 CDT 2011" to a usable date/time using Excel
|
I have a giant spreadsheet with computer names and the date stamp that they last reported into our PGP server that I need to convert to a usable date/time, so I can sort the column by the time the computer last reported. The format of the field now is as follows:
Mon Aug 01 09:08:25 CDT 2011
All of them have a 3-character day followed by a 3-character month followed by a 2 character date, and so on, so someone with some Excel skill should be able to parse it out.
Edit -- The closest I have come to getting it is using this formula:
RIGHT(L2,4),VLOOKUP(MID(L2,5,3),MonthLookup!A:B,2,FALSE),MID(L2,9,2)
Where L2 is the field I am trying to convert and MonthLookup is a sheet with two columns, the first column being the 3 character month ("Jan", "Feb", etc.) and the second column being the numerical month (1, 2, etc.)
This gives me a usable date, but I need to keep the time as well.
|
Well it's going to depend on what format you want to get as a result. This:
=MID(A1,5,15) & " " & MID(A1, 25, 4)
Would give you a result of:
Aug 01 09:08:25 2011
Just play around with MID() to get the parts that you want and use & to concatenate them together in the order that you want.
| 0.888889 |
MID(A1,5,15) & "
|
Equivalent of Java 1.6 @Override for interfaces in C#
|
This question gives the answer that Java's @Override has the C# equivalent of the override keyword on methods. However, since Java 1.6 the @Override annotation can be applied to interfaces also.
The practical use for this is that in Java you get compile errors when a class claims it implements an interface method when it no longer does (e.g. if the interface method is removed). Is there equivalent functionality in C#?
Some code examples:
Java:
public interface A {
public void foo();
// public void bar(); // Removed method.
}
public class B implements A {
@Override public void foo();
@Override public void bar(); // Compile error
}
C#:
public interface IA {
void Foo();
// void Bar(); // Removed method.
}
public class B : A {
public override void Foo(); // Doesn't compile as not 'overriding' method
public void Bar(); // Compiles, but no longer implements interface method
}
|
There is similar functionality: explicit interface implementation.
public interface IA {
void foo();
// void bar(); // Removed method.
}
public class B : IA {
void IA.foo() {}
void IA.bar() {} // does not compile
}
The problem is that if you do this you cannot call the methods through the this pointer (from inside the class) or through an expression that evaluates to a B -- it is now necessary to cast to IA.
You can work around that by making a public method with the same signature and forwarding the call to the explicit implementation like so:
public class B : IA {
void IA.foo() { this.foo(); }
public void foo() {}
}
However this isn't quite ideal, and I 've never seen it done in practice.
| 0.833333 |
How to cast to IA?
|
.xlsx and xls(Latest Versions) to pdf using python
|
With the help of this .doc to pdf using python
Link I am trying for excel (.xlsx and xls formats)
Following is modified Code for Excel:
import os
from win32com import client
folder = "C:\\Oprance\\Excel\\XlsxWriter-0.5.1"
file_type = 'xlsx'
out_folder = folder + "\\PDF_excel"
os.chdir(folder)
if not os.path.exists(out_folder):
print 'Creating output folder...'
os.makedirs(out_folder)
print out_folder, 'created.'
else:
print out_folder, 'already exists.\n'
for files in os.listdir("."):
if files.endswith(".xlsx"):
print files
print '\n\n'
word = client.DispatchEx("Excel.Application")
for files in os.listdir("."):
if files.endswith(".xlsx") or files.endswith('xls'):
out_name = files.replace(file_type, r"pdf")
in_file = os.path.abspath(folder + "\\" + files)
out_file = os.path.abspath(out_folder + "\\" + out_name)
doc = word.Workbooks.Open(in_file)
print 'Exporting', out_file
doc.SaveAs(out_file, FileFormat=56)
doc.Close()
It is showing following error :
>>> execfile('excel_to_pdf.py')
Creating output folder...
C:\Excel\XlsxWriter-0.5.1\PDF_excel created.
apms_trial.xlsx
~$apms_trial.xlsx
Exporting C:\Excel\XlsxWriter-0.5.1\PDF_excel\apms_trial.pdf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "excel_to_pdf.py", line 30, in <module>
doc = word.Workbooks.Open(in_file)
File "<COMObject <unknown>>", line 8, in Open
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Excel
', u"Excel cannot open the file '~$apms_trial.xlsx' because the file format or f
ile extension is not valid. Verify that the file has not been corrupted and that
the file extension matches the format of the file.", u'xlmain11.chm', 0, -21468
27284), None)
>>>
There is problem in
doc.SaveAs(out_file, FileFormat=56)
What should be FileFormat file format?
Please Help
|
Link of xlsxwriter :
https://xlsxwriter.readthedocs.org/en/latest/contents.html
With the help of this you can generate excel file with .xlsx and .xls
for example excel file generated name is trial.xls
Now if you want to generate pdf of that excel file then do the following :
from win32com import client
xlApp = win32com.client.Dispatch("Excel.Application")
books = xlApp.Workbooks.Open('C:\\excel\\trial.xls')
ws = books.Worksheets[0]
ws.Visible = 1
ws.ExportAsFixedFormat(0, 'C:\\excel\\trial.pdf')
| 0.888889 |
Excel file generated name is trial.xls
|
Is the Hebrew vocabulary used in the Tanakh/(other recognized Hebrew books) the same as the what is considered Hebrew today?
|
There are many Hebrew resources available in the mainstream world, i.e. Webster's, Google, etc. Is the Hebrew used in the Tanakh/(other recognized Hebrew books, i.e. the Mishna, Rambam, etc.) considered to have the same vocab (word definitions, not necessarily grammar etc.) as what is commonly referred to as Hebrew nowadays? It is my understanding that it is, i.e. any English-Hebrew dictionary could be consulted to translate the texts for an English speaker, but how could this be verified? Is there some sort of official Rabbinical concordance of Hebrew?
|
The Hebrew used in the Tanakh is often the source for most of Modern Hebrew. However, influences of history have changed the modern day Hebrew in ways that are not always so noticeable. For Example:
A lot of Aramaic has slipped its way into modern Hebrew, even down to the most basic words.
Father in Tanakh: "Av"
Father in Modern Hebrew: "Abba" (Aramaic)
This is not a unique phenomenon, the Tanakh itself has loan words from other languages. If you asked the average Israeli, they would not know that Abba is Aramaic in origin.
The reversing waw/vav is also heavily prevalent in Biblical Hebrew (but by no means is used 100% of the time). It's common English name of the reversing waw/vav is because it switches the past tense to future tense, and future tense to past tense, simply by adding a waw to the front of the verb. You often see a mixing of the normal verb conjugation with a sprinkling of this reversing waw in many paragraphs, including the first paragraph of the Torah.
בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ.
וְהָאָרֶץ, הָיְתָה תֹהוּ וָבֹהוּ, וְחֹשֶׁךְ, עַל פְּנֵי תְהוֹם.
וְרוּחַ אֱלֹהִים, מְרַחֶפֶת עַל פְּנֵי הַמָּיִם. וַיֹּאמֶר
אֱלֹהִים, יְהִי אוֹר; וַיְהִי אוֹר; וַיַּרְא אֱלֹהִים אֶת
הָאוֹר, כִּי טוֹב .וַיַּבְדֵּל אֱלֹהִים, בֵּין הָאוֹר וּבֵין
הַחֹשֶׁךְ; וַיִּקְרָא אֱלֹהִים לָאוֹר יוֹם, וְלַחֹשֶׁךְ קָרָא
לָיְלָה. וַיְהִי עֶרֶב וַיְהִי בֹקֶר, יוֹם אֶחָד.
Some other oddities would include the verb roots having changed as Hebrew pronunciation by communities caused mistakes to become the new norm. i can't remember the word off the top of my head, but i remember that the root in the Tanakh had an Ayin, but in modern Hebrew, the Ayin was replaced with an Aleph, most likely due to the pronunciation of Ayin being lost in many communities and the writing reflecting the pronunciation.
Another possible large difference is the use of the "present tense." Modern Hebrew has an established present tense, while according to Historians and Biblical grammarians, Biblical Hebrew has no "present tense." According to them, Biblical Hebrew has only two tenses, perfect tense (action is complete) and imperfect tense (action is not yet complete). For them, words/conjugations that we would call present tense are actually "active participles." An example of what this means/looks like would be the following:
אָנִי שׁוֹמֵר אוֹתֶךָ
How the text translates in Modern Hebrew: "I am guarding you."
How the text translates in Biblical Hebrew according to Historians: "I am the
one that guards you."
But if you try and make the argument of Biblical Hebrew not having a present tense to your local Rabbi, be prepared for some resistance. The prior two times i had mentioned in a Synagogue setting that Biblical Hebrew did not have a present tense, it led to a very long debate in which the Rabbi's would refuse to allow anyone who heard my statement to walk away with the belief that Biblical Hebrew didn't have a present tense.
| 1 |
How the text translates in Modern Hebrew: "I am guarding you"
|
R biglm predict searching for dependent variable
|
I'm using the biglm package to run a regression on a data set. The regression runs fine using the following code:
chunkStart <- seq(1,150000000,1000000)
chunkEnd <- seq(1000000,151000000,1000000)
ff <- price ~ factor(Var1) + factor(Var2)
#for(i in 1:length(chunkStart)){
for(i in 1:5){
startRow <- chunkStart[i]
endRow <- chunkEnd[i]
curchunk <- data.frame( price=x[startRow:endRow,1]
,Var1=factor( x[startRow:endRow,6], levels=1:3), Var2= factor( x[startRow:endRow,7], levels=1:3 ) )
if(i == 1){
a <- biglm(ff,curchunk )
}
if(i != 1){
a <- update(a,curchunk )
}
rm(curchunk )
gc()
print(paste(i, " | ",startRow ," | ",endRow ," | ", sep=""))
flush.console()
}
> summary(a)
Large data regression model: biglm(ff, curchunk)
Sample size = 5000000
Coef (95% CI) SE p
(Intercept) 0.0457 0.0454 0.0461 2e-04 0
factor(Var1)2 0.0189 0.0184 0.0194 2e-04 0
factor(Var1)3 0.0148 0.0142 0.0155 3e-04 0
factor(Var2)2 -0.0331 -0.0335 -0.0326 2e-04 0
factor(Var2)3 -0.0417 -0.0426 -0.0408 4e-04 0
The problems come when I try to predict using the biglm object, 'a'.
> df1 <- data.frame(y[1:1000,])
> pred1 <- predict(a, df1)
Error in eval(expr, envir, enclos) : object 'price' not found
Why is the predict function looking for the price/ dependent variable? Any suggestions?
EDIT:
> head(df1)
Var1 Var2
1 3 3
2 3 1
3 3 2
4 2 1
5 2 2
6 1 1
> str(df1)
'data.frame': 1000 obs. of 2 variables:
$ Var1: Factor w/ 3 levels "1","2","3": 3 3 3 2 2 1 2 1 2 1 ...
$ Var2: Factor w/ 3 levels "1","2","3": 3 1 2 1 2 1 1 1 2 1 ...
> pred1 <- predict(a, df1)
Error in eval(expr, envir, enclos) : object 'price' not found
|
The reason it is looking for the dependent variable is that the predict method uses a call to model.frame from the stats package, and that function requires all the variables to be present in the new data. This is indicated on the model.frame help page without explanation for the motivation behind it.
All you actually need to do about this is create a variable in your new data that has the same name as the dependent variable, then fill it with zeroes (or any non-missing value). So it should work if you run this:
df1$price <- 0
pred1 <- predict(a, df1)
| 0.777778 |
df1$price <- predict
|
iPhone app - Persistent hamburger menu vs last page visited
|
I'm wondering which option is best for an iPhone app using a hamburger menu (placed at the top left):
The menu is persistent on every single page even when the user goes
to a sub-level.
When the user goes to a sub-level, the hamburger menu is replaced by a back button or a button whose label is the name of last page visited.
Both. The menu is persistent on every page and a back button appears when needed.
Thanks for your help :)
|
Always have your navigation persistent.
But that doesn't mean you can't have a "back" button in place when it's needed when you dig deeper on portions of the site.
download bmml source – Wireframes created with Balsamiq Mockups
Now this is just for the sake of your answer, but I highly suggest against the hamburger menu. Many products (twitter and Facebook to name a few) have moved away from the hamburger menu because of various reasons:
Discoverability was at an all time low
Not a lot of people understood what the hamburger menu was
They all placed a navigation element that was persistent on the bottom of the page, where people could toggle between what they knew were big hit points on the site (timeline, discover, messages, etc).
Some examples:
| 1 |
Using a "back" button in place
|
Difference in technique for cooking with non-stick and standard pans?
|
Following up from my previous question, which I'd raised because I have concerns that my non-stick wok will need replacing very soon (again), and was having a think about "standard" pans.
I'm not currently interested in differences in care/cleaning/etc, I think those are quite well covered in other questions.
So, I'm wondering what's the difference in the required technique when using them to cook food?
|
You can get the benefits of both non-stick and fond by prepping the stainless steel pan so it's more non-stick:
Use the "water test" to know when a stainless steel pan is hot enough to add oil. Besides being fascinating to watch, passing the water test ensures the pan becomes amazingly non-stick.
When the pan is hot enough, water will ball up like mercury and slide around the pan without evaporating. The temperature required is pretty high, but I've found the non-stick properties remain if I add the oil and let the pan cool to the cooking temperature I want.
Note: preheating the pan like this applies to non-stainless steel pans, but water only balls up like mercury on stainless steel.
Detailed explanation of how/why this works: On properly heating your pan
| 1 |
Prepping stainless steel pans for non-stick and fond
|
Is encrypting a single 128 bit block with AES ECB "safe"
|
I want to encrypt a small piece of data that is less that 16 bytes in size (think SSN), and I'll be using a 256bit encryption key. The typical suggestion is to never use ECB, but if there is just a single block being encrypted, is it a concern?
The reason I want to use ECB is because I want the encrypted value of the block to be consistent between encryptions for other reasons (so I can check if a value already exists by just comparing the uniqueness of the cipherText).
Updated: Also note that these encrypted values will be stored in a set, so there will not be data leakage by having multiple encrypted values of the same plainText available.
|
Thomas' comment is correct. While, theoretically, ECB is perfectly acceptable for use in a single block, the lack of any IV means your crypto system will leak information if you ever encrypt the same plaintext with the same key. Even if you are encrypting discrete messages, I highly recommend using something that has an IV to prevent this kind of attack.
Though I don't know what application you are thinking of, in many cases when you are encrypting SSNs or similar, it may be worth using public/private key cryptography so as not to require having the private key anywhere on the machines that are accepting the input.
| 0.888889 |
ECB is perfectly acceptable for use in a single block
|
How do you get your Steam games to run on Ubuntu through Wine or something similar?
|
Ok, I was kind of surprised that this hadn't been asked here before, but maybe it's too technical for this site. You guys decide.
I've heard lots of different stories about setting up Wine on Ubuntu, WineTricks, PlayOnLinux etc., but never a 'This is the best way to do it for Steam and Steam games' thread.
So has anyone had any real success getting their Steam games to run on Ubuntu through Wine or something similar? If so, could we get some specific steps?
|
You could try http://transgaming.com/ (Cedega). I did this in the past and it worked fine, but you have to pay for it - :\
| 1 |
http://transgaming.com/
|
Build-time GLSL syntax validation
|
Is there a way to validate GLSL syntax build-time instead of run-time? My application takes a long time to start and I want to know at the earliest possible stage that my shaders are ok. I'm using Visual Studio/Xcode. The solution probably involves running a tool as a part of build process, but I'm looking for such a tool.
|
This is a pretty late reply, but some new options have shown up recently to address this.
Khronos released a reference compiler called glslangValidator that can perform syntax validation (and more) on GLSL shader files. If there are any issues with your shader, it will print them out with line number information.
You can set up a custom pre build step or the like in Visual Studio or XCode to run this tool on your shader files.
I also wrote a Property Sheet for Visual Studio that makes use of glslangValidator to do build time validation of shader files. You can find it here.
| 0.777778 |
glslangValidator can perform syntax validation on GLSL shader files
|
How do I auto-remove trailing whitespace in Android Studio?
|
Similar to the question for eclipse,
How can I auto-remove trailing whitespace from the entire file being edited?
How can I auto-remove trailing whitespace only from the lines I changed?
|
Ha, it's as simple as Code->Reformat code... (option-cmd-L)
| 1 |
Code->Reformat code
|
Google Fonts loading on desktop, but not on mobile?
|
Per Google PageSpeed's recommendation, I inlined much of my CSS. Previously, I had minified all of my CSS through W3 Total Cache, but now I inlined much of my CSS, plus all of the CSS that controls Google Fonts.
Now Google Fonts aren't appearing on mobile devices, but they do appear on desktops. Any reason why this is the case? The mobile screen cap here shows the fonts not loading.
<style>@font-face{font-family:'Pathway Gothic One';font-style:normal;font-weight:400;src:local('Pathway Gothic One'),local(PathwayGothicOne-Regular),url(https://fonts.gstatic.com/s/pathwaygothicone/v4/Lqv9ztoTUV8Q0FmQZzPqaA6LSHyyJAN5JIFgwWnj0Az3rGVtsTkPsbDajuO5ueQw.woff2) format("woff2");unicode-range:U+0100-024F,U+1E00-1EFF,U+20A0-20AB,U+20AD-20CF,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:'Pathway Gothic One';font-style:normal;font-weight:400;src:local('Pathway Gothic One'),local(PathwayGothicOne-Regular),url(https://fonts.gstatic.com/s/pathwaygothicone/v4/Lqv9ztoTUV8Q0FmQZzPqaHT0-GP0evTJPrdxn7U7ioo.woff2) format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2212,U+2215,U+E0FF,U+EFFD,U+F000}@font-face{font-family:'Quicksand';font-style:normal;font-weight:400;src:local('Quicksand Regular'),local(Quicksand-Regular),url(https://fonts.gstatic.com/s/quicksand/v5/sKd0EMYPAh5PYCRKSryvW5Bw1xU1rKptJj_0jans920.woff2) format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2212,U+2215,U+E0FF,U+EFFD,U+F000}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:400;src:local('Roboto Condensed'),local(RobotoCondensed-Regular),url(https://fonts.gstatic.com/s/robotocondensed/v13/Zd2E9abXLFGSr9G3YK2MsIPxuqWfQuZGbz5Rz4Zu1gk.woff2) format("woff2");unicode-range:U+0460-052F,U+20B4,U+2DE0-2DFF,U+A640-A69F}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:400;src:local('Roboto Condensed'),local(RobotoCondensed-Regular),url(https://fonts.gstatic.com/s/robotocondensed/v13/Zd2E9abXLFGSr9G3YK2MsENRpQQ4njX3CLaCqI4awdk.woff2) format("woff2");unicode-range:U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:400;src:local('Roboto Condensed'),local(RobotoCondensed-Regular),url(https://fonts.gstatic.com/s/robotocondensed/v13/Zd2E9abXLFGSr9G3YK2MsET2KMEyTWEzJqg9U8VS8XM.woff2) format("woff2");unicode-range:U+1F00-1FFF}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:400;src:local('Roboto Condensed'),local(RobotoCondensed-Regular),url(https://fonts.gstatic.com/s/robotocondensed/v13/Zd2E9abXLFGSr9G3YK2MsMH5J2QbmuFthYTFOnnSRco.woff2) format("woff2");unicode-range:U+0370-03FF}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:400;src:local('Roboto Condensed'),local(RobotoCondensed-Regular),url(https://fonts.gstatic.com/s/robotocondensed/v13/Zd2E9abXLFGSr9G3YK2MsDcCYxVKuOcslAgPRMZ8RJE.woff2) format("woff2");unicode-range:U+0102-0103,U+1EA0-1EF1,U+20AB}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:400;src:local('Roboto Condensed'),local(RobotoCondensed-Regular),url(https://fonts.gstatic.com/s/robotocondensed/v13/Zd2E9abXLFGSr9G3YK2MsNKDSU5nPdoBdru70FiVyb0.woff2) format("woff2");unicode-range:U+0100-024F,U+1E00-1EFF,U+20A0-20AB,U+20AD-20CF,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:400;src:local('Roboto Condensed'),local(RobotoCondensed-Regular),url(https://fonts.gstatic.com/s/robotocondensed/v13/Zd2E9abXLFGSr9G3YK2MsH4vxAoi6d67T_UKWi0EoHQ.woff2) format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2212,U+2215,U+E0FF,U+EFFD,U+F000}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:700;src:local('Roboto Condensed Bold'),local(RobotoCondensed-Bold),url(https://fonts.gstatic.com/s/robotocondensed/v13/b9QBgL0iMZfDSpmcXcE8nBYyuMfI6pbvLqniwcbLofP2Ot9t5h1GRSTIE78Whtoh.woff2) format("woff2");unicode-range:U+0460-052F,U+20B4,U+2DE0-2DFF,U+A640-A69F}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:700;src:local('Roboto Condensed Bold'),local(RobotoCondensed-Bold),url(https://fonts.gstatic.com/s/robotocondensed/v13/b9QBgL0iMZfDSpmcXcE8nIT75Viso9fCesWUO0IzDUX2Ot9t5h1GRSTIE78Whtoh.woff2) format("woff2");unicode-range:U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:700;src:local('Roboto Condensed Bold'),local(RobotoCondensed-Bold),url(https://fonts.gstatic.com/s/robotocondensed/v13/b9QBgL0iMZfDSpmcXcE8nL8EBb1YR1F8PhofwHtObrz2Ot9t5h1GRSTIE78Whtoh.woff2) format("woff2");unicode-range:U+1F00-1FFF}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:700;src:local('Roboto Condensed Bold'),local(RobotoCondensed-Bold),url(https://fonts.gstatic.com/s/robotocondensed/v13/b9QBgL0iMZfDSpmcXcE8nAro84VToOve-uw23YSmBS72Ot9t5h1GRSTIE78Whtoh.woff2) format("woff2");unicode-range:U+0370-03FF}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:700;src:local('Roboto Condensed Bold'),local(RobotoCondensed-Bold),url(https://fonts.gstatic.com/s/robotocondensed/v13/b9QBgL0iMZfDSpmcXcE8nACS0ZgDg4kY8EFPTGlvyHP2Ot9t5h1GRSTIE78Whtoh.woff2) format("woff2");unicode-range:U+0102-0103,U+1EA0-1EF1,U+20AB}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:700;src:local('Roboto Condensed Bold'),local(RobotoCondensed-Bold),url(https://fonts.gstatic.com/s/robotocondensed/v13/b9QBgL0iMZfDSpmcXcE8nGPMCwzADhgEiQ8LZ-01G1L2Ot9t5h1GRSTIE78Whtoh.woff2) format("woff2");unicode-range:U+0100-024F,U+1E00-1EFF,U+20A0-20AB,U+20AD-20CF,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:'Roboto Condensed';font-style:normal;font-weight:700;src:local('Roboto Condensed Bold'),local(RobotoCondensed-Bold),url(https://fonts.gstatic.com/s/robotocondensed/v13/b9QBgL0iMZfDSpmcXcE8nPX2or14QGUHgbhSBV1Go0E.woff2) format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2212,U+2215,U+E0FF,U+EFFD,U+F000}</style>
Can be seen here.
|
You only have definitions for woff2. This probably will not only not work on mobile but as well not in many other Desktop browsers. For example, Internet Explorer requires eot, Safari requires ttf. I think only Chrome uses woff2. Depending on which mobile browser you use you need a different font format. I believe Safari on IOS even uses svg!
I think what you did is, you opened the CSS file Google Fonts gave you and simply copied the content. The problem is, this CSS depends on the User Agent. It has different content with the correct font format for the Browser which requested.
You could use a tool like http://localfont.com to generate the correct CSS with all font formats. They have different formats for downloading fonts as well only generating CSS for inline use.
| 0.888889 |
woff2 does not work on mobile but in many other Desktop browsers
|
How to fill a shape in photoshop and avoid white lines
|
This is something it will be useful for several things now that I started "photoshoping" - so I made some lines with the pen tool, then right clicked with the 'direct selection' and then 'stroke path' to paint the lines.
Now, this lines are closed, they make a shape, if I paint the inside with the bucket tool it creates white spaces inbetween the border and the filling!
How does one fill properly in photoshop?
|
This happens because of anti-aliasing; pixels of lighter colors are generated along edges in order to make it look smooth. The paint bucket doesn't fill those other colors, just the empty pixels.
There are so many ways to do this! Since you already discovered the paint bucket, here is a simple way using the same tool:
Before you click to fill with the bucket, while it's selected, locate in the top menu a place named "Tolerance". Increase the value. Too little won't make a difference, too much will fill the whole screen. You should have that option if you're on CS5+, not sure about earlier versions.
| 0.888889 |
The paint bucket doesn't fill other colors, just empty pixels
|
Is there added value in having your own presentation layout and using it consistently?
|
From the perspective of a Ph.D. student, how much of an added value is it to have your own presentation slides layout, that is used consistently throughout your Ph.D. conference presentations and other talks (and possibly throughout your academic career afterwards)?
Here is one such example from the Computer Science community.
This as as opposed to using existing Beamer templates with LaTeX, or built-in PowerPoint templates, or simply preparing each presentation on its own (without a specific layout).
A couple of axes I can think along:
Creating a signature layout that distinguishes one in their community
Ease of preparation of presentations (especially over time), maybe overcoming constraints with existing templates.
Note that I am not concerned with the question of content, but just design and layout.
|
I always appreciate when someone cares about their presentation. There are some things that are just inexcusable (e.g., tables that are left aligned on one slide and centered on another), and make you look lazy, so to the extent a consistent template would mitigate those then it can't hurt.
My presentations tend to look the same and stand out against my peers. I do all of my writing in Markdown, analyses in R, and create dynamic presentations with some available R packages. Therefore, all of my graphs tend to have a style (ggplot2), tables look the same in HTML, fonts (and related consistencies between headings and body text) work together nicely. It's not just about the style of the presentation, as I know a few people who give presentations and have a very distinctive voice in their text, and a welcomed minimalism in slide content.
I never thought too much about it, but I do have a "style" or "brand" in my presentations that most people who have met me and seen me present a few times recognize as clearly a presentation I crafted. However, this "brand" is really just me using a specific set of tools that most people don't use. What's the standard for most fields? Unfortunately Powerpoint, and some use the Mac Office Suite, while a few others use Prezi (and most use that tool poorly).
There's a range of tools out there that you can utilize that might help develop a consistent "style" for you, but also will help to vastly improve your workflow, and also make your scholarship better (i.e., tools with an emphasis on reproducibility).
Whatever you do just do it well and make sure it works for you and our audiences.
| 1 |
What's the standard for most fields?
|
How to deploy webpart on production (not debugging) server?
|
I've created a web part, debugging it on a test Sharepoint 2010 install on my local workstation. I'd like to test it on our production server. It seems that I won't be able to use Build --> Deploy to accomplish this, and I have to deal with my assembly and .webpart file.
What are the steps to accomplish this?
|
Alternatively you can create some .bat files and then run them from command prompt as Administrator:
1. Add.bat
"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\stsadm.exe" -o addsolution -filename "C:\YourSolution.wsp"
"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\stsadm.exe" -o deploysolution -name "YourSolution.wsp" -immediate -url http://YourDomain -allowgacdeployment -allowcaspolicies
2. Retract.bat
"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\stsadm.exe" -o retractsolution -name "YourSolution.wsp" -immediate -allcontenturls
3. Delete.bat
"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\stsadm.exe" -o deletesolution -name YourSolution.wsp
Additional resources:
Index for Stsadm operations and properties
| 0.888889 |
Retract.bat "C:Program Files"
|
Kohana (or straight PHP) OAuth2 implementation
|
Does anyone have a very clear step-by-step guide for implementing OAuth2 (preferably in Kohana 3.2, but I'll take whatever I can get)?
I would like it to include the tables I need to create, etc. (Hard to implement something without knowing the table structure.)
UPDATE:
I completely forgot to mention that I'm looking for a Provider implementation! Thanks! (and sorry).
|
Maybe this helps: https://github.com/kohana-world (look into https://github.com/kohana-world/kw-accounts and https://github.com/kohana-world/kw-auth modules). Unfortunately, currently we have no time for development :(
PS. Also I've wrote an article about OAuth2 in Kohana, you can try to translate it from russian: http://translate.google.com/translate?hl=ru&ie=UTF8&prev=_t&sl=ru&tl=en&u=http://brotkin.ru/2011/05/24/oauth-v2/
| 0.5 |
https://github.com/kohana-world
|
Administer block permission let the user to see admin theme name
|
I gave the site admin role permission to administer blocks, but the problem is in admin/structure/block page, there is a tab that shows the admin theme name (Rubik).
he can click on Rubik but doesn't have permission to see the page.
what I want is to hide the tab.
other issue is in admin_menu module under structure > blocks there is a Rubik item too, which shouldn't be there too since the user doesn't have the permission to edit admin theme blocks.
So I'm wondering why does rubik block page link shows up!
|
In theory, you could write a module that uses hook_menu_alter(). It would modify the access callback element in the "admin theme" menu item (and maybe sub-menu items?). The callback function would check user_access('administer themes'). You could probably write this in 30 minutes or less.
That would cover both cases -- the block admin page and the admin menu.
| 0.777778 |
How to write a module that uses hook_menu_alter()
|
Will a 78S12 be cooler than a 7812 when handling the same load?
|
Given of course that both come in a TO-220 case. I wouldn't think so, right? I try to make it out from the K/W ratings but they seem to vary wildly from manufacturer to manufacturer. Anybody knows the answer?
|
Just about exactly the same. 5°C/W for both packages in TO-220 for junction to case, and 50°C/W for junction to ambient (under same conditions for the latter, and same manufacturer- ST). Sometimes they use a thicker leadframe (or use more thermally conductive materials) but that does not seem to be the case here.
The quiescent current is typically 4.4mA for both so even that (30mW) loss will be about the same.
| 1 |
The quiescent current is typically 4.4mA for both packages in TO-220 and 50°C for junction to ambient
|
Errors when attempting to install a sharepoint 2010 feature
|
I'm attempting to install and activate a feature containing a Timer Job. When I execute the install-spfeature cmdlet I get the following error. What is the source of my error?
PS C:\Users\crmadmin> install-spfeature AltirisOpsListFeature
Install-SPFeature : Required tag 'http://schemas.microsoft.com/sharepoint/:Feat
ure' is missing from XML file 'feature.xml', found 'Feature' instead.
At line:1 char:18
+ install-spfeature <<<< AltirisOpsListFeature
+ CategoryInfo : InvalidData: (Microsoft.Share...tInstallFeature:
SPCmdletInstallFeature) [Install-SPFeature], ArgumentException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletInstallF
eature
The feature folder has been added to the 14\Template\Features directory, the Feature.xml file exists and is the following,
<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="58dce6e3-0444-4122-8aa6-08e35345e03e" FeatureId="58dce6e3-0444-4122-8aa6-08e35345e03e" ImageUrl="" ReceiverAssembly="$SharePoint.Project.AssemblyFullName$" ReceiverClass="$SharePoint.Type.bde159bf-eac9-44cd-a06a-df7bfb0e912e.FullName$" Scope="Site" SolutionId="00000000-0000-0000-0000-000000000000" Title="AltirisOpsListFeature" Version="" DeploymentPath="$SharePoint.Project.FileNameWithoutExtension$_$SharePoint.Feature.FileNameWithoutExtension$" Xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/FeatureModel" />
I appreciate any assistance.
|
The namespace of your Feature element is wrong. It should be:
xmlns="http://schemas.microsoft.com/sharepoint/"
And the next problem you're going to run into if this is how the file looks in SharePointRoot is that a lot of the attributes has tokens that isn't replaced by the real values.
It seems as if the project has been created using the tool from hell (VseWss for VS 2008) and hasn't been upgraded properly see lab for upgrading here
| 1 |
The namespace of Feature element is wrong.
|
Modifying a calculated column gives different errors
|
I have site column with the following formula:
[AmountLeftToPay]/([AmountAssigned]-[AmountReleased])
The problem is the division by zero, sometimes it shows on list items #DIV/0!
So I wanted to do the following:
=IF([AmountAssigned]-[AmountReleased]=0; 0; [AmountLeftToPay]/([AmountAssigned]-[AmountReleased]))
And it shows me the same error in all lists where its used.
is not supported.
/apps/xx/xx/Lists/Budgets : The formula contains a syntax error or is not
supported.
If I change ; with commas,
The formula contains a syntax error or is not supported.
so I got no clue
|
SharePoint uses Excel formulas (and same engine to parse them) for calculated fields. And as you probably know, Excel uses localized formulas.
Thus, when trying to define formulas through GUI and having non-english site, you should use the localized version of function names and ";" instead of commas. This definitely brings some confusion, because this fact is not even mentioned in documentation I know.
But from code or from powershell it is sometimes possible to put english formulas there (your thread should be set to use English locale or something like this). Also, internally SharePoint stores those formulas in English format.
So to resolve your issue, just open Excel, create a sketch of your formula there using formula wizard, and then "migrate" it to SharePoint, passing correct field names instead of Excel cell addresses (please keep in mind that not all of the Excel functions will work in SharePoint, only limited subset of them is available).
Hopefully this explanation makes things a bit more clear for you.
| 0.888889 |
SharePoint uses localized formulas for calculated fields
|
Loshon hara to a therapist
|
Is saying things that would otherwise be considered loshon hara permitted in the context of mental health therapy?
I am not familiar with the details of therapeutic schools, but I understand that some are predicated on an idea of speaking "freely" and exhaustively about the topics of therapeutic interest. Are there opinions that allow all speech within these contexts, understanding that the goal is the improvement of health and possibly the preservation of life?
|
The Chofetz Chaim writes in a note to the fifth detail of permissible Lashon Hara in Hilchos Lashon Hara 10:14
אפשר דהוא הדין אם כוונתו בסיפורו להפיג את דאגתו מלבו - הוי כמכוון לתועלת על להבא, [ולפי זה מה שאמרו ז"ל, דאגה בלב איש ישיחנה לאחרים, קאי גם על ענין כזה]. אך שיזהר שלא יחסרו שאר הפרטים שבסעיף זה"
It is possible that the same [allowance] applies if his intent in retelling is to remove the worry from his heart, it is like intending for toeles for the future [and according to this, that which Chazal say "[when there is] worry in the heart of a man, speak it over to others" also applies to this concept]. However, be careful not to lack any of the other details from this section.
"This section" is the section of the 7 requirements of speaking Lashon Hara(*), and the Chofetz Chaim writes that helping one's self cope, while it constitutes valid toeles, still requires the rest of the preconditions for speaking Lashon Hara.
(*) 1 - Firsthand knowledge
2 - Be sure you are not jumping to conclusions
3 - Speak to the offender, if you think that may work
4- Don't exaggerate, or leave out important details
5 - to'eles
6 - Ensure that there is no other route that could cause the to'eles
7 - Ensure that your words will not cause more damage than is duly deserved
| 0.666667 |
The Chofetz Chaim writes in a note to the fifth detail of permissible Lashon Hara .
|
How to make a strong mug of instant Coffee?
|
I am not an avid coffee drinker.
Yesterday, I tried Bru Gold coffee brand. I mixed one teaspoon milk with 1 teaspoon coffee and added the remaining 200ml hot milk premixed with 2 teaspoons of sugar.
The result wasn't great. The coffee was NOT strong nor did it contain any froth.
I want strong, not bitter coffee.
How do I know how much coffee to add to how much milk?
Secondly, do I have to mix coffee in whole milk and then boil the whole thing like it is done for tea?
Does the amount of time I spend in mixing coffee with milk also have an effect on the outcome?
|
To make froth in coffee.. Take 1 teaspoon of instant coffee and sugar to taste.. add a teaspoon of boiling water to this. Mix them by whisking and beating.. you can see the mixture turn to froth.. now add 1 cup of hot milk to this.. Tasty frothy coffee is ready.. fir a strong coffee add little more coffee..
| 1 |
Add 1 teaspoon of instant coffee and sugar to froth.
|
The Acidity of the Hydrated Iron (III) Ion
|
Why is $\ce{Fe(OH_2)_6^{3+}}$ fairly acidic? This iron has six water molecules coordinated to it.
In other words, water itself is a very weak acid. But when water is coordinated to iron, it becomes more acidic. I can think of a few reasons; can you think of more? Also are my reasons valid?
1) Induction. The negative charge generated through loss of the hydrogen proton is stabilized by the coordinated water molecules. Plus the center of the square planar molecule is greatly positively charged (and therefore can handle the negative charge, despite the fact that iron itself is actually electropositive rather than electronegative - at least in iron's ground state).
2) Size of the ferric ion. The ferric ion is rather big (it is, after all, able to coordinate six water molecules, as opposed to only four for some other metal ions). So whatever positive charge it has after being ionized once is spread out over a large surface area and that makes entire compound relatively stable.
3) Oxidation state of the central ferric ion - positive 3. This indicates a high degree of ionic character in the coordination bonds. Withdrawal of electron density from the water molecules makes the hydrogens even more positively charged and thus even more electrophilic.
4) Positive charge density of the central ferric atom. Coulomb's law is in (significant) effect here. Positive and positive. Like charges repel. Kicking off a hydrogen proton - no problem.
|
When a water molecule coordinates to $\ce{Fe^3+}$, one non-bonded $sp^3$ hybrid orbital (with one of the 2 lone pairs) of oxygen overlaps with an empty $d$ or $p$ orbital of $\ce{Fe^3+}$. Electron density is transferred from oxygen to iron, and due to the electronegativity of oxygen, the polarization of the $\ce{O-H}$ bond in the water ligand is increased (more electron density is "pulled" from $\ce{H}$ towards $\ce{O}$). The hydrogens are more positively polarized than in a free (uncoordinated) water molecule, and this increases their electrophilic character and acidity to the point that they are readily abstracted by solvent (non-coordinated) $\ce{H2O}$ in aqueous solution:
$$\ce{Fe(H2O)6^3+ + H2O \rightleftharpoons Fe(H2O)5(OH)^2+ + H3O+}$$
$$\ce{Fe(H2O)5(OH)^2+ + H2O \rightleftharpoons Fe(H2O)4(OH)2^+ + H3O+}$$
Further deprotonation results in the neutral complex $\ce{Fe(H2O)3(OH)3}$, from which $\ce{Fe(OH)3}$ precipitates.
The aqueous solution of $\ce{Fe^3+}$ aquo complexes is fairly acidic, wth a pH of up to 1.5 depending on iron concentration. The first dissociation equilibrium lies mainly on the product side, which can also be seen in the color of the solution: Pure $\ce{Fe(H2O)6^3+}$ is pale violet and found in crystals of some hydrated $\ce{Fe(III)}$ salts, while aqueous solutions get their orange color from $\ce{Fe(H2O)5(OH)^2+}$.
You have mentioned ion charge (oxidation state) and charge density (which is proportional to ion size) of the metal center as potential factors of influence. One can expect that with increased charge and/or charge density, the polarization of the water ligands also increases, and thus the aquo complex should be more acidic. This is true for many aquo complexes; however, there are also some deviations from this rule, like $\ce{Cr(H2O)6^2+}$ and $\ce{V(H2O)6^2+}$ (reference).
| 0.888889 |
polarization of hydrogens in water molecule increases electrophilic character and acidity .
|
Why is my MacBook Pro's screen going black for a second?
|
I have a new MacBook Pro, when I'm using it the screen goes suddenly blank for a second and comes back, it feels like as if someone unplugged my screen and plugged it back immediately.. why does this happen?
Initially I thought it was only happening when I'm running on battery, but happens even when I'm connected too.
This is very sporadic.
|
I hope I figured it out. I have no more Black screen issue & flickering since I did below yesterday:
Found advise from a user and Killed process called "warmd", process user: unknown.
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/warmd.8.html
When my Screen went black sporadically, My ipad was connected and nearby my MacBook , I relocated it further away (I read about interference issues)
I right clicked on battery icon and it showed me that Battery needs Service. I fully re-charged and re-booted my Pro and WoohLah, Battery status was back to normal....
I switched GPU >> Installed programm called GFXcardstatus (you can Google that)
In Applications->Utilities->Terminal
enter: sudo pmset -a lidwake 0 to reverse replace 0 with 1
enter your computer password...
This sends your laptop to sleep on closing but on opening tap any key to wake. According to advise by other user on the net this has stopped his issue with black screen and lastly I performed it after step 1-4.
Not sure what caused it tho but fiddeling around with above sorted my issue.
I posted this comment in the apple discussions forum.
I hope that helps.
Good luck to all of you!
| 1 |
Black screen issue & flickering
|
'Trying to help someone, but the other party doesn't appreciate it'
|
What is a word that best describes trying to help someone, but the other party doesn't appreciate it?
I'm looking for a word.
|
unrequited
(of a feeling, especially love) not returned: Scion shared his wishes to learn more of the world first-hand to Kara unrequitedly.
Though more commonly used in the context of, and paired with, love, the basic definition applies to any feeling or action, or even an object perhaps.
Braden, Abraham Lincoln, Public Speaker, p.94
Yet, if God wills that it continue, until all the wealth piled by the bondsman's two hundred and fifty years of unrequited toil shall be sunk, and until every drop of blood drawn with the lash, shall be paid by another drawn with the sword, …
Shoup, Public Finance, p.145
Types of unrequitted payment: Payments not made for a consideration are unrequited payments. When paid by the government to the private sector, they are subsidies or welfare payments.
| 1 |
Unrequited (of a feeling, especially love) not returned
|
Parsing Ids from a string to create detail objects
|
I am building a Flow that takes a user through a wizard to create a custom contract object with detail objects that represent the products on that contract (stored as a junction object). An issue I ran into is that Flow has a known limitation where if you use a Dynamic Choice (i.e. creating a dynamic set of checkboxes to choose Products from based on records from the Product object) it can only store the choices as a long semicolon delimited string in a variable; it cannot create detail objects based on your dynamic selection (even using a loop).
To get around this, I want the flow to just create the parent Contract, then I want an after insert Apex trigger to parse the field where the long string of semicolon separated Product Ids are stored. The trigger would need to take the string and find each Id to store in a List. Once I had the List made from the text field I could insert the Product detail records to the parent Contract.
I am very new to Apex, mostly just a point and click admin here. I am struggling with how to use RIGHT and LEFT to loop through the string field.
trigger AddProductstoSOW on PS_Contract__c (after insert) {
for(PS_Contract__c c:Trigger.new){
List<Id> ProductsToInsert = new List<Id>;
integer n = LEN(c.Initial_Services_Products__c);
for(p=15,p<n,p+17){
//How to iterate through Initial_Products_Selected__c?
thisId = LEFT(p);
Id product = Id.valueOf(thisId);
ProductsToInsert.add(product);
}
}
insert ProductsToInsert;
}
Any help is very appreciated.
|
Thank you for the assistance. I was able to resolve the issue. Though with .split() you also seem to need an upper limit parameter. Took a little struggling to figure this out but here it is:
trigger AddProductstoSOW on PS_Contract__c (after insert) {
try{
for(PS_Contract__c c : Trigger.new){
List<String> strProductIds = c.Initial_Services_Selected__c.split('; ', 1000);
System.debug(strProductIds);
List<SOW_Task__c> tasks = new List<SOW_Task__c>();
for(String i : strProductIds){
SOW_Task__c s = new SOW_Task__c();
s.PS_ServiceNo__c = i;
s.PS_Contract__c = c.Id;
tasks.add(s);
}
insert tasks;
}
}
catch(DmlException e) {
System.debug('An unexpected error has occurred: ' + e.getMessage());
}
}
| 0.888889 |
AddProductstoSOW on PS_Contract_c
|
Disk became full, had to force shutdown, now it doesn't boot
|
Don't know why I didn't get a warning about disk being almost full... It came down to zero free space and I couldn't do anything except force-shutdown it. I booted into Windows, deleted some files from OSX drive, but now on boot there is a progress bar every time and when it reaches the end (in 15 min), the computer shuts down.
I went into the recovery mode and tried to repair the disk, but it says "The Disk Utility cannot repair the drive... backup files and reinstall the OS" -- something like that.
I have a time machine backup but I'm currently not at home - going home in 3 weeks.
Is it "normal" that system gets borked like this because of full disk + force shutdown? Seems too fragile to me. I have Mavericks 10.9.4 on this system.
Is there anything I can do?
|
The problem is that the system goes into a fail-safe mode when the directory structure cannot be presumed to be safe for a new write.
You did the correct triage step by booting into recovery mode and attempting to repair the volume with Disk Utility.
At this point, you should back up any files you need. Test that your backup is complete and run Disk Utility against it to make sure it's in a good state.
Then you can boot to recovery and erase the volume or perhaps use another tool to repair the volume. If the drive erases and takes a format - the problem was a directory (data) corruption and not a hardware issue. If the disk can't be erased, then you need to repair the machine before restoring your backup onto a clean install of the OS.
In your case, you could possibly back up the changed files since 3 weeks or just get a new external drive and use Disk Utility to clone the volume or terminal to copy what you can using rsync or another tool.
| 1 |
Disk Utility is a fail-safe mode when the directory structure cannot be presumed safe for a new write
|
Does store-bought Kombucha spoil? If so, how can I tell?
|
I recently bought Ginger Kombucha for the first time in a reputable health food store. I'd never heard of it, but my doctor feels the probiotics will help my chronic digestive problem. Because of the strong taste, I only drank a small amount each day. I did this by pouring some out, not by drinking from the bottle. On the fifth day, it smelled and tasted so much like alcohol I was afraid it was rancid. I took it back to the store for advice. One clerk told me it was supposed to smell like that, just to use it for seven days and discard any remainder. Another clerk said it can't spoil, and as long as I keep it refrigerated it will last indefinitely. Can someone with experience please help me? It's expensive, so I don't want to throw it away if I don't have to, however I don't want to poison myself or use something that's no longer effective. Thank you!
|
If you're talking about raw kombucha (rather than pasteurized) then the answer is yes, inevitably, in the sense that it loses its desired probiotic properties. The kombucha will start to grow its own culture (though small), more commonly referred to as a mother or a scoby, which forms at the top of the bottle (container) and in time will take on both the look and feel of a jellyfish (tendrils hanging down). At this stage it can be harmful to consume, especially if discolored. Gauging however when it is that your purchase has crossed over from being beneficial to not beneficial, (meaning not good for you but not bad for you either), would probably require lab equipment and a working knowledge of microbiology. Refrigeration greatly slows down the culturation process but does not bring it to a halt.
| 1 |
Raw kombucha loses its desired probiotic properties
|
Is there an app similar to Pandora for movies/television?
|
I enjoy how Pandora can recommend new titles based off songs I already like. Is there a similar app that can take a few movies/shows I like and give me suggestions for similar ones?
EDIT: Showing the vids would be nice but what I'm really looking for is suggestions for other good flicks to watch, just the similar-theme aspect.
|
Fancast http://Fancast.com is probably the best option for what you are looking for. Although that's not saying much. Here are a few other options as well:
Jinni: http://www.jinni.com/ was recommended by phwd as well.
Get Glue (as recommended by tsodermann below) does something similar to what you are looking for as well: http://getglue.com
Hulu: http://Hulu.com also offers recommendations after videos are complete.
youTube: As mention by phwd, http://www.youtube.com/disco is a good option if you are looking for more home grown options.
Netflix offers a suggestion feature based on things that you watch on their service. It takes into account movies and tv shows that you have watched online, as well as rented via their mail service.
You could sign up for a free account and take the preliminary survey if you really wanted to get a list of suggested videos/shows based on your likes/dislikes.
IMDB also has a chart of the top movies of all time, sortable by a number of different criteria, including, genre, decade, votes by their users, etc. View the list here: http://www.imdb.com/chart/top
If you are looking for "meme" type videos that you think you will enjoy, you could check out:
http://www.youshouldhaveseenthis.com/
http://www.todaysbigthing.com/
| 1 |
Fancast http://Fancast.com is probably the best option for what you are looking for.
|
Can't ping host in OpenVPN Site-to-Site VPN
|
My logs say that a connection has been established but I cant ping the host.
Here are my logs.
Firewall 1 Logs:
May 24 10:42:57 openvpn[9163]: /etc/rc.filter_configure tun0 1500 1544 10.0.8.1 10.0.8.2 init
May 24 10:42:57 openvpn[9163]: SIGTERM[hard,] received, process exiting
May 24 10:42:59 openvpn[9742]: OpenVPN 2.0.6 i386-portbld-freebsd7.2 [SSL] [LZO] built on Dec 4 2009
May 24 10:42:59 openvpn[9742]: WARNING: file '/var/etc/openvpn_server0.key' is group or others accessible
May 24 10:42:59 openvpn[9742]: gw 112.202.0.1
May 24 10:42:59 openvpn[9742]: TUN/TAP device /dev/tun0 opened
May 24 10:42:59 openvpn[9742]: /sbin/ifconfig tun0 10.0.8.1 10.0.8.2 mtu 1500 netmask 255.255.255.255 up
May 24 10:42:59 openvpn[9742]: /etc/rc.filter_configure tun0 1500 1544 10.0.8.1 10.0.8.2 init
May 24 10:43:00 openvpn[9757]: Listening for incoming TCP connection on [undef]:1194
May 24 10:43:00 openvpn[9757]: TCPv4_SERVER link local (bound): [undef]:1194
May 24 10:43:00 openvpn[9757]: TCPv4_SERVER link remote: [undef]
May 24 10:43:00 openvpn[9757]: Initialization Sequence Completed
May 24 10:43:02 openvpn[9757]: Re-using SSL/TLS context
May 24 10:43:02 openvpn[9757]: LZO compression initialized
May 24 10:43:02 openvpn[9757]: TCP connection established with 119.93.150.4:47750
May 24 10:43:02 openvpn[9757]: TCPv4_SERVER link local: [undef]
May 24 10:43:02 openvpn[9757]: TCPv4_SERVER link remote: 119.93.150.4:47750
May 24 10:43:06 openvpn[9757]: 119.93.150.4:47750 [client] Peer Connection Initiated with 119.93.150.4:47750
Firewall 2 Logs:
May 24 10:42:57 openvpn[7489]: Connection reset, restarting [0]
May 24 10:42:57 openvpn[7489]: SIGUSR1[soft,connection-reset] received, process restarting
May 24 10:43:02 openvpn[7489]: WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.
May 24 10:43:02 openvpn[7489]: Re-using SSL/TLS context
May 24 10:43:02 openvpn[7489]: LZO compression initialized
May 24 10:43:02 openvpn[7489]: Attempting to establish TCP connection with 112.202.103.45:1194
May 24 10:43:02 openvpn[7489]: TCP connection established with 112.202.103.45:1194
May 24 10:43:02 openvpn[7489]: TCPv4_CLIENT link local: [undef]
May 24 10:43:02 openvpn[7489]: TCPv4_CLIENT link remote: 112.202.103.45:1194
May 24 10:43:06 openvpn[7489]: [server] Peer Connection Initiated with 112.202.103.45:1194
May 24 10:43:08 openvpn[7489]: Options error: Unrecognized option or missing parameter(s) in [PUSH-OPTIONS]:1: 112.202.103.45 (2.0.6)
May 24 10:43:08 openvpn[7489]: Preserving previous TUN/TAP instance: tun0
May 24 10:43:08 openvpn[7489]: Initialization Sequence Completed
What could the problem be?
|
Aside from the push, which probably isn't enough to break the connection, the logs look normal. You're likely missing a route, or have the route wrong, on one or both ends.
| 1 |
You're likely missing a route, or have the route wrong on both ends
|
Can you send data usefully over one wire, literally one wire?
|
It is possible to design networking systems that only use two wires: one for data and one for a common ground. Examples include 1-wire and Pin&Play. These are called single wire systems because the requirement for an earth wire is implied too. But you can also get systems to extend home networks that use the home earth to connect network points, like Power Line Communication. How is this possible over just one wire?
== EDIT ==
From the answers (thanks!) I think I failed to word this question clearly. Let me try again.
Can you send data usefully over one wire, literally one wire? Radio is zero, 1-wire is two, but is it possible with one? "No, and here's why" or "Yes, here's how it is done in X" are the kind of answers I am hoping for.
(N.B. I'll also change the question title from "Single wire systems need two wires; so how does ethernet over ground work?" to "Can you send data usefully over one wire, literally one wire?")
|
Over a very limited range - yes. You will need to have a return path that is supported by electric fields. The best way to look at this would be like a AC coupled circuit - coupled through a capacitor of which the capacitor is formed by some plate that the circuit is coupled to and another plate that is providing a return path.
We know that electric fields can couple over long-ish distances, some Anti-aircraft proximity fuzes from WWII used an e-field detection technique that would trigger the bomb because the shell and the aircraft would be carrying different levels of charge and thus e-field lines would form linking the two and thus change the capacitance in an internal circuit.
This in no way violates physics, it's best to view it as a capacitor that is so physically large that you can walk between the plates. However, the actual capacitance value would be very small.
uChip just released some technology that uses a similar effect that is called GestIC and they couple with E-Fields. Here they couple on both the top rail and the return path so it is a "Zero" wire solution. But it will also work if you ground one of the plates inside the remote device to one polarity of the plate in the "pad".
| 0.888889 |
The best way to look at electric fields is to have a return path supported by electric fields
|
Simple static integer stack
|
This question is about improving my C++ coding skills. I was asked to implement a simple static integer stack in C++ as an assignment. I've come up with the following code:
class myStaticIntStack
{
int stackSize;
int storedElements;
int *elements;
public:
myStaticIntStack();
myStaticIntStack( int aNumber );
~myStaticIntStack();
int peek();
int pop();
void push( int element );
};
myStaticIntStack::myStaticIntStack()
{
this->stackSize = 1;
this->elements = new int(0);
this->storedElements = 0;
}
myStaticIntStack::myStaticIntStack( int stackSize )
{
this->stackSize = stackSize;
this->elements = new int[ stackSize ];
this->storedElements = 0;
}
myStaticIntStack::~myStaticIntStack()
{
if( this->elements != NULL )
{
if( stackSize > 1 )
delete[] this->elements;
else
delete this->elements;
}
}
void myStaticIntStack::push( int newElement )
{
if( this->storedElements == this->stackSize )
cout << "Stack is full, you must POP an element before PUSHing a new one!" << endl;
else
{
this->elements[ (this->stackSize - 1) - this->storedElements ] = newElement;
this->storedElements++;
}
}
int myStaticIntStack::pop()
{
if( this->storedElements == 0 )
{
cout << "Stack is empty, you must PUSH an element before POPping one!" << endl;
return -1;
}
else
{
storedElements--;
return this->elements[ (this->stackSize - 1) - this->storedElements ];
}
}
int myStaticIntStack::peek()
{
if( this->storedElements == 0 )
{
cout << "Stack is empty, you must PUSH an element before PEEKing one!" << endl;
return -1;
}
else
{
return this->elements[ this->stackSize - this->storedElements ];
}
}
int main()
{
myStaticIntStack aStack(3);
cout << "Popped Element: " << aStack.pop() << endl;
aStack.push(1);
cout << "Stack Top is: " << aStack.peek() << endl;
aStack.push(2);
cout << "Stack Top is: " << aStack.peek() << endl;
aStack.push(3);
cout << "Stack Top is: " << aStack.peek() << endl;
aStack.push(4);
cout << "Stack Top is: " << aStack.peek() << endl;
cout << "Popped Element: " << aStack.pop() << endl;
cout << "Stack Top is: " << aStack.peek() << endl;
cout << "Popped Element: " << aStack.pop() << endl;
cout << "Stack Top is: " << aStack.peek() << endl;
cout << "Popped Element: " << aStack.pop() << endl;
cout << "Stack Top is: " << aStack.peek() << endl;
return 0;
}
The code is compiling and running correctly, this is standard output:
Stack is empty, you must PUSH an element before POPping one!
Popped Element: -1
Stack Top is: 1
Stack Top is: 2
Stack Top is: 3
Stack is full, you must POP an element before PUSHing a new one!
Stack Top is: 3
Popped Element: 3
Stack Top is: 2
Popped Element: 2
Stack Top is: 1
Popped Element: 1
Stack is empty, you must PUSH an element before PEEKing one!
Stack Top is: -1
However I was given a B due to the following reasons:
There was a better way of implementing it.
I didn't manage well the case in which I'm trying to POP an element from an empty stack, since it's confusing that pop() returns a value even if Stack is empty.
Can you please help me understand how I could improve my code?
|
If you have to implement a stack backwards, ok. :) It's a common thought pattern; i used to do it all the time too. But the truth is, it makes a lot of things easier if you consider the stack to grow upward.
void myStaticIntStack::push( int newElement )
{
if( storedElements == stackSize ) {
cout << "Stack is full, you must POP an element before PUSHing a new one!" << endl;
}
else {
// note the lack of index math :P
elements[ storedElements ] = newElement;
storedElements++;
// you could even do this all in one line like:
// elements[storedElements++] = newElement;
// but i assume you're just learning c++, so. :)
}
}
int myStaticIntStack::pop()
{
if( storedElements == 0 )
{
// For future reference, you should be throwing exceptions here, rather than
// returning an int. You're forgiven this time, cause you're new. :)
// But what if i wanted to store -1 in this thing? I can't reliably do that,
// now that you've used -1 as an error code.
cout << "Stack is empty, you must PUSH an element before POPping one!" << endl;
return -1;
}
else
{
storedElements--;
// again, note the indexing is much simpler
return elements[storedElements];
// You could likewise make this a one-liner...
// return elements[--storedElements];
}
}
| 0.888889 |
void myStaticIntStack::pop
|
Why is the pixel count of RAW images from the Panasonic LX5 slightly larger than the generated JPEGs?
|
I'm new to working with RAW images, and I'm capturing simultaneous RAW+JPGs with my new Lumix LX5, and using Bibble to view/process the results.
I'm very surprised that the RAW images taken at 24mm wide 16x9 seem to capture a different (and larger) sensor area compared to the JPGs. The RAW images seem to contain the equivalent of about 100 extra pixels on left and right sides, and a smaller number top and bottom. I say "equivalent", because the actual pixel counts of RAW and JPG are only slightly different, which implies some resizing must be going on...?
JPG: 3968 x 2232
RAW: 3976 x 2238
I guess this small difference is because JPG images must be 16x16 multiples>
The raw image displays noticeable vignetting in the extra pixels, and there's a fair bit of chromatic aberration. I can crop off the 'extra' pixels, but then my RAW image has fewer pixels in it than the JPG, which doesn't feel right.
I'll try and add samples shortly.
|
Firstly there are a couple of general reasons raw and JPEG images differ in size, and raw differs from the actual number of pixels on the sensor:
Whilst JPEG image dimensions don't have to be multiples of 16 (or 8 if not using chroma subsampling) it is more efficient to do so, as it allows you to rotate the images without re-encoding (lossless rotation). So that can account for a small image size difference, as you say.
Even raw image sizes typically differ from the actual number of pixels as most sensors have strips masked pixels (that receive no light) down each side in order to detect banding issues with uneven amplification. Further, the size you see in your raw viewer will differ from the actual raw data as some image processing operations use a form of averaging which doesn't work at extreme edges (because there's no data beyond the image to use when averaging) so they get cropped off when the image is viewed/converted.
Secondly the Panasonic Lumix LX3 and LX5 have a different sensor design to most cameras, which is partially responsible for the difference in coverage between raw and jpeg you are experiencing:
The maximum 16:9 image size is actually wider than the maximum 4:3 image size. You would expect them to be the same width but different heights.
This is because they've made the sensor a bit wider for 16:9, employing a non rectangular design and it's pushing the very edges of the lens image circle, this explains the vignetting and CA you observe with the raw. This diagram shows the irregular design:
As John Cavan suggests, the JPEG image pipeline is doing some correction, including barrel distortion correction, given that 24mm equiv. is very wide for a compact, and the sensor is pushing to the very edge of the image circle.
Barrel distortion correction makes straight lines straight again, but will cause the image edges to bend in response. In response to this the correcting transformation enlarges the image slightly and crops to get straight edges again.
Can you see any differences in the appearance of straight lines between the raw and JPEG? It might be quite subtle but get revealed if you overlay them.
| 1 |
Raw and JPEG images differ in size, and how to rotate images without re-encoding
|
Get list of all files by mask in terminal
|
I want to find all *.h,*.cpp files in folders with defined mask, like */trunk/src*. So, I can find separately *.h and *.cpp files:
find . -path "*/trunk/src/*.h"
find . -path "*/trunk/src/*.cpp"
What is the best way to get the file-list both of types (*.h and *.cpp)?
PS I'd like to pipe the list to grep.
|
In bash, turn on the globstar option so that ** matches any level of subdirectories. You can do this from your ~/.bashrc. Also turn on the extglob options to activate ksh extended patterns.
shopt -s globstar extglob
Then:
grep PATTERN **/trunk/src/**/*.@(h|cpp)
Beware that bash versions up to 4.2 follow symlinks to directories when you use **.
Zsh makes this easier, you don't need to set any options and can just type
grep PATTERN **/trunk/src/**/*.(h|cpp)
If the command line is too long, and you're on Linux or other platform with GNU grep, you can make grep recurse instead of the shell to save on the command line length.
grep -R --include='*.cpp' --include='*.h' PATTERN **/trunk/src
| 0.777778 |
In bash, turn on the globstar option so that ** matches any level of subdirectories
|
RenderTarget2D behavior in XNA
|
I've been dabbling with XNA for a couple of days now. This chunk of code doesn't work as I expect. The goal is to render sprites individually and composite them on another rendertarget.
P = RenderTarget2D(with RenderTargetUsage.PreserveContents)
D = RenderTarget2D(with RenderTargetUsage.DiscardContents)
for all sprites:
{
graphicsDevice.SetRenderTarget(D);
<draw sprite i>
graphicsDevice.SetRenderTarget(P);
<Draw D>
}
graphicsDevice.SetRenderTarget(null);
<Draw P>
The result I get is - only the last sprite is visible. I'm sure I'm missing some piece of information about RenderTarget2D. Any hints on what that might be?
|
Change this:
for all sprites:
{
graphicsDevice.SetRenderTarget(D);
<draw sprite i>
graphicsDevice.SetRenderTarget(P);
<Draw D>
}
to this:
for all sprites:
{
graphicsDevice.SetRenderTarget(D);
<draw sprite i>
}
graphicsDevice.SetRenderTarget(P);
<Draw D>
The problem is that D or P are being cleared somewhere (probably when they get set as a render target), so the only sprite that "survives" is the last one.
Since you have all your sprites rendered to D you only need to render D onto P once.
| 0.888889 |
D or P are being cleared somewhere (probably when they get set as a render target)
|
Amazon Ec2: Problem In Setting up FTP Server
|
after setting up My vsFtp Server ON Ec2 i am facing problem , my client is Filezilla
and i am getting this error
Response: 230 Login successful.
Command: OPTS UTF8 ON
Response: 200 Always in UTF8 mode.
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/"
Command: TYPE I
Response: 200 Switching to Binary mode.
Command: PASV
Response: 500 OOPS: invalid pasv_address
Command: PORT 10,130,8,44,240,50
Response: 500 OOPS: priv_sock_get_cmd
Error: Failed to retrieve directory listing
Error: Connection closed by server
this is the current setting in my vsftpd.conf
#nopriv_user=ftpsecure
#async_abor_enable=YES
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
GNU nano 2.0.6 File: /etc/vsftpd/vsftpd.conf
# #ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
pasv_enable=YES
pasv_min_port=2345
pasv_max_port=2355
listen_port=1024
pasv_address=ec2-xxxxxxx.compute-1.amazonaws.com
pasv_promiscuous=YES
Note: i have already open those port in security group
i mean listen port, min max
if someone shows me how to fix this i will be very greatful
thanks
|
Either pasv_address needs to be the external IP address, or pasv_addr_resolve=YES needs to be set so that the hostname you entered will be resolved when vsftpd starts. If you use a hostname with pasv_addr_resolve, vsftpd has to be restarted if the IP address changes.
| 0.888889 |
vsftpd has to be restarted if the IP address changes .
|
How has sneaking changed from 3.5 to Pathfinder?
|
Was researching this in order to answer How can a Shadowdancer use spring attack with Hide in Plain Sight? I learned a fair amount about these changes and since they’re pretty significant, I wanted to write it down.
How have the rules regarding sneaking around changed from Dungeons and Dragons 3.5 to Pathfinder?
|
Skill Consolidation
Hide and Move Silently are now one skill, Stealth. A nice perk for rogues; a nicer perk for those who don’t have 8+Int skill points and still want to be sneaky. Also very nice that it’s only one roll: less chance of rolling very low and messing up your attempt to sneak. Or, if you do roll high, you don’t have to worry about having a mediocre roll on the other.
On the flip side, Spot and Listen have also been consolidated into one skill, Perception. This is still to your benefit when you’re sneaking, though, since it means those trying to find you only get to roll one check; there’s less chance of an abnormally high roll.
Changes to the effect of Hiding
In 3.5, the effect of hiding was left vague until Rules Compendium. Thankfully, Rules Compendium clarified some things, including the fact that those who fail their Spot check treat you the same way they treat invisible creatures, which means they are flat-footed with respect to you. This is important because that’s one of the conditions that qualifies for Sneak Attack.
In Pathfinder, not so much: a successful Stealth check gets you Concealment. In most cases, this is basically useless because you usually need Concealment to use Stealth in the first place. That is, Stealth is often literally giving you what you already had. You can use Stealth with Cover instead of Concealment, in which case you get both, but Cover is much more difficult to manufacture, which makes it much less reliable.
With Hide in Plain Sight, you can give yourself Concealment when you wouldn’t have had it. That’s nice, but the costs of getting Hide in Plain Sight are very high, and Concealment just isn’t that good. All Concealment does is give attackers a 20% chance to miss you. It does not improve your attack or damage in any way. Notably, Concealment is insufficient to trigger Sneak Attack.
Changes to triggering Sneak Attack
On the plus side, constructs, plants, and undead are no longer immune to Sneak Attack. Elementals and oozes still are, as are the new proteans, and things with the incorporeal subtype are immune unless you have Ghost Touch. The 3.5 rogue could overcome these limitations, but it was tricky (required particular wands or feats or ACFs, and often still only did half damage), so this is good.
The good news ends there. As stated, Stealth cannot trigger Sneak Attack. Nor can grease in most cases (and the rules are ambiguous about the cases where it would work), and the blink spell is right-out. Alchemical weapons no longer work either, which is a shame for low-level rogues. Marbles no longer exist. That means a lot of the ways for a solo rogue to generate the conditions required to get Sneak Attack are gone.
As such, you are either going to have to ignore the “Sneak” aspect of Sneak Attack entirely (and just use Flanking to trigger it), or you’re going to need magic, preferably greater invisibility. Rogues get Use Magic Device, but that’s an expensive wand.
| 0.777778 |
Stealth is one of the conditions that qualifies for Sneak Attack
|
Does the function which sends a right angled triangle to its area produce infinitely many numbers having hardly any prime factors?
|
Let $T$ be the set of pythagorean triples, that is, triples of integers (a,b,c) satisfying a2 + b2 = c2. We think of $T$ as the set of right angles triangles with integer lengths. And let $f : T \rightarrow \mathbb{Z}$ be the function $(a,b,c) \mapsto \frac{ab}{12}$ which computes the area of a triangle (divided by 6, which seems to always be a factor for some reason).
I was wondering: what are the number theoretic propertires of $f$? It seems to produce numbers with few prime factors. What is the reason for this? For instance, $f(3,4,5) = 1$, $f(36,77,85) = 3 * 11 * 7$, and $f(65,72,97)=39*5*2$. Can we put a bound on the number of prime factors in the numbers that $f$ spits out? Or at least, can we give a 'generic' statement such as 'The output of $f$ almost always spits out numbers with less than 8 factors' or something?
|
There are many right triangles whose area has as few prime factors as possible:
The Green-Tao paper "Linear equations in primes", and the subsequent work on their Mobius Nilsequences conjecture by GT and Gowers Inverse conjecture by GT-Ziegler, implies that $\frac{ab}{12}$ is infintely often a product of four primes, in a quantitative sense. Indeed, reparametrizing gives $ab=12xy(2x+3y)(2x-3y)$, and now we are asking for points in the lattice $(1,0,2,2)\mathbb{Z}+(0,1,3,-3)\mathbb{Z}$ all of whose coordinates are prime. This system has finite complexity and thus the main results of "Linear equations in primes" applies unconditionally, that is to say the number of pairs $(x,y)$ with $0 < |x| , |y| < T$ and $xy(2x+3y)(2x-3y)$ a product of four primes is asymptotically $cT^2 (\log{T})^{-4}$ for some constant $c$.
This deduction can be found, for example, in Sarnak's notes "Equidistribution and primes".
| 0.777778 |
"Linear equations in primes" is infintely often a product of four primes .
|
Ribbon javascript function reference
|
I was wondering whether there is somekind of reference available with the javascript methods called for each of the buttons in the ribbon. Question behind the question: I want to make a button on a wiki page which says "edit me", without the user having to go to the same button in the ribbon. Functionality should be exactly the same, but I need it on a different place. So what is the easiest way to find out which code the ootb "edit" button calls?
|
All you need to to is to pass some query strings to the aspx page without any JS call. As like in wiki this goes like this.
<a href="/demo/wiki/Seiten/home.aspx?ControlMode=Edit&DisplayMode=Design">Edit this page</a>
This works for every page and not only for wiki page. The valid control mode values can be found on the MSDN as the values for the display mode.
| 1 |
How to pass query strings to aspx page without any JS call?
|
Is it possible to have a convergent subsequence of a divergent sequence?
|
Is it possible to have a convergent subsequence of a divergent sequence? Thanks!
|
Sure. Consider $0, 1, 0, 1, 0, 1, \dots$
Furthermore, the Bolzano-Weierstrass Theorem says that every bounded sequence has a convergent subsequence.
| 0.777778 |
Bolzano-Weierstrass Theorem: Every bounded sequence has a convergent subse
|
What is the English name for Chitra Rajmah?
|
What is this variety of kidney beans called in English? We call them "Chitra Rajmah" in Hindi.
http://www.helloorganic.com/Rajma_chitra.html
|
Pinto beans. Throw in a few more foods in Hindi, and I'll translate them too, while I'm here; I've got good reference books handy with names in both English and Hindi.
| 1 |
Pinto beans in English and Hindi
|
How do you output the filename in find command while using -exec?
|
I use the following line to find all sub-directories of the PWD and run svnadmin verify on each directory (I already know that they're Subversion repositories)
find ./* -maxdepth 0 -exec svnadmin verify {} \;
This works well, other than the fact that the output looks like this:
* Verifying repository metadata ...
* Verifying metadata at revision 1 ...
* Verifying metadata at revision 2 ...
* Verifying metadata at revision 4 ...
* Verifying metadata at revision 5 ...
* Verifying metadata at revision 6 ...
* Verifying metadata at revision 9 ...
* Verifying metadata at revision 10 ...
* Verifying metadata at revision 12 ...
* Verifying metadata at revision 14 ...
* Verifying metadata at revision 15 ...
* Verifying metadata at revision 18 ...
* Verifying metadata at revision 20 ...
* Verifying metadata at revision 22 ...
* Verified revision 0.
* Verified revision 1.
* Verified revision 2.
* Verified revision 3.
* Verified revision 4.
* Verified revision 5.
* Verified revision 6.
* Verified revision 7.
* Verified revision 8.
* Verified revision 9.
* Verified revision 10.
* Verified revision 11.
* Verified revision 12.
* Verified revision 13.
* Verified revision 14.
* Verified revision 15.
* Verified revision 16.
* Verified revision 17.
* Verified revision 18.
* Verified revision 19.
* Verified revision 20.
* Verified revision 21.
* Verified revision 22.
* Verified revision 23.
* Verified revision 0.
* Verifying repository metadata ...
* Verifying metadata at revision 4 ...
* Verifying metadata at revision 5 ...
* Verifying metadata at revision 6 ...
* Verifying metadata at revision 7 ...
* Verifying metadata at revision 9 ...
* Verified revision 0.
* Verified revision 1.
* Verified revision 2.
* Verified revision 3.
* Verified revision 4.
* Verified revision 5.
* Verified revision 6.
* Verified revision 7.
* Verified revision 8.
* Verified revision 9.
I'd really like find to print the filename before executing the svnadmin verify command, to make logging easier.
I've tried to squeeze a little ls in there but bodged it up, how should I do this (preferably simply)?
|
find ./* -maxdepth 0 -type d -exec bash -c 'echo "{}"; svnadmin verify "{}"' \;
I have added -type d if it is only directories.
| 0.888889 |
find -type d if it is only directories
|
Replicate a big, dense Windows volume over a WAN -- too big for DFS-R
|
I've got a server with a LOT of small files -- many millions files, and over 1.5 TB of data. I need a decent backup strategy.
Any filesystem-based backup takes too long -- just enumerating which files need to be copied takes a day.
Acronis can do a disk image in 24 hours, but fails when it tries to do a differential backup the next day.
DFS-R won't replicate a volume with this many files.
I'm starting to look at Double Take, which seems to be able to do continuous replication. Are there other solutions that can do continuous replication at a block or sector level -- not file-by-file over a WAN?
Some details:
The files are split up into about 75,000 directories.
99% of the daily change comes from adding new directories; existing files are rarely changed.
There's some other relevant discussion here.
|
I've had great luck with Doubletake, despite the price. Their "move" product might fit the budget though...
See my answer to a similar question here.
| 0.777778 |
Doubletake's "move" product might fit the budget
|
Refused visit a friend visa for Belgium
|
I applied for a visa to visit a friend in Belgium last April 28, 2014 and I got the result recently (June 6, 2014) wherein it has been refused.
Reasons were:
The plan and the circumstances from the intend stay are insufficient.
Resolve to leave country before end of visa couldn't be determined.
No med-travel insurance.
I'm a Filipino citizen and applied from Manila. My boyfriend is sponsoring me. We were confident that I should be able to get the visa, because we both know that we have completed and submitted all the requirements that are needed for the visa. I wanted to appeal the refusal of my visa.
What are my options? I haven't yet received the official result of my refusal and will be going to the Belgium Embassy in Manila as per the schedule they have given me.
What sort of letter can I do to assist my situation?
|
It's common for embassies to get nervous when your reason is to visit family / spouse / significant other, as sometimes this is what overstayers do - find a way in, and then just don't leave. Therefore, your job is to assure them that:
You're not overstaying
You're just visiting your significant other
You have money to cover your time there
You have a return ticket booked
You have valid medical insurance to cover your time there, so that you won't be a medical problem for their country
To prove you're not trying to overstay and are just visiting, you simply print out your plane tickets showing your return. If you have evidence that you're working or studying at home, a letter from your employer showing you're returning to work at a given date will help, or your uni showing the upcoming courses you're involved in.
You'll also need to print bank statements showing your current balance to show you've considered how to cover your time there. If you've only got say, $200 and are planning to stay at the best hotels when asked, it'll raise flags. They're just making sure you don't get into financial difficulty while there.
Also make sure you get medical insurance, or show intent to get it (reserved funds) and print that out, showing that you're covered for the duration of the trip.
Finally if you have an itinerary (are travelling while there) write it out, so that you can clearly show what your intended journey is, how much it might cost, and so on. A budget may even help! (Not normally required, but at this point, more documentation is good to help convince them).
You said you were confident you'd completed all requirements, but the letter clearly indicates you're missing a few things, so hopefully with the above items covered your next application will go more smoothly, and you can enjoy a trip to Belgium!
| 0.777778 |
How do you cover your time in Belgium?
|
execute a batch file on remote machine
|
I'm trying to execute a batch file(shutdown.bat and startup.bat of tomcat 7) on a remote machine(Windows server 2008) using PSTools but didn't got any luck till now.
Below are the steps I used
c:\>psexec \\129.12.3.1 -u Admin -p admin90 C:\>Hyp\tom7_50080\bin\shutdown.bat
and on my cmd i got
PsExec v2.0 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com
PsExec could not start cmd on 129.12.3.1:
There are currently no logon servers available to service the logon request.
Can anyone help with the above output and with the batch file for executing the shutdown and startup batch file on remote machine.
Is PS Tools only option to execute any service/batch file on remote machine or we could use any other utility provided by MS.
|
If you want to execute a program on another server, you can use a stored procedure on that server to invoke the command, and call that stored procedure from the local mcahine.
You could also create a web service on the remote server that invoked the command you want to execute.
In either case, be very careful that you don't open a security hole by either allowing more users to execute commands through the mechanism you implement, or by some user to execute commands other than the one you intend.
| 0.833333 |
Use a stored procedure on a remote server to invoke the command
|
How do I create a great fantasy villain that inspires the party to rally against them?
|
In my early years of GMing it was simple enough to say that the badguys were evil and that was all the justification we needed. They are attacking the village because they are evil, they are stealing the princess because they are evil, etc.
Over time, my group needs have grown to need more complicated and detailed villains. It is important to consider motives. What is it that defines them as 'evil' to the party? In terms of a fantasy setting, what would you consider to be an interesting villain?
What qualities make a villain that inspires your party to rally against him? What kind of villains have worked for your games in the past?
Example:
A member of nobility is using trade connections to move valuable pieces of art into another country that is secretly paying him quite well and is framing a member of the party to take the fall. In addition, someone important to the party member has been taken hostage with a promise of release once they party member takes the blame for the crime.
|
The most memorable villians in my experience are the ones that defeat the PCs especially if it happens more than once. Nothing drives the passions of the players more than a familiar villian who has managed to outwit them. I was once had an entire campaign revolve around defeating a single recurring villian. The key was to allow the players to frequently win. Each time creating set backs for the villian and his minions but not fatally.
| 1 |
The most memorable villians in my experience are the ones that defeat PCs
|
Can I undo changes made via "defaults write"?
|
I've been messing with Bluetooth audio settings to try to keep my Bluetooth speakers from popping by changing settings via defaults write, but I'm afraid I've made the problem worse.
I'd like to revert to the default… defaults, bringing them back to where they were originally or, more specifically, where they would be for a new user account or new system. Is this as simple as using defaults delete on the appropriate domain and key?
|
Yes, usually you can just use defaults delete. If for example you have run defaults write -g NSScrollAnimationEnabled -bool false, you can undo the changes by running defaults delete -g NSScrollAnimationEnabled or defaults write -g NSScrollAnimationEnabled -bool true (and by reopening applications to apply the changes).
Even if the preference key had some value before you used defaults, it shouldn't matter if you delete the key. It is generally safe to delete preference keys or even complete files, and they can usually be recreated by OS X or applications.
The property lists modified by defaults are stored in directories like ~/Library/Preferences/, ~/Library/Containers/com.apple.mail/Data/Library/Preferences/, or ~/Library/Preferences/ByHost/. You can edit a plist in a text editor after converting it to XML with plutil -convert xml1.
| 1 |
Use defaults delete to delete defaults
|
How to implement Many to many relationship for USERS TABLE in ruby on rails without using any extra table?
|
I am a newbie to the Ruby on Rails but stuck at this interesting situation :
I have three Models with me :
User
Company
Project
I want to relate them in the following way :
Company has_many Users
Users belong_to Company
Implemented via company_id column in USERS table
User.Company or Company.Users works fine.
Project has_and_belongs_to_many Users
Users has_and_belongs_to_many Project
Implemented via has_and_belongs_to_many relation using in projetcs_users table
Project.Users or User.Projects works fine.
The real problem comes when I want them to join as following as well :
Company belong_to Owners (:through => User)
Owner has_one Company
---A company can have multiple owners but one user can own just one company. He can't be owner of multiple companies.
---A user may or may not be owner of a company but always belong to some company.
---A user cannot be part of two companies.
Project has_one Project_manager (:through => User)
Project_manager belongs_to Projects
---A Project can have just one Project_manager but one can be project manager of multiple projects.
I am not able to figure out how the relationship should be defined in the Models. Also what should be the table structure for all three models.
My objective is to achieve :
Company.Owners
It can be done by :
@owner = User.find(Company.owner_id)
Project.Project_manager
It can be done by :
@Project_manager = User.find(Project.project_manager_id)
But don't want it that way to work !!
Rest is working perfectly fine for me.
|
This should help you get on the right track:
class User
# the owner relation
#
# user.owned_company
# => company
#
has_one :owned_company, :class_name => "Company", :foreign_key => "owner_id"
# the project manager relation
#
# user.managed_projects
# => [project,...]
#
has_many :managed_projects, :class_name => "Project", :foreign_key => "project_manager_id"
end
class Company
# the owner relation
#
# company.owner
# => user
#
belongs_to :owner, :class_name => "User"
end
class Project
# the project manager relation
#
# company.project_manager
# => user
#
belongs_to :project_manager, :class_name => "User"
end
Rails ActiveRecord relations are very well documented. See the documentation http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
| 0.666667 |
ActiveRecord relations with Rails
|
How to use explicit template instantiation to reduce compilation time?
|
It was suggesting to use explicit template instantiation to reduce compilation time. I am wondering how to do it. For example
// a.h
template<typename T> class A {...};
template class A<int>; // explicit template instantiation to reduce compilation time
But in every translation unit that a.h is included, it seems A<int> will be compiled. The compilation time is not reduced. How to use the explicit template instantiation to reduce compilation time?
|
Declare the instantiation in the header:
extern template class A<int>;
and define it in one source file:
template class A<int>;
Now it will only be instantiated once, not in every translation unit, which might speed things up.
| 1 |
instantiation in header: extern template class A<int>
|
Sending Via PIC18F97J60 EUSART
|
When trying to send and receive using a PIC18F97J60 and MAX232 using a program written with the C18 compiler, I am only able to transmit data. For receiving, I have tried at least 50 methods but none are working. I even tried the software on multiple micro-controller boards to check for a hardware problem but none of the boards ever receive anything. I believe that the following items are correct:
My clock is perfect at 41.6667MHz
My baud generation is perfect
My hardware is OK (some other IIIrd party hex code able to receive also)
My host PC, its COM port, and the serial cable are OK
Can anyone guide with probable areas I may be missing?
------------------ FURTHER CLARIFICATIONS -------------------------------------------
Thanks Olin for helping, you are great man. Sorry for not putting my question correctly. Please note:
I was trying to do serial I/O to write a boot loader for the PIC18F97J60 myself as my vendor's supplied boot loader stops sending/receiving with PCloader software after a partial user application hex download. It also ensures that RS232 port is able to both send and receive. Moreover, Microchip's boot loader described in AN1310 also stucks on receiving data.
My sample application (a bootloader) is able to transmit but never receives anything. I'm in soup: either I need a new boot loader or my application must work. I have never faced such a problem in my 12 years of development and I am feeling like a fool.
Other details as you requested are as follows:
I had 10-12 PIC18F97J60 cards with MAX232 on C6/C7 for Serial I/O. The problem is the same for all boards (of different batches).
I wish to do 9600 baud, 8 bit, no parity, 1 stop, no handshake, no interrupt data exchange with RealTerm (Better Than Hyperterminal - Displays HEX Code).
My clock and baud rate calculations are perfect for 41.6667MHz. I have set OSCTUNE = 0x40 and BAUDCON = 1084. I am able to receive perfectly on the PC with RealTerm.
My program not able to receive anything on the PIC but able to transmit.
I tried polling as well as interrupt but nothing works.
Snippet of code is as follows:
void putchar(unsigned char Char)
{
//Wait for (TSR==1)
while(TXSTA1bits.TRMT!=1);
//Trasmit Current Data
TXREG1= Char;
//Wait for (TSR==1)
while(TXSTA1bits.TRMT!=1);
}
void putstr(unsigned char *String)
{
do
{
putchar((*String));
}while(*String++);
//CR
putchar(CR);
//LF
putchar(LF);
}
void main(void)
{
unsigned char RS232[] = "RS-232";
OSCTUNE = 0x40;
TXSTA1 = 0x24;
RCSTA1 = 0x90;
BAUDCON1=0x08;
SPBRGH1=0x04;
SPBRG1=0x3C;
while(1)
{
putstr(RS232);
Delay10KTCYx(200);
if(PIR1bits.RC1IF == 1)
{
MYChar = RCREG1; //*** No OERR & FERR present, RC1IF never gets set ***
}
}
}
|
One annoying misfeature of the UART on every PIC I've worked with is that a data overrun error will shut down the receiver until code disables and re-enables it. It is thus imperative to have code that will periodically check the overrun-error flag and, if it is set, disable and re-enable the UART receive function. Otherwise if the receive buffer overruns, you won't just lose a received byte--you'll lose all data forevermore.
I'm not really sure why Microchip designed their UARTs this way. My guess would be that in early PICs a receive overrun would cause the receive state machine to lose frame sync, and that disabling the receiver was considered preferable to receiving randomly-framed data (I might agree with them on that point, though I would consider dropping whole bytes while maintaining sync to be better still); later PICs maintained the behavior for compatibility, despite substantial redesigns of the UART subsystem.
In any case, the PIC's UART implementation is what it is. Check to ensure that the UART receiver is enabled and the receive-overflow isn't tripped. If not, disable the UART receive function and re-enable it. Note, btw, that on some PICs the master disable for the UART function will not disable the receiver; you need to clear and re-set the receiver enable.
| 0.888889 |
a data overrun error will shut down the receiver until code disables and re-enables it
|
Changing LED color for notifications
|
I am basically just experimenting with Android development, and a couple of days ago I came across this app called "Go SMS Pro", which, among other things, can set up notifications in different colors (blue, green, orange, pink and light blue). So, I have tried to do this myself in my own app, however I cannot change neiher the color nor the blinking internal of the LED. I currently use this code:
public class MainActivity extends Activity {
static final int NOTIFICATION_ID = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(buttonOnClick);
}
public OnClickListener buttonOnClick = new OnClickListener() {
@Override
public void onClick(View v) {
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
Notification notification = new Notification(R.drawable.icon, "Hello", System.currentTimeMillis());
notification.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL;
notification.ledARGB = Color.BLUE;
notification.ledOnMS = 1000;
notification.ledOffMS = 300;
Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(MainActivity.this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
};
}
But as I said, it doesn't work the way I want it to; instead it just blinks in regular green with the default delay, and not the one I have set in my code.
Can anyone see what is wrong with my code, or know if I have to do something else to achieve this?
|
Leds are a quite non-standard feature in android phones. If you depend in them, you will miss a good chunk of the user base (consider, for example, the SGS phones, which do not even have leds).
That said, id the int field ledARGB was not useful, you might need to look into some JNI call from that APK. My guess is that it will have different methods depending on the device in which is running.
| 0.666667 |
Leds are non-standard feature in android phones
|
Have to set multiple displays on every start
|
I have a HP DV7 with an ATI graphic card and I have a Samsung monitor connected to the laptop. Every time I turn on the laptop the displays are mirrored and I have to go to the Catalyst control centre (Administrative) and change the displays configuration, I have to do this EVERY TIME I turn on the computer.
I Didn’t try the solution suggested here ( Settings for multiple monitors are not stored ) because it took me a lot to make the graphics card work properly and I want to make sure that I have the right solution ( or the "rightest")
Thanks!
|
some times may be that graphic driver will behave like that, and nothing to worry about this problem. You have to reset or change to default settings of Graphic driver or Screen Settings provided by Ubuntu Operating system.
| 1 |
How to reset or change settings of Graphic driver
|
Auto Refresh Div Using jQuery from 5 Seconds to Zero
|
How to create a countdown counter in Drupal 7 that says:
Your download will start in 5 seconds...
During page load and it countdown the number to 5, 4, 3, 2, 1
And change the value to "our download will start shortly... "
When finished?
|
Look at THIS demo...That is all you need...
Also look at THIS and THIS...
To learn how to include script in Drupal look at THIS answer...
| 0.833333 |
How to include script in Drupal
|
ToolingAPI.cls for Apex: How to get CompilerErrors at ContainerAsyncRequest in v31+?
|
Im trying to patch ToolingAPI.cls in order to use it with API v32. I run it successfully for a couple of month now with v29/30, but due to changes to the API, I need to adapt some parts. Unfortunately the latest version available on github is for v30.
So far I got somthing which works partly, but:
looking at the tooling.wsdl for v32 at <xsd:complexType name="ContainerAsyncRequest"> it has lost the element <xsd:element name="CompilerErrors" minOccurs="0" type="xsd:string" nillable="true"/> which I've used to obtain the error details, e. g. when I save an ApexClass containing syntax error, this was the element I used to get the error.
Now, since it's gone, how an where can I get the compiler error message? It's not in <xsd:element name="ErrorMsg" minOccurs="0" type="xsd:string" nillable="true"/> - this one stays empty on syntax errors.
|
It has been replaced by DeployDetails
<xsd:element name="DeployDetails" minOccurs="0" type="tns:DeployDetails" nillable="true"/>
http://www.salesforce.com/us/developer/docs/api_tooling/Content/sforce_api_objects_deploydetails.htm
A complex type that contains detailed XML for any compile errors
reported in the asynchronous request defined by a
ContainerAsyncRequest object. Replaces the JSON field CompilerErrors
in Tooling API version 31.0 and later.
UPDATE
First I still wasn't able to retrieve this information, because I got an Illegal value for primitive error. I've asked another question in order to show my problem and finally is solved thanks to the help of @DanielBallinger here:
Patching ToolingAPI.cls for v31+: How to query for DeployDetails at ContainerAsyncRequest?
| 0.666667 |
How to query for DeployDetails at ContainerAsyncRequest
|
No sound in Ubuntu except at log in
|
I installed Ubuntu 12.04 a month ago and am using it till now. I failed to notice that all this time there was no sound at all while running Ubuntu, even while playing a game in Wine. The weird thing is that only the startup sound comes when I log in (Indian/African drum tone), then comes the utter silence.
I tested both Digital Output (S/PDIF) and the speakers in the sound settings but can hear nothing.
Any help?
|
I had no sound problem with Xubuntu 12.04 Beta on my HP laptop. After some googling I fixed it with setting HDMI Audio Profile to OFF in Application Menu - Multimedia - PulseAudio Volume Control - Configuration.
| 1 |
Xubuntu 12.04 Beta on my HP laptop
|
how to lock object face a certain distance away from another object face?
|
i tried searching for this on google but i came up empty. i want to know how to lock object 2 5 inches away from the corner of object 1? i want it to stay 5 inches away even if i re-scale.
can someone please help me? how do i lock cube 2 5 inches away from the edge of objects 1?
here is an image of what i want to do:
EDIT:
i want to offset "cube 2" 5 inches away from the bottom right vertex of "cube 1" no matter where "cube 1" is?
so if i move or scale "cube 1", "cube 2" would still be offset 5 inches from the bottom right vertex of "cube 1"
|
Set object2 origin point to its right bottom corner and you are free to scale in object mode.
Select object2, go to edit mode, select right bottom vertex, Shift+S > Cursor to selected.
Return to object mode Shift+Ctrl+Alt+C > Origin to 3D cursor.
| 0.333333 |
Set object2 origin point to its right bottom corner and scale in object mode
|
A symbol for the quotient of two objects
|
One needs often a symbol to denote the quotient of two (algebraic) objects. (e.g. quotient by a subgroup, subring, submodule etc.). In simple cases people use A/B. But when both A,B are complicated to write, this doesn't look good. e.g. \mathcal{O}_{(V',0)}}/\mathcal{O}_{(V,0)}}
For some reasons people do not use just \frac{A}{B}. Is there some way to achieve the following:
$A$ raised a bit, then \Big/ then $B$ a bit lowered.
|
As already mentioned, there are two packages to solve this problem:
xfrac - typeset fractions in the form n/d generally
faktor - especially to typeset factor structures
Here is a comparison between the \sfrac{n}{d} and \faktor{n}{d} commands which also demonstrates how they behave in comparison to normal text:
\documentclass[12pt,preview, border={2pt,2pt,2pt,2pt}]{standalone}
\usepackage[english]{babel}
\usepackage{xfrac}
\usepackage{amsmath}
\usepackage[amsmath,thmmarks,standard]{ntheorem}
\usepackage{faktor}
\begin{document}
\begin{alignat*}{4}
\text{This } &\sfrac{\mathcal{O}_{(V',0)}}{\mathcal{O}_{(V,0)}} &\text{ and this } &\sfrac{\mathcal{S}^n}{\equiv_m} &\text{ and this } &\sfrac{A}{B} &&\text{ is \texttt{sfrac}.}\\
\text{This } &\faktor{\mathcal{O}_{(V',0)}}{\mathcal{O}_{(V,0)}} &\text{ and this } &\faktor{\mathcal{S}^n}{\equiv_m} &\text{ and this } &\faktor{A}{B} &&\text{ is \texttt{faktor}.}
\end{alignat*}
\end{document}
| 0.666667 |
xfrac - typeset fractions in the form n/d generally faktor
|
IE9 RC crashes on my Windows 7 laptop?
|
I was using IE9 beta till now and installed IE9 RC today. However it starts crashing on 50% of the sites I visit. This also includes www.youtube.com.
I did not uninstall IE9 beta before installing IE9 RC. Could this be the reason?
EDIT: I have uninstalled IE9 RC and installed it again after restart but that has not fixed this issue.
|
Does this occur on pages with flash or any other plugins?
Have you tried checking memory in your computer?
I can't really have any other idea. Other apps misbehave too? (To be honest I don't really have an idea why would you want to use IE9RC if the other apps work like a charm. Like.. it only have GPU accel.. like Chrome and Firefox's latest beta. Nothing new, nothing special.)
| 0.888889 |
Does this occur on pages with flash or any other plugins?
|
Breaking Masterwork Weapons/Armor
|
I have an encounter in which my party will be fighting a slime that deals damage to their armor and weapons. My whole party has at least 2 masterworked items. Does masterwork imply that the items can not be broken?
Thank You
|
No
The masterwork property does a few things for items, but making them immune to breaking is not one of them. It does grant +1 to hit, and allows the item to be made into a magic item. Masterwork items that have been broken, be it through sundering etc., still have to be repaired like any other item (the exception is the Durable magic property).
| 1 |
The masterwork property does a few things for items, but making them immune to breaking is not one of them.
|
What is the Goal of "Hot Network Questions"?
|
There has been a tug-of-war in the hot-questions list.
Community members like JonW seem to be unhappy with the traffic that it brings to their site:
'But we want to encourage people to post, that's the whole point of the HQ list!' I hear you cry. I disagree. We want to encourage people to the site not just to that question.
The SE Community Team seems to have a different opinion as Shog9 points out (emphasis mine):
the results have been... Not great so far: a significantly smaller number of people are clicking through to randomly-selected questions than to the top questions, which hints that the algorithm may've been doing a better job of identifying general-interest questions across topics than some expected.
Disclaimer: This should not be taken as a slight of the community team whatsoever, nor do I think this is some cause for revolt or a boxing match as the below prose may indicate. These are just poorly applied literary tools to emphasize the drastically different approaches to the same list between two groups.
In the Red Corner, the Community Members
The goal of the hot questions should be to drive up interest in the site. The hot questions should be a lure to encourage SE network users to contribute to other content, not just do a drive-by on the hot question.
In the Blue Corner, the Community Team
The goal of the hot questions should be to drive traffic to general-interest questions. After all, the Hot Network Questions used to be more accurately named as "Popular Questions".
What is the Goal of Advertising Network Questions?
Before discussing how to calculate hotness, or how the list should be ordered, we need to come to an agreement on what the heck we are actually trying to achieve. Once we know what we are looking to accomplish, we can find the best way to do that.
The list of questions from a variety of sites is in a great location screen-wise, it is readily accessible and does get a lot of eyes on it. But as with any marketing, the goal isn't just to grab eyes, it's to grab the right eyes.*
* I have nothing against left eyes. Most of my friends have left eyes too. And they are awesome. But in the context right eyes are not a geospatial thing, but rather in the 'correct' sense.
So what are the right eyes? What type of people do we want to attract to our site? What would we determine as 'success'? How can we measure that success?
Please do not limit yourself to the very narrowly scoped topic above. Think outside the box if you'd like. On every page across the network we have a nice piece of real estate for showing off the rest of the network. How can that space best be used if not on a list of questions picked by an arbitrary algorithm?
|
I agree that increasing viewership to good questions and driving users to sites they may wish to join but might not naturally visit are both good goals. I would like to mention a third goal:
In the....other corner, random intermittent positive reinforcement
Studies have shown that random intermittent positive reinforcement can be more effective that purely positive reinforcement. This means that a reward that is given for good behaviour, but only sometime and to varying degrees, is more effective than a proportional reward. This is perhaps because people are always chasing the next "big score".
So what has this got to do with hot questions?
Hot questions are (one can only hope) good questions with a good answer since the upvotes are a major part of what drives them - So the positive part is taken care of.
However, it is rare to get one of your questions/answers on the "Hot questions" list, and I haven't been able to detect much of a pattern (except that the questions seem to be more easily understandable to a general audience and are high quality) - So the intermittent random portion is taken care of.
And I think we can all agree you are heavily rewarded for having a good answer/question in the hot questions list.
My experience
When I got my first answer on the hot questions list it was the most exciting Stack Exchange had been since the initial honeymoon period was over. These rare periodic large rewards are key to keeping long term expert users loving the site.
Conclusion
I'm not saying that random intermittent positive reinforcement should be the main goal of the hot questions list. But it is an additional positive effect to take into consideration.
| 0.777778 |
What is the main goal of random intermittent positive reinforcement?
|
sleeping SPID blocking other transactions
|
I'm really having trouble tracking down some blocking we are experiencing.
The root blocking SPID's status is 'sleeping', the cmd is 'AWAITING COMMAND', and the sqltext is 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED'.
When I view the Top Transactions by Blocked Transactions Count report, the Blocking SQL Statement is '--'.
I've performed a trace on the SQL and when the blocking happens tracing the root blocking SPID but it hasn't really led me anywhere. The last trace statement is the same as the sqltext above 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED'.
I've checked all the related SPROCs I can find to make sure they have TRY/CATCH BEGIN TRAN/COMMIT TRAN/ROLLBACK TRAN statements (we use SPROCs for everything so there are no standalone statements being ran). This issue just started happening over the last 24 hours and no one is claiming to have made any changes to the system.
Solution. One of our seldomly used SPROCs had an error with an insert (number of columns didn't match), but we are still confused on what exactly was happening.
When looking at all the trace information, the EXEC statement for this SPROC was listed at times, but NEVER just before the BLOCK happened on the blockking SPID. It seemed that when it starting blocking, the trace didn't record the execution of it (or any of the statements within it either). However there are other times were the trace did record it's execution and no blocking occurred.
The SPROC error report came from a user, and I was able to find multiple EXEC statements in traces and run them in SSMS. No time when I ran them did we have any blocking occur or did they hang. They ran as expected (the catch block fired and rolled back the transaction after the error). After resolving the fixing the SPROC, we have not seen the issue again.
|
From comments, I'm guessing you had a client side Command timeout that has aborted the SQL query. This does not rollback the transaction because the connection stays open on SQL Server due to connection pooling.
So, you need to use SET XACT_ABORT ON or add some client rollback code
See SQL Server Transaction Timeout for all the gory details
| 0.888889 |
SET XACT_ABORT ON or add client rollback code
|
How to get <img> src from CDATA in RSS?
|
I am fetching data from RSS feed with Magpie.
$rss[description] contains CDATA with html elements:
<![CDATA[
<div>
<a href='url'>
<img src='img_url' alt='aaa' title='bbb' border='0' width='116' height='116'>
</a>
</div>]]>
Some other text
How can I fetch "img_url" from this? Is preg_match() the only way? Maybe I can use simpleXML?
|
You would better not to use regular expressions where you can use proper tools. Something which comes to my mind (although maybe it can be done easier):
$descr = $rss[description]; // String. You have extracted description part from your feed
$dom = new DOMDocument();
$dom->loadHTML($descr); // or you can use loadXML
if (!$dom) {
die('Error loading HTML string.');
}
$xml = simplexml_import_dom($dom);
$imgSrc = (string)$xml->body->div->a->img['src'];
Here we go. Based on the your example CDATA $imgSrc will be equal to img_url.
| 1 |
How to use regular expressions?
|
How to improve or get rid of an Indian English Accent?
|
As you might suspect, that the only person who can ask this kind of question must be an Indian. What's wrong with an Indian accent, that makes it difficult for other people to understand. I have communicated with Japanese, Chinese, American and French, and all have told me that your Indian English accent is difficult to understand.
Can anyone tell me how to improve Indian English Accent or get rid of Indian English Accent. Please tell me how to improve specific pronunciation of alphabets, that can help other understand me clearly.
|
Without hearing you speak it's difficult to say what you should work on. Indian English embraces native speakers of many different languages and dialects, and each brings different problems to English pronunciation.
With respect to phonology—pronunciation of individual sounds, what you call ‘alphabets’†—this Wikipedia article may help you identify your own points of difficulty.
But in general I‘m going to guess that the biggest problem your hearers face is not your pronunciation of individual sounds but the tonal contour of your phrases and sentences—what linguists call ‘prosody’ or (as in the linked article) ‘supra-segmentals’. English listeners tolerate a great deal of variety in the pronunciation of phonemes, but rely very heavily on stress patterns to identify the ‘shape’ of sentences; and as the article tells you, Indian languages use stress very differently.
To attack this problem I suggest simple imitation. Find recordings of fairly long passages by native speakers of the particular dialect you wish to emulate—General American or Australian or British Received Pronunciation or Estuary English, or whatever. The recordings should be fairly conversational in tone, not readings from technical or highly ‘literary’ works; interviews with practised public speakers will do very well, particularly if they are telling stories rather than just giving brief answers to questions. Sit down with the recordings, for twenty or thirty minutes at a time, playing stretches of two or three sentences or so, and try to reproduce exactly what you hear. It will feel very odd and artificial for quite a while, but at some point everything will ‘click’: your voice and the recording will have the same lilt and feel. You will then find it very natural to carry that lilt and feel over into your own speech.
That, at any rate, is how I used to learn dialects for stage use. And you should think of it that way, as a role you are playing. You are 'portraying' an English speaker: not losing an Indian accent, but acquiring a specific English accent.
† This is a problem of a different sort, a lexical one. Alphabet is a common ‘Indianism’ for Standard English letter. And since English spelling (as you are no doubt painfully aware!) is very far from being phonetic, letter is really not appropriate when speaking of pronunciation.
| 1 |
phonology and pronunciation of individual sounds in Indian English
|
Displaying articles created by user in profile page using views
|
I want to display the articles created by user in user profile page. It should also display to anonymous user also.
For example : twitter.com/google displays all tweets by google.
Like that I want to display xyz.com/john. I want to display all articles created by john in user profile page.
I also want to know how to add that view to profile page.
|
Add a contextual filter to your view:
User: Uid (if it is not available -> define a relationship to User)
Now select in the section "When the filter value is NOT available" the value "Provide default value" and choose "User ID from url". Additionally you can specify a validation criteria to accept UIDs and user names.
| 0.888889 |
Add a contextual filter to your view
|
Photo icons have generic picture only
|
When going to a JPG photo folder OS C drive and opening it to view photos in an icon mode the icons only show a generic picture. If I click on the icon then the actual photo comes up. It seems like this problem just started happening. In the past I would open a folder and view icons and the photos were all there to view at once. I don't believe I made any intentinal changes. Thanks for the help.
|
I found the answer. Simple and easy. Go into your pictures folder. After that, press view on the upper left and go to options. From there go to view and the first check box "Always show icons, never thumbnails" I going to be checked. Unchecked it and bam
| 0.888889 |
Unchecked the first check box "Always show icons, never thumbnails"
|
What does the lpr -h command exactly mean from linux?
|
I am new at Linux and in my school they asked me to give an example of this command
lpr -h
I already know that lpr its for printing and that the option -h disables banner printing.
What banner? As far as I am with Linux I only know to create banners from the banner command
banner "hello world"
Not how to save it or print it. Is that kind of banner what this -h option refers to?
Could you give me an example?
|
man lpr --> -h --> -o job-sheets=none --> banner page --> Wikipedia – Banner Page.
The first page explains what the command does, the second explains the options -o takes and the third explains what the banner page actually is; thus we obtain this paragraph from Wikipedia:
A banner page, also called a burst page, job sheet, or a printer separator, is used in computerized printing in order to separate documents (or "print jobs") from each other and to identify the originator of the print request by username. These pages are typically used in office environments where many people share a small number of printers. In some cases, print jobs are sent to a central processing area where messengers take the printouts back to the owner, but the usual practice in modern office environments is for the user to retrieve his or her own documents. The banner page makes it clear who printed each job.
You can find examples of what banner pages look like on Google Images.
Also, I should note that the Linux banner command is something completely different.
You are responsible for not doing your homework yourself, not me.
| 1 |
Banner page is used in computerized printing
|
Who invented pointers?
|
Pretty simple question, but something I haven't been able to find out. Who was the first person to describe the idea of a pointer? The abstract concept itself?
|
Pointers as a basic concept are used in "indirect addressing" a function on most CPUs going back at least as the 6502.
Commodore used the "kernal" on its VIC 20, C64, and C128 computers. a fixed set of address software could call that would then be redirected to the current code. They could then modify the OS without breaking existing software.
I think the 8080 and Z80 had indirect address too, but I am not certain and I don't remember it in the 8008.
| 0.777778 |
"indirect addressing" a function on most CPUs going back at least as the 6502.
|
MySQL does not work fine with UTF-8
|
I added this rows to my-default file, restarted server, recreated schema, table and data in the tables, but my cyrillic data still looks like '????'.
Now I have a new user and such config, but utf8 still does not work.
[mysqld]
init-connect=SET NAMES utf8
character-set-server=utf8
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8
[mysql]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqladmin]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqlcheck]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqldump]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqlimport]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqlshow]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
#end
|
I replaced my.cnf by the default my.cnf, added
CHARACTER SET utf8 COLLATE utf8_general_ci;
for the DB and all tables.
Now it is works fine! Thank you very much!
| 0.833333 |
CHARACTER SET utf8_general_ci
|
JQuery - Select exact class structure
|
I am working on some functionality for a website. I am designing, and I am kind of stuck on something small. I want to hide divs that contain an exact class structure.
For example, if I give it the class selector ".class1.class2.class3", it will ONLY hide elements that have exact class structure. What I am doing now would hide elements like ".class1.class2.class3.class4", and I don't want that.
Any help would be greatly appreciated!
|
I you want to match objects that ONLY have exactly those three class names and you want to be insensitive to the order of the class names or the amount of white space between them, then you can do it like this:
$('.class1.class2.class3').filter(function() {
return(this.className.replace(/class1|class2|class3/g, "").replace(/\s*/g, "") == '');
});
If you want to only exclude a specific other class, then you can do it like this:
$('.class1.class2.class3').not('.class4')
| 0.888889 |
If you want to only exclude a specific other class, then you can do it like this: $('.class1.class2.class
|
How can I fix messy hair in Animal Crossing?
|
I time-warped in Animal Crossing: New Leaf so I could get to the award ceremonies for the Bug-Off. I time-warped a year ahead, and now my hair's all messy. How can I put my hair back to normal?
|
You can fix messy hair by going to Shampoodles. Shampoodles can be found on main street.
| 1 |
Shampoodles can be found on main street
|
Using conditionals to set tag parameters
|
I have this opening low search result tag
{exp:low_search:results
{if segment_2}query="{segment_2}"{/if}
group_id="7"
limit="4"
paginate="bottom"
}
I wanted to do more checks on segment_2 before deciding if I should set query param(checking if the segment is for pagination such as P1 or P4).
{exp:low_search:results
{if segment_2 == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}{if:else}query="{segment_2}"{/if}
group_id="7"
limit="4"
paginate="bottom"
}
However, I don't think this will work. I think it has something to do with the parse order where you can't set complex conditionals inside a tag.
If so, is there an alternative way to set the query param?
UPDATE: The reason I am asking is because the code below does not work
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
{exp:low_search:results
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{if:else}
{exp:low_search:results
query="{segment_2}"
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{/if}
I always get a Parse error: syntax error, unexpected T_ELSE in the code where I don't set the query param.
|
You problem is you're trying to do a complex conditional within the tag parameters, that's not possible.
Here's a good article regarding parsing conditionals within tags:
http://johndwells.com/blog/expressionengine-parse-order-advanced-conditionals-as-tag-parameters
As you state, the problem is simple conditionals versus complex conditionals.
The problem with your second code:
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
{exp:low_search:results
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{if:else}
{exp:low_search:results
query="{segment_2}"
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{/if}
...Is that you won't be able to have the opening tag in a separate conditional to the closing tag - EE parses conditionals at a separate stage to tags. It's not linear (working from top to bottom).
This may work:
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
{exp:low_search:results
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{title}
{/exp:low_search:results}
{if:else}
{exp:low_search:results
query="{segment_2}"
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{title}
{/exp:low_search:results}
{/if}
...Where each tag pair is contained within the same conditional.
There's an additional problem in your revised conditional that is showing a parse error:
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
If there is no keyword, that tag will return an empty string, resulting in your conditional looking like this prior to EE parsing it: {if {segment_2} == '' OR }
...Which will result in the parse error. This is safer:
{if {segment_2} == '' OR '{exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}'}
With the quotes, it can be parsed correctly as {if {segment_2} == '' OR ''}
Or how I'd approach it, by including in an embed and doing all the conditionals in the parent:
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
{embed=template-group/search-results group_id="{if segment_1 == "foo"}6{/if}{if segment_1 == "bar"}7{/if}" query=""}
{if:else}
{embed=template-group/search-results group_id="{if segment_1 == "foo"}6{/if}{if segment_1 == "bar"}7{/if}" query='query="{segment_2}"'}
{/if}
And in the embed template:
{exp:low_search:results
group_id="{embed:group_id}"
{embed:query}
limit="4"
paginate="bottom"}
{title}
{/exp:low_search:results}
Note: for the first embed, query will be an empty string which is fine to pass as a parameter.
| 0.666667 |
How to parse conditionals within tags?
|
What do you do about contradictory rules of Pit?
|
The rules of Pit are oddly contradictory. For n players choose n commonities, add in the Bull and Bear, shuffle and deal out the cards. The rules state that everyone gets 9 cards. Doh! With the Bull and the Bear added in that doesn't work.
The way we reconcile this is two people have 10 cards which gives them a significant advantage, e.g. they can simply hold a single card of a commodity to effectively eliminate whoever ends up going for that commodity.
Are there better solutions to this?
|
In the group where I've often played Pit, we discarded the Bull and Bear cards before shuffling. It makes the game simpler and better, in my humble opinion.
That being said, we can still debate which is the best solution if you do want to keep those cards. MrHen's solution may well win that honour. A different option would be to discard two cards at random every time you deal. The advantage is that the playing field is level; however, there are up to two commodities that cannot be completed. But in this version, all players are equally likely to be affected.
I could see a few variants of this variant:
Make the discarded cards secret. At the end of every round people are going to be frustrated that their chosen commodity was unwinnable.
Make the discarded cards public. Now all commodities of the discarded type are effectively Bear cards.
Start a timer for (say) 30 seconds when the round starts. At the end, if no one has won yet, play is interrupted and one of the discarded cards is made public. Players try not to give away that they were close to finalizing a "doomed" commodity. Play continues for another 30 seconds and is interrupted again to make the last card public. Chaos ensues.
| 1 |
Make the discarded cards secret
|
How do I counter support Zyra?
|
I main support, usually opting for poke supports such as Lulu and Sona or aggressive supports such as Blitzcrank and Leona. Since the various Regional Finals, however, I've begun to encounter support Zyras in my bot lane.
This is a very difficult lane for me. I can't establish lane dominance, since Zyra just sits in her bush and puts seeds in mine. I've tried a rune page with flat MR for when I play against Zyra to counter some of her harass, but it doesn't help against her cc.
How can I effectively counter a support Zyra?
|
I'm not the best support player, but maybe I can give you another point of view.
Zyra doesn't have any ability to heal her lane partner, nor does she have an escape mechanism. Additionally, her harass is based on her skills.
To counter her, I would recommend Soraka, for 2 reasons:
Sustain
Since you have the aability to heal your carry and Zyra doesn't, you can stay longer in the lane and harass the opponent. Ask your carry to harass as much as possible, and you will force them to go back to base, giving your partner a gold advantage.
Silence
Zyra is based on her skills; as Soraka, you have the ability to silence her every time she gets close to you or your partner.
If Zyra is still bothering you, simply put a ward in her brush. This allows you to predict her moves and gives vision of her to your carry, so he can harass her.
If I could choose a lane partner, I would pick Caitlyn, as her long range makes her pretty good at harassing the opponents.
As a support, your role is to keep your carry safe. If Zyra tries to harass you, silence her and attack back, healing right after. Soon, they will have low hp and your hp will stay full.
| 0.777778 |
Sustain Zyra doesn't have any ability to heal her lane partner or escape mechanism .
|
Mark: outstanding (as in: not yet known)
|
I’m updating my tabular CV for an application and I’d like to include my master thesis even though it’s not yet finished (soon!) and marked. So I’d like to write that the mark is still outstanding but I fear that if I simply write
Master thesis: ‹topic›
Supervisor: ‹supervisor›
Mark: outstanding
this could be misconstrued to mean that the result is in, and that it’s outstanding (as in: spectacular). What can I say here instead? It should be as salient as possible, single word preferred. I specifically want to avoid writing half a sentence.
|
I agree, using outstanding here is quite ambiguous.
I would use Awaiting mark or Pending mark - they are both clear and direct. (You can alternatively substitute mark with grade.)
| 1 |
Awaiting mark or Pending mark is clear and direct
|
Formal proof that $\mathbb{R}^{2}\setminus (\mathbb{Q}\times \mathbb{Q}) \subset \mathbb{R}^{2}$ is connected.
|
Cam anyone provide me the proof of:
that $\mathbb{R}^{2}\setminus (\mathbb{Q}\times \mathbb{Q}) \subset \mathbb{R}^{2}$ is connected.
|
Theorem. $\ \mathbb{R}^2-A\ $ is connected for any set $A\subset\mathbb{R}^2$ of cardinality less than the continuum.
Proof. Consider any two points $u,v$ in $\mathbb{R}^2-A$. There is a foliation of continuum many paths from $u$ to $v$, which are disjoint except at $u$ and $v$. For example, one could consider all the various circle fragments containing $u$ and $v$. Since only fewer than continuum many of these paths contain points from $A$, it follows that almost all of them are contained in $\mathbb{R}^2-A$, which is therefore path-connected, and even arc-connected. QED
In particular, $\mathbb{R}^2-\mathbb{Q}\times\mathbb{Q}$ is connected.
| 1 |
foliation of continuum paths
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.