Number of complex roots of the equation $x^n=a, a\ge 0$

Question:
I have a question about number of complex roots of the equation
$$x^n=a, a\ge 0, n\not\in \mathbb Z.$$

According to the Fundamental Theorem of Algebra if $x^n=a, n\in\mathbb N$, then we have exactly $n$ distinct complex roots. The real root is $x=\sqrt [n]{a}$, if $n$ is odd or $x_{1,2}=\pm \sqrt [n]{a}$, if $n$ is even.
But, when $n$ is not a natural number, for instance,
$$x^{\pi}=a, a\ge 0$$
What are all the complex roots and exactly how many roots are there?
I think that, $x=a^{\frac 1\pi}, a\ge 0$ is an only real root.
Comment: $x^{\pi}$ is not really well-defined if $x$ isn't a positive real. You can take it to mean $e^{\pi \log x}$ but then its value depends on a choice of branch of the logarithm. (I'm not saying anything here about how many different values of $x$ there are for a given value of $x^{\pi}$; I am saying that already to define the *function* one runs into multiple values.)
Comment: I agree with @QiaochuYuan ... Before asking about complex roots of the equation $x^n=a$ (for non-integer $n$), you first need to know a definition of $x^n$ (for non-integer $n$).
Comment: @DietrichBurde Fixed.
Comment: @QiaochuYuan Cann't we say $x^{\pi}$ is well-defined in complex number set, when $x≤0$? Because, I am aware $(-1)^{\pi}$ is a non-real complex number.
Comment: "The real root is only $x=\sqrt [n]{a}$." No, take $n=2$ and $a=4$.
Answer: Coincidentally I was checking this out a few months back. I'll share my findings.
The roots of said function lie along the unit circle scaled up by $a^{\frac1n}$. I'll invert your expression into $\dfrac{1}{x^n-a}$ with $a> 0$ and make all of its roots poles instead to make everything much more obvious
For an integer power $n\in\mathbb{Z}$, we will get the $n$ roots of unity. The function is entire with no branch cut.
For each noninteger $n\in\mathbb{R}$, we have the number of poles will be the nearest odd integer. There will be a branch cut since by definition $$p(z) = z^c = \exp\left(c \ln(z)\right) = \exp\left(c \left( \operatorname{Log}(z) + 2n\pi i \right)\right),\qquad n\in \mathbb Z$$ and since $c$ is not a whole multiple of the logarithm, there will be multiple branches. We can safely choose it to be along the negative real axis.
We may observe that at $n=1$, we have a singular pole at $z=1$.
As we gradually increase our $n$, the pole splits into two along the branch cut and proceeds to make its way towards the positive real axis.
More generally, at every even integer, a pole appears at $\sqrt[n]{a}$ (which we will define to be the negative real pole), and as you increase $n$ the pole splits and pushes the other poles backwards along the unit circle scaled up by $a$ until we reach the next integer, where the poles would be at some arrangement of the roots of unity again.
In your example, we have $x^\pi=a$. The nearest odd number to this is $3$ so there will be $3$ poles, one at the positive real value of $a^{\frac1{\pi}}$ and the other two roots using the complex power function definition shared earlier would be at $a^{\frac1{\pi}}\cdot e^{2i}$ and $a^{\frac1{\pi}}\cdot e^{-2i}$, pretty close to the true third roots of unity since well, $\pi$ is close to $3$.
In the most general case(you can derive this too by tinkering with the logarithm definition of the power function), the solutions can be found as follows. Given $$x^n=a$$ our real root is $$a^{\frac{1}{n}}$$ Next, the complex roots will have this form... $$a^{\frac{1}{n}}\cdot e^{\pm\frac{(2u)\pi i}{n}}$$ for some $u\in\mathbb{N}$ given that the root you get from it will not violate your chosen argument(which in this case I selected $-\pi\le\arg(z)<\pi$).
You can use the manipulate command in mathematica to watch how the roots evolve, it is pretty fun. Here, I will let $a=2$ and show the pole evolution of $n$ from $n=2$ to $n=4$


Reference for a fast introduction to the bare minimum of Abstract Algebra

Question: I'm doing a PhD in Applied Mathematics coming from a Master also in Applied Mathematics. Yet, my undergrad was actually civil engineering, so the first time I actually learned "pure" mathematics was during my Masters, where I took courses such as Real Analysis, Functional Analysis, Measure Theory and Linear Algebra. For this reason, I haven't been exposed to some "basics" that perhaps an undergraduate in math already has. The most blatant example is Abstract Algebra. I'm completely in the dark about the subject, and from time to time it comes up when I'm studying a subject (e.g. Caratheodory's Extension Theorem).
I'm really interested in learning Algebra, but I don't have the time now to take a deep dive. Yet, I feel that knowing the "bare minimum" could help me with other subjects I'm studying. Hence, I was wondering what good references were out there that could serve as a "fast course" on Abstract Algebra. Some of the answers for book recommendations are usually books that are too large. I'd be interested in something that presented the "main" results in a rigorous manner.
Answer: I really like A first course in Abstract Algebra by Fraleigh. He starts by the basics, is very didactic and has nice visualizations. You can get a good grasp on group theory, ring theory and Galois theory. More advanced topics are clearly marked so you can skip them in a first reading.
Answer: I could recommend the book with I was introduced to algebra being almost from scratch: Abstract Algebra by Gregory T. Lee. It is a book with less than 300 pages and in the preface the author talks about what he considers to be the "basic" topics. Gallian's Algebra book is more extensive, but I think you can take it for specific queries and references.
Answer: Alongside with the Fraleigh book you can study the online textbook "Abstract Algebra: Theory and Applications" by Thomas W. Judson. it covers the basics of abstract algebra, including groups, rings, and fields. It is aimed at undergraduate students and includes many examples and exercises.


C++ string's internal buffer address undefined behaviour

Question: Is the following undefined behaviour under c++11 standard:
(trying to get the address of the internal buffer of a string)
std::string s;
... = &s[0];

for example when s is empty?
I know that we have c_str(), data(), but nevertheless.
Note
this is coming from a debate with someone, this is not intended to promote hacky coding
Comment: You also have s.data()
Comment: @Alex yes, still the question remains
Answer: In C++11, the code is well-defined, but may not do what you expect. The exact effects are, as per 21.4.5/2:

Returns: *(begin() + pos) if pos < size(), otherwise a reference to an object of type T with value
  charT(); the referenced value shall not be modified.

So if the string is non-empty, it returns a reference to the internal buffer's start. If it's empty, it returns a reference to a char with value 0, whose location is memory is an implementation details.
Comment: So, `&str[str.size()]` could always return a pointer to the same address for every `str`?  Meanwhile, `*(str.data()+str.size())` for non-empty strings is a `'\0'` adjacent to `&str.back()`?  Amusing.
Comment: @Yakk Um, not for every `str`. `c_str()` and `data()` returns a pointer `p` such that `p + i == &operator[](i)` for each `i` in `[0,size()]`. So for non-empty strings, `&str[str.size()]` must be the `'\0'` adjacent to `back()`.
Comment: @T.C. I think I see it now.  `data()+i` being in terms of `operator[](i)` implicitly forces `operator[]` to return contiguous elements, including `operator[](size())`.  That is also what forces `for(char& c:str)` to be contiguous characters?  No, that is covered (in the current standard proposal) by the contiguous iterators concept.  Contiguous iterators don't force the null terminator to be contiguous, however: that is the data clause?
Comment: @Yakk Yes, that's the `data()`, I believe. `string`'s iterators doesn't cover the null terminator, so the contiguous iterator rules doesn't apply to it.
Answer: I think this will give you an address somewhere on your stack. Due to the small-string optimization in most implementations.
http://www.cplusplus.com/reference/string/string/operator[]/ says:

If pos is equal to the string length, the function returns a reference to the null character that follows the last character in the string, which shall not be modified.

You may get problems in form of undefined behavior as soon as your index-parameter is greater than the size of string.
Comment: cplusplus is non-normative, and disagrees with the standard in this case.
Comment: Well, that's a surprise to me! Thank you for pointing this one out. I think cplusplus refers to a specific implementation that has implemented this behavior!? It its not clear to me what charT() generates... may this be any value of type charT or does the standard somewhere states the value of  a default constructed charT()?


Publish or Un publish any comment

Question: How to give moderator a right to publish or unpublish/edit any comment , not just own comment or  comment on own content without giving "Administer comments and comment settings" Permission, by giving just a tab for publish and unpublish for appropriate role ?
Answer: Go to /admin/people/permissions and check assign the appropriate permission("Administer comments and comment settings") you'd like to the that role.
Check https://www.drupal.org/node/777696
Comment: If giving Administer ... comment settings is not wanted then blocking that path via [Custom Permissions](https://www.drupal.org/project/config_perms) from moderator can enhance this solution.
Comment: I wanted to ask it that can be done without giving "Administer comments and comment settings" by giving just a tab for publish and unpublish  for appropriate role?
Comment: Can This be done through flag with flag only visible to particular role? and that role can see all unpublished comments visible to only that role?
Comment: I do not really understand what you aim for.  What is a flag? What do you mean by tab?
Comment: By tab i mean a link , by flag https://www.drupal.org/project/flag , I just want to give easy link for publishing and unpublishing a comment  for moderator.
Comment: You can also add a link like "comment/%/approve", where "%" holds the comment id. You can add the link within hook_form_FORMID_alter(). You need to implement the callback on your own. This will require access check both on the addition of the html in the form and the callback. Hope that helps.

Publish or Un publish any comment


Proof concerning Numerical Integration using Monte Carlo Methods

Question: Im currently trying to proove that:
Let $ f:[0,1]^r\to [0,1]$ a contiunous function and $(X_{n,k})$ for $   n \in N, 0<=k<=r $. be independently and identically distributed random variables with a Uniform(0,1) distribution. Show that for $Z_n: Z_n= 1,$ if $X_{n,0}<= f(X_{n,1}, ... ,X_{n,r})$ and 0  elsewhere,  that
$E(Z_n)$= $\int fd \lambda ^r $
A hint into the right direction would be nice. I have no idea how to do this.
The Integral $E(Z_n) $ is obviously the probability that $X_{n,0}<=f(X_{n,1}, ... ,X_{n,r})$ but I have no idea how to calculate this.
Thanks in advance
EDIT: I have an Idea
$E(Z_n) = \int_{0}^1 Z_n(X_0(\omega),....,X_r(\omega)) d P ( \omega )= \int_0^1Z_n(x_0,...,x_r)d[X(P)] = \int_0^1...\int_0^1f(x_o,...,x_r)d \lambda(x_o)....d \lambda(x_r)=\int_0^1...\int_0^1\chi_{(f(x_1,...,x_r)>x_o)}d\lambda(x_1)...d\lambda(x_r) d (x_0) = \int_0^1 \lambda^r(f(x_1,...,x_r)>x_0)\lambda(x_0)=\int_0^1f(x_1,...,x_r)d \lambda ^r$
is this correct?
Comment: Why did you use this title? Tell some more about what your prof said, and what you understand by Monte Carlo methods, such that other people may understand your problem better.
Comment: Then please tell us where are you stuck and add `[self-study]` tag as described in https://stats.stackexchange.com/tags/self-study/info
Comment: Is this a homework question?
Comment: Yes. I dont want the full proof, just a hint into the right direction
Comment: What has this to do with Monte Carlo methods?
Comment: How am I supposed to know that? My Prof said so xD
Comment: The homework task is about numerical Monte Carlo Integration. So I thought it makes sense to write it into the title even though I dont really understand it yet. Is the title missleading?  If so I will remove it
Comment: as soon as I understand everything myself I will update the post. Only the title of the homework question said "Numerical Integration using Monte Carlo". So I unfortunately cannot provide more information about the problem yet
Answer: Use $$E(Z_n) = \int_{X_1 \cdots X_n \in \left[ 0,1 \right] ^r} \left( \int_{X_0 \in \left[ 0,1 \right]} Z_n d X_0 \right) dX_1 \cdots dX_n $$
and start with finding out how you can rewrite:
$$\int_{X_0 \in \left[0,1\right]} Z_n(X_0,X_1 \cdots X_n) d X_0 $$


Clone Windows 10 to new disk

Question: I have problem with Windows 10. I've installed Windows 10 on Qemu virtual machine and I need to clone this image to physical disk. I use ntfstool for do that.
Unfortunatelly my Windows doesn't boot because UNIQUEID for disk is different. I can change disk uniqueid to correct and boot windows but I must change uniqueid in Windows VM to 0x00000000. I have a system which automatically save windows images to correct disk but all disks have uniqueid as 0x00000000. I need to have image with the same id.
My questions are:
1. Can I change unique id for Windows disks without loosing boot ability?
2. Can I tell Qemu which id should new disk have?
Thanks.
Answer: +1 Run sysprep to prepare system for cloning then go with Clonezilla to prepare image of your VM and to write it on physical host.
Comment: I don't use clonezilla, I use ntfsclone because I want to automat that process. Unfortunatelly after sysprep my system goes to reboot loop. :(
Answer: There is guide how to prepare windows system before cloning.
In two words, you need to use sysprep before cloning to remove system-specific data from Windows.
Comment: Thank you for a suggestion but It doesn't work. After sysprep I got some questions during boot and everything takes too much time. Anyway I didn't run cloned system because it went to reboot loop. :(

Previously I manually installed system on disk with id 0x00000000 and clone with ntfsclone. All my machines has partition with that ID. Now I wan't to automate that process and use qemu to create system but I have problem because I can't tell qemu to create disk with specific disk id.

Clone Windows 10 to new disk


R - randomForest resample - replacement or not

Question: I am studying the randomForest package to deal with an extremely imbalanced dataset (target: 98% vs 2%).
I realize I can utilize parameters sampsize and strata to do Balanced Random Forest (downsizing).
However, assuming I am taking 70% of the minor group and the same size of the major group as my sample size (e.g. sampsize = c(minorSize*0.7,minorSize*0.7)), should I do replacement = TRUE or FALSE?
Answer: Your sampling objective would be to have more samples from the minority class (which is 2% of population), to match the majority class to train a better classifier.
For this, you should sample with replacement from the minority class, which means you could end up having many copies of the same minority class sample in the training set.
For the majority class, you can sample without replacement since you have many records available to use.
For highly imbalanced classes, under-sampling the majority class and over-sampling the minority class works best. As part of hyper-parameter tuning, its advisable to try out different sample sizes when training your classifier and find out what works best for your dataset.
You could also consider using SMOTE - it creates synthetic samples of the minority class and randomly under samples the majority class.
Edit: You could first split the training set into majority class and minority class, sample from them separately and then re-combine them to get the final training set. If you're not comfortable doing this by writing your own code in R, you could use the downSample and upSample functions of the caret package.
Comment: thanks. I am curious, is it possible to set replacement for one class and non-replacement for the other one? I am using randomForest package in R.
Comment: Edited to answer your query.
Comment: thanks for your quick response. I like that we should sample the majority class without replacement and do the minority class with replacement. Actually randomForest package allows us to balance data within the function, meaning every time it grows a new tree, it will re-sample again, which is more robust than re-sampling before. My concern is `replacement` parameter will set to both majority group and minor group, while I want majority group to be non-replacement sampling and minor group to be replacement.
Comment: Why would you want to create the training set within the function ?  It seems inelegant and would mean that results could not be compared with different methods.  I would always take my training set, create the more balanced training set and then run my models.  In addition, have you considered using SMOTE ?


How to handle a Drupal core change that have an impact in the next release of a contrib module?

Question: Reading the Drupal Changes records I found that drupal_get_message() and drupal_set_message() replaced by Messenger service so lets suppose that I have a module that use the drupal_get_message() function and I want to replace it with the new Messenger service. If I do it my module only will works starting from Drupal Core >= 8.5.
So, in this point what is the correct way to produce the next module release?
Should I restrict the next release to a specific Core version adding a comment in the release notes or should I create a new branch (lets says 8.x-2.x) to implement this changes and have two module versions like 8.x-1.x (working for Core < 8.5) and 8.x-2.x (working for Core >= 8.5)?
Answer: There is no need for a new branch in your module as long as your own API doesn't change IMHO. The version definition will prevent that users update too early.
There is also no need to continue providing versions compatible with old core versions, they are no longer supported.
If it's just about deprecated usages, there's no reason to hurry, you can easily wait a few month/next core minor before starting to use it to give your users time to update. All those deprecated functions will only be removed in the 9.x branch, so you have plenty of time to update. It's different if core broke something in your module and you're forced to update asap or if there is a completely new API that you'd want to use.
See also last paragraph on PHP 7.1 requirement for Doctrine packages: Their PHP version dependency is similar to your Drupal core dependency.
Comment: As additional info @bojanz says: each time a new core major drops, I update the codebase and raise the minimum core requirement in info.yml and composer.json (in Commerce and other modules)


Why am I getting one too many tabs in Emacs?

Question: init.el
(setq make-backup-files nil)

(add-to-list 'load-path "~/.emacs.d/")

; Add all top-level subdirectories of .emacs.d to the load path
(progn (cd "~/.emacs.d")
       (normal-top-level-add-subdirs-to-load-path))
; Third party libraries are stored in ~/.emacs.d/extern
(add-to-list 'load-path "~/.emacs.d/extern")
(progn (cd "~/.emacs.d/extern")
       (normal-top-level-add-subdirs-to-load-path))

; Python-specific enchancements
(load-library "python")

; Zenburn color theme
(require 'color-theme-zenburn)

(color-theme-zenburn)

python.el
; use tabs in files (urgh...yelp!)
;(setq-default indent-tabs-mode t)

; tab display width of 4 columns by default
; (throw everything at the wall, and eventually something will stick...)
;(setq-default tab-width 4)  ; Normal emacs tab-width
; (setq-default c-basic-offset 2) ; python-mode.el setting
;(setq-default py-indent-offset 4) ; Use Tabs, not spaces
;(setq-default py-smart-indentation nil) ; Don't try to guess tab width

(defun customize-py-tabs ()
    (setq tab-width 4
        py-indent-offset 4
        indent-tabs-mode t
        py-smart-indentation nil
   )
)

(add-hook 'python-mode-hook 'customize-py-tabs)

; Highlight useless whitespace
(add-hook 'python-mode-hook
                  (lambda () (setq show-trailing-whitespace t)))

I'm trying to setup my emacs to tab to the right level on my python code, but it adds in extra tab. It's consistant. If there should be 4 tabs, I get 5. Any suggestions?
for example
def func:
        # This is where it puts me
    # This is where it SHOULD put be

Comment: It'll all end in tears... mark my words.
Comment: I'm using ^q tab right now. It's a pain. Too much more of this and I'll be forced to use vi. :P
Comment: What is the value of `indent-line-func` in that buffer? (Do `C-h v indent-line-func` while visiting that buffer to find out.) For me it's `python-indent-line` from python.el, and it works well enough. Looking at the implementation, I note that it will cycle through all possible tab positions, so perhaps hitting tab again will indent to the correct location.
Comment: It works correctly for me, both for newline-and-indent (C-j) and indent-region (C-M-\)  For you, does it do the same, incorrect behavior for both?
Comment: Works for me out of the box, I'm wondering which Emacs version you are using, and whether perhaps your file name `python.el` somehow shadows the system definition of `python-mode`?  Can you make it work with `emacs -q` and/or `emacs -Q` for a start?  The variables called py-something are not available in my Emacs, so I suspect you are using a different Python mode than us others, perhaps ...?  What do you get from `M-x locate-library python`?
Comment: In a python file indent-line-func is set to indent-relative. I'm running emacs 23.3.
Comment: C-j does the same thing.
Comment: The py-smart-indentation is defined for me and is nil. Python mode is "/Applications/Emacs.app/Contents/Resources/lisp/progmodes/python.elc". python-indent-offset is 4, but tab-width is 8 in python files, and 4 by default?!?
Comment: Rename your `python.el` to `python-settings.el` to be safe.
Answer: Maybe you don't need to solve this problem. Style Guide for Python Code strongly recommends using 4 spaces, why not follow it?
Comment: Not an option. This is for work and style is tab only. We follow PEP8 except for that one spot.
Answer: Any Python indentation which starts with setting tab-width to something else than 8 is doomed to bring trouble.  tab-width determines how Emacs displays the TAB character, not how far to indent in response to hitting the tab key.


What is the difference between legato and portamento?

Question: On Wikipedia Legato means: [...] the player makes a transition from note to note with no intervening silence. [...]
Source: https://en.wikipedia.org/wiki/Legato
On Wikipedia Portamento means: [...] is a pitch sliding from one note to another. [...]
Source: https://en.wikipedia.org/wiki/Portamento
It seem to me, that both, Legato and Portamento slide from one note to another. So what is the difference?
Answer: Legato is smooth transition from one note to another. Exactly that. One specific note to another specific note. Rather like how we string words together to speak sentences, or rather, phrases. If it's on, say, a trumpet, the notes will be played all in one breath, not separately tongued, usually.
Portamento is similar, but will move from one note to the next, playing other pitches in between the two notes in the process. A trombone or violin will be able to do this easily. A piano just won't. Usually portamento is quite quick, but if it was slowed right down, you would be able to hear notes 'in the cracks'.
So, portamento is a sort of legato, whereas legato is not any kind of portamento.


C++ - Is there a workaround to delegating constructors being not the only members in an initialization list

Question: class Foo
{
public:
  Foo() {}
  Foo(int i)
   : Foo(), m_bar(0) {}

private:
  int m_bar;
};

Is there a workaround to making such code valid?
Is there a way to have more than one member in the initialization list if we have a delegating constructor, and what is the reason for such a restriction on having the delegating constructor be the only member in the initialization list.
Comment: What should the compiler initialize `m_bar` to? From his perspective both statements are conflicting because a variable can only be initialized exactly once (e.g declare `m_bar` const if you don't see the issue). You can however assign another value to `m_bar` in the body of the ctor. Notice that such an assignment would happen after the initialization of `m_bar`.
Comment: While it would certainly be possible to add precedence rules for such cases to the language, i would speculate that it was deliberately left out because such things increase complexity (from both a languages and a users perspectice) without really adding any significant benefit.
Comment: @SebastianHoffmann How could that work with a non inline ctor?
Comment: @curiousguy Good point; when both ctors are implemented in different translation units, things become non-trivial
Answer: The rule that you refer to is defined in [class.base.init]/6:

A mem-initializer-list can delegate to another constructor of the
  constructor's class using any class-or-decltype that denotes the
  constructor's class itself. If a mem-initializer-id designates the
  constructor's class, it shall be the only mem-initializer; the
  constructor is a delegating constructor, and the constructor selected
  by the mem-initializer is the target constructor. The target
  constructor is selected by overload resolution. Once the target
  constructor returns, the body of the delegating constructor is
  executed. If a constructor delegates to itself directly or indirectly,
  the program is ill-formed, no diagnostic required.

Suppose a moment that the the delegate constructor could be used together with other mem-initializers:

you could invoke two different delegates.  But there can be only one construction.  So you'd have a conflict of which one to chose.
with mem-initializers after the delegation, when the delegate would finish its job, the execution of the delegating constructor would be resumed not with the body but in the remaining mem-initializers.
But mem-initializers are not like assignments where one assignement could overwrite another.  Mem-initializers invoke constructors of members.  And member variables can be constructed only once.  There would then be a conflict of how to initialize the members in the list, and which constructor to discard.
This is even worse, since both delegating and delegated constructors have to completely construct a class boject, i.e. all its members.

Here an example to clarify the problem with a member that can be initialized only once, and solutions:
class Foo
{
  const int m_bar;              // can be initalized only once
  int m_zoo;                    // must be constructed (default possible) but can be overwritten
public:
  Foo(): m_bar(1), m_zoo(2) {}  // the constant can never be changed
  Foo(int i)
   : Foo() {m_zoo=i;}           // you can still change in the body already constructed items
  Foo(int i, int j)            // comprehensive init
    : m_bar(i), m_zoo(j) {}    // (has all that delegating may want(
  Foo(char a)
    : Foo(a,2) {};             // delegate to the comprehensive ctor
};

Online demo
The delegation rule aims to keep all this simple. It just means that

there can be only one constructor that constructs the object and its members (either the constructor itself, or a delegate)
the delegating constructor just decides of the parameters of the delegate, and can add additional behavior in the constructor body
(and we all know that the body is invoked only once all the base classes and members are constructed)

So the way to make your design valid is to move all the mem-initilizer to the target constructor, and if needed use parameters of this target constructor to specify values for its mem-initializers. Or to overwrite in the body what was already initialized; but this is not always possible.
Answer: The problem is since the initializer list in a constructor must initialize every base and member (in declaration order) that has it's own constructor (default constructor if not otherwise specified), that : Foo() must have already done so, and calling some members constructor twice would be bad.
I suppose you could argue in the case of primitives that might be left uninitialized that it could be allowed, but then in such cases assigning them within the function body would be equivalent.


How to secure open journal system original submission files

Question: I have installed ojs in my own server. In the installation process, it is required to create a folder that is writable by php (apache = www-data), but not accessible from the browser. The folder is used to save uploaded manuscripts, that must not be viewable for the public, but must be readable by the software itself. I changed httpd.conf file to deny listing of the files in the folder, but the problem does not seem to be completely solved. In fact, although the file names are random, if a malicious or curious user has the exact file name of the original manuscript, she/he can download the file. Please note that there are numerous such manuscripts now in my server (ubuntu 12.04.4). Is there any way I can deny them from downloading (at least for unauthorized users not registered as editor)?
Answer: The README told you what to do. The relevant parts:
    * Install OJS so that the files directory is NOT a subdirectory of
      the OJS installation and cannot be accessed directly via the web
      server.

    3. Create a directory to store uploaded files (submission files, etc.)
       and make this directory writeable. It is recommended that this
       directory be placed in a non-web-accessible location (or otherwise
       protected from direct access, such as via .htaccess rules).

This means the files directory you use for uploads should not be under the DocumentRoot. Of course you have to specify its location in config.inc.php if you already completed the installation.
[files]

; Complete path to directory to store uploaded files
; (This directory should not be directly web-accessible)
; Windows users should use forward slashes
files_dir = files

Comment: I have done the instruments. Its now in /var/www/files folder, while the installation is in the /var/www/public_html. How to make all manuscript PDF files accessible only for authorized users. If even, this is possible?
Comment: It sounds like you have already done it correctly.


Compare two columns from different tables

Question: I know that this question has been asked several times and I did read them all.   However, my situation is little different I can still can't get the right results with my SQL statement below.
I have two tables as shown below:
TABLE A
######################################################################
   |   ID   | IP_Address    | Username  | Comments
----------------------------------------------------------------------
    1       128.        abc     travel to US
    2       127.        dzd     author
    3       127.        abc     It's not redundant at all. Not offering a single function
    4       124.        deb     I just lost laptop.  How do I report it?
-----------------------------------------------------------------------

TABLE B
######################################################################
   |   keywords     |
----------------------------------------------------------------------
    author
    How do I report
-----------------------------------------------------------------------

My intention is to pull out all records in TABLE A when the Comments column partially matches one of the keywords in TABLE B.
Here is the query:
SELECT ID, IP_Address, UserName, Comments FROM TABLEA
FULL JOIN TABLEB
ON TABLEA.Comments LIKE TABLEB.Keywords
WHERE TABLEA.Comments IS NOT NULL AND TABLEB.Keywords IS NOT NULL

It works but it only pulls out the EXACT match, not a part of the comments.
In my sample, it pulls out "author" record but not "I just lost laptop.  How do I report it?" record.
Is there a way to twist my query to meet my requirements?
Thanks
JPL
Answer: Add % to the LIKE clause
SELECT ID, IP_Address, UserName, Comments FROM TABLEA
FULL JOIN TABLEB
ON TABLEA.Comments LIKE '%' + TABLEB.Keywords + '%'
WHERE TABLEA.Comments IS NOT NULL AND TABLEB.Keywords IS NOT NULL

Comment: As simple as it is but I could not think of! Sometimes, just a break would fix all problems!
Answer: This will do what you need.
SELECT ID, IP_Address, UserName
FROM TABLE1 T1
CROSS APPLY (SELECT Keywords FROM Table2) T2
WHERE CHARINDEX(T2.Keywords,T1.Comments) >0

The CROSS APPLY could be replaced with the full join, but cross apply works better if there are more columns in the 2nd table.
Comment: Thanks LeeG.  Your results completely match with RADAR's suggestion.

Thanks much.


capture and compare images

Question: is there a way to grab a screen capture of a specific section of the screen and compare it to another image already store in disk. And if the image is identical, it would prompt something.
Answer: Check http://www.developerfusion.com/code/4630/capture-a-screen-shot/ for examples on how to capture the screenshot.
The image comparison is a lot more complicated. The image that is stored on disk might have a different size, a different aspect ratio, or a different depth. Unless you can be sure that the screenshot and the image on the disk are absolutely identical, you'll have to look at a method that identifies similar images.
Take a look at the pHash Demo, which takes two images and outputs a similarity score. The algorithm it uses is pretty straightforward, and is available on the website.
Answer: If you are trying to compare an image (or part of it) with another images, I searched internet and found that leadtools has correlation functions that compare an image with all the areas of the same dimensions in another image. For more information, see this link: http://www.leadtools.com/help/leadtools/v175/dh/po/leadtools.imageprocessing.core~leadtools.imageprocessing.core.correlationcommand.html
OR
This project may be what you're looking for:
https://github.com/cameronmcefee/Image-Diff-View-Modes/commit/8e95f70c9c47168305970e91021072673d7cdad8

capture and compare images


AWS ELB terminates instance when using offline.htm for IIS

Question: Currently we using AWS ELB with multiple instances for hosting our IIS website(s).
When using app_offline.htm to display a maintenance message, the ELB healthcheck will terminate all the instances. This is due to the fact that the app_offline.htm page will return a 503 message and the ELB will determine this a non healthy host.
Is there a way to gracefully solve this problem, without modifying the health check (time) parameters within the AWS ELB. (and not deploying a "maintenance site")
thanx in advance.
Comment: Are you running your instances under an Auto Scaling group? The ELB itself will not terminate instances, but an Auto Scaling group using an ELB Health Check can do so.
Answer: Yes, use the EC2 health checks instead of the ELB health checks in your AutoScaling group, at least while in maintenance. Otherwise, your instance will be terminated when the ELB Health Check fails due to the 503.
You can also remove the instance under maintenance from your AutoScaling group.
In the AutoScaling docs, see:
Temporarily Removing Instances
Health Checks
Comment: Thanx, i hoped that there was an easier way. I will take a look to change the health check


Will lock() statement block all threads in the process/appdomain?

Question: Maybe the question sounds silly, but I don't understand 'something about threads and locking and I would like to get a confirmation (here's why I ask).
So, if I have 10 servers and 10 request in the same time come to each server, that's 100 request across the farm. Without locking, thats 100 request to the database.
If I do something like this:
private static readonly object myLockHolder = new object();
if (Cache[key] == null)
{
   lock(myLockHolder)
   {
      if (Cache[key] == null)
      {
         Cache[key] = LengthyDatabaseCall();
      }
   }
}

How many database requests will I do? 10? 100? Or as much as I have threads?
Comment: Thank you all for excellent explanations, I tested it and it works as you all suggested - 10 db requests.
Answer: You have a hierarchy of objects:

You have servers (10)
On each server you have processes (probably only 1 - your service/app pool)
In each process you have threads (probably many)

Your code will only prohibit threads within the same process on the same server access to modify the Cache object simultaneously. You can create locks across processes and even across servers, but the cost increases a lot as you move up the hierarchy.
Using the lock statement does not actually lock any threads. However, if one thread is executing code inside the lock (that is in the block of code following the lock statement) any other thread that wants to take the lock and execute the same code has to wait until the first thread holding the lock leaves the block of code and releases the lock.
The C# lock statement uses a Windows critical section which a lightweight locking mechanism. If you want to lock across processes you can use a mutex instead. To lock across servers you can use a database or a shared file.
As dkackman has pointed out .NET has the concept of an AppDomain that is a kind of lightweight process. You can have multiple AppDomains per process. The C# lock statement only locks a resource within a single AppDomain, and a proper description of the hierarchy would include the AppDomain below the process and above the threads. However, quite often you only have a single AppDomain in a process making the distinction somewhat irrelevant.
Comment: Slight correction "Your code will only prohibit threads within the same AppDomain". C# statics are bound to an AppDomain, not a process.
Answer: The C# lock statement locks on a particular instance of an object (the object you created with new object()). Objects are (in most cases) not shared across AppDomains, thus if you are having 10 servers, 10 threads can run concurrently access your database with that piece of code.
Answer: Lock is not blocking threads.
It is locking some instance of an object. And each thread which tries to access it is blocked.
So in your case each thread which will try to access myLockHolder will be locked and not all the threads.
In other words we can say that Lock statement is syntactic sugar for using Critical Section.
Like you can see in MSDN :

lock(expression) statement block
where:
expression Specifies the object that you want to lock on.  expression must
  be a reference type. Typically,
  expression will either be this, if you
  want to protect an instance variable,
  or typeof(class), if you want to
  protect a static variable (or if the
  critical section occurs in a static
  method in the given class).
statement block The statements of the critical section.
Answer: lock will block all threads in that application from accessing the myLockHolder object.
So if you have 10 instances of the application running you'll get 10 requests to the server while the object is locked on each.  The moment you exit the lock statement, the next request will process in that application, but as long as Cache[key] is not null, it won't access the database..
The number of actual requests you get depends on what happens here:
  if (Cache[key] == null)
  {
     Cache[key] = LengthyDatabaseCall();
  }

If LengthyDatabaseCall(); fails, the next request will try and access the database server and retrieve the information as well, so really your best case scenario is that there will only be 10 requests to the server.
Answer: Only the threads that need access to your shared variable at the moment another thread is using it will go into a wait state.
how many that is at any give time is hard to determine.
Answer: Your DB will get 10 requests, with odds being good that requests 2-10 run much faster than request 1.


Search API Attachments not working

Question: I'm running Drupal 7.12. I have a requirement to index files attached to nodes. (DOC, PDF, XLS, etc).
After quite a bit of trail and error, reading and searching I have been unable to get any of the attachment file indexing modules to work.
Search API Attachments  seems the most promising but after configuring it doesn't seem to index any of the documents. It does call Tika to process attachments to new nodes, but doesn't seem to re-index any existing nodes. Searching on any file contents yields no results.
Any thoughts on what I should investigate to track this down would be greatly appreciated. Anyone running this module successfully? If so how did you configure it.
More info:
I followed these instructions: http://permalink.gmane.org/gmane.comp.php.drupal.support/22390
To see if I can track this down:

I configured a fresh installation of Drupal 7.12.
I installed Search API, Search API DB and Search API Attachments

projects/search_api_db-7.x-1.x-dev.tar.gz
projects/search_api_attachments-7.x-1.2.tar.gz
projects/search_api-7.x-1.0.tar.gz

I installed Tika and verified that it is working per instructions.
I created a field called Attachment1 of type File for the "Article" content type: structure -> content types -> article. label: Attachment1 name: field_attachment1, field: File.
I created a search server in Configuration -> Search and metadata -> search api using the database service class.
I then edited the Default Node Index to use the search server I defined and enabled it.
I then went to the Default Node Index fields and using "Add Related Fields" added Attachment1 » The file.
I checked the box next to Attachment1 >> The file and Attachment content: field_attachment1
I created a single Article and attached a word document to it.
I ran the cron service from the admin menu.
In the database I ran select * from search_index and I notice that only the terms from the node content are present, nothing from the document that I uploaded.
I verified that Tika was being called by adding the syslog call prior to shell_exec which yields:

Mar 17 13:32:06 xeon httpd: Calling Tika: java -Dfile.encoding=UTF8 -cp '/usr/local/tika' -jar '/usr/local/tika/tika-app-1.0.jar' -t 'http:///drupal/sites/default/files/Resume_0.doc'

However, if I select to re-index the site by going to Configuration -> Search and metadata -> search settings -> clear index and re-run cron I notice that Tika is NOT being called.
Also I notice that selecting clear index does not affect the search_index table. (Should it?)
I have separately verified that Tika is properly extracting the text from the document by logging it to a file prior to the call.
My feeling is that I'm missing something obvious.
Comment: I followed these instructions: http://permalink.gmane.org/gmane.comp.php.drupal.support/22390
Comment: Crossposted in the drupal issue tracker: http://drupal.org/node/1491356
Answer: Ok, this looks like part of this is a case of PEBKAC. Or maybe could be considered an issue of documentation.
It looks like the default search box form does not interface with search API and that in order for the search API indeces to be used you must use the Search API Pages module.
However, re-indexing definitely does NOT re-index attachments on existing nodes. I'm not sure whether it's supposed to or not but that is what threw me to believe it was not working.
Answer: Did you select the "File Attachments" option in the Workflow tab of your index?
Comment: yes, I did. It turns out the mistake I was making was not using the Search API Pages module for the search box. I had mistakenly thought the search API would "take over" the existing search box. (Unless that's how it's supposed to work.)

Search API Attachments not working


How to style the help text that appears at the top of pages?

Question: I'm using the "Piano" theme, and I just don't like the way it displays the help text that would normally appear as a red box when there's an error or a green box for information or to indicate that something processed successfully. I really just want it to be back to normal because right now it's easy to miss and it kind of blends in to the rest of the text.
Answer: What you're looking for is the $messages variable, which is given the following styling by core, yet seems to be removed from that contributed theme:
div.status {
  background-color: #f8fff0;
  border-color: #be7;
  color: #234600;
}
div.warning {
  background-color: #fffce5;
  border-color: #ed5;
  color: #840;
}
div.error {
  background-color: #fef5f1;
  border-color: #ed541d;
  color: #8c2e0b;
}


How to set default connection parameters for DBLINK on Postgresql

Question: I have Postgresql 9.5 installed on Ubuntu and need to use dblink.  However I am using port 5433 (set in postgresql.conf) but dblink always defaults to port 5432.  I know you can specify the port in the dblink parameters, but this is massive redundancy when I want to use the default port of my instance.
There is a way of telling dblink to use a specific port by default.  I know this because I have successfully changed it in the past - but can't for the life of me remember how I did it.  I have tried setting the PGPORT environment variable and rebooting.  I have tried recreating the extension.  I have tried reinstalling postgresql-contrib.  None of this has made a difference.  I have a feeling that there is some obscure file I edited but can't remember what, where or how.
Any suggestions of how to change the default connection parameters for dblink?
Answer: Got it!
It IS done by changing the environment variable, but this is not an environment variable in the sense that a Windows user would understand it (so changing /etc/environment does not work and neither does any other normal nix-style setting of global environment variables).
To change the default connection parameters for dblink you need to add PGPORT=5433 (in my case) to /etc/postgresql/9.5/main/environment.  The annoying thing with Ubuntu install of Postgres is that I have at least three versions of all these sorts of files (including pg_HBA.conf and so on).  The ones in /etc/... are mostly not read apart from in this case.  It's the ones in my data directory (which for space reasons is in a non-default location).  So, for anybody else having the same issue check /etc, /var, /your-data-directory.


Multistorage with avro?

Question: I have a single file containing multiple avro records. Each record contains a unique "name". How do I load and store files such that each file represents a record that corresponds with a given name?
Here is my avro schema:
<code>{
    "type": "records",
    "name": "XXItem",
    "namespace": "com.xxx.xxx",
    "fields": [
        {
            "name": "data",
            "type":  {"type": "map", "values" : ["string", "long", "int"]}
        }
    ]
}
</code>
Answer: A quick check seems to indicate that avro, is simply using JSON for data storage.
By looking for solutions for handling JSON in general, you should be able to come up with something that works for you.
This could be a starting point: Hadoop for JSON files

Multistorage with avro?


Segfault from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0

Question: I am trying to write a little program to encrypt something with OpenSSL and AES in CBC mode.
Here is my code :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <openssl/aes.h>
#include <openssl/rand.h>

// main entrypoint
int main(int argc, char **argv)
{

    unsigned char *aes_key = malloc(32*sizeof(unsigned char));
        printf("Enter a 32 char key\n");
        scanf("%s", aes_key);
        if ((sizeof(aes_key)/sizeof(aes_key[0])) != 8) {
            fprintf(stderr,"you didn't write 32 char\n");
            return -1;
        }

    uint64_t msg = 30849384302932039;

    /* generate input with a given length */
    unsigned char *aes_input = malloc(100*sizeof(unsigned char));
    sprintf(aes_input, "%lu", msg);

    /* init vector */
    unsigned char *iv = (unsigned char*)malloc(sizeof(unsigned char) *AES_BLOCK_SIZE);
    RAND_bytes(iv, AES_BLOCK_SIZE);

    // buffers for encryption and decryption
    unsigned char *enc_out = malloc(sizeof(unsigned char)*16);
    sprintf(enc_out, "%d", 0);

    AES_KEY enc_key, dec_key;
    AES_set_encrypt_key(aes_key, 32, &enc_key);
    AES_cbc_encrypt(aes_input, enc_out, 16, &enc_key, iv, AES_ENCRYPT);

    printf("original:\t + %s\n",aes_input);
    printf("encrypt:\t + %s\n",enc_out);

    return 0;
}

I compile it with gcc -g test.c -lcrypto -o test but when I run it, I get a segmentation fault and gdb indicates me :
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7a7b9a0 in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0

After trying to debug it, I found that the line AES_cbc_encrypt(aes_input, enc_out, 15, &enc_key, iv, AES_ENCRYPT); is responsible of the segfaut... But, all arguments seem initialized, I tried to print their values and I didn't get any problem ?
So I don't realy get what I am doing wrong, could someone help me ? Thank you very much :)
Comment: segmentation fault has so many reasons, there are no call stack displayed ? first you need to debug your program to see at which line it crashes ...
Comment: Well I just made it and it seems that it is the line  `AES_cbc_encrypt(aes_input, enc_out, 15, &enc_key, iv AES_ENCRYPT)` that makes my program crash. I will modify my post to indicate it
Comment: You need to go further more inside that function.
Answer: unsigned char *aes_key = malloc(32*sizeof(unsigned char));
...
if ((sizeof(aes_key)/sizeof(aes_key[0])) != 8) {

This is not getting the size of the array (32), but the size of a pointer to unsigned char.
Same for
const uint64_t encslength = ((sizeof(aes_input)/sizeof(aes_input[0]) + AES_BLOCK_SIZE) / AES_BLOCK_SIZE) * AES_BLOCK_SIZE;

Take a look to Question 7.28 of C FAQ
Comment: The source of your segfault is probably `const uint64_t encslength = ((sizeof(aes_input)/sizeof(aes_input[0]) ...` because `aes_input` is a pointer (not an array)
Comment: Thank you for your answer. Well so that means that my test is useless, right ? But I don't know how to test it properly... Anyway I don't think that's the source of my segfault
Comment: Well I replaced `encslength` by `100` in my code and I still have a segfault at the line `AES_cbc_encrypt(aes_input, enc_out, 15, &enc_key, iv AES_ENCRYPT)`. However thank you for your help
Comment: My bad, I changed it to 16 but still the same problem. I will try to check more precisely the function `AES_cbc_encrypt`
Comment: @AlterMann AES block size is always 128 bits / 16 bytes.


odbc connection and oracle server connection in crystal reports

Question: Please suggest what is the difference between odbc connection and oracle server connection in crystal reports while connecting to oracle database.
Please suggest when we will use both of them
Answer: ODBC works with "rectangular" or 2D data. If you have spatial data, you will need to use the native Oracle client. Our DBA also says Oracle ODBC has to convert data types while a native client would be "apples to apples".
If you have a Crystal Server accessing an Oracle database, use the native Oracle client. On your workstation, also run the same client whether ODBC or Native as the server.


julia fast lookup of a list of array values

Question: I have a lookup table in the form of a 2d array and a list of indices (in the form of two 1d arrays xs, ys) at which I would like to evaluate the lookup table. How to accomplish this in a fast manner?
It looks like a standard problem, however I found nothing about looking up array values at a general list of indices (e.g. not a cartesian product) in the docs. I tried
result = zeros((10^6,))
for i in [1:10^6]
    x = xs[i]
    y = ys[i]
    result[i] = lookup[x, y]
end

Besides looking a bit cumbersome, this code is also 10 times slower then an equivalent numpy code. Also it looks like a standard problem, however I found nothing about looking up array values at a general list of indices (e.g. not a cartesian product) in the docs.
So what would be a fast alternative to the above code?
Comment: It's slow only because it's not inside a function.
Comment: ok avoid global variables in speedtest lesson learned.
Answer: You can try broadcast_getindex (see http://julia.readthedocs.org/en/latest/stdlib/arrays/#Base.broadcast_getindex).
Otherwise, it looks like your code should be pretty efficient if you just change [1:10^6] to 1:10^6.
Comment: Also be sure to wrap it in a function instead of running in global scope. That's going to be dog slow: http://julia.readthedocs.org/en/latest/manual/performance-tips/#avoid-global-variables
Comment: Thanks, wrapping it in a function and iterating over a UnitRange instead of array gives roughly same speed as in numpy. Will look into broadcast_getindex next.
Answer: Here are the updated links for Base.getindex (see https://docs.julialang.org/en/v1/base/collections/#Base.getindex). The broadcasted implementation found here.


Chrome ( 103 ) dev tool doesn't show "progress::-webkit-progress-value"

Question: Chrome ( 103 ) dev tool doesn't show below values under Styles tab.
I could see this value in FF ( 102 ) under dev tool middle section at top.
Is this bug with Chrome or they have changed location somewhere else ?
progress::-moz-progress-bar {
  border-radius: 12px;
  background: radial-gradient(6px at 96%, white, white 4px, transparent),
    linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
}

progress::-webkit-progress-bar {
  background: transparent;
}
progress::-webkit-progress-value {
  border-radius: 12px;
  background: radial-gradient(6px at 98%, white, white 4px, transparent),
    linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
}

Answer:
Make sure you have enabled "Show user agent Shadow DOM" in the Settings > Preferences > Elements

You need to have appearance: none on the progress element for the pseudo elements to take effect. Then you can inspect the shadow DOM and see the corresponding values in the Styles pane.


Ratios with A.P.

Question: Two A.P.'s have the same number of terms. The ratio of the last term of the first progression to first term of
the second progression is equal to the ratio of the last term of the second progression to the first term of the
first progression and is equal to 4, the ratio of the sum of the n-terms of the first progression to the sum of the
n-terms of the second progression is equal to 2.
1) What is the ratio of Common Difference?
2) What is the ratio of n-th term?
3) What is the ratio of first term?
ANSWER:
n1=n2
tn1/a2 = tn2/a1 = 4
Sn1/Sn2 = 2
Since A.P. deals with addition, I don't know how to cancel the unnecessary terms in the ratio.
Any help would be greatly appreciated!!!
Answer: HINT: if $$\frac{a}{b}=\frac{c}{d}$$ then each is equal to $\frac{a+c}{b+d}$ and $\frac{a-c}{b-d}$
Answer: See if two ratios are given then we can use two rules componendo ,dividendo so here we write $a_n=a+(n-1)d$ ,$a'_n=a'+(n-1)d'$ so we want $d/d',\frac{a+a+(n-1)d}{a'+a'+(n-1)d'}$ so first one is $\frac{d}{d'}=\frac{a+(n-1)d-a}{a'+(n-1)d'-a'}=d/d'=4$ same logic goes for other

Ratios with A.P.


October Azure SDK broken when inserting a string with a trailing space

Question: Has anyone worked out a fix for this problem. When using the storage emulator and inserting a row into table storage then the row insert fails if there is a space at end of the field.
This was pointed out two weeks ago but I still see no updates from Microsoft on this? Does anyone know of a fix ?
Microsoft forum link
Stackoverflow link
Please don't close this question. Having something out here on Stackoverflow might help save someone from the two days I spent trying to work out what was wrong.
Comment: @smarx, you are right, but one could implement trim() either in client code, or in the client lib. Or just use the real storage meanwhile. Fact is that this issue needs a fix, and that this fix is not going to happen in the next hours.
Comment: if you are in a hurry you can [fix it yourself](https://github.com/WindowsAzure/azure-sdk-for-net), but I would rather work with real storage meantime.
Comment: @astaykov, you linked to the client library source code, but this issue is with the storage emulator, right?
Answer: This issue has been fixed in later versions of the Windows Azure SDK. Install the latest version to fix the problem.
http://www.windowsazure.com/en-us/downloads/


Insert a WHERE conditional in Table creation code for AWS Athena

Question: I need to create a table with a specific condition that can be updated when the bucket is updated. This is an example:
CREATE EXTERNAL TABLE IF NOT EXISTS `default`.`cards-test` (
  `id` bigint,
  `created_at` timestamp,
  `type` string,
  `account_id` bigint,
  `last_4_digits` string,
  `is_active` boolean,
  `status` string,
  )
ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION 's3://something/cards-bucket/'
TBLPROPERTIES ('classification' = 'parquet');

Now, let's say I want a WHERE clause that says WHERE type = 'type_1', can I insert this here? If so, where?
If not, how should I create a table with such specific conditions out of the buckets?
Answer: No, as doc show the syntax for CREATE TABLE - there is no option to provide filtering the data.
What you can do - create another table via CREATE TABLE AS syntax with filtering applied:
CREATE TABLE cards-test-type_1 WITH (
  ...
) AS
SELECT
  *
FROM
  cards-test
WHERE type = 'type_1'

Or create a view:

Creates a new view from a specified SELECT query. The view is a logical table that can be referenced by future queries. Views do not contain any data and do not write data. Instead, the query specified by the view runs each time you reference the view by another query.

CREATE VIEW cards-test-type_1 AS
SELECT
  *
FROM
  cards-test
WHERE type = 'type_1'

Comment: Understood, thank you. But, I tried a similar approach before, and unfortunately this table doesn't get updated when the Bucket 's3://something/cards-bucket/' gets updated. Is that doable?
Comment: @AquilesPáez as written in the [Using CTAS and INSERT INTO for ETL and data analysis](https://docs.aws.amazon.com/athena/latest/ug/ctas-insert-into-etl.html) doc - _"When new data becomes available, you can use an INSERT INTO statement to transform and load the data into the table that you created with the CTAS statement."_ - it seems there is no build in option to autoupdate the CTAS table.


Registering to 'GCAllocationTick_V1' CLR event from C#

Question: I'm trying to add some profiling capabilities to a server application.
I have found 'GCAllocationTick_V1' event and I would like to monitor it and react to it in code. Unfortunately, I couldn't find any information regarding this topic.

Actually, I found out that my production server sometimes allocates ~1GC/Sec, which causes the GC to go nuts. I couldn't find any pattern to this behaviour and it never happened on my DEV ENV. Thus, I'm searching for a way to catch the memory allocation LIVE.
Be my guests and offer any other ideas on how to find the source to the problem.
Thanks,
O
Answer: Did you see the EventLogWatcher class?
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventing.reader.eventlogwatcher(v=vs.90).aspx
(From C# - Subscribing to a ETW event channel?)
An example found here:
http://blogs.msdn.com/b/danielvl/archive/2009/02/02/how-to-consume-etw-events-from-c.aspx


Why $0 \cdot 0=1$ not allowed even in a set S that cancellation property failed to be applied?

Question: Recently I was studying a linear algebra class which introduce some basic concepts of fields, groups
Once again I tried to divide by zero by constructing an algebraic structure from scratch using just a few axioms because I stumbled across this when browsing the site
We knew that the important theorem in fields that
$$0\cdot n=0$$
holds for all n
and one of the shortest proof of this is as follows
$$\text{Take any }a \in S$$
$$a\cdot 0=a\cdot (0+0) \text{ (Additive identity)}$$
$$a\cdot 0=a\cdot 0+a\cdot 0 \text{ (Distributivity of }\cdot n\text{ over }+)$$
$$a\cdot 0=0 \text{ (Cancellation using additive inverses of }a\cdot 0) $$
$$\square$$
In my following attempt, I have not assumed anything for this set $S$ except
$$\begin{matrix}
\text{Associativity} \\
\text{Additive and multiplicative identities}\\
\text{Multiplicative inverses}\\
\text{Distributivity}
\end{matrix}$$
and the following was set as an axiom inspired from the link
$$0\cdot m=n \text{ (Call it "Zero axiom") }$$
The following 13 Theorems was then obtained (in order) from $S$ after some algebra
$$\begin{matrix}
\text{Theorem 0.1,0.2,0.3} \\ 0 =n\cdot m^{-1} \\ n^{-1}\cdot 0=m \\m\cdot n \cdot m^{-1}=m \cdot 0
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 1} \\ m+n=m \\ \text{Proof:  } m=1 \cdot m=(1+0)\cdot m=m+0\cdot m=m+n
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 2} \\ n+n=n \\ \text{Proof:  } n+n=(0 \cdot m)+(0 \cdot m)=(0+0)\cdot m=0\cdot m=n
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 3} \\ n+m=m \\ \text{Proof:  } n+m=(0 \cdot m)+m=(0+1)\cdot m=1\cdot m=m
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 4} \\ m=m+1 \\ \text{Proof:  } n\cdot m=(n+0) \cdot m=n\cdot m+0\cdot m=n\cdot m+n=n\cdot (m+1)\Rightarrow m=m+1
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 5} \\ 1=1+m^{-1} \\ \text{Proof:  } m\cdot n=m \cdot (n+0)=m\cdot n+m\cdot 0=m\cdot n+m\cdot n\cdot m^{-1}=m\cdot n \cdot (1+ m^{-1})\Rightarrow 1=1+m^{-1}
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 6} \\ (1+n^{-1})\cdot 0=m^{-1} \\ \text{Proof:  } (1+n^{-1})\cdot 0=0+ n^{-1}\cdot 0=n^{-1}\cdot 0=m^{-1}
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 7} \\ n\cdot 0=0 \\ \text{Proof:  Multiply n on the left both sides of Theorem 6 and then use Theorem 0.1}
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 8} \\ n\cdot n=n \\ \text{Proof: Using Theorem 7,  } n\cdot n=n \cdot (0 \cdot m)=(n \cdot 0)\cdot m=0 \cdot m=n
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 9} \\ m^{-1}=0 \\ \text{Proof: Apply Theorem 7 to Theorem 0.2}
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 10} \\ n=1 \\ \text{Proof: Multiply m on the right both sides of Theorem 9 and then use the Zero Axiom} \\ \text{and multiplicative inverse property}. m\cdot m^{-1}=1
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 11} \\ 1+1=1 \\ \text{Proof: Apply Theorem 10 to the Zero Axiom followed by} \\ \text{Theorem 9 to obtain } \\1=0\cdot m=(0+0) \cdot m=0\cdot m + 0\cdot m=m^{-1} \cdot m+m^{-1} \cdot m=1+1
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 12} \\ m+m=m \\ \text{Proof: Factor out m and then apply Theorem 11}
\end{matrix}$$
$$\begin{matrix}
\text{Theorem 13} \\ 1+m=m \\ \text{Proof: Apply Theorem 10 to the Zero Axiom and then factor out m to obtain}\\ 1+m=0\cdot m+m=(0+1)\cdot m=1\cdot m=m
\end{matrix}$$
Sumarise all the findings in a Caley table we get the following:

Now since m remains unspecified by the axioms of $S$, if $m=0$ then we got a contradiction in Theorem 1 and Theorem 4
$$\begin{matrix}
\color{red}{\text{Theorem 1 & 4} \\ 0+1=0\Rightarrow 1=0 \\ 0=0+1\Rightarrow 1=0
}\end{matrix}$$

However I don't understand, $\square$ was never proven in $S$ due to lack of additive inverses to apply cancellation property (and $S$ is possibly non integral domain, because $m \cdot m$ is unspecified and can be set to $0$ thus cancellation may not work in $S$).
But the contradictions of S clearly suggests that $\square$ must still be able to be proved in $S$ even without the cancellation law
Question:Why $$0\cdot 0=1$$ is not allowed, even if we lacked the cancellation law in this set to prove that $\square$ holds for all elements?
Comment: Tried to read this (except the images) a few times, and am confused, possibly because the symbols ($n$, $n0$, $m$) are defined only implicitly or after they are used, or their meanings change from place to place. It also seems your entire thought process is shown (including dead ends). It's assumed $+$ is commutative, but its Cayley table isn't symmetric. You write "$0 = 1$ is a contradiction", which isn't true; it just means you have an algebraic system with only one element (which is what you'd expect if $0$ is invertible). Perhaps the last observation (partially) answers your question?
Comment: Not clear what you are asking. Unless you are asking for a minimal set of field axioms from which it follows that $0x=0$ for all field elements $x$ (and if you meant to say that, why not just do so?), I don't think there is anything clear that you _could_ be asking; it is just confused. Voting to close.
Comment: Please shorten this down to the essential minimum.
Comment: The image is pretty illegible.
Comment: The question was edited and the major issue highlighted now in the title, refined with goblin's answer. I hope it is legible enough
Answer: I'm not sure what the question is, but the easiest way to prove $a0=0$ from the field axioms is:
$$0+a0 = a0 = a(0+0) = a0 + a0$$
$$\therefore 0 + a0 = a0 + a0$$
$$\therefore 0 = a0$$
The same argument goes through from the following axiom set:

take the axiom list for semirings with $0$. (Google "semiring axioms" if you don't know them).
delete $a0=0$ from the list to avoid triviality
adjoin the additive cancellation law:

$$a+x = a+y \rightarrow x=y$$
Note that, in semiring theory, we usually just take $a0=0$ as one of the axioms. This makes perfect sense, because $a0 = 0$ actually completes the distributive law. Can you see the pattern?
$$a(x+y+z) = ax+ay+az$$
$$a(x+y) = ax+ay$$
$$a(x)= ax$$
$$a0 = 0$$
Hint: The empty sum is $0$.
Comment: I am in the middle of editing the question now to highlight the problem given the comments said the image is too confusing.

Specifically, does the additive cancellation law require additive inverses to exist?
Comment: @Secret, good question; no, the classic example is that $\mathbb{N}$ satisfies the additive cancellation law, but no element of $\mathbb{N}$ has an additive inverse, except $0$ of course.


Seeking suggestions for summarizing and visualizing data

Question: I have a dataset that includes individual responses to a series of questions.
Participants played a game with one of two roles (hider, seeker) and indicated their response with a binary variable (0:BLUE, 1:RED).
There were 4 within subject conditions and 3 between subject conditions.
I would somehow like to graphically summarize aggregate patterns in individual responses; i.e. I would like to summarize common patterns in each condition.  For example, to see how many participants gave the same answer in each condition, across conditions, etc.
So I'm thinking of some kind of frequency distribution, but for each individual question. So probably some kind of multidimensional grid would be best.
Any suggestions?
Comment: By "4 within subject conditions" do you mean 1 within subject variable with 4 values? Or 4 variables with an unspecified number of values each? Likewise for 3 between subject conditions.
Comment: @xan 1 within subject variable with 4 values and 1 between subject variable with 3 conditions
Answer: I like spider-web (radar/star) plots for multiple variables. The Swedish Hip Arthroplasty Register which I work with have nice spider plots that convey multiple variables nicely:

For an example on how to create them I've found the plotrix package (R), their example(radial.plot) has an example that shows how to create the plot:
<code>ion.names<-c("Na","Ca","Mg","Cl","HCO3","SO4"
ions<-c(3.2,5,1,3.1,2.1,4.5)
radial.plot(ions,labels=ion.names,rp.type="p",main="Dissolved ions in water",
            grid.unit="meq/l",radial.lim=c(0,5),poly.col="yellow")
</code>
diamondplot() in the same package may also be an alternative.

UPDATE

I've looked at the dataset and I've tried to figure out how to group the variables:
<code># I've saved the file as a csv so that it's easier to import it
library(foreign)
my_data <- read.csv(file.choose(), sep=";")

# Create a new clean dataset
# merge the different variable 4 future creation of the outcome variable
my_cleaned_data <- data.frame(id=my_data$subject.id,
  role=my_data$role,
  no_GREEN=my_data$no..GREEN,
  no_RED=my_data$no..RED,
  # This creates a variable where 1 == red and 2 == blue,
  # any other value indicates an error, se below
  org_colour=
  ((my_data$Colour.of.ball.from.Urn.1=="red")*1 + (my_data$Message.received=="red")*1 +
   (my_data$Colour.of.ball.from.Urn.1=="blue")*2 + (my_data$Message.received=="blue")*2),
  decision_colour=
   ((my_data$Decision.as.Hider=="RED")*1 + (my_data$Decision.as.Seeker=="RED")*1 +
    (my_data$Decision.as.Hider=="BLUE")*2 + (my_data$Decision.as.Seeker=="BLUE")*2))

# There are some empty rows ==> remove all rows without id
my_cleaned_data <- subset(my_cleaned_data, id > 0)

# Check that only 1 & 2
table(my_cleaned_data$org_colour)
table(my_cleaned_data$decision_colour)

# Factor and label the original colours
#  - not really necessary step but it's always nice to know your data
my_cleaned_data$org_colour = factor(my_cleaned_data$org_colour, levels=c(1, 2), labels=c("red", "blue"))
my_cleaned_data$decision_colour = factor(my_cleaned_data$decision_colour, levels=c(1, 2), labels=c("red", "blue"))

# Create the outcome variable
my_cleaned_data$same_colour = my_cleaned_data$org_colour==my_cleaned_data$decision_colour

# Aggregate by the variables that your interested in
# This part gets an average for the same colour & that id
# I'm a little uncertain if no_GREEN may affect the average for that subject
# since it is a variable that may change within the subject and the whole point
# of this part is to aggregate by the id variable
t <- aggregate(same_colour ~ id + role + no_RED + no_GREEN, data=my_cleaned_data, mean)

# These are probably the outputs that you want to put into your graph
# use the role data to sort out the different parts of the spider-web graph
res.base <- aggregate(same_colour ~ role, data=t, mean)
res.no_RED <- aggregate(same_colour ~ no_RED + role, data=t, mean)
res.no_GREEN <- aggregate(same_colour ~ no_GREEN + role, data=t, mean)

# Create the output for the spider web graph
# I guess this is the lazy solution, there
# probably is a much speedier solution out there
# I find though sometimes that a little more code
# often enhances the readability
hider_data <- subset(res.no_RED, role=="hider")
hider_data_output <- hider_data$same_colour
data_labels <- paste("No. RED:", hider_data$no_RED)
hider_data <- subset(res.no_GREEN, role=="hider")
hider_data_output <- c(hider_data_output, hider_data$same_colour)
data_labels <- c(data_labels, paste("No. GREEN:", hider_data$no_GREEN))

seeker_data <- subset(res.no_RED, role=="seeker")
seeker_data_output <- seeker_data$same_colour
seeker_data <- subset(res.no_GREEN, role=="seeker")
seeker_data_output <- c(seeker_data_output, seeker_data$same_colour)

# Create a 2-row matrix since we
# want to output two polygons
data_output <- rbind(seeker_data_output, hider_data_output)

library(plotrix)
# The plot with two transparent polygons, one yellow
# and the other one blue
# If you omit the .5 in limits you get more lines
# you could also add .25 & .75
radial.plot(data_output,
  labels=data_labels,
  rp.type="p",
  radial.lim=c(0,0.5,round(max(data_output), digits=1)),
  poly.col=c(rgb(255/255, 215/255, 0, .8), rgb(0, 0, 1, .8)),
  line.col=c("black", "black"),
  lwd=1)
</code>
Adding more complexity shouldn't be that hard. The same_color indicates the proportion with the same colour. This gives a graph:

I guess you need to ask yourself what the seeker/hider means and how their colours depend. If you want to know if they change colours depending on some base colour information it shouldn't matter that you merge the two into one variable since the don't overlap. I find it easier to calculate the change in this way.
Comment: here's an example of the dataset: http://dl.dropbox.com/u/22681355/example.xls
I'm trying to summarize common patterns in the variables: decision as hider, decision as seeker. I'm interested in similarities in responses between participants in each condition (no.RED, 5, 7 , 9)
Comment: I've had quick look at the data, I think you need to start with how to group the data, I guess your interested in seeker/hider behaviour? I guess the question is: do they choose same or different color depending on their role? Your variable no.RED has in this sample no meaning since they are all 5. The questions you want to answer is the best place to start, what you describe is 4 different proportions and that is a fairly small amount of possibilities and is perhaps easiest displayed as bar charts.
Comment: there are 3 conditions for No. RED 5, 7 and 9 you just have to scroll down a bit, its separated with a few lines because I was doing some hand coding...but otherwise its pretty much what you're saying except that there are 3x4 conditions i.e 5,7,9 and no. green 1,2,3,4. still not sure though how to find common patterns and plot in bar charts. can you give a quick tutorial? thanks!
Comment: thanks for all the help! can you explain what you are doing when you define the variables org_colour and decision_colour ? are you aggregating the two variables and making it 1 and 2 instead of RED/BLUE? two things: one: colour from URN 1 and message received should not be aggregated because those are different things. two: can you also explain in words what you are doing? I really appreciate your help!
Comment: so what I'm interested in is common patterns in Decision as Hider and Decision as Seeker between participants and across conditions. For example did many Seeker's choose the same answers in the same condition?
Comment: It's hard for me to help you more but this should be enough to get you started. Only you know the true background to the data and I guess figuring out how to formulate your outcome is part of the research ;)


How to force DllMain to return true while having a loop?

Question: I am writing a dll and face this problem. While its working as intented, it never reaches to the point of return true, so the injector hangs.
Here is the code:
<code>BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
    case DLL_PROCESS_ATTACH:
        MessageBox(0, "all ok", "injection ok", 0);
        while(true){
            ..................}
        break;
    }
    return TRUE;
}
</code>
So, is there any way to return true even though I have to use an infinite loop?
Comment: By definition, an *infinite loop* never ends, so you can't *return* from it. Think about it. If you return, you're not in an infinite loop, and if you''re in an infinite loop you don't want to return. You don't do loops in DLLMain(). You use the absolute minimum code you need and then return.
Comment: Don't put code in DllMain.  It's holding a loader lock. See the warning here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682583(v=vs.85).aspx
Answer: If this is being injected use CreateRemoteThread and put your logic in the called function, you should never call anything from user32.dll (including MessageBox) from DllMain anyway.
Answer: It is impossible to return when you has a infinite loop. Why do you need to return ?
you can use DLL_PROCESS_ATTACH to know when to exit.
Answer: Setup a VOID routine (VOID meaning no return value) which you can invoke from your DllMain routine. The VOID routine will create a new thread and the thread will point to another routine which will handle execution of your main code-base. Meanwhile, you return back from DllMain and the new thread doesn't hold you up because you're on a different thread.
Whether you stay in DllMain or not is irrelevant, unless you switch threads to handle your infinite loop, the thread will be blocked from reaching the return point.
You can do this effortlessly with the documented CreateThread routine from the Win32 API. Thank me later.


Devise links / routes getting mixed up with non devise model

Question: I am using Devise in an app for the first time and I am having a weird problem I cant understand:
I've created my User model with Devise, and setup all the registration, user sign-up, etc, and everything works fine. In my application header, I have my nav menu (which is currently empty) and a partial with log in, sign out, etc:
_header.html.erb

        <%= link_to 'My app', root_path, :class => 'brand' %>

        <%= render 'layouts/user_options' %>

_user_options.html.erb

    <% if user_signed_in? %>

<%= link_to "Signed in as #{current_user.username}", '#' %>

<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>

    <% else %>

<%= link_to "Sign up", new_user_registration_path %>

<%= link_to "Sign in", new_user_session_path %>

    <% end %>

Now I am adding the first link to the nav menu, if I use:
<%= link_to 'Tasks', '/tasks/index'  %>

Everything is fine. BUT if I use:
<%= link_to 'Tasks', :controller => 'tasks', :action => 'index'  %>

When I click on any of the Devise links, such as 'Sign in', I get 'No route matches {:controller=>"devise/tasks"}'
By request on the comments, here is the output of rake routes:
Tasks: TOP => routes => environment
(See full trace by running task with --trace)
MacBook-Pro-de-o:dearsherpa Oscar$ bundle exec rake routes
             tasks_index GET    /tasks/index(.:format)         {:controller=>"tasks", :action=>"index"}
              tasks_show GET    /tasks/show(.:format)          {:controller=>"tasks", :action=>"show"}
        new_user_session GET    /users/sign_in(.:format)       {:action=>"new", :controller=>"devise/sessions"}
            user_session POST   /users/sign_in(.:format)       {:action=>"create", :controller=>"devise/sessions"}
    destroy_user_session DELETE /users/sign_out(.:format)      {:action=>"destroy", :controller=>"devise/sessions"}
           user_password POST   /users/password(.:format)      {:action=>"create", :controller=>"devise/passwords"}
       new_user_password GET    /users/password/new(.:format)  {:action=>"new", :controller=>"devise/passwords"}
      edit_user_password GET    /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
                         PUT    /users/password(.:format)      {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET    /users/cancel(.:format)        {:action=>"cancel", :controller=>"devise/registrations"}
       user_registration POST   /users(.:format)               {:action=>"create", :controller=>"devise/registrations"}
   new_user_registration GET    /users/sign_up(.:format)       {:action=>"new", :controller=>"devise/registrations"}
  edit_user_registration GET    /users/edit(.:format)          {:action=>"edit", :controller=>"devise/registrations"}
                         PUT    /users(.:format)               {:action=>"update", :controller=>"devise/registrations"}
                         DELETE /users(.:format)               {:action=>"destroy", :controller=>"devise/registrations"}
                    root        /                              {:controller=>"pages", :action=>"home"

and here is routes.rb:
  get "tasks/index"

  get "tasks/show"

  devise_for :users

  root :to => 'pages#home'

Why is this?? What I am doing wrong?
Edit2: By the way, I forgot mentioning that Task belongs_to User, and the User model has been generated by devise. Which probably is whats causing this. Can't I access /tasks/index without /user/id/tasks/?
Edit: more weird stuff, I tried using resources :tasks in my routes file, instead of the 'get' routes for that controller, and now when I click on <%= link_to 'Tasks', :controller => 'tasks', :action => 'index'  %> it takes me to the show action. So something is really wrong with my routes, apparently.
Comment: run: rake routes  and copy paste the result here.
Comment: can you post the code from routes.rb and run `rake routes` please?
Comment: You're routes were correct: heres the route                               tasks_index GET    /tasks/index(.:format)         {:controller=>"tasks", :action=>"index"} . Now show us the html generated by <%= link_to "Tasks", :controller => 'tasks', :action => 'index' %> and also <% link_to 'Tasks', tasks_index_path %>
Answer: The problem is with 'devise' namespace. When you use link creation this way:
<%= link_to 'Tasks', :controller => 'tasks', :action => 'index' %>

then the route is generated from the current namespace, which is 'devise' when you click any devise link.
To avoid this behavior, you can either use the route this way:
<%= link_to 'Tasks', :controller => '/tasks', :action => 'index' %>

or use helpers, which work correctly in this situation (tasks_index_path in case of 'get "tasks/index"' in routes.rb, or tasks_path in case of resources :tasks)
Comment: Sounds like a good solution, but could you clarify if this is a Devise specific problem or Rails standard behaviour? I've been working with Rails for a while now and never before came across this problem
Comment: That's common rails behaviour. Actually could not find a doc corresponding to this feature quickly, but tried it with the common user defined namespace - the routes work the same way as in your example


Error when trying to mount snapshot LVM (XFS filesystem)

Question: I have the following logical volume:
  --- Logical volume ---
  LV Path                /dev/wd1/mongodb
  LV Name                mongodb
  VG Name                wd1
  LV UUID                xxxx
  LV Write Access        read/write
  LV Creation host, time xxxx
  LV snapshot status     source of
                         mongodbSnap [active]
  LV Status              available
  # open                 1
  LV Size                8.00 GiB
  Current LE             2048
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

I used the command:
lvcreate --size 100M --snapshot --name mongodbSnap /dev/wd1/mongodb

to create the following snapshot:
  --- Logical volume ---
  LV Path                /dev/wd1/mongodbSnap
  LV Name                mongodbSnap
  VG Name                wd1
  LV UUID                xxx
  LV Write Access        read/write
  LV Creation host, time xxx
  LV snapshot status     active destination for mongodb
  LV Status              available
  # open                 0
  LV Size                8.00 GiB
  Current LE             2048
  COW-table size         100.00 MiB
  COW-table LE           25
  Allocated to snapshot  0.18%
  Snapshot chunk size    4.00 KiB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:7

Everything looks good at this point. However when I try to mount the snap lv volume with the following:

mount -t xfs /dev/wd1/mongodbSnap /mnt

I get the following error:
mount: wrong fs type, bad option, bad superblock on /dev/mapper/wd1-mongodbSnap,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

Update
The log message contains the following error:
[2424239.516667] XFS (dm-7): Filesystem has duplicate UUID xxxxxx - can't mount

Why would the snapshot contain the same UUID as the original lv and how do I get around this? The whole purpose of doing this is to make a backup of the drive using the dd command...
Solution to this is to mount the filesystem with nouuid option
mount -o nouuid <source> <dest>

Comment: Perhaps I'm misunderstanding, but you don't need to mount a block device before taking an image of it with dd. In fact, it's better to *not* mount it.
Comment: oh ok thanks for that EEAA i didn't realise that...i thought I had to mount it. What if i wanted to use tar to do an archive file backup though i would need to mount then right?
Comment: That's correct.
Answer:
There is no need to mount it for taking a backup with dd. Although dd is not recommended for XFS (see below for why), but if you insist using dd just use the snapshot LV device as the input parameter (if):
dd if=/dev/wd1/mongodbSnap of=/path/backup_of_mongodb_$(date -I).img

UUID is the filesystem's unique identifier which is stored within the filesystem metadata. When you take a snapshot of the LV, also this metadata is identical to the original LV in the snapshot LV and therefore they have the same UUID. However, note what XFS's manual page (locally man xfs or online e.g. here) says about its UUIDs:

  Each XFS filesystem is labeled with a Universal Unique Identifier
  (UUID).  The UUID is stored in every allocation group header  and
  is  used  to  help  distinguish  one XFS filesystem from another,
  therefore you should avoid using dd(1)  or  other  block-by-block
  copying programs to copy XFS filesystems.  If two XFS filesystems
  on the same machine have the same  UUID,  xfsdump(8)  may  become
  confused  when  doing  incremental and resumed dumps.  xfsdump(8)
  and xfsrestore(8)  are  recommended  for  making  copies  of  XFS
  filesystems.

TLDR: It's better to use xfsdump and xfsrestore.

Backing up with xfsdump:

Install xfsdump. E.g. in Ubuntu these tools can be installed from the xfsdump package:

apt install xfsdump

Take the dump:

xfsdump -f /path/backup_of_mongodb_$(date -I).xfsdump /dev/wd1/mongodb


mlx4 VF PF responsibilities - Query Mellanox

Question: I was going through the Mellanox driver (mlx4) and then I had difficulty understanding which portion of code corresponds to the one executed by the PF(Physical Function Driver) and which portion of code by (Virtual Function Driver) in the SRIOV mode.
My confusion is because, I was of the understanding that the QPs, CQs (and their creation, state mgmt commands) etc are to be performed by the virtual function driver(VF driver).
And the role of the physical function driver(PF driver) is to just take care of the resource_tracker.c and ICM allocation.
But of late, I think I may have understood wrong. This is because there is code that is specifically executed when mlx4_is_master is true/false( indicating PF or VF).
And then, there is code which is not surrounded by this test, which indicates it is executed in both cases(PF driver as well as VF driver).
Is my understanding correct? If yes, then are the QPs, CQs and ethernet tx, rx related functionality is executed both by master and slave?
Is there any way we can clearly separate the files that are used by PF vs the files that are used by VF in the (drivers/net/ethernet/mlx4 sub-directory)?
I would be really thankful and really appreciate all the help/clarification I can get in understanding this.
Thank you so much.
Best Regards,
Bob
Answer: If anyone is interested, this question was also posted and answered here:
http://linux-pci.vger.kernel.narkive.com/mxQuEb2w/mlx4-query-regarding-pf-vf-functionality-division


Login Exchange Office 365 in Office 2016 and from PC Active Directory

Question: i have some issue here.
i have domain Active Directory xxx.id and domain Office 365 abcd.com
in WORKGROUP PC i can login my email Office 365 using Office 2016.
and if i login my email from Office 365 using PC with Active Directory domain xxx.id it will show Error :https://prnt.sc/tf5sb4
is my PC with Active Directory canot login email using Office 365 in Office 2016 because different domain with Active Directory and Office 365?
Thankyou
Answer: Have you tried any solutions from these topics and articles?
Adding email 365 account - An encrypted connection to your mail server is not available. Already added others without issues.
Account Setup fails for Outlook.com accounts
Outlook Auto Account Setup: Encrypted Connection not available
Exchange - An encrypted connection to your mail server is not available
Answer: This issue may be caused by the Autodiscover-related registry data:
HKEY_CURRENT_USER\Software\Microsoft\Office\x.0\Outlook\AutoDiscover
Review the following possible DWORD values that may be located under the \Autodiscover subkey.
•   PreferLocalXML
•   ExcludeHttpRedirect
•   ExcludeHttpsAutoDiscoverDomain
•   ExcludeHttpsRootDomain
•   ExcludeScpLookup
•   ExcludeSrvRecord
•   ExcludeLastKnownGoodURL (only applies to Outlook 2010 version 14.0.7140.5001 and later versions)
•   ExcludeExplicitO365Endpoint (only applies to Outlook 2016 version 16.0.6741.2017 and later versions)
If the issue persist, you could test and solve Outlook problems with SARA
Support and Recovery Assistant is a new tool that helps users troubleshoot and fix issues with various Office 365 apps and services. The app diagnoses common Outlook issues like account setup, connectivity issues, password issues, or Outlook stops responding or crashes.
https://support.office.com/en-us/article/about-the-microsoft-support-and-recovery-assistant-e90bb691-c2a7-4697-a94f-88836856c72f?ui=en-US&rs=en-US&ad=US#/?env=ExRCA
https://social.technet.microsoft.com/Forums/Azure/en-US/9e2671d9-8de3-4965-b0fc-e210b7a33cd1/alternative-to-quotexcludescplookupquot-after-migration-to-office-365-for-business?forum=exchangesvrgenerallegacy
Comment: Is there any update on this thread? If the issue has been resolved, please mark the helpful replies as answers
Comment: Hello Jayce, sorry for late response.. i've try SARA in my PC and it like this for an hour https://prnt.sc/tkxish thankyou


group theory related modulo proof

Question: let $n$ be natural number $>1$. define  $[a] = \{b \in  Z :a \pmod n = b\}$ and $Z_{n}  = \{[x]:x \in Z\} $
define $[a] + [b] = [a+b]$ if $[x] = [y]$ , $[z] = [w]$,
prove $[x]+[z]=[y]+[w]$
don't know what it is asking of me
and the previous question is to prove that $Z_{n} = \{[0],[1]...[n+1]\}$ just in case it contains some sort of hint
Comment: Your definition of $[a]$ should be $[a] =\{b \in \mathbb{Z} \colon a \equiv b \pmod{n}\}$
Comment: yes it is . can you help me prove that Zn={[0],[1]...[n+1]}? I don't see what needs to be proved.
Answer: The question is asking you to show that this notion of addition is well-defined. That is, the act of addition doesn't depend on what representation of the object you use. So for example, we have that (say, $n = 10$)
$$[2] = [22]$$
and $$[3] = [-7]$$
but how do we know that $$[2] + [3] = [22] + [-7] ?$$
After all, just going from the definition, the thing on the left is $[5]$ while the thing on the right is $[15]$. But happily, we can show that $[5] = [15]$ in any number of ways - element chasing is the easiest.
So, as far as what you need to prove: You should start with any two representatives of the classes you're adding (such as $2$ and $22$) and prove that the sets you get out of the $+$ operation are the same for these two representatives.

group theory related modulo proof


Wpf Prism Modularity config

Question: Can i place my libraries in some where over the internet and load them from cloud each time the app runs instead of being placed beside the *.exe file ?
Answer: As far as I know, Prism does not provide the functionality to do this in desktop applications as out of the box. However, Prism allows you to extend its functionality by implementing your own versions for some of its components. For this particular case I believe you might need to create your own implementation of an IModuleTypeLoader that obtains the files from the cloud instead of the local file system. You can check the FileModuleTypeLoader implementation of Prism and use it as a starting point.

Wpf Prism Modularity config


How to Interprete Constant Intercept in Log Models?

Question: Even though this seems like an especially simple question, I am not 100% sure about what the constant in a log-log model, log-level, or level-log model means. For example, in
log(weight) = 8.29 - 0.0039(smoking) - .00037149(drinking).
I understand what the variables do to log(weight), but what does the intercept, 8.29, do? Does it = weight when the independent var.s are 0, or does it = log(weight), necessitating another step to figure out what (weight) by itself is?
Comment: Do you mean an intercept parameter that is estimated, or do you mean a term in the model that has a constant effect (an offset)? The former controls (estimated from the data) when the predicted log(weight) is zero and is much the same thing as an intercept in a linear model. The latter usually leads to a weight/exp(offset) interpretation for the model (e.g. events per time unit).
Comment: @Achim I mean an intercept that is estimated.  Still not sure what you mean by it being the same thing as in a linear model. Could you explain a but further? This is something that I have heard conflicting opinions about, even though I know what the math should ostensibly mean.
Answer: I write your estimated regression model as
$$ \text{weight} = C - \beta_1\cdot\text{smoking} - \beta_2\cdot\text{drinking}$$
Just exponentiate:
\begin{align}
   \text{weight} &= e^{C - \beta_1\cdot\text{smoking} - \beta_2\cdot\text{drinking} } \\
  &= e^C e^{-\beta_1\cdot\text{smoking}} e^{- \beta_2\cdot\text{drinking}}  \\
&=  e^C \left(e^{-\text{smoking}}  \right)^\beta_1   \left(e^{-\text{drinking}}  \right)^\beta_2
\end{align}
so the (additive) intercept in the logged model, corresponds to a (multiplicative) constant in the original multiplicative model.


highlighting text according to output of a text to speech. in Asp.net c#

Question: i am trying to highlight words read by the text to speech but its not working. until now i made:
    string startSpan = "";
    string endSpan = "";

 //button onclick
protected void speak_Hope(object sender, EventArgs e)
    {
            speaker.Rate = -4;
            speaker.SpeakAsync(announce.InnerText);
            speaker.SpeakProgress += new EventHandler<SpeakProgressEventArgs>    (speaker_SpeakProgress);
            System.Diagnostics.Debug.WriteLine("processing");

    }

void speaker_SpeakProgress(object sender, SpeakProgressEventArgs  e)
    {
        counter2 = e.CharacterPosition - 10;
        counter3 = e.Text.Length;
        counter4 = counter2 + counter3;
        System.Diagnostics.Debug.WriteLine(e.CharacterPosition - 10 + " next one" + e.Text);
        announce.InnerHtml = announce.InnerText.Substring(0, counter2) + startSpan + announce.InnerText.Substring(counter2, counter3) + endSpan + announce.InnerText.Substring( announce.InnerText.Length - 1);

    }

am i doing it right or is there any other way, can it be done in a javascript manner?
thanks alot
Comment: You show server side code, but then mention `` unless the page is posting back for every word read, or you are using a [WebBrowser Control](http://msdn.microsoft.com/en-us/library/aa752040%28v=vs.85%29.aspx), you will not be able to update the HTML.
Comment: Your `""` seems to be trying to escape the double quotes.  What it's actually ending up with is ``.  I think you want `""`, which produces ``.  I doubt this is related to your problem, just pointing out another issue.
Comment: What is not working?  Are you getting an error message or no output, or the event is not being fired, or?
Comment: there is no highlighting of the text in  the announcment "" but the offsets are written to the debugger console and variables change.
Comment: @TimS. thanks i will sort it out though too :)
Comment: @JoshuaDrake i will try and use webbrowser controls. do you have any idea if it can be done in javascript? thanks a million for you help :)
Comment: If you were to try it _in javascript_ you would need [Ajax](http://www.asp.net/ajax), so you can push the updates to the client.
Comment: @JoshuaDrake do you know a good tutorial on how to use webbrowser controls?
Comment: @AdrianDeBarro What type of project are you currently working in?  If you are building a web application / web site you are not going to be able to utilize SpeakRecognition, and based on your html code I'm concerned that this is what you're attempting.
Comment: @vpiTriumph     yes im part of a team of students, building a portal application, part of my job was to try and implement text to speech for the web site. can you tell me why pls?
Answer: In the case you are looking for text to speech this is a possible duplicate of this Stackoverflow Question.  That question provides the suggestion of using WebAnywhere, this provides speech to text without any additional downloads or special software.  Pretty cool!
However, it seems like you are actually looking to achieve speech recognition.  Based on your code you are heading down the wrong rabbit hole.  You are not going to be able to use the Microsoft Speech libraries to accomplish this goal (short on embedding them in an XBAP) and this is a result of them running on the server and not on the client side.
There are some Flash and Java based solutions that will indeed allow for client side voice recognition.  I suggest you explore them because I believe they achieve what you're looking for.
1) Speech API - Open source and their website includes a range of demos that I found to work quite well.
2) wami - Also open source
Comment: im not doing speech recognition but text to speech but i think i would have the same problem thought. but this morining i googled for alternatives and i found the speech API which is all written in javascript which you told me that it works quite well. therefore i think i will implement it in that way thanks alot for your time and patience :)
Comment: @AdrianDeBarro great, I'm glad you figured something out!  Do you mind either posting and accepting your own answer or accepting this one?  That way if someone has a similar question they can quickly decipher how your problem was solved.
Comment: do you have any idea how i can get the offset of current being read word from the speech api?


Topology on abelian groups

Question: Take $(G,+)$ an abelian additive group. I was looking for a proof or a counterexample of the following statement

For every family of subgroups $G_n, n \in \Bbb N$ such that $G_0=G$ and $G_{n+1} \subset G_n$ for all $n$, there exists a topology on $G$ such that $G_n$ is a neighbourhood base for the neutral element and $(G,+)$ is a topological group.
Comment: not necessary. I need only to know if this induces a topology
Answer: Yes, there always is such a topology, as is well-known. Go via uniformities (which is the standard way to look at topologies on a group): let $D_n = \{(x,y) \in G \times G \mid x-y \in G_n\}$ which is a translation invariant family of entourages which is nested and so it's a filter base and we take the uniformity generated by this filter base, call it $\mathcal{U}$. It's well-known that this induces a topology on $G$ which is  topological group (precisely as the $D_n$ are translation invariant) and which has the $G_n$ as a local base at $0$ (easy to see). It will be a separated uniformity (or equivalently a $T_1$ group) iff $\bigcap_n G_n = \{0\}$ and by the Birkhoff-Kakutani theorem in that latter case $G$ is metrisable in the uniform topology.
For a possible reference see (here, e.g.) or any good book on topological groups (Bourbaki is one).

Topology on abelian groups